public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] scox/gdbserver-multi-client: Replace global state access macros with member references.
@ 2018-01-31 15:52 scox
0 siblings, 0 replies; only message in thread
From: scox @ 2018-01-31 15:52 UTC (permalink / raw)
To: archer-commits
The branch, scox/gdbserver-multi-client has been updated
via 996acadf2d184ccab20ee67a861d6ffe2d096b94 (commit)
from 975a0cde0cc8190d62f6eebb227c23e49e62602e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 996acadf2d184ccab20ee67a861d6ffe2d096b94
Author: Stan Cox <scox@redhat.com>
Date: Wed Jan 31 10:50:19 2018 -0500
Replace global state access macros with member references.
-----------------------------------------------------------------------
Summary of changes:
gdb/gdbserver/ChangeLog | 5 +
gdb/gdbserver/fork-child.c | 13 +-
gdb/gdbserver/gdbthread.h | 12 +-
gdb/gdbserver/inferiors.c | 61 ++-
gdb/gdbserver/inferiors.h | 8 +-
gdb/gdbserver/linux-aarch32-low.c | 2 +-
gdb/gdbserver/linux-aarch64-low.c | 16 +-
gdb/gdbserver/linux-arm-low.c | 14 +-
gdb/gdbserver/linux-crisv32-low.c | 8 +-
gdb/gdbserver/linux-low.c | 374 +++++++++++--------
gdb/gdbserver/linux-low.h | 2 +-
gdb/gdbserver/linux-mips-low.c | 8 +-
gdb/gdbserver/linux-ppc-low.c | 6 +-
gdb/gdbserver/linux-s390-low.c | 10 +-
gdb/gdbserver/linux-tile-low.c | 2 +-
gdb/gdbserver/linux-x86-low.c | 26 +-
gdb/gdbserver/lynx-low.c | 16 +-
gdb/gdbserver/mem-break.c | 30 +-
gdb/gdbserver/notif.c | 7 +-
gdb/gdbserver/nto-low.c | 20 +-
gdb/gdbserver/proc-service.c | 13 +-
gdb/gdbserver/regcache.c | 18 +-
gdb/gdbserver/remote-utils.c | 179 +++++----
gdb/gdbserver/server.c | 737 ++++++++++++++++++++-----------------
gdb/gdbserver/server.h | 129 +++-----
gdb/gdbserver/spu-low.c | 8 +-
gdb/gdbserver/target.c | 33 +-
gdb/gdbserver/tdesc.c | 4 +-
gdb/gdbserver/thread-db.c | 19 +-
gdb/gdbserver/tracepoint.c | 15 +-
gdb/gdbserver/win32-i386-low.c | 6 +-
gdb/gdbserver/win32-low.c | 14 +-
gdb/gnulib/import/error.c | 12 +-
33 files changed, 990 insertions(+), 837 deletions(-)
First 500 lines of diff:
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index c86f4e0..feac55d 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2018-01-31 Stan Cox <scox@redhat.com>
+
+ * server.h (client_state, server_state): Removed struct member
+ access macros. Changed all callers.
+
2018-01-19 James Clarke <jrtc27@jrtc27.com>
* linux-low.c (handle_extended_wait): Surround call to
diff --git a/gdb/gdbserver/fork-child.c b/gdb/gdbserver/fork-child.c
index e00c788..74fa5e4 100644
--- a/gdb/gdbserver/fork-child.c
+++ b/gdb/gdbserver/fork-child.c
@@ -44,6 +44,8 @@ restore_old_foreground_pgrp (void)
void
prefork_hook (const char *args)
{
+ client_state *cs = get_client_state();
+
if (debug_threads)
{
debug_printf ("args: %s\n", args);
@@ -57,7 +59,7 @@ prefork_hook (const char *args)
/* Clear this so the backend doesn't get confused, thinking
CONT_THREAD died, and it needs to resume all threads. */
- cont_thread = null_ptid;
+ cs->ss->cont_thread = null_ptid;
}
/* See nat/fork-inferior.h. */
@@ -97,6 +99,7 @@ void
post_fork_inferior (int pid, const char *program)
{
#ifdef SIGTTOU
+ client_state *cs = get_client_state();
signal (SIGTTOU, SIG_IGN);
signal (SIGTTIN, SIG_IGN);
terminal_fd = fileno (stderr);
@@ -106,10 +109,10 @@ post_fork_inferior (int pid, const char *program)
#endif
startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED,
- &last_status, &last_ptid);
- current_thread->last_resume_kind = resume_stop;
- current_thread->last_waitstatus = last_status;
- signal_pid = pid;
+ &cs->ss->last_status, &cs->ss->last_ptid);
+ cs->ss->current_thread->last_resume_kind = resume_stop;
+ cs->ss->current_thread->last_status = cs->ss->last_status;
+ cs->ss->signal_pid = pid;
target_post_create_inferior ();
fprintf (stderr, "Process %s created; pid = %d\n", program, pid);
fflush (stderr);
diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index 3cacb1c..c5bd117 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -39,7 +39,7 @@ struct thread_info
enum resume_kind last_resume_kind;
/* The last wait status reported for this thread. */
- struct target_waitstatus last_waitstatus;
+ struct target_waitstatus last_status;
/* True if LAST_STATUS hasn't been reported to GDB yet. */
int status_pending_p;
@@ -93,9 +93,9 @@ template <typename Func>
static thread_info *
find_thread (Func func)
{
- std::list<thread_info *>::iterator next, cur = all_threads.begin ();
+ std::list<thread_info *>::iterator next, cur = get_client_state()->ss->all_threads.begin ();
- while (cur != all_threads.end ())
+ while (cur != get_client_state()->ss->all_threads.end ())
{
next = cur;
next++;
@@ -139,9 +139,9 @@ template <typename Func>
static void
for_each_thread (Func func)
{
- std::list<thread_info *>::iterator next, cur = all_threads.begin ();
+ std::list<thread_info *>::iterator next, cur = get_client_state()->ss->all_threads.begin ();
- while (cur != all_threads.end ())
+ while (cur != get_client_state()->ss->all_threads.end ())
{
next = cur;
next++;
@@ -196,7 +196,7 @@ find_thread_in_random (Func func)
}
/* Get current thread ID (Linux task ID). */
-#define current_ptid (current_thread->id)
+#define current_ptid (get_client_state()->ss->current_thread->id)
/* Get the ptid of THREAD. */
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index d9b56ad..c63f202 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -29,16 +29,17 @@ static const char *current_inferior_cwd = NULL;
struct thread_info *
add_thread (ptid_t thread_id, void *target_data)
{
+ client_state *cs = get_client_state();
struct thread_info *new_thread = XCNEW (struct thread_info);
new_thread->id = thread_id;
new_thread->last_resume_kind = resume_continue;
- new_thread->last_waitstatus.kind = TARGET_WAITKIND_IGNORE;
+ new_thread->last_status.kind = TARGET_WAITKIND_IGNORE;
- all_threads.push_back (new_thread);
+ cs->ss->all_threads.push_back (new_thread);
- if (current_thread == NULL)
- current_thread = new_thread;
+ if (cs->ss->current_thread == NULL)
+ cs->ss->current_thread = new_thread;
new_thread->target_data = target_data;
@@ -50,8 +51,10 @@ add_thread (ptid_t thread_id, void *target_data)
struct thread_info *
get_first_thread (void)
{
- if (!all_threads.empty ())
- return all_threads.front ();
+ client_state *cs = get_client_state();
+
+ if (!cs->ss->all_threads.empty ())
+ return cs->ss->all_threads.front ();
else
return NULL;
}
@@ -93,14 +96,16 @@ free_one_thread (thread_info *thread)
void
remove_thread (struct thread_info *thread)
{
+ client_state *cs = get_client_state();
+
if (thread->btrace != NULL)
target_disable_btrace (thread->btrace);
discard_queued_stop_replies (ptid_of (thread));
- all_threads.remove (thread);
+ cs->ss->all_threads.remove (thread);
free_one_thread (thread);
- if (current_thread == thread)
- current_thread = NULL;
+ if (cs->ss->current_thread == thread)
+ cs->ss->current_thread = NULL;
}
void *
@@ -124,20 +129,24 @@ set_thread_regcache_data (struct thread_info *thread, struct regcache *data)
void
clear_inferiors (void)
{
+ client_state *cs = get_client_state();
+
for_each_thread (free_one_thread);
- all_threads.clear ();
+ cs->ss->all_threads.clear ();
clear_dlls ();
- current_thread = NULL;
+ cs->ss->current_thread = NULL;
}
struct process_info *
add_process (int pid, int attached)
{
+ client_state *cs = get_client_state();
+
process_info *process = new process_info (pid, attached);
- all_processes.push_back (process);
+ cs->ss->all_processes.push_back (process);
return process;
}
@@ -149,10 +158,12 @@ add_process (int pid, int attached)
void
remove_process (struct process_info *process)
{
+ client_state *cs = get_client_state();
+
clear_symbol_cache (&process->symbol_cache);
free_all_breakpoints (process);
gdb_assert (find_thread_process (process) == NULL);
- all_processes.remove (process);
+ cs->ss->all_processes.remove (process);
delete process;
}
@@ -169,8 +180,10 @@ find_process_pid (int pid)
process_info *
get_first_process (void)
{
- if (!all_processes.empty ())
- return all_processes.front ();
+ client_state *cs = get_client_state();
+
+ if (!cs->ss->all_processes.empty ())
+ return cs->ss->all_processes.front ();
else
return NULL;
}
@@ -205,20 +218,26 @@ get_thread_process (const struct thread_info *thread)
struct process_info *
current_process (void)
{
- gdb_assert (current_thread != NULL);
- return get_thread_process (current_thread);
+ client_state *cs = get_client_state();
+
+ gdb_assert (cs->ss->current_thread != NULL);
+ return get_thread_process (cs->ss->current_thread);
}
static void
do_restore_current_thread_cleanup (void *arg)
{
- current_thread = (struct thread_info *) arg;
+ client_state *cs = get_client_state();
+
+ cs->ss->current_thread = (struct thread_info *) arg;
}
struct cleanup *
make_cleanup_restore_current_thread (void)
{
- return make_cleanup (do_restore_current_thread_cleanup, current_thread);
+ client_state *cs = get_client_state();
+
+ return make_cleanup (do_restore_current_thread_cleanup, cs->ss->current_thread);
}
/* See common/common-gdbthread.h. */
@@ -226,8 +245,10 @@ make_cleanup_restore_current_thread (void)
void
switch_to_thread (ptid_t ptid)
{
+ client_state *cs = get_client_state();
+
gdb_assert (ptid != minus_one_ptid);
- current_thread = find_thread_ptid (ptid);
+ cs->ss->current_thread = find_thread_ptid (ptid);
}
/* See common/common-inferior.h. */
diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h
index 5753c67..7f149f5 100644
--- a/gdb/gdbserver/inferiors.h
+++ b/gdb/gdbserver/inferiors.h
@@ -91,9 +91,9 @@ template <typename Func>
static void
for_each_process (Func func)
{
- std::list<process_info *>::iterator next, cur = all_processes.begin ();
+ std::list<process_info *>::iterator next, cur = get_client_state()->ss->all_processes.begin ();
- while (cur != all_processes.end ())
+ while (cur != get_client_state()->ss->all_processes.end ())
{
next = cur;
next++;
@@ -109,9 +109,9 @@ template <typename Func>
static process_info *
find_process (Func func)
{
- std::list<process_info *>::iterator next, cur = all_processes.begin ();
+ std::list<process_info *>::iterator next, cur = get_client_state()->ss->all_processes.begin ();
- while (cur != all_processes.end ())
+ while (cur != get_client_state()->ss->all_processes.end ())
{
next = cur;
next++;
diff --git a/gdb/gdbserver/linux-aarch32-low.c b/gdb/gdbserver/linux-aarch32-low.c
index 12c11a4..85b2d0d 100644
--- a/gdb/gdbserver/linux-aarch32-low.c
+++ b/gdb/gdbserver/linux-aarch32-low.c
@@ -171,7 +171,7 @@ struct regs_info regs_info_aarch32 =
int
arm_is_thumb_mode (void)
{
- struct regcache *regcache = get_thread_regcache (current_thread, 1);
+ struct regcache *regcache = get_thread_regcache (cs->ss->current_thread, 1);
unsigned long cpsr;
collect_register_by_name (regcache, "cpsr", &cpsr);
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index eccac4d..b382f4e 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -67,7 +67,7 @@ struct arch_process_info
static int
is_64bit_tdesc (void)
{
- struct regcache *regcache = get_thread_regcache (current_thread, 0);
+ struct regcache *regcache = get_thread_regcache (cs->ss->current_thread, 0);
return register_size (regcache->tdesc, 0) == 8;
}
@@ -253,7 +253,7 @@ aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
int ret;
enum target_hw_bp_type targ_type;
struct aarch64_debug_reg_state *state
- = aarch64_get_debug_reg_state (pid_of (current_thread));
+ = aarch64_get_debug_reg_state (pid_of (cs->ss->current_thread));
if (show_debug_regs)
fprintf (stderr, "insert_point on entry (addr=0x%08lx, len=%d)\n",
@@ -302,7 +302,7 @@ aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
int ret;
enum target_hw_bp_type targ_type;
struct aarch64_debug_reg_state *state
- = aarch64_get_debug_reg_state (pid_of (current_thread));
+ = aarch64_get_debug_reg_state (pid_of (cs->ss->current_thread));
if (show_debug_regs)
fprintf (stderr, "remove_point on entry (addr=0x%08lx, len=%d)\n",
@@ -345,7 +345,7 @@ aarch64_stopped_data_address (void)
int pid, i;
struct aarch64_debug_reg_state *state;
- pid = lwpid_of (current_thread);
+ pid = lwpid_of (cs->ss->current_thread);
/* Get the siginfo. */
if (ptrace (PTRACE_GETSIGINFO, pid, NULL, &siginfo) != 0)
@@ -357,7 +357,7 @@ aarch64_stopped_data_address (void)
return (CORE_ADDR) 0;
/* Check if the address matches any watched address. */
- state = aarch64_get_debug_reg_state (pid_of (current_thread));
+ state = aarch64_get_debug_reg_state (pid_of (cs->ss->current_thread));
for (i = aarch64_num_wp_regs - 1; i >= 0; --i)
{
const unsigned int len = aarch64_watchpoint_length (state->dr_ctrl_wp[i]);
@@ -473,7 +473,7 @@ aarch64_arch_setup (void)
int is_elf64;
int tid;
- tid = lwpid_of (current_thread);
+ tid = lwpid_of (cs->ss->current_thread);
is_elf64 = linux_pid_exe_is_elf_64_file (tid, &machine);
@@ -482,7 +482,7 @@ aarch64_arch_setup (void)
else
current_process ()->tdesc = tdesc_arm_with_neon;
- aarch64_linux_get_debug_reg_capacity (lwpid_of (current_thread));
+ aarch64_linux_get_debug_reg_capacity (lwpid_of (cs->ss->current_thread));
}
static struct regset_info aarch64_regsets[] =
@@ -527,7 +527,7 @@ aarch64_regs_info (void)
static int
aarch64_supports_tracepoints (void)
{
- if (current_thread == NULL)
+ if (cs->ss->current_thread == NULL)
return 1;
else
{
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index 6c2dcea..2bf687b 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -528,7 +528,7 @@ arm_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
pts[i] = p;
/* Only update the threads of the current process. */
- for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
+ for_each_thread (cs->ss->current_thread->id.pid (), [&] (thread_info *thread)
{
update_registers_callback (thread, watch, i);
});
@@ -573,7 +573,7 @@ arm_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
pts[i].control = arm_hwbp_control_disable (pts[i].control);
/* Only update the threads of the current process. */
- for_each_thread (current_thread->id.pid (), [&] (thread_info *thread)
+ for_each_thread (cs->ss->current_thread->id.pid (), [&] (thread_info *thread)
{
update_registers_callback (thread, watch, i);
});
@@ -589,7 +589,7 @@ arm_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
static int
arm_stopped_by_watchpoint (void)
{
- struct lwp_info *lwp = get_thread_lwp (current_thread);
+ struct lwp_info *lwp = get_thread_lwp (cs->ss->current_thread);
siginfo_t siginfo;
/* We must be able to set hardware watchpoints. */
@@ -598,7 +598,7 @@ arm_stopped_by_watchpoint (void)
/* Retrieve siginfo. */
errno = 0;
- ptrace (PTRACE_GETSIGINFO, lwpid_of (current_thread), 0, &siginfo);
+ ptrace (PTRACE_GETSIGINFO, lwpid_of (cs->ss->current_thread), 0, &siginfo);
if (errno != 0)
return 0;
@@ -624,7 +624,7 @@ arm_stopped_by_watchpoint (void)
static CORE_ADDR
arm_stopped_data_address (void)
{
- struct lwp_info *lwp = get_thread_lwp (current_thread);
+ struct lwp_info *lwp = get_thread_lwp (cs->ss->current_thread);
return lwp->arch_private->stopped_data_address;
}
@@ -872,7 +872,7 @@ arm_get_hwcap (unsigned long *valp)
static const struct target_desc *
arm_read_description (void)
{
- int pid = lwpid_of (current_thread);
+ int pid = lwpid_of (cs->ss->current_thread);
unsigned long arm_hwcap = 0;
/* Query hardware watchpoint/breakpoint capabilities. */
@@ -919,7 +919,7 @@ arm_read_description (void)
static void
arm_arch_setup (void)
{
- int tid = lwpid_of (current_thread);
+ int tid = lwpid_of (cs->ss->current_thread);
int gpregs[18];
struct iovec iov;
diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c
index 6eb8217..4158260 100644
--- a/gdb/gdbserver/linux-crisv32-low.c
+++ b/gdb/gdbserver/linux-crisv32-low.c
@@ -139,7 +139,7 @@ cris_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
unsigned long ccs;
struct regcache *regcache;
- regcache = get_thread_regcache (current_thread, 1);
+ regcache = get_thread_regcache (cs->ss->current_thread, 1);
/* Read watchpoints are set as access watchpoints, because of GDB's
inability to deal with pure read watchpoints. */
@@ -212,7 +212,7 @@ cris_remove_point (enum raw_bkpt_type type, CORE_ADDR addr, int len,
struct regcache *regcache;
unsigned long bp_d_regs[12];
- regcache = get_thread_regcache (current_thread, 1);
+ regcache = get_thread_regcache (cs->ss->current_thread, 1);
/* Read watchpoints are set as access watchpoints, because of GDB's
inability to deal with pure read watchpoints. */
@@ -289,7 +289,7 @@ static int
cris_stopped_by_watchpoint (void)
{
unsigned long exs;
- struct regcache *regcache = get_thread_regcache (current_thread, 1);
+ struct regcache *regcache = get_thread_regcache (cs->ss->current_thread, 1);
collect_register_by_name (regcache, "exs", &exs);
@@ -300,7 +300,7 @@ static CORE_ADDR
cris_stopped_data_address (void)
{
unsigned long eda;
- struct regcache *regcache = get_thread_regcache (current_thread, 1);
+ struct regcache *regcache = get_thread_regcache (cs->ss->current_thread, 1);
collect_register_by_name (regcache, "eda", &eda);
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 561086d..3359ce7 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -455,14 +455,15 @@ linux_arch_setup (void)
static void
linux_arch_setup_thread (struct thread_info *thread)
{
+ client_state *cs = get_client_state();
struct thread_info *saved_thread;
- saved_thread = current_thread;
- current_thread = thread;
+ saved_thread = cs->ss->current_thread;
+ cs->ss->current_thread = thread;
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-01-31 15:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 15:52 [SCM] scox/gdbserver-multi-client: Replace global state access macros with member references scox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).