how to add breakpoint if a method is not jitted
-
14-04-2021 - |
Вопрос
I have an application MyApp.exe
. This app uses an assembly MyAssembly1.dll
which itself refers to MyAssembly2.dll
. Within MyAssembly2
, I have a class MyClass
that has a method MyMethod
. This method is called after user go through several dialog etc.
If I launch this application from within Windbg, is there some way I can put a breakpoint on this method? The problem is that I don't know when the MyAssembly2
is loaded by CLR
and this method get JITted?
Решение
The documentation on msdn for BPMD says
If the specified module and method have not been loaded, this command waits for a notification that the module was loaded and just-in-time (JIT) compiled before creating a breakpoint.
So you should be able to do !bpmd MyAssembly2.dll MyClass.MyMethod even if MyAssembly2.dll isn't loaded yet, and when it loads the debugger will put in the breakpoint.
Другие советы
You can also run !sosex.mbm or, if you know the source file/line number, !sosex.mbp. You can even run these commands at the initial breakpoint. It's not necessary to wait for the CLR to be loaded. SOSEX will process the necessary notifications to set the breakpoint on the jitted code when it becomes available.
SOSEX is free at http://www.stevestechspot.com