From: Tom de Vries Date: Wed, 22 Oct 2025 05:28:45 +0000 (+0200) Subject: [gdb/contrib] Handle unknown attribute in dwarf-to-dwarf-assembler.py X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24c1871a045f7d6b331ad2130e0a2353b6daf276;p=thirdparty%2Fbinutils-gdb.git [gdb/contrib] Handle unknown attribute in dwarf-to-dwarf-assembler.py I ran gdb/contrib/dwarf-to-dwarf-assembler.py on a hello world compiled with gcc 15, and ran into: ... Traceback (most recent call last): File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 642, in main(sys.argv) ~~~~^^^^^^^^^^ File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 638, in main generator.generate() ~~~~~~~~~~~~~~~~~~^^ File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 610, in generate self.generate_die(die, indent_count) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 589, in generate_die die_lines = die.format(self.dwarf_parser.offset_to_die, indent_count) File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 279, in format return "\n".join(self.format_lines(offset_die_lookup, indent_count)) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 376, in format_lines inner_lines = super().format_lines(offset_die_lookup, indent_count + 1) File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 251, in format_lines attr_line = attr.format( offset_die_lookup, indent_count=indent_count + 1 ) File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 199, in format s += self.name + " " ~~~~~~~~~~^~~~~ TypeError: unsupported operand type(s) for +: 'int' and 'str' ... because of trying to print DWARF v6 attributes DW_AT_language_name (0x90) and DW_AT_language_version (0x91). Fix this by printing the number if the name is not known: ... {DW_AT_0x90 3 DW_FORM_data1} {DW_AT_0x91 202311 DW_FORM_data4} ... --- diff --git a/gdb/contrib/dwarf-to-dwarf-assembler.py b/gdb/contrib/dwarf-to-dwarf-assembler.py index cf00be0e1ae..58fb6cbe549 100755 --- a/gdb/contrib/dwarf-to-dwarf-assembler.py +++ b/gdb/contrib/dwarf-to-dwarf-assembler.py @@ -196,7 +196,11 @@ class DWARFAttribute: applicable. """ s = lbrace - s += self.name + " " + if isinstance(self.name, int): + s += "DW_AT_" + hex(self.name) + else: + s += self.name + s += " " s += self._format_value(offset_die_lookup) # Only explicitly state form if it's not a reference.