dotnet / dotnet/diagnostics

[SOS][Linux] Managed breakpoints are lost after application restart

Open
#53 0 comments 0 reactions 1 assignee Claimed by @mikem8361 View on GitHub
bug enhancement up-for-grabs
Dominant language
C++
Stars
1.3k
Forks
404
Avg merge
2d 3h
Merged PRs (30d)
38

Description

@Dmitri-Botcharnikov commented on [Thu Jul 21 2016](https://github.com/dotnet/coreclr/issues/6387)

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 #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.

---

@Dmitri-Botcharnikov commented on [Thu Jul 21 2016](https://github.com/dotnet/coreclr/issues/6387#issuecomment-234312218)

cc @mikem8361 @janvorli @chunseoklee @seanshpark @lucenticus @kvochko @papaslavik

---

@mikem8361 commented on [Thu Jul 21 2016](https://github.com/dotnet/coreclr/issues/6387#issuecomment-234315261)

Yes, it looks like those notifications need to be sent/set again on restart.

---

@Dmitri-Botcharnikov commented on [Mon Jul 25 2016](https://github.com/dotnet/coreclr/issues/6387#issuecomment-234926830)

@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?

---

@mikem8361 commented on [Mon Jul 25 2016](https://github.com/dotnet/coreclr/issues/6387#issuecomment-235100410)

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.