1

I use SOS.dll in VisualStudio to debug my C# program. The program is as below.

The debug command is !DumpStackObjects.

class Program
{
    static void Main()
    {
        Int32 result = f(1);
    }

    static Int32 f(Int32 i)
    {
        Int32 j = i + 1;
        return j;            <===========BreakPoint is here
    }
}

After I input the "!dso" command in the immediate window of Visual Studio, the result is as below:

OS Thread Id: 0xf6c (3948)

ESP/REG Object Name

Why there's nothing? I thought there should be the args i and local variable j.

Thanks for my answering my naive questions...

Community
  • 1
  • 1
smwikipedia
  • 61,609
  • 92
  • 309
  • 482

1 Answers1

3

!dumpstackobject dumps references on the stack to objects. I.e. you won't see value types with this command. Use !clrstack -l to see locals (use -p to see parameters, and -a for both).

Brian Rasmussen
  • 114,645
  • 34
  • 221
  • 317
  • Thanks, Brian. Is there any commands in the SOS.dll to get a list of varibales on stack? Do I have to use WinDbg? – smwikipedia Apr 09 '10 at 06:19
  • Keep in mind that locals/parameters may be stored in registers so for an optimized build you may not be able to see all the details - even in WinDbg. – Brian Rasmussen Apr 09 '10 at 06:38
  • Also, since you're loading SOS in VS, why not just use the Locals, Watch, or the Immediate window to watch locals? – Brian Rasmussen Apr 09 '10 at 06:42
  • Thanks Brian, your answer is very informative. I just want to view what's going on on the stack in the most native and primitive way. – smwikipedia Apr 09 '10 at 14:02
  • I have limited experience with SOS in VS, but I use it on a regular basis from WinDbg. You should also check out sosex.dll and psscor2.dll. – Brian Rasmussen Apr 09 '10 at 14:44
  • Thanks Brian for telling me about sosex.dll and psscor2.dll. I will try them. – smwikipedia Apr 13 '10 at 04:23