/* Tracing functionality for remote targets in custom GDB protocol
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
- 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbthread.h"
#include "stack.h"
#include "gdbcore.h"
-
+#include "remote.h"
+#include "source.h"
#include "ax.h"
#include "ax-gdb.h"
/* Tracepoint for last traceframe collected. */
static int tracepoint_number;
-/* Symbol for function for last traceframe collected */
+/* Symbol for function for last traceframe collected. */
static struct symbol *traceframe_fun;
-/* Symtab and line for last traceframe collected */
+/* Symtab and line for last traceframe collected. */
static struct symtab_and_line traceframe_sal;
-/* Tracing command lists */
+/* Tracing command lists. */
static struct cmd_list_element *tfindlist;
/* List of expressions to collect by default at each tracepoint hit. */
}
/* Set externally visible debug variables for querying/printing
- the traceframe context (line, function, file) */
+ the traceframe context (line, function, file). */
static void
set_traceframe_context (struct frame_info *trace_frame)
{
CORE_ADDR trace_pc;
- if (trace_frame == NULL) /* Cease debugging any trace buffers. */
+ if (trace_frame == NULL) /* Cease debugging any trace buffers. */
{
traceframe_fun = 0;
traceframe_sal.pc = traceframe_sal.line = 0;
if (tsv)
{
tsv->initial_value = initval;
- printf_filtered (_("Trace state variable $%s now has initial value %s.\n"),
+ printf_filtered (_("Trace state variable $%s "
+ "now has initial value %s.\n"),
tsv->name, plongest (tsv->initial_value));
+ do_cleanups (old_chain);
return;
}
tsv = create_trace_state_variable (internalvar_name (intvar));
tsv->initial_value = initval;
- printf_filtered (_("Trace state variable $%s created, with initial value %s.\n"),
+ printf_filtered (_("Trace state variable $%s "
+ "created, with initial value %s.\n"),
tsv->name, plongest (tsv->initial_value));
do_cleanups (old_chain);
void
delete_trace_variable_command (char *args, int from_tty)
{
- int i, ix;
+ int ix;
char **argv;
struct cleanup *back_to;
- struct trace_state_variable *tsv;
if (args == NULL)
{
argv = gdb_buildargv (args);
back_to = make_cleanup_freeargv (argv);
- for (i = 0; argv[i] != NULL; i++)
+ for (ix = 0; argv[ix] != NULL; ix++)
{
- if (*argv[i] == '$')
- delete_trace_state_variable (argv[i] + 1);
+ if (*argv[ix] == '$')
+ delete_trace_state_variable (argv[ix] + 1);
else
- warning (_("Name \"%s\" not prefixed with '$', ignoring"), argv[i]);
+ warning (_("Name \"%s\" not prefixed with '$', ignoring"), argv[ix]);
}
do_cleanups (back_to);
back_to2 = make_cleanup_ui_out_tuple_begin_end (uiout, "variable");
- name = concat ("$", tsv->name, NULL);
+ name = concat ("$", tsv->name, (char *) NULL);
make_cleanup (xfree, name);
ui_out_field_string (uiout, "name", name);
ui_out_field_string (uiout, "initial", plongest (tsv->initial_value));
t->number);
struct cleanup *cleanups = make_cleanup (xfree, tmpbuf);
- l = read_command_lines (tmpbuf, from_tty, 1, check_tracepoint_command, t);
+ l = read_command_lines (tmpbuf, from_tty, 1,
+ check_tracepoint_command, t);
do_cleanups (cleanups);
breakpoint_set_commands (t, l);
}
internal errors. */
static void
-report_agent_reqs_errors (struct agent_expr *aexpr, struct agent_reqs *areqs)
+report_agent_reqs_errors (struct agent_expr *aexpr)
{
/* All of the "flaws" are serious bytecode generation issues that
should never occur. */
- if (areqs->flaw != agent_flaw_none)
+ if (aexpr->flaw != agent_flaw_none)
internal_error (__FILE__, __LINE__, _("expression is malformed"));
/* If analysis shows a stack underflow, GDB must have done something
badly wrong in its bytecode generation. */
- if (areqs->min_height < 0)
+ if (aexpr->min_height < 0)
internal_error (__FILE__, __LINE__,
_("expression has min height < 0"));
depth roughly corresponds to parenthesization, so a limit of 20
amounts to 20 levels of expression nesting, which is actually
a pretty big hairy expression. */
- if (areqs->max_height > 20)
+ if (aexpr->max_height > 20)
error (_("Expression is too complicated."));
}
char *p, *tmp_p;
struct bp_location *loc;
struct agent_expr *aexpr;
- struct agent_reqs areqs;
- /* if EOF is typed, *line is NULL */
+ /* If EOF is typed, *line is NULL. */
if (*line == NULL)
return;
if (cmd_cfunc_eq (c, collect_pseudocommand))
{
do
- { /* repeat over a comma-separated list */
- QUIT; /* allow user to bail out with ^C */
+ { /* Repeat over a comma-separated list. */
+ QUIT; /* Allow user to bail out with ^C. */
while (isspace ((int) *p))
p++;
- if (*p == '$') /* look for special pseudo-symbols */
+ if (*p == '$') /* Look for special pseudo-symbols. */
{
- if ((0 == strncasecmp ("reg", p + 1, 3)) ||
- (0 == strncasecmp ("arg", p + 1, 3)) ||
- (0 == strncasecmp ("loc", p + 1, 3)))
+ if (0 == strncasecmp ("reg", p + 1, 3)
+ || 0 == strncasecmp ("arg", p + 1, 3)
+ || 0 == strncasecmp ("loc", p + 1, 3)
+ || 0 == strncasecmp ("_sdata", p + 1, 6))
{
p = strchr (p, ',');
continue;
{
if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_CONST)
{
- error (_("constant `%s' (value %ld) will not be collected."),
+ error (_("constant `%s' (value %ld) "
+ "will not be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol),
SYMBOL_VALUE (exp->elts[2].symbol));
}
- else if (SYMBOL_CLASS (exp->elts[2].symbol) == LOC_OPTIMIZED_OUT)
+ else if (SYMBOL_CLASS (exp->elts[2].symbol)
+ == LOC_OPTIMIZED_OUT)
{
- error (_("`%s' is optimized away and cannot be collected."),
+ error (_("`%s' is optimized away "
+ "and cannot be collected."),
SYMBOL_PRINT_NAME (exp->elts[2].symbol));
}
}
if (aexpr->len > MAX_AGENT_EXPR_LEN)
error (_("Expression is too complicated."));
- ax_reqs (aexpr, &areqs);
- (void) make_cleanup (xfree, areqs.reg_mask);
+ ax_reqs (aexpr);
- report_agent_reqs_errors (aexpr, &areqs);
+ report_agent_reqs_errors (aexpr);
do_cleanups (old_chain);
}
else if (cmd_cfunc_eq (c, teval_pseudocommand))
{
do
- { /* repeat over a comma-separated list */
- QUIT; /* allow user to bail out with ^C */
+ { /* Repeat over a comma-separated list. */
+ QUIT; /* Allow user to bail out with ^C. */
while (isspace ((int) *p))
p++;
if (aexpr->len > MAX_AGENT_EXPR_LEN)
error (_("Expression is too complicated."));
- ax_reqs (aexpr, &areqs);
- (void) make_cleanup (xfree, areqs.reg_mask);
-
- report_agent_reqs_errors (aexpr, &areqs);
+ ax_reqs (aexpr);
+ report_agent_reqs_errors (aexpr);
do_cleanups (old_chain);
}
else if (cmd_cfunc_eq (c, while_stepping_pseudocommand))
{
- char *steparg; /* in case warning is necessary */
+ char *steparg; /* In case warning is necessary. */
while (isspace ((int) *p))
p++;
struct memrange
{
int type; /* memrange_absolute for absolute memory range,
- else basereg number */
+ else basereg number. */
bfd_signed_vma start;
bfd_signed_vma end;
};
long next_aexpr_elt;
struct agent_expr **aexpr_list;
+ /* True is the user requested a collection of "$_sdata", "static
+ tracepoint data". */
+ int strace_data;
}
tracepoint_list, stepping_list;
static int memrange_cmp (const void *, const void *);
-/* compare memranges for qsort */
+/* Compare memranges for qsort. */
static int
memrange_cmp (const void *va, const void *vb)
{
collection->regs_mask[regno / 8] |= 1 << (regno % 8);
}
-/* Add a memrange to a collection list */
+/* Add a memrange to a collection list. */
static void
add_memrange (struct collection_list *memranges,
int type, bfd_signed_vma base,
memranges->listsize);
}
- if (type != memrange_absolute) /* Better collect the base register! */
+ if (type != memrange_absolute) /* Better collect the base register! */
add_register (memranges, type);
}
{
struct agent_expr *aexpr;
struct cleanup *old_chain1 = NULL;
- struct agent_reqs areqs;
aexpr = gen_trace_for_var (scope, gdbarch, sym);
old_chain1 = make_cleanup_free_agent_expr (aexpr);
- ax_reqs (aexpr, &areqs);
+ ax_reqs (aexpr);
- report_agent_reqs_errors (aexpr, &areqs);
+ report_agent_reqs_errors (aexpr);
discard_cleanups (old_chain1);
add_aexpr (collect, aexpr);
- /* take care of the registers */
- if (areqs.reg_mask_len > 0)
+ /* Take care of the registers. */
+ if (aexpr->reg_mask_len > 0)
{
int ndx1, ndx2;
- for (ndx1 = 0; ndx1 < areqs.reg_mask_len; ndx1++)
+ for (ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
{
- QUIT; /* allow user to bail out with ^C */
- if (areqs.reg_mask[ndx1] != 0)
+ QUIT; /* Allow user to bail out with ^C. */
+ if (aexpr->reg_mask[ndx1] != 0)
{
- /* assume chars have 8 bits */
+ /* Assume chars have 8 bits. */
for (ndx2 = 0; ndx2 < 8; ndx2++)
- if (areqs.reg_mask[ndx1] & (1 << ndx2))
- /* it's used -- record it */
+ if (aexpr->reg_mask[ndx1] & (1 << ndx2))
+ /* It's used -- record it. */
add_register (collect, ndx1 * 8 + ndx2);
}
}
int count;
};
-/* The callback for the locals and args iterators */
+/* The callback for the locals and args iterators. */
static void
do_collect_symbol (const char *print_name,
p->count++;
}
-/* Add all locals (or args) symbols to collection list */
+/* Add all locals (or args) symbols to collection list. */
static void
add_local_symbols (struct collection_list *collect,
struct gdbarch *gdbarch, CORE_ADDR pc,
}
}
+static void
+add_static_trace_data (struct collection_list *collection)
+{
+ if (info_verbose)
+ printf_filtered ("collect static trace data\n");
+ collection->strace_data = 1;
+}
+
/* worker function */
static void
clear_collection_list (struct collection_list *list)
}
list->next_aexpr_elt = 0;
memset (list->regs_mask, 0, sizeof (list->regs_mask));
+ list->strace_data = 0;
}
-/* reduce a collection list to string form (for gdb protocol) */
+/* Reduce a collection list to string form (for gdb protocol). */
static char **
stringify_collection_list (struct collection_list *list, char *string)
{
char *end;
long i;
- count = 1 + list->next_memrange + list->next_aexpr_elt + 1;
+ count = 1 + 1 + list->next_memrange + list->next_aexpr_elt + 1;
str_list = (char *(*)[]) xmalloc (count * sizeof (char *));
+ if (list->strace_data)
+ {
+ if (info_verbose)
+ printf_filtered ("\nCollecting static trace data\n");
+ end = temp_buf;
+ *end++ = 'L';
+ (*str_list)[ndx] = savestring (temp_buf, end - temp_buf);
+ ndx++;
+ }
+
for (i = sizeof (list->regs_mask) - 1; i > 0; i--)
- if (list->regs_mask[i] != 0) /* skip leading zeroes in regs_mask */
+ if (list->regs_mask[i] != 0) /* Skip leading zeroes in regs_mask. */
break;
- if (list->regs_mask[i] != 0) /* prepare to send regs_mask to the stub */
+ if (list->regs_mask[i] != 0) /* Prepare to send regs_mask to the stub. */
{
if (info_verbose)
printf_filtered ("\nCollecting registers (mask): 0x");
*end++ = 'R';
for (; i >= 0; i--)
{
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
if (info_verbose)
printf_filtered ("%02X", list->regs_mask[i]);
sprintf (end, "%02X", list->regs_mask[i]);
printf_filtered ("Collecting memranges: \n");
for (i = 0, count = 0, end = temp_buf; i < list->next_memrange; i++)
{
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
sprintf_vma (tmp2, list->list[i].start);
if (info_verbose)
{
for (i = 0; i < list->next_aexpr_elt; i++)
{
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
if ((count + 10 + 2 * list->aexpr_list[i]->len) > MAX_AGENT_EXPR_LEN)
{
(*str_list)[ndx] = savestring (temp_buf, count);
{
char *action_exp;
struct expression *exp = NULL;
- struct command_line *actions;
int i;
struct value *tempval;
struct cmd_list_element *cmd;
for (; action; action = action->next)
{
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
action_exp = action->line;
while (isspace ((int) *action_exp))
action_exp++;
if (cmd_cfunc_eq (cmd, collect_pseudocommand))
{
do
- { /* repeat over a comma-separated list */
- QUIT; /* allow user to bail out with ^C */
+ { /* Repeat over a comma-separated list. */
+ QUIT; /* Allow user to bail out with ^C. */
while (isspace ((int) *action_exp))
action_exp++;
'L');
action_exp = strchr (action_exp, ','); /* more? */
}
+ else if (0 == strncasecmp ("$_sdata", action_exp, 7))
+ {
+ add_static_trace_data (collect);
+ action_exp = strchr (action_exp, ','); /* more? */
+ }
else
{
unsigned long addr, len;
struct cleanup *old_chain = NULL;
struct cleanup *old_chain1 = NULL;
- struct agent_reqs areqs;
exp = parse_exp_1 (&action_exp,
block_for_pc (tloc->address), 1);
}
case UNOP_MEMVAL:
- /* safe because we know it's a simple expression */
+ /* Safe because we know it's a simple expression. */
tempval = evaluate_expression (exp);
addr = value_address (tempval);
len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
tloc->address);
break;
- default: /* full-fledged expression */
+ default: /* Full-fledged expression. */
aexpr = gen_trace_for_expr (tloc->address, exp);
old_chain1 = make_cleanup_free_agent_expr (aexpr);
- ax_reqs (aexpr, &areqs);
+ ax_reqs (aexpr);
- report_agent_reqs_errors (aexpr, &areqs);
+ report_agent_reqs_errors (aexpr);
discard_cleanups (old_chain1);
add_aexpr (collect, aexpr);
- /* take care of the registers */
- if (areqs.reg_mask_len > 0)
+ /* Take care of the registers. */
+ if (aexpr->reg_mask_len > 0)
{
int ndx1;
int ndx2;
- for (ndx1 = 0; ndx1 < areqs.reg_mask_len; ndx1++)
+ for (ndx1 = 0; ndx1 < aexpr->reg_mask_len; ndx1++)
{
- QUIT; /* allow user to bail out with ^C */
- if (areqs.reg_mask[ndx1] != 0)
+ QUIT; /* Allow user to bail out with ^C. */
+ if (aexpr->reg_mask[ndx1] != 0)
{
- /* assume chars have 8 bits */
+ /* Assume chars have 8 bits. */
for (ndx2 = 0; ndx2 < 8; ndx2++)
- if (areqs.reg_mask[ndx1] & (1 << ndx2))
- /* it's used -- record it */
+ if (aexpr->reg_mask[ndx1] & (1 << ndx2))
+ /* It's used -- record it. */
add_register (collect,
ndx1 * 8 + ndx2);
}
else if (cmd_cfunc_eq (cmd, teval_pseudocommand))
{
do
- { /* repeat over a comma-separated list */
- QUIT; /* allow user to bail out with ^C */
+ { /* Repeat over a comma-separated list. */
+ QUIT; /* Allow user to bail out with ^C. */
while (isspace ((int) *action_exp))
action_exp++;
{
- unsigned long addr, len;
struct cleanup *old_chain = NULL;
struct cleanup *old_chain1 = NULL;
- struct agent_reqs areqs;
exp = parse_exp_1 (&action_exp,
block_for_pc (tloc->address), 1);
aexpr = gen_eval_for_expr (tloc->address, exp);
old_chain1 = make_cleanup_free_agent_expr (aexpr);
- ax_reqs (aexpr, &areqs);
-
- report_agent_reqs_errors (aexpr, &areqs);
+ ax_reqs (aexpr);
+ report_agent_reqs_errors (aexpr);
discard_cleanups (old_chain1);
/* Even though we're not officially collecting, add
here. */
gdb_assert (stepping_list);
- encode_actions_1 (action->body_list[0], t, tloc, frame_reg, frame_offset,
- stepping_list, NULL);
+ encode_actions_1 (action->body_list[0], t, tloc, frame_reg,
+ frame_offset, stepping_list, NULL);
}
else
error (_("Invalid tracepoint command '%s'"), action->line);
{
collect->aexpr_list =
xrealloc (collect->aexpr_list,
- 2 * collect->aexpr_listsize * sizeof (struct agent_expr *));
+ 2 * collect->aexpr_listsize * sizeof (struct agent_expr *));
collect->aexpr_listsize *= 2;
}
collect->aexpr_list[collect->next_aexpr_elt] = aexpr;
void
start_tracing (void)
{
- char buf[2048];
VEC(breakpoint_p) *tp_vec = NULL;
int ix;
struct breakpoint *t;
struct trace_state_variable *tsv;
- int any_enabled = 0;
+ int any_enabled = 0, num_to_download = 0;
tp_vec = all_tracepoints ();
- /* No point in tracing without any tracepoints... */
+ /* No point in tracing without any tracepoints... */
if (VEC_length (breakpoint_p, tp_vec) == 0)
{
VEC_free (breakpoint_p, tp_vec);
for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
{
if (t->enable_state == bp_enabled)
- {
- any_enabled = 1;
- break;
- }
+ any_enabled = 1;
+
+ if ((t->type == bp_fast_tracepoint
+ ? may_insert_fast_tracepoints
+ : may_insert_tracepoints))
+ ++num_to_download;
+ else
+ warning (_("May not insert %stracepoints, skipping tracepoint %d"),
+ (t->type == bp_fast_tracepoint ? "fast " : ""), t->number);
}
/* No point in tracing with only disabled tracepoints. */
error (_("No tracepoints enabled, not starting trace"));
}
+ if (num_to_download <= 0)
+ {
+ VEC_free (breakpoint_p, tp_vec);
+ error (_("No tracepoints that may be downloaded, not starting trace"));
+ }
+
target_trace_init ();
for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
{
+ if ((t->type == bp_fast_tracepoint
+ ? !may_insert_fast_tracepoints
+ : !may_insert_tracepoints))
+ continue;
+
t->number_on_target = 0;
target_download_tracepoint (t);
t->number_on_target = t->number;
stop_tracing (void)
{
target_trace_stop ();
- /* should change in response to reply? */
+ /* Should change in response to reply? */
current_trace_status ()->running = 0;
}
break;
case tracepoint_error:
if (ts->stopping_tracepoint)
- printf_filtered (_("Trace stopped by an error (%s, tracepoint %d).\n"),
+ printf_filtered (_("Trace stopped by an "
+ "error (%s, tracepoint %d).\n"),
ts->error_desc, ts->stopping_tracepoint);
else
printf_filtered (_("Trace stopped by an error (%s).\n"),
if (ts->traceframes_created >= 0
&& ts->traceframe_count != ts->traceframes_created)
{
- printf_filtered (_("Buffer contains %d trace frames (of %d created total).\n"),
+ printf_filtered (_("Buffer contains %d trace "
+ "frames (of %d created total).\n"),
ts->traceframe_count, ts->traceframes_created);
}
else if (ts->traceframe_count >= 0)
{
struct trace_status *ts = current_trace_status ();
int status;
- char *string_status;
status = target_get_trace_status (ts);
{
if (current_trace_status ()->disconnected_tracing)
{
- if (!query (_("Trace is running and will continue after detach; detach anyway? ")))
+ if (!query (_("Trace is running and will "
+ "continue after detach; detach anyway? ")))
error (_("Not confirmed."));
}
else
{
- if (!query (_("Trace is running but will stop on detach; detach anyway? ")))
+ if (!query (_("Trace is running but will "
+ "stop on detach; detach anyway? ")))
error (_("Not confirmed."));
}
}
{
int target_frameno = -1, target_tracept = -1;
struct frame_id old_frame_id = null_frame_id;
- char *reply;
struct breakpoint *tp;
/* Only try to get the current stack frame if we have a chance of
{
if (info_verbose)
printf_filtered ("End of trace buffer.\n");
-#if 0 /* dubious now? */
+#if 0 /* dubious now? */
/* The following will not recurse, since it's
special-cased. */
trace_find_command ("-1", from_tty);
{
if (ui_out_is_mi_like_p (uiout))
ui_out_field_string (uiout, "found", "0");
- else
- printf_unfiltered (_("No trace frame found"));
+ else if (type == tfind_number && num == -1)
+ printf_unfiltered (_("No longer looking at any trace frame\n"));
+ else /* This case may never occur, check. */
+ printf_unfiltered (_("No trace frame found\n"));
}
/* If we're in nonstop mode and getting out of looking at trace
/* tfind command */
static void
trace_find_command (char *args, int from_tty)
-{ /* this should only be called with a numeric argument */
+{ /* This should only be called with a numeric argument. */
int frameno = -1;
if (current_trace_status ()->running && !current_trace_status ()->from_file)
- error ("May not look at trace frames while trace is running.");
+ error (_("May not look at trace frames while trace is running."));
if (args == 0 || *args == 0)
{ /* TFIND with no args means find NEXT trace frame. */
if (traceframe_number == -1)
- frameno = 0; /* "next" is first one */
+ frameno = 0; /* "next" is first one. */
else
frameno = traceframe_number + 1;
}
trace_find_pc_command (char *args, int from_tty)
{
CORE_ADDR pc;
- char tmp[40];
if (current_trace_status ()->running && !current_trace_status ()->from_file)
- error ("May not look at trace frames while trace is running.");
+ error (_("May not look at trace frames while trace is running."));
if (args == 0 || *args == 0)
pc = regcache_read_pc (get_current_regcache ());
struct breakpoint *tp;
if (current_trace_status ()->running && !current_trace_status ()->from_file)
- error ("May not look at trace frames while trace is running.");
+ error (_("May not look at trace frames while trace is running."));
if (args == 0 || *args == 0)
{
if (tracepoint_number == -1)
error (_("No current tracepoint -- please supply an argument."));
else
- tdp = tracepoint_number; /* default is current TDP */
+ tdp = tracepoint_number; /* Default is current TDP. */
}
else
tdp = parse_and_eval_long (args);
struct symtabs_and_lines sals;
struct symtab_and_line sal;
struct cleanup *old_chain;
- char startpc_str[40], endpc_str[40];
if (current_trace_status ()->running && !current_trace_status ()->from_file)
- error ("May not look at trace frames while trace is running.");
+ error (_("May not look at trace frames while trace is running."));
if (args == 0 || *args == 0)
{
trace_find_range_command (char *args, int from_tty)
{
static CORE_ADDR start, stop;
- char start_str[40], stop_str[40];
char *tmp;
if (current_trace_status ()->running && !current_trace_status ()->from_file)
- error ("May not look at trace frames while trace is running.");
+ error (_("May not look at trace frames while trace is running."));
if (args == 0 || *args == 0)
{ /* XXX FIXME: what should default behavior be? */
if (0 != (tmp = strchr (args, ',')))
{
- *tmp++ = '\0'; /* terminate start address */
+ *tmp++ = '\0'; /* Terminate start address. */
while (isspace ((int) *tmp))
tmp++;
start = parse_and_eval_address (args);
stop = parse_and_eval_address (tmp);
}
else
- { /* no explicit end address? */
+ { /* No explicit end address? */
start = parse_and_eval_address (args);
stop = start + 1; /* ??? */
}
trace_find_outside_command (char *args, int from_tty)
{
CORE_ADDR start, stop;
- char start_str[40], stop_str[40];
char *tmp;
if (current_trace_status ()->running && !current_trace_status ()->from_file)
- error ("May not look at trace frames while trace is running.");
+ error (_("May not look at trace frames while trace is running."));
if (args == 0 || *args == 0)
- { /* XXX FIXME: what should default behavior be? */
+ { /* XXX FIXME: what should default behavior be? */
printf_filtered ("Usage: tfind outside <startaddr>,<endaddr>\n");
return;
}
if (0 != (tmp = strchr (args, ',')))
{
- *tmp++ = '\0'; /* terminate start address */
+ *tmp++ = '\0'; /* Terminate start address. */
while (isspace ((int) *tmp))
tmp++;
start = parse_and_eval_address (args);
stop = parse_and_eval_address (tmp);
}
else
- { /* no explicit end address? */
+ { /* No explicit end address? */
start = parse_and_eval_address (args);
stop = start + 1; /* ??? */
}
int regno;
if (args == 0 || *args == 0)
- error (_("requires an argument (function, line or *addr) to define a scope"));
+ error (_("requires an argument (function, "
+ "line or *addr) to define a scope"));
sals = decode_line_1 (&args, 1, NULL, 0, &canonical, NULL);
if (sals.nelts == 0)
- return; /* presumably decode_line_1 has already warned */
+ return; /* Presumably decode_line_1 has already warned. */
- /* Resolve line numbers to PC */
+ /* Resolve line numbers to PC. */
resolve_sal_pc (&sals.sals[0]);
block = block_for_pc (sals.sals[0].pc);
while (block != 0)
{
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
ALL_BLOCK_SYMBOLS (block, iter, sym)
{
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
if (count == 0)
printf_filtered ("Scope for %s:\n", save_args);
count++;
symname = SYMBOL_PRINT_NAME (sym);
if (symname == NULL || *symname == '\0')
- continue; /* probably botched, certainly useless */
+ continue; /* Probably botched, certainly useless. */
gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
switch (SYMBOL_CLASS (sym))
{
default:
- case LOC_UNDEF: /* messed up symbol? */
+ case LOC_UNDEF: /* Messed up symbol? */
printf_filtered ("a bogus symbol, class %d.\n",
SYMBOL_CLASS (sym));
- count--; /* don't count this one */
+ count--; /* Don't count this one. */
continue;
case LOC_CONST:
printf_filtered ("a constant with value %ld (0x%lx)",
We assume the objfile architecture will contain all the
standard registers that occur in debug info in that
objfile. */
- regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
+ regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym,
+ gdbarch);
if (SYMBOL_IS_ARGUMENT (sym))
printf_filtered ("an argument in register $%s",
break;
case LOC_REGPARM_ADDR:
/* Note comment at LOC_REGISTER. */
- regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
+ regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym,
+ gdbarch);
printf_filtered ("the address of an argument, in register $%s",
gdbarch_register_name (gdbarch, regno));
break;
printf_filtered ("optimized out.\n");
continue;
case LOC_COMPUTED:
- SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, gdb_stdout);
+ SYMBOL_COMPUTED_OPS (sym)->describe_location (sym,
+ BLOCK_START (block),
+ gdb_stdout);
break;
}
if (SYMBOL_TYPE (sym))
{
struct cmd_list_element *cmd;
- QUIT; /* allow user to bail out with ^C */
+ QUIT; /* Allow user to bail out with ^C. */
action_exp = action->line;
while (isspace ((int) *action_exp))
action_exp++;
if (stepping_frame == stepping_actions)
{
do
- { /* repeat over a comma-separated list */
- QUIT; /* allow user to bail out with ^C */
+ { /* Repeat over a comma-separated list. */
+ QUIT; /* Allow user to bail out with ^C. */
if (*action_exp == ',')
action_exp++;
while (isspace ((int) *action_exp))
if (80 + strlen (srctype) > buf_size)
error (_("Buffer too small for source encoding"));
sprintf (buf, "%x:%s:%s:%x:%x:",
- tpnum, phex_nz (addr, sizeof (addr)), srctype, 0, (int) strlen (src));
+ tpnum, phex_nz (addr, sizeof (addr)),
+ srctype, 0, (int) strlen (src));
if (strlen (buf) + strlen (src) * 2 >= buf_size)
error (_("Source string too long for buffer"));
bin2hex (src, buf + strlen (buf), 0);
pathname = tilde_expand (filename);
cleanup = make_cleanup (xfree, pathname);
- fp = fopen (pathname, "w");
+ fp = fopen (pathname, "wb");
if (!fp)
error (_("Unable to open file '%s' for saving trace data (%s)"),
filename, safe_strerror (errno));
if (ts->stop_reason == tracepoint_error)
{
char *buf = (char *) alloca (strlen (ts->error_desc) * 2 + 1);
+
bin2hex ((gdb_byte *) ts->error_desc, buf, 0);
fprintf (fp, ":%s", buf);
}
for (a = 0; VEC_iterate (char_ptr, utp->actions, a, act); ++a)
fprintf (fp, "tp A%x:%s:%s\n",
utp->number, phex_nz (utp->addr, sizeof (utp->addr)), act);
- for (a = 0; VEC_iterate (char_ptr, utp->actions, a, act); ++a)
+ for (a = 0; VEC_iterate (char_ptr, utp->step_actions, a, act); ++a)
fprintf (fp, "tp S%x:%s:%s\n",
utp->number, phex_nz (utp->addr, sizeof (utp->addr)), act);
if (utp->at_string)
if (utp->cond_string)
{
encode_source_string (utp->number, utp->addr,
- "cond", utp->cond_string, buf, MAX_TRACE_UPLOAD);
+ "cond", utp->cond_string,
+ buf, MAX_TRACE_UPLOAD);
fprintf (fp, "tp Z%s\n", buf);
}
for (a = 0; VEC_iterate (char_ptr, utp->cmd_strings, a, act); ++a)
if (t->type == utp->type
&& t->step_count == utp->step
&& t->pass_count == utp->pass
- /* FIXME also test conditionals and actions */
+ /* FIXME also test conditionals and actions. */
)
{
/* Scan the locations for an address match. */
{
t = find_matching_tracepoint (utp);
if (t)
- printf_filtered (_("Assuming tracepoint %d is same as target's tracepoint %d at %s.\n"),
- t->number, utp->number, paddress (get_current_arch (), utp->addr));
+ printf_filtered (_("Assuming tracepoint %d is same "
+ "as target's tracepoint %d at %s.\n"),
+ t->number, utp->number,
+ paddress (get_current_arch (), utp->addr));
else
{
t = create_tracepoint_from_upload (utp);
if (t)
- printf_filtered (_("Created tracepoint %d for target's tracepoint %d at %s.\n"),
- t->number, utp->number, paddress (get_current_arch (), utp->addr));
+ printf_filtered (_("Created tracepoint %d for "
+ "target's tracepoint %d at %s.\n"),
+ t->number, utp->number,
+ paddress (get_current_arch (), utp->addr));
else
- printf_filtered (_("Failed to create tracepoint for target's tracepoint %d at %s, skipping it.\n"),
- utp->number, paddress (get_current_arch (), utp->addr));
+ printf_filtered (_("Failed to create tracepoint for target's "
+ "tracepoint %d at %s, skipping it.\n"),
+ utp->number,
+ paddress (get_current_arch (), utp->addr));
}
/* Whether found or created, record the number used by the
target, to help with mapping target tracepoints back to their
}
/* Fish for a name that is not in use. */
- /* (should check against all internal vars?) */
+ /* (should check against all internal vars?) */
while (find_trace_state_variable (buf))
sprintf (buf, "%s_%d", namebase, try_num++);
{
tsv = find_matching_tsv (utsv);
if (tsv)
- printf_filtered (_("Assuming trace state variable $%s is same as target's variable %d.\n"),
- tsv->name, utsv->number);
+ {
+ if (info_verbose)
+ printf_filtered (_("Assuming trace state variable $%s "
+ "is same as target's variable %d.\n"),
+ tsv->name, utsv->number);
+ }
else
{
tsv = create_tsv_from_upload (utsv);
- printf_filtered (_("Created trace state variable $%s for target's variable %d.\n"),
- tsv->name, utsv->number);
+ if (info_verbose)
+ printf_filtered (_("Created trace state variable "
+ "$%s for target's variable %d.\n"),
+ tsv->name, utsv->number);
}
/* Give precedence to numberings that come from the target. */
if (tsv)
int flags;
int scratch_chan;
char header[TRACE_HEADER_SIZE];
- char linebuf[1000]; /* should be max remote packet size or so */
+ char linebuf[1000]; /* Should be max remote packet size or so. */
char byte;
int bytes, i, gotten;
struct trace_status *ts;
filename = tilde_expand (filename);
if (!IS_ABSOLUTE_PATH(filename))
{
- temp = concat (current_directory, "/", filename, (char *)NULL);
+ temp = concat (current_directory, "/", filename, (char *) NULL);
xfree (filename);
filename = temp;
}
/* Looks semi-reasonable. Toss the old trace file and work on the new. */
- discard_cleanups (old_chain); /* Don't free filename any more */
+ discard_cleanups (old_chain); /* Don't free filename any more. */
unpush_target (&tfile_ops);
push_target (&tfile_ops);
error (_("No register block size recorded in trace file"));
if (ts->traceframe_count <= 0)
{
- warning ("No traceframes present in this file.");
+ warning (_("No traceframes present in this file."));
return;
}
post_create_inferior (&tfile_ops, from_tty);
#if 0
- /* FIXME this will get defined in MI patch submission */
+ /* FIXME this will get defined in MI patch submission. */
tfind_1 (tfind_number, 0, 0, 0, 0);
#endif
}
parse_tsv_definition (p, utsvp);
}
else
- warning ("Ignoring trace file definition \"%s\"", line);
+ warning (_("Ignoring trace file definition \"%s\""), line);
}
/* Parse the part of trace status syntax that is shared between
the remote protocol and the trace file reader. */
-extern char *unpack_varlen_hex (char *buff, ULONGEST *result);
-
void
parse_trace_status (char *line, struct trace_status *ts)
{
p = unpack_varlen_hex (++p1, &val);
ts->stop_reason = trace_never_run;
}
- else if (strncmp (p, stop_reason_names[tracepoint_passcount], p1 - p) == 0)
+ else if (strncmp (p, stop_reason_names[tracepoint_passcount],
+ p1 - p) == 0)
{
p = unpack_varlen_hex (++p1, &val);
ts->stop_reason = tracepoint_passcount;
char *p;
char piece;
ULONGEST num, addr, step, pass, orig_size, xlen, start;
- int enabled, i, end;
+ int enabled, end;
enum bptype type;
- char *cond, *srctype, *src, *buf;
+ char *cond, *srctype, *buf;
struct uploaded_tp *utp = NULL;
p = line;
p++;
p = unpack_varlen_hex (p, &orig_size);
}
+ else if (*p == 'S')
+ {
+ type = bp_static_tracepoint;
+ p++;
+ }
else if (*p == 'X')
{
p++;
p += 2 * xlen;
}
else
- warning (_("Unrecognized char '%c' in tracepoint definition, skipping rest"), *p);
+ warning (_("Unrecognized char '%c' in tracepoint "
+ "definition, skipping rest"), *p);
}
utp = get_uploaded_tp (num, addr, utpp);
utp->type = type;
return;
pid = ptid_get_pid (inferior_ptid);
- inferior_ptid = null_ptid; /* Avoid confusion from thread stuff */
+ inferior_ptid = null_ptid; /* Avoid confusion from thread stuff. */
exit_inferior_silent (pid);
close (trace_fd);
static void
tfile_files_info (struct target_ops *t)
{
- /* (it would be useful to mention the name of the file) */
+ /* (it would be useful to mention the name of the file). */
printf_filtered ("Looking at a trace file.\n");
}
off_t saved_offset = cur_offset;
int gotten;
- /* FIXME dig pc out of collected registers */
+ /* FIXME dig pc out of collected registers. */
/* Fall back to using tracepoint address. */
lseek (trace_fd, tframe_offset, SEEK_SET);
perror_with_name (trace_filename);
else if (gotten < 2)
error (_("Premature end of file while reading trace file"));
+ tpnum = (short) extract_signed_integer ((gdb_byte *) &tpnum, 2,
+ gdbarch_byte_order
+ (target_gdbarch));
tp = get_tracepoint_by_number_on_target (tpnum);
- /* FIXME this is a poor heuristic if multiple locations */
+ /* FIXME this is a poor heuristic if multiple locations. */
if (tp && tp->loc)
addr = tp->loc->address;
{
short tpnum;
int tfnum = 0, found = 0, gotten;
- int data_size;
+ unsigned int data_size;
struct breakpoint *tp;
off_t offset, tframe_offset;
ULONGEST tfaddr;
perror_with_name (trace_filename);
else if (gotten < 2)
error (_("Premature end of file while reading trace file"));
+ tpnum = (short) extract_signed_integer ((gdb_byte *) &tpnum, 2,
+ gdbarch_byte_order
+ (target_gdbarch));
offset += 2;
if (tpnum == 0)
break;
perror_with_name (trace_filename);
else if (gotten < 4)
error (_("Premature end of file while reading trace file"));
+ data_size = (unsigned int) extract_unsigned_integer
+ ((gdb_byte *) &data_size, 4,
+ gdbarch_byte_order (target_gdbarch));
offset += 4;
switch (type)
{
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
char block_type;
- int i, pos, offset, regn, regsize, gotten, pc_regno;
+ int pos, offset, regn, regsize, gotten, pc_regno;
unsigned short mlen;
char *regs;
/* Make sure we stay within block bounds. */
if (offset + regsize >= trace_regblock_size)
break;
- if (!regcache_valid_p (regcache, regn))
+ if (regcache_register_status (regcache, regn) == REG_UNKNOWN)
{
if (regno == regn)
{
perror_with_name (trace_filename);
else if (gotten < 2)
error (_("Premature end of file while reading trace file"));
+ mlen = (unsigned short)
+ extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+ gdbarch_byte_order
+ (target_gdbarch));
lseek (trace_fd, mlen, SEEK_CUR);
pos += (8 + 2 + mlen);
break;
pos += (4 + 8);
break;
default:
- error ("Unknown block type '%c' (0x%x) in trace frame",
+ error (_("Unknown block type '%c' (0x%x) in trace frame"),
block_type, block_type);
break;
}
/* But don't try to guess if tracepoint is multi-location... */
if (tp->loc->next)
{
- warning ("Tracepoint %d has multiple locations, cannot infer $pc",
+ warning (_("Tracepoint %d has multiple "
+ "locations, cannot infer $pc"),
tp->number);
return;
}
/* ... or does while-stepping. */
if (tp->step_count > 0)
{
- warning ("Tracepoint %d does while-stepping, cannot infer $pc",
+ warning (_("Tracepoint %d does while-stepping, "
+ "cannot infer $pc"),
tp->number);
return;
}
return -1;
if (readbuf == NULL)
- error ("tfile_xfer_partial: trace file is read-only");
+ error (_("tfile_xfer_partial: trace file is read-only"));
lseek (trace_fd, cur_offset, SEEK_SET);
pos = 0;
perror_with_name (trace_filename);
else if (gotten < 8)
error (_("Premature end of file while reading trace file"));
-
+ maddr = extract_unsigned_integer ((gdb_byte *) &maddr, 8,
+ gdbarch_byte_order
+ (target_gdbarch));
gotten = read (trace_fd, &mlen, 2);
if (gotten < 0)
perror_with_name (trace_filename);
else if (gotten < 2)
error (_("Premature end of file while reading trace file"));
+ mlen = (unsigned short)
+ extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+ gdbarch_byte_order
+ (target_gdbarch));
/* If the block includes the first part of the desired
range, return as much it has; GDB will re-request the
remainder, which might be in a different block of this
pos += (4 + 8);
break;
default:
- error ("Unknown block type '%c' (0x%x) in traceframe",
+ error (_("Unknown block type '%c' (0x%x) in traceframe"),
block_type, block_type);
break;
}
/* It's unduly pedantic to refuse to look at the executable for
read-only pieces; so do the equivalent of readonly regions aka
QTro packet. */
- /* FIXME account for relocation at some point */
+ /* FIXME account for relocation at some point. */
if (exec_bfd)
{
asection *s;
bfd_size_type size;
- bfd_vma lma;
+ bfd_vma vma;
for (s = exec_bfd->sections; s; s = s->next)
{
(s->flags & SEC_READONLY) == 0)
continue;
- lma = s->lma;
+ vma = s->vma;
size = bfd_get_section_size (s);
- if (lma <= offset && offset < (lma + size))
+ if (vma <= offset && offset < (vma + size))
{
- amt = (lma + size) - offset;
+ amt = (vma + size) - offset;
if (amt > len)
amt = len;
amt = bfd_get_section_contents (exec_bfd, s,
- readbuf, offset - lma, amt);
+ readbuf, offset - vma, amt);
return amt;
}
}
perror_with_name (trace_filename);
else if (gotten < 2)
error (_("Premature end of file while reading trace file"));
+ mlen = (unsigned short)
+ extract_unsigned_integer ((gdb_byte *) &mlen, 2,
+ gdbarch_byte_order
+ (target_gdbarch));
lseek (trace_fd, mlen, SEEK_CUR);
pos += (8 + 2 + mlen);
break;
perror_with_name (trace_filename);
else if (gotten < 4)
error (_("Premature end of file while reading trace file"));
+ vnum = (int) extract_signed_integer ((gdb_byte *) &vnum, 4,
+ gdbarch_byte_order
+ (target_gdbarch));
if (tsvnum == vnum)
{
gotten = read (trace_fd, val, 8);
perror_with_name (trace_filename);
else if (gotten < 8)
error (_("Premature end of file while reading trace file"));
+ *val = extract_signed_integer ((gdb_byte *)val, 8,
+ gdbarch_byte_order
+ (target_gdbarch));
return 1;
}
lseek (trace_fd, 8, SEEK_CUR);
pos += (4 + 8);
break;
default:
- error ("Unknown block type '%c' (0x%x) in traceframe",
+ error (_("Unknown block type '%c' (0x%x) in traceframe"),
block_type, block_type);
break;
}
{
tfile_ops.to_shortname = "tfile";
tfile_ops.to_longname = "Local trace dump file";
- tfile_ops.to_doc =
- "Use a trace file as a target. Specify the filename of the trace file.";
+ tfile_ops.to_doc
+ = "Use a trace file as a target. Specify the filename of the trace file.";
tfile_ops.to_open = tfile_open;
tfile_ops.to_close = tfile_close;
tfile_ops.to_fetch_registers = tfile_fetch_registers;
tfile_ops.to_files_info = tfile_files_info;
tfile_ops.to_get_trace_status = tfile_get_trace_status;
tfile_ops.to_trace_find = tfile_trace_find;
- tfile_ops.to_get_trace_state_variable_value = tfile_get_trace_state_variable_value;
- /* core_stratum might seem more logical, but GDB doesn't like having
- more than one core_stratum vector. */
+ tfile_ops.to_get_trace_state_variable_value
+ = tfile_get_trace_state_variable_value;
tfile_ops.to_stratum = process_stratum;
tfile_ops.to_has_all_memory = tfile_has_all_memory;
tfile_ops.to_has_memory = tfile_has_memory;
tfile_ops.to_magic = OPS_MAGIC;
}
+/* Given a line of text defining a static tracepoint marker, parse it
+ into a "static tracepoint marker" object. Throws an error is
+ parsing fails. If PP is non-null, it points to one past the end of
+ the parsed marker definition. */
+
+void
+parse_static_tracepoint_marker_definition (char *line, char **pp,
+ struct static_tracepoint_marker *marker)
+{
+ char *p, *endp;
+ ULONGEST addr;
+ int end;
+
+ p = line;
+ p = unpack_varlen_hex (p, &addr);
+ p++; /* skip a colon */
+
+ marker->gdbarch = target_gdbarch;
+ marker->address = (CORE_ADDR) addr;
+
+ endp = strchr (p, ':');
+ if (endp == NULL)
+ error (_("bad marker definition: %s"), line);
+
+ marker->str_id = xmalloc (endp - p + 1);
+ end = hex2bin (p, (gdb_byte *) marker->str_id, (endp - p + 1) / 2);
+ marker->str_id[end] = '\0';
+
+ p += 2 * end;
+ p++; /* skip a colon */
+
+ marker->extra = xmalloc (strlen (p) + 1);
+ end = hex2bin (p, (gdb_byte *) marker->extra, strlen (p) / 2);
+ marker->extra[end] = '\0';
+
+ if (pp)
+ *pp = p;
+}
+
+/* Release a static tracepoint marker's contents. Note that the
+ object itself isn't released here. There objects are usually on
+ the stack. */
+
+void
+release_static_tracepoint_marker (struct static_tracepoint_marker *marker)
+{
+ xfree (marker->str_id);
+ marker->str_id = NULL;
+}
+
+/* Print MARKER to gdb_stdout. */
+
+static void
+print_one_static_tracepoint_marker (int count,
+ struct static_tracepoint_marker *marker)
+{
+ struct command_line *l;
+ struct symbol *sym;
+
+ char wrap_indent[80];
+ char extra_field_indent[80];
+ struct ui_stream *stb = ui_out_stream_new (uiout);
+ struct cleanup *old_chain = make_cleanup_ui_out_stream_delete (stb);
+ struct cleanup *bkpt_chain;
+ VEC(breakpoint_p) *tracepoints;
+
+ struct symtab_and_line sal;
+
+ init_sal (&sal);
+
+ sal.pc = marker->address;
+
+ tracepoints = static_tracepoints_here (marker->address);
+
+ bkpt_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "marker");
+
+ /* A counter field to help readability. This is not a stable
+ identifier! */
+ ui_out_field_int (uiout, "count", count);
+
+ ui_out_field_string (uiout, "marker-id", marker->str_id);
+
+ ui_out_field_fmt (uiout, "enabled", "%c",
+ !VEC_empty (breakpoint_p, tracepoints) ? 'y' : 'n');
+ ui_out_spaces (uiout, 2);
+
+ strcpy (wrap_indent, " ");
+
+ if (gdbarch_addr_bit (marker->gdbarch) <= 32)
+ strcat (wrap_indent, " ");
+ else
+ strcat (wrap_indent, " ");
+
+ strcpy (extra_field_indent, " ");
+
+ ui_out_field_core_addr (uiout, "addr", marker->gdbarch, marker->address);
+
+ sal = find_pc_line (marker->address, 0);
+ sym = find_pc_sect_function (marker->address, NULL);
+ if (sym)
+ {
+ ui_out_text (uiout, "in ");
+ ui_out_field_string (uiout, "func",
+ SYMBOL_PRINT_NAME (sym));
+ ui_out_wrap_hint (uiout, wrap_indent);
+ ui_out_text (uiout, " at ");
+ }
+ else
+ ui_out_field_skip (uiout, "func");
+
+ if (sal.symtab != NULL)
+ {
+ ui_out_field_string (uiout, "file", sal.symtab->filename);
+ ui_out_text (uiout, ":");
+
+ if (ui_out_is_mi_like_p (uiout))
+ {
+ char *fullname = symtab_to_fullname (sal.symtab);
+
+ if (fullname)
+ ui_out_field_string (uiout, "fullname", fullname);
+ }
+ else
+ ui_out_field_skip (uiout, "fullname");
+
+ ui_out_field_int (uiout, "line", sal.line);
+ }
+ else
+ {
+ ui_out_field_skip (uiout, "fullname");
+ ui_out_field_skip (uiout, "line");
+ }
+
+ ui_out_text (uiout, "\n");
+ ui_out_text (uiout, extra_field_indent);
+ ui_out_text (uiout, _("Data: \""));
+ ui_out_field_string (uiout, "extra-data", marker->extra);
+ ui_out_text (uiout, "\"\n");
+
+ if (!VEC_empty (breakpoint_p, tracepoints))
+ {
+ struct cleanup *cleanup_chain;
+ int ix;
+ struct breakpoint *b;
+
+ cleanup_chain = make_cleanup_ui_out_tuple_begin_end (uiout,
+ "tracepoints-at");
+
+ ui_out_text (uiout, extra_field_indent);
+ ui_out_text (uiout, _("Probed by static tracepoints: "));
+ for (ix = 0; VEC_iterate(breakpoint_p, tracepoints, ix, b); ix++)
+ {
+ if (ix > 0)
+ ui_out_text (uiout, ", ");
+ ui_out_text (uiout, "#");
+ ui_out_field_int (uiout, "tracepoint-id", b->number);
+ }
+
+ do_cleanups (cleanup_chain);
+
+ if (ui_out_is_mi_like_p (uiout))
+ ui_out_field_int (uiout, "number-of-tracepoints",
+ VEC_length(breakpoint_p, tracepoints));
+ else
+ ui_out_text (uiout, "\n");
+ }
+ VEC_free (breakpoint_p, tracepoints);
+
+ do_cleanups (bkpt_chain);
+ do_cleanups (old_chain);
+}
+
+static void
+info_static_tracepoint_markers_command (char *arg, int from_tty)
+{
+ VEC(static_tracepoint_marker_p) *markers;
+ struct cleanup *old_chain;
+ struct static_tracepoint_marker *marker;
+ int i;
+
+ old_chain
+ = make_cleanup_ui_out_table_begin_end (uiout, 5, -1,
+ "StaticTracepointMarkersTable");
+
+ ui_out_table_header (uiout, 7, ui_left, "counter", "Cnt");
+
+ ui_out_table_header (uiout, 40, ui_left, "marker-id", "ID");
+
+ ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb");
+ if (gdbarch_addr_bit (target_gdbarch) <= 32)
+ ui_out_table_header (uiout, 10, ui_left, "addr", "Address");
+ else
+ ui_out_table_header (uiout, 18, ui_left, "addr", "Address");
+ ui_out_table_header (uiout, 40, ui_noalign, "what", "What");
+
+ ui_out_table_body (uiout);
+
+ markers = target_static_tracepoint_markers_by_strid (NULL);
+ make_cleanup (VEC_cleanup (static_tracepoint_marker_p), &markers);
+
+ for (i = 0;
+ VEC_iterate (static_tracepoint_marker_p,
+ markers, i, marker);
+ i++)
+ {
+ print_one_static_tracepoint_marker (i + 1, marker);
+ release_static_tracepoint_marker (marker);
+ }
+
+ do_cleanups (old_chain);
+}
+
+/* The $_sdata convenience variable is a bit special. We don't know
+ for sure type of the value until we actually have a chance to fetch
+ the data --- the size of the object depends on what has been
+ collected. We solve this by making $_sdata be an internalvar that
+ creates a new value on access. */
+
+/* Return a new value with the correct type for the sdata object of
+ the current trace frame. Return a void value if there's no object
+ available. */
+
+static struct value *
+sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var)
+{
+ LONGEST size;
+ gdb_byte *buf;
+
+ /* We need to read the whole object before we know its size. */
+ size = target_read_alloc (¤t_target,
+ TARGET_OBJECT_STATIC_TRACE_DATA,
+ NULL, &buf);
+ if (size >= 0)
+ {
+ struct value *v;
+ struct type *type;
+
+ type = init_vector_type (builtin_type (gdbarch)->builtin_true_char,
+ size);
+ v = allocate_value (type);
+ memcpy (value_contents_raw (v), buf, size);
+ xfree (buf);
+ return v;
+ }
+ else
+ return allocate_value (builtin_type (gdbarch)->builtin_void);
+}
+
/* module initialization */
void
_initialize_tracepoint (void)
{
struct cmd_list_element *c;
+ /* Explicitly create without lookup, since that tries to create a
+ value with a void typed value, and when we get here, gdbarch
+ isn't initialized yet. At this point, we're quite sure there
+ isn't another convenience variable of the same name. */
+ create_internalvar_type_lazy ("_sdata", sdata_make_value);
+
traceframe_number = -1;
tracepoint_number = -1;
Delete one or more trace state variables.\n\
Arguments are the names of the variables to delete.\n\
If no arguments are supplied, delete all variables."), &deletelist);
- /* FIXME add a trace variable completer */
+ /* FIXME add a trace variable completer. */
add_info ("tvariables", tvariables_info, _("\
Status of trace state variables and their values.\n\
+"));
+
+ add_info ("static-tracepoint-markers",
+ info_static_tracepoint_markers_command, _("\
+List target static tracepoints markers.\n\
"));
add_prefix_cmd ("tfind", class_trace, trace_find_command, _("\
add_cmd ("line", class_trace, trace_find_line_command, _("\
Select a trace frame by source line.\n\
-Argument can be a line number (with optional source file), \n\
+Argument can be a line number (with optional source file),\n\
a function name, or '*' followed by an address.\n\
Default argument is 'the next source line that was traced'."),
&tfindlist);
$regs -- all registers.\n\
$args -- all function arguments.\n\
$locals -- all variables local to the block/function scope.\n\
+ $_sdata -- static tracepoint data (ignored for non-static tracepoints).\n\
Note: this command can only be used in a tracepoint \"actions\" list."));
add_com ("teval", class_trace, teval_pseudocommand, _("\
add_com ("actions", class_trace, trace_actions_command, _("\
Specify the actions to be taken at a tracepoint.\n\
-Tracepoint actions may include collecting of specified data, \n\
-single-stepping, or enabling/disabling other tracepoints, \n\
+Tracepoint actions may include collecting of specified data,\n\
+single-stepping, or enabling/disabling other tracepoints,\n\
depending on target's capabilities."));
default_collect = xstrdup ("");