]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py
authorTom de Vries <tdevries@suse.de>
Mon, 9 Mar 2026 15:13:02 +0000 (16:13 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 9 Mar 2026 15:13:02 +0000 (16:13 +0100)
The previous commit mentions:
...
      File "dwarf-to-dwarf-assembler.py", line 173, in _format_value
        raise NotImplementedError(f"Unknown data type: {type(self.value)}")
    NotImplementedError: Unknown data type: <class 'elftools.construct.lib.container.ListContainer'>
...

While the NotImplementedError makes its point clear, it's unhelpful in two ways:
- it's hard to find out what part of the input causes the error, and
- it may be that the user is not interested at all in the bit triggering the
  error, but some part after it, and the error prevents the user from seeing it

Fix this by returning an error string instead of raising an error, resulting in this output:
...
  DW_AT_upper_bound Unknown data type: <class 'elftools.construct.lib.container.ListContainer'>: \
    [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] DW_FORM_data16
...

Approved-By: Tom Tromey <tom@tromey.com>
gdb/contrib/dwarf-to-dwarf-assembler.py

index 91e868da99870c64459253e21771a9f5e129d960..4832c6c8cb1414bf9fb92e4f06d4f0364cd85359 100755 (executable)
@@ -173,7 +173,7 @@ class DWARFAttribute:
         elif isinstance(self.value, ListContainer):
             return "0x" + "".join(format(i, "x") for i in self.value)
         else:
-            raise NotImplementedError(f"Unknown data type: {type(self.value)}")
+            return f"Unknown data type: {type(self.value)}: {self.value}"
 
     def format(
         self, offset_die_lookup: dict[int, "DWARFDIE"], indent_count: int = 0