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 3/3] [gdb/contrib] Avoid NotImplementedError in dwarf-to-dwarf-assembler.py
Date: Mon,  9 Mar 2026 13:19:30 +0100	[thread overview]
Message-ID: <20260309121930.3098744-4-tdevries@suse.de> (raw)
In-Reply-To: <20260309121930.3098744-1-tdevries@suse.de>

The previous commit mentions:
...
      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'>
...

While the NotImplementedError makes its point clear, it's unhelpful in two ways:
- it's hard to find out what part of the input causes the error, and
- it may be that the user is not interested at all in the bit triggering the
  error, but some part after it, and the error prevents the user from seeing it

Fix this by returning an error string instead of raising an error, resulting in this output:
...
  DW_AT_upper_bound Unknown data type: <class 'elftools.construct.lib.container.ListContainer'>: \
    [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255] DW_FORM_data16
...
---
 gdb/contrib/dwarf-to-dwarf-assembler.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/contrib/dwarf-to-dwarf-assembler.py b/gdb/contrib/dwarf-to-dwarf-assembler.py
index 91e868da998..4832c6c8cb1 100755
--- a/gdb/contrib/dwarf-to-dwarf-assembler.py
+++ b/gdb/contrib/dwarf-to-dwarf-assembler.py
@@ -173,7 +173,7 @@ class DWARFAttribute:
         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)}")
+            return f"Unknown data type: {type(self.value)}: {self.value}"
 
     def format(
         self, offset_die_lookup: dict[int, "DWARFDIE"], indent_count: int = 0
-- 
2.51.0


  parent reply	other threads:[~2026-03-09 12:21 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 ` [PATCH 2/3] [gdb/contrib] Handle DW_FORM_data16 " Tom de Vries
2026-03-09 12:19 ` Tom de Vries [this message]
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-4-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