This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[patch] Fix glitches with libstdc++ pretty printers
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: archer at sourceware dot org
- Date: Wed, 15 Oct 2008 15:29:34 -0700 (PDT)
- Subject: [patch] Fix glitches with libstdc++ pretty printers
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1224109792; bh=AbfxPAfbhHJbmBhDGqVAnd90PEc=;h=DomainKey-Signature:To:Subject:Message-Id:Date:From; b=TVs4R5+ClvnoF6M6+03aCdebpQXrA1AUM9v5v6cqz+6ULWsNRKqikgyMdgs+ubyfw++AxB2RQ6k1gO683emKZw==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=to:subject:message-id:date:from;b=b+1lYJDDnbawGhZOhHV5KkPiBTDvRMZj7RT8CrjjHaMQd8nF2o5Iqg/HCbzk7D7wR/LEygskrqPHFfNe+hwVaQ==
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)