This is the mail archive of the archer@sourceware.org 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


Greetings,

Still rather on the obvious side ...
Consider:

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

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

int main()
{
  LI  xx;
  VLI yy;

  xx.push_back(1);
  yy.push_back(xx);
  xx = yy[0];
  return 0; // break here
}
--- cut ---

Using Tom's pretty printers from:
 http://sourceware.org/ml/gdb-patches/2008-10/msg00123.html
I observe:

  $ gdb64-py -ex 'source ~/.gdbinit.py' stl1
  GNU gdb (GDB) 6.8.50.20080929-cvs
  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 stl1.cc, line 15.
  (gdb) r

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

Glitch:

  $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.

Thanks,

--
Paul Pluzhnikov


2008-10-15  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* 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]