mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 01:27:16 +08:00
proc,proc/native,proc/gdbserial: initial plugin support (#1413)
Adds initial support for plugins, this is only the code needed to keep track of loaded plugins on linux (both native and gdbserial backend). It does not actually implement support for debugging plugins on linux. Updates #865
This commit is contained in:
committed by
Derek Parker
parent
09c92c75b9
commit
af1ffc8504
@ -29,6 +29,8 @@ type Fixture struct {
|
||||
Path string
|
||||
// Source is the absolute path of the test binary source.
|
||||
Source string
|
||||
// BuildDir is the directory where the build command was run.
|
||||
BuildDir string
|
||||
}
|
||||
|
||||
// FixtureKey holds the name and builds flags used for a test fixture.
|
||||
@ -72,6 +74,7 @@ const (
|
||||
// EnableDWZCompression will enable DWZ compression of DWARF sections.
|
||||
EnableDWZCompression
|
||||
BuildModePIE
|
||||
BuildModePlugin
|
||||
)
|
||||
|
||||
// BuildFixture will compile the fixture 'name' using the provided build flags.
|
||||
@ -126,6 +129,9 @@ func BuildFixture(name string, flags BuildFlags) Fixture {
|
||||
if flags&BuildModePIE != 0 {
|
||||
buildFlags = append(buildFlags, "-buildmode=pie")
|
||||
}
|
||||
if flags&BuildModePlugin != 0 {
|
||||
buildFlags = append(buildFlags, "-buildmode=plugin")
|
||||
}
|
||||
if ver.AfterOrEqual(goversion.GoVersion{1, 11, -1, 0, 0, ""}) {
|
||||
if flags&EnableDWZCompression != 0 {
|
||||
buildFlags = append(buildFlags, "-ldflags=-compressdwarf=false")
|
||||
@ -161,7 +167,9 @@ func BuildFixture(name string, flags BuildFlags) Fixture {
|
||||
source = strings.Replace(sympath, "\\", "/", -1)
|
||||
}
|
||||
|
||||
fixture := Fixture{Name: name, Path: tmpfile, Source: source}
|
||||
absdir, _ := filepath.Abs(dir)
|
||||
|
||||
fixture := Fixture{Name: name, Path: tmpfile, Source: source, BuildDir: absdir}
|
||||
|
||||
Fixtures[fk] = fixture
|
||||
return Fixtures[fk]
|
||||
@ -312,3 +320,22 @@ func DefaultTestBackend(testBackend *string) {
|
||||
*testBackend = "native"
|
||||
}
|
||||
}
|
||||
|
||||
// WithPlugins builds the fixtures in plugins as plugins and returns them.
|
||||
// The test calling WithPlugins will be skipped if the current combination
|
||||
// of OS, architecture and version of GO doesn't support plugins or
|
||||
// debugging plugins.
|
||||
func WithPlugins(t *testing.T, plugins ...string) []Fixture {
|
||||
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 12) {
|
||||
t.Skip("versions of Go before 1.12 do not include debug information in packages that import plugin (or they do but it's wrong)")
|
||||
}
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("only supported on linux")
|
||||
}
|
||||
|
||||
r := make([]Fixture, len(plugins))
|
||||
for i := range plugins {
|
||||
r[i] = BuildFixture(plugins[i], BuildModePlugin)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user