diff --git a/proc/eval.go b/proc/eval.go index c8a4ad22..5982e7a5 100644 --- a/proc/eval.go +++ b/proc/eval.go @@ -432,16 +432,23 @@ func (scope *EvalScope) evalIdent(node *ast.Ident) (*Variable, error) { // try to interpret this as a local variable v, err := scope.extractVarInfo(node.Name) if err != nil { - // if it's not a local variable then it could be a package variable w/o explicit package name origErr := err - _, _, fn := scope.Thread.dbp.PCToLine(scope.PC) - if fn != nil { - if v, err := scope.packageVarAddr(fn.PackageName() + "." + node.Name); err == nil { - v.Name = node.Name - return v, nil + // workaround: sometimes go inserts an entry for '&varname' instead of varname + v, err = scope.extractVarInfo("&" + node.Name) + if err != nil { + // if it's not a local variable then it could be a package variable w/o explicit package name + _, _, fn := scope.Thread.dbp.PCToLine(scope.PC) + if fn != nil { + if v, err := scope.packageVarAddr(fn.PackageName() + "." + node.Name); err == nil { + v.Name = node.Name + return v, nil + } } + return nil, origErr + } else { + v = v.maybeDereference() + v.Name = node.Name } - return nil, origErr } return v, nil } diff --git a/service/test/variables_test.go b/service/test/variables_test.go index ddab8f35..c7e6b826 100644 --- a/service/test/variables_test.go +++ b/service/test/variables_test.go @@ -548,6 +548,9 @@ func TestEvalExpression(t *testing.T) { {"uint8(i5)", false, "253", "", "uint8", nil}, {"int8(i5)", false, "-3", "", "int8", nil}, {"int8(i6)", false, "12", "", "int8", nil}, + + // misc + {"i1", true, "1", "", "int", nil}, } withTestProcess("testvariables3", t, func(p *proc.Process, fixture protest.Fixture) {