0

I use this website to debug small programs. And it shows in a clear way what's happening with memory on each step. Like on the screenshot. enter image description here

In VScode I only know how to write an expression for each element of the array str[i]; and watch it. It shows zeroes in cells only this way. But I don't want to write an expression for each element every time I need to watch the whole array. And VScode while debugging (lldb) by default doesn't show allocated memory if i didn't write something there, or they are containing zeroes.

So is there any way to watch memory as on screenshot in VScode or CLion?

kukinpower
  • 45
  • 1
  • 1
  • 7
  • 1
    Read [*how to debug small programs*](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/). Learn to use a good debugger, such as [GDB](https://www.gnu.org/software/gdb/). You might be interested in its [DDD](https://www.gnu.org/software/ddd/) front-end; enable all warnings and debug info in your C compiler: with [GCC](http://gcc.gnu.org/) compile [with](https://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html) `gcc -Wall -Wextra -g` – Basile Starynkevitch Jun 09 '20 at 04:55
  • "watch" is an overloaded word. Some people use it to mean opening a window on memory that updates as you step. The formal meaning is "use hardware assisted data watch features of your processor to inform you when memory changes." Which of these are you trying to do? – Jim Ingham Jun 10 '20 at 17:08
  • @JimIngham I meant: watching how memory updates as I step – kukinpower Jun 11 '20 at 03:54

1 Answers1

0

The internet seems to agree that VSCode does not have a memory viewer, but CLion does seem to:

https://www.jetbrains.com/help/clion/memory-view.html

You can also view memory in the console window using the lldb memory read command. Do help memory read for more details.

You can also add a "stop-hook" using the target stop-hook add. Stop-hooks get run every time the debugger stops and returns control to the user. See help target stop-hook add for more details on how to use that command.

So just add a new stop-hook with your memory read command, and it will dump to the console at the end of each step or next.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63