/* Tracing functionality for remote targets in custom GDB protocol
- Copyright (C) 1997-2014 Free Software Foundation, Inc.
+ Copyright (C) 1997-2015 Free Software Foundation, Inc.
This file is part of GDB.
#include "target.h"
#include "target-dcache.h"
#include "language.h"
-#include <string.h>
#include "inferior.h"
#include "breakpoint.h"
#include "tracepoint.h"
#include "ax.h"
#include "ax-gdb.h"
#include "memrange.h"
-#include "exceptions.h"
#include "cli/cli-utils.h"
#include "probe.h"
#include "ctf.h"
#include "filestuff.h"
#include "rsp-low.h"
#include "tracefile.h"
+#include "location.h"
/* readline include files */
#include "readline/readline.h"
long frame_regno, long frame_offset, int type,
int trace_string)
{
- struct block *block;
+ const struct block *block;
struct add_local_symbols_data cb_data;
cb_data.collect = collect;
t->number_on_target = b->number;
for (loc = b->loc; loc; loc = loc->next)
- if (loc->probe.probe != NULL)
+ 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);
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)
+ 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);
{
sal = find_pc_line (get_frame_pc (get_current_frame ()), 0);
sals.nelts = 1;
- sals.sals = (struct symtab_and_line *)
- xmalloc (sizeof (struct symtab_and_line));
+ sals.sals = XNEW (struct symtab_and_line);
sals.sals[0] = sal;
}
else
struct symtabs_and_lines sals;
struct symbol *sym;
struct bound_minimal_symbol msym;
- struct block *block;
+ const struct block *block;
const char *symname;
char *save_args = args;
struct block_iterator iter;
int j, count = 0;
struct gdbarch *gdbarch;
int regno;
+ struct event_location *location;
+ struct cleanup *back_to;
if (args == 0 || *args == 0)
error (_("requires an argument (function, "
"line or *addr) to define a scope"));
- sals = decode_line_1 (&args, DECODE_LINE_FUNFIRSTLINE, NULL, 0);
+ location = string_to_event_location (&args, current_language);
+ back_to = make_cleanup_delete_event_location (location);
+ sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL, 0);
if (sals.nelts == 0)
- return; /* Presumably decode_line_1 has already warned. */
+ {
+ /* Presumably decode_line_1 has already warned. */
+ do_cleanups (back_to);
+ return;
+ }
/* Resolve line numbers to PC. */
resolve_sal_pc (&sals.sals[0]);
if (symname == NULL || *symname == '\0')
continue; /* Probably botched, certainly useless. */
- gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile);
+ gdbarch = symbol_arch (sym);
printf_filtered ("Symbol %s is ", symname);
if (count <= 0)
printf_filtered ("Scope for %s contains no locals or arguments.\n",
save_args);
+ do_cleanups (back_to);
}
/* Helper for trace_dump_command. Dump the action list starting at
make_cleanup (xfree, default_collect_line);
validate_actionline (default_collect_line, t);
- default_collect_action = xmalloc (sizeof (struct command_line));
+ default_collect_action = XNEW (struct command_line);
make_cleanup (xfree, default_collect_action);
default_collect_action->next = actions;
default_collect_action->line = default_collect_line;
extern int
encode_source_string (int tpnum, ULONGEST addr,
- char *srctype, char *src, char *buf, int buf_size)
+ char *srctype, const char *src, char *buf, int buf_size)
{
if (80 + strlen (srctype) > buf_size)
error (_("Buffer too small for source encoding"));
struct cleanup *
make_cleanup_restore_current_traceframe (void)
{
- struct current_traceframe_cleanup *old;
+ struct current_traceframe_cleanup *old =
+ XNEW (struct current_traceframe_cleanup);
- old = xmalloc (sizeof (struct current_traceframe_cleanup));
old->traceframe_number = traceframe_number;
return make_cleanup_dtor (do_restore_current_traceframe_cleanup, old,
for (utp = *utpp; utp; utp = utp->next)
if (utp->number == num && utp->addr == addr)
return utp;
- utp = (struct uploaded_tp *) xmalloc (sizeof (struct uploaded_tp));
- memset (utp, 0, sizeof (struct uploaded_tp));
+
+ utp = XCNEW (struct uploaded_tp);
utp->number = num;
utp->addr = addr;
utp->actions = NULL;
utp->cmd_strings = NULL;
utp->next = *utpp;
*utpp = utp;
+
return utp;
}
for (utsv = *utsvp; utsv; utsv = utsv->next)
if (utsv->number == num)
return utsv;
- utsv = (struct uploaded_tsv *) xmalloc (sizeof (struct uploaded_tsv));
- memset (utsv, 0, sizeof (struct uploaded_tsv));
+
+ utsv = XCNEW (struct uploaded_tsv);
utsv->number = num;
utsv->next = *utsvp;
*utsvp = utsv;
+
return utsv;
}
end = hex2bin (p, (gdb_byte *) buf, strlen (p) / 2);
buf[end] = '\0';
- if (strncmp (srctype, "at:", strlen ("at:")) == 0)
+ if (startswith (srctype, "at:"))
utp->at_string = xstrdup (buf);
- else if (strncmp (srctype, "cond:", strlen ("cond:")) == 0)
+ else if (startswith (srctype, "cond:"))
utp->cond_string = xstrdup (buf);
- else if (strncmp (srctype, "cmd:", strlen ("cmd:")) == 0)
+ else if (startswith (srctype, "cmd:"))
VEC_safe_push (char_ptr, utp->cmd_strings, xstrdup (buf));
}
else if (piece == 'V')