*: Fix go vet complaints (#1935)
* *: Fix go vet struct complaints * *: Fix struct vet issue on linux * *: Ignore proc/native in go vet check We have to do some unsafe pointer manipulation that will never make go vet happy within the proc/native package. Ignore it for runs of go vet.
This commit is contained in:
parent
edc5436fe3
commit
ad75f78c4e
7
Makefile
7
Makefile
@ -12,9 +12,12 @@ install:
|
|||||||
uninstall:
|
uninstall:
|
||||||
@go run scripts/make.go uninstall
|
@go run scripts/make.go uninstall
|
||||||
|
|
||||||
test:
|
test: vet
|
||||||
@go run scripts/make.go test
|
@go run scripts/make.go test
|
||||||
|
|
||||||
|
vet:
|
||||||
|
@go vet $$(go list ./... | grep -v scripts | grep -v native)
|
||||||
|
|
||||||
test-proc-run:
|
test-proc-run:
|
||||||
@go run scripts/make.go test -s proc -r $(RUN)
|
@go run scripts/make.go test -s proc -r $(RUN)
|
||||||
|
|
||||||
@ -24,4 +27,4 @@ test-integration-run:
|
|||||||
vendor:
|
vendor:
|
||||||
@go run scripts/make.go vendor
|
@go run scripts/make.go vendor
|
||||||
|
|
||||||
.PHONY: vendor test-integration-run test-proc-run test check-cert install build
|
.PHONY: vendor test-integration-run test-proc-run test check-cert install build vet
|
||||||
|
|||||||
@ -90,7 +90,7 @@ func New(docCall bool) *cobra.Command {
|
|||||||
buildFlagsDefault := ""
|
buildFlagsDefault := ""
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
ver, _ := goversion.Installed()
|
ver, _ := goversion.Installed()
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
// Work-around for https://github.com/golang/go/issues/13154
|
// Work-around for https://github.com/golang/go/issues/13154
|
||||||
buildFlagsDefault = "-ldflags='-linkmode internal'"
|
buildFlagsDefault = "-ldflags='-linkmode internal'"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -545,7 +545,7 @@ func readType(d *dwarf.Data, name string, r *dwarf.Reader, off dwarf.Offset, typ
|
|||||||
}
|
}
|
||||||
addressSize := r.AddressSize()
|
addressSize := r.AddressSize()
|
||||||
if e == nil || e.Offset != off {
|
if e == nil || e.Offset != off {
|
||||||
return nil, dwarf.DecodeError{name, off, "no type at offset"}
|
return nil, dwarf.DecodeError{Name: name, Offset: off, Err: "no type at offset"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is the root of the recursion, prepare to resolve typedef sizes
|
// If this is the root of the recursion, prepare to resolve typedef sizes
|
||||||
@ -613,7 +613,7 @@ func readType(d *dwarf.Data, name string, r *dwarf.Reader, off dwarf.Offset, typ
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
case uint64:
|
case uint64:
|
||||||
err = dwarf.DecodeError{name, e.Offset, "DWARFv4 section debug_types unsupported"}
|
err = dwarf.DecodeError{Name: name, Offset: e.Offset, Err: "DWARFv4 section debug_types unsupported"}
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
// It appears that no Type means "void".
|
// It appears that no Type means "void".
|
||||||
@ -677,7 +677,7 @@ func readType(d *dwarf.Data, name string, r *dwarf.Reader, off dwarf.Offset, typ
|
|||||||
}
|
}
|
||||||
ndim++
|
ndim++
|
||||||
case dwarf.TagEnumerationType:
|
case dwarf.TagEnumerationType:
|
||||||
err = dwarf.DecodeError{name, kid.Offset, "cannot handle enumeration type as array bound"}
|
err = dwarf.DecodeError{Name: name, Offset: kid.Offset, Err: "cannot handle enumeration type as array bound"}
|
||||||
goto Error
|
goto Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,12 +697,12 @@ func readType(d *dwarf.Data, name string, r *dwarf.Reader, off dwarf.Offset, typ
|
|||||||
name, _ := e.Val(dwarf.AttrName).(string)
|
name, _ := e.Val(dwarf.AttrName).(string)
|
||||||
enc, ok := e.Val(dwarf.AttrEncoding).(int64)
|
enc, ok := e.Val(dwarf.AttrEncoding).(int64)
|
||||||
if !ok {
|
if !ok {
|
||||||
err = dwarf.DecodeError{name, e.Offset, "missing encoding attribute for " + name}
|
err = dwarf.DecodeError{Name: name, Offset: e.Offset, Err: "missing encoding attribute for " + name}
|
||||||
goto Error
|
goto Error
|
||||||
}
|
}
|
||||||
switch enc {
|
switch enc {
|
||||||
default:
|
default:
|
||||||
err = dwarf.DecodeError{name, e.Offset, "unrecognized encoding attribute value"}
|
err = dwarf.DecodeError{Name: name, Offset: e.Offset, Err: "unrecognized encoding attribute value"}
|
||||||
goto Error
|
goto Error
|
||||||
|
|
||||||
case encAddress:
|
case encAddress:
|
||||||
@ -816,12 +816,12 @@ func readType(d *dwarf.Data, name string, r *dwarf.Reader, off dwarf.Offset, typ
|
|||||||
f.ByteOffset = b.Int()
|
f.ByteOffset = b.Int()
|
||||||
op_ = op.Opcode(b.Uint8())
|
op_ = op.Opcode(b.Uint8())
|
||||||
if op_ != op.DW_OP_plus {
|
if op_ != op.DW_OP_plus {
|
||||||
err = dwarf.DecodeError{name, kid.Offset, fmt.Sprintf("unexpected opcode 0x%x", op_)}
|
err = dwarf.DecodeError{Name: name, Offset: kid.Offset, Err: fmt.Sprintf("unexpected opcode 0x%x", op_)}
|
||||||
goto Error
|
goto Error
|
||||||
}
|
}
|
||||||
b.AssertEmpty()
|
b.AssertEmpty()
|
||||||
default:
|
default:
|
||||||
err = dwarf.DecodeError{name, kid.Offset, fmt.Sprintf("unexpected opcode 0x%x", op_)}
|
err = dwarf.DecodeError{Name: name, Offset: kid.Offset, Err: fmt.Sprintf("unexpected opcode 0x%x", op_)}
|
||||||
goto Error
|
goto Error
|
||||||
}
|
}
|
||||||
if b.Err != nil {
|
if b.Err != nil {
|
||||||
|
|||||||
@ -146,6 +146,6 @@ func (b *buf) AssertEmpty() {
|
|||||||
func (b *buf) error(s string) {
|
func (b *buf) error(s string) {
|
||||||
if b.Err == nil {
|
if b.Err == nil {
|
||||||
b.data = nil
|
b.data = nil
|
||||||
b.Err = dwarf.DecodeError{b.name, b.off, s}
|
b.Err = dwarf.DecodeError{Name: b.name, Offset: b.off, Err: s}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,9 @@ func optflags(args []string) []string {
|
|||||||
|
|
||||||
ver, _ := goversion.Installed()
|
ver, _ := goversion.Installed()
|
||||||
switch {
|
switch {
|
||||||
case ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}):
|
case ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}):
|
||||||
args = append(args, "-gcflags", "all=-N -l")
|
args = append(args, "-gcflags", "all=-N -l")
|
||||||
case ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}):
|
case ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}):
|
||||||
args = append(args, "-gcflags", "-N -l", "-a")
|
args = append(args, "-gcflags", "-N -l", "-a")
|
||||||
default:
|
default:
|
||||||
args = append(args, "-gcflags", "-N -l")
|
args = append(args, "-gcflags", "-N -l")
|
||||||
|
|||||||
@ -263,7 +263,7 @@ func TestCoreFpRegisters(t *testing.T) {
|
|||||||
}
|
}
|
||||||
// in go1.10 the crash is executed on a different thread and registers are
|
// in go1.10 the crash is executed on a different thread and registers are
|
||||||
// no longer available in the core dump.
|
// no longer available in the core dump.
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
t.Skip("not supported in go1.10 and later")
|
t.Skip("not supported in go1.10 and later")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,11 +368,12 @@ mainSearch:
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope := proc.FrameToScope(p.BinInfo(), p.CurrentThread(), nil, *mainFrame)
|
scope := proc.FrameToScope(p.BinInfo(), p.CurrentThread(), nil, *mainFrame)
|
||||||
v1, err := scope.EvalVariable("t", proc.LoadConfig{true, 1, 64, 64, -1, 0})
|
loadConfig := proc.LoadConfig{FollowPointers: true, MaxVariableRecurse: 1, MaxStringLen: 64, MaxArrayValues: 64, MaxStructFields: -1}
|
||||||
|
v1, err := scope.EvalVariable("t", loadConfig)
|
||||||
assertNoError(err, t, "EvalVariable(t)")
|
assertNoError(err, t, "EvalVariable(t)")
|
||||||
assertNoError(v1.Unreadable, t, "unreadable variable 't'")
|
assertNoError(v1.Unreadable, t, "unreadable variable 't'")
|
||||||
t.Logf("t = %#v\n", v1)
|
t.Logf("t = %#v\n", v1)
|
||||||
v2, err := scope.EvalVariable("s", proc.LoadConfig{true, 1, 64, 64, -1, 0})
|
v2, err := scope.EvalVariable("s", loadConfig)
|
||||||
assertNoError(err, t, "EvalVariable(s)")
|
assertNoError(err, t, "EvalVariable(s)")
|
||||||
assertNoError(v2.Unreadable, t, "unreadable variable 's'")
|
assertNoError(v2.Unreadable, t, "unreadable variable 's'")
|
||||||
t.Logf("s = %#v\n", v2)
|
t.Logf("s = %#v\n", v2)
|
||||||
|
|||||||
@ -215,8 +215,8 @@ func TestDwarfExprLoclist(t *testing.T) {
|
|||||||
|
|
||||||
dwb.AddSubprogram("main.main", 0x40100, 0x41000)
|
dwb.AddSubprogram("main.main", 0x40100, 0x41000)
|
||||||
dwb.AddVariable("a", uint16off, []dwarfbuilder.LocEntry{
|
dwb.AddVariable("a", uint16off, []dwarfbuilder.LocEntry{
|
||||||
{0x40100, 0x40700, dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa)},
|
{Lowpc: 0x40100, Highpc: 0x40700, Loc: dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa)},
|
||||||
{0x40700, 0x41000, dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa, op.DW_OP_consts, int(2), op.DW_OP_plus)},
|
{Lowpc: 0x40700, Highpc: 0x41000, Loc: dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa, op.DW_OP_consts, int(2), op.DW_OP_plus)},
|
||||||
})
|
})
|
||||||
dwb.TagClose()
|
dwb.TagClose()
|
||||||
|
|
||||||
@ -288,8 +288,8 @@ func TestLocationCovers(t *testing.T) {
|
|||||||
dwb.AddCompileUnit("main", 0x0)
|
dwb.AddCompileUnit("main", 0x0)
|
||||||
dwb.AddSubprogram("main.main", 0x40100, 0x41000)
|
dwb.AddSubprogram("main.main", 0x40100, 0x41000)
|
||||||
aOff := dwb.AddVariable("a", uint16off, []dwarfbuilder.LocEntry{
|
aOff := dwb.AddVariable("a", uint16off, []dwarfbuilder.LocEntry{
|
||||||
{0x40100, 0x40700, dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa)},
|
{Lowpc: 0x40100, Highpc: 0x40700, Loc: dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa)},
|
||||||
{0x40700, 0x41000, dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa, op.DW_OP_consts, int(2), op.DW_OP_plus)},
|
{Lowpc: 0x40700, Highpc: 0x41000, Loc: dwarfbuilder.LocationBlock(op.DW_OP_call_frame_cfa, op.DW_OP_consts, int(2), op.DW_OP_plus)},
|
||||||
})
|
})
|
||||||
dwb.TagClose()
|
dwb.TagClose()
|
||||||
dwb.TagClose()
|
dwb.TagClose()
|
||||||
|
|||||||
@ -55,7 +55,7 @@ func registers(thread *Thread, floatingPoint bool) (proc.Registers, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r := &linutil.AMD64Registers{®s, nil, nil}
|
r := &linutil.AMD64Registers{Regs: ®s}
|
||||||
if floatingPoint {
|
if floatingPoint {
|
||||||
var fpregset linutil.AMD64Xstate
|
var fpregset linutil.AMD64Xstate
|
||||||
r.Fpregs, fpregset, err = thread.fpRegisters()
|
r.Fpregs, fpregset, err = thread.fpRegisters()
|
||||||
|
|||||||
@ -527,7 +527,7 @@ func TestNextGeneral(t *testing.T) {
|
|||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
|
|
||||||
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
testcases = []nextTest{
|
testcases = []nextTest{
|
||||||
{17, 19},
|
{17, 19},
|
||||||
{19, 20},
|
{19, 20},
|
||||||
@ -674,7 +674,7 @@ func TestNextFunctionReturnDefer(t *testing.T) {
|
|||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
|
|
||||||
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
testcases = []nextTest{
|
testcases = []nextTest{
|
||||||
{5, 6},
|
{5, 6},
|
||||||
{6, 9},
|
{6, 9},
|
||||||
@ -1724,7 +1724,7 @@ func TestIssue384(t *testing.T) {
|
|||||||
// Crash related to reading uninitialized memory, introduced by the memory prefetching optimization
|
// Crash related to reading uninitialized memory, introduced by the memory prefetching optimization
|
||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// go 1.10 emits DW_AT_decl_line and we won't be able to evaluate 'st'
|
// go 1.10 emits DW_AT_decl_line and we won't be able to evaluate 'st'
|
||||||
// which is declared after line 13.
|
// which is declared after line 13.
|
||||||
t.Skip("can not evaluate not-yet-declared variables with go 1.10")
|
t.Skip("can not evaluate not-yet-declared variables with go 1.10")
|
||||||
@ -1856,7 +1856,7 @@ func TestPackageVariables(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue149(t *testing.T) {
|
func TestIssue149(t *testing.T) {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// setting breakpoint on break statement
|
// setting breakpoint on break statement
|
||||||
@ -2073,7 +2073,7 @@ func TestIssue509(t *testing.T) {
|
|||||||
|
|
||||||
func TestUnsupportedArch(t *testing.T) {
|
func TestUnsupportedArch(t *testing.T) {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major < 0 || !ver.AfterOrEqual(goversion.GoVersion{1, 6, -1, 0, 0, ""}) || ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major < 0 || !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 6, Rev: -1}) || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
// cross compile (with -N?) works only on select versions of go
|
// cross compile (with -N?) works only on select versions of go
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2725,7 +2725,7 @@ func TestStacktraceWithBarriers(t *testing.T) {
|
|||||||
// struct.
|
// struct.
|
||||||
|
|
||||||
// In Go 1.9 stack barriers have been removed and this test must be disabled.
|
// In Go 1.9 stack barriers have been removed and this test must be disabled.
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3074,7 +3074,7 @@ func TestIssue871(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestShadowedFlag(t *testing.T) {
|
func TestShadowedFlag(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
withTestProcess("testshadow", t, func(p *proc.Target, fixture protest.Fixture) {
|
withTestProcess("testshadow", t, func(p *proc.Target, fixture protest.Fixture) {
|
||||||
@ -3285,13 +3285,13 @@ func frameInFile(frame proc.Stackframe, file string) bool {
|
|||||||
func TestCgoStacktrace(t *testing.T) {
|
func TestCgoStacktrace(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
t.Skip("disabled on windows with go before version 1.9")
|
t.Skip("disabled on windows with go before version 1.9")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 8, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 8, Rev: -1}) {
|
||||||
t.Skip("disabled on macOS with go before version 1.8")
|
t.Skip("disabled on macOS with go before version 1.8")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3394,7 +3394,7 @@ func TestCgoStacktrace(t *testing.T) {
|
|||||||
func TestCgoSources(t *testing.T) {
|
func TestCgoSources(t *testing.T) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
t.Skip("disabled on windows with go before version 1.9")
|
t.Skip("disabled on windows with go before version 1.9")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3516,7 +3516,7 @@ func TestIssue1008(t *testing.T) {
|
|||||||
|
|
||||||
func TestDeclLine(t *testing.T) {
|
func TestDeclLine(t *testing.T) {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
t.Skip("go 1.9 and prior versions do not emit DW_AT_decl_line")
|
t.Skip("go 1.9 and prior versions do not emit DW_AT_decl_line")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3662,7 +3662,7 @@ func checkFrame(frame proc.Stackframe, fnname, file string, line int, inlined bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllPCsForFileLines(t *testing.T) {
|
func TestAllPCsForFileLines(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3683,7 +3683,7 @@ func TestAllPCsForFileLines(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInlinedStacktraceAndVariables(t *testing.T) {
|
func TestInlinedStacktraceAndVariables(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3802,7 +3802,7 @@ func TestInlinedStacktraceAndVariables(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInlineStep(t *testing.T) {
|
func TestInlineStep(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3816,7 +3816,7 @@ func TestInlineStep(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInlineNext(t *testing.T) {
|
func TestInlineNext(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3830,7 +3830,7 @@ func TestInlineNext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInlineStepOver(t *testing.T) {
|
func TestInlineStepOver(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3842,7 +3842,7 @@ func TestInlineStepOver(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInlineStepOut(t *testing.T) {
|
func TestInlineStepOut(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3855,7 +3855,7 @@ func TestInlineStepOut(t *testing.T) {
|
|||||||
|
|
||||||
func TestInlineFunctionList(t *testing.T) {
|
func TestInlineFunctionList(t *testing.T) {
|
||||||
// We should be able to list all functions, even inlined ones.
|
// We should be able to list all functions, even inlined ones.
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3875,7 +3875,7 @@ func TestInlineFunctionList(t *testing.T) {
|
|||||||
|
|
||||||
func TestInlineBreakpoint(t *testing.T) {
|
func TestInlineBreakpoint(t *testing.T) {
|
||||||
// We should be able to set a breakpoint on the call site of an inlined function.
|
// We should be able to set a breakpoint on the call site of an inlined function.
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
// Versions of go before 1.10 do not have DWARF information for inlined calls
|
||||||
t.Skip("inlining not supported")
|
t.Skip("inlining not supported")
|
||||||
}
|
}
|
||||||
@ -3898,7 +3898,7 @@ func TestInlineBreakpoint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIssue951(t *testing.T) {
|
func TestIssue951(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
t.Skip("scopes not implemented in <=go1.8")
|
t.Skip("scopes not implemented in <=go1.8")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3975,7 +3975,7 @@ func TestMapLoadConfigWithReslice(t *testing.T) {
|
|||||||
|
|
||||||
func TestStepOutReturn(t *testing.T) {
|
func TestStepOutReturn(t *testing.T) {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
t.Skip("return variables aren't marked on 1.9 or earlier")
|
t.Skip("return variables aren't marked on 1.9 or earlier")
|
||||||
}
|
}
|
||||||
withTestProcess("stepoutret", t, func(p *proc.Target, fixture protest.Fixture) {
|
withTestProcess("stepoutret", t, func(p *proc.Target, fixture protest.Fixture) {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestScopeWithEscapedVariable(t *testing.T) {
|
func TestScopeWithEscapedVariable(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 3, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1, Beta: 3}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ func TestScopeWithEscapedVariable(t *testing.T) {
|
|||||||
// every variable except the last one should be marked as shadowed
|
// every variable except the last one should be marked as shadowed
|
||||||
// 2. EvalExpression should return the last one.
|
// 2. EvalExpression should return the last one.
|
||||||
func TestScope(t *testing.T) {
|
func TestScope(t *testing.T) {
|
||||||
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver, _ := goversion.Parse(runtime.Version()); ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,7 @@ func BuildFixture(name string, flags BuildFlags) Fixture {
|
|||||||
|
|
||||||
buildFlags := []string{"build"}
|
buildFlags := []string{"build"}
|
||||||
var ver goversion.GoVersion
|
var ver goversion.GoVersion
|
||||||
if ver, _ = goversion.Parse(runtime.Version()); runtime.GOOS == "windows" && ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver, _ = goversion.Parse(runtime.Version()); runtime.GOOS == "windows" && ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
// Work-around for https://github.com/golang/go/issues/13154
|
// Work-around for https://github.com/golang/go/issues/13154
|
||||||
buildFlags = append(buildFlags, "-ldflags=-linkmode internal")
|
buildFlags = append(buildFlags, "-ldflags=-linkmode internal")
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ func BuildFixture(name string, flags BuildFlags) Fixture {
|
|||||||
if flags&BuildModePlugin != 0 {
|
if flags&BuildModePlugin != 0 {
|
||||||
buildFlags = append(buildFlags, "-buildmode=plugin")
|
buildFlags = append(buildFlags, "-buildmode=plugin")
|
||||||
}
|
}
|
||||||
if ver.IsDevel() || ver.AfterOrEqual(goversion.GoVersion{1, 11, -1, 0, 0, ""}) {
|
if ver.IsDevel() || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 11, Rev: -1}) {
|
||||||
if flags&EnableDWZCompression != 0 {
|
if flags&EnableDWZCompression != 0 {
|
||||||
buildFlags = append(buildFlags, "-ldflags=-compressdwarf=false")
|
buildFlags = append(buildFlags, "-ldflags=-compressdwarf=false")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,10 +7,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/cosiner/argv"
|
|
||||||
"github.com/go-delve/delve/service"
|
|
||||||
"github.com/go-delve/delve/service/api"
|
|
||||||
"github.com/go-delve/delve/service/debugger"
|
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/scanner"
|
"go/scanner"
|
||||||
"io"
|
"io"
|
||||||
@ -24,6 +20,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
|
"github.com/cosiner/argv"
|
||||||
|
"github.com/go-delve/delve/service"
|
||||||
|
"github.com/go-delve/delve/service/api"
|
||||||
|
"github.com/go-delve/delve/service/debugger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const optimizedFunctionWarning = "Warning: debugging optimized function"
|
const optimizedFunctionWarning = "Warning: debugging optimized function"
|
||||||
@ -88,10 +89,10 @@ var (
|
|||||||
// * Follows pointers
|
// * Follows pointers
|
||||||
// * Loads more array values
|
// * Loads more array values
|
||||||
// * Does not limit struct fields
|
// * Does not limit struct fields
|
||||||
LongLoadConfig = api.LoadConfig{true, 1, 64, 64, -1}
|
LongLoadConfig = api.LoadConfig{FollowPointers: true, MaxVariableRecurse: 1, MaxStringLen: 64, MaxArrayValues: 64, MaxStructFields: -1}
|
||||||
// ShortLoadConfig loads less information, not following pointers
|
// ShortLoadConfig loads less information, not following pointers
|
||||||
// and limiting struct fields loaded to 3.
|
// and limiting struct fields loaded to 3.
|
||||||
ShortLoadConfig = api.LoadConfig{false, 0, 64, 0, 3}
|
ShortLoadConfig = api.LoadConfig{MaxStringLen: 64, MaxStructFields: 3}
|
||||||
)
|
)
|
||||||
|
|
||||||
// ByFirstAlias will sort by the first
|
// ByFirstAlias will sort by the first
|
||||||
|
|||||||
@ -245,7 +245,9 @@ func TestExecuteFile(t *testing.T) {
|
|||||||
|
|
||||||
func TestIssue354(t *testing.T) {
|
func TestIssue354(t *testing.T) {
|
||||||
printStack([]api.Stackframe{}, "", false)
|
printStack([]api.Stackframe{}, "", false)
|
||||||
printStack([]api.Stackframe{{api.Location{PC: 0, File: "irrelevant.go", Line: 10, Function: nil}, nil, nil, 0, 0, nil, true, ""}}, "", false)
|
printStack([]api.Stackframe{
|
||||||
|
{Location: api.Location{PC: 0, File: "irrelevant.go", Line: 10, Function: nil},
|
||||||
|
Bottom: true}}, "", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIssue411(t *testing.T) {
|
func TestIssue411(t *testing.T) {
|
||||||
@ -778,7 +780,7 @@ func TestConfig(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error executing configureCmd(substitute-path a b): %v", err)
|
t.Fatalf("error executing configureCmd(substitute-path a b): %v", err)
|
||||||
}
|
}
|
||||||
if len(term.conf.SubstitutePath) != 1 || (term.conf.SubstitutePath[0] != config.SubstitutePathRule{"a", "b"}) {
|
if len(term.conf.SubstitutePath) != 1 || (term.conf.SubstitutePath[0] != config.SubstitutePathRule{From: "a", To: "b"}) {
|
||||||
t.Fatalf("unexpected SubstitutePathRules after insert %v", term.conf.SubstitutePath)
|
t.Fatalf("unexpected SubstitutePathRules after insert %v", term.conf.SubstitutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -884,7 +886,7 @@ func TestPrintContextParkedGoroutine(t *testing.T) {
|
|||||||
|
|
||||||
func TestStepOutReturn(t *testing.T) {
|
func TestStepOutReturn(t *testing.T) {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
t.Skip("return variables aren't marked on 1.9 or earlier")
|
t.Skip("return variables aren't marked on 1.9 or earlier")
|
||||||
}
|
}
|
||||||
withTestTerminal("stepoutret", t, func(term *FakeTerminal) {
|
withTestTerminal("stepoutret", t, func(term *FakeTerminal) {
|
||||||
|
|||||||
@ -170,7 +170,7 @@ func configureSetSubstitutePath(t *Term, rest string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.conf.SubstitutePath = append(t.conf.SubstitutePath, config.SubstitutePathRule{argv[0], argv[1]})
|
t.conf.SubstitutePath = append(t.conf.SubstitutePath, config.SubstitutePathRule{From: argv[0], To: argv[1]})
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("too many arguments to \"config substitute-path\"")
|
return fmt.Errorf("too many arguments to \"config substitute-path\"")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// autoLoadConfig is the load configuration used to automatically load more from a variable
|
// autoLoadConfig is the load configuration used to automatically load more from a variable
|
||||||
var autoLoadConfig = api.LoadConfig{false, 1, 1024, 64, -1}
|
var autoLoadConfig = api.LoadConfig{MaxVariableRecurse: 1, MaxStringLen: 1024, MaxArrayValues: 64, MaxStructFields: -1}
|
||||||
|
|
||||||
// interfaceToStarlarkValue converts an interface{} variable (produced by
|
// interfaceToStarlarkValue converts an interface{} variable (produced by
|
||||||
// decoding JSON) into a starlark.Value.
|
// decoding JSON) into a starlark.Value.
|
||||||
@ -253,7 +253,7 @@ func (env *Env) variableValueToStarlarkValue(v *api.Variable, top bool) (starlar
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (env *Env) autoLoad(expr string) *api.Variable {
|
func (env *Env) autoLoad(expr string) *api.Variable {
|
||||||
v, err := env.ctx.Client().EvalVariable(api.EvalScope{-1, 0, 0}, expr, autoLoadConfig)
|
v, err := env.ctx.Client().EvalVariable(api.EvalScope{GoroutineID: -1}, expr, autoLoadConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &api.Variable{Unreadable: err.Error()}
|
return &api.Variable{Unreadable: err.Error()}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ func (ctx starlarkContext) CallCommand(cmdstr string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ctx starlarkContext) Scope() api.EvalScope {
|
func (ctx starlarkContext) Scope() api.EvalScope {
|
||||||
return api.EvalScope{-1, ctx.term.cmds.frame, 0}
|
return api.EvalScope{GoroutineID: -1, Frame: ctx.term.cmds.frame}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx starlarkContext) LoadConfig() api.LoadConfig {
|
func (ctx starlarkContext) LoadConfig() api.LoadConfig {
|
||||||
|
|||||||
@ -417,7 +417,7 @@ func (t *Term) handleExit() (int, error) {
|
|||||||
// loadConfig returns an api.LoadConfig with the parameterss specified in
|
// loadConfig returns an api.LoadConfig with the parameterss specified in
|
||||||
// the configuration file.
|
// the configuration file.
|
||||||
func (t *Term) loadConfig() api.LoadConfig {
|
func (t *Term) loadConfig() api.LoadConfig {
|
||||||
r := api.LoadConfig{true, 1, 64, 64, -1}
|
r := api.LoadConfig{FollowPointers: true, MaxVariableRecurse: 1, MaxStringLen: 64, MaxArrayValues: 64, MaxStructFields: -1}
|
||||||
|
|
||||||
if t.conf != nil && t.conf.MaxStringLen != nil {
|
if t.conf != nil && t.conf.MaxStringLen != nil {
|
||||||
r.MaxStringLen = *t.conf.MaxStringLen
|
r.MaxStringLen = *t.conf.MaxStringLen
|
||||||
|
|||||||
@ -305,12 +305,12 @@ func LoadConfigToProc(cfg *LoadConfig) *proc.LoadConfig {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &proc.LoadConfig{
|
return &proc.LoadConfig{
|
||||||
cfg.FollowPointers,
|
FollowPointers: cfg.FollowPointers,
|
||||||
cfg.MaxVariableRecurse,
|
MaxVariableRecurse: cfg.MaxVariableRecurse,
|
||||||
cfg.MaxStringLen,
|
MaxStringLen: cfg.MaxStringLen,
|
||||||
cfg.MaxArrayValues,
|
MaxArrayValues: cfg.MaxArrayValues,
|
||||||
cfg.MaxStructFields,
|
MaxStructFields: cfg.MaxStructFields,
|
||||||
0, // MaxMapBuckets is set internally by pkg/proc, read its documentation for an explanation.
|
MaxMapBuckets: 0, // MaxMapBuckets is set internally by pkg/proc, read its documentation for an explanation.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,11 +320,11 @@ func LoadConfigFromProc(cfg *proc.LoadConfig) *LoadConfig {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &LoadConfig{
|
return &LoadConfig{
|
||||||
cfg.FollowPointers,
|
FollowPointers: cfg.FollowPointers,
|
||||||
cfg.MaxVariableRecurse,
|
MaxVariableRecurse: cfg.MaxVariableRecurse,
|
||||||
cfg.MaxStringLen,
|
MaxStringLen: cfg.MaxStringLen,
|
||||||
cfg.MaxArrayValues,
|
MaxArrayValues: cfg.MaxArrayValues,
|
||||||
cfg.MaxStructFields,
|
MaxStructFields: cfg.MaxStructFields,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1482,7 +1482,7 @@ func go11DecodeErrorCheck(err error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gover, ok := goversion.Installed()
|
gover, ok := goversion.Installed()
|
||||||
if !ok || !gover.AfterOrEqual(goversion.GoVersion{1, 11, -1, 0, 0, ""}) || goversion.VersionAfterOrEqual(runtime.Version(), 1, 11) {
|
if !ok || !gover.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 11, Rev: -1}) || goversion.VersionAfterOrEqual(runtime.Version(), 1, 11) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -275,7 +275,7 @@ func (loc *AddrLocationSpec) Find(d *Debugger, scope *proc.EvalScope, locStr str
|
|||||||
}
|
}
|
||||||
return []api.Location{{PC: uint64(addr)}}, nil
|
return []api.Location{{PC: uint64(addr)}}, nil
|
||||||
} else {
|
} else {
|
||||||
v, err := scope.EvalExpression(loc.AddrExpr, proc.LoadConfig{true, 0, 0, 0, 0, 0})
|
v, err := scope.EvalExpression(loc.AddrExpr, proc.LoadConfig{FollowPointers: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,13 @@ import (
|
|||||||
"github.com/go-delve/delve/service/debugger"
|
"github.com/go-delve/delve/service/debugger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var defaultLoadConfig = proc.LoadConfig{true, 1, 64, 64, -1, 0}
|
var defaultLoadConfig = proc.LoadConfig{
|
||||||
|
FollowPointers: true,
|
||||||
|
MaxVariableRecurse: 1,
|
||||||
|
MaxStringLen: 64,
|
||||||
|
MaxArrayValues: 64,
|
||||||
|
MaxStructFields: -1,
|
||||||
|
}
|
||||||
|
|
||||||
type RPCServer struct {
|
type RPCServer struct {
|
||||||
// config is all the information necessary to start the debugger and server.
|
// config is all the information necessary to start the debugger and server.
|
||||||
|
|||||||
@ -33,7 +33,7 @@ func NewClient(addr string) *RPCClient {
|
|||||||
|
|
||||||
func newFromRPCClient(client *rpc.Client) *RPCClient {
|
func newFromRPCClient(client *rpc.Client) *RPCClient {
|
||||||
c := &RPCClient{client: client}
|
c := &RPCClient{client: client}
|
||||||
c.call("SetApiVersion", api.SetAPIVersionIn{2}, &api.SetAPIVersionOut{})
|
c.call("SetApiVersion", api.SetAPIVersionIn{APIVersion: 2}, &api.SetAPIVersionOut{})
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -174,7 +174,7 @@ type StacktraceOut struct {
|
|||||||
func (s *RPCServer) Stacktrace(arg StacktraceIn, out *StacktraceOut) error {
|
func (s *RPCServer) Stacktrace(arg StacktraceIn, out *StacktraceOut) error {
|
||||||
cfg := arg.Cfg
|
cfg := arg.Cfg
|
||||||
if cfg == nil && arg.Full {
|
if cfg == nil && arg.Full {
|
||||||
cfg = &api.LoadConfig{true, 1, 64, 64, -1}
|
cfg = &api.LoadConfig{FollowPointers: true, MaxVariableRecurse: 1, MaxStringLen: 64, MaxArrayValues: 64, MaxStructFields: -1}
|
||||||
}
|
}
|
||||||
if arg.Defers {
|
if arg.Defers {
|
||||||
arg.Opts |= api.StacktraceReadDefers
|
arg.Opts |= api.StacktraceReadDefers
|
||||||
@ -453,7 +453,7 @@ type EvalOut struct {
|
|||||||
func (s *RPCServer) Eval(arg EvalIn, out *EvalOut) error {
|
func (s *RPCServer) Eval(arg EvalIn, out *EvalOut) error {
|
||||||
cfg := arg.Cfg
|
cfg := arg.Cfg
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
cfg = &api.LoadConfig{true, 1, 64, 64, -1}
|
cfg = &api.LoadConfig{FollowPointers: true, MaxVariableRecurse: 1, MaxStringLen: 64, MaxArrayValues: 64, MaxStructFields: -1}
|
||||||
}
|
}
|
||||||
v, err := s.debugger.EvalVariableInScope(arg.Scope, arg.Expr, *api.LoadConfigToProc(cfg))
|
v, err := s.debugger.EvalVariableInScope(arg.Scope, arg.Expr, *api.LoadConfigToProc(cfg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -89,9 +89,9 @@ func findLocationHelper(t *testing.T, c interface{}, loc string, shouldErr bool,
|
|||||||
|
|
||||||
switch c := c.(type) {
|
switch c := c.(type) {
|
||||||
case locationFinder1:
|
case locationFinder1:
|
||||||
locs, err = c.FindLocation(api.EvalScope{-1, 0, 0}, loc)
|
locs, err = c.FindLocation(api.EvalScope{GoroutineID: -1}, loc)
|
||||||
case locationFinder2:
|
case locationFinder2:
|
||||||
locs, err = c.FindLocation(api.EvalScope{-1, 0, 0}, loc, false)
|
locs, err = c.FindLocation(api.EvalScope{GoroutineID: -1}, loc, false)
|
||||||
default:
|
default:
|
||||||
t.Errorf("unexpected type %T passed to findLocationHelper", c)
|
t.Errorf("unexpected type %T passed to findLocationHelper", c)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -253,7 +253,7 @@ func Test1NextGeneral(t *testing.T) {
|
|||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
|
|
||||||
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
testcases = []nextTest{
|
testcases = []nextTest{
|
||||||
{17, 19},
|
{17, 19},
|
||||||
{19, 20},
|
{19, 20},
|
||||||
@ -433,7 +433,7 @@ func Test1ClientServer_infoLocals(t *testing.T) {
|
|||||||
if state.Err != nil {
|
if state.Err != nil {
|
||||||
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
||||||
}
|
}
|
||||||
locals, err := c.ListLocalVariables(api.EvalScope{-1, 0, 0})
|
locals, err := c.ListLocalVariables(api.EvalScope{GoroutineID: -1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ func Test1ClientServer_infoArgs(t *testing.T) {
|
|||||||
if regs == "" {
|
if regs == "" {
|
||||||
t.Fatal("Expected string showing registers values, got empty string")
|
t.Fatal("Expected string showing registers values, got empty string")
|
||||||
}
|
}
|
||||||
locals, err := c.ListFunctionArgs(api.EvalScope{-1, 0, 0})
|
locals, err := c.ListFunctionArgs(api.EvalScope{GoroutineID: -1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ func Test1ClientServer_EvalVariable(t *testing.T) {
|
|||||||
t.Fatalf("Continue(): %v\n", state.Err)
|
t.Fatalf("Continue(): %v\n", state.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var1, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "a1")
|
var1, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "a1")
|
||||||
assertNoError(err, t, "EvalVariable")
|
assertNoError(err, t, "EvalVariable")
|
||||||
|
|
||||||
t.Logf("var1: %s", var1.SinglelineString())
|
t.Logf("var1: %s", var1.SinglelineString())
|
||||||
@ -706,9 +706,9 @@ func Test1ClientServer_SetVariable(t *testing.T) {
|
|||||||
t.Fatalf("Continue(): %v\n", state.Err)
|
t.Fatalf("Continue(): %v\n", state.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNoError(c.SetVariable(api.EvalScope{-1, 0, 0}, "a2", "8"), t, "SetVariable()")
|
assertNoError(c.SetVariable(api.EvalScope{GoroutineID: -1}, "a2", "8"), t, "SetVariable()")
|
||||||
|
|
||||||
a2, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "a2")
|
a2, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "a2")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not evaluate variable: %v", err)
|
t.Fatalf("Could not evaluate variable: %v", err)
|
||||||
}
|
}
|
||||||
@ -835,10 +835,10 @@ func Test1Issue355(t *testing.T) {
|
|||||||
assertError(err, t, "ListThreads()")
|
assertError(err, t, "ListThreads()")
|
||||||
_, err = c.GetThread(tid)
|
_, err = c.GetThread(tid)
|
||||||
assertError(err, t, "GetThread()")
|
assertError(err, t, "GetThread()")
|
||||||
assertError(c.SetVariable(api.EvalScope{gid, 0, 0}, "a", "10"), t, "SetVariable()")
|
assertError(c.SetVariable(api.EvalScope{GoroutineID: gid}, "a", "10"), t, "SetVariable()")
|
||||||
_, err = c.ListLocalVariables(api.EvalScope{gid, 0, 0})
|
_, err = c.ListLocalVariables(api.EvalScope{GoroutineID: gid})
|
||||||
assertError(err, t, "ListLocalVariables()")
|
assertError(err, t, "ListLocalVariables()")
|
||||||
_, err = c.ListFunctionArgs(api.EvalScope{gid, 0, 0})
|
_, err = c.ListFunctionArgs(api.EvalScope{GoroutineID: gid})
|
||||||
assertError(err, t, "ListFunctionArgs()")
|
assertError(err, t, "ListFunctionArgs()")
|
||||||
_, err = c.ListRegisters()
|
_, err = c.ListRegisters()
|
||||||
assertError(err, t, "ListRegisters()")
|
assertError(err, t, "ListRegisters()")
|
||||||
@ -846,9 +846,9 @@ func Test1Issue355(t *testing.T) {
|
|||||||
assertError(err, t, "ListGoroutines()")
|
assertError(err, t, "ListGoroutines()")
|
||||||
_, err = c.Stacktrace(gid, 10, false)
|
_, err = c.Stacktrace(gid, 10, false)
|
||||||
assertError(err, t, "Stacktrace()")
|
assertError(err, t, "Stacktrace()")
|
||||||
_, err = c.FindLocation(api.EvalScope{gid, 0, 0}, "+1")
|
_, err = c.FindLocation(api.EvalScope{GoroutineID: gid}, "+1")
|
||||||
assertError(err, t, "FindLocation()")
|
assertError(err, t, "FindLocation()")
|
||||||
_, err = c.DisassemblePC(api.EvalScope{-1, 0, 0}, 0x40100, api.IntelFlavour)
|
_, err = c.DisassemblePC(api.EvalScope{GoroutineID: -1}, 0x40100, api.IntelFlavour)
|
||||||
assertError(err, t, "DisassemblePC()")
|
assertError(err, t, "DisassemblePC()")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -863,12 +863,12 @@ func Test1Disasm(t *testing.T) {
|
|||||||
state := <-ch
|
state := <-ch
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
|
|
||||||
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "main.main")
|
locs, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "main.main")
|
||||||
assertNoError(err, t, "FindLocation()")
|
assertNoError(err, t, "FindLocation()")
|
||||||
if len(locs) != 1 {
|
if len(locs) != 1 {
|
||||||
t.Fatalf("wrong number of locations for main.main: %d", len(locs))
|
t.Fatalf("wrong number of locations for main.main: %d", len(locs))
|
||||||
}
|
}
|
||||||
d1, err := c.DisassemblePC(api.EvalScope{-1, 0, 0}, locs[0].PC, api.IntelFlavour)
|
d1, err := c.DisassemblePC(api.EvalScope{GoroutineID: -1}, locs[0].PC, api.IntelFlavour)
|
||||||
assertNoError(err, t, "DisassemblePC()")
|
assertNoError(err, t, "DisassemblePC()")
|
||||||
if len(d1) < 2 {
|
if len(d1) < 2 {
|
||||||
t.Fatalf("wrong size of disassembly: %d", len(d1))
|
t.Fatalf("wrong size of disassembly: %d", len(d1))
|
||||||
@ -876,7 +876,7 @@ func Test1Disasm(t *testing.T) {
|
|||||||
|
|
||||||
pcstart := d1[0].Loc.PC
|
pcstart := d1[0].Loc.PC
|
||||||
pcend := d1[len(d1)-1].Loc.PC + uint64(len(d1[len(d1)-1].Bytes))
|
pcend := d1[len(d1)-1].Loc.PC + uint64(len(d1[len(d1)-1].Bytes))
|
||||||
d2, err := c.DisassembleRange(api.EvalScope{-1, 0, 0}, pcstart, pcend, api.IntelFlavour)
|
d2, err := c.DisassembleRange(api.EvalScope{GoroutineID: -1}, pcstart, pcend, api.IntelFlavour)
|
||||||
assertNoError(err, t, "DisassembleRange()")
|
assertNoError(err, t, "DisassembleRange()")
|
||||||
|
|
||||||
if len(d1) != len(d2) {
|
if len(d1) != len(d2) {
|
||||||
@ -885,7 +885,7 @@ func Test1Disasm(t *testing.T) {
|
|||||||
t.Fatal("mismatched length between disassemble pc and disassemble range")
|
t.Fatal("mismatched length between disassemble pc and disassemble range")
|
||||||
}
|
}
|
||||||
|
|
||||||
d3, err := c.DisassemblePC(api.EvalScope{-1, 0, 0}, state.CurrentThread.PC, api.IntelFlavour)
|
d3, err := c.DisassemblePC(api.EvalScope{GoroutineID: -1}, state.CurrentThread.PC, api.IntelFlavour)
|
||||||
assertNoError(err, t, "DisassemblePC() - second call")
|
assertNoError(err, t, "DisassemblePC() - second call")
|
||||||
|
|
||||||
if len(d1) != len(d3) {
|
if len(d1) != len(d3) {
|
||||||
@ -934,7 +934,7 @@ func Test1Disasm(t *testing.T) {
|
|||||||
state, err := c.StepInstruction()
|
state, err := c.StepInstruction()
|
||||||
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
||||||
|
|
||||||
d3, err = c.DisassemblePC(api.EvalScope{-1, 0, 0}, state.CurrentThread.PC, api.IntelFlavour)
|
d3, err = c.DisassemblePC(api.EvalScope{GoroutineID: -1}, state.CurrentThread.PC, api.IntelFlavour)
|
||||||
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
||||||
|
|
||||||
curinstr := getCurinstr(d3)
|
curinstr := getCurinstr(d3)
|
||||||
@ -1000,7 +1000,7 @@ func Test1ClientServer_CondBreakpoint(t *testing.T) {
|
|||||||
state := <-c.Continue()
|
state := <-c.Continue()
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
|
|
||||||
nvar, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "n")
|
nvar, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "n")
|
||||||
assertNoError(err, t, "EvalVariable()")
|
assertNoError(err, t, "EvalVariable()")
|
||||||
|
|
||||||
if nvar.SinglelineString() != "7" {
|
if nvar.SinglelineString() != "7" {
|
||||||
@ -1054,14 +1054,14 @@ func Test1TypesCommand(t *testing.T) {
|
|||||||
|
|
||||||
func Test1Issue406(t *testing.T) {
|
func Test1Issue406(t *testing.T) {
|
||||||
withTestClient1("issue406", t, func(c *rpc1.RPCClient) {
|
withTestClient1("issue406", t, func(c *rpc1.RPCClient) {
|
||||||
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "issue406.go:146")
|
locs, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "issue406.go:146")
|
||||||
assertNoError(err, t, "FindLocation()")
|
assertNoError(err, t, "FindLocation()")
|
||||||
_, err = c.CreateBreakpoint(&api.Breakpoint{Addr: locs[0].PC})
|
_, err = c.CreateBreakpoint(&api.Breakpoint{Addr: locs[0].PC})
|
||||||
assertNoError(err, t, "CreateBreakpoint()")
|
assertNoError(err, t, "CreateBreakpoint()")
|
||||||
ch := c.Continue()
|
ch := c.Continue()
|
||||||
state := <-ch
|
state := <-ch
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
v, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "cfgtree")
|
v, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "cfgtree")
|
||||||
assertNoError(err, t, "EvalVariable()")
|
assertNoError(err, t, "EvalVariable()")
|
||||||
vs := v.MultilineString("")
|
vs := v.MultilineString("")
|
||||||
t.Logf("cfgtree formats to: %s\n", vs)
|
t.Logf("cfgtree formats to: %s\n", vs)
|
||||||
|
|||||||
@ -26,7 +26,14 @@ import (
|
|||||||
"github.com/go-delve/delve/service/rpccommon"
|
"github.com/go-delve/delve/service/rpccommon"
|
||||||
)
|
)
|
||||||
|
|
||||||
var normalLoadConfig = api.LoadConfig{true, 1, 64, 64, -1}
|
var normalLoadConfig = api.LoadConfig{
|
||||||
|
FollowPointers: true,
|
||||||
|
MaxVariableRecurse: 1,
|
||||||
|
MaxStringLen: 64,
|
||||||
|
MaxArrayValues: 64,
|
||||||
|
MaxStructFields: -1,
|
||||||
|
}
|
||||||
|
|
||||||
var testBackend, buildMode string
|
var testBackend, buildMode string
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
@ -304,7 +311,7 @@ func TestNextGeneral(t *testing.T) {
|
|||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
|
|
||||||
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
testcases = []nextTest{
|
testcases = []nextTest{
|
||||||
{17, 19},
|
{17, 19},
|
||||||
{19, 20},
|
{19, 20},
|
||||||
@ -488,7 +495,7 @@ func TestClientServer_infoLocals(t *testing.T) {
|
|||||||
if state.Err != nil {
|
if state.Err != nil {
|
||||||
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
||||||
}
|
}
|
||||||
locals, err := c.ListLocalVariables(api.EvalScope{-1, 0, 0}, normalLoadConfig)
|
locals, err := c.ListLocalVariables(api.EvalScope{GoroutineID: -1}, normalLoadConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -532,7 +539,7 @@ func TestClientServer_infoArgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Logf("GoroutineID: -1, Frame: 1\n%s", regs.String())
|
t.Logf("GoroutineID: -1, Frame: 1\n%s", regs.String())
|
||||||
|
|
||||||
locals, err := c.ListFunctionArgs(api.EvalScope{-1, 0, 0}, normalLoadConfig)
|
locals, err := c.ListFunctionArgs(api.EvalScope{GoroutineID: -1}, normalLoadConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unexpected error: %v", err)
|
t.Fatalf("Unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
@ -781,7 +788,7 @@ func TestClientServer_EvalVariable(t *testing.T) {
|
|||||||
t.Fatalf("Continue(): %v\n", state.Err)
|
t.Fatalf("Continue(): %v\n", state.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var1, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "a1", normalLoadConfig)
|
var1, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "a1", normalLoadConfig)
|
||||||
assertNoError(err, t, "EvalVariable")
|
assertNoError(err, t, "EvalVariable")
|
||||||
|
|
||||||
t.Logf("var1: %s", var1.SinglelineString())
|
t.Logf("var1: %s", var1.SinglelineString())
|
||||||
@ -800,9 +807,9 @@ func TestClientServer_SetVariable(t *testing.T) {
|
|||||||
t.Fatalf("Continue(): %v\n", state.Err)
|
t.Fatalf("Continue(): %v\n", state.Err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNoError(c.SetVariable(api.EvalScope{-1, 0, 0}, "a2", "8"), t, "SetVariable()")
|
assertNoError(c.SetVariable(api.EvalScope{GoroutineID: -1}, "a2", "8"), t, "SetVariable()")
|
||||||
|
|
||||||
a2, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "a2", normalLoadConfig)
|
a2, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "a2", normalLoadConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not evaluate variable: %v", err)
|
t.Fatalf("Could not evaluate variable: %v", err)
|
||||||
}
|
}
|
||||||
@ -935,22 +942,22 @@ func TestIssue355(t *testing.T) {
|
|||||||
assertError(err, t, "ListThreads()")
|
assertError(err, t, "ListThreads()")
|
||||||
_, err = c.GetThread(tid)
|
_, err = c.GetThread(tid)
|
||||||
assertError(err, t, "GetThread()")
|
assertError(err, t, "GetThread()")
|
||||||
assertError(c.SetVariable(api.EvalScope{gid, 0, 0}, "a", "10"), t, "SetVariable()")
|
assertError(c.SetVariable(api.EvalScope{GoroutineID: gid}, "a", "10"), t, "SetVariable()")
|
||||||
_, err = c.ListLocalVariables(api.EvalScope{gid, 0, 0}, normalLoadConfig)
|
_, err = c.ListLocalVariables(api.EvalScope{GoroutineID: gid}, normalLoadConfig)
|
||||||
assertError(err, t, "ListLocalVariables()")
|
assertError(err, t, "ListLocalVariables()")
|
||||||
_, err = c.ListFunctionArgs(api.EvalScope{gid, 0, 0}, normalLoadConfig)
|
_, err = c.ListFunctionArgs(api.EvalScope{GoroutineID: gid}, normalLoadConfig)
|
||||||
assertError(err, t, "ListFunctionArgs()")
|
assertError(err, t, "ListFunctionArgs()")
|
||||||
_, err = c.ListThreadRegisters(0, false)
|
_, err = c.ListThreadRegisters(0, false)
|
||||||
assertError(err, t, "ListThreadRegisters()")
|
assertError(err, t, "ListThreadRegisters()")
|
||||||
_, err = c.ListScopeRegisters(api.EvalScope{gid, 0, 0}, false)
|
_, err = c.ListScopeRegisters(api.EvalScope{GoroutineID: gid}, false)
|
||||||
assertError(err, t, "ListScopeRegisters()")
|
assertError(err, t, "ListScopeRegisters()")
|
||||||
_, _, err = c.ListGoroutines(0, 0)
|
_, _, err = c.ListGoroutines(0, 0)
|
||||||
assertError(err, t, "ListGoroutines()")
|
assertError(err, t, "ListGoroutines()")
|
||||||
_, err = c.Stacktrace(gid, 10, 0, &normalLoadConfig)
|
_, err = c.Stacktrace(gid, 10, 0, &normalLoadConfig)
|
||||||
assertError(err, t, "Stacktrace()")
|
assertError(err, t, "Stacktrace()")
|
||||||
_, err = c.FindLocation(api.EvalScope{gid, 0, 0}, "+1", false)
|
_, err = c.FindLocation(api.EvalScope{GoroutineID: gid}, "+1", false)
|
||||||
assertError(err, t, "FindLocation()")
|
assertError(err, t, "FindLocation()")
|
||||||
_, err = c.DisassemblePC(api.EvalScope{-1, 0, 0}, 0x40100, api.IntelFlavour)
|
_, err = c.DisassemblePC(api.EvalScope{GoroutineID: -1}, 0x40100, api.IntelFlavour)
|
||||||
assertError(err, t, "DisassemblePC()")
|
assertError(err, t, "DisassemblePC()")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -965,12 +972,12 @@ func TestDisasm(t *testing.T) {
|
|||||||
state := <-ch
|
state := <-ch
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
|
|
||||||
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "main.main", false)
|
locs, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "main.main", false)
|
||||||
assertNoError(err, t, "FindLocation()")
|
assertNoError(err, t, "FindLocation()")
|
||||||
if len(locs) != 1 {
|
if len(locs) != 1 {
|
||||||
t.Fatalf("wrong number of locations for main.main: %d", len(locs))
|
t.Fatalf("wrong number of locations for main.main: %d", len(locs))
|
||||||
}
|
}
|
||||||
d1, err := c.DisassemblePC(api.EvalScope{-1, 0, 0}, locs[0].PC, api.IntelFlavour)
|
d1, err := c.DisassemblePC(api.EvalScope{GoroutineID: -1}, locs[0].PC, api.IntelFlavour)
|
||||||
assertNoError(err, t, "DisassemblePC()")
|
assertNoError(err, t, "DisassemblePC()")
|
||||||
if len(d1) < 2 {
|
if len(d1) < 2 {
|
||||||
t.Fatalf("wrong size of disassembly: %d", len(d1))
|
t.Fatalf("wrong size of disassembly: %d", len(d1))
|
||||||
@ -980,10 +987,10 @@ func TestDisasm(t *testing.T) {
|
|||||||
pcend := d1[len(d1)-1].Loc.PC + uint64(len(d1[len(d1)-1].Bytes))
|
pcend := d1[len(d1)-1].Loc.PC + uint64(len(d1[len(d1)-1].Bytes))
|
||||||
|
|
||||||
// start address should be less than end address
|
// start address should be less than end address
|
||||||
_, err = c.DisassembleRange(api.EvalScope{-1, 0, 0}, pcend, pcstart, api.IntelFlavour)
|
_, err = c.DisassembleRange(api.EvalScope{GoroutineID: -1}, pcend, pcstart, api.IntelFlavour)
|
||||||
assertError(err, t, "DisassembleRange()")
|
assertError(err, t, "DisassembleRange()")
|
||||||
|
|
||||||
d2, err := c.DisassembleRange(api.EvalScope{-1, 0, 0}, pcstart, pcend, api.IntelFlavour)
|
d2, err := c.DisassembleRange(api.EvalScope{GoroutineID: -1}, pcstart, pcend, api.IntelFlavour)
|
||||||
assertNoError(err, t, "DisassembleRange()")
|
assertNoError(err, t, "DisassembleRange()")
|
||||||
|
|
||||||
if len(d1) != len(d2) {
|
if len(d1) != len(d2) {
|
||||||
@ -992,7 +999,7 @@ func TestDisasm(t *testing.T) {
|
|||||||
t.Fatal("mismatched length between disassemble pc and disassemble range")
|
t.Fatal("mismatched length between disassemble pc and disassemble range")
|
||||||
}
|
}
|
||||||
|
|
||||||
d3, err := c.DisassemblePC(api.EvalScope{-1, 0, 0}, state.CurrentThread.PC, api.IntelFlavour)
|
d3, err := c.DisassemblePC(api.EvalScope{GoroutineID: -1}, state.CurrentThread.PC, api.IntelFlavour)
|
||||||
assertNoError(err, t, "DisassemblePC() - second call")
|
assertNoError(err, t, "DisassemblePC() - second call")
|
||||||
|
|
||||||
if len(d1) != len(d3) {
|
if len(d1) != len(d3) {
|
||||||
@ -1041,7 +1048,7 @@ func TestDisasm(t *testing.T) {
|
|||||||
state, err := c.StepInstruction()
|
state, err := c.StepInstruction()
|
||||||
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
||||||
|
|
||||||
d3, err = c.DisassemblePC(api.EvalScope{-1, 0, 0}, state.CurrentThread.PC, api.IntelFlavour)
|
d3, err = c.DisassemblePC(api.EvalScope{GoroutineID: -1}, state.CurrentThread.PC, api.IntelFlavour)
|
||||||
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
assertNoError(err, t, fmt.Sprintf("StepInstruction() %d", count))
|
||||||
|
|
||||||
curinstr := getCurinstr(d3)
|
curinstr := getCurinstr(d3)
|
||||||
@ -1109,7 +1116,7 @@ func TestClientServer_CondBreakpoint(t *testing.T) {
|
|||||||
state := <-c.Continue()
|
state := <-c.Continue()
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
|
|
||||||
nvar, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "n", normalLoadConfig)
|
nvar, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "n", normalLoadConfig)
|
||||||
assertNoError(err, t, "EvalVariable()")
|
assertNoError(err, t, "EvalVariable()")
|
||||||
|
|
||||||
if nvar.SinglelineString() != "7" {
|
if nvar.SinglelineString() != "7" {
|
||||||
@ -1227,14 +1234,14 @@ func TestTypesCommand(t *testing.T) {
|
|||||||
func TestIssue406(t *testing.T) {
|
func TestIssue406(t *testing.T) {
|
||||||
protest.AllowRecording(t)
|
protest.AllowRecording(t)
|
||||||
withTestClient2("issue406", t, func(c service.Client) {
|
withTestClient2("issue406", t, func(c service.Client) {
|
||||||
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "issue406.go:146", false)
|
locs, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "issue406.go:146", false)
|
||||||
assertNoError(err, t, "FindLocation()")
|
assertNoError(err, t, "FindLocation()")
|
||||||
_, err = c.CreateBreakpoint(&api.Breakpoint{Addr: locs[0].PC})
|
_, err = c.CreateBreakpoint(&api.Breakpoint{Addr: locs[0].PC})
|
||||||
assertNoError(err, t, "CreateBreakpoint()")
|
assertNoError(err, t, "CreateBreakpoint()")
|
||||||
ch := c.Continue()
|
ch := c.Continue()
|
||||||
state := <-ch
|
state := <-ch
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
v, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "cfgtree", normalLoadConfig)
|
v, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "cfgtree", normalLoadConfig)
|
||||||
assertNoError(err, t, "EvalVariable()")
|
assertNoError(err, t, "EvalVariable()")
|
||||||
vs := v.MultilineString("")
|
vs := v.MultilineString("")
|
||||||
t.Logf("cfgtree formats to: %s\n", vs)
|
t.Logf("cfgtree formats to: %s\n", vs)
|
||||||
@ -1246,7 +1253,7 @@ func TestEvalExprName(t *testing.T) {
|
|||||||
state := <-c.Continue()
|
state := <-c.Continue()
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
|
|
||||||
var1, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "i1+1", normalLoadConfig)
|
var1, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "i1+1", normalLoadConfig)
|
||||||
assertNoError(err, t, "EvalVariable")
|
assertNoError(err, t, "EvalVariable")
|
||||||
|
|
||||||
const name = "i1+1"
|
const name = "i1+1"
|
||||||
@ -1266,7 +1273,7 @@ func TestClientServer_Issue528(t *testing.T) {
|
|||||||
// f744717d1924340b8f5e5a385e99078693ad9097
|
// f744717d1924340b8f5e5a385e99078693ad9097
|
||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
t.Log("Test skipped")
|
t.Log("Test skipped")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1489,7 +1496,7 @@ func TestClientServerConsistentExit(t *testing.T) {
|
|||||||
|
|
||||||
func TestClientServer_StepOutReturn(t *testing.T) {
|
func TestClientServer_StepOutReturn(t *testing.T) {
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
t.Skip("return variables aren't marked on 1.9 or earlier")
|
t.Skip("return variables aren't marked on 1.9 or earlier")
|
||||||
}
|
}
|
||||||
withTestClient2("stepoutret", t, func(c service.Client) {
|
withTestClient2("stepoutret", t, func(c service.Client) {
|
||||||
@ -1583,7 +1590,7 @@ func TestAcceptMulticlient(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mustHaveDebugCalls(t *testing.T, c service.Client) {
|
func mustHaveDebugCalls(t *testing.T, c service.Client) {
|
||||||
locs, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "runtime.debugCallV1", false)
|
locs, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "runtime.debugCallV1", false)
|
||||||
if len(locs) == 0 || err != nil {
|
if len(locs) == 0 || err != nil {
|
||||||
t.Skip("function calls not supported on this version of go")
|
t.Skip("function calls not supported on this version of go")
|
||||||
}
|
}
|
||||||
@ -1633,7 +1640,7 @@ func TestClientServerFunctionCallBadPos(t *testing.T) {
|
|||||||
}
|
}
|
||||||
withTestClient2("fncall", t, func(c service.Client) {
|
withTestClient2("fncall", t, func(c service.Client) {
|
||||||
mustHaveDebugCalls(t, c)
|
mustHaveDebugCalls(t, c)
|
||||||
loc, err := c.FindLocation(api.EvalScope{-1, 0, 0}, "fmt/print.go:649", false)
|
loc, err := c.FindLocation(api.EvalScope{GoroutineID: -1}, "fmt/print.go:649", false)
|
||||||
assertNoError(err, t, "could not find location")
|
assertNoError(err, t, "could not find location")
|
||||||
|
|
||||||
_, err = c.CreateBreakpoint(&api.Breakpoint{File: loc[0].File, Line: loc[0].Line})
|
_, err = c.CreateBreakpoint(&api.Breakpoint{File: loc[0].File, Line: loc[0].Line})
|
||||||
@ -1689,7 +1696,7 @@ func TestClientServerFunctionCallStacktrace(t *testing.T) {
|
|||||||
protest.MustSupportFunctionCalls(t, testBackend)
|
protest.MustSupportFunctionCalls(t, testBackend)
|
||||||
withTestClient2("fncall", t, func(c service.Client) {
|
withTestClient2("fncall", t, func(c service.Client) {
|
||||||
mustHaveDebugCalls(t, c)
|
mustHaveDebugCalls(t, c)
|
||||||
c.SetReturnValuesLoadConfig(&api.LoadConfig{false, 0, 2048, 0, 0})
|
c.SetReturnValuesLoadConfig(&api.LoadConfig{FollowPointers: false, MaxStringLen: 2048})
|
||||||
state := <-c.Continue()
|
state := <-c.Continue()
|
||||||
assertNoError(state.Err, t, "Continue()")
|
assertNoError(state.Err, t, "Continue()")
|
||||||
state, err := c.Call(-1, "callstacktrace()", false)
|
state, err := c.Call(-1, "callstacktrace()", false)
|
||||||
@ -1750,7 +1757,7 @@ type brokenRPCClient struct {
|
|||||||
func (c *brokenRPCClient) Detach(kill bool) error {
|
func (c *brokenRPCClient) Detach(kill bool) error {
|
||||||
defer c.client.Close()
|
defer c.client.Close()
|
||||||
out := new(rpc2.DetachOut)
|
out := new(rpc2.DetachOut)
|
||||||
return c.call("Detach", rpc2.DetachIn{kill}, out)
|
return c.call("Detach", rpc2.DetachIn{Kill: kill}, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *brokenRPCClient) call(method string, args, reply interface{}) error {
|
func (c *brokenRPCClient) call(method string, args, reply interface{}) error {
|
||||||
@ -1760,7 +1767,7 @@ func (c *brokenRPCClient) call(method string, args, reply interface{}) error {
|
|||||||
func TestUnknownMethodCall(t *testing.T) {
|
func TestUnknownMethodCall(t *testing.T) {
|
||||||
clientConn, _ := startServer("continuetestprog", t)
|
clientConn, _ := startServer("continuetestprog", t)
|
||||||
client := &brokenRPCClient{jsonrpc.NewClient(clientConn)}
|
client := &brokenRPCClient{jsonrpc.NewClient(clientConn)}
|
||||||
client.call("SetApiVersion", api.SetAPIVersionIn{2}, &api.SetAPIVersionOut{})
|
client.call("SetApiVersion", api.SetAPIVersionIn{APIVersion: 2}, &api.SetAPIVersionOut{})
|
||||||
defer client.Detach(true)
|
defer client.Detach(true)
|
||||||
var out int
|
var out int
|
||||||
err := client.call("NonexistentRPCCall", nil, &out)
|
err := client.call("NonexistentRPCCall", nil, &out)
|
||||||
@ -1798,7 +1805,7 @@ func TestRerecord(t *testing.T) {
|
|||||||
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
t.Fatalf("Unexpected error: %v, state: %#v", state.Err, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
vart, err := c.EvalVariable(api.EvalScope{-1, 0, 0}, "t", normalLoadConfig)
|
vart, err := c.EvalVariable(api.EvalScope{GoroutineID: -1}, "t", normalLoadConfig)
|
||||||
assertNoError(err, t, "EvalVariable")
|
assertNoError(err, t, "EvalVariable")
|
||||||
if vart.Unreadable != "" {
|
if vart.Unreadable != "" {
|
||||||
t.Fatalf("Could not read variable 't': %s\n", vart.Unreadable)
|
t.Fatalf("Could not read variable 't': %s\n", vart.Unreadable)
|
||||||
|
|||||||
@ -19,8 +19,18 @@ import (
|
|||||||
protest "github.com/go-delve/delve/pkg/proc/test"
|
protest "github.com/go-delve/delve/pkg/proc/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
var pnormalLoadConfig = proc.LoadConfig{true, 1, 64, 64, -1, 0}
|
var pnormalLoadConfig = proc.LoadConfig{
|
||||||
var pshortLoadConfig = proc.LoadConfig{false, 0, 64, 0, 3, 0}
|
FollowPointers: true,
|
||||||
|
MaxVariableRecurse: 1,
|
||||||
|
MaxStringLen: 64,
|
||||||
|
MaxArrayValues: 64,
|
||||||
|
MaxStructFields: -1,
|
||||||
|
}
|
||||||
|
|
||||||
|
var pshortLoadConfig = proc.LoadConfig{
|
||||||
|
MaxStringLen: 64,
|
||||||
|
MaxStructFields: 3,
|
||||||
|
}
|
||||||
|
|
||||||
type varTest struct {
|
type varTest struct {
|
||||||
name string
|
name string
|
||||||
@ -496,7 +506,7 @@ func TestEmbeddedStruct(t *testing.T) {
|
|||||||
assertNoError(proc.Continue(p), t, "Continue()")
|
assertNoError(proc.Continue(p), t, "Continue()")
|
||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
|
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 9, Rev: -1}) {
|
||||||
// on go < 1.9 embedded fields had different names
|
// on go < 1.9 embedded fields had different names
|
||||||
for i := range testcases {
|
for i := range testcases {
|
||||||
if testcases[i].name == "b2" {
|
if testcases[i].name == "b2" {
|
||||||
@ -812,7 +822,7 @@ func TestEvalExpression(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 7, -1, 0, 0, ""}) {
|
if ver.Major >= 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 7, Rev: -1}) {
|
||||||
for i := range testcases {
|
for i := range testcases {
|
||||||
if testcases[i].name == "iface3" {
|
if testcases[i].name == "iface3" {
|
||||||
testcases[i].value = "interface {}(*map[string]go/constant.Value) *[]"
|
testcases[i].value = "interface {}(*map[string]go/constant.Value) *[]"
|
||||||
@ -948,7 +958,7 @@ func TestIssue426(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 8, -1, 0, 0, ""}) {
|
if ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 8, Rev: -1}) {
|
||||||
testcases[2].typ = `struct { main.val go/constant.Value }`
|
testcases[2].typ = `struct { main.val go/constant.Value }`
|
||||||
testcases[3].typ = `func(struct { main.i int }, interface {}, struct { main.val go/constant.Value })`
|
testcases[3].typ = `func(struct { main.i int }, interface {}, struct { main.val go/constant.Value })`
|
||||||
testcases[4].typ = `struct { main.i int; main.j int }`
|
testcases[4].typ = `struct { main.i int; main.j int }`
|
||||||
@ -1085,7 +1095,7 @@ func TestConstants(t *testing.T) {
|
|||||||
{"pkg.SomeConst", false, "2", "", "int", nil},
|
{"pkg.SomeConst", false, "2", "", "int", nil},
|
||||||
}
|
}
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{1, 10, -1, 0, 0, ""}) {
|
if ver.Major > 0 && !ver.AfterOrEqual(goversion.GoVersion{Major: 1, Minor: 10, Rev: -1}) {
|
||||||
// Not supported on 1.9 or earlier
|
// Not supported on 1.9 or earlier
|
||||||
t.Skip("constants added in go 1.10")
|
t.Skip("constants added in go 1.10")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user