From 484d8d361de65a8489252d14511b77c142d859a1 Mon Sep 17 00:00:00 2001 From: Maksim Dzabraev Date: Sun, 29 Oct 2017 01:14:34 +0700 Subject: 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) pi gdb.selected_thread().inferior Python Exception '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 --- gdb/python/py-infthread.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gdb/python') diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index 626c15c..31d576f 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -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; } -- cgit v1.1