27

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.

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
merlin2011
  • 71,677
  • 44
  • 195
  • 329

2 Answers2

41

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

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
  • 1
    I wish VS wouldn't try to be so smart, and require the data type be known to see what's at the memory location. I'd rather it be a little dumb and just show me a hex dump at the memory location :P – SW_user2953243 Oct 30 '14 at 08:06
  • 6
    Well it has the Memory window for that already. Just drag and drop a variable there (or paste a hex address) and it will show you the raw memory state. – Neutrino Mar 23 '16 at 13:18
1

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.

Alan
  • 1,889
  • 2
  • 18
  • 30
peeyush
  • 2,841
  • 3
  • 24
  • 43
  • "In the Memory window Address box, type a pointer expression." What, exactly, is a pointer expression? Nothing I try works. – Dan Bechard Sep 13 '15 at 18:45
  • 1
    A pointer expression could be something like:`*(int*)(ebp+0ch)` .It treats ebp+0ch as a pointer to int and then dereference it. – Yuval Jan 01 '16 at 23:12