mirror of
https://github.com/go-delve/delve.git
synced 2025-10-29 17:56:45 +08:00
proc/variables: bugfix: disable cast to maps and channels
It's was implemented unintentionally and the unintentional implementation doesn't work and causes a crash.
This commit is contained in:
@ -119,6 +119,20 @@ func (err *IsNilErr) Error() string {
|
||||
return fmt.Sprintf("%s is nil", err.name)
|
||||
}
|
||||
|
||||
func ptrTypeKind(t *dwarf.PtrType) reflect.Kind {
|
||||
structtyp, isstruct := t.Type.(*dwarf.StructType)
|
||||
_, isvoid := t.Type.(*dwarf.VoidType)
|
||||
if isstruct && strings.HasPrefix(structtyp.StructName, "hchan<") {
|
||||
return reflect.Chan
|
||||
} else if isstruct && strings.HasPrefix(structtyp.StructName, "hash<") {
|
||||
return reflect.Map
|
||||
} else if isvoid {
|
||||
return reflect.UnsafePointer
|
||||
} else {
|
||||
return reflect.Ptr
|
||||
}
|
||||
}
|
||||
|
||||
func newVariable(name string, addr uintptr, dwarfType dwarf.Type, thread *Thread) *Variable {
|
||||
v := &Variable{
|
||||
Name: name,
|
||||
@ -131,17 +145,7 @@ func newVariable(name string, addr uintptr, dwarfType dwarf.Type, thread *Thread
|
||||
|
||||
switch t := v.RealType.(type) {
|
||||
case *dwarf.PtrType:
|
||||
structtyp, isstruct := t.Type.(*dwarf.StructType)
|
||||
_, isvoid := t.Type.(*dwarf.VoidType)
|
||||
if isstruct && strings.HasPrefix(structtyp.StructName, "hchan<") {
|
||||
v.Kind = reflect.Chan
|
||||
} else if isstruct && strings.HasPrefix(structtyp.StructName, "hash<") {
|
||||
v.Kind = reflect.Map
|
||||
} else if isvoid {
|
||||
v.Kind = reflect.UnsafePointer
|
||||
} else {
|
||||
v.Kind = reflect.Ptr
|
||||
}
|
||||
v.Kind = ptrTypeKind(t)
|
||||
case *dwarf.StructType:
|
||||
switch {
|
||||
case t.StructName == "string":
|
||||
|
||||
Reference in New Issue
Block a user