Make gdb.selected_thread().inferior return a new reference
thpy_get_inferior function should return a new reference to the existing inferior object, and therefore should increment its refcount. Fixed bug looks like this. If multiple time call gdb.selected_thread ().inferior, gdb throws exception: (gdb) pi gdb.selected_thread().inferior <gdb.Inferior object at 0x7f1952bea698> (gdb) pi gdb.selected_thread().inferior Python Exception <type 'exceptions.AttributeError'> 'NoneType' object has no attribute 'inferior': Error while executing Python code. (gdb) info threads Id Target Id Frame * 1 Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in
This commit is contained in:
parent
d91f0b20e5
commit
484d8d361d
4 changed files with 22 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2017-10-28 Maksim Dzabraev <dzabraew@gmail.com>
|
||||||
|
|
||||||
|
PR python/21213
|
||||||
|
* python/py-infthread.c (thpy_get_inferior): Increment reference
|
||||||
|
of inferior before returning it.
|
||||||
|
|
||||||
2017-10-27 Simon Marchi <simon.marchi@ericsson.com>
|
2017-10-27 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* unittests/common-utils-selftests.c (format): Add
|
* unittests/common-utils-selftests.c (format): Add
|
||||||
|
|
|
@ -162,6 +162,7 @@ thpy_get_inferior (PyObject *self, void *ignore)
|
||||||
thread_object *thread_obj = (thread_object *) self;
|
thread_object *thread_obj = (thread_object *) self;
|
||||||
|
|
||||||
THPY_REQUIRE_VALID (thread_obj);
|
THPY_REQUIRE_VALID (thread_obj);
|
||||||
|
Py_INCREF (thread_obj->inf_obj);
|
||||||
|
|
||||||
return thread_obj->inf_obj;
|
return thread_obj->inf_obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2017-10-28 Maksim Dzabraev <dzabraew@gmail.com>
|
||||||
|
|
||||||
|
PR python/21213
|
||||||
|
* gdb.python/py-infthread.exp: Test calling
|
||||||
|
InferiorThread.inferior () multiple times in a row.
|
||||||
|
|
||||||
2017-10-27 Keith Seitz <keiths@redhat.com>
|
2017-10-27 Keith Seitz <keiths@redhat.com>
|
||||||
|
|
||||||
* gdb.opt/inline-break.exp (break_info_1): New procedure.
|
* gdb.opt/inline-break.exp (break_info_1): New procedure.
|
||||||
|
|
|
@ -51,6 +51,15 @@ gdb_test "python print(seen_a_thread)" "True"
|
||||||
|
|
||||||
# Test basic gdb.Inferior attributes and methods.
|
# Test basic gdb.Inferior attributes and methods.
|
||||||
|
|
||||||
|
# Make sure that InferiorThread.inferior returns a new reference (see PR 21213).
|
||||||
|
|
||||||
|
gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test InferiorThread.inferior 1" 1
|
||||||
|
gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test InferiorThread.inferior 2" 1
|
||||||
|
gdb_test_no_output "python import gc; gc.collect()" "call Python garbage collection"
|
||||||
|
gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test InferiorThread.inferior 3" 1
|
||||||
|
gdb_py_test_silent_cmd "python gdb.selected_thread ().inferior" "test InferiorThread.inferior 4" 1
|
||||||
|
|
||||||
|
|
||||||
gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1
|
gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1
|
||||||
gdb_test "python print (t0)" "\\<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object"
|
gdb_test "python print (t0)" "\\<gdb.InferiorThread object at 0x\[\[:xdigit:\]\]+>" "verify InferiorThread object"
|
||||||
gdb_test "python print ('result = %s' % t0.num)" " = 1" "test InferiorThread.num"
|
gdb_test "python print ('result = %s' % t0.num)" " = 1" "test InferiorThread.num"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue