mirror of
https://github.com/go-delve/delve.git
synced 2025-10-27 20:23:41 +08:00
pkg/prog: Improve support for external debug info
Adds a config file option to allow specifying a list of directories to search in when looking for seperate external debug info files. Fixes #1353
This commit is contained in:
committed by
Derek Parker
parent
a2346ef69a
commit
51c342c6b7
39
pkg/proc/proc_linux_test.go
Normal file
39
pkg/proc/proc_linux_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package proc_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/derekparker/delve/pkg/proc/native"
|
||||
protest "github.com/derekparker/delve/pkg/proc/test"
|
||||
)
|
||||
|
||||
func TestLoadingExternalDebugInfo(t *testing.T) {
|
||||
fixture := protest.BuildFixture("locationsprog", 0)
|
||||
defer os.Remove(fixture.Path)
|
||||
stripAndCopyDebugInfo(fixture, t)
|
||||
p, err := native.Launch(append([]string{fixture.Path}, ""), "", false, []string{filepath.Dir(fixture.Path)})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p.Detach(true)
|
||||
}
|
||||
|
||||
func stripAndCopyDebugInfo(f protest.Fixture, t *testing.T) {
|
||||
name := filepath.Base(f.Path)
|
||||
// Copy the debug information to an external file.
|
||||
copyCmd := exec.Command("objcopy", "--only-keep-debug", name, name+".debug")
|
||||
copyCmd.Dir = filepath.Dir(f.Path)
|
||||
if err := copyCmd.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Strip the original binary of the debug information.
|
||||
stripCmd := exec.Command("strip", "--strip-debug", "--strip-unneeded", name)
|
||||
stripCmd.Dir = filepath.Dir(f.Path)
|
||||
if err := stripCmd.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user