diff --git a/_fixtures/testvariables b/_fixtures/testvariables index d60b4d80938f7b7b492f97ce7e5501920092cb94..354ec6766f4a60e18469c30fc3d30a5e7ece24c7 100755 Binary files a/_fixtures/testvariables and b/_fixtures/testvariables differ diff --git a/_fixtures/testvariables.go b/_fixtures/testvariables.go index 1425b74b120a56fe3a4f44020ef87a5a0834def9..07d8530a60890ab3368e795819f4f55331944edb 100644 --- a/_fixtures/testvariables.go +++ b/_fixtures/testvariables.go @@ -9,12 +9,14 @@ type FooBar struct { func main() { var ( - bar = "foo" - foo = 6 - sl = []int{1, 2, 3, 4, 5} - arr = [1]int{1} - baz = &FooBar{Baz: 5, Bur: "strum"} + a1 = "foo" + a2 = 6 + a3 = 7.23 + a4 = []int{1, 2, 3, 4, 5} + a5 = [1]int{1} + a6 = FooBar{Baz: 8, Bur: "word"} + a7 = &FooBar{Baz: 5, Bur: "strum"} ) - fmt.Println(bar, foo, arr, sl, baz) + fmt.Println(a1, a2, a3, a4, a5, a6, a7) } diff --git a/proctl/proctl_linux_amd64.go b/proctl/proctl_linux_amd64.go index a5b21fcd9b31bfde0b33ee0d798f4c05d8bf334d..58917f3855b671714edc2d34c60ec6f6e81fa026 100644 --- a/proctl/proctl_linux_amd64.go +++ b/proctl/proctl_linux_amd64.go @@ -384,6 +384,17 @@ func (dbp *DebuggedProcess) extractValue(instructions []byte, typ interface{}) ( n := binary.LittleEndian.Uint64(val) return strconv.Itoa(int(n)), nil + case *dwarf.FloatType: + var n float64 + addr := uintptr(int64(regs.Rsp) + off) + val, err := dbp.readMemory(addr, 8) + if err != nil { + return "", err + } + buf := bytes.NewBuffer(val) + binary.Read(buf, binary.LittleEndian, &n) + + return strconv.FormatFloat(n, 'f', -1, 64), nil } return "", fmt.Errorf("could not find value for type %s", typ) diff --git a/proctl/proctl_test.go b/proctl/proctl_test.go index 2c32553eb939a17938898ec3a48ace9618987cf4..4961ea9c975ab25cd96e2ce63d153e4f7e08b59b 100644 --- a/proctl/proctl_test.go +++ b/proctl/proctl_test.go @@ -231,17 +231,18 @@ func TestVariableEvaluation(t *testing.T) { value string varType string }{ - {"foo", "6", "int"}, + {"a2", "6", "int"}, + {"a3", "7.23", "float64"}, } helper.WithTestProcess(executablePath, t, func(p *proctl.DebuggedProcess) { - pc, _, _ := p.GoSymTable.LineToPC(fp, 19) + pc, _, _ := p.GoSymTable.LineToPC(fp, 21) _, err := p.Break(uintptr(pc)) assertNoError(err, t, "Break() returned an error") err = p.Continue() - assertNoError(err, t, "Break() returned an error") + assertNoError(err, t, "Continue() returned an error") for _, tc := range testcases { variable, err := p.EvalSymbol(tc.name)