VSCode Debugging

Debugging tricks in VSCode.

Memory Addresses on Macs

If you want to watch the memory address of a variable x on a mac, you can't use just &x. You need to surround the address of request with ${ } like this:

${&x}

Show String in Detail

To see all the characters in a string s listed with their index, add a watch that looks like:

(char*) STRING_NAME, SIZE

Here is an example of viewing 11 characters from the string s:

Watching "(char*) s, 11"

Show an Array

The debugger will show the contents of a statically allocated array when the array is viewed in its original context.

When an array is passed into another function, or when an array is allocated dynamically, the debugger doesn't know how many elements there are. So you usually will just be shown the first element. To see the rest, use the instructions below:

PC

Add a watch that looks like:

ARRAY_NAME, SIZE

Here a watch is showing 3 elements from the array named array. Notice that the Locals pane just shows the first value from the array (5).

Watching "array, 3"

Mac

To see the contents of your array, you need to add a Watch with the following syntax:

ARRAY_NAME,[SIZE]

So to watch the array pages if it is 10 items long, you would use:

pages,[10]

Note that you cannot use a space on either side of the comma.