proc/gdbserver: clean up rr directory on detach (#3570)
We used to autoremove the trace recorded by rr but as a result of various refactorings done to implement follow exec mode this broke. Restore the functionality. Also remove the _fixtures/testfnpos.go file which is autogenerated during testing.
This commit is contained in:
parent
0d35295491
commit
ef20fbbf12
@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func f2() {
|
||||
fmt.Printf("f2\n")
|
||||
}
|
||||
|
||||
func f1() {
|
||||
fmt.Printf("f1\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
}
|
@ -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) {
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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]
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user