diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-09-11 20:07:55 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-09-30 13:44:53 +0100 |
| commit | cedd9de64f183e4ce088654f8a9ed978cbdc8962 (patch) | |
| tree | c7429dc0487d54d509308472416c8e2747cd8418 /lib/std/debug/Dwarf.zig | |
| parent | a12ce28224f475bd97dc92bc8314ffff60fd6dd2 (diff) | |
| download | zig-cedd9de64f183e4ce088654f8a9ed978cbdc8962.tar.gz zig-cedd9de64f183e4ce088654f8a9ed978cbdc8962.zip | |
std.debug.Dwarf: fix names of inlined functions
Diffstat (limited to 'lib/std/debug/Dwarf.zig')
| -rw-r--r-- | lib/std/debug/Dwarf.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/std/debug/Dwarf.zig b/lib/std/debug/Dwarf.zig index dfe9bd8dd3..9a70746b0a 100644 --- a/lib/std/debug/Dwarf.zig +++ b/lib/std/debug/Dwarf.zig @@ -348,7 +348,13 @@ pub fn deinit(di: *Dwarf, gpa: Allocator) void { } pub fn getSymbolName(di: *Dwarf, address: u64) ?[]const u8 { - for (di.func_list.items) |*func| { + // Iterate the function list backwards so that we see child DIEs before their parents. This is + // important because `DW_TAG_inlined_subroutine` DIEs will have a range which is a sub-range of + // their caller, and we want to return the callee's name, not the caller's. + var i: usize = di.func_list.items.len; + while (i > 0) { + i -= 1; + const func = &di.func_list.items[i]; if (func.pc_range) |range| { if (address >= range.start and address < range.end) { return func.name; |
