diff options
| author | Tom Tromey <tromey@adacore.com> | 2025-10-22 08:04:12 -0600 |
|---|---|---|
| committer | Tom Tromey <tromey@adacore.com> | 2025-10-28 09:38:47 -0600 |
| commit | 8e2dd54209199c7df1a5cb83f4b281b5bea03b8f (patch) | |
| tree | 4a39dc13ca79d96070f97eb43e3f337e294b710a /gdb/contrib/dwarf-to-dwarf-assembler.py | |
| parent | 101b7a01c203425a8c4316e72ff187f8912b16e9 (diff) | |
| download | binutils-8e2dd54209199c7df1a5cb83f4b281b5bea03b8f.zip binutils-8e2dd54209199c7df1a5cb83f4b281b5bea03b8f.tar.gz binutils-8e2dd54209199c7df1a5cb83f4b281b5bea03b8f.tar.bz2 | |
Emit language and encoding names from dwarf-to-dwarf-assembler
This changes dwarf-to-dwarf-assembler to emit DW_LANG_* and DW_ATE_*
names when decoding the appropriate attributes. This makes the output
a little more readable and a little closer to something we'd check in.
Approved-By: Andrew Burgess <aburgess@redhat.com>
Diffstat (limited to 'gdb/contrib/dwarf-to-dwarf-assembler.py')
| -rwxr-xr-x | gdb/contrib/dwarf-to-dwarf-assembler.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/gdb/contrib/dwarf-to-dwarf-assembler.py b/gdb/contrib/dwarf-to-dwarf-assembler.py index 12fd99f..60f2935 100755 --- a/gdb/contrib/dwarf-to-dwarf-assembler.py +++ b/gdb/contrib/dwarf-to-dwarf-assembler.py @@ -53,6 +53,7 @@ from typing import Annotated, Optional from elftools.dwarf.compileunit import CompileUnit as RawCompileUnit from elftools.dwarf.die import DIE as RawDIE from elftools.dwarf.die import AttributeValue +from elftools.dwarf.enums import ENUM_DW_ATE, ENUM_DW_LANG from elftools.elf.elffile import ELFFile logger = getLogger(__file__) @@ -68,6 +69,10 @@ EXPR_ATTRIBUTE_FORMS = [ "DW_FORM_block4", ] +# Map from language number to name. +LANG_NAME = {v: k for k, v in ENUM_DW_LANG.items()} +# Map from encoding number to name. +ATE_NAME = {v: k for k, v in ENUM_DW_ATE.items()} # Workaround for my editor not to freak out over unclosed braces. lbrace, rbrace = "{", "}" @@ -201,11 +206,17 @@ class DWARFAttribute: else: s += self.name s += " " - s += self._format_value(offset_die_lookup) - # Only explicitly state form if it's not a reference. - if self.form not in [None, "DW_FORM_ref4", "DW_FORM_ref_addr"]: - s += " " + self.form + if self.name == "DW_AT_language" and isinstance(self.value, int): + s += "@" + LANG_NAME[self.value] + elif self.name == "DW_AT_encoding" and isinstance(self.value, int): + s += "@" + ATE_NAME[self.value] + else: + s += self._format_value(offset_die_lookup) + + # Only explicitly state form if it's not a reference. + if self.form not in [None, "DW_FORM_ref4", "DW_FORM_ref_addr"]: + s += " " + self.form return indent(s, indent_count) |
