This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix glitches with libstdc++ pretty printers


Still rather on the obvious side ...

--- cut ---
#include <list>
#include <vector>

typedef std::list<int> LI;
typedef std::vector<LI> VLI;

int main()
  LI  xx;
  VLI yy;

  xx = yy[0];
  return 0; // break here
--- cut ---

Using Tom's pretty printers from:
I observe:

  $ gdb64-py -ex 'source ~/' stl1
  GNU gdb (GDB)
  Copyright (C) 2008 Free Software Foundation, Inc.
  This GDB was configured as "x86_64-unknown-linux-gnu".
  (gdb) b 15
  Breakpoint 1 at 0x400364: file, line 15.
  (gdb) r

  Breakpoint 1, main () at
  15        return 0; // break here
  (gdb) p xx


  $1 = Traceback (most recent call last):
    File "<string>", line 7, in printstdlist
  RuntimeError: type is not a template
  [0] = 1

  (gdb) p yy[0]
  Segmentation fault

Crash :-(

Attached patch fixes both.

I am not making a test case for this, because there are some more
glitches to fix, and I'd rather have a single test for everything.


Paul Pluzhnikov

2008-10-15  Paul Pluzhnikov  <>

	* python/python-types.c (typy_template_argument): Handle typedefs,
	reference types, fix crash.

diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
index 4bef184..c749aa3 100644
--- a/gdb/python/python-type.c
+++ b/gdb/python/python-type.c
@@ -203,6 +203,16 @@ typy_template_argument (PyObject *self, PyObject *args)
+  type = check_typedef (type);
+  if (TYPE_CODE (type) == TYPE_CODE_REF)
+    type = check_typedef (TYPE_TARGET_TYPE (type));
+  if (TYPE_NAME (type) == NULL)
+    {
+      PyErr_SetString (PyExc_RuntimeError, "null type name");
+      return NULL;
+    }
   /* Note -- this is not thread-safe.  */
   demangled = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
   if (! demangled)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]