proc/variables: bugfix: ifaces with types in user defined packages

The concrete type of an interface only contains the abbreviated
package name, we must construct a map from package names to package
paths to be able to resolve the concrete type of an interface.
This commit is contained in:
aarzilli
2015-11-26 14:10:58 +01:00
committed by Derek Parker
parent 8346a6ee08
commit 38716dcc26
6 changed files with 144 additions and 27 deletions

View File

@ -5,7 +5,6 @@ import (
"debug/dwarf"
"encoding/binary"
"fmt"
"go/ast"
"go/constant"
"go/parser"
"go/token"
@ -1451,10 +1450,16 @@ func (v *Variable) loadInterface(recurseLevel int, loadData bool) {
typ, err := v.thread.dbp.findTypeExpr(t)
if err != nil {
v.Unreadable = fmt.Errorf("invalid interface type: %v", err)
v.Unreadable = fmt.Errorf("interface type \"%s\" not found for 0x%x: %v", constant.StringVal(typestring.Value), data.Addr, err)
return
}
realtyp := resolveTypedef(typ)
if _, isptr := realtyp.(*dwarf.PtrType); !isptr {
// interface to non-pointer types are pointers even if the type says otherwise
typ = v.thread.dbp.pointerTo(typ)
}
data = newVariable("data", data.Addr, typ, data.thread)
v.Children = []Variable{*data}
@ -1464,21 +1469,6 @@ func (v *Variable) loadInterface(recurseLevel int, loadData bool) {
return
}
func (dbp *Process) findTypeExpr(expr ast.Expr) (dwarf.Type, error) {
if snode, ok := expr.(*ast.StarExpr); ok {
// Pointer types only appear in the dwarf informations when
// a pointer to the type is used in the target program, here
// we create a pointer type on the fly so that the user can
// specify a pointer to any variable used in the target program
ptyp, err := dbp.findType(exprToString(snode.X))
if err != nil {
return nil, err
}
return &dwarf.PtrType{dwarf.CommonType{int64(dbp.arch.PtrSize()), exprToString(expr)}, ptyp}, nil
}
return dbp.findType(exprToString(expr))
}
// Fetches all variables of a specific type in the current function scope
func (scope *EvalScope) variablesByTag(tag dwarf.Tag) ([]*Variable, error) {
reader := scope.DwarfReader()