File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ package gocore
7
7
import (
8
8
"debug/dwarf"
9
9
"fmt"
10
+ "reflect"
10
11
"regexp"
11
12
"sort"
12
13
"strings"
@@ -58,6 +59,23 @@ func (p *Process) readDWARFTypes() {
58
59
t .Kind = KindStruct
59
60
for _ , f := range x .Field {
60
61
fType := p .dwarfMap [f .Type ]
62
+ if fType == nil {
63
+ // Weird case: arrays of size 0 in structs, like
64
+ // Sysinfo_t.X_f. Synthesize a type so things later don't
65
+ // get sad.
66
+ if arr , ok := f .Type .(* dwarf.ArrayType ); ok && arr .Count == 0 {
67
+ fType = & Type {
68
+ Name : f .Type .String (),
69
+ Kind : KindArray ,
70
+ Count : arr .Count ,
71
+ Elem : p .dwarfMap [arr .Type ],
72
+ }
73
+ } else {
74
+ panic (fmt .Sprintf (
75
+ "found a nil ftype for field %s.%s, type %s (%s) on " ,
76
+ x .StructName , f .Name , f .Type , reflect .TypeOf (f .Type )))
77
+ }
78
+ }
61
79
62
80
// Work around issue 21094. There's no guarantee that the
63
81
// pointer type is in the DWARF, so just invent a Type.
You can’t perform that action at this time.
0 commit comments