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:
Maksim Dzabraev 2017-10-29 01:14:34 +07:00 committed by Simon Marchi
parent d91f0b20e5
commit 484d8d361d
4 changed files with 22 additions and 0 deletions

View file

@ -162,6 +162,7 @@ thpy_get_inferior (PyObject *self, void *ignore)
thread_object *thread_obj = (thread_object *) self;
THPY_REQUIRE_VALID (thread_obj);
Py_INCREF (thread_obj->inf_obj);
return thread_obj->inf_obj;
}