| ... | @@ -348,7 +348,13 @@ pub fn deinit(di: *Dwarf, gpa: Allocator) void { | ... | @@ -348,7 +348,13 @@ pub fn deinit(di: *Dwarf, gpa: Allocator) void { |
| 348 | } | 348 | } |
| 349 | | 349 | |
| 350 | pub fn getSymbolName(di: *Dwarf, address: u64) ?[]const u8 { | 350 | pub fn getSymbolName(di: *Dwarf, address: u64) ?[]const u8 { |
| 351 | for (di.func_list.items) |*func| { | 351 | // Iterate the function list backwards so that we see child DIEs before their parents. This is |
| | 352 | // important because `DW_TAG_inlined_subroutine` DIEs will have a range which is a sub-range of |
| | 353 | // their caller, and we want to return the callee's name, not the caller's. |
| | 354 | var i: usize = di.func_list.items.len; |
| | 355 | while (i > 0) { |
| | 356 | i -= 1; |
| | 357 | const func = &di.func_list.items[i]; |
| 352 | if (func.pc_range) |range| { | 358 | if (func.pc_range) |range| { |
| 353 | if (address >= range.start and address < range.end) { | 359 | if (address >= range.start and address < range.end) { |
| 354 | return func.name; | 360 | return func.name; |