From 5e9a70c51e7f8dbd6ea27c2771021ade66c34d54 Mon Sep 17 00:00:00 2001 From: Seva Alekseyev Date: Mon, 20 Mar 2023 20:01:05 -0400 Subject: [PATCH] Filename in lineprog index fix made DWARF5 aware (#463) --- examples/dwarf_decode_address.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/dwarf_decode_address.py b/examples/dwarf_decode_address.py index e335d0b..79938e4 100644 --- a/examples/dwarf_decode_address.py +++ b/examples/dwarf_decode_address.py @@ -80,6 +80,7 @@ def decode_file_line(dwarfinfo, address): for CU in dwarfinfo.iter_CUs(): # First, look at line programs to find the file/line for the address lineprog = dwarfinfo.line_program_for_CU(CU) + delta = 1 if lineprog.header.version < 5 else 0 prevstate = None for entry in lineprog.get_entries(): # We're interested in those entries where a new state is assigned @@ -88,7 +89,7 @@ def decode_file_line(dwarfinfo, address): # Looking for a range of addresses in two consecutive states that # contain the required address. if prevstate and prevstate.address <= address < entry.state.address: - filename = lineprog['file_entry'][prevstate.file - 1].name + filename = lineprog['file_entry'][prevstate.file - delta].name line = prevstate.line return filename, line if entry.state.end_sequence: -- 2.30.2