Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* patch for #14363
@ 2012-08-02 16:21 Oliver Buchtala
  2012-08-06 10:43 ` Phil Muldoon
  2012-09-12 17:40 ` Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Buchtala @ 2012-08-02 16:21 UTC (permalink / raw)
  To: gdb-patches

[-- 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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-09-12 17:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-02 16:21 patch for #14363 Oliver Buchtala
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox