*: remove some code for Go 1.12 or earlier (#3271)
Delve no longer compiles on Go1.12 and earlier, we don't test it on these versions and they are 4 years old and unsupported. Remove some code related to Go 1.12 and earlier, mostly from tests.
This commit is contained in:
parent
f6e6eadd22
commit
7c835342d3
@ -152,6 +152,10 @@ func EvalExpressionWithCalls(grp *TargetGroup, g *G, expr string, retLoadCfg Loa
|
||||
if !t.SupportsFunctionCalls() {
|
||||
return errFuncCallUnsupportedBackend
|
||||
}
|
||||
producer := bi.Producer()
|
||||
if producer == "" || !goversion.ProducerAfterOrEqual(bi.Producer(), 1, 12) {
|
||||
return errFuncCallUnsupported
|
||||
}
|
||||
|
||||
// check that the target goroutine is running
|
||||
if g == nil {
|
||||
@ -641,9 +645,6 @@ func funcCallArgs(fn *Function, bi *BinaryInfo, includeRet bool) (argFrameSize i
|
||||
return 0, nil, fmt.Errorf("DWARF read error: %v", err)
|
||||
}
|
||||
|
||||
producer := bi.Producer()
|
||||
trustArgOrder := producer != "" && goversion.ProducerAfterOrEqual(bi.Producer(), 1, 12)
|
||||
|
||||
if bi.regabi && fn.cu.optimized && fn.Name != "runtime.mallocgc" {
|
||||
// Debug info for function arguments on optimized functions is currently
|
||||
// too incomplete to attempt injecting calls to arbitrary optimized
|
||||
@ -672,7 +673,7 @@ func funcCallArgs(fn *Function, bi *BinaryInfo, includeRet bool) (argFrameSize i
|
||||
if bi.regabi {
|
||||
formalArg, err = funcCallArgRegABI(fn, bi, entry, argname, typ, &argFrameSize)
|
||||
} else {
|
||||
formalArg, err = funcCallArgOldABI(fn, bi, entry, argname, typ, trustArgOrder, &argFrameSize)
|
||||
formalArg, err = funcCallArgOldABI(fn, bi, entry, argname, typ, &argFrameSize)
|
||||
}
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
@ -707,7 +708,7 @@ func funcCallArgs(fn *Function, bi *BinaryInfo, includeRet bool) (argFrameSize i
|
||||
return argFrameSize, formalArgs, nil
|
||||
}
|
||||
|
||||
func funcCallArgOldABI(fn *Function, bi *BinaryInfo, entry reader.Variable, argname string, typ godwarf.Type, trustArgOrder bool, pargFrameSize *int64) (*funcCallArg, error) {
|
||||
func funcCallArgOldABI(fn *Function, bi *BinaryInfo, entry reader.Variable, argname string, typ godwarf.Type, pargFrameSize *int64) (*funcCallArg, error) {
|
||||
const CFA = 0x1000
|
||||
var off int64
|
||||
|
||||
@ -726,10 +727,6 @@ func funcCallArgOldABI(fn *Function, bi *BinaryInfo, entry reader.Variable, argn
|
||||
off -= CFA
|
||||
}
|
||||
if err != nil {
|
||||
if !trustArgOrder {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// With Go version 1.12 or later we can trust that the arguments appear
|
||||
// in the same order as declared, which means we can calculate their
|
||||
// address automatically.
|
||||
|
@ -2278,19 +2278,11 @@ func TestNextPanicAndDirectCall(t *testing.T) {
|
||||
// Next should not step into a deferred function if it is called
|
||||
// directly, only if it is called through a panic or a deferreturn.
|
||||
// Here we test the case where the function is called by a panic
|
||||
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 11) {
|
||||
testseq("defercall", contNext, []nextTest{
|
||||
{15, 16},
|
||||
{16, 17},
|
||||
{17, 18},
|
||||
{18, 6}}, "main.callAndPanic2", t)
|
||||
} else {
|
||||
testseq("defercall", contNext, []nextTest{
|
||||
{15, 16},
|
||||
{16, 17},
|
||||
{17, 18},
|
||||
{18, 5}}, "main.callAndPanic2", t)
|
||||
}
|
||||
testseq("defercall", contNext, []nextTest{
|
||||
{15, 16},
|
||||
{16, 17},
|
||||
{17, 18},
|
||||
{18, 6}}, "main.callAndPanic2", t)
|
||||
}
|
||||
|
||||
func TestStepCall(t *testing.T) {
|
||||
@ -2321,71 +2313,26 @@ func TestStepCallPtr(t *testing.T) {
|
||||
func TestStepReturnAndPanic(t *testing.T) {
|
||||
// Tests that Step works correctly when returning from functions
|
||||
// and when a deferred function is called when panic'ing.
|
||||
switch {
|
||||
case goversion.VersionAfterOrEqual(runtime.Version(), 1, 11):
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{17, 6},
|
||||
{6, 7},
|
||||
{7, 18},
|
||||
{18, 6},
|
||||
{6, 7}}, "", t)
|
||||
case goversion.VersionAfterOrEqual(runtime.Version(), 1, 10):
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{17, 5},
|
||||
{5, 6},
|
||||
{6, 7},
|
||||
{7, 18},
|
||||
{18, 5},
|
||||
{5, 6},
|
||||
{6, 7}}, "", t)
|
||||
case goversion.VersionAfterOrEqual(runtime.Version(), 1, 9):
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{17, 5},
|
||||
{5, 6},
|
||||
{6, 7},
|
||||
{7, 17},
|
||||
{17, 18},
|
||||
{18, 5},
|
||||
{5, 6},
|
||||
{6, 7}}, "", t)
|
||||
default:
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{17, 5},
|
||||
{5, 6},
|
||||
{6, 7},
|
||||
{7, 18},
|
||||
{18, 5},
|
||||
{5, 6},
|
||||
{6, 7}}, "", t)
|
||||
}
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{17, 6},
|
||||
{6, 7},
|
||||
{7, 18},
|
||||
{18, 6},
|
||||
{6, 7}}, "", t)
|
||||
}
|
||||
|
||||
func TestStepDeferReturn(t *testing.T) {
|
||||
// Tests that Step works correctly when a deferred function is
|
||||
// called during a return.
|
||||
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 11) {
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{11, 6},
|
||||
{6, 7},
|
||||
{7, 12},
|
||||
{12, 13},
|
||||
{13, 6},
|
||||
{6, 7},
|
||||
{7, 13},
|
||||
{13, 28}}, "", t)
|
||||
} else {
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{11, 5},
|
||||
{5, 6},
|
||||
{6, 7},
|
||||
{7, 12},
|
||||
{12, 13},
|
||||
{13, 5},
|
||||
{5, 6},
|
||||
{6, 7},
|
||||
{7, 13},
|
||||
{13, 28}}, "", t)
|
||||
}
|
||||
testseq("defercall", contStep, []nextTest{
|
||||
{11, 6},
|
||||
{6, 7},
|
||||
{7, 12},
|
||||
{12, 13},
|
||||
{13, 6},
|
||||
{6, 7},
|
||||
{7, 13},
|
||||
{13, 28}}, "", t)
|
||||
}
|
||||
|
||||
func TestStepIgnorePrivateRuntime(t *testing.T) {
|
||||
@ -2410,27 +2357,8 @@ func TestStepIgnorePrivateRuntime(t *testing.T) {
|
||||
{21, 14},
|
||||
{14, 15},
|
||||
{15, 22}}, "", t)
|
||||
case goversion.VersionAfterOrEqual(runtime.Version(), 1, 10):
|
||||
testseq("teststepprog", contStep, []nextTest{
|
||||
{21, 13},
|
||||
{13, 14},
|
||||
{14, 15},
|
||||
{15, 22}}, "", t)
|
||||
case goversion.VersionAfterOrEqual(runtime.Version(), 1, 7):
|
||||
testseq("teststepprog", contStep, []nextTest{
|
||||
{21, 13},
|
||||
{13, 14},
|
||||
{14, 15},
|
||||
{15, 14},
|
||||
{14, 17},
|
||||
{17, 22}}, "", t)
|
||||
default:
|
||||
testseq("teststepprog", contStep, []nextTest{
|
||||
{21, 13},
|
||||
{13, 14},
|
||||
{14, 15},
|
||||
{15, 17},
|
||||
{17, 22}}, "", t)
|
||||
panic("too old")
|
||||
}
|
||||
}
|
||||
|
||||
@ -2790,15 +2718,9 @@ func TestStepOutPanicAndDirectCall(t *testing.T) {
|
||||
// StepOut should not step into a deferred function if it is called
|
||||
// directly, only if it is called through a panic.
|
||||
// Here we test the case where the function is called by a panic
|
||||
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 11) {
|
||||
testseq2(t, "defercall", "", []seqTest{
|
||||
{contContinue, 17},
|
||||
{contStepout, 6}})
|
||||
} else {
|
||||
testseq2(t, "defercall", "", []seqTest{
|
||||
{contContinue, 17},
|
||||
{contStepout, 5}})
|
||||
}
|
||||
testseq2(t, "defercall", "", []seqTest{
|
||||
{contContinue, 17},
|
||||
{contStepout, 6}})
|
||||
}
|
||||
|
||||
func TestWorkDir(t *testing.T) {
|
||||
|
@ -1051,11 +1051,6 @@ func TestPackageRenames(t *testing.T) {
|
||||
{"amap2", true, "interface {}(*map[go/ast.BadExpr]net/http.Request) *[{From: 2, To: 3}: *{Method: \"othermethod\", …", "", "interface {}", nil},
|
||||
}
|
||||
|
||||
testcases1_8 := []varTest{
|
||||
// before 1.9 embedded struct fields have fieldname == type
|
||||
{"astruct2", true, `interface {}(*struct { github.com/go-delve/delve/_fixtures/internal/dir1/pkg.SomeType; X int }) *{github.com/go-delve/delve/_fixtures/internal/dir1/pkg.SomeType: github.com/go-delve/delve/_fixtures/internal/dir1/pkg.SomeType {X: 1, Y: 2}, X: 10}`, "", "interface {}", nil},
|
||||
}
|
||||
|
||||
testcases1_9 := []varTest{
|
||||
{"astruct2", true, `interface {}(*struct { github.com/go-delve/delve/_fixtures/internal/dir1/pkg.SomeType; X int }) *{SomeType: github.com/go-delve/delve/_fixtures/internal/dir1/pkg.SomeType {X: 1, Y: 2}, X: 10}`, "", "interface {}", nil},
|
||||
}
|
||||
@ -1074,11 +1069,7 @@ func TestPackageRenames(t *testing.T) {
|
||||
assertNoError(p.Continue(), t, "Continue() returned an error")
|
||||
testPackageRenamesHelper(t, p, testcases)
|
||||
|
||||
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 9) {
|
||||
testPackageRenamesHelper(t, p, testcases1_9)
|
||||
} else {
|
||||
testPackageRenamesHelper(t, p, testcases1_8)
|
||||
}
|
||||
testPackageRenamesHelper(t, p, testcases1_9)
|
||||
|
||||
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 13) {
|
||||
testPackageRenamesHelper(t, p, testcases1_13)
|
||||
|
@ -2000,19 +2000,6 @@ func TestClientServer_StepOutReturn(t *testing.T) {
|
||||
stridx := 0
|
||||
numidx := 1
|
||||
|
||||
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 12) {
|
||||
// in 1.11 and earlier the order of return values in DWARF is
|
||||
// unspecified, in 1.11 and later it follows the order of definition
|
||||
// specified by the user
|
||||
for i := range ret {
|
||||
if ret[i].Name == "str" {
|
||||
stridx = i
|
||||
numidx = 1 - i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ret[stridx].Name != "str" {
|
||||
t.Fatalf("(str) bad return value name %s", ret[stridx].Name)
|
||||
}
|
||||
@ -2139,32 +2126,6 @@ func TestClientServerFunctionCall(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestClientServerFunctionCallBadPos(t *testing.T) {
|
||||
protest.MustSupportFunctionCalls(t, testBackend)
|
||||
if goversion.VersionAfterOrEqual(runtime.Version(), 1, 12) {
|
||||
t.Skip("this is a safe point for Go 1.12")
|
||||
}
|
||||
withTestClient2("fncall", t, func(c service.Client) {
|
||||
loc, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "fmt/print.go:649", false, nil)
|
||||
assertNoError(err, t, "could not find location")
|
||||
|
||||
_, err = c.CreateBreakpoint(&api.Breakpoint{File: loc[0].File, Line: loc[0].Line})
|
||||
assertNoError(err, t, "CreateBreakpoin")
|
||||
|
||||
state := <-c.Continue()
|
||||
assertNoError(state.Err, t, "Continue()")
|
||||
|
||||
state = <-c.Continue()
|
||||
assertNoError(state.Err, t, "Continue()")
|
||||
|
||||
c.SetReturnValuesLoadConfig(&normalLoadConfig)
|
||||
state, err = c.Call(-1, "main.call1(main.zero, main.zero)", false)
|
||||
if err == nil || err.Error() != "call not at safe point" {
|
||||
t.Fatalf("wrong error or no error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestClientServerFunctionCallPanic(t *testing.T) {
|
||||
protest.MustSupportFunctionCalls(t, testBackend)
|
||||
withTestClient2("fncall", t, func(c service.Client) {
|
||||
|
Loading…
Reference in New Issue
Block a user