@@ -20,7 +20,35 @@ import (
2020func (k * KnownInfo ) AddDwarfVariable (entry * dwarf.Entry , d * dwarf.Data , pkg * entity.Package , ptrSize int ) {
2121 instsAny := entry .Val (dwarf .AttrLocation )
2222 if instsAny == nil {
23- slog .Warn (fmt .Sprintf ("no location attribute for %s" , dwarfutil .EntryPrettyPrint (entry )))
23+ printErr := false
24+ defer func () {
25+ if printErr {
26+ slog .Warn (fmt .Sprintf ("no location attribute for %s" , dwarfutil .EntryPrettyPrint (entry )))
27+ }
28+ }()
29+
30+ typOffset , ok := entry .Val (dwarf .AttrType ).(dwarf.Offset )
31+ if ! ok {
32+ slog .Warn (fmt .Sprintf ("no type attribute for %s" , dwarfutil .EntryPrettyPrint (entry )))
33+ printErr = true
34+ return
35+ }
36+
37+ typEntry , err := d .Type (typOffset )
38+ if err != nil {
39+ slog .Warn (fmt .Sprintf ("failed to get type for %s: %v" , dwarfutil .EntryPrettyPrint (entry ), err ))
40+ printErr = true
41+ return
42+ }
43+
44+ _ , ok = typEntry .(* dwarf.QualType )
45+ if ok {
46+ // fixme: we ignore const values for now, support this if possible
47+ return
48+ }
49+ printErr = true
50+ slog .Warn (fmt .Sprintf ("unexpected type %T for %s: " , typEntry , dwarfutil .EntryPrettyPrint (entry )))
51+
2452 return
2553 }
2654 insts , ok := instsAny .([]byte )
@@ -116,7 +144,7 @@ func (k *KnownInfo) AddDwarfSubProgram(
116144 if len (ranges ) == 0 {
117145 // fixme: maybe compiler optimize it?
118146 // example: sqlite3 simpleDestroy
119- slog .Warn (fmt .Sprintf ("Failed to load DWARF function size, no range: %s" , subEntryName ))
147+ slog .Debug (fmt .Sprintf ("Failed to load DWARF function size, no range: %s" , subEntryName ))
120148 return
121149 }
122150
0 commit comments