From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Pedro Alves <palves@redhat.com>,
Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH v2] Use "switch_to_thread" more thoroughly on gdbserver
Date: Tue, 26 Sep 2017 04:23:00 -0000 [thread overview]
Message-ID: <20170926042239.30748-1-sergiodj@redhat.com> (raw)
In-Reply-To: <20170915043357.26094-1-sergiodj@redhat.com>
This is a technical debt that I left when I ported "switch_to_thread"
to gdbserver. It's a simple patch that converts occurences of:
current_thread = find_thread_ptid (ptid);
to:
switch_to_thread (ptid);
This patch also converts a simple "if" to a "gdb_assert" on
gdbserver's version of "switch_to_thread":
gdb_assert (!ptid_equal (ptid, minus_one_ptid));
This change makes the code more similar to what GDB already does.
Regtested on BuildBot.
gdb/gdbserver/ChangeLog:
yyyy-mm-dd Sergio Durigan Junior <sergiodj@redhat.com>
* gdbthread.h: Include "common-gdbthread.h".
* inferiors.c (switch_to_thread): Use "gdb_assert" instead of
"if" when validating the ptid.
* remote-utils.c: Include "gdbthread.h".
(prepare_resume_reply): Use "switch_to_thread".
* target.c (done_accessing_memory): Likewise.
---
gdb/gdbserver/gdbthread.h | 1 +
gdb/gdbserver/inferiors.c | 4 ++--
gdb/gdbserver/remote-utils.c | 3 ++-
gdb/gdbserver/target.c | 2 +-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index 04cc47ba71..a864f95884 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -19,6 +19,7 @@
#ifndef GDB_THREAD_H
#define GDB_THREAD_H
+#include "common-gdbthread.h"
#include "inferiors.h"
struct btrace_target_info;
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 72f0412757..7705c2af47 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -442,6 +442,6 @@ make_cleanup_restore_current_thread (void)
void
switch_to_thread (ptid_t ptid)
{
- if (!ptid_equal (ptid, minus_one_ptid))
- current_thread = find_thread_ptid (ptid);
+ gdb_assert (!ptid_equal (ptid, minus_one_ptid));
+ current_thread = find_thread_ptid (ptid);
}
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 25b7e41a91..761604683c 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -23,6 +23,7 @@
#include "tdesc.h"
#include "dll.h"
#include "rsp-low.h"
+#include "gdbthread.h"
#include <ctype.h>
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
@@ -1188,7 +1189,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
saved_thread = current_thread;
- current_thread = find_thread_ptid (ptid);
+ switch_to_thread (ptid);
regp = current_target_desc ()->expedite_regs;
diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c
index 7f5bed7ec7..94224a8a7c 100644
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -138,7 +138,7 @@ done_accessing_memory (void)
/* Restore the previous selected thread. */
general_thread = prev_general_thread;
- current_thread = find_thread_ptid (general_thread);
+ switch_to_thread (general_thread);
}
int
--
2.13.3
next prev parent reply other threads:[~2017-09-26 4:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 4:34 [PATCH] " Sergio Durigan Junior
2017-09-15 11:14 ` Pedro Alves
2017-09-15 18:25 ` Sergio Durigan Junior
2017-09-21 15:11 ` Pedro Alves
2017-09-21 15:42 ` Sergio Durigan Junior
2017-09-26 4:23 ` Sergio Durigan Junior [this message]
2017-09-26 12:28 ` [PATCH v2] " Pedro Alves
2017-09-26 16:52 ` Sergio Durigan Junior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170926042239.30748-1-sergiodj@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox