Under The Hood - Matt Pietrek

Why can't I detach the debugger from an app?

An interesting internal thread on debugging went by, and it was news to me, so figured I'd share.

In the VS2005 debugger, you can't detach from a running app (that is, stop debugging but leave the target process alive)  if you're debugging in mixed mode (native and managed simultaneously.)

 

Published Thursday, January 12, 2006 8:42 PM by Matt Pietrek

Comments

 

Yaytay said:

That's a good question, what's the answer?
January 13, 2006 12:17 AM
 

Seth McCarus said:

AFAIK you could not do this is VC6 either, or VS2003 - even in native mode. So what is the reason for this?
January 13, 2006 10:16 AM
 

Matt Pietrek said:

Don't remember what the story with VS 2003 was (it's been almost 2 years since I've used it.) The VS2005 debugger behavior, as given by a debugger dude:

If you attach to your app, when you stop debugging you will automatically detach without killing the app.

If you launch your app under the debugger, you can detach by choosing the Debug->Detach All menu item. Otherwise, stop debugging will automatically terminate the app.
January 13, 2006 11:56 AM
 

andypennell said:

VC6 couldnt do it for Native because its release (in 1998) preceeded the OS support for Detach (ie XP).

VS7.0 and later can do it for Native (Seth is mistaken).

Nothing can do it for Mixed because the debugging services support in the CLR doesn't include Detach support.
January 13, 2006 1:11 PM
 

Norman Diamond said:

Ummm, is the answer going to be posted by anyone who knows the answer? In the VS2005 debugger, if you're debugging in mixed native and managed mode, why can't you detach?
January 15, 2006 10:11 PM
 

greggm said:

As Andy said, VS doesn't support it because the CLR doesn't support it.

So then I guess the question becomes -- why doesn't the CLR support it? Interop debugging is hard, and it was implemented in a way that made detach too difficult to implement.

The CLR is currently working on reimplementing interop debugging for a future version. With the new architecture, detach should be much more reasonable.
January 16, 2006 3:33 PM
 

Norman Diamond said:

I swear Andy Pennell's answer wasn't displayed yet when I asked.

Though actually I'm still confused. If the debugging services support in the CLR doesn't include Detach support then even Managed (without mixing) wouldn't be capable?
January 16, 2006 8:26 PM
 

Mike Stall's .NET Debugging Blog said:

Matt Pietrek noticed you can't detach while interop-debugging (aka "mixed-mode") in VS. Short answer:...
March 1, 2006 11:28 AM
New Comments to this post are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker