From: Oliver Buchtala <oliver.buchtala@googlemail.com>
To: gdb-patches@sourceware.org
Subject: patch for #14363
Date: Thu, 02 Aug 2012 16:21:00 -0000 [thread overview]
Message-ID: <501AA900.8020205@googlemail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 832 bytes --]
Hello,
this patch can be used to achieve a workaround to bug
http://sourceware.org/bugzilla/show_bug.cgi?id=14363
Besides being a workaround, it also is a new feature, enabling a
pretty-printer to
control the pretty-printing on deeper recursion levels.
The bug:
Structures/classes which produce cyclic reference lead to an infinite
recursion on
iterating children during pretty-pretting - leading to endless print and
stack-overflow on gdb print.
What the patch does:
Before calling the pretty-printer, py-prettyprint.c:print_children()
informs the pretty-printer about the current recursion level.
This is done by setting a property "level" if this property exists.
Changelog:
2012-08-02 Oliver Buchtala <oliver.buchtala@googlemail.com>
python/py-prettyprint.c: provide current recursion level to pretty
printer.
[-- Attachment #2: 0001-Adapt-py-prettyprint-to-inform-pretty-printer-about-.patch --]
[-- Type: text/x-patch, Size: 2193 bytes --]
From 05a921d423793db93dfead59c9fe12d342f55d75 Mon Sep 17 00:00:00 2001
From: Oliver Buchtala <oliver.buchtala@googlemail.com>
Date: Wed, 1 Aug 2012 21:59:43 +0200
Subject: [PATCH] Adapt py-prettyprint to inform pretty-printer about current
recursion level.
---
gdb/python/py-prettyprint.c | 3 +++
gdb/python/python-internal.h | 1 +
gdb/python/python.c | 2 ++
3 files changed, 6 insertions(+)
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 86d4f2c..d5c6b66 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -476,6 +476,9 @@ print_children (PyObject *printer, const char *hint,
if (! PyObject_HasAttr (printer, gdbpy_children_cst))
return;
+ if ( PyObject_HasAttr (printer, gdbpy_level_cst))
+ PyObject_SetAttr(printer, gdbpy_level_cst, PyInt_FromLong((long) recurse));
+
/* If we are printing a map or an array, we want some special
formatting. */
is_map = hint && ! strcmp (hint, "map");
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index bae61c2..e600632 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -328,6 +328,7 @@ extern PyObject *gdbpy_to_string_cst;
extern PyObject *gdbpy_display_hint_cst;
extern PyObject *gdbpy_enabled_cst;
extern PyObject *gdbpy_value_cst;
+extern PyObject *gdbpy_level_cst;
/* Exception types. */
extern PyObject *gdbpy_gdb_error;
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c66efe4..ae9e530 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -82,6 +82,7 @@ PyObject *gdbpy_display_hint_cst;
PyObject *gdbpy_doc_cst;
PyObject *gdbpy_enabled_cst;
PyObject *gdbpy_value_cst;
+PyObject *gdbpy_level_cst;
/* The GdbError exception. */
PyObject *gdbpy_gdberror_exc;
@@ -1305,6 +1306,7 @@ message == an error message without a stack will be printed."),
gdbpy_doc_cst = PyString_FromString ("__doc__");
gdbpy_enabled_cst = PyString_FromString ("enabled");
gdbpy_value_cst = PyString_FromString ("value");
+ gdbpy_level_cst = PyString_FromString ("level");
/* Release the GIL while gdb runs. */
PyThreadState_Swap (NULL);
--
1.7.9.5
next reply other threads:[~2012-08-02 16:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 16:21 Oliver Buchtala [this message]
2012-08-06 10:43 ` Phil Muldoon
2012-08-06 11:12 ` Oliver Buchtala
2012-08-06 11:19 ` Sergio Durigan Junior
2012-09-12 17:40 ` 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=501AA900.8020205@googlemail.com \
--to=oliver.buchtala@googlemail.com \
--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