Memory dump for VSCODE

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi,

How can I see the memory dump with VSCODE?

I export a project from mtb2.1 for vscode but cannot see the memory window.

Visual Studio Code Tips and Tricks are described as below, but what should I do specifically?

Memory dump debugging

The C/C++ extension for VS Code also has the ability to debug memory dumps. To debug a memory dump, open your launch.json file and add the coreDumpPath (for GDB or LLDB) or dumpPath (for the Visual Studio Windows Debugger) property to the C++ Launch configuration, set its value to be a string containing the path to the memory dump. This will even work for x86 programs being debugged on an x64 machine

Thanks,

Kenshow

Memory dump debugging

The C/C++ extension for VS Code also has the ability to debug memory dumps. To debug a memory dump, open your launch.json file and add the coreDumpPath (for GDB or LLDB) or dumpPath (for the Visual Studio Windows Debugger) property to the C++ Launch configuration, set its value to be a string containing the path to the memory dump. This will even work for x86 programs being debugged on an x64 machine

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi NoTa_4591161​,

I export a project from mtb2.1 for vscode but cannot see the memory window.

I checked online and found that vscode does not have support for memory window.

Reference Links -

Question: How to display memory during a debug session · Issue #1503 · microsoft/vscode-cpptools · G...

https://stackoverflow.com/questions/38557168/does-vs-code-have-a-memory-viewer-and-or-a-disassembler...

So a workaround would be to use the 'x <address>' gdb command as suggested in those links.

Once you start debugging, go to your DEBUG CONSOLE and type in the command.

For example, I have created a variable - variable_dummy, initialized the variable to 8 and in the .map file I got the address of the variable as 0x080023a8. So, in the DEBUG CONSOLE I used the command x 0x080023a8 as shown -

pastedImage_5.png

Along with this, you can check all the local and global variables in the VARIABLES section. You can also add these variables to watch in the WATCH section as shown -

pastedImage_6.png

To view the Core registers and the peripheral registers you can follow the steps mentioned below. This is an extrapolation of DheerajK_81​'s response in the thread - GPIO registers are not displayed in memory window Re: GPIO registers are not displayed in memory window

1. Open the launch.json file present inside .vscode folder

2. Search "svdFile" and add the path to the SVD file. Please refer to Dheeraj's response to know the path to SVD file.

3. So your svdFile file configuration should be similar to -

// svdFile is optional, it can be very large.

"svdFile": "C:/MTB_Workspace/mtb_02_ex07_i2c_brightness_control/libs/psoc6pdl/devices/svd/psoc6_01.svd",

Now when you debug the device, you should be able to view the registers as shown -

pastedImage_14.png

Please let me know if this works.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B

View solution in original post

0 Likes
4 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi NoTa_4591161​,

I export a project from mtb2.1 for vscode but cannot see the memory window.

I checked online and found that vscode does not have support for memory window.

Reference Links -

Question: How to display memory during a debug session · Issue #1503 · microsoft/vscode-cpptools · G...

https://stackoverflow.com/questions/38557168/does-vs-code-have-a-memory-viewer-and-or-a-disassembler...

So a workaround would be to use the 'x <address>' gdb command as suggested in those links.

Once you start debugging, go to your DEBUG CONSOLE and type in the command.

For example, I have created a variable - variable_dummy, initialized the variable to 8 and in the .map file I got the address of the variable as 0x080023a8. So, in the DEBUG CONSOLE I used the command x 0x080023a8 as shown -

pastedImage_5.png

Along with this, you can check all the local and global variables in the VARIABLES section. You can also add these variables to watch in the WATCH section as shown -

pastedImage_6.png

To view the Core registers and the peripheral registers you can follow the steps mentioned below. This is an extrapolation of DheerajK_81​'s response in the thread - GPIO registers are not displayed in memory window Re: GPIO registers are not displayed in memory window

1. Open the launch.json file present inside .vscode folder

2. Search "svdFile" and add the path to the SVD file. Please refer to Dheeraj's response to know the path to SVD file.

3. So your svdFile file configuration should be similar to -

// svdFile is optional, it can be very large.

"svdFile": "C:/MTB_Workspace/mtb_02_ex07_i2c_brightness_control/libs/psoc6pdl/devices/svd/psoc6_01.svd",

Now when you debug the device, you should be able to view the registers as shown -

pastedImage_14.png

Please let me know if this works.

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi Rakshith,

Thank you very much for your solution.

I checked your suggestion. Everything worked.

I have additional information how to display with WATCH section.

It can also be described as follows:

*(int(*)[10])(0x40320000),h

Unfortunately, the data is not displayed as hexadecimal, but as decimal in my VSCODE. if you have any idea to solve it, please let me know.

Thanks,

Kenshow

Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi Kenshow-san,

Thank you for sharing the information!

I tried to find out a way to display the values in hexadecimal. The responses in various vscode git issues worked only with one memory location. An array of memory was still displayed in decimal.

One workaround might be to use the gdb command again. I used the command "x/16x 0x80023a8" in the console. It displays 16 x 32bits data. You can check this link for information regarding this command - https://visualgdb.com/gdbreference/commands/x

The main disadvantage with this is that you will have to type the command every time you want to read the memory.
So, I was trying to add the command to a handle which will be called each time the debugger is paused. I put the command in overrideLaunchCommands in launch.json file and the memory values were displayed each time the debugger was launched as shown -

pastedImage_4.png

I searched online and in the VSCode IntelliSense suggestions for the handle called on debugger pause (during step, breakpoint, etc) but I was not able to find one. What I am searching for is something similar to "onPauseCommands". Please let me know if you are aware of a way to do this. Meanwhile, I will check with the internal teams if they have any suggestions or if they are aware of any other methods. As this is a VSCode feature, I cannot assure you of a viable workaround.

Hope this helps,

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes
Kenshow
Level 8
Level 8
Distributor - Marubun (Japan)
50 solutions authored 25 solutions authored 10 solutions authored

Hi Rakshith-san,

Thank you for your research and information sharing.

I was able to get very fruitful information about debugging of VSCODE from you.

Thanks,

Kenshow

0 Likes