Add client_state struct.
Collect per client specific global data items into struct client_state, which is similar in purpose to remote.c::remote_state. gdbserver/ChangeLog * server.h (struct client_state): New. * server.c (cont_thread, general_thread, multi_process) (report_fork_events, report_vfork_events, report_exec_events) (report_thread_events, swbreak_feature, hwbreak_feature) (vCont_supported, disable_randomization, pass_signals) (program_signals, program_signals_p, last_status, last_ptid, own_buf): Moved to client_state. * remote-utils.c (remote_debug, noack_mode) (transport_is_reliable): Moved to client_state. * tracepoint.c (current_traceframe): Moved to client_state. Update all callers. * server.c, remote-utils.c, tracepoint.c, fork-child.c, linux-low.c, remote-utils.h, target.c: Use client_state.
This commit is contained in:
parent
23081219bf
commit
c12a508964
9 changed files with 451 additions and 374 deletions
|
@ -1,3 +1,20 @@
|
||||||
|
2018-06-04 Stan Cox <scox@redhat.com>
|
||||||
|
|
||||||
|
* server.h (struct client_state): New.
|
||||||
|
* server.c (cont_thread, general_thread, multi_process)
|
||||||
|
(report_fork_events, report_vfork_events, report_exec_events)
|
||||||
|
(report_thread_events, swbreak_feature, hwbreak_feature)
|
||||||
|
(vCont_supported, disable_randomization, pass_signals)
|
||||||
|
(program_signals, program_signals_p, last_status, last_ptid, own_buf):
|
||||||
|
Moved to client_state.
|
||||||
|
* remote-utils.c (remote_debug, noack_mode)
|
||||||
|
(transport_is_reliable): Moved to client_state.
|
||||||
|
* tracepoint.c (current_traceframe): Moved to client_state.
|
||||||
|
|
||||||
|
Update all callers.
|
||||||
|
* server.c, remote-utils.c, tracepoint.c, fork-child.c,
|
||||||
|
linux-low.c, remote-utils.h, target.c: Use client_state.
|
||||||
|
|
||||||
2018-05-31 Alan Hayward <alan.hayward@arm.com>
|
2018-05-31 Alan Hayward <alan.hayward@arm.com>
|
||||||
|
|
||||||
* configure.srv: Add new c/h file.
|
* configure.srv: Add new c/h file.
|
||||||
|
|
|
@ -44,6 +44,7 @@ restore_old_foreground_pgrp (void)
|
||||||
void
|
void
|
||||||
prefork_hook (const char *args)
|
prefork_hook (const char *args)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
if (debug_threads)
|
if (debug_threads)
|
||||||
{
|
{
|
||||||
debug_printf ("args: %s\n", args);
|
debug_printf ("args: %s\n", args);
|
||||||
|
@ -57,7 +58,7 @@ prefork_hook (const char *args)
|
||||||
|
|
||||||
/* Clear this so the backend doesn't get confused, thinking
|
/* Clear this so the backend doesn't get confused, thinking
|
||||||
CONT_THREAD died, and it needs to resume all threads. */
|
CONT_THREAD died, and it needs to resume all threads. */
|
||||||
cont_thread = null_ptid;
|
cs.cont_thread = null_ptid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See nat/fork-inferior.h. */
|
/* See nat/fork-inferior.h. */
|
||||||
|
@ -96,6 +97,7 @@ gdb_flush_out_err ()
|
||||||
void
|
void
|
||||||
post_fork_inferior (int pid, const char *program)
|
post_fork_inferior (int pid, const char *program)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
#ifdef SIGTTOU
|
#ifdef SIGTTOU
|
||||||
signal (SIGTTOU, SIG_IGN);
|
signal (SIGTTOU, SIG_IGN);
|
||||||
signal (SIGTTIN, SIG_IGN);
|
signal (SIGTTIN, SIG_IGN);
|
||||||
|
@ -106,9 +108,9 @@ post_fork_inferior (int pid, const char *program)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED,
|
startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED,
|
||||||
&last_status, &last_ptid);
|
&cs.last_status, &cs.last_ptid);
|
||||||
current_thread->last_resume_kind = resume_stop;
|
current_thread->last_resume_kind = resume_stop;
|
||||||
current_thread->last_status = last_status;
|
current_thread->last_status = cs.last_status;
|
||||||
signal_pid = pid;
|
signal_pid = pid;
|
||||||
target_post_create_inferior ();
|
target_post_create_inferior ();
|
||||||
fprintf (stderr, "Process %s created; pid = %d\n", program, pid);
|
fprintf (stderr, "Process %s created; pid = %d\n", program, pid);
|
||||||
|
|
|
@ -475,6 +475,7 @@ linux_arch_setup_thread (struct thread_info *thread)
|
||||||
static int
|
static int
|
||||||
handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
|
handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct lwp_info *event_lwp = *orig_event_lwp;
|
struct lwp_info *event_lwp = *orig_event_lwp;
|
||||||
int event = linux_ptrace_get_extended_event (wstat);
|
int event = linux_ptrace_get_extended_event (wstat);
|
||||||
struct thread_info *event_thr = get_lwp_thread (event_lwp);
|
struct thread_info *event_thr = get_lwp_thread (event_lwp);
|
||||||
|
@ -655,7 +656,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
|
||||||
new_lwp->status_pending_p = 1;
|
new_lwp->status_pending_p = 1;
|
||||||
new_lwp->status_pending = status;
|
new_lwp->status_pending = status;
|
||||||
}
|
}
|
||||||
else if (report_thread_events)
|
else if (cs.report_thread_events)
|
||||||
{
|
{
|
||||||
new_lwp->waitstatus.kind = TARGET_WAITKIND_THREAD_CREATED;
|
new_lwp->waitstatus.kind = TARGET_WAITKIND_THREAD_CREATED;
|
||||||
new_lwp->status_pending_p = 1;
|
new_lwp->status_pending_p = 1;
|
||||||
|
@ -683,7 +684,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
|
||||||
/* Report the event. */
|
/* Report the event. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (event == PTRACE_EVENT_EXEC && report_exec_events)
|
else if (event == PTRACE_EVENT_EXEC && cs.report_exec_events)
|
||||||
{
|
{
|
||||||
struct process_info *proc;
|
struct process_info *proc;
|
||||||
std::vector<int> syscalls_to_catch;
|
std::vector<int> syscalls_to_catch;
|
||||||
|
@ -998,13 +999,14 @@ static int
|
||||||
linux_create_inferior (const char *program,
|
linux_create_inferior (const char *program,
|
||||||
const std::vector<char *> &program_args)
|
const std::vector<char *> &program_args)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct lwp_info *new_lwp;
|
struct lwp_info *new_lwp;
|
||||||
int pid;
|
int pid;
|
||||||
ptid_t ptid;
|
ptid_t ptid;
|
||||||
|
|
||||||
{
|
{
|
||||||
maybe_disable_address_space_randomization restore_personality
|
maybe_disable_address_space_randomization restore_personality
|
||||||
(disable_randomization);
|
(cs.disable_randomization);
|
||||||
std::string str_program_args = stringify_argv (program_args);
|
std::string str_program_args = stringify_argv (program_args);
|
||||||
|
|
||||||
pid = fork_inferior (program,
|
pid = fork_inferior (program,
|
||||||
|
@ -1429,6 +1431,7 @@ linux_kill (int pid)
|
||||||
static int
|
static int
|
||||||
get_detach_signal (struct thread_info *thread)
|
get_detach_signal (struct thread_info *thread)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
enum gdb_signal signo = GDB_SIGNAL_0;
|
enum gdb_signal signo = GDB_SIGNAL_0;
|
||||||
int status;
|
int status;
|
||||||
struct lwp_info *lp = get_thread_lwp (thread);
|
struct lwp_info *lp = get_thread_lwp (thread);
|
||||||
|
@ -1469,7 +1472,7 @@ get_detach_signal (struct thread_info *thread)
|
||||||
|
|
||||||
signo = gdb_signal_from_host (WSTOPSIG (status));
|
signo = gdb_signal_from_host (WSTOPSIG (status));
|
||||||
|
|
||||||
if (program_signals_p && !program_signals[signo])
|
if (cs.program_signals_p && !cs.program_signals[signo])
|
||||||
{
|
{
|
||||||
if (debug_threads)
|
if (debug_threads)
|
||||||
debug_printf ("GPS: lwp %s had signal %s, but it is in nopass state\n",
|
debug_printf ("GPS: lwp %s had signal %s, but it is in nopass state\n",
|
||||||
|
@ -1477,7 +1480,7 @@ get_detach_signal (struct thread_info *thread)
|
||||||
gdb_signal_to_string (signo));
|
gdb_signal_to_string (signo));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (!program_signals_p
|
else if (!cs.program_signals_p
|
||||||
/* If we have no way to know which signals GDB does not
|
/* If we have no way to know which signals GDB does not
|
||||||
want to have passed to the program, assume
|
want to have passed to the program, assume
|
||||||
SIGTRAP/SIGINT, which is GDB's default. */
|
SIGTRAP/SIGINT, which is GDB's default. */
|
||||||
|
@ -2328,18 +2331,19 @@ check_stopped_by_watchpoint (struct lwp_info *child)
|
||||||
static int
|
static int
|
||||||
linux_low_ptrace_options (int attached)
|
linux_low_ptrace_options (int attached)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int options = 0;
|
int options = 0;
|
||||||
|
|
||||||
if (!attached)
|
if (!attached)
|
||||||
options |= PTRACE_O_EXITKILL;
|
options |= PTRACE_O_EXITKILL;
|
||||||
|
|
||||||
if (report_fork_events)
|
if (cs.report_fork_events)
|
||||||
options |= PTRACE_O_TRACEFORK;
|
options |= PTRACE_O_TRACEFORK;
|
||||||
|
|
||||||
if (report_vfork_events)
|
if (cs.report_vfork_events)
|
||||||
options |= (PTRACE_O_TRACEVFORK | PTRACE_O_TRACEVFORKDONE);
|
options |= (PTRACE_O_TRACEVFORK | PTRACE_O_TRACEVFORKDONE);
|
||||||
|
|
||||||
if (report_exec_events)
|
if (cs.report_exec_events)
|
||||||
options |= PTRACE_O_TRACEEXEC;
|
options |= PTRACE_O_TRACEEXEC;
|
||||||
|
|
||||||
options |= PTRACE_O_TRACESYSGOOD;
|
options |= PTRACE_O_TRACESYSGOOD;
|
||||||
|
@ -2354,6 +2358,7 @@ linux_low_ptrace_options (int attached)
|
||||||
static struct lwp_info *
|
static struct lwp_info *
|
||||||
linux_low_filter_event (int lwpid, int wstat)
|
linux_low_filter_event (int lwpid, int wstat)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct lwp_info *child;
|
struct lwp_info *child;
|
||||||
struct thread_info *thread;
|
struct thread_info *thread;
|
||||||
int have_stop_pc = 0;
|
int have_stop_pc = 0;
|
||||||
|
@ -2425,7 +2430,7 @@ linux_low_filter_event (int lwpid, int wstat)
|
||||||
/* If there is at least one more LWP, then the exit signal was
|
/* If there is at least one more LWP, then the exit signal was
|
||||||
not the end of the debugged application and should be
|
not the end of the debugged application and should be
|
||||||
ignored, unless GDB wants to hear about thread exits. */
|
ignored, unless GDB wants to hear about thread exits. */
|
||||||
if (report_thread_events
|
if (cs.report_thread_events
|
||||||
|| last_thread_of_process_p (pid_of (thread)))
|
|| last_thread_of_process_p (pid_of (thread)))
|
||||||
{
|
{
|
||||||
/* Since events are serialized to GDB core, and we can't
|
/* Since events are serialized to GDB core, and we can't
|
||||||
|
@ -3049,12 +3054,13 @@ static ptid_t
|
||||||
filter_exit_event (struct lwp_info *event_child,
|
filter_exit_event (struct lwp_info *event_child,
|
||||||
struct target_waitstatus *ourstatus)
|
struct target_waitstatus *ourstatus)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct thread_info *thread = get_lwp_thread (event_child);
|
struct thread_info *thread = get_lwp_thread (event_child);
|
||||||
ptid_t ptid = ptid_of (thread);
|
ptid_t ptid = ptid_of (thread);
|
||||||
|
|
||||||
if (!last_thread_of_process_p (pid_of (thread)))
|
if (!last_thread_of_process_p (pid_of (thread)))
|
||||||
{
|
{
|
||||||
if (report_thread_events)
|
if (cs.report_thread_events)
|
||||||
ourstatus->kind = TARGET_WAITKIND_THREAD_EXITED;
|
ourstatus->kind = TARGET_WAITKIND_THREAD_EXITED;
|
||||||
else
|
else
|
||||||
ourstatus->kind = TARGET_WAITKIND_IGNORE;
|
ourstatus->kind = TARGET_WAITKIND_IGNORE;
|
||||||
|
@ -3106,6 +3112,7 @@ static ptid_t
|
||||||
linux_wait_1 (ptid_t ptid,
|
linux_wait_1 (ptid_t ptid,
|
||||||
struct target_waitstatus *ourstatus, int target_options)
|
struct target_waitstatus *ourstatus, int target_options)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int w;
|
int w;
|
||||||
struct lwp_info *event_child;
|
struct lwp_info *event_child;
|
||||||
int options;
|
int options;
|
||||||
|
@ -3475,7 +3482,7 @@ linux_wait_1 (ptid_t ptid,
|
||||||
|| WSTOPSIG (w) == __SIGRTMIN + 1))
|
|| WSTOPSIG (w) == __SIGRTMIN + 1))
|
||||||
||
|
||
|
||||||
#endif
|
#endif
|
||||||
(pass_signals[gdb_signal_from_host (WSTOPSIG (w))]
|
(cs.pass_signals[gdb_signal_from_host (WSTOPSIG (w))]
|
||||||
&& !(WSTOPSIG (w) == SIGSTOP
|
&& !(WSTOPSIG (w) == SIGSTOP
|
||||||
&& current_thread->last_resume_kind == resume_stop)
|
&& current_thread->last_resume_kind == resume_stop)
|
||||||
&& !linux_wstatus_maybe_breakpoint (w))))
|
&& !linux_wstatus_maybe_breakpoint (w))))
|
||||||
|
@ -3782,7 +3789,7 @@ linux_wait_1 (ptid_t ptid,
|
||||||
it was a software breakpoint, and the client doesn't know we can
|
it was a software breakpoint, and the client doesn't know we can
|
||||||
adjust the breakpoint ourselves. */
|
adjust the breakpoint ourselves. */
|
||||||
if (event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|
if (event_child->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT
|
||||||
&& !swbreak_feature)
|
&& !cs.swbreak_feature)
|
||||||
{
|
{
|
||||||
int decr_pc = the_low_target.decr_pc_after_break;
|
int decr_pc = the_low_target.decr_pc_after_break;
|
||||||
|
|
||||||
|
|
|
@ -115,11 +115,6 @@ static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
|
||||||
extern int using_threads;
|
extern int using_threads;
|
||||||
extern int debug_threads;
|
extern int debug_threads;
|
||||||
|
|
||||||
/* If true, then GDB has requested noack mode. */
|
|
||||||
int noack_mode = 0;
|
|
||||||
/* If true, then we tell GDB to use noack mode by default. */
|
|
||||||
int transport_is_reliable = 0;
|
|
||||||
|
|
||||||
#ifdef USE_WIN32API
|
#ifdef USE_WIN32API
|
||||||
# define read(fd, buf, len) recv (fd, (char *) buf, len, 0)
|
# define read(fd, buf, len) recv (fd, (char *) buf, len, 0)
|
||||||
# define write(fd, buf, len) send (fd, (char *) buf, len, 0)
|
# define write(fd, buf, len) send (fd, (char *) buf, len, 0)
|
||||||
|
@ -222,6 +217,7 @@ handle_accept_event (int err, gdb_client_data client_data)
|
||||||
void
|
void
|
||||||
remote_prepare (const char *name)
|
remote_prepare (const char *name)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
const char *port_str;
|
const char *port_str;
|
||||||
#ifdef USE_WIN32API
|
#ifdef USE_WIN32API
|
||||||
static int winsock_initialized;
|
static int winsock_initialized;
|
||||||
|
@ -238,14 +234,14 @@ remote_prepare (const char *name)
|
||||||
call to remote_open so start_inferior knows the connection is
|
call to remote_open so start_inferior knows the connection is
|
||||||
via stdio. */
|
via stdio. */
|
||||||
remote_is_stdio = 1;
|
remote_is_stdio = 1;
|
||||||
transport_is_reliable = 1;
|
cs.transport_is_reliable = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
port_str = strchr (name, ':');
|
port_str = strchr (name, ':');
|
||||||
if (port_str == NULL)
|
if (port_str == NULL)
|
||||||
{
|
{
|
||||||
transport_is_reliable = 0;
|
cs.transport_is_reliable = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +276,7 @@ remote_prepare (const char *name)
|
||||||
|| listen (listen_desc, 1))
|
|| listen (listen_desc, 1))
|
||||||
perror_with_name ("Can't bind address");
|
perror_with_name ("Can't bind address");
|
||||||
|
|
||||||
transport_is_reliable = 1;
|
cs.transport_is_reliable = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open a connection to a remote debugger.
|
/* Open a connection to a remote debugger.
|
||||||
|
@ -485,9 +481,10 @@ try_rle (char *buf, int remaining, unsigned char *csum, char **p)
|
||||||
char *
|
char *
|
||||||
write_ptid (char *buf, ptid_t ptid)
|
write_ptid (char *buf, ptid_t ptid)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int pid, tid;
|
int pid, tid;
|
||||||
|
|
||||||
if (multi_process)
|
if (cs.multi_process)
|
||||||
{
|
{
|
||||||
pid = ptid_get_pid (ptid);
|
pid = ptid_get_pid (ptid);
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
|
@ -594,6 +591,7 @@ read_prim (void *buf, int count)
|
||||||
static int
|
static int
|
||||||
putpkt_binary_1 (char *buf, int cnt, int is_notif)
|
putpkt_binary_1 (char *buf, int cnt, int is_notif)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int i;
|
int i;
|
||||||
unsigned char csum = 0;
|
unsigned char csum = 0;
|
||||||
char *buf2;
|
char *buf2;
|
||||||
|
@ -631,7 +629,7 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noack_mode || is_notif)
|
if (cs.noack_mode || is_notif)
|
||||||
{
|
{
|
||||||
/* Don't expect an ack then. */
|
/* Don't expect an ack then. */
|
||||||
if (remote_debug)
|
if (remote_debug)
|
||||||
|
@ -851,6 +849,7 @@ static unsigned char *readchar_bufp;
|
||||||
static int
|
static int
|
||||||
readchar (void)
|
readchar (void)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
if (readchar_bufcnt == 0)
|
if (readchar_bufcnt == 0)
|
||||||
|
@ -926,6 +925,7 @@ reschedule (void)
|
||||||
int
|
int
|
||||||
getpkt (char *buf)
|
getpkt (char *buf)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
char *bp;
|
char *bp;
|
||||||
unsigned char csum, c1, c2;
|
unsigned char csum, c1, c2;
|
||||||
int c;
|
int c;
|
||||||
|
@ -977,7 +977,7 @@ getpkt (char *buf)
|
||||||
if (csum == (c1 << 4) + c2)
|
if (csum == (c1 << 4) + c2)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (noack_mode)
|
if (cs.noack_mode)
|
||||||
{
|
{
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"Bad checksum, sentsum=0x%x, csum=0x%x, "
|
"Bad checksum, sentsum=0x%x, csum=0x%x, "
|
||||||
|
@ -993,7 +993,7 @@ getpkt (char *buf)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!noack_mode)
|
if (!cs.noack_mode)
|
||||||
{
|
{
|
||||||
if (remote_debug)
|
if (remote_debug)
|
||||||
{
|
{
|
||||||
|
@ -1081,6 +1081,7 @@ void
|
||||||
prepare_resume_reply (char *buf, ptid_t ptid,
|
prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
struct target_waitstatus *status)
|
struct target_waitstatus *status)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
if (debug_threads)
|
if (debug_threads)
|
||||||
debug_printf ("Writing resume reply for %s:%d\n",
|
debug_printf ("Writing resume reply for %s:%d\n",
|
||||||
target_pid_to_str (ptid), status->kind);
|
target_pid_to_str (ptid), status->kind);
|
||||||
|
@ -1100,8 +1101,9 @@ prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
const char **regp;
|
const char **regp;
|
||||||
struct regcache *regcache;
|
struct regcache *regcache;
|
||||||
|
|
||||||
if ((status->kind == TARGET_WAITKIND_FORKED && report_fork_events)
|
if ((status->kind == TARGET_WAITKIND_FORKED && cs.report_fork_events)
|
||||||
|| (status->kind == TARGET_WAITKIND_VFORKED && report_vfork_events))
|
|| (status->kind == TARGET_WAITKIND_VFORKED
|
||||||
|
&& cs.report_vfork_events))
|
||||||
{
|
{
|
||||||
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
||||||
const char *event = (status->kind == TARGET_WAITKIND_FORKED
|
const char *event = (status->kind == TARGET_WAITKIND_FORKED
|
||||||
|
@ -1112,13 +1114,14 @@ prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
buf = write_ptid (buf, status->value.related_pid);
|
buf = write_ptid (buf, status->value.related_pid);
|
||||||
strcat (buf, ";");
|
strcat (buf, ";");
|
||||||
}
|
}
|
||||||
else if (status->kind == TARGET_WAITKIND_VFORK_DONE && report_vfork_events)
|
else if (status->kind == TARGET_WAITKIND_VFORK_DONE
|
||||||
|
&& cs.report_vfork_events)
|
||||||
{
|
{
|
||||||
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
||||||
|
|
||||||
sprintf (buf, "T%02xvforkdone:;", signal);
|
sprintf (buf, "T%02xvforkdone:;", signal);
|
||||||
}
|
}
|
||||||
else if (status->kind == TARGET_WAITKIND_EXECD && report_exec_events)
|
else if (status->kind == TARGET_WAITKIND_EXECD && cs.report_exec_events)
|
||||||
{
|
{
|
||||||
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
||||||
const char *event = "exec";
|
const char *event = "exec";
|
||||||
|
@ -1138,7 +1141,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
buf += strlen (buf);
|
buf += strlen (buf);
|
||||||
}
|
}
|
||||||
else if (status->kind == TARGET_WAITKIND_THREAD_CREATED
|
else if (status->kind == TARGET_WAITKIND_THREAD_CREATED
|
||||||
&& report_thread_events)
|
&& cs.report_thread_events)
|
||||||
{
|
{
|
||||||
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
enum gdb_signal signal = GDB_SIGNAL_TRAP;
|
||||||
|
|
||||||
|
@ -1186,12 +1189,12 @@ prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
*buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
|
*buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
|
||||||
*buf++ = ';';
|
*buf++ = ';';
|
||||||
}
|
}
|
||||||
else if (swbreak_feature && target_stopped_by_sw_breakpoint ())
|
else if (cs.swbreak_feature && target_stopped_by_sw_breakpoint ())
|
||||||
{
|
{
|
||||||
sprintf (buf, "swbreak:;");
|
sprintf (buf, "swbreak:;");
|
||||||
buf += strlen (buf);
|
buf += strlen (buf);
|
||||||
}
|
}
|
||||||
else if (hwbreak_feature && target_stopped_by_hw_breakpoint ())
|
else if (cs.hwbreak_feature && target_stopped_by_hw_breakpoint ())
|
||||||
{
|
{
|
||||||
sprintf (buf, "hwbreak:;");
|
sprintf (buf, "hwbreak:;");
|
||||||
buf += strlen (buf);
|
buf += strlen (buf);
|
||||||
|
@ -1219,13 +1222,13 @@ prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
in GDB will claim this event belongs to inferior_ptid
|
in GDB will claim this event belongs to inferior_ptid
|
||||||
if we do not specify a thread, and there's no way for
|
if we do not specify a thread, and there's no way for
|
||||||
gdbserver to know what inferior_ptid is. */
|
gdbserver to know what inferior_ptid is. */
|
||||||
if (1 || !ptid_equal (general_thread, ptid))
|
if (1 || !ptid_equal (cs.general_thread, ptid))
|
||||||
{
|
{
|
||||||
int core = -1;
|
int core = -1;
|
||||||
/* In non-stop, don't change the general thread behind
|
/* In non-stop, don't change the general thread behind
|
||||||
GDB's back. */
|
GDB's back. */
|
||||||
if (!non_stop)
|
if (!non_stop)
|
||||||
general_thread = ptid;
|
cs.general_thread = ptid;
|
||||||
sprintf (buf, "thread:");
|
sprintf (buf, "thread:");
|
||||||
buf += strlen (buf);
|
buf += strlen (buf);
|
||||||
buf = write_ptid (buf, ptid);
|
buf = write_ptid (buf, ptid);
|
||||||
|
@ -1256,14 +1259,14 @@ prepare_resume_reply (char *buf, ptid_t ptid,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TARGET_WAITKIND_EXITED:
|
case TARGET_WAITKIND_EXITED:
|
||||||
if (multi_process)
|
if (cs.multi_process)
|
||||||
sprintf (buf, "W%x;process:%x",
|
sprintf (buf, "W%x;process:%x",
|
||||||
status->value.integer, ptid_get_pid (ptid));
|
status->value.integer, ptid_get_pid (ptid));
|
||||||
else
|
else
|
||||||
sprintf (buf, "W%02x", status->value.integer);
|
sprintf (buf, "W%02x", status->value.integer);
|
||||||
break;
|
break;
|
||||||
case TARGET_WAITKIND_SIGNALLED:
|
case TARGET_WAITKIND_SIGNALLED:
|
||||||
if (multi_process)
|
if (cs.multi_process)
|
||||||
sprintf (buf, "X%x;process:%x",
|
sprintf (buf, "X%x;process:%x",
|
||||||
status->value.sig, ptid_get_pid (ptid));
|
status->value.sig, ptid_get_pid (ptid));
|
||||||
else
|
else
|
||||||
|
@ -1435,6 +1438,7 @@ clear_symbol_cache (struct sym_cache **symcache_p)
|
||||||
int
|
int
|
||||||
look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
|
look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
int len;
|
int len;
|
||||||
struct sym_cache *sym;
|
struct sym_cache *sym;
|
||||||
|
@ -1456,14 +1460,14 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Send the request. */
|
/* Send the request. */
|
||||||
strcpy (own_buf, "qSymbol:");
|
strcpy (cs.own_buf, "qSymbol:");
|
||||||
bin2hex ((const gdb_byte *) name, own_buf + strlen ("qSymbol:"),
|
bin2hex ((const gdb_byte *) name, cs.own_buf + strlen ("qSymbol:"),
|
||||||
strlen (name));
|
strlen (name));
|
||||||
if (putpkt (own_buf) < 0)
|
if (putpkt (cs.own_buf) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
|
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
|
||||||
len = getpkt (own_buf);
|
len = getpkt (cs.own_buf);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -1474,45 +1478,45 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
|
||||||
while it figures out the address of the symbol. */
|
while it figures out the address of the symbol. */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (own_buf[0] == 'm')
|
if (cs.own_buf[0] == 'm')
|
||||||
{
|
{
|
||||||
CORE_ADDR mem_addr;
|
CORE_ADDR mem_addr;
|
||||||
unsigned char *mem_buf;
|
unsigned char *mem_buf;
|
||||||
unsigned int mem_len;
|
unsigned int mem_len;
|
||||||
|
|
||||||
decode_m_packet (&own_buf[1], &mem_addr, &mem_len);
|
decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
|
||||||
mem_buf = (unsigned char *) xmalloc (mem_len);
|
mem_buf = (unsigned char *) xmalloc (mem_len);
|
||||||
if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
|
if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
|
||||||
bin2hex (mem_buf, own_buf, mem_len);
|
bin2hex (mem_buf, cs.own_buf, mem_len);
|
||||||
else
|
else
|
||||||
write_enn (own_buf);
|
write_enn (cs.own_buf);
|
||||||
free (mem_buf);
|
free (mem_buf);
|
||||||
if (putpkt (own_buf) < 0)
|
if (putpkt (cs.own_buf) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (own_buf[0] == 'v')
|
else if (cs.own_buf[0] == 'v')
|
||||||
{
|
{
|
||||||
int new_len = -1;
|
int new_len = -1;
|
||||||
handle_v_requests (own_buf, len, &new_len);
|
handle_v_requests (cs.own_buf, len, &new_len);
|
||||||
if (new_len != -1)
|
if (new_len != -1)
|
||||||
putpkt_binary (own_buf, new_len);
|
putpkt_binary (cs.own_buf, new_len);
|
||||||
else
|
else
|
||||||
putpkt (own_buf);
|
putpkt (cs.own_buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
len = getpkt (own_buf);
|
len = getpkt (cs.own_buf);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!startswith (own_buf, "qSymbol:"))
|
if (!startswith (cs.own_buf, "qSymbol:"))
|
||||||
{
|
{
|
||||||
warning ("Malformed response to qSymbol, ignoring: %s\n", own_buf);
|
warning ("Malformed response to qSymbol, ignoring: %s\n", cs.own_buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = own_buf + strlen ("qSymbol:");
|
p = cs.own_buf + strlen ("qSymbol:");
|
||||||
q = p;
|
q = p;
|
||||||
while (*q && *q != ':')
|
while (*q && *q != ':')
|
||||||
q++;
|
q++;
|
||||||
|
@ -1548,17 +1552,18 @@ look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
|
||||||
int
|
int
|
||||||
relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
|
relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int len;
|
int len;
|
||||||
ULONGEST written = 0;
|
ULONGEST written = 0;
|
||||||
|
|
||||||
/* Send the request. */
|
/* Send the request. */
|
||||||
sprintf (own_buf, "qRelocInsn:%s;%s", paddress (oldloc),
|
sprintf (cs.own_buf, "qRelocInsn:%s;%s", paddress (oldloc),
|
||||||
paddress (*to));
|
paddress (*to));
|
||||||
if (putpkt (own_buf) < 0)
|
if (putpkt (cs.own_buf) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
|
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
|
||||||
len = getpkt (own_buf);
|
len = getpkt (cs.own_buf);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -1566,61 +1571,61 @@ relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
|
||||||
wait for the qRelocInsn "response". That requires re-entering
|
wait for the qRelocInsn "response". That requires re-entering
|
||||||
the main loop. For now, this is an adequate approximation; allow
|
the main loop. For now, this is an adequate approximation; allow
|
||||||
GDB to access memory. */
|
GDB to access memory. */
|
||||||
while (own_buf[0] == 'm' || own_buf[0] == 'M' || own_buf[0] == 'X')
|
while (cs.own_buf[0] == 'm' || cs.own_buf[0] == 'M' || cs.own_buf[0] == 'X')
|
||||||
{
|
{
|
||||||
CORE_ADDR mem_addr;
|
CORE_ADDR mem_addr;
|
||||||
unsigned char *mem_buf = NULL;
|
unsigned char *mem_buf = NULL;
|
||||||
unsigned int mem_len;
|
unsigned int mem_len;
|
||||||
|
|
||||||
if (own_buf[0] == 'm')
|
if (cs.own_buf[0] == 'm')
|
||||||
{
|
{
|
||||||
decode_m_packet (&own_buf[1], &mem_addr, &mem_len);
|
decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
|
||||||
mem_buf = (unsigned char *) xmalloc (mem_len);
|
mem_buf = (unsigned char *) xmalloc (mem_len);
|
||||||
if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
|
if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
|
||||||
bin2hex (mem_buf, own_buf, mem_len);
|
bin2hex (mem_buf, cs.own_buf, mem_len);
|
||||||
else
|
else
|
||||||
write_enn (own_buf);
|
write_enn (cs.own_buf);
|
||||||
}
|
}
|
||||||
else if (own_buf[0] == 'X')
|
else if (cs.own_buf[0] == 'X')
|
||||||
{
|
{
|
||||||
if (decode_X_packet (&own_buf[1], len - 1, &mem_addr,
|
if (decode_X_packet (&cs.own_buf[1], len - 1, &mem_addr,
|
||||||
&mem_len, &mem_buf) < 0
|
&mem_len, &mem_buf) < 0
|
||||||
|| write_inferior_memory (mem_addr, mem_buf, mem_len) != 0)
|
|| write_inferior_memory (mem_addr, mem_buf, mem_len) != 0)
|
||||||
write_enn (own_buf);
|
write_enn (cs.own_buf);
|
||||||
else
|
else
|
||||||
write_ok (own_buf);
|
write_ok (cs.own_buf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decode_M_packet (&own_buf[1], &mem_addr, &mem_len, &mem_buf);
|
decode_M_packet (&cs.own_buf[1], &mem_addr, &mem_len, &mem_buf);
|
||||||
if (write_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
|
if (write_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
|
||||||
write_ok (own_buf);
|
write_ok (cs.own_buf);
|
||||||
else
|
else
|
||||||
write_enn (own_buf);
|
write_enn (cs.own_buf);
|
||||||
}
|
}
|
||||||
free (mem_buf);
|
free (mem_buf);
|
||||||
if (putpkt (own_buf) < 0)
|
if (putpkt (cs.own_buf) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
len = getpkt (own_buf);
|
len = getpkt (cs.own_buf);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (own_buf[0] == 'E')
|
if (cs.own_buf[0] == 'E')
|
||||||
{
|
{
|
||||||
warning ("An error occurred while relocating an instruction: %s\n",
|
warning ("An error occurred while relocating an instruction: %s\n",
|
||||||
own_buf);
|
cs.own_buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!startswith (own_buf, "qRelocInsn:"))
|
if (!startswith (cs.own_buf, "qRelocInsn:"))
|
||||||
{
|
{
|
||||||
warning ("Malformed response to qRelocInsn, ignoring: %s\n",
|
warning ("Malformed response to qRelocInsn, ignoring: %s\n",
|
||||||
own_buf);
|
cs.own_buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unpack_varlen_hex (own_buf + strlen ("qRelocInsn:"), &written);
|
unpack_varlen_hex (cs.own_buf + strlen ("qRelocInsn:"), &written);
|
||||||
|
|
||||||
*to += written;
|
*to += written;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
#define REMOTE_UTILS_H
|
#define REMOTE_UTILS_H
|
||||||
|
|
||||||
extern int remote_debug;
|
extern int remote_debug;
|
||||||
extern int noack_mode;
|
|
||||||
extern int transport_is_reliable;
|
|
||||||
|
|
||||||
int gdb_connected (void);
|
int gdb_connected (void);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -60,8 +60,6 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap);
|
||||||
#include "gdb_signals.h"
|
#include "gdb_signals.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
#include "mem-break.h"
|
#include "mem-break.h"
|
||||||
#include "gdbthread.h"
|
|
||||||
#include "inferiors.h"
|
|
||||||
#include "environ.h"
|
#include "environ.h"
|
||||||
|
|
||||||
/* Target-specific functions */
|
/* Target-specific functions */
|
||||||
|
@ -70,42 +68,16 @@ void initialize_low ();
|
||||||
|
|
||||||
/* Public variables in server.c */
|
/* Public variables in server.c */
|
||||||
|
|
||||||
extern ptid_t cont_thread;
|
|
||||||
extern ptid_t general_thread;
|
|
||||||
|
|
||||||
extern int server_waiting;
|
extern int server_waiting;
|
||||||
extern int pass_signals[];
|
|
||||||
extern int program_signals[];
|
|
||||||
extern int program_signals_p;
|
|
||||||
|
|
||||||
extern int disable_packet_vCont;
|
extern int disable_packet_vCont;
|
||||||
extern int disable_packet_Tthread;
|
extern int disable_packet_Tthread;
|
||||||
extern int disable_packet_qC;
|
extern int disable_packet_qC;
|
||||||
extern int disable_packet_qfThreadInfo;
|
extern int disable_packet_qfThreadInfo;
|
||||||
|
|
||||||
extern char *own_buf;
|
|
||||||
|
|
||||||
extern int run_once;
|
extern int run_once;
|
||||||
extern int multi_process;
|
|
||||||
extern int report_fork_events;
|
|
||||||
extern int report_vfork_events;
|
|
||||||
extern int report_exec_events;
|
|
||||||
extern int report_thread_events;
|
|
||||||
extern int non_stop;
|
extern int non_stop;
|
||||||
|
|
||||||
/* True if the "swbreak+" feature is active. In that case, GDB wants
|
|
||||||
us to report whether a trap is explained by a software breakpoint
|
|
||||||
and for the server to handle PC adjustment if necessary on this
|
|
||||||
target. Only enabled if the target supports it. */
|
|
||||||
extern int swbreak_feature;
|
|
||||||
|
|
||||||
/* True if the "hwbreak+" feature is active. In that case, GDB wants
|
|
||||||
us to report whether a trap is explained by a hardware breakpoint.
|
|
||||||
Only enabled if the target supports it. */
|
|
||||||
extern int hwbreak_feature;
|
|
||||||
|
|
||||||
extern int disable_randomization;
|
|
||||||
|
|
||||||
#if USE_WIN32API
|
#if USE_WIN32API
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
typedef SOCKET gdb_fildes_t;
|
typedef SOCKET gdb_fildes_t;
|
||||||
|
@ -158,8 +130,79 @@ extern void post_fork_inferior (int pid, const char *program);
|
||||||
/* Get the gdb_environ being used in the current session. */
|
/* Get the gdb_environ being used in the current session. */
|
||||||
extern gdb_environ *get_environ ();
|
extern gdb_environ *get_environ ();
|
||||||
|
|
||||||
extern target_waitstatus last_status;
|
|
||||||
extern ptid_t last_ptid;
|
|
||||||
extern unsigned long signal_pid;
|
extern unsigned long signal_pid;
|
||||||
|
|
||||||
|
|
||||||
|
/* Description of the client remote protocol state for the currently
|
||||||
|
connected client. */
|
||||||
|
|
||||||
|
struct client_state
|
||||||
|
{
|
||||||
|
client_state ():
|
||||||
|
own_buf ((char *) xmalloc (PBUFSIZ + 1))
|
||||||
|
{}
|
||||||
|
|
||||||
|
/* The thread set with an `Hc' packet. `Hc' is deprecated in favor of
|
||||||
|
`vCont'. Note the multi-process extensions made `vCont' a
|
||||||
|
requirement, so `Hc pPID.TID' is pretty much undefined. So
|
||||||
|
CONT_THREAD can be null_ptid for no `Hc' thread, minus_one_ptid for
|
||||||
|
resuming all threads of the process (again, `Hc' isn't used for
|
||||||
|
multi-process), or a specific thread ptid_t. */
|
||||||
|
ptid_t cont_thread;
|
||||||
|
|
||||||
|
/* The thread set with an `Hg' packet. */
|
||||||
|
ptid_t general_thread;
|
||||||
|
|
||||||
|
int multi_process = 0;
|
||||||
|
int report_fork_events = 0;
|
||||||
|
int report_vfork_events = 0;
|
||||||
|
int report_exec_events = 0;
|
||||||
|
int report_thread_events = 0;
|
||||||
|
|
||||||
|
/* True if the "swbreak+" feature is active. In that case, GDB wants
|
||||||
|
us to report whether a trap is explained by a software breakpoint
|
||||||
|
and for the server to handle PC adjustment if necessary on this
|
||||||
|
target. Only enabled if the target supports it. */
|
||||||
|
int swbreak_feature = 0;
|
||||||
|
/* True if the "hwbreak+" feature is active. In that case, GDB wants
|
||||||
|
us to report whether a trap is explained by a hardware breakpoint.
|
||||||
|
Only enabled if the target supports it. */
|
||||||
|
int hwbreak_feature = 0;
|
||||||
|
|
||||||
|
/* True if the "vContSupported" feature is active. In that case, GDB
|
||||||
|
wants us to report whether single step is supported in the reply to
|
||||||
|
"vCont?" packet. */
|
||||||
|
int vCont_supported = 0;
|
||||||
|
|
||||||
|
/* Whether we should attempt to disable the operating system's address
|
||||||
|
space randomization feature before starting an inferior. */
|
||||||
|
int disable_randomization = 0;
|
||||||
|
|
||||||
|
int pass_signals[GDB_SIGNAL_LAST];
|
||||||
|
int program_signals[GDB_SIGNAL_LAST];
|
||||||
|
int program_signals_p = 0;
|
||||||
|
|
||||||
|
/* Last status reported to GDB. */
|
||||||
|
struct target_waitstatus last_status;
|
||||||
|
ptid_t last_ptid;
|
||||||
|
|
||||||
|
char *own_buf;
|
||||||
|
|
||||||
|
/* If true, then GDB has requested noack mode. */
|
||||||
|
int noack_mode = 0;
|
||||||
|
/* If true, then we tell GDB to use noack mode by default. */
|
||||||
|
int transport_is_reliable = 0;
|
||||||
|
|
||||||
|
/* The traceframe to be used as the source of data to send back to
|
||||||
|
GDB. A value of -1 means to get data from the live program. */
|
||||||
|
|
||||||
|
int current_traceframe = -1;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
client_state &get_client_state ();
|
||||||
|
|
||||||
|
#include "gdbthread.h"
|
||||||
|
#include "inferiors.h"
|
||||||
|
|
||||||
#endif /* SERVER_H */
|
#endif /* SERVER_H */
|
||||||
|
|
|
@ -26,7 +26,8 @@ struct target_ops *the_target;
|
||||||
int
|
int
|
||||||
set_desired_thread ()
|
set_desired_thread ()
|
||||||
{
|
{
|
||||||
thread_info *found = find_thread_ptid (general_thread);
|
client_state &cs = get_client_state ();
|
||||||
|
thread_info *found = find_thread_ptid (cs.general_thread);
|
||||||
|
|
||||||
current_thread = found;
|
current_thread = found;
|
||||||
return (current_thread != NULL);
|
return (current_thread != NULL);
|
||||||
|
@ -42,6 +43,8 @@ static ptid_t prev_general_thread;
|
||||||
int
|
int
|
||||||
prepare_to_access_memory (void)
|
prepare_to_access_memory (void)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
|
|
||||||
/* The first thread found. */
|
/* The first thread found. */
|
||||||
struct thread_info *first = NULL;
|
struct thread_info *first = NULL;
|
||||||
/* The first stopped thread found. */
|
/* The first stopped thread found. */
|
||||||
|
@ -51,7 +54,7 @@ prepare_to_access_memory (void)
|
||||||
|
|
||||||
/* Save the general thread value, since prepare_to_access_memory could change
|
/* Save the general thread value, since prepare_to_access_memory could change
|
||||||
it. */
|
it. */
|
||||||
prev_general_thread = general_thread;
|
prev_general_thread = cs.general_thread;
|
||||||
|
|
||||||
if (the_target->prepare_to_access_memory != NULL)
|
if (the_target->prepare_to_access_memory != NULL)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +101,7 @@ prepare_to_access_memory (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
current_thread = thread;
|
current_thread = thread;
|
||||||
general_thread = ptid_of (thread);
|
cs.general_thread = ptid_of (thread);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -108,12 +111,14 @@ prepare_to_access_memory (void)
|
||||||
void
|
void
|
||||||
done_accessing_memory (void)
|
done_accessing_memory (void)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
|
|
||||||
if (the_target->done_accessing_memory != NULL)
|
if (the_target->done_accessing_memory != NULL)
|
||||||
the_target->done_accessing_memory ();
|
the_target->done_accessing_memory ();
|
||||||
|
|
||||||
/* Restore the previous selected thread. */
|
/* Restore the previous selected thread. */
|
||||||
general_thread = prev_general_thread;
|
cs.general_thread = prev_general_thread;
|
||||||
switch_to_thread (general_thread);
|
switch_to_thread (cs.general_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -973,11 +973,6 @@ struct traceframe
|
||||||
fields (and no data) marks the end of trace data. */
|
fields (and no data) marks the end of trace data. */
|
||||||
#define TRACEFRAME_EOB_MARKER_SIZE offsetof (struct traceframe, data)
|
#define TRACEFRAME_EOB_MARKER_SIZE offsetof (struct traceframe, data)
|
||||||
|
|
||||||
/* The traceframe to be used as the source of data to send back to
|
|
||||||
GDB. A value of -1 means to get data from the live program. */
|
|
||||||
|
|
||||||
int current_traceframe = -1;
|
|
||||||
|
|
||||||
/* This flag is true if the trace buffer is circular, meaning that
|
/* This flag is true if the trace buffer is circular, meaning that
|
||||||
when it fills, the oldest trace frames are discarded in order to
|
when it fills, the oldest trace frames are discarded in order to
|
||||||
make room. */
|
make room. */
|
||||||
|
@ -2279,10 +2274,11 @@ static struct traceframe *
|
||||||
find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
|
find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
|
||||||
int *tfnump)
|
int *tfnump)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct traceframe *tframe;
|
struct traceframe *tframe;
|
||||||
CORE_ADDR tfaddr;
|
CORE_ADDR tfaddr;
|
||||||
|
|
||||||
*tfnump = current_traceframe + 1;
|
*tfnump = cs.current_traceframe + 1;
|
||||||
tframe = find_traceframe (*tfnump);
|
tframe = find_traceframe (*tfnump);
|
||||||
/* The search is not supposed to wrap around. */
|
/* The search is not supposed to wrap around. */
|
||||||
if (!tframe)
|
if (!tframe)
|
||||||
|
@ -2312,9 +2308,10 @@ find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
|
||||||
static struct traceframe *
|
static struct traceframe *
|
||||||
find_next_traceframe_by_tracepoint (int num, int *tfnump)
|
find_next_traceframe_by_tracepoint (int num, int *tfnump)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct traceframe *tframe;
|
struct traceframe *tframe;
|
||||||
|
|
||||||
*tfnump = current_traceframe + 1;
|
*tfnump = cs.current_traceframe + 1;
|
||||||
tframe = find_traceframe (*tfnump);
|
tframe = find_traceframe (*tfnump);
|
||||||
/* The search is not supposed to wrap around. */
|
/* The search is not supposed to wrap around. */
|
||||||
if (!tframe)
|
if (!tframe)
|
||||||
|
@ -2343,6 +2340,7 @@ find_next_traceframe_by_tracepoint (int num, int *tfnump)
|
||||||
static void
|
static void
|
||||||
cmd_qtinit (char *packet)
|
cmd_qtinit (char *packet)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
struct trace_state_variable *tsv, *prev, *next;
|
struct trace_state_variable *tsv, *prev, *next;
|
||||||
|
|
||||||
/* Can't do this command without a pid attached. */
|
/* Can't do this command without a pid attached. */
|
||||||
|
@ -2353,7 +2351,7 @@ cmd_qtinit (char *packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we don't try to read from a trace frame. */
|
/* Make sure we don't try to read from a trace frame. */
|
||||||
current_traceframe = -1;
|
cs.current_traceframe = -1;
|
||||||
|
|
||||||
stop_tracing ();
|
stop_tracing ();
|
||||||
|
|
||||||
|
@ -2813,6 +2811,7 @@ cmd_qtenable_disable (char *own_buf, int enable)
|
||||||
static void
|
static void
|
||||||
cmd_qtv (char *own_buf)
|
cmd_qtv (char *own_buf)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
ULONGEST num;
|
ULONGEST num;
|
||||||
LONGEST val = 0;
|
LONGEST val = 0;
|
||||||
int err;
|
int err;
|
||||||
|
@ -2821,7 +2820,7 @@ cmd_qtv (char *own_buf)
|
||||||
packet += strlen ("qTV:");
|
packet += strlen ("qTV:");
|
||||||
unpack_varlen_hex (packet, &num);
|
unpack_varlen_hex (packet, &num);
|
||||||
|
|
||||||
if (current_traceframe >= 0)
|
if (cs.current_traceframe >= 0)
|
||||||
{
|
{
|
||||||
err = traceframe_read_tsv ((int) num, &val);
|
err = traceframe_read_tsv ((int) num, &val);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -3552,6 +3551,7 @@ cmd_qtdisconnected (char *own_buf)
|
||||||
static void
|
static void
|
||||||
cmd_qtframe (char *own_buf)
|
cmd_qtframe (char *own_buf)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
ULONGEST frame, pc, lo, hi, num;
|
ULONGEST frame, pc, lo, hi, num;
|
||||||
int tfnum, tpnum;
|
int tfnum, tpnum;
|
||||||
struct traceframe *tframe;
|
struct traceframe *tframe;
|
||||||
|
@ -3602,7 +3602,7 @@ cmd_qtframe (char *own_buf)
|
||||||
if (tfnum == -1)
|
if (tfnum == -1)
|
||||||
{
|
{
|
||||||
trace_debug ("Want to stop looking at traceframes");
|
trace_debug ("Want to stop looking at traceframes");
|
||||||
current_traceframe = -1;
|
cs.current_traceframe = -1;
|
||||||
write_ok (own_buf);
|
write_ok (own_buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3612,7 +3612,7 @@ cmd_qtframe (char *own_buf)
|
||||||
|
|
||||||
if (tframe)
|
if (tframe)
|
||||||
{
|
{
|
||||||
current_traceframe = tfnum;
|
cs.current_traceframe = tfnum;
|
||||||
sprintf (own_buf, "F%xT%x", tfnum, tframe->tpnum);
|
sprintf (own_buf, "F%xT%x", tfnum, tframe->tpnum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -5297,6 +5297,7 @@ traceframe_read_mem (int tfnum, CORE_ADDR addr,
|
||||||
static int
|
static int
|
||||||
traceframe_read_tsv (int tsvnum, LONGEST *val)
|
traceframe_read_tsv (int tsvnum, LONGEST *val)
|
||||||
{
|
{
|
||||||
|
client_state &cs = get_client_state ();
|
||||||
int tfnum;
|
int tfnum;
|
||||||
struct traceframe *tframe;
|
struct traceframe *tframe;
|
||||||
unsigned char *database, *dataptr;
|
unsigned char *database, *dataptr;
|
||||||
|
@ -5306,7 +5307,7 @@ traceframe_read_tsv (int tsvnum, LONGEST *val)
|
||||||
|
|
||||||
trace_debug ("traceframe_read_tsv");
|
trace_debug ("traceframe_read_tsv");
|
||||||
|
|
||||||
tfnum = current_traceframe;
|
tfnum = cs.current_traceframe;
|
||||||
|
|
||||||
if (tfnum < 0)
|
if (tfnum < 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue