all groups > dotnet performance > february 2005 >
You're in the

dotnet performance

group:

How to access Locals, Autos...programmatically?...



How to access Locals, Autos...programmatically?... G.Ashok
2/28/2005 11:26:06 PM
dotnet performance:
Hi All,

I'm posting this again!

How can I can access all of the debugger aids (like Autos, Locals, Me
(This), MemoryLists, Threads, Modules, Register) programmatically? I want to
use them in my program to log the exact picture of the error and its
condition like the values of the each variable etc. when an error occurs in
my program. While running my program I want to dump the memory contents to a
log file. At-least if I can access them while in development (Debug version)
of them program will also do.

I have posted this query several times on the various MS new groups. I
didn't a got a solution. However I got some fake replies (from MS/MVPS also)
pointing me to other direction (They don't undertsand the issue).

Thanks in advance.

Regards,
....Ashok

Re: How to access Locals, Autos...programmatically?... Sean Hederman
3/1/2005 7:26:57 AM
Removed cross-posting

[quoted text, click to view]

Strange. I searched the groups and only found one query, and you got a
correct response. The Systems.Diagnostics namespace is indeed the right
place to look for debugging information when inside .NET. Autos and Locals
are just categorisations of variables for you by the VS.NET IDE. .NET itself
knows abolutely nothing about Autos. Locals are local variables, and can be
logged like any other variable to your destination.

e.g. to Log this followed by the Locals:

int a = 10;
int b = 20;
int c = 30;
Debug.WriteLine("a = " + a.ToString());
Debug.WriteLine("b = " + a.ToString());
Debug.WriteLine("c = " + a.ToString());
Debug.WriteLine("this = " + a.ToString());

As I indicated before, Autos are merely a display of the variables the
debugger IDE thinks you'll find useful, and have no idependent existence.

[quoted text, click to view]

System.Diagnostics.Process contains information about the executing process,
including memory usage, handle information, and threads. Modules are merely
a way of an assembly to organize metadata, and don't have much debugging
value, but if you want this, it can easily be retrieved via Reflections.

In order to fetch detailed memory use information and register state, you'll
have to write your own debugger or find one that does what you want. A
debugger must run outside the Framework, and therefore cannot be included
into your application. Have a look at "C:\Program Files\Microsoft Visual
Studio .NET\FrameworkSDK\Tool Developers Guide\Samples\debugger" for a
debugger written in C++.

[quoted text, click to view]

It's probably a good idea not to denigrate the efforts of those who
sincerely try to help you, assuming you'll ever want help from them in the
future. Perhaps you didn't ask the question clearly enough, or perhaps you
didn't understand the answer. Even if they didn't understand the problem
calling them "fake" replies is frankly insulting. As I said, when I searched
the newsgroups, I found only one attempt at posting this, and it garnered a
short but correct answer.

[quoted text, click to view]

AddThis Social Bookmark Button