]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix inferior_thread attribute in new_thread event
authorHannes Domani <ssbssa@yahoo.de>
Wed, 5 Jan 2022 15:37:28 +0000 (16:37 +0100)
committerHannes Domani <ssbssa@yahoo.de>
Wed, 5 Jan 2022 17:35:20 +0000 (18:35 +0100)
Commit 72ee03ff58 fixed a use-after-move bug in add_thread_object, but
it changed the inferior_thread attribute to contain the inferior instead
of the actual thread.
This now uses the thread_obj in its new location instead.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28429

gdb/python/py-inferior.c
gdb/testsuite/gdb.python/py-infthread.exp

index 6b1443db2a842e1b93494dd67da048b230064406..45e33f9e28a7d896ef353c6348f7fcd64d3b1e0a 100644 (file)
@@ -333,7 +333,8 @@ add_thread_object (struct thread_info *tp)
     return;
 
   gdbpy_ref<> event = create_thread_event_object (&new_thread_event_object_type,
-                                                 (PyObject *) inf_obj);
+                                                 (PyObject *)
+                                                 entry->thread_obj.get ());
   if (event == NULL
       || evpy_emit_event (event.get (), gdb_py_events.new_thread) < 0)
     gdbpy_print_stack ();
index b0747154ee0002e36c891d97cddd5058eaa1aaa8..5cbbe43c44c14ded6d3b33c8ace641a156c13c15 100644 (file)
@@ -31,7 +31,8 @@ gdb_test_multiline "install new_thread event handler" \
     "python" "" \
     "seen_a_thread = False" "" \
     "def thread_handler(evt):" "" \
-    "  if evt.inferior_thread is not None:" "" \
+    "  if (evt.inferior_thread is not None" "" \
+    "      and isinstance (evt.inferior_thread, gdb.InferiorThread)):" "" \
     "    global seen_a_thread" "" \
     "    seen_a_thread = True" "" \
     "gdb.events.new_thread.connect(thread_handler)" "" \