[binutils-gdb] [gdb/contrib] Handle unknown attribute in dwarf-to-dwarf-assembler.py
Tom de Vries
vries@sourceware.org
Wed Oct 22 05:28:55 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24c1871a045f7d6b331ad2130e0a2353b6daf276
commit 24c1871a045f7d6b331ad2130e0a2353b6daf276
Author: Tom de Vries <tdevries@suse.de>
Date: Wed Oct 22 07:28:45 2025 +0200
[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 <module>
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:
---
gdb/contrib/dwarf-to-dwarf-assembler.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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.
More information about the Gdb-cvs
mailing list