aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/thread-db.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/thread-db.cc
parentf24791b72e764ada576901c0e866bf7768773a16 (diff)
downloadgdb-24583e45efc823c1a9ea009dfddc36f9b74dcbcd.zip
gdb-24583e45efc823c1a9ea009dfddc36f9b74dcbcd.tar.gz
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/thread-db.cc')
-rw-r--r--gdbserver/thread-db.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index 9a70cdf..01e8357 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -388,7 +388,6 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
psaddr_t addr;
td_err_e err;
struct lwp_info *lwp;
- struct thread_info *saved_thread;
struct process_info *proc;
struct thread_db *thread_db;
@@ -411,8 +410,8 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
if (!lwp->thread_known)
return TD_NOTHR;
- saved_thread = current_thread;
- current_thread = thread;
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (thread);
if (load_module != 0)
{
@@ -435,7 +434,6 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
addr = (char *) addr + offset;
}
- current_thread = saved_thread;
if (err == TD_OK)
{
*address = (CORE_ADDR) (uintptr_t) addr;
@@ -788,7 +786,7 @@ disable_thread_event_reporting (struct process_info *proc)
if (td_ta_clear_event_p != NULL)
{
- struct thread_info *saved_thread = current_thread;
+ scoped_restore_current_thread restore_thread;
td_thr_events_t events;
switch_to_process (proc);
@@ -797,8 +795,6 @@ disable_thread_event_reporting (struct process_info *proc)
in any events anymore. */
td_event_fillset (&events);
(*td_ta_clear_event_p) (thread_db->thread_agent, &events);
-
- current_thread = saved_thread;
}
}
}
@@ -894,8 +890,8 @@ thread_db_notice_clone (struct thread_info *parent_thr, ptid_t child_ptid)
/* find_one_thread calls into libthread_db which accesses memory via
the current thread. Temporarily switch to a thread we know is
stopped. */
- scoped_restore restore_current_thread
- = make_scoped_restore (&current_thread, parent_thr);
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (parent_thr);
if (!find_one_thread (child_ptid))
warning ("Cannot find thread after clone.");