From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/3] [gdb/contrib] Handle DW_FORM_data16 in dwarf-to-dwarf-assembler.py
Date: Mon, 9 Mar 2026 13:19:29 +0100 [thread overview]
Message-ID: <20260309121930.3098744-3-tdevries@suse.de> (raw)
In-Reply-To: <20260309121930.3098744-1-tdevries@suse.de>
I ran gdb/contrib/dwarf-to-dwarf-assembler.py on testsuite executable
gdb.ada/task_bp/foo, and ran into:
...
Traceback (most recent call last):
File "dwarf-to-dwarf-assembler.py", line 660, in <module>
main(sys.argv)
~~~~^^^^^^^^^^
File "dwarf-to-dwarf-assembler.py", line 656, in main
generator.generate()
~~~~~~~~~~~~~~~~~~^^
File "dwarf-to-dwarf-assembler.py", line 628, in generate
self.generate_die(die, indent_count)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "dwarf-to-dwarf-assembler.py", line 607, in generate_die
die_lines = die.format(self.dwarf_parser.offset_to_die, indent_count)
File "dwarf-to-dwarf-assembler.py", line 297, in format
return "\n".join(self.format_lines(offset_die_lookup, indent_count))
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "dwarf-to-dwarf-assembler.py", line 394, in format_lines
inner_lines = super().format_lines(offset_die_lookup, indent_count + 1)
File "dwarf-to-dwarf-assembler.py", line 285, in format_lines
child_lines = child.format_lines(
offset_die_lookup, indent_count=indent_count + 1
)
File "dwarf-to-dwarf-assembler.py", line 269, in format_lines
attr_line = attr.format(
offset_die_lookup, indent_count=indent_count + 1
)
File "dwarf-to-dwarf-assembler.py", line 219, in format
s += self._format_value(offset_die_lookup)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
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'>
...
when trying to print the DW_FORM_data16 constant for this upper bound:
...
<1><3af88>: Abbrev Number: 47 (DW_TAG_subrange_type)
<3af89> DW_AT_lower_bound : 0
<3af89> DW_AT_upper_bound : 0xffffffffffffffffffffffffffffffff
<3af99> DW_AT_name : system__put_images__lll_integer_images__unsigned_typeXn
...
Fix this by handling elftools.construct.lib.container.ListContainer.
---
gdb/contrib/dwarf-to-dwarf-assembler.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/contrib/dwarf-to-dwarf-assembler.py b/gdb/contrib/dwarf-to-dwarf-assembler.py
index ca4c7696835..91e868da998 100755
--- a/gdb/contrib/dwarf-to-dwarf-assembler.py
+++ b/gdb/contrib/dwarf-to-dwarf-assembler.py
@@ -48,6 +48,7 @@ from io import BytesIO, IOBase
from logging import getLogger
from typing import Annotated, Optional
+from elftools.construct.lib.container import ListContainer
from elftools.dwarf.compileunit import CompileUnit as RawCompileUnit
from elftools.dwarf.die import DIE as RawDIE
from elftools.dwarf.die import AttributeValue
@@ -169,6 +170,8 @@ class DWARFAttribute:
return self._format_str(self.value.decode("ascii"))
elif isinstance(self.value, str):
return self._format_str(self.value)
+ 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)}")
--
2.51.0
next prev parent reply other threads:[~2026-03-09 12:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 12:19 [PATCH 0/3] [gdb/contrib] Some dwarf-to-dwarf-assember.py fixes Tom de Vries
2026-03-09 12:19 ` [PATCH 1/3] [gdb/contrib] Handle DW_LANG_Mips_Assembler in dwarf-to-dwarf-assembler.py Tom de Vries
2026-03-09 14:10 ` Tom Tromey
2026-03-09 15:25 ` Tom de Vries
2026-03-09 12:19 ` Tom de Vries [this message]
2026-03-09 12:19 ` [PATCH 3/3] [gdb/contrib] Avoid NotImplementedError " Tom de Vries
2026-03-09 14:10 ` [PATCH 0/3] [gdb/contrib] Some dwarf-to-dwarf-assember.py fixes Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260309121930.3098744-3-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox