Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 0/3] [gdb/contrib] Some dwarf-to-dwarf-assember.py fixes
Date: Mon,  9 Mar 2026 13:19:27 +0100	[thread overview]
Message-ID: <20260309121930.3098744-1-tdevries@suse.de> (raw)

I ran into trouble using dwarf-to-dwarf-assember.py on a hello world
executable, due to DW_LANG_MIPS_assembler.

The first patch fixes this.

I then tested the script on the executables generated by the testsuite, and ran into
DW_FORM_data16 being unsupported.

The second patch fixes that.

The third patch removes the only raise from the script, preferring imperfect
to partial output.

I tested the changes using the following command:
...
$ for f in $(find outputs/ -type f -executable| sort); do \
    ./src/gdb/contrib/dwarf-to-dwarf-assembler.py $f > /dev/null; \
    st=$?; \
    if [ $st -ne 0 ]; then echo "FILE: $f: $st"; fi; \
  done \
  2>&1 | tee LOG
Error parsing ELF file. Does it contain DWARF information?
'int' object has no attribute 'decode'
FILE: outputs/gdb.base/dwz-symtabs/libfoo-2.so: 61
Error parsing ELF file. Does it contain DWARF information?
'int' object has no attribute 'decode'
FILE: outputs/gdb.base/dwz-symtabs/libfoo.so: 61
Error parsing ELF file. Does it contain DWARF information?
Magic number does not match
FILE: outputs/gdb.base/gnu-debugdata/gnu-debugdata.mini_debuginfo-debuglink.xz: 61
Error parsing ELF file. Does it contain DWARF information?
'ascii' codec can't decode byte 0xc3 in position 6: ordinal not in range(128)
FILE: outputs/gdb.base/utf8-identifiers/utf8-identifiers: 61
Error parsing ELF file. Does it contain DWARF information?
'int' object has no attribute 'decode'
FILE: outputs/gdb.debuginfod/solib-with-dwz/debug/libfoo-2.so.debug: 61
Error parsing ELF file. Does it contain DWARF information?
'int' object has no attribute 'decode'
FILE: outputs/gdb.debuginfod/solib-with-dwz/debug/libfoo.so.debug: 61
Error parsing ELF file. Does it contain DWARF information?
refaddr 12346399 not in DIE range of CU 721
FILE: outputs/gdb.dwarf2/corrupt/corrupt: 61
Error parsing ELF file. Does it contain DWARF information?
unexpected end of stream while parsing a ULEB128 encoded value
FILE: outputs/gdb.dwarf2/debug-names-missing-cu/debug-names-missing-cu: 61
Error parsing ELF file. Does it contain DWARF information?
no decoding mapping for 103 [unit_type]
FILE: outputs/gdb.dwarf2/dw2-error/dw2-error: 61
Error parsing ELF file. Does it contain DWARF information?
refaddr 756 not in DIE range of CU 756
FILE: outputs/gdb.dwarf2/dw2-inter-cu-error-2/dw2-inter-cu-error-2: 61
Error parsing ELF file. Does it contain DWARF information?
769
FILE: outputs/gdb.dwarf2/dw2-inter-cu-error/dw2-inter-cu-error: 61
Error parsing ELF file. Does it contain DWARF information?
1271
FILE: outputs/gdb.dwarf2/dw2-op-out-param/dw2-op-out-param: 61
Error parsing ELF file. Does it contain DWARF information?
'NoneType' object has no attribute 'stream'
FILE: outputs/gdb.dwarf2/dw2-using-debug-str/dw2-using-debug-str-no-debug-str: 61
Error parsing ELF file. Does it contain DWARF information?
'DW_FORM_strx'
FILE: outputs/gdb.dwarf2/dw-form-strx/dw-form-strx: 61
Error parsing ELF file. Does it contain DWARF information?
'DW_FORM_strx'
FILE: outputs/gdb.dwarf2/dw-form-strx-out-of-bounds/dw-form-strx-out-of-bounds: 61
Error parsing ELF file. Does it contain DWARF information?
2
FILE: outputs/gdb.dwarf2/implptrpiece/implptrpiece: 61
Error parsing ELF file. Does it contain DWARF information?
refaddr 860 not in DIE range of CU 721
FILE: outputs/gdb.dwarf2/imported-unit-c/imported-unit-c: 61
Traceback (most recent call last):
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 663, in <module>
    main(sys.argv)
    ~~~~^^^^^^^^^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 659, in main
    generator.generate()
    ~~~~~~~~~~~~~~~~~~^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 631, in generate
    self.generate_die(die, indent_count)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 610, 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 300, 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 397, 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 288, in format_lines
    child_lines = child.format_lines(
        offset_die_lookup, indent_count=indent_count + 1
    )
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 288, in format_lines
    child_lines = child.format_lines(
        offset_die_lookup, indent_count=indent_count + 1
    )
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 288, in format_lines
    child_lines = child.format_lines(
        offset_die_lookup, indent_count=indent_count + 1
    )
  [Previous line repeated 1 more time]
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 272, 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 222, in format
    s += self._format_value(offset_die_lookup)
         ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/data/vries/gdb/./src/gdb/contrib/dwarf-to-dwarf-assembler.py", line 170, in _format_value
    return self._format_str(self.value.decode("ascii"))
                            ~~~~~~~~~~~~~~~~~^^^^^^^^^
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 0: ordinal not in range(128)
FILE: outputs/gdb.rust/unicode/unicode: 1
...

I filed the UnicodeDecodeError as PR testsuite/33970 [1].

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=33970

Tom de Vries (3):
  [gdb/contrib] Handle DW_LANG_Mips_Assembler in
    dwarf-to-dwarf-assembler.py
  [gdb/contrib] Handle DW_FORM_data16 in dwarf-to-dwarf-assembler.py
  [gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py

 gdb/contrib/dwarf-to-dwarf-assembler.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)


base-commit: 072ea1fa0d39ea0110722385f37415ab6352315d
-- 
2.51.0


             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 Tom de Vries [this message]
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 ` [PATCH 2/3] [gdb/contrib] Handle DW_FORM_data16 " Tom de Vries
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-1-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