12

How can I view the Stack content (not the callstack) in Visual Studio 2013?


View to where ESP is pointing and below. Show content at char.

Thanks for the help.

1
  • already try this: stackoverflow.com/questions/23020232/… it not work for me. visual say it can't read the memory. I look for something built-in at visual studio if it exist.
    – Tal
    Commented Apr 24, 2014 at 17:48

3 Answers 3

16

You can do this by going to Debug > Windows > Registers, get the location of ESP, and then enter this address in a Debug > Windows > Memory window. However, that will only give you the raw memory.

As OwenWengerd points out in the comments, you can simply type ESP in the address field if you're debugging native code. For some reason, this doesn't work for managed code though.

4
  • 10
    It's not necessary to get the value of ESP from the Registers window. Just enter ESP in the Memory window's address field and the debugger will resolve its current value. Commented Apr 25, 2014 at 4:28
  • @OwenWengerd I tried to find a shortcut like that but couldn't locate it. When I type ESP in the memory window's address field I get "unable to evaluate the expression". What's the exact syntax? Commented Apr 25, 2014 at 15:19
  • @Brian The exact syntax is ESP, then <Enter> to evaluate it. You have to be debugging native code at the time, otherwise I don't know why it wouldn't work for you. Commented Apr 25, 2014 at 19:56
  • @OwenWengerd Ah that explains it. I was looking at managed code. Thanks for the update. Commented Apr 25, 2014 at 19:57
6

You may recreate what some older DOS debuggers had like Turbo Debug, with an arranged memory pane:

  1. Open a memory pane.
  2. In the context menu, select 4-bytes integer (resp. 8-bytes) for a 32-bit stack (resp. 64-).
  3. Select 1 column (or reduce the width of the pane to let only 1 column appear, whatever suits you best; also you might want to display this narrow pane under your solution explorer where it'll almost naturally have a single column)
  4. Enter esp (resp. rsp) in the address bar.
  5. Click on the refresh button so that the address bar reevaluates on each step.

If debugging at assembly level and stepping through some PUSHes and POPs, you should see the memory pane keep in sync.

Note: this was written with x86 or amd64 architectures in mind which aren't the only supported by VS. If you're on another architecture, adapt what you read to your CPU's own specifics i.e., open the register pane to find out your own stack pointer register name.

1
  • 1
    This should be the actual marked answer
    – Lorenzo
    Commented Jun 26, 2022 at 18:17
3

The other answer is correct for 32-bit code, however it is only "half-correct" for 64-bit code.

If you really want to see the memory at esp, then you can enter esp in the Address input box in the Memory debug window.

However, this is probably not what you want for 64-bit code. The stack is at rsp not esp.

If you enter rsp into the Address input textbox in the Memory debug window then you will see the stack memory. If you enter esp into the Address input textbox then you will see the memory at (rsp & 0x00000000ffffffff), which is probably not what you want.

Not the answer you're looking for? Browse other questions tagged or ask your own question.