From aea2b479bfe494a84253f5b80a941c8ac70054d9 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Wed, 23 Aug 2023 05:23:34 -0700 Subject: [PATCH] fix examples/dwarf_location_info.py (#490) Pass along the DIE otherwise the following error is observed: Traceback (most recent call last): File "/tmp/pyelftools/examples/dwarf_location_info.py", line 110, in process_file(filename) File "/tmp/pyelftools/examples/dwarf_location_info.py", line 78, in process_file loc = loc_parser.parse_from_attribute(attr, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pyelftools/elftools/dwarf/locationlists.py", line 307, in parse_from_attribute return self.location_lists.get_location_list_at_offset( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pyelftools/elftools/dwarf/locationlists.py", line 96, in get_location_list_at_offset return self._parse_location_list_from_stream_v5(die.cu) if self.version >= 5 else self._parse_location_list_from_stream() ^^^^^^ AttributeError: 'NoneType' object has no attribute 'cu' --- examples/dwarf_location_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dwarf_location_info.py b/examples/dwarf_location_info.py index ec491aa..99e8ae0 100644 --- a/examples/dwarf_location_info.py +++ b/examples/dwarf_location_info.py @@ -76,7 +76,7 @@ def process_file(filename): if loc_parser.attribute_has_location(attr, CU['version']): print(' DIE %s. attr %s.' % (DIE.tag, attr.name)) loc = loc_parser.parse_from_attribute(attr, - CU['version']) + CU['version'], DIE) # We either get a list (in case the attribute is a # reference to the .debug_loc section) or a LocationExpr # object (in case the attribute itself contains location -- 2.30.2