/* Tracepoint code for remote server for GDB.
- Copyright (C) 2009-2017 Free Software Foundation, Inc.
+ Copyright (C) 2009-2019 Free Software Foundation, Inc.
This file is part of GDB.
#include "server.h"
#include "tracepoint.h"
#include "gdbthread.h"
-#include "agent.h"
#include "rsp-low.h"
#include <ctype.h>
#include "ax.h"
#include "tdesc.h"
+#define IPA_SYM_STRUCT_NAME ipa_sym_addresses
+#include "agent.h"
+
#define DEFAULT_TRACE_BUFFER_SIZE 5242880 /* 5*1024*1024 */
/* This file is built for both GDBserver, and the in-process
fields (and no data) marks the end of trace 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
when it fills, the oldest trace frames are discarded in order to
make room. */
/* Append another action to perform when the tracepoint triggers. */
static void
-add_tracepoint_action (struct tracepoint *tpoint, char *packet)
+add_tracepoint_action (struct tracepoint *tpoint, const char *packet)
{
- char *act;
+ const char *act;
if (*packet == 'S')
{
while (*act)
{
- char *act_start = act;
+ const char *act_start = act;
struct tracepoint_action *action = NULL;
switch (*act)
find_next_traceframe_in_range (CORE_ADDR lo, CORE_ADDR hi, int inside_p,
int *tfnump)
{
+ client_state &cs = get_client_state ();
struct traceframe *tframe;
CORE_ADDR tfaddr;
- *tfnump = current_traceframe + 1;
+ *tfnump = cs.current_traceframe + 1;
tframe = find_traceframe (*tfnump);
/* The search is not supposed to wrap around. */
if (!tframe)
static struct traceframe *
find_next_traceframe_by_tracepoint (int num, int *tfnump)
{
+ client_state &cs = get_client_state ();
struct traceframe *tframe;
- *tfnump = current_traceframe + 1;
+ *tfnump = cs.current_traceframe + 1;
tframe = find_traceframe (*tfnump);
/* The search is not supposed to wrap around. */
if (!tframe)
static void
cmd_qtinit (char *packet)
{
+ client_state &cs = get_client_state ();
struct trace_state_variable *tsv, *prev, *next;
/* Can't do this command without a pid attached. */
}
/* Make sure we don't try to read from a trace frame. */
- current_traceframe = -1;
+ cs.current_traceframe = -1;
stop_tracing ();
ULONGEST addr;
ULONGEST count;
struct tracepoint *tpoint;
- char *actparm;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("QTDP:");
}
else if (*packet == 'X')
{
- actparm = (char *) packet;
- tpoint->cond = gdb_parse_agent_expr (&actparm);
- packet = actparm;
+ tpoint->cond = gdb_parse_agent_expr (&packet);
}
else if (*packet == '-')
break;
{
ULONGEST num, addr, start, slen;
struct tracepoint *tpoint;
- char *packet = own_buf;
- char *saved, *srctype, *src;
+ const char *packet = own_buf;
+ const char *saved;
+ char *srctype, *src;
size_t nbytes;
struct source_string *last, *newlast;
char *varname;
size_t nbytes;
struct trace_state_variable *tsv;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("QTDV:");
static void
cmd_qtenable_disable (char *own_buf, int enable)
{
- char *packet = own_buf;
+ const char *packet = own_buf;
ULONGEST num, addr;
struct tracepoint *tp;
static void
cmd_qtv (char *own_buf)
{
+ client_state &cs = get_client_state ();
ULONGEST num;
LONGEST val = 0;
int err;
packet += strlen ("qTV:");
unpack_varlen_hex (packet, &num);
- if (current_traceframe >= 0)
+ if (cs.current_traceframe >= 0)
{
err = traceframe_read_tsv ((int) num, &val);
if (err)
{
ULONGEST start, end;
struct readonly_region *roreg;
- char *packet = own_buf;
+ const char *packet = own_buf;
trace_debug ("Want to mark readonly regions");
static void
cmd_qtframe (char *own_buf)
{
+ client_state &cs = get_client_state ();
ULONGEST frame, pc, lo, hi, num;
int tfnum, tpnum;
struct traceframe *tframe;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("QTFrame:");
if (tfnum == -1)
{
trace_debug ("Want to stop looking at traceframes");
- current_traceframe = -1;
+ cs.current_traceframe = -1;
write_ok (own_buf);
return;
}
if (tframe)
{
- current_traceframe = tfnum;
+ cs.current_traceframe = tfnum;
sprintf (own_buf, "F%xT%x", tfnum, tframe->tpnum);
}
else
{
ULONGEST num, addr;
struct tracepoint *tpoint;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("qTP:");
run_inferior_command (packet, strlen (packet) + 1);
}
-/* Helper for gdb_agent_about_to_close.
- Return non-zero if thread ENTRY is in the same process in DATA. */
-
-static int
-same_process_p (struct inferior_list_entry *entry, void *data)
-{
- int *pid = (int *) data;
-
- return ptid_get_pid (entry->id) == *pid;
-}
-
/* Sent the agent a command to close it. */
void
saved_thread = current_thread;
/* Find any thread which belongs to process PID. */
- current_thread = (struct thread_info *)
- find_inferior (&all_threads, same_process_p, &pid);
+ current_thread = find_any_thread_of_pid (pid);
strcpy (buf, "close");
{
ULONGEST offset, num, tot;
unsigned char *tbp;
- char *packet = own_buf;
+ const char *packet = own_buf;
packet += strlen ("qTBuffer:");
wstep_link = &tinfo->while_stepping;
trace_debug ("Thread %s finished a single-step for tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->entry.id),
+ target_pid_to_str (tinfo->id),
wstep->tp_number, paddress (wstep->tp_address));
ctx.base.type = trap_tracepoint;
{
trace_debug ("NO TRACEPOINT %d at 0x%s FOR THREAD %s!",
wstep->tp_number, paddress (wstep->tp_address),
- target_pid_to_str (tinfo->entry.id));
+ target_pid_to_str (tinfo->id));
/* Unlink. */
*wstep_link = wstep->next;
{
/* The requested numbers of steps have occurred. */
trace_debug ("Thread %s done stepping for tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->entry.id),
+ target_pid_to_str (tinfo->id),
wstep->tp_number, paddress (wstep->tp_address));
/* Unlink the wstep. */
&& tpoint->type != static_tracepoint)
{
trace_debug ("Thread %s at address of tracepoint %d at 0x%s",
- target_pid_to_str (tinfo->entry.id),
+ target_pid_to_str (tinfo->id),
tpoint->number, paddress (tpoint->address));
/* Test the condition if present, and collect if true. */
static int
traceframe_read_tsv (int tsvnum, LONGEST *val)
{
+ client_state &cs = get_client_state ();
int tfnum;
struct traceframe *tframe;
unsigned char *database, *dataptr;
trace_debug ("traceframe_read_tsv");
- tfnum = current_traceframe;
+ tfnum = cs.current_traceframe;
if (tfnum < 0)
{
run_inferior_command (char *cmd, int len)
{
int err = -1;
- int pid = ptid_get_pid (current_ptid);
+ int pid = current_ptid.pid ();
trace_debug ("run_inferior_command: running: %s", cmd);
}
#include <sys/mman.h>
-#include <fcntl.h>
IP_AGENT_EXPORT_VAR char *gdb_tp_heap_buffer;
IP_AGENT_EXPORT_VAR char *gdb_jump_pad_buffer;