proc: automatically dereference interfaces on member access
If 'iv' is an interface variable with a struct as a concrete value let 'iv.A' evaluate to the access to field 'A' of the concrete value of 'iv'.
This commit is contained in:
parent
844762a853
commit
5f0f77f414
@ -670,6 +670,11 @@ func (v *Variable) structMember(memberName string) (*Variable, error) {
|
|||||||
case reflect.Chan:
|
case reflect.Chan:
|
||||||
v = v.clone()
|
v = v.clone()
|
||||||
v.RealType = resolveTypedef(&(v.RealType.(*godwarf.ChanType).TypedefType))
|
v.RealType = resolveTypedef(&(v.RealType.(*godwarf.ChanType).TypedefType))
|
||||||
|
case reflect.Interface:
|
||||||
|
v.loadInterface(0, false, LoadConfig{})
|
||||||
|
if len(v.Children) > 0 {
|
||||||
|
v = &v.Children[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
structVar := v.maybeDereference()
|
structVar := v.maybeDereference()
|
||||||
structVar.Name = v.Name
|
structVar.Name = v.Name
|
||||||
|
@ -552,6 +552,8 @@ func TestEvalExpression(t *testing.T) {
|
|||||||
{"err2", true, "error(*main.bstruct) *{a: main.astruct {A: 1, B: 2}}", "error(*main.bstruct) 0x…", "error", nil},
|
{"err2", true, "error(*main.bstruct) *{a: main.astruct {A: 1, B: 2}}", "error(*main.bstruct) 0x…", "error", nil},
|
||||||
{"errnil", true, "error nil", "error nil", "error", nil},
|
{"errnil", true, "error nil", "error nil", "error", nil},
|
||||||
{"iface1", true, "interface {}(*main.astruct) *{A: 1, B: 2}", "interface {}(*main.astruct) 0x…", "interface {}", nil},
|
{"iface1", true, "interface {}(*main.astruct) *{A: 1, B: 2}", "interface {}(*main.astruct) 0x…", "interface {}", nil},
|
||||||
|
{"iface1.A", false, "1", "1", "int", nil},
|
||||||
|
{"iface1.B", false, "2", "2", "int", nil},
|
||||||
{"iface2", true, "interface {}(string) \"test\"", "interface {}(string) \"test\"", "interface {}", nil},
|
{"iface2", true, "interface {}(string) \"test\"", "interface {}(string) \"test\"", "interface {}", nil},
|
||||||
{"iface3", true, "interface {}(map[string]go/constant.Value) []", "interface {}(map[string]go/constant.Value) []", "interface {}", nil},
|
{"iface3", true, "interface {}(map[string]go/constant.Value) []", "interface {}(map[string]go/constant.Value) []", "interface {}", nil},
|
||||||
{"iface4", true, "interface {}([]go/constant.Value) [4]", "interface {}([]go/constant.Value) [...]", "interface {}", nil},
|
{"iface4", true, "interface {}([]go/constant.Value) [4]", "interface {}([]go/constant.Value) [...]", "interface {}", nil},
|
||||||
|
Loading…
Reference in New Issue
Block a user