4 Replies Latest reply on Jun 17, 2020 4:55 PM by NoTa_4591161

    Memory dump for VSCODE

    NoTa_4591161

      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

        • 1. Re: Memory dump for VSCODE
          RakshithM_16

          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 · GitHub

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

           

          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 -

           

          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 -

           

          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 -

           

          Please let me know if this works.

           

          Thanks and Regards,

          Rakshith M B

          • 2. Re: Memory dump for VSCODE
            NoTa_4591161

            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

            1 of 1 people found this helpful
            • 3. Re: Memory dump for VSCODE
              RakshithM_16

              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 -

               

              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

              • 4. Re: Memory dump for VSCODE
                NoTa_4591161

                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