Mike Stall's .NET Debugging Blog

Notes on Managed Debugging, ICorDebug, and random .NET stuff

Browse by Tags

Tagged Content List
  • Blog Post: Why is System.Diagnostic.Debugger class compiled in retail?

    There's a good reason that methods on a "System.Diagnostics.Debugger" class are still compiled in retail builds, although this occasionally surprises folks. Here's why... Background: The System.Diagnostics.Debugger class provides some useful low-level debugging APIs such as: Debugger.Break () - causes...
  • Blog Post: How to tell if a function is managed code?

    This is a moot point for pure C# apps, but what if you're writing in MC++ (or some other 'mixed' language) and you want to know if a function is getting compiled as managed or native code? You can try and inspect the source and infer from the language rules. Eg, in MC++, look for #pragma managed / #pragma...
  • Blog Post: Interop-debugging fails when using more than 63 TLS slots

    Here's a Public Service Announcement: Interop-debugging may hang if the debuggee uses more than 63 native Thread Local-Storage slots and then loads the CLR. KB939969 has more details, including three workarounds. This is fixed in Orcas, so only applies to pre-Orcas runtimes (like .NET 2.0). You really...
  • Blog Post: ICorPublish does not cross the 32/64 bit boundary

    I mentioned earlier that ICorDebug does not cross the 32/64 boundary . If you want to debug a 32-bit managed app, you need to use a 32-bit version of the ICorDebug interfaces (or Mdbg). If you want to debug a 64-bit managed app, you need a 64-bit savy debugger. When you debug a 64-bit managed app in...
  • Blog Post: You don't want to write an interop debugger.

    I've had a growing number of people inquire about how to write an interop-debugger with ICorDebug. My goal here is to discourage you from doing that. (This reminds me of one of my college classes. On day one, the acting-Prof launched into a great sermon "Why you should drop this class now". It turned...
  • Blog Post: Possible slowdowns under a debugger

    Here's a list of things that may slow down execution under a debugger. I've seen a few threads go by about ways that running under the debugger significantly slows down normal execution by more than 2x, and this is a collection of those items. Background : Stepping through each statement (F10) runs...
  • Blog Post: How to start a console app in a new window, the parent's window, or no window

    The ProcessStartInfo.CreateNoWindow property says "Gets or sets a value indicating whether to start the process in a new window." and later " true to start the process without creating a new window to contain it; otherwise, false . The default is false " But that's misleading and wrong because it's meaning...
  • Blog Post: Caveats about managed JIT-debugging

    I received some questions in the mailbag about what Debugger.Launch actually does. Debugger.Launch the same mechanism as JIT-attach when you get an unhandled managed exception. Here are some random caveats about the jit-launch mechanism: Jit-launch calls kernel32!CreateProcess on the string set...
  • Blog Post: Resolving functions and func-eval syntax

    I got a question about MDbg's func-eval syntax, which brings up a nice point about function resolution: Is it possible to evaluate a function by specifying an instance variable instead of the fully qualified name of the class? f ex.get_StackTrace ... is so much nicer than ... System.Exception...
  • Blog Post: #line hidden vs. DebuggerNonUserCode attribute

    I got this great question from the mailbag: "[W]hat is the relation between the "# line hidden" directive and the DebuggerNonUserCode attribute ? Are these the same ?" Short Answer : They're both markings that library authors can put in their source code to mark certain portions as "hidden" to the...
  • Blog Post: Conventions for passing the arguments to a process

    A process's main() function gets an array of strings for the command line args. This is string[] in C#, or {int argc, char** argv} in C/C++. But there are some different conventions for how the parent app passes those strings in. If you execute a program on the command line like: myapp.exe myfile...
  • Blog Post: Managed vs. Native debugging APIs

    FxCop has a great rule ( UseManagedEquivalentsOfWin32Api ) to tell you about managed APIs that exist instead of trying to pinvoke out. I'm writing a native debugger in managed code (more on this later), and FxCop was telling me to use the managed debugging APIs instead of pinvoke out to the native...
  • Blog Post: Debugger won't properly evaluate C#s base keyword

    Public Service Announcement: You may have noticed that trying to evaluate members using C#'s 'base' keyword in the debugger still calls the derived members. (The 'base' keyword lets you access base class member implementations from within a derived class, which is very useful when the members are polymorphic...
  • Blog Post: How to build Mdbg apps

    I often publish little samples in this blog based off MDbg (which generally show off the debugging services in some way; such as app to convert Pdb-->XML , or this harness to print all exceptions in an app ). I generally call these apps "harnesses" because they run on another app (the debuggee). I...
  • Blog Post: Beware of the Vectored Exception Handler and managed code

    A vectored exception handler (see kernel32!AddVectoredExceptionHandler ) lets you add to a global list of filters that get executed by the OS when a native exception is thrown. More specifically, this list is executed by the OS before the filters in the FS:0 chain are executed. This means you can get...
  • Blog Post: Enc APIs aren't exposed through reflection

    David Srbecky asked : Can a EnC capable compiler work on top of System.Refletion.Emit? (ie. If an existing compiler is to be extended to support EnC, does it have to be rewritten to use the unmanaged emitting interface?) Unfortuantely, No. Details: 1. You can indeed write a compiler in C# which...
  • Blog Post: You can't do Edit-and-Continue with Interop-debugging on.

    Somebody asked on the forums about Edit-and-Continue (EnC) in mixed mode . You can't use managed EnC with mixed-mode ( interop ) debugging enabled. This is a limitation of the CLR Debugging Services. Both Interop-debugging and EnC are complicated features; combining them would be a huge test-matrix and...
  • Blog Post: PSA: Pinvokes may be 100x slower under the debugger.

    I need to make an embarrassing public service announcement (PSA): Pinvokes are 100x slower under the debugger in VS2005 / Whidbey. For example, this is the issue that came up here . It may also manifest as your app "hanging" under the debugger w/ 100% CPU usage. How did this happen? I'll explain why...
  • Blog Post: Using MC++ to wrap ICorDebug for .NET 1.1

    MDbg and the managed wrappers around ICorDebug only work on .NET 2.0 (VS2005). I previously discussed why they won't work on 1.1 . One workaround to access ICorDebug from managed code in .NET 1.1 is to use MC++. In general, MC++ can be extremely useful for gluing managed and unmanaged code together....
  • Blog Post: Evil trick to render UI when stopped at a breakpoint.

    Here's an EVIL trick to render your UI in a winforms app when you're stopped at a breakpoint. When managed-debugging, when you hit a breakpoint, all the managed threads stop . With a winforms app, the UI thread is managed and so it stops too. However, that same UI thread that's pumping WM_Paint messages...
  • Blog Post: "Visual Studio 2003 Mixed Mode Debugging Crash"

    It's great that 2005 has shipped. I personally enjoy using it for my own pet projects and I'm very pleased. But shipping a V2 also means exposing versioning problems in the V1 design. Such an issue came up on the forums , which basically boils down to: VS 2003 crashes when: 1. I install VS2005 2. I'm...
  • Blog Post: VS 2003 can not debug .NET 2.0 apps.

    Somebody asked here on the forums if you can use VS 2003 to debug .NET 2.0 (whidbey) apps. Unfortunately, the answer is no. VS 2003 can not debug .NET 2.0 apps. It is a restriction in the underlying .NET debugging services (see below) You can still use the .NET 2.0 SDK tools (such as Mdbg , DbgClr) to...
  • Blog Post: Why you sometimes get a bogus ContextSwitchDeadLock MDA under the debugger

    The ContextSwitchDeadLock MDA (I blogged about MDAs here ) sometimes fires under the debugger. MSDN says: It is possible for this MDA to be falsely activated when all of the following conditions are met: * An application creates COM components from STA threads either directly or indirectly through...
  • Blog Post: Symbol API (CorSym.idl) for managed PDBs

    From the mailbag: Just wanted to know if there are plans to ever give us world citizens an API to modify & emit pdb files, at least for managed assemblies. Good news. You've already got them. 1) The CorSym.idl API (exists in sdk, next to where you find CorDebug.idl) is a com-classic API that can...
  • Blog Post: MDbg Sample temporarily broken in post-beta 2 builds.

    Customers have alerted us that the MDBg sample is broken on post-beta 2 builds. Rick Byers has diagnosed the problem as an issue in the mdbg build and we're working to update it. I guess there was a VS change that exposed this problem. Rick may blog a more detailed explanation, but I just wanted to get...
Page 1 of 2 (29 items) 12