Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proc,service/dap,proc/gdbserial: fixes for debugserver --unmask-signals #3541

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/proc/gdbserial/gdbserver_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,20 @@ func (conn *gdbConn) step(th *gdbThread, tu *threadUpdater, ignoreFaultSignal bo
if ignoreFaultSignal { // we attempting to read the TLS, a fault here should be ignored
return nil
}
if conn.isDebugserver {
// For some reason trying to deliver a signal in vCont step makes
// debugserver lockup (no errors, it just gets stuck), store the signal
// to deliver it later with the vCont;c
th.sig = sig
return nil
}
case _SIGILL, _SIGBUS, _SIGFPE:
// propagate these signals to inferior immediately
if conn.isDebugserver {
// See comment above
th.sig = sig
return nil
}
// otherwise propagate these signals to inferior immediately
case interruptSignal, breakpointSignal, stopSignal:
return nil
case childSignal: // stop on debugserver but SIGCHLD on lldb-server/linux
Expand Down
8 changes: 7 additions & 1 deletion pkg/proc/proc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5044,7 +5044,13 @@ func TestRefreshCurThreadSelGAfterContinueOnceError(t *testing.T) {
setFileBreakpoint(p, t, fixture.Source, 4)
assertNoError(grp.Continue(), t, "Continue() (first)")
if grp.Continue() == nil {
t.Fatalf("Second continue did not return an error")
pc := currentPC(p, t)
f, l, fn := p.BinInfo().PCToLine(pc)
t.Logf("Second continue did not return an error %s:%d %#v", f, l, fn)
if fn != nil && fn.Name == "runtime.fatalpanic" {
// this is also ok, it just means this debugserver supports --unmask-signals and it's working as intented.
return
}
}
g := p.SelectedGoroutine()
if g.CurrentLoc.Line != 9 {
Expand Down
11 changes: 9 additions & 2 deletions service/dap/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4874,12 +4874,12 @@ func TestBadAccess(t *testing.T) {
expectStoppedOnError := func(errorPrefix string) {
t.Helper()
se := client.ExpectStoppedEvent(t)
if se.Body.ThreadId != 1 || se.Body.Reason != "exception" || se.Body.Description != "runtime error" || !strings.HasPrefix(se.Body.Text, errorPrefix) {
if se.Body.ThreadId != 1 || se.Body.Reason != "exception" || (se.Body.Description != "runtime error" && se.Body.Description != "panic") || !strings.Contains(se.Body.Text, errorPrefix) {
t.Errorf("\ngot %#v\nwant ThreadId=1 Reason=\"exception\" Description=\"runtime error\" Text=\"%s\"", se, errorPrefix)
}
client.ExceptionInfoRequest(1)
eInfo := client.ExpectExceptionInfoResponse(t)
if eInfo.Body.ExceptionId != "runtime error" || !strings.HasPrefix(eInfo.Body.Description, errorPrefix) {
if (eInfo.Body.ExceptionId != "runtime error" && eInfo.Body.ExceptionId != "panic") || !strings.Contains(eInfo.Body.Description, errorPrefix) {
t.Errorf("\ngot %#v\nwant ExceptionId=\"runtime error\" Text=\"%s\"", eInfo, errorPrefix)
}
}
Expand All @@ -4888,6 +4888,13 @@ func TestBadAccess(t *testing.T) {
client.ExpectContinueResponse(t)
expectStoppedOnError("invalid memory address or nil pointer dereference")

client.StackTraceRequest(1, 0, 2)
st := client.ExpectStackTraceResponse(t)
if len(st.Body.StackFrames) > 0 && st.Body.StackFrames[0].Name == "runtime.fatalpanic" {
// this debugserver has --unmask-signals and it works correctly
return
}

client.NextRequest(1)
client.ExpectNextResponse(t)
expectStoppedOnError("invalid memory address or nil pointer dereference")
Expand Down