This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RFC: fix PR 14635
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 27 Sep 2012 14:17:48 -0600
- Subject: RFC: fix PR 14635
This fixes PR python/14635.
Like PR 14634, this is a destructor bug.
In this case, the Python SAL code assumes that the 'symtab' field will
always be a valid object; but del_objfile_sal incorrectly sets this
field to NULL.
This fixes the problem in the obvious way.
Built and regtested on x86-64 Fedora 16.
New test case included.
Tom
PR python/14635:
* python/py-symtab.c (del_objfile_sal): Set 'symtab' field
to Py_None.
* gdb.python/py-symtab.exp: Test sal and symtab destructors.
---
gdb/python/py-symtab.c | 5 ++++-
gdb/testsuite/gdb.python/py-symtab.exp | 3 +++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index b6f45e6..21a172c 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -470,7 +470,10 @@ del_objfile_sal (struct objfile *objfile, void *datum)
{
sal_object *next = obj->next;
- obj->symtab = NULL;
+ Py_DECREF (obj->symtab);
+ obj->symtab = (symtab_object *) Py_None;
+ Py_INCREF (Py_None);
+
obj->next = NULL;
obj->prev = NULL;
xfree (obj->sal);
diff --git a/gdb/testsuite/gdb.python/py-symtab.exp b/gdb/testsuite/gdb.python/py-symtab.exp
index da0c3e4..0d3a5f2 100644
--- a/gdb/testsuite/gdb.python/py-symtab.exp
+++ b/gdb/testsuite/gdb.python/py-symtab.exp
@@ -73,3 +73,6 @@ gdb_test "python print \"simple_struct\" in static_symbols" "True" "Test simple_
gdb_unload
gdb_test "python print sal.is_valid()" "False" "Test sal.is_valid"
gdb_test "python print symtab.is_valid()" "False" "Test symtab.is_valid()"
+
+gdb_test_no_output "python sal = None" "Test sal destructor"
+gdb_test_no_output "python symtab = None" "Test symtab destructor"
--
1.7.7.6