tags:

views:

38

answers:

1

How can I determine if the local variable is a value type or a reference type?

0:000> !CLRStack -a
OS Thread Id: 0xf74 (0)
Child-SP RetAddr Call Site
000000000023e9c0 000007fef6b32012 ConsoleApplication2.Program.Main(System.String[])
PARAMETERS:
args = 0x00000000028f3c70
LOCALS:
0x000000000023e9e0 = 0x0000000000000000
0x000000000023e9e8 = 0x00000000028f3c90
0x000000000023e9f0 = 0x00000000000493e0

A: 

The easiest way to identify is using sosex extension. The command !mk -l can give you the memory address as well as the type. Here is an example where s is a struct and c is class

0a:M 002aec64 004700f3 ConsoleApplication1.Program.Main(System.String[])(+0x27 IL)(+0x83 Native) [C:\Users\nsrinivasan\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs, @ 90,17]
     [L0]:s:VALTYPE (MT=001a3884, ADDR=002aec70) (MyStruct)
     [L1]:c:0x0276c098 (MyClass)

Also sosex has some cool things that sos lacks.

Naveen