public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@yahoo.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/4] Handle anonymous fields and base classes in NoOpStructPrinter
Date: Wed, 19 Jun 2024 19:07:51 +0200	[thread overview]
Message-ID: <20240619170754.1651-1-ssbssa@yahoo.de> (raw)
In-Reply-To: <20240619170754.1651-1-ssbssa.ref@yahoo.de>

Currently anonymous fields are not shown at all, this shows
them with the name [anonymous].

And it also marks base classes with <>, e.g. <BaseClass>, so
they can be distinguished from struct fields.
---
 gdb/python/lib/gdb/printing.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index 55ba43585ec..542909bf631 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -351,8 +351,13 @@ class NoOpStructPrinter(gdb.ValuePrinter):
 
     def children(self):
         for field in self.__ty.fields():
-            if hasattr(field, "bitpos") and field.name is not None:
-                yield (field.name, self.__value[field])
+            if hasattr(field, "bitpos"):
+                name = field.name
+                if name is None:
+                    name = "[anonymous]"
+                elif field.is_base_class:
+                    name = "<" + name + ">"
+                yield (name, self.__value[field])
 
 
 def make_visualizer(value):
-- 
2.35.1


       reply	other threads:[~2024-06-19 17:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240619170754.1651-1-ssbssa.ref@yahoo.de>
2024-06-19 17:07 ` Hannes Domani [this message]
2024-06-19 17:07   ` [PATCH 2/4] Make it possible to disable pretty-printers in make_visualizer Hannes Domani
2024-06-24 15:48     ` Tom Tromey
2024-06-19 17:07   ` [PATCH 3/4] Use custom format argument in NoOpScalarPrinter Hannes Domani
2024-06-24 15:49     ` Tom Tromey
2024-06-19 17:07   ` [PATCH 4/4] Implement locals TUI window Hannes Domani
2024-06-24 15:45   ` [PATCH 1/4] Handle anonymous fields and base classes in NoOpStructPrinter 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=20240619170754.1651-1-ssbssa@yahoo.de \
    --to=ssbssa@yahoo.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).