From: Pedro Alves Date: Thu, 4 May 2017 13:43:34 +0000 (+0100) Subject: make_cleanup_restore_current_thread: Look up thread earlier X-Git-Tag: users/hjl/linux/release/2.28.51.0.1~1^2~41^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6223dbb50b5d8780df633633adf0742c662173d;p=thirdparty%2Fbinutils-gdb.git make_cleanup_restore_current_thread: Look up thread earlier The unconditional is_stopped call already asserts that the thread exists. gdb/ChangeLog: 2017-05-04 Pedro Alves * thread.c (make_cleanup_restore_current_thread): Move find_thread_ptid call before the is_stopped call. Assert that the thread is found. Replace is_stopped call by checking the thread's state directly. Remove unnecessary NULL-thread check. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aeb83ddebba..7c48c3d311d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2017-05-04 Pedro Alves + + * thread.c (make_cleanup_restore_current_thread): Move + find_thread_ptid call before the is_stopped call. Assert that the + thread is found. Replace is_stopped call by checking the thread's + state directly. Remove unnecessary NULL-thread check. + 2017-05-04 Pedro Alves * corelow.c (thread_section_name): New class. diff --git a/gdb/thread.c b/gdb/thread.c index d08f4143273..fce37c5cb80 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1626,9 +1626,12 @@ make_cleanup_restore_current_thread (void) if (inferior_ptid != null_ptid) { + thread_info *tp = find_thread_ptid (inferior_ptid); struct frame_info *frame; - old->was_stopped = is_stopped (inferior_ptid); + gdb_assert (tp != NULL); + + old->was_stopped = tp->state == THREAD_STOPPED; if (old->was_stopped && target_has_registers && target_has_stack @@ -1647,10 +1650,7 @@ make_cleanup_restore_current_thread (void) old->selected_frame_id = get_frame_id (frame); old->selected_frame_level = frame_relative_level (frame); - struct thread_info *tp = find_thread_ptid (inferior_ptid); - - if (tp) - tp->incref (); + tp->incref (); old->thread = tp; }