DCSIMG
CLR Stack Explorer – Preview - All Your Base Are Belong To Us

All Your Base Are Belong To Us

Mostly .NET internals and other kinds of gory details

CLR Stack Explorer – Preview

Synopsis: CLR Stack Explorer obtains reliable call stacks of managed processes, supports any combination of 32-bit/64-bit and CLR2/CLR4.

UPDATE [2011/7/20]: If you downloaded CLR Stack Explorer from the above link and are using a recent Windows version, you need to Unblock all the .exe files (right-click, Properties, Unblock) for the tool to run correctly. I have just updated the download location with a self-extracting executable which should solve this problem.

I’m happy to announce that CLR Stack Explorer, a tool I’ve been working on during the last few days, is now ready for preview. Frankly, I have Managed Stack Explorer to thank for this little project – its lack of support for CLR 4 has encouraged me to embark on this journey.

You can find the bits here – but please remember this is a very early preview with probably lots of bugs. Your process may crash as a result of using this tool to view its call stacks.

This is the basic experience when using CLR Stack Explorer:

image

The tool consists of several components:

  • C++/CLI assembly which contains the necessary interactions with the unmanaged CLR Debugging APIs. This assembly exports an unmanaged class, too – so it can be used without the rest of the code.
  • C# WinForms GUI that displays a list of relevant managed processes and obtains call stacks from…
  • …a C# WCF service that listens over a named pipe for requests to obtain process call stacks. The reason for this service is that the CLR Debugging APIs don’t support cross-bitness debugging, i.e. a 32-bit debugger process can’t obtain call stacks of 64-bit processes and vice versa. Instead of having two separate GUI versions for 32-bit and 64-bit, the GUI talks to two separate services (32-bit and 64-bit) which provide the information.

As I was going at it I found that it would be pretty easy to add source browsing support, so if you have sources at the right location you can double-click a stack frame and go to the line of code:

image

Also, CLR 4 features a nice addition to the Debugging API which lets a debugger easily see which thread is holding a Monitor (lock) and which threads are waiting for a Monitor using Monitor.Wait. This information is made available through the GUI when right-clicking a thread:

image

If you find this tool useful, please let me know. It’s been a pleasure writing it so far, and I’m planning to go on – some of the things I have on my TODO list:

  • Use GetActiveInternalFrames to retrieve internal frames and display them on the stack (e.g. managed-unmanaged transition)
  • Consider moving to ICorDebugStackWalk
  • Consider support for unmanaged frames
  • Perform automatic deadlock detection
  • Cache module metadata and symbol information
  • Symbol path support (currently it's just the current directory)
  • Source path support (e.g. prompt the user for source location)

Comments

Huseyin Tufekcilerli said:

Wow, this will definitely help me on a future debugging session. Keep up the great work!

# July 19, 2011 10:25 PM

Giorgi said:

You can also use mdbg 4.0 to get managed stacks. The Managed Stack Explorer is based on an earlier version of mdbg.

# July 20, 2011 1:05 PM

Joakim Dahl said:

Great work! Now if they only could add this to 'process explorer' also

# July 20, 2011 4:01 PM

Jaspio said:

Any tips on how to get this working on Win7 x64?

I keep on getting the error "cannot find file" when retrieving the process list

# July 20, 2011 5:15 PM

Nick said:

is there x64 Version of the preview? I assume the error message "Error retrieving processes: Unknown error (0xffffffe)" has to that i use the x86 version on Windows 7 SP1 x64.

# July 21, 2011 12:26 PM

Sasha Goldshtein said:

@Jaspio, @Nick:

Thanks for checking out the app. The 32-bit GUI works with 32-bit and 64-bit processes (by using two additional sub-processes). I tested the release on my Windows 7 SP1 x64 system.

Have you downloaded the self-extracting EXE version, in which unblocking is no longer required? If you still have problems, please shoot me an email (through the contact form).

Thanks a lot.

# July 22, 2011 3:19 PM

radiy said:

source code?

# July 23, 2011 2:49 PM

Sasha Goldshtein said:

@radiy: will be published on CodePlex or similar as soon as I clean it up and fix some initial bugs.

# July 23, 2011 6:55 PM

Andy said:

It crashes when I try to run it on a Windows Server 2008 :-(

# July 28, 2011 10:07 PM

madhu said:

We really need this tool. Appreciate your effort. Any reason why you are not using MdbgCore ( managed clr debugger library )

# October 21, 2011 2:06 PM

Omer Raviv said:

This tool is wonderful! *Extremely* useful in many real world scenarios, especially when there's a client on the other side of the world experiencing a hang!

My top feature requests would be:

1. Show thread names / highlight the "Main" UI thread.

2. The ability to export the entire output to a text file.

# November 17, 2011 10:09 AM

Steve Binney said:

Is the source code available?

# December 1, 2011 4:22 AM

Andrew said:

The tool is useful to me too.

Having source code would be great.

Several bugs: do not display services even if Explorer running as admin

If it can't attach to process (already debugged) it shows error message, but after several tries, crashes.

Also all "Service" application crashes when I start them. I don't know if I need to start them at all.

I have Win 7 x64

# January 20, 2012 4:03 PM

jim said:

the tool is very userful for me ,Please keep up the great work!

and the tools request msvcr100.dll.

# June 22, 2012 10:44 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: