|
@@ -41,9 +41,11 @@ type addr2Liner struct {
|
41
|
41
|
rw lineReaderWriter
|
42
|
42
|
base uint64
|
43
|
43
|
|
44
|
|
- // nm holds an NM based addr2Liner which can provide
|
45
|
|
- // better full names compared to addr2line, which often drops
|
46
|
|
- // namespaces etc. from the names it returns.
|
|
44
|
+ // nm holds an addr2Liner using nm tool. Certain versions of addr2line
|
|
45
|
+ // produce incomplete names due to
|
|
46
|
+ // https://sourceware.org/bugzilla/show_bug.cgi?id=17541. As a workaround,
|
|
47
|
+ // the names from nm are used when they look more complete. See addrInfo()
|
|
48
|
+ // code below for the exact heuristic.
|
47
|
49
|
nm *addr2LinerNM
|
48
|
50
|
}
|
49
|
51
|
|
|
@@ -215,17 +217,22 @@ func (d *addr2Liner) addrInfo(addr uint64) ([]plugin.Frame, error) {
|
215
|
217
|
return nil, err
|
216
|
218
|
}
|
217
|
219
|
|
218
|
|
- // Get better name from nm if possible.
|
|
220
|
+ // Certain versions of addr2line produce incomplete names due to
|
|
221
|
+ // https://sourceware.org/bugzilla/show_bug.cgi?id=17541. Attempt to replace
|
|
222
|
+ // the name with a better one from nm.
|
219
|
223
|
if len(stack) > 0 && d.nm != nil {
|
220
|
224
|
nm, err := d.nm.addrInfo(addr)
|
221
|
225
|
if err == nil && len(nm) > 0 {
|
222
|
|
- // Last entry in frame list should match since
|
223
|
|
- // it is non-inlined. As a simple heuristic,
|
224
|
|
- // we only switch to the nm-based name if it
|
225
|
|
- // is longer.
|
|
226
|
+ // Last entry in frame list should match since it is non-inlined. As a
|
|
227
|
+ // simple heuristic, we only switch to the nm-based name if it is longer
|
|
228
|
+ // by 2 or more characters. We consider nm names that are longer by 1
|
|
229
|
+ // character insignificant to avoid replacing foo with _foo on MacOS (for
|
|
230
|
+ // unknown reasons read2line produces the former and nm produces the
|
|
231
|
+ // latter on MacOS even though both tools are asked to produce mangled
|
|
232
|
+ // names).
|
226
|
233
|
nmName := nm[len(nm)-1].Func
|
227
|
234
|
a2lName := stack[len(stack)-1].Func
|
228
|
|
- if len(nmName) > len(a2lName) {
|
|
235
|
+ if len(nmName) > len(a2lName)+1 {
|
229
|
236
|
stack[len(stack)-1].Func = nmName
|
230
|
237
|
}
|
231
|
238
|
}
|