This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[pushed/ob] make_cleanup_restore_current_thread: Look up thread earlier
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 4 May 2017 15:18:30 +0100
- Subject: [pushed/ob] make_cleanup_restore_current_thread: Look up thread earlier
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 096037AE99
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 096037AE99
The unconditional is_stopped call already asserts that the thread exists.
gdb/ChangeLog:
2017-05-04 Pedro Alves <palves@redhat.com>
* 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.
---
gdb/ChangeLog | 7 +++++++
gdb/thread.c | 10 +++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index aeb83dd..7c48c3d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2017-05-04 Pedro Alves <palves@redhat.com>
+ * 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 <palves@redhat.com>
+
* corelow.c (thread_section_name): New class.
(get_core_register_section, get_core_siginfo): Use it.
diff --git a/gdb/thread.c b/gdb/thread.c
index d08f414..fce37c5 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;
}
--
2.5.5