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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *process) Close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Valid returns whether the process is active. Always returns true
|
// Valid returns whether the process is active. Always returns true
|
||||||
// for core files as it cannot exit or be otherwise detached from.
|
// for core files as it cannot exit or be otherwise detached from.
|
||||||
func (p *process) Valid() (bool, error) {
|
func (p *process) Valid() (bool, error) {
|
||||||
|
@ -1082,6 +1082,10 @@ func (p *gdbProcess) Detach(_pid int, kill bool) error {
|
|||||||
p.process = nil
|
p.process = nil
|
||||||
}
|
}
|
||||||
p.detached = true
|
p.detached = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *gdbProcess) Close() error {
|
||||||
if p.onDetach != nil {
|
if p.onDetach != nil {
|
||||||
p.onDetach()
|
p.onDetach()
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ type ProcessGroup interface {
|
|||||||
ContinueOnce(*ContinueOnceContext) (Thread, StopReason, error)
|
ContinueOnce(*ContinueOnceContext) (Thread, StopReason, error)
|
||||||
StepInstruction(int) error
|
StepInstruction(int) error
|
||||||
Detach(int, bool) error
|
Detach(int, bool) error
|
||||||
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process represents the target of the debugger. This
|
// Process represents the target of the debugger. This
|
||||||
|
@ -130,6 +130,10 @@ func (procgrp *processGroup) Detach(pid int, kill bool) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (procgrp *processGroup) Close() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Valid returns whether the process is still attached to and
|
// Valid returns whether the process is still attached to and
|
||||||
// has not exited.
|
// has not exited.
|
||||||
func (dbp *nativeProcess) Valid() (bool, error) {
|
func (dbp *nativeProcess) Valid() (bool, error) {
|
||||||
|
@ -1098,12 +1098,13 @@ func skipAutogeneratedWrappersOut(tgt *Target, g *G, thread Thread, startTopfram
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
bi := thread.BinInfo()
|
||||||
for i := 1; i < len(frames); i++ {
|
for i := 1; i < len(frames); i++ {
|
||||||
frame := frames[i]
|
frame := frames[i]
|
||||||
if frame.Current.Fn == nil {
|
if frame.Current.Fn == nil {
|
||||||
return
|
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}) {
|
if !isAutogeneratedOrDeferReturn(Location{File: file, Line: line, Fn: frame.Current.Fn}) {
|
||||||
return &frames[i-1], &frames[i]
|
return &frames[i-1], &frames[i]
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ func (grp *TargetGroup) Detach(kill bool) error {
|
|||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return fmt.Errorf("%s", strings.Join(errs, "\n"))
|
return fmt.Errorf("%s", strings.Join(errs, "\n"))
|
||||||
}
|
}
|
||||||
return nil
|
return grp.procgrp.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// detachTarget will detach the target from the underlying process.
|
// 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.log.Debug("detaching")
|
||||||
d.targetMutex.Lock()
|
d.targetMutex.Lock()
|
||||||
defer d.targetMutex.Unlock()
|
defer d.targetMutex.Unlock()
|
||||||
if ok, _ := d.target.Valid(); !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return d.detach(kill)
|
return d.detach(kill)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2831,11 +2831,12 @@ func TestRestart_PreserveFunctionBreakpoint(t *testing.T) {
|
|||||||
// even if the function changed position in the source file.
|
// even if the function changed position in the source file.
|
||||||
|
|
||||||
dir := protest.FindFixturesDir()
|
dir := protest.FindFixturesDir()
|
||||||
|
outpath := filepath.Join(dir, "testfnpos.go")
|
||||||
|
defer os.Remove(outpath)
|
||||||
|
|
||||||
copy := func(inpath string) {
|
copy := func(inpath string) {
|
||||||
buf, err := os.ReadFile(inpath)
|
buf, err := os.ReadFile(inpath)
|
||||||
assertNoError(err, t, fmt.Sprintf("Reading %q", 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))
|
assertNoError(os.WriteFile(outpath, buf, 0o666), t, fmt.Sprintf("Creating %q", outpath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user