aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/server.cc
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2021-12-13 12:22:48 +0100
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2021-12-13 12:22:48 +0100
commit24583e45efc823c1a9ea009dfddc36f9b74dcbcd (patch)
treeac00cde441192c880eee0f36a7e4346e0ba53c58 /gdbserver/server.cc
parentf24791b72e764ada576901c0e866bf7768773a16 (diff)
downloadfsf-binutils-gdb-24583e45efc823c1a9ea009dfddc36f9b74dcbcd.zip
fsf-binutils-gdb-24583e45efc823c1a9ea009dfddc36f9b74dcbcd.tar.gz
fsf-binutils-gdb-24583e45efc823c1a9ea009dfddc36f9b74dcbcd.tar.bz2
gdbserver: replace direct assignments to current_thread
Replace the direct assignments to current_thread with switch_to_thread. Use scoped_restore_current_thread when appropriate. There is one instance remaining in linux-low.cc's wait_for_sigstop. This will be handled in a separate patch. Regression-tested on X86-64 Linux using the native-gdbserver and native-extended-gdbserver board files.
Diffstat (limited to 'gdbserver/server.cc')
-rw-r--r--gdbserver/server.cc13
1 files changed, 5 insertions, 8 deletions
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 27e2aba..54ca95e 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1294,7 +1294,7 @@ handle_detach (char *own_buf)
cs.last_status.set_exited (0);
cs.last_ptid = ptid_t (pid);
- current_thread = NULL;
+ switch_to_thread (nullptr);
}
else
{
@@ -1722,8 +1722,7 @@ handle_qxfer_threads_proper (struct buffer *buffer)
{
client_state &cs = get_client_state ();
- scoped_restore save_current_thread
- = make_scoped_restore (&current_thread);
+ scoped_restore_current_thread restore_thread;
scoped_restore save_current_general_thread
= make_scoped_restore (&cs.general_thread);
@@ -2258,7 +2257,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (strcmp ("qSymbol::", own_buf) == 0)
{
- struct thread_info *save_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
/* For qSymbol, GDB only changes the current thread if the
previous current thread was of a different process. So if
@@ -2267,15 +2266,15 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
exec in a non-leader thread. */
if (current_thread == NULL)
{
- current_thread
+ thread_info *any_thread
= find_any_thread_of_pid (cs.general_thread.pid ());
+ switch_to_thread (any_thread);
/* Just in case, if we didn't find a thread, then bail out
instead of crashing. */
if (current_thread == NULL)
{
write_enn (own_buf);
- current_thread = save_thread;
return;
}
}
@@ -2298,8 +2297,6 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
if (current_thread != NULL)
the_target->look_up_symbols ();
- current_thread = save_thread;
-
strcpy (own_buf, "OK");
return;
}