Bind Debugger

The debugger can be used to run a bind rules against a particular device. It outputs a trace of the bind rules's execution, describing why the driver would or would not bind to the device.

You can run the debugger in the following ways:

  • As a host tool. You provide the bind rules source file and a file listing the properties of the device. This is useful during bind rules development for testing the outcome of the rules against different combinations of node properties.
  • On the target device. You specify the driver path and the device path within the system. This is useful for figuring out why a driver did or did not bind to a particular device.

Running the debugger as a host tool

You can run the debugger with the --debug option in the bind compiler.

fx bindc debug \
  --include src/devices/bind/fuchsia.usb/fuchsia.usb.bind \
  --debug tools/bindc/examples/ \

The bind rules source and the library sources are in the formats described in the bind rules and bind libraries sections, respectively. The --debug option takes a file containing a specification of the device to run the bind rules against.

Device specification file

The debugger takes a file specifying the device to run against the bind rules. This specification is simply a list of key-value pairs describing the properties of the device.


This example device specification can be found at //tools/bindc/examples/

fuchsia.BIND_USB_VID = fuchsia.usb.BIND_USB_VID.REALTEK


device-specification = ( property )* ;

property = compound-identifier , "=" , value ;

compound-identifier = IDENTIFIER ( "." , IDENTIFIER )* ;

value = compound-identifier | STRING-LITERAL | NUMERIC-LITERAL | "true" | "false" ;

An identifier matches the regex [a-zA-Z]([a-zA-Z0-9_]*[a-zA-Z0-9])?.

A string literal matches the regex ”[^”]*”, and a numeric literal matches the regex [0-9]+ or 0x[0-9A-F]+.

The bind compiler will ignore (treat as whitespace) any line prefixed by //, and any multiple lines delimited by /* and */.

Running the debugger on the target device

The debugger is run using its package URL. For example:

ffx driver debug-bind /system/driver/ class/bt-transport/000

The command takes the path of the driver to debug and the path of the device to debug it against.

Device path

There are two ways to specify the device:

  • Its path within /dev/class, e.g. class/bt-transport/000.
  • Its topological path, e.g. sys/platform/pci/00:14.0/xhci/usb-bus/003/003/ifc-000/bt_transport_usb.

Both of the paths are relative to /dev/.

The topological path can be determined from the output of driver dump. For example, tracing the path to the node [bt_transport_usb] in the output below gives the topological path sys/platform/pci/00:14.0/xhci/usb-bus/003/003/ifc-000/bt_transport_usb.

   <root> pid=3456
      [null] pid=3456 /boot/driver/
      [zero] pid=3456 /boot/driver/
      <misc> pid=3525
         [demo-fifo] pid=3525 /boot/driver/
         [ktrace] pid=3525 /boot/driver/
      <sys> pid=3369 /boot/driver/
         [pci] pid=3369 /boot/driver/
            [00:00.0] pid=3369 /boot/driver/
            [00:14.0] pid=3369 /boot/driver/
               <00:14.0> pid=4384 /boot/driver/
                  [xhci] pid=4384 /boot/driver/
                     [xdc] pid=4384 /boot/driver/
                     [usb-bus] pid=4384 /boot/driver/
                        [001] pid=4384 /boot/driver/
                           [001] pid=4384 /boot/driver/
                              [ifc-000] pid=4384 /boot/driver/
                                 [usb-hid] pid=4384 /boot/driver/
                                    [hid-device-000] pid=4384 /boot/driver/
                        [002] pid=4384 /boot/driver/
                           [002] pid=4384 /boot/driver/
                              [ifc-000] pid=4384 /boot/driver/
                                 [usb-hid] pid=4384 /boot/driver/
                                    [hid-device-000] pid=4384 /boot/driver/
                        [003] pid=4384 /boot/driver/
                           [003] pid=4384 /boot/driver/
                              [ifc-000] pid=4384 /boot/driver/
                                 [bt_transport_usb] pid=4384 /boot/driver/
                                    [bt_hci_intel] pid=4384 /system/driver/
                                       [bt_host] pid=4384 /system/driver/

It should be noted that if driver framework version 2 (DFv2) is enabled, the node's topological path can't be determined from its place in the node graph.

Debugger output

The output of the debugger is a trace of the bind rules' evaluation. The trace contains information about whether each statement in the bind rules succeeded, and why or why not. For example, if a condition statement failed because the device did not have the required value, the debugger will output what the actual value of the device was (or the fact that the device had no value for that property). The trace also includes information about which branches were taken in if statements.


The output of the debugger when running the host tool command above is:

Line 4: Condition statement succeeded: fuchsia.BIND_PROTOCOL == fuchsia.usb.BIND_PROTOCOL.INTERFACE;
Line 6: If statement condition failed: fuchsia.BIND_USB_VID == fuchsia.usb.BIND_USB_VID.INTEL
    Actual value of `fuchsia.BIND_USB_VID` was `fuchsia.usb.BIND_USB_VID.REALTEK` [0xbda].
Line 9: If statement condition succeeded: fuchsia.BIND_USB_VID == fuchsia.usb.BIND_USB_VID.REALTEK
Line 11: Accept statement succeeded.
    Value of `fuchsia.BIND_USB_CLASS` was `fuchsia.usb.BIND_USB_CLASS.VIDEO` [0xe].
Driver binds to device.

If you run the debugger on the Fuchsia target device, you will see similar output information. However, information such as identifiers and source code snippets may be missing, since the system only stores the bind rules bytecode, not the source code.

The trace shows the outcome of each statement that was reached while executing the bind rules:

  • The device has the USB device protocol, so the first condition statement is satisfied.
  • The device's vendor ID is REALTEK, so the second branch of the if statement is taken.
  • The device has one of the two accepted classes (video), so the accept statement is satisfied.

The debugger outputs that the driver would successfully bind to a device with these properties.