From: Tom de Vries Date: Mon, 9 Mar 2026 15:13:02 +0000 (+0100) Subject: [gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=092f2f12ee886e7e95f0f643a3284f52be21eea3;p=thirdparty%2Fbinutils-gdb.git [gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py 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: ... 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: : \ [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] DW_FORM_data16 ... Approved-By: Tom Tromey --- diff --git a/gdb/contrib/dwarf-to-dwarf-assembler.py b/gdb/contrib/dwarf-to-dwarf-assembler.py index 91e868da998..4832c6c8cb1 100755 --- a/gdb/contrib/dwarf-to-dwarf-assembler.py +++ b/gdb/contrib/dwarf-to-dwarf-assembler.py @@ -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