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/gdbserver: clean up rr directory on detach #3570

Merged
merged 1 commit into from
Jan 24, 2024
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
16 changes: 0 additions & 16 deletions _fixtures/testfnpos.go

This file was deleted.

4 changes: 4 additions & 0 deletions pkg/proc/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ func (p *process) Detach(int, bool) error {
return nil
}

func (p *process) Close() error {
return nil
}

// Valid returns whether the process is active. Always returns true
// for core files as it cannot exit or be otherwise detached from.
func (p *process) Valid() (bool, error) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/proc/gdbserial/gdbserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,10 @@ func (p *gdbProcess) Detach(_pid int, kill bool) error {
p.process = nil
}
p.detached = true
return nil
}

func (p *gdbProcess) Close() error {
if p.onDetach != nil {
p.onDetach()
}
Expand Down
1 change: 1 addition & 0 deletions pkg/proc/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type ProcessGroup interface {
ContinueOnce(*ContinueOnceContext) (Thread, StopReason, error)
StepInstruction(int) error
Detach(int, bool) error
Close() error
}

// Process represents the target of the debugger. This
Expand Down
4 changes: 4 additions & 0 deletions pkg/proc/native/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ func (procgrp *processGroup) Detach(pid int, kill bool) (err error) {
return
}

func (procgrp *processGroup) Close() error {
return nil
}

// Valid returns whether the process is still attached to and
// has not exited.
func (dbp *nativeProcess) Valid() (bool, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/proc/target_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1098,12 +1098,13 @@ func skipAutogeneratedWrappersOut(tgt *Target, g *G, thread Thread, startTopfram
if err != nil {
return
}
bi := thread.BinInfo()
for i := 1; i < len(frames); i++ {
frame := frames[i]
if frame.Current.Fn == nil {
return
}
file, line := g.Thread.BinInfo().EntryLineForFunc(frame.Current.Fn)
file, line := bi.EntryLineForFunc(frame.Current.Fn)
if !isAutogeneratedOrDeferReturn(Location{File: file, Line: line, Fn: frame.Current.Fn}) {
return &frames[i-1], &frames[i]
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/proc/target_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (grp *TargetGroup) Detach(kill bool) error {
if len(errs) > 0 {
return fmt.Errorf("%s", strings.Join(errs, "\n"))
}
return nil
return grp.procgrp.Close()
}

// detachTarget will detach the target from the underlying process.
Expand Down
3 changes: 0 additions & 3 deletions service/debugger/debugger.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,6 @@ func (d *Debugger) Detach(kill bool) error {
d.log.Debug("detaching")
d.targetMutex.Lock()
defer d.targetMutex.Unlock()
if ok, _ := d.target.Valid(); !ok {
return nil
}
return d.detach(kill)
}

Expand Down
3 changes: 2 additions & 1 deletion service/test/integration2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2831,11 +2831,12 @@ func TestRestart_PreserveFunctionBreakpoint(t *testing.T) {
// even if the function changed position in the source file.

dir := protest.FindFixturesDir()
outpath := filepath.Join(dir, "testfnpos.go")
defer os.Remove(outpath)

copy := func(inpath string) {
buf, err := os.ReadFile(inpath)
assertNoError(err, t, fmt.Sprintf("Reading %q", inpath))
outpath := filepath.Join(dir, "testfnpos.go")
assertNoError(os.WriteFile(outpath, buf, 0o666), t, fmt.Sprintf("Creating %q", outpath))
}

Expand Down