Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to watch the value of a memory location using the Visual Studio Debugger's Watch window?

Yes, I know there are four Memory windows, but I much prefer the display of a single value in the watch window, and I'm wondering if it's possible to specify a memory location to watch in the watch window.

Putting the address by itself just evaluates to the address in hex.

like image 243
merlin2011 Avatar asked Apr 05 '12 06:04

merlin2011


People also ask

How do I see memory values in Visual Studio?

Under Debug > Windows > Memory, select Memory 1, Memory 2, Memory 3, or Memory 4. (Some editions of Visual Studio offer only one Memory window.)


2 Answers

If you want to watch a particular memory location then you need to tell the debugger the type of the object that lives in that location. Instead of just 0x00aabbcc use (SomeType*)0x00aabbcc. Once the debugger knows the type of the memory location it will treat it just like a typed local and display values accordingly

like image 192
JaredPar Avatar answered Oct 21 '22 13:10

JaredPar


Check the official site answer, which works as well as the other answers given to this question :). On that page, the section "Following a Pointer Through Memory" says:

In native code applications, you can use register names as live expressions. For example, you can use the stack pointer to follow the stack.

To follow a pointer through memory

  1. In the Memory window Address box, type a pointer expression. The pointer variable must be in the current scope. Depending on the language, you might have to dereference it.

  2. Press ENTER. Now, when you use an execution command such as Step, the memory address that is displayed will automatically change as the pointer changes.

like image 43
peeyush Avatar answered Oct 21 '22 14:10

peeyush