Start the Fuchsia debugger ([zxdb][fuchsia-debugger]) in VS Code and debug the sample component, which is now updated to crash when it runs.

The tasks include:

  • Set a breakpoint in the source code.
  • Start the Fuchsia debugger.
  • Step through the code.

In VS Code, do the following:

  1. Select the src/hello_world/hello_world.cc file from the OPEN EDITORS view at the top of VS Code.

  2. To set a breakpoint at the main() method, click the space to the left of the line number.

    Breakpoint{: .screenshot width=“500”}

    When a breakpoint is set, a red dot appears.

  3. Click Run > Start Debugging.

    This starts a debug session that launches the hello_world component. The debugger then pauses at the line where the breakpoint is set in the src/hello_world/hello_world.cc file.

  4. Click the DEBUG CONSOLE tab on the VS Code panel.

    Debug console{: .screenshot}

    This shows the console output of the Fuchsia debugger (zxdb).

  5. Click the FUCHSIA LOGS tab on the VS Code panel.

  6. At the top right corner of the FUCHSIA LOGS panel, click the Clear logs icon.

  7. In the Filter logs text box, type hello_world and press Enter.

  8. In the debug toolbar at the top of VS Code, click the Step Over icon.

    Step over{: .screenshot width=“250”}

  9. In the FUCHSIA LOGS panel, verify that a new Hello again, World! entry is printed in the logs.

    Hello again{: .screenshot}

  10. In the debug toolbar at the top of VS Code, click the Stop icon.

    This causes the component to finish the execution of the rest of the code.