[SOS][Linux] Managed breakpoints are lost after application restart
Breakpoints on managed code are lost after application finishes and is restarted again. The issue can be reproduced on Linux/x64 as well as on Linux/ARM:
(lldb) bpmd helloworld4.exe ExceptionTest.Main
Adding pending breakpoints...
(lldb) c
Process 19495 resuming
(lldb) JITTED helloworld4!HelloWorld4.ExceptionTest.Main()
Setting breakpoint: breakpoint set --address 0x00007FFF7D3CD4AF [HelloWorld4.ExceptionTest.Main()]
Process 19495 stopped
* thread dotnet/coreclr#1: tid = 19495, 0x00007fff7d3cd4af JIT(0x6f80c0) at helloworld4.cs:14, name = 'corerun', stop reason = breakpoint 3.1
frame #0: 0x00007fff7d3cd4af JIT(0x6f80c0) at helloworld4.cs:14
11 return x / y;
12 }
13 static void Main()
-> 14 {
15 // Input for test purposes. Change the values to see
16 // exception handling behavior.
17 double a = 98, b = 0;
(lldb) c
Process 19495 resuming
Attempted divide by zero.
Process 19495 exited with status = 0 (0x00000000)
(lldb) run
Process 19707 launched: '/home/dima/work/dotnet/demo/runtime/corerun' (x86_64)
Attempted divide by zero.
Process 19707 exited with status = 0 (0x00000000)
(lldb) bpmd -list
!bpmd pending breakpoint list
Breakpoint index - Location, ModuleID, Method Token
1 - helloworld4.exe!ExceptionTest.Main+0, 0x00007FFF7C0729B8, 0x06000002
2 - helloworld4.exe!ExceptionTest.Main+0, 0x0000000000000000, 0x00000000
We can see that pending breakpoints are retained across runs, but it seems that no notifications on module loading and code generation are sent to SOS.
cc @mikem8361 @janvorli @chunseoklee @seanshpark @lucenticus @kvochko @papaslavik
Yes, it looks like those notifications need to be sent/set again on restart.
@mikem8361 I've tried to set notification flags in each call of LoadClrDebugDll (which in turn called from HandleExceptionNotification) but without success. Am I missing something?
Can you share your changes. There are a lot of pieces that need to be looked at. LoadClrDebugDll is called for everything sos command invocation but putting something inside the "if (s_clrDataProcess == NULL)" would be called only once. Putting something outside it would be called on command (which is probably not that big a deal). The "exception breakpoint" set in g_ExtServices->SetExceptionCallback(HandleExceptionNotfication) may need to be setting again on restart. Not sure if lldb preserves this breakpoint on restart and the callback handler that is set. g_ExtServices->ClearExceptionCallback would need to be called first to clear the global state in the sosplugin.
Issue moved to dotnet/diagnostics dotnet/coreclr#53 via ZenHub