|
@@ -38,6 +38,11 @@ const (
|
38
|
38
|
type addr2Liner struct {
|
39
|
39
|
rw lineReaderWriter
|
40
|
40
|
base uint64
|
|
41
|
+
|
|
42
|
+ // nm holds an NM based addr2Liner which can provide
|
|
43
|
+ // better full names compared to addr2line, which often drops
|
|
44
|
+ // namespaces etc. from the names it returns.
|
|
45
|
+ nm *addr2LinerNM
|
41
|
46
|
}
|
42
|
47
|
|
43
|
48
|
// lineReaderWriter is an interface to abstract the I/O to an addr2line
|
|
@@ -193,5 +198,22 @@ func (d *addr2Liner) addrInfo(addr uint64) ([]plugin.Frame, error) {
|
193
|
198
|
stack = append(stack, frame)
|
194
|
199
|
}
|
195
|
200
|
}
|
|
201
|
+
|
|
202
|
+ // Get better name from nm if possible.
|
|
203
|
+ if len(stack) > 0 && d.nm != nil {
|
|
204
|
+ nm, err := d.nm.addrInfo(addr)
|
|
205
|
+ if err == nil && len(nm) > 0 {
|
|
206
|
+ // Last entry in frame list should match since
|
|
207
|
+ // it is non-inlined. As a simple heuristic,
|
|
208
|
+ // we only switch to the nm-based name if it
|
|
209
|
+ // is longer.
|
|
210
|
+ nmName := nm[len(nm)-1].Func
|
|
211
|
+ a2lName := stack[len(stack)-1].Func
|
|
212
|
+ if len(nmName) > len(a2lName) {
|
|
213
|
+ stack[len(stack)-1].Func = nmName
|
|
214
|
+ }
|
|
215
|
+ }
|
|
216
|
+ }
|
|
217
|
+
|
196
|
218
|
return stack, nil
|
197
|
219
|
}
|