How can I debug Just My Code?

Sometimes developers want to debug just the code they wrote and not the 3rd-party code (such as framework and libraries) that’s also inside their app. This becomes particularly useful when user and non-user code call back and forth between each other.  The v2.0 CLR debugging services have a host of new features to support this,…

27

How do Managed Breakpoints work?

In this blog entry, I’ll explain how setting source-level breakpoints in a managed debugger work under the hood from end to end.   Here’s an overview of the pipeline of components: 1)      End-user 2)      Debugger (such as Visual Studio or MDbg) . 3)      CLR Debugging Services (which we call “The Right Side”). This is the…

19

You can’t attach 2 debuggers to 1 process

For both managed-only and native-only debugging, you can only attach 1 debugger to a process.   Why? The native debugger steals debug events from underneath the managed debugger. This confuses the managed-debugger and will cause it to crash. The native debugger has no way of coordinating with the managed-debugger here.   Troubles enforcing this: In…

12

Enumerating Managed Processes

I noticed Brad Abrams and Krzysztof Cwalina were  blogging about how to find a list of all the managed processes on a machine. Their solution involved looking for managed perf counters. The debugging APIs provide a more orthodox approach via the ICorPublish API (see corpub.idl in the SDK). ICorPublish is an unmanaged com-classic API, but…

8

Sample app to print loaded modules.

Here’s a simple C# sample tool that runs an app and prints the modules loaded. It’s effectively a highly simplified debugger and uses the ICorDebug debugging APIs as exposed by MDbg.   Here’s the code. [update: 1/26/05: updated code for final 2005 release of MDbg] You can create a a new console app, paste it in,…

6

Winforms gui on top of Managed debugger sample.

UPDATE: The source for this sample is now available here. Since this post is closed (it’s from Nov 2004), please direct comments to this post. The MDbg sample ships with some interesting extensions, including a simple winforms gui with some very basic features (gui.dll): –         opens source files in a MDI window. –         redirects console…

11

Problems for a managed debugger for v1.1?

Now that we’ve released a managed debugger sample for V2.0, people commonly ask “What about v1.1?”. I briefly touched on this when in a comment in the original MDbg post (http://blogs.msdn.com/jmstall/archive/2004/09/30/236281.aspx#245499). Here are more details: In theory, it’s doable, but there are some hurdles. Here are the biggest problems to back-porting MDbg to v1.1:1)       CLR…

11

Using metadata interfaces from managed code

The metadata APIs are unmanaged COM-classic interfaces declared in Cor.h in the SDK. (look for IMetaData* ). In this blog entry, I’ll wander over some random trivia about trying to use the metadata interfaces from managed code. We run into this from the debugging side because the debugging interfaces are intimately related to the metadata…

7

David Notario, JIT guru, is blogging

David Notario, a dev on the CLR JIT has a blog. Check out http://blogs.msdn.com/davidnotario. The debugger and  compiler have an intimate relationship because the debugger needs to understand the code-gen patterns from the compiler in order to meaningfully debug it.

0

CLR Debugging vs. CLR Profiling

The CLR offers both debugging and profiling services.  While there is some overlap, there are some significant differences between profiling and debugging in the CLR and they’re intended to solve very different problems.   What about the similarities? There’s certainly some overlap between these two services. Both: 1)      can inspect CLR state. including callstacks, local…

9