public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH] gdb: add HtabPrinter to gdb-gdb.py.in
Date: Mon, 27 Feb 2023 11:10:22 -0700	[thread overview]
Message-ID: <87edqbdlo1.fsf@tromey.com> (raw)
In-Reply-To: <20230209195056.100681-1-simon.marchi@efficios.com> (Simon Marchi via Gdb-patches's message of "Thu, 9 Feb 2023 14:50:56 -0500")

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> When debugging GDB, I find it a bit tedious to inspect htab_t objects.
Simon> It is possible to find the entries by poking at the fields, but it's
Simon> annoying to do each time.  I think a pretty printer would help.  Add a
Simon> basic one to gdb-gdb.py.

I could have used this today :-}

Simon> +    def _children_generator(self):
Simon> +        size = int(self._val["size"])
Simon> +        entries = self._val["entries"]
Simon> +
Simon> +        child_i = 0
Simon> +        for entries_i in range(size):
Simon> +            entry = entries[entries_i]
Simon> +            # 0 (NULL pointer) means there's nothing, 1 (HTAB_DELETED_ENTRY)
Simon> +            # means there was something, but is now deleted.
Simon> +            if int(entry) in (0, 1):
Simon> +                continue
Simon> +
Simon> +            yield (str(child_i), entry)
Simon> +            child_i += 1
Simon> +
Simon> +    def children(self):
Simon> +        return self._children_generator()

I don't think the indirection here is needed, you can just have children
yield.  But, either way seems fine to me.

Reviewed-By: Tom Tromey <tom@tromey.com>

Tom

  parent reply	other threads:[~2023-02-27 18:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 19:50 Simon Marchi
2023-02-09 19:52 ` Simon Marchi
2023-02-27 18:10 ` Tom Tromey [this message]
2023-02-28  4:23   ` Simon Marchi
2023-02-28 14:30     ` Tom Tromey
2023-02-28 16:08       ` Simon Marchi

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=87edqbdlo1.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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).