Doug Reilly's Weblog

Embedded Reporting of the Information Age...

Interesting CLR Tricks...

From the CLR Internals talk at PDC, a really useful tidbit. 

Create a module with a call early to System.Diagnostics.Debugger.Launch.  Create a method that does not get called until after the call to Launch.

Compile the assembly, using /debug:pdbonly switch.  This tells the compiler to create the PDB, but otherwise creates code that is release mode.

When the code hits the Launch() call, the debugger pops up.  Because of the way the JIT compiler works (compiling on the first call to a method) when you call a method not previously called) the code the JIT emits will be debug code, since it knows you are in the debugger, and since you have the pdb lying around, you are in business.  Very cool.

(Note to folks at PDC, CLR Internals talk is amazing so far.  I am sitting way in the back against the wall).

 

Comments

Scott Burke said:

Hi Doug! Sitting in the same talk! Back row near the door banging away on the laptop.
Had to blog the armymen.exe trick from the earlier session too -
# October 26, 2003 7:52 PM

doug reilly said:

I found a seat near the middle after the break. great talk, especilly info on problems with finalize.
# October 26, 2003 8:00 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)