How to watch variables

nRF Connect for VS Code

tags
nRF Connect for VS Code

During debugging, you can add variables and symbols to the Watch View list.

To start watching a variable from code:

  1. Click and drag the mouse cursor to highlight the variable in your code.
  2. Right-click and choose Add to Watch.
    The Watch View list is updated with the variables you added, like in the following example.

    Example of the Watch View with a list of variables

  3. Click the Start/Continue button in the debugging control bar to watch the debugger go through the code until it stops at a variable breakpoint.
    The value of the watched variables is shown in the Watch View.

To start watching a variable from Global Data View:

  1. Locate the variable you want to watch in the Global Data View.

    Tip

    Use the View's toolbar actions to choose how you want to group the variables.

  2. Click the variable to select it.

  3. Click the Add Symbol to Watch button.

    Add to Watch button in the Global Data View

    The variable is added to the Watch View list.

    Example of the Watch View with callback_list added

  4. Click the Start/Continue button in the debugging control bar to watch the debugger go through the code until it stops at a variable breakpoint.
    The value of the watched variables is shown in the Watch View.