Fix inferior_thread attribute in new_thread event

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
This commit is contained in:
Hannes Domani 2022-01-05 16:37:28 +01:00
parent 63a8c05f09
commit 72df4c816f
2 changed files with 4 additions and 2 deletions

View file

@ -333,7 +333,8 @@ add_thread_object (struct thread_info *tp)
return; return;
gdbpy_ref<> event = create_thread_event_object (&new_thread_event_object_type, gdbpy_ref<> event = create_thread_event_object (&new_thread_event_object_type,
(PyObject *) inf_obj); (PyObject *)
entry->thread_obj.get ());
if (event == NULL if (event == NULL
|| evpy_emit_event (event.get (), gdb_py_events.new_thread) < 0) || evpy_emit_event (event.get (), gdb_py_events.new_thread) < 0)
gdbpy_print_stack (); gdbpy_print_stack ();

View file

@ -31,7 +31,8 @@ gdb_test_multiline "install new_thread event handler" \
"python" "" \ "python" "" \
"seen_a_thread = False" "" \ "seen_a_thread = False" "" \
"def thread_handler(evt):" "" \ "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" "" \ " global seen_a_thread" "" \
" seen_a_thread = True" "" \ " seen_a_thread = True" "" \
"gdb.events.new_thread.connect(thread_handler)" "" \ "gdb.events.new_thread.connect(thread_handler)" "" \