public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "dmitry.neverov at jetbrains dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug mi/31324] -var-create: slowdown due to children printing
Date: Thu, 01 Feb 2024 12:51:31 +0000 [thread overview]
Message-ID: <bug-31324-4717-XsJx0UpIoH@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31324-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=31324
--- Comment #1 from Dmitry Neverov <dmitry.neverov at jetbrains dot com> ---
To reproduce, one needs to register a pretty-printer for arrays:
class ArrayPrinter(object):
def __init__(self, val, type):
self.val = val
self.type = type
def display_hint(self):
return 'array'
def to_string(self):
return None
def children(self):
return self.Iterator(self.val, self.type)
class Iterator:
def __init__(self, val, type):
self.val = val
try:
(start_index, end_index) = type.range()
self.index = start_index - 1
self.end_index = end_index + 1
except:
self.index = -1
self.end_index = untypedef(type).sizeof //
untypedef(type).target().sizeof
def __iter__(self):
return self
def __next__(self):
self.index += 1
if self.index == self.end_index:
raise StopIteration
return ('[{0}]'.format(self.index), self.val[self.index])
def next(self):
return self.__next__()
def arrayMatcher(val):
if val.type.code == gdb.TYPE_CODE_ARRAY:
return ArrayPrinter(val, type)
return None
gdb.pretty_printers.append(arrayMatcher)
--
You are receiving this mail because:
You are on the CC list for the bug.
next prev parent reply other threads:[~2024-02-01 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 12:17 [Bug mi/31324] New: " dmitry.neverov at jetbrains dot com
2024-02-01 12:51 ` dmitry.neverov at jetbrains dot com [this message]
2024-02-01 16:20 ` [Bug mi/31324] " tromey at sourceware dot org
2024-02-02 9:07 ` dmitry.neverov at jetbrains dot com
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=bug-31324-4717-XsJx0UpIoH@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=gdb-prs@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).