/* Everything about breakpoints, for GDB.
- Copyright (C) 1986-2017 Free Software Foundation, Inc.
+ Copyright (C) 1986-2018 Free Software Foundation, Inc.
This file is part of GDB.
#include "block.h"
#include "solib.h"
#include "solist.h"
-#include "observer.h"
+#include "observable.h"
#include "memattr.h"
#include "ada-lang.h"
#include "top.h"
(struct breakpoint *b, const struct event_location *location,
struct program_space *search_pspace);
-static int can_use_hardware_watchpoint (struct value *);
+static int can_use_hardware_watchpoint
+ (const std::vector<value_ref_ptr> &vals);
static void mention (struct breakpoint *);
{
struct watchpoint *w = (struct watchpoint *) b;
- innermost_block = NULL;
+ innermost_block.reset ();
arg = exp;
w->cond_exp = parse_exp_1 (&arg, 0, 0, 0);
if (*arg)
error (_("Junk at end of expression"));
- w->cond_exp_valid_block = innermost_block;
+ w->cond_exp_valid_block = innermost_block.block ();
}
else
{
}
mark_breakpoint_modified (b);
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
/* Completion for the "condition" command. */
{
int len;
struct breakpoint *b;
- VEC (char_ptr) *result = NULL;
if (text[0] == '$')
{
validate_commands_for_breakpoint (b, commands.get ());
b->commands = std::move (commands);
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
/* Set the internal `silent' flag on the breakpoint. Note that this
b->silent = silent;
if (old_silent != silent)
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
/* Set the thread for this breakpoint. If THREAD is -1, make the
b->thread = thread;
if (old_thread != thread)
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
/* Set the task for this breakpoint. If TASK is 0, make the
b->task = task;
if (old_task != task)
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
void
{
validate_commands_for_breakpoint (b, cmd.get ());
b->commands = cmd;
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
});
-
- if (cmd == NULL)
- error (_("No breakpoints specified."));
}
static void
no longer relevant. We don't want to report a watchpoint hit
to the user when the old value and the new value may actually
be completely different objects. */
- value_free (b->val);
b->val = NULL;
b->val_valid = 0;
else if (within_current_scope && b->exp)
{
int pc = 0;
- struct value *val_chain, *v, *result, *next;
+ std::vector<value_ref_ptr> val_chain;
+ struct value *v, *result, *next;
struct program_space *frame_pspace;
fetch_subexp_value (b->exp.get (), &pc, &v, &result, &val_chain, 0);
if (!b->val_valid && !is_masked_watchpoint (b))
{
if (b->val_bitsize != 0)
- {
- v = extract_bitfield_from_watchpoint_value (b, v);
- if (v != NULL)
- release_value (v);
- }
- b->val = v;
+ v = extract_bitfield_from_watchpoint_value (b, v);
+ b->val = release_value (v);
b->val_valid = 1;
}
frame_pspace = get_frame_program_space (get_selected_frame (NULL));
/* Look at each value on the value chain. */
- for (v = val_chain; v; v = value_next (v))
+ gdb_assert (!val_chain.empty ());
+ for (const value_ref_ptr &iter : val_chain)
{
+ v = iter.get ();
+
/* If it's a memory location, and GDB actually needed
its contents to evaluate the expression, then we
must watch it. If the first value returned is
still lazy, that means an error occurred reading it;
watch it anyway in case it becomes readable. */
if (VALUE_LVAL (v) == lval_memory
- && (v == val_chain || ! value_lazy (v)))
+ && (v == val_chain[0] || ! value_lazy (v)))
{
struct type *vtype = check_typedef (value_type (v));
loc->gdbarch = get_type_arch (value_type (v));
loc->pspace = frame_pspace;
- loc->address = addr;
+ loc->address = address_significant (loc->gdbarch, addr);
if (bitsize != 0)
{
bl->loc_type = loc_type;
}
- for (v = val_chain; v; v = next)
- {
- next = value_next (v);
- if (v != b->val)
- value_free (v);
- }
-
/* If a software watchpoint is not watching any memory, then the
above left it without any location set up. But,
bpstat_stop_status requires a location to be able to report
static agent_expr_up
parse_cmd_to_aexpr (CORE_ADDR scope, char *cmd)
{
- struct cleanup *old_cleanups = 0;
- struct expression **argvec;
const char *cmdrest;
const char *format_start, *format_end;
- struct format_piece *fpieces;
- int nargs;
struct gdbarch *gdbarch = get_current_arch ();
if (cmd == NULL)
format_start = cmdrest;
- fpieces = parse_format_string (&cmdrest);
-
- old_cleanups = make_cleanup (free_format_pieces_cleanup, &fpieces);
+ format_pieces fpieces (&cmdrest);
format_end = cmdrest;
/* For each argument, make an expression. */
- argvec = (struct expression **) alloca (strlen (cmd)
- * sizeof (struct expression *));
-
- nargs = 0;
+ std::vector<struct expression *> argvec;
while (*cmdrest != '\0')
{
const char *cmd1;
cmd1 = cmdrest;
expression_up expr = parse_exp_1 (&cmd1, scope, block_for_pc (scope), 1);
- argvec[nargs++] = expr.release ();
+ argvec.push_back (expr.release ());
cmdrest = cmd1;
if (*cmdrest == ',')
++cmdrest;
{
aexpr = gen_printf (scope, gdbarch, 0, 0,
format_start, format_end - format_start,
- fpieces, nargs, argvec);
+ argvec.size (), argvec.data ());
}
CATCH (ex, RETURN_MASK_ERROR)
{
}
END_CATCH
- do_cleanups (old_cleanups);
-
/* We have a valid agent expression, return it. */
return aexpr;
}
{
/* See also: disable_breakpoints_in_shlibs. */
bl->shlib_disabled = 1;
- observer_notify_breakpoint_modified (bl->owner);
+ gdb::observers::breakpoint_modified.notify (bl->owner);
if (!*disabled_breaks)
{
fprintf_unfiltered (tmp_error_stream,
/* We are only interested in checking one element. */
probe *p = ret[0];
- if (!can_evaluate_probe_arguments (p))
+ if (!p->can_evaluate_arguments ())
{
/* We cannot use the probe interface here, because it does
not know how to evaluate arguments. */
struct breakpoint *b;
b = create_internal_breakpoint (gdbarch,
- get_probe_address (p, objfile),
+ p->get_relocated_address (objfile),
bp_longjmp_master,
&internal_breakpoint_ops);
b->location = new_probe_location ("-probe-stap libc:longjmp");
/* We are only interested in checking one element. */
probe *p = ret[0];
- if (!can_evaluate_probe_arguments (p))
+ if (!p->can_evaluate_arguments ())
{
/* We cannot use the probe interface here, because it does
not know how to evaluate arguments. */
struct breakpoint *b;
b = create_internal_breakpoint (gdbarch,
- get_probe_address (p, objfile),
+ p->get_relocated_address (objfile),
bp_exception_master,
&internal_breakpoint_ops);
b->location = new_probe_location ("-probe-stap libgcc:unwind");
{
/* Reset val field to force reread of starting value in
insert_breakpoints. */
- if (w->val)
- value_free (w->val);
- w->val = NULL;
+ w->val.reset (nullptr);
w->val_valid = 0;
}
}
bpstats::~bpstats ()
{
- if (old_val != NULL)
- value_free (old_val);
if (bp_location_at != NULL)
decref_bp_location (&bp_location_at);
}
bp_location_at (other.bp_location_at),
breakpoint_at (other.breakpoint_at),
commands (other.commands),
- old_val (other.old_val),
print (other.print),
stop (other.stop),
print_it (other.print_it)
{
- if (old_val != NULL)
- {
- old_val = value_copy (old_val);
- release_value (old_val);
- }
+ if (other.old_val != NULL)
+ old_val = release_value (value_copy (other.old_val.get ()));
incref_bp_location (bp_location_at);
}
for (bs = tp->control.stop_bpstat; bs != NULL; bs = bs->next)
{
bs->commands = NULL;
-
- if (bs->old_val != NULL)
- {
- value_free (bs->old_val);
- bs->old_val = NULL;
- }
+ bs->old_val.reset (nullptr);
}
}
static void
print_solib_event (int is_catchpoint)
{
- int any_deleted
- = !VEC_empty (char_ptr, current_program_space->deleted_solibs);
+ bool any_deleted = !current_program_space->deleted_solibs.empty ();
int any_added
= !VEC_empty (so_list_ptr, current_program_space->added_solibs);
if (any_deleted)
{
- char *name;
- int ix;
-
current_uiout->text (_(" Inferior unloaded "));
ui_out_emit_list list_emitter (current_uiout, "removed");
- for (ix = 0;
- VEC_iterate (char_ptr, current_program_space->deleted_solibs,
- ix, name);
- ++ix)
+ for (int ix = 0; ix < current_program_space->deleted_solibs.size (); ix++)
{
+ const std::string &name = current_program_space->deleted_solibs[ix];
+
if (ix > 0)
current_uiout->text (" ");
current_uiout->field_string ("library", name);
bp_location_at (bl),
breakpoint_at (bl->owner),
commands (NULL),
- old_val (NULL),
print (0),
stop (0),
print_it (print_it_normal)
bp_location_at (NULL),
breakpoint_at (NULL),
commands (NULL),
- old_val (NULL),
print (0),
stop (0),
print_it (print_it_normal)
the address of the array instead of its contents. This is
not what we want. */
if ((b->val != NULL) != (new_val != NULL)
- || (b->val != NULL && !value_equal_contents (b->val, new_val)))
+ || (b->val != NULL && !value_equal_contents (b->val.get (),
+ new_val)))
{
- if (new_val != NULL)
- {
- release_value (new_val);
- value_free_to_mark (mark);
- }
bs->old_val = b->val;
- b->val = new_val;
+ b->val = release_value (new_val);
b->val_valid = 1;
+ if (new_val != NULL)
+ value_free_to_mark (mark);
return WP_VALUE_CHANGED;
}
else
bs->stop = 0;
/* Increase the hit count even though we don't stop. */
++(b->hit_count);
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
}
if (bs->stop)
{
++(b->hit_count);
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
/* We will stop here. */
if (b->disposition == disp_disable)
adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr, enum bptype bptype)
{
- if (!gdbarch_adjust_breakpoint_address_p (gdbarch))
- {
- /* Very few targets need any kind of breakpoint adjustment. */
- return bpaddr;
- }
- else if (bptype == bp_watchpoint
- || bptype == bp_hardware_watchpoint
- || bptype == bp_read_watchpoint
- || bptype == bp_access_watchpoint
- || bptype == bp_catchpoint)
+ if (bptype == bp_watchpoint
+ || bptype == bp_hardware_watchpoint
+ || bptype == bp_read_watchpoint
+ || bptype == bp_access_watchpoint
+ || bptype == bp_catchpoint)
{
/* Watchpoints and the various bp_catch_* eventpoints should not
have their addresses modified. */
}
else
{
- CORE_ADDR adjusted_bpaddr;
+ CORE_ADDR adjusted_bpaddr = bpaddr;
- /* Some targets have architectural constraints on the placement
- of breakpoint instructions. Obtain the adjusted address. */
- adjusted_bpaddr = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
+ if (gdbarch_adjust_breakpoint_address_p (gdbarch))
+ {
+ /* Some targets have architectural constraints on the placement
+ of breakpoint instructions. Obtain the adjusted address. */
+ adjusted_bpaddr = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
+ }
+
+ adjusted_bpaddr = address_significant (gdbarch, adjusted_bpaddr);
/* An adjusted breakpoint address can significantly alter
a user's expectations. Print a warning if an adjustment
loc->inserted = 0;
/* This may cause duplicate notifications for the same breakpoint. */
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
if (!disabled_shlib_breaks)
{
}
if (bp_modified)
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
}
{
struct solib_catchpoint *self
= (struct solib_catchpoint *) bs->breakpoint_at;
- int ix;
if (self->is_load)
{
struct so_list *iter;
- for (ix = 0;
+ for (int ix = 0;
VEC_iterate (so_list_ptr, current_program_space->added_solibs,
ix, iter);
++ix)
}
else
{
- char *iter;
-
- for (ix = 0;
- VEC_iterate (char_ptr, current_program_space->deleted_solibs,
- ix, iter);
- ++ix)
+ for (const std::string &iter : current_program_space->deleted_solibs)
{
if (!self->regex
- || self->compiled->exec (iter, 0, NULL, 0) == 0)
+ || self->compiled->exec (iter.c_str (), 0, NULL, 0) == 0)
return;
}
}
set_tracepoint_count (breakpoint_count);
if (!internal)
mention (b);
- observer_notify_breakpoint_created (b);
+ gdb::observers::breakpoint_created.notify (b);
if (update_gll)
update_global_location_list (UGLL_MAY_INSERT);
loc->requested_address = sal->pc;
loc->address = adjusted_address;
loc->pspace = sal->pspace;
- loc->probe.probe = sal->probe;
+ loc->probe.prob = sal->prob;
loc->probe.objfile = sal->objfile;
gdb_assert (loc->pspace != NULL);
loc->section = sal->section;
const char *p
= &event_location_to_string (b->location.get ())[3];
const char *endp;
- char *marker_str;
p = skip_spaces (p);
endp = skip_to_space (p);
- marker_str = savestring (p, endp - p);
- t->static_trace_marker_id = marker_str;
+ t->static_trace_marker_id.assign (p, endp - p);
printf_filtered (_("Probed static tracepoint "
"marker \"%s\"\n"),
- t->static_trace_marker_id);
+ t->static_trace_marker_id.c_str ());
}
else if (target_static_tracepoint_marker_at (sal.pc, &marker))
{
- t->static_trace_marker_id = xstrdup (marker.str_id);
- release_static_tracepoint_marker (&marker);
+ t->static_trace_marker_id = std::move (marker.str_id);
printf_filtered (_("Probed static tracepoint "
"marker \"%s\"\n"),
- t->static_trace_marker_id);
+ t->static_trace_marker_id.c_str ());
}
else
warning (_("Couldn't determine the static "
if (event_location_type (location) == LINESPEC_LOCATION)
{
- const char *address = get_linespec_location (location);
+ const char *spec = get_linespec_location (location)->spec_string;
- if (address == NULL)
+ if (spec == NULL)
{
/* The last displayed codepoint, if it's valid, is our default
breakpoint address. */
cursal = get_current_source_symtab_and_line ();
if (last_displayed_sal_is_valid ())
{
- const char *address = NULL;
+ const char *spec = NULL;
if (event_location_type (location) == LINESPEC_LOCATION)
- address = get_linespec_location (location);
+ spec = get_linespec_location (location)->spec_string;
if (!cursal.symtab
- || (address != NULL
- && strchr ("+-", address[0]) != NULL
- && address[1] != '['))
+ || (spec != NULL
+ && strchr ("+-", spec[0]) != NULL
+ && spec[1] != '['))
{
decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL,
get_last_displayed_symtab (),
check_fast_tracepoint_sals (struct gdbarch *gdbarch,
gdb::array_view<const symtab_and_line> sals)
{
- int rslt;
- char *msg;
- struct cleanup *old_chain;
-
for (const auto &sal : sals)
{
struct gdbarch *sarch;
associated with SAL. */
if (sarch == NULL)
sarch = gdbarch;
- rslt = gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg);
- old_chain = make_cleanup (xfree, msg);
-
- if (!rslt)
+ std::string msg;
+ if (!gdbarch_fast_tracepoint_valid_at (sarch, sal.pc, &msg))
error (_("May not have a fast tracepoint at %s%s"),
- paddress (sarch, sal.pc), (msg ? msg : ""));
-
- do_cleanups (old_chain);
+ paddress (sarch, sal.pc), msg.c_str ());
}
}
static std::vector<symtab_and_line>
decode_static_tracepoint_spec (const char **arg_p)
{
- VEC(static_tracepoint_marker_p) *markers = NULL;
const char *p = &(*arg_p)[3];
const char *endp;
- int i;
p = skip_spaces (p);
std::string marker_str (p, endp - p);
- markers = target_static_tracepoint_markers_by_strid (marker_str.c_str ());
- if (VEC_empty(static_tracepoint_marker_p, markers))
+ std::vector<static_tracepoint_marker> markers
+ = target_static_tracepoint_markers_by_strid (marker_str.c_str ());
+ if (markers.empty ())
error (_("No known static tracepoint marker named %s"),
marker_str.c_str ());
std::vector<symtab_and_line> sals;
- sals.reserve (VEC_length(static_tracepoint_marker_p, markers));
+ sals.reserve (markers.size ());
- for (i = 0; i < VEC_length(static_tracepoint_marker_p, markers); i++)
+ for (const static_tracepoint_marker &marker : markers)
{
- struct static_tracepoint_marker *marker;
-
- marker = VEC_index (static_tracepoint_marker_p, markers, i);
-
- symtab_and_line sal = find_pc_line (marker->address, 0);
- sal.pc = marker->address;
+ symtab_and_line sal = find_pc_line (marker.address, 0);
+ sal.pc = marker.address;
sals.push_back (sal);
-
- release_static_tracepoint_marker (marker);
- }
+ }
*arg_p = endp;
return sals;
b->loc->length = length;
mention (b);
- observer_notify_breakpoint_created (b);
+ gdb::observers::breakpoint_created.notify (b);
update_global_location_list (UGLL_MAY_INSERT);
}
{
xfree (this->exp_string);
xfree (this->exp_string_reparse);
- value_free (this->val);
}
/* Implement the "re_set" breakpoint_ops method for watchpoints. */
mention (b);
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nOld value = ");
- watchpoint_value_print (bs->old_val, &stb);
+ watchpoint_value_print (bs->old_val.get (), &stb);
uiout->field_stream ("old", stb);
uiout->text ("\nNew value = ");
- watchpoint_value_print (w->val, &stb);
+ watchpoint_value_print (w->val.get (), &stb);
uiout->field_stream ("new", stb);
uiout->text ("\n");
/* More than one watchpoint may have been triggered. */
mention (b);
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nValue = ");
- watchpoint_value_print (w->val, &stb);
+ watchpoint_value_print (w->val.get (), &stb);
uiout->field_stream ("value", stb);
uiout->text ("\n");
result = PRINT_UNKNOWN;
mention (b);
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nOld value = ");
- watchpoint_value_print (bs->old_val, &stb);
+ watchpoint_value_print (bs->old_val.get (), &stb);
uiout->field_stream ("old", stb);
uiout->text ("\nNew value = ");
}
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nValue = ");
}
- watchpoint_value_print (w->val, &stb);
+ watchpoint_value_print (w->val.get (), &stb);
uiout->field_stream ("new", stb);
uiout->text ("\n");
result = PRINT_UNKNOWN;
{
struct breakpoint *scope_breakpoint = NULL;
const struct block *exp_valid_block = NULL, *cond_exp_valid_block = NULL;
- struct value *val, *mark, *result;
+ struct value *mark, *result;
int saved_bitpos = 0, saved_bitsize = 0;
const char *exp_start = NULL;
const char *exp_end = NULL;
/* Parse the rest of the arguments. From here on out, everything
is in terms of a newly allocated string instead of the original
ARG. */
- innermost_block = NULL;
+ innermost_block.reset ();
std::string expression (arg, exp_end - arg);
exp_start = arg = expression.c_str ();
expression_up exp = parse_exp_1 (&arg, 0, 0, 0);
error (_("Cannot watch constant value `%.*s'."), len, exp_start);
}
- exp_valid_block = innermost_block;
+ exp_valid_block = innermost_block.block ();
mark = value_mark ();
- fetch_subexp_value (exp.get (), &pc, &val, &result, NULL, just_location);
+ struct value *val_as_value = nullptr;
+ fetch_subexp_value (exp.get (), &pc, &val_as_value, &result, NULL,
+ just_location);
- if (val != NULL && just_location)
+ if (val_as_value != NULL && just_location)
{
- saved_bitpos = value_bitpos (val);
- saved_bitsize = value_bitsize (val);
+ saved_bitpos = value_bitpos (val_as_value);
+ saved_bitsize = value_bitsize (val_as_value);
}
+ value_ref_ptr val;
if (just_location)
{
int ret;
exp_valid_block = NULL;
- val = value_addr (result);
- release_value (val);
+ val = release_value (value_addr (result));
value_free_to_mark (mark);
if (use_mask)
{
- ret = target_masked_watch_num_registers (value_as_address (val),
+ ret = target_masked_watch_num_registers (value_as_address (val.get ()),
mask);
if (ret == -1)
error (_("This target does not support masked watchpoints."));
error (_("Invalid mask or memory region."));
}
}
- else if (val != NULL)
- release_value (val);
+ else if (val_as_value != NULL)
+ val = release_value (val_as_value);
tok = skip_spaces (arg);
end_tok = skip_to_space (tok);
toklen = end_tok - tok;
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
- innermost_block = NULL;
+ innermost_block.reset ();
tok = cond_start = end_tok + 1;
parse_exp_1 (&tok, 0, 0, 0);
/* The watchpoint expression may not be local, but the condition
may still be. E.g.: `watch global if local > 0'. */
- cond_exp_valid_block = innermost_block;
+ cond_exp_valid_block = innermost_block.block ();
cond_end = tok;
}
w->cond_exp_valid_block = cond_exp_valid_block;
if (just_location)
{
- struct type *t = value_type (val);
- CORE_ADDR addr = value_as_address (val);
+ struct type *t = value_type (val.get ());
+ CORE_ADDR addr = value_as_address (val.get ());
w->exp_string_reparse
= current_language->la_watch_location_expression (t, addr).release ();
If the watchpoint cannot be handled in hardware return zero. */
static int
-can_use_hardware_watchpoint (struct value *v)
+can_use_hardware_watchpoint (const std::vector<value_ref_ptr> &vals)
{
int found_memory_cnt = 0;
- struct value *head = v;
/* Did the user specifically forbid us to use hardware watchpoints? */
if (!can_use_hw_watchpoints)
return 0;
+ gdb_assert (!vals.empty ());
+ struct value *head = vals[0].get ();
+
/* Make sure that the value of the expression depends only upon
memory contents, and values computed from them within GDB. If we
find any register references or function calls, we can't use a
function calls are special in any way. So this function may not
notice that an expression involving an inferior function call
can't be watched with hardware watchpoints. FIXME. */
- for (; v; v = value_next (v))
+ for (const value_ref_ptr &iter : vals)
{
+ struct value *v = iter.get ();
+
if (VALUE_LVAL (v) == lval_memory)
{
if (v != head && value_lazy (v))
{
struct breakpoint *b;
int default_match;
- int i;
std::vector<symtab_and_line> decoded_sals;
symtab_and_line last_sal;
t = (struct tracepoint *) b;
t->number_on_target = b->number;
if (bp_location_downloaded)
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
}
{
/* The insertion was successful, now let's set the probe's semaphore
if needed. */
- if (bl->probe.probe->pops->set_semaphore != NULL)
- bl->probe.probe->pops->set_semaphore (bl->probe.probe,
- bl->probe.objfile,
- bl->gdbarch);
+ bl->probe.prob->set_semaphore (bl->probe.objfile, bl->gdbarch);
}
return v;
enum remove_bp_reason reason)
{
/* Let's clear the semaphore before removing the location. */
- if (bl->probe.probe->pops->clear_semaphore != NULL)
- bl->probe.probe->pops->clear_semaphore (bl->probe.probe,
- bl->probe.objfile,
- bl->gdbarch);
+ bl->probe.prob->clear_semaphore (bl->probe.objfile, bl->gdbarch);
return bkpt_remove_location (bl, reason);
}
struct ui_out *uiout)
{
struct tracepoint *tp = (struct tracepoint *) self;
- if (tp->static_trace_marker_id)
+ if (!tp->static_trace_marker_id.empty ())
{
gdb_assert (self->type == bp_static_tracepoint);
struct linespec_sals lsal;
const char *arg_start, *arg;
- arg = arg_start = get_linespec_location (location);
+ arg = arg_start = get_linespec_location (location)->spec_string;
lsal.sals = decode_static_tracepoint_spec (&arg);
std::string str (arg_start, arg - arg_start);
const char *ptr = str.c_str ();
- canonical->location = new_linespec_location (&ptr);
+ canonical->location
+ = new_linespec_location (&ptr, symbol_name_match_type::FULL);
lsal.canonical
= xstrdup (event_location_to_string (canonical->location.get ()));
struct program_space *search_pspace)
{
struct tracepoint *tp = (struct tracepoint *) b;
- const char *s = get_linespec_location (location);
+ const char *s = get_linespec_location (location)->spec_string;
std::vector<symtab_and_line> sals = decode_static_tracepoint_spec (&s);
if (sals.size () > tp->static_trace_marker_id_idx)
return sals;
}
else
- error (_("marker %s not found"), tp->static_trace_marker_id);
+ error (_("marker %s not found"), tp->static_trace_marker_id.c_str ());
}
static struct breakpoint_ops strace_marker_breakpoint_ops;
a problem in that process, we'll be asked to delete the half-created
watchpoint. In that case, don't announce the deletion. */
if (bpt->number)
- observer_notify_breakpoint_deleted (bpt);
+ gdb::observers::breakpoint_deleted.notify (bpt);
if (breakpoint_chain == bpt)
breakpoint_chain = bpt->next;
ambiguous_names_p (struct bp_location *loc)
{
struct bp_location *l;
- htab_t htab = htab_create_alloc (13, htab_hash_string,
- (int (*) (const void *,
- const void *)) streq,
- NULL, xcalloc, xfree);
+ htab_t htab = htab_create_alloc (13, htab_hash_string, streq_hash, NULL,
+ xcalloc, xfree);
for (l = loc; l != NULL; l = l->next)
{
if (target_static_tracepoint_marker_at (pc, &marker))
{
- if (strcmp (tp->static_trace_marker_id, marker.str_id) != 0)
+ if (tp->static_trace_marker_id != marker.str_id)
warning (_("static tracepoint %d changed probed marker from %s to %s"),
- b->number,
- tp->static_trace_marker_id, marker.str_id);
+ b->number, tp->static_trace_marker_id.c_str (),
+ marker.str_id.c_str ());
- xfree (tp->static_trace_marker_id);
- tp->static_trace_marker_id = xstrdup (marker.str_id);
- release_static_tracepoint_marker (&marker);
+ tp->static_trace_marker_id = std::move (marker.str_id);
return sal;
}
if (!sal.explicit_pc
&& sal.line != 0
&& sal.symtab != NULL
- && tp->static_trace_marker_id != NULL)
+ && !tp->static_trace_marker_id.empty ())
{
- VEC(static_tracepoint_marker_p) *markers;
+ std::vector<static_tracepoint_marker> markers
+ = target_static_tracepoint_markers_by_strid
+ (tp->static_trace_marker_id.c_str ());
- markers
- = target_static_tracepoint_markers_by_strid (tp->static_trace_marker_id);
-
- if (!VEC_empty(static_tracepoint_marker_p, markers))
+ if (!markers.empty ())
{
struct symbol *sym;
struct static_tracepoint_marker *tpmarker;
struct ui_out *uiout = current_uiout;
struct explicit_location explicit_loc;
- tpmarker = VEC_index (static_tracepoint_marker_p, markers, 0);
+ tpmarker = &markers[0];
- xfree (tp->static_trace_marker_id);
- tp->static_trace_marker_id = xstrdup (tpmarker->str_id);
+ tp->static_trace_marker_id = std::move (tpmarker->str_id);
warning (_("marker for static tracepoint %d (%s) not "
"found at previous line number"),
- b->number, tp->static_trace_marker_id);
+ b->number, tp->static_trace_marker_id.c_str ());
symtab_and_line sal2 = find_pc_line (tpmarker->address, 0);
sym = find_pc_sect_function (tpmarker->address, NULL);
/* Might be nice to check if function changed, and warn if
so. */
-
- release_static_tracepoint_marker (tpmarker);
}
}
return sal;
gdb::array_view<const symtab_and_line> sals,
gdb::array_view<const symtab_and_line> sals_end)
{
- int i;
struct bp_location *existing_locations;
if (!sals_end.empty () && (sals.size () != 1 || sals_end.size () != 1))
}
if (!locations_are_equal (existing_locations, b->loc))
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
}
/* Find the SaL locations corresponding to the given LOCATION.
"crossings of breakpoint %d."),
count, bptnum);
}
- observer_notify_breakpoint_modified (b);
+ gdb::observers::breakpoint_modified.notify (b);
return;
}
update_global_location_list (UGLL_DONT_INSERT);
- observer_notify_breakpoint_modified (bpt);
+ gdb::observers::breakpoint_modified.notify (bpt);
}
/* Enable or disable the breakpoint(s) or breakpoint location(s)
bpt->enable_count = count;
update_global_location_list (UGLL_MAY_INSERT);
- observer_notify_breakpoint_modified (bpt);
+ gdb::observers::breakpoint_modified.notify (bpt);
}
{
struct watchpoint *wp = (struct watchpoint *) bp;
- if (wp->val_valid && wp->val)
+ if (wp->val_valid && wp->val != nullptr)
{
struct bp_location *loc;
&& loc->address + loc->length > addr
&& addr + len > loc->address)
{
- value_free (wp->val);
wp->val = NULL;
wp->val_valid = 0;
}
if (arg && startswith (arg, "-m") && isspace (arg[2]))
{
ops = &strace_marker_breakpoint_ops;
- location = new_linespec_location (&arg);
+ location = new_linespec_location (&arg, symbol_name_match_type::FULL);
}
else
{
static char *
read_uploaded_action (void)
{
- char *rslt;
-
- VEC_iterate (char_ptr, this_utp->cmd_strings, next_cmd, rslt);
+ char *rslt = nullptr;
- next_cmd++;
+ if (next_cmd < this_utp->cmd_strings.size ())
+ {
+ rslt = this_utp->cmd_strings[next_cmd];
+ next_cmd++;
+ }
return rslt;
}
special-purpose "reader" function and call the usual command line
reader, then pass the result to the breakpoint command-setting
function. */
- if (!VEC_empty (char_ptr, utp->cmd_strings))
+ if (!utp->cmd_strings.empty ())
{
command_line_up cmd_list;
breakpoint_set_commands (tp, std::move (cmd_list));
}
- else if (!VEC_empty (char_ptr, utp->actions)
- || !VEC_empty (char_ptr, utp->step_actions))
+ else if (!utp->actions.empty ()
+ || !utp->step_actions.empty ())
warning (_("Uploaded tracepoint %d actions "
"have no source form, ignoring them"),
utp->number);
trace_pass_set_count (struct tracepoint *tp, int count, int from_tty)
{
tp->pass_count = count;
- observer_notify_breakpoint_modified (tp);
+ gdb::observers::breakpoint_modified.notify (tp);
if (from_tty)
printf_filtered (_("Setting tracepoint %d's passcount to %d\n"),
tp->number, count);
syntax to specify location parameters.\n\
Example: To specify the start of the label named \"the_top\" in the\n\
function \"fact\" in the file \"factorial.c\", use \"-source factorial.c\n\
--function fact -label the_top\".\n"
+-function fact -label the_top\".\n\
+\n\
+By default, a specified function is matched against the program's\n\
+functions in all scopes. For C++, this means in all namespaces and\n\
+classes. For Ada, this means in all packages. E.g., in C++,\n\
+\"func()\" matches \"A::func()\", \"A::B::func()\", etc. The\n\
+\"-qualified\" flag overrides this behavior, making GDB interpret the\n\
+specified name as a complete fully-qualified name instead.\n"
/* This help string is used for the break, hbreak, tbreak and thbreak
commands. It is defined as a macro to prevent duplication.
initialize_breakpoint_ops ();
- observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib);
- observer_attach_free_objfile (disable_breakpoints_in_freed_objfile);
- observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
+ gdb::observers::solib_unloaded.attach (disable_breakpoints_in_unloaded_shlib);
+ gdb::observers::free_objfile.attach (disable_breakpoints_in_freed_objfile);
+ gdb::observers::memory_changed.attach (invalidate_bp_value_on_memory_change);
breakpoint_objfile_key
= register_objfile_data_with_cleanup (NULL, free_breakpoint_objfile_data);
automatic_hardware_breakpoints = 1;
- observer_attach_about_to_proceed (breakpoint_about_to_proceed);
- observer_attach_thread_exit (remove_threaded_breakpoints);
+ gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed);
+ gdb::observers::thread_exit.attach (remove_threaded_breakpoints);
}