This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR Python/12212


Tom Tromey <tromey@redhat.com> writes:

>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> Oops I did not notice that the documentation.  In that case the only
> Phil> change is to py-inferior.c, and I can delete the changes to
> Phil> py-infthread.c.  Do you want me to generate a new patch, or should I
> Phil> just go ahead check that change in?
>
> It would be nice to have a regression test for the crash.

I adjusted the regression test in the previous patch I sent to account
for this.  

Patch included.

Cheers,

Phil

--

diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index b1ddb168..6382dab 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -130,6 +130,9 @@ find_thread_object (ptid_t ptid)
   PyObject *inf_obj;
 
   pid = PIDGET (ptid);
+  if (pid == 0)
+    return NULL;
+
   inf_obj = find_inferior_object (pid);
 
   if (inf_obj)
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index dd9175a..e6080d1 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -146,6 +146,11 @@ gdb_test_no_output "python a = gdb.execute('help', to_string=True)" "collect hel
 
 gdb_test "python print a" ".*aliases -- Aliases of other commands.*" "verify help to uiout"
 
+# Test PR 12212, using InfThread.selected_thread() when no inferior is
+# loaded.
+gdb_py_test_silent_cmd "python nothread = gdb.selected_thread()" "Attempt to aquire thread with no inferior" 1
+gdb_test "python print nothread == None" "True" "Ensure that no threads are returned"
+
 # Start with a fresh gdb.
 clean_restart ${testfile}
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]