Debugging example components

There are two ways to attach a debugger to example components:

The Fuchsia debugger is called zxdb. Once attached, you can follow this reference for common zxdb workflows.

Attaching a debugger from the CLI

  1. Connect the debugger to your Fuchsia device, for example the emulator started before running an example.

    $FUCHSIA_EMBEDDER_DIR/tools/ffx debug connect
    

    When successful, this should start a [zxdb] prompt.

  2. From the [zxdb] prompt, attach to embedder.cm and add a breakpoint to main:

    [zxdb] attach embedder.cm
    [zxdb] break main
    
  3. In a separate terminal, run an example component. The debugger should detect the running component, attach to it and break on the main function.

    $FUCHSIA_EMBEDDER_DIR/scripts/build_and_run_example.sh hello_flutter
    

Attaching a debugger from VSCode

Requirements

  1. Install the Fuchsia VSCode extension.

  2. Set the “Ffx Path” setting for this extension to the output from this command:

    echo $FUCHSIA_EMBEDDER_DIR/tools/ffx
    

    For example:

    ffx path configuration in vscode

  3. Make sure the target for the Fuchsia extension is set to fuchsia-emulator.

    target set to fuchsia-emulator

Running an example from VSCode

The examples can be run from VSCode's Run and Debug menu. Breakpoints that are added to the code should be triggered.

Running example from run and debug menu

There are several options:

Future improvements

  • Document how to step into Fuchsia SDK code.
  • Figure out how to step into Flutter Engine code.