proc: change (*Variable).setValue for use in CallFunction

Changes (*Variable).setValue so that it can be used in CallFunction to
set up the argument frame for the function call, adding the ability to:
- nil nillable types
- set strings to the empty string
- copy from one structure to another (including strings and slices)
- convert any interface type to interface{}
- convert pointer shaped types (map, chan, pointers, and structs
  consisting of a single pointer field) to interface{}

This covers all cases where an assignment statement can be evaluated
without allocating memory or calling functions in the target process.
This commit is contained in:
aarzilli
2018-07-27 19:19:01 +02:00
committed by Derek Parker
parent f342d2784c
commit 12a3f8bb97
6 changed files with 266 additions and 59 deletions

View File

@ -1160,10 +1160,18 @@ func (v *Variable) asUint() (uint64, error) {
return n, nil
}
type typeConvErr struct {
srcType, dstType godwarf.Type
}
func (err *typeConvErr) Error() string {
return fmt.Sprintf("can not convert value of type %s to %s", err.srcType.String(), err.dstType.String())
}
func (v *Variable) isType(typ godwarf.Type, kind reflect.Kind) error {
if v.DwarfType != nil {
if typ != nil && typ.String() != v.RealType.String() {
return fmt.Errorf("can not convert value of type %s to %s", v.DwarfType.String(), typ.String())
return &typeConvErr{v.DwarfType, typ}
}
return nil
}