yet attempted to fetch it, or if the target does not support
fetching this object, or if we're not inspecting a traceframe
presently. */
-static struct traceframe_info *current_traceframe_info;
+static traceframe_info_up current_traceframe_info;
/* Tracing command lists. */
static struct cmd_list_element *tfindlist;
return &trace_status;
}
-/* Destroy INFO. */
-
-static void
-free_traceframe_info (struct traceframe_info *info)
-{
- if (info != NULL)
- {
- VEC_free (mem_range_s, info->memory);
- VEC_free (int, info->tvars);
-
- xfree (info);
- }
-}
-
/* Free and clear the traceframe info cache of the current
traceframe. */
static void
clear_traceframe_info (void)
{
- free_traceframe_info (current_traceframe_info);
current_traceframe_info = NULL;
}
evaluate into an initial value. */
static void
-trace_variable_command (char *args, int from_tty)
+trace_variable_command (const char *args, int from_tty)
{
LONGEST initval = 0;
struct trace_state_variable *tsv;
- char *name_start, *p;
+ const char *name_start, *p;
if (!args || !*args)
error_no_arg (_("Syntax is $NAME [ = EXPR ]"));
/* List all the trace state variables. */
static void
-info_tvariables_command (char *args, int from_tty)
+info_tvariables_command (const char *args, int from_tty)
{
tvariables_info_1 ();
}
which is always an error. */
static void
-end_actions_pseudocommand (char *args, int from_tty)
+end_actions_pseudocommand (const char *args, int from_tty)
{
error (_("This command cannot be used at the top level."));
}
static void
-while_stepping_pseudocommand (char *args, int from_tty)
+while_stepping_pseudocommand (const char *args, int from_tty)
{
error (_("This command can only be used in a tracepoint actions list."));
}
static void
-collect_pseudocommand (char *args, int from_tty)
+collect_pseudocommand (const char *args, int from_tty)
{
error (_("This command can only be used in a tracepoint actions list."));
}
static void
-teval_pseudocommand (char *args, int from_tty)
+teval_pseudocommand (const char *args, int from_tty)
{
error (_("This command can only be used in a tracepoint actions list."));
}
/* Enter a list of actions for a tracepoint. */
static void
-actions_command (char *args, int from_tty)
+actions_command (const char *args, int from_tty)
{
struct tracepoint *t;
/* Reduce a collection list to string form (for gdb protocol). */
-char **
+std::vector<std::string>
collection_list::stringify ()
{
char temp_buf[2048];
int count;
- int ndx = 0;
- char *(*str_list)[];
char *end;
long i;
-
- count = 1 + 1 + m_memranges.size () + m_aexprs.size () + 1;
- str_list = (char *(*)[]) xmalloc (count * sizeof (char *));
+ std::vector<std::string> str_list;
if (m_strace_data)
{
printf_filtered ("\nCollecting static trace data\n");
end = temp_buf;
*end++ = 'L';
- (*str_list)[ndx] = savestring (temp_buf, end - temp_buf);
- ndx++;
+ str_list.emplace_back (temp_buf, end - temp_buf);
}
for (i = sizeof (m_regs_mask) - 1; i > 0; i--)
sprintf (end, "%02X", m_regs_mask[i]);
end += 2;
}
- (*str_list)[ndx] = xstrdup (temp_buf);
- ndx++;
+ str_list.emplace_back (temp_buf);
}
if (info_verbose)
printf_filtered ("\n");
}
if (count + 27 > MAX_AGENT_EXPR_LEN)
{
- (*str_list)[ndx] = savestring (temp_buf, count);
- ndx++;
+ str_list.emplace_back (temp_buf, count);
count = 0;
end = temp_buf;
}
QUIT; /* Allow user to bail out with ^C. */
if ((count + 10 + 2 * m_aexprs[i]->len) > MAX_AGENT_EXPR_LEN)
{
- (*str_list)[ndx] = savestring (temp_buf, count);
- ndx++;
+ str_list.emplace_back (temp_buf, count);
count = 0;
end = temp_buf;
}
if (count != 0)
{
- (*str_list)[ndx] = savestring (temp_buf, count);
- ndx++;
+ str_list.emplace_back (temp_buf, count);
count = 0;
end = temp_buf;
}
- (*str_list)[ndx] = NULL;
- if (ndx == 0)
- {
- xfree (str_list);
- return NULL;
- }
- else
- return *str_list;
+ return str_list;
}
/* Add the printed expression EXP to *LIST. */
/* Render all actions into gdb protocol. */
void
-encode_actions_rsp (struct bp_location *tloc, char ***tdp_actions,
- char ***stepping_actions)
+encode_actions_rsp (struct bp_location *tloc,
+ std::vector<std::string> *tdp_actions,
+ std::vector<std::string> *stepping_actions)
{
struct collection_list tracepoint_list, stepping_list;
- *tdp_actions = NULL;
- *stepping_actions = NULL;
-
encode_actions (tloc, &tracepoint_list, &stepping_list);
*tdp_actions = tracepoint_list.stringify ();
}
void
-start_tracing (char *notes)
+start_tracing (const char *notes)
{
VEC(breakpoint_p) *tp_vec = NULL;
int ix;
t->number_on_target = b->number;
for (loc = b->loc; loc; loc = loc->next)
- if (loc->probe.probe != NULL
- && loc->probe.probe->pops->set_semaphore != NULL)
- loc->probe.probe->pops->set_semaphore (loc->probe.probe,
- loc->probe.objfile,
- loc->gdbarch);
+ if (loc->probe.prob != NULL)
+ loc->probe.prob->set_semaphore (loc->probe.objfile,
+ loc->gdbarch);
if (bp_location_downloaded)
observer_notify_breakpoint_modified (b);
anybody else messing with the target. */
static void
-tstart_command (char *args, int from_tty)
+tstart_command (const char *args, int from_tty)
{
dont_repeat (); /* Like "run", dangerous to repeat accidentally. */
of the trace run's status. */
static void
-tstop_command (char *args, int from_tty)
+tstop_command (const char *args, int from_tty)
{
if (!current_trace_status ()->running)
error (_("Trace is not running."));
}
void
-stop_tracing (char *note)
+stop_tracing (const char *note)
{
int ret;
VEC(breakpoint_p) *tp_vec = NULL;
but we don't really care if this semaphore goes out of sync.
That's why we are decrementing it here, but not taking care
in other places. */
- if (loc->probe.probe != NULL
- && loc->probe.probe->pops->clear_semaphore != NULL)
- loc->probe.probe->pops->clear_semaphore (loc->probe.probe,
- loc->probe.objfile,
- loc->gdbarch);
+ if (loc->probe.prob != NULL)
+ loc->probe.prob->clear_semaphore (loc->probe.objfile,
+ loc->gdbarch);
}
}
/* tstatus command */
static void
-tstatus_command (char *args, int from_tty)
+tstatus_command (const char *args, int from_tty)
{
struct trace_status *ts = current_trace_status ();
int status, ix;
static void
tfind_command (const char *args, int from_tty)
{
- tfind_command_1 (const_cast<char *> (args), from_tty);
+ tfind_command_1 (args, from_tty);
}
/* tfind end */
/* info scope command: list the locals for a scope. */
static void
-info_scope_command (char *args_in, int from_tty)
+info_scope_command (const char *args_in, int from_tty)
{
struct symbol *sym;
struct bound_minimal_symbol msym;
/* The tdump command. */
static void
-tdump_command (char *args, int from_tty)
+tdump_command (const char *args, int from_tty)
{
int stepping_frame = 0;
struct bp_location *loc;
disconnects for some reason. */
static void
-set_disconnected_tracing (char *args, int from_tty,
+set_disconnected_tracing (const char *args, int from_tty,
struct cmd_list_element *c)
{
target_set_disconnected_tracing (disconnected_tracing);
}
static void
-set_circular_trace_buffer (char *args, int from_tty,
+set_circular_trace_buffer (const char *args, int from_tty,
struct cmd_list_element *c)
{
target_set_circular_trace_buffer (circular_trace_buffer);
}
static void
-set_trace_buffer_size (char *args, int from_tty,
+set_trace_buffer_size (const char *args, int from_tty,
struct cmd_list_element *c)
{
target_set_trace_buffer_size (trace_buffer_size);
}
static void
-set_trace_user (char *args, int from_tty,
+set_trace_user (const char *args, int from_tty,
struct cmd_list_element *c)
{
int ret;
}
static void
-set_trace_notes (char *args, int from_tty,
+set_trace_notes (const char *args, int from_tty,
struct cmd_list_element *c)
{
int ret;
}
static void
-set_trace_stop_notes (char *args, int from_tty,
+set_trace_stop_notes (const char *args, int from_tty,
struct cmd_list_element *c)
{
int ret;
}
static void
-info_static_tracepoint_markers_command (char *arg, int from_tty)
+info_static_tracepoint_markers_command (const char *arg, int from_tty)
{
VEC(static_tracepoint_marker_p) *markers;
struct cleanup *old_chain;
#if !defined(HAVE_LIBEXPAT)
-struct traceframe_info *
+struct std::unique_ptr<traceframe_info>
parse_traceframe_info (const char *tframe_info)
{
static int have_warned;
void *user_data, VEC(gdb_xml_value_s) *attributes)
{
struct traceframe_info *info = (struct traceframe_info *) user_data;
- struct mem_range *r = VEC_safe_push (mem_range_s, info->memory, NULL);
ULONGEST *start_p, *length_p;
start_p
length_p
= (ULONGEST *) xml_find_attribute (attributes, "length")->value;
- r->start = *start_p;
- r->length = *length_p;
+ info->memory.emplace_back (*start_p, *length_p);
}
/* Handle the start of a <tvar> element. */
= (const char *) xml_find_attribute (attributes, "id")->value;
int id = gdb_xml_parse_ulongest (parser, id_attrib);
- VEC_safe_push (int, info->tvars, id);
-}
-
-/* Discard the constructed trace frame info (if an error occurs). */
-
-static void
-free_result (void *p)
-{
- struct traceframe_info *result = (struct traceframe_info *) p;
-
- free_traceframe_info (result);
+ info->tvars.push_back (id);
}
/* The allowed elements and attributes for an XML memory map. */
/* Parse a traceframe-info XML document. */
-struct traceframe_info *
+traceframe_info_up
parse_traceframe_info (const char *tframe_info)
{
- struct traceframe_info *result;
- struct cleanup *back_to;
-
- result = XCNEW (struct traceframe_info);
- back_to = make_cleanup (free_result, result);
+ traceframe_info_up result (new traceframe_info);
if (gdb_xml_parse_quick (_("trace frame info"),
"traceframe-info.dtd", traceframe_info_elements,
- tframe_info, result) == 0)
- {
- /* Parsed successfully, keep the result. */
- discard_cleanups (back_to);
+ tframe_info, result.get ()) == 0)
+ return result;
- return result;
- }
-
- do_cleanups (back_to);
return NULL;
}
if (current_traceframe_info == NULL)
current_traceframe_info = target_traceframe_info ();
- return current_traceframe_info;
+ return current_traceframe_info.get ();
}
/* If the target supports the query, return in RESULT the set of
undefined. */
int
-traceframe_available_memory (VEC(mem_range_s) **result,
+traceframe_available_memory (std::vector<mem_range> *result,
CORE_ADDR memaddr, ULONGEST len)
{
struct traceframe_info *info = get_traceframe_info ();
if (info != NULL)
{
- struct mem_range *r;
- int i;
-
- *result = NULL;
+ result->clear ();
- for (i = 0; VEC_iterate (mem_range_s, info->memory, i, r); i++)
- if (mem_ranges_overlap (r->start, r->length, memaddr, len))
+ for (mem_range &r : info->memory)
+ if (mem_ranges_overlap (r.start, r.length, memaddr, len))
{
ULONGEST lo1, hi1, lo2, hi2;
- struct mem_range *nr;
lo1 = memaddr;
hi1 = memaddr + len;
- lo2 = r->start;
- hi2 = r->start + r->length;
+ lo2 = r.start;
+ hi2 = r.start + r.length;
- nr = VEC_safe_push (mem_range_s, *result, NULL);
+ CORE_ADDR start = std::max (lo1, lo2);
+ int length = std::min (hi1, hi2) - start;
- nr->start = std::max (lo1, lo2);
- nr->length = std::min (hi1, hi2) - nr->start;
+ result->emplace_back (start, length);
}
- normalize_mem_ranges (*result);
+ normalize_mem_ranges (result);
return 1;
}