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:
In VS Code, do the following:
Click the Run and Debug icon on the left side of VS Code.
{: .screenshot width=“400”}
Click the Show all automatic debug configurations link.
This opens the Command Palette and displays a list of launch configurations.
In the Command Palette, click Add Config (fuchsia-getting-started)....
Click zxdb.
This opens the .vscode/launch.json file.
Update this launch.json file to the following configuration:
"configurations": [ { "name": "{{ '<strong>' }}Fuchsia getting started{{ '</strong>' }}", "type": "zxdb", "request": "launch", "launchCommand": "{{ '<strong>' }}tools/bazel run //src/hello_world:pkg.component{{ '</strong>' }}", "process": "{{ '<strong>' }}hello_world{{ '</strong>' }}" } ]
This configuration is set to start the hello_world component and attach the debugger to it.
To save the file, press CTRL+S (or Command+S on macOS).
Select the src/hello_world/hello_world.cc file from the OPEN EDITORS view at the top of VS Code.
To set a breakpoint at the main() method, click the space to the left of the line number.
{: .screenshot width=“500”}
When a breakpoint is set, a red dot appears.
At the top of the Run and Debug panel, select the Fuchsia getting started option in the dropdown memu.
At the top of the Run and Debug panel, click the Play icon to launch the debugger.
{: .screenshot width=“400”}
This builds and runs the hello_world component, which causes the debugger to pause at the line where the breakpoint is set in the src/hello_world/hello_world.cc file.
Click the DEBUG CONSOLE tab on the VS Code panel.
{: .screenshot}
This shows the console output of the Fuchsia debugger (zxdb).
Click the FUCHISA LOGS tab on the VS Code panel.
In the Filter logs... text box, type hello_world and press Enter.
You may see some Hello, World! and Hello again, World! entries from the previous sections. However, you can ignore those entries.
At the top right corner of the FUCHSIA LOGS panel, click the Clear logs icon.
In the debug toolbar at the top of VS Code, click the Step Over icon.
{: .screenshot width=“300”}
In the FUCHSIA LOGS panel, verify that a new Hello again, World! entry is printed in the logs.
{: .screenshot}
To exit the debugger, click the Stop icon in the debug toolbar.
This causes the component to finish the execution of the rest of the code.