views:

42

answers:

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...

+3  A: 

!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
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
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
Also, since you're loading SOS in VS, why not just use the Locals, Watch, or the Immediate window to watch locals?
Brian Rasmussen
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
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
Thanks Brian for telling me about sosex.dll and psscor2.dll. I will try them.
smwikipedia