workaround: proc/eval: go sometimes inserts &v instead of v
This commit is contained in:
parent
d4bfd25a28
commit
7e0d3fc244
21
proc/eval.go
21
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
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user