Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a breakpoint when .NET 2 or .NET 4 is loaded?

Tags:

windbg

Sometimes I'm debugging .NET applications but I don't know whether they will use .NET 2 or .NET 4. I want to break in when .NET gets loaded, so I do

sxe -c ".echo .NET4 loaded" ld clr
sxe -c ".echo .NET2 loaded" ld mscorwks

Unfortunately there can only be one such breakpoint and in above example, mscorwks overwrites clr and in case of .NET4, it will not hit the breakpoint.

Is there a way to break on multiple different load events?

I really don't want to fiddle around with my non-working incomprehensible try of

sxe -c".foreach /ps 5 /pS 99 (token {.lastevent}) {.if ($spat(\"[0-9a-z.:\\]*\\clr.dll\",\"${token}\")) {.echo clr;} .elsif ($spat(\".*\mscorwks.dll\",\"${token}\")) {.echo mscorwks} .else {}}" ld
like image 904
Thomas Weller Avatar asked Jan 12 '14 21:01

Thomas Weller


1 Answers

You can set two breakpoints

bu mscorwks!EEStartup

bu clr!EEStartup

(for example bu clr!EEStartup ".echo Breaking into debugger on clr loaded") and only one of them will work

like image 101
Stas Sh Avatar answered Oct 13 '22 20:10

Stas Sh