aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-05-18 21:19:17 -0600
committerTom Tromey <tom@tromey.com>2016-05-23 10:08:34 -0600
commit0f6ed0e0efe2c4dcd35b0e483dc3b5da7fe4edf0 (patch)
tree5dfc9cba90af71c05055effd27973c1b7297ccb3 /gdb/testsuite
parentd9eca1df01c0e6f7f22566c154e63b1df9315790 (diff)
downloadgdb-0f6ed0e0efe2c4dcd35b0e483dc3b5da7fe4edf0.zip
gdb-0f6ed0e0efe2c4dcd35b0e483dc3b5da7fe4edf0.tar.gz
gdb-0f6ed0e0efe2c4dcd35b0e483dc3b5da7fe4edf0.tar.bz2
Fix PR python/19438, PR python/18393 - initialize dictionaries
This fixes PR python/19438 and PR python/18393. Both bugs are about invoking dir() on some Python object implemented by gdb, and getting a crash. The crash happens because the dictionary field of these objects was not initialized. Apparently what happens is that this field can be lazily initialized by Python when assigning to an attribute; and it can also be handled ok when using dir() but without __dict__ defined; but gdb defines __dict__ because this isn't supplied automatically by Python. The docs on this seem rather sparse, but this patch works ok. An alternative might be to lazily create the dictionary in gdb_py_generic_dict, but I went with this approach because it seemed more straightforward. Built and regtested on x86-64 Fedora 23. 2016-05-23 Tom Tromey <tom@tromey.com> PR python/19438, PR python/18393: * python/py-objfile.c (objfpy_initialize): Initialize self->dict. * python/py-progspace.c (pspy_initialize): Initialize self->dict. 2016-05-23 Tom Tromey <tom@tromey.com> PR python/19438, PR python/18393: * gdb.python/py-progspace.exp: Add "dir" test. * gdb.python/py-objfile.exp: Add "dir" test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog6
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp2
3 files changed, 10 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 2aadae0..1f0e3f9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2016-05-23 Tom Tromey <tom@tromey.com>
+
+ PR python/19438, PR python/18393:
+ * gdb.python/py-progspace.exp: Add "dir" test.
+ * gdb.python/py-objfile.exp: Add "dir" test.
+
2016-05-23 Yao Qi <yao.qi@linaro.org>
* gdb.arch/thumb-prologue.exp: Use standard_testfile.
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 1bbb4cf..62ca309 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -45,6 +45,8 @@ gdb_test "python print (objfile.filename)" "${testfile}" \
gdb_test "python print (objfile.username)" "${testfile}" \
"Get objfile user name"
+gdb_test_no_output "python dir(objfile)"
+
gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").filename)" \
"${testfile}" "print lookup_objfile filename"
gdb_test "python print (gdb.lookup_objfile (\"junk\"))" \
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index 5c1db1c..396d0f2 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -37,6 +37,8 @@ gdb_test "python print (gdb.current_progspace().filename)" "None" \
"current progspace filename (None)"
gdb_test "python print (gdb.progspaces())" "\\\[<gdb.Progspace object at $hex>\\\]"
+gdb_test_no_output "python dir(gdb.current_progspace())"
+
gdb_load ${binfile}
gdb_py_test_silent_cmd "python progspace = gdb.current_progspace()" \