How to break WinDbg in an anonymous method?
Posted
by Richard Berg
on Stack Overflow
See other posts from Stack Overflow
or by Richard Berg
Published on 2010-03-12T06:33:15Z
Indexed on
2010/03/12
6:37 UTC
Read the original article
Hit count: 721
Title kinda says it all. The usual SOS command !bpmd doesn't do a lot of good without a name.
Some ideas I had:
- dump every method, then use !bpmd -md when you find the corresponding MethodDesc
- not practical in real world usage, from what I can tell. Even if I wrote a macro to limit the dump to anonymous types/methods, there's no obvious way to tell them apart.
- use Reflector to dump the MSIL name
- doesn't help when dealing with dynamic assemblies and/or Reflection.Emit. Visual Studio's inability to read local vars inside such scenarios is the whole reason I turned to Windbg in the first place...
- set the breakpoint in VS, wait for it to hit, then change to Windbg using the noninvasive trick
- attempting to detach from VS causes it to hang (along with the app). I think this is due to the fact that the managed debugger is a "soft" debugger via thread injection instead of a standard "hard" debugger. Or maybe it's just a VS bug specific to Silverlight (would hardly be the first I've encountered).
- set a breakpoint on some other location known to call into the anonymous method, then single-step your way in
- my backup plan, though I'd rather not resort to it if this Q&A reveals a better way
© Stack Overflow or respective owner