Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error display variable value/type

390 views
Skip to first unread message

George

unread,
Jul 6, 2008, 8:16:01 AM7/6/08
to
Hello everyone,


I am using the following commands in Windbg to debug the following simple
application, why there is error like, "Note: this object has an invalid CLASS
field
Invalid object"?

[Code]
0:004> ~0e!clrstack -a
OS Thread Id: 0x1194 (0)
Child-SP RetAddr Call Site
RSP/REG Object Name
RSP/REG Object Name
RSP/REG Object Name
RSP/REG Object Name
RSP/REG Object Name
000000000012efe0 0000064280150182 TestDebugManaged1.Program.foo()
PARAMETERS:
this = 0x0000000002651ac8
LOCALS:
0x000000000012f000 = 0x0000000000000064
0x000000000012f004 = 0x0000000000000001

RSP/REG Object Name
000000000012f020 000006427f67d4a2
TestDebugManaged1.Program.Main(System.String[])
PARAMETERS:
args = 0x0000000002651aa8
LOCALS:
0x000000000012f040 = 0x0000000002651ac8

0:004> !do 0x000000000012f000
<Note: this object has an invalid CLASS field>
Invalid object

0:004> !do 0x000000000012f004
<Note: this object has an invalid CLASS field>
Invalid object

namespace TestDebugManaged1
{
class Program
{
void foo()
{
int a = 100;
while (true)
{
Thread.Sleep(10000);
a++;
}
}

static void Main(string[] args)
{
Program instance = new Program();
instance.foo();
return;
}
}
}
[/Code]


thanks in advance,
George

Brian Rasmussen [C# MVP]

unread,
Jul 8, 2008, 3:02:32 PM7/8/08
to
To display a value type you need use the !dumpvs command and to provide the
method table for that type. Use the !name2ee command to locate the method
table. E.g. if you need to find the method table for an int you can do a

!name2ee *!System.Int32.

That will give you something like

Module: 790c2000 (mscorlib.dll)
Token: 0x020000c2
MethodTable: 79102290
EEClass: 79102218
Name: System.Int32
...

Use the !dumpvc command with the method table just obtained to dump the
value of a specific value type.

--
Regards,
Brian Rasmussen [C# MVP]
http://kodehoved.dk

"George" <Geo...@discussions.microsoft.com> wrote in message
news:E76E8550-D9A0-4577...@microsoft.com...

George

unread,
Jul 8, 2008, 9:54:01 PM7/8/08
to
Thanks Brian,


I have tried your solution works! Cool!! Two more comments,

1.

How do you know whether it is a value type or reference type from clrstack
-a output? Or something else command which could check value or reference
type of a variable?

2.

I have used name2ee before to find the method table, then set break point
using bpmd on the specific method in the method table.

My current confusion is, I just want to get the value of a variable, it is
"value", and why it deals with "method" table? Is it because the "value" is
internally implemented as a method (property)?


regards,
George

Brian Rasmussen [C# MVP]

unread,
Jul 9, 2008, 8:48:27 AM7/9/08
to
George wrote:
> Thanks Brian,
>
>
> I have tried your solution works! Cool!! Two more comments,
>
> 1.
>
> How do you know whether it is a value type or reference type from clrstack
> -a output? Or something else command which could check value or reference
> type of a variable?

As far as I'm aware, you can't tell that from !clrstack -a. However,
often you will know this because the type is either your own or a well
known type from the BCL. If you don't know look at the VT column of the
output for !do - a "1" indicates a value type.


>
> 2.
>
> I have used name2ee before to find the method table, then set break point
> using bpmd on the specific method in the method table.
>
> My current confusion is, I just want to get the value of a variable, it is
> "value", and why it deals with "method" table? Is it because the "value" is
> internally implemented as a method (property)?
>

I can't tell you why it's called a "method table", but it may help to
think of it as a type instead.

Value types are stored by storing the actual value on the stack / heap
so there's no method call involved in retrieving the value.


--
Regards,
Brian Rasmussen [C# MVP]

kodehoved.dk

George

unread,
Jul 10, 2008, 11:03:00 PM7/10/08
to
Great Brian!


I have tried name2ee just now and find some strange output. Do you know what
is wrong?

0:000> !name2ee *!TestDebugManaged1.Program
Module: 0000064278854000 (mscorlib.dll)
--------------------------------------
Module: 0000064280012e20 (TestDebug.exe)


Code,

namespace TestDebugManaged1
{
class Program
{
public void foo()


{
int a = 100;
while (true)
{
Thread.Sleep(10000);
a++;
}
}

static void Main(string[] args)
{
Program instance = new Program();
instance.foo();
return;
}
}
}


regards,
George

0 new messages