#include "common/array-view.h"
#include "common/gdb_optional.h"
-/* Enums for exception-handling support. */
-enum exception_event_kind
-{
- EX_EVENT_THROW,
- EX_EVENT_RETHROW,
- EX_EVENT_CATCH
-};
-
/* Prototypes for local functions. */
static void map_breakpoint_numbers (const char *,
{
struct watchpoint *w = (struct watchpoint *) b;
- innermost_block.reset ();
+ innermost_block_tracker tracker;
arg = exp;
- w->cond_exp = parse_exp_1 (&arg, 0, 0, 0);
+ w->cond_exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
if (*arg)
error (_("Junk at end of expression"));
- w->cond_exp_valid_block = innermost_block.block ();
+ w->cond_exp_valid_block = tracker.block ();
}
else
{
xsnprintf (number, sizeof (number), "%d", b->number);
if (strncmp (number, text, len) == 0)
- {
- gdb::unique_xmalloc_ptr<char> copy (xstrdup (number));
- tracker.add_completion (std::move (copy));
- }
+ tracker.add_completion (make_unique_xstrdup (number));
}
return;
/* We don't want to stop processing, so catch any errors
that may show up. */
- TRY
+ try
{
aexpr = gen_eval_for_expr (scope, cond);
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
/* If we got here, it means the condition could not be parsed to a valid
bytecode expression and thus can't be evaluated on the target's side.
It's no use iterating through the conditions. */
}
- END_CATCH
/* We have a valid agent expression. */
return aexpr;
/* We don't want to stop processing, so catch any errors
that may show up. */
- TRY
+ try
{
aexpr = gen_printf (scope, gdbarch, 0, 0,
format_start, format_end - format_start,
argvec.size (), argvec.data ());
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
/* If we got here, it means the command could not be parsed to a valid
bytecode expression and thus can't be evaluated on the target's side.
It's no use iterating through the other commands. */
}
- END_CATCH
/* We have a valid agent expression, return it. */
return aexpr;
int *hw_breakpoint_error,
int *hw_bp_error_explained_already)
{
- gdb_exception bp_excpt = exception_none;
+ gdb_exception bp_excpt;
if (!should_be_inserted (bl) || (bl->inserted && !bl->needs_update))
return 0;
|| !(section_is_overlay (bl->section)))
{
/* No overlay handling: just set the breakpoint. */
- TRY
+ try
{
int val;
if (val)
bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR};
}
- CATCH (e, RETURN_MASK_ALL)
+ catch (gdb_exception &e)
{
- bp_excpt = e;
+ bp_excpt = std::move (e);
}
- END_CATCH
}
else
{
bl->overlay_target_info.reqstd_address = addr;
/* No overlay handling: just set the breakpoint. */
- TRY
+ try
{
int val;
bp_excpt
= gdb_exception {RETURN_ERROR, GENERIC_ERROR};
}
- CATCH (e, RETURN_MASK_ALL)
+ catch (gdb_exception &e)
{
- bp_excpt = e;
+ bp_excpt = std::move (e);
}
- END_CATCH
if (bp_excpt.reason != 0)
fprintf_unfiltered (tmp_error_stream,
if (section_is_mapped (bl->section))
{
/* Yes. This overlay section is mapped into memory. */
- TRY
+ try
{
int val;
if (val)
bp_excpt = gdb_exception {RETURN_ERROR, GENERIC_ERROR};
}
- CATCH (e, RETURN_MASK_ALL)
+ catch (gdb_exception &e)
{
- bp_excpt = e;
+ bp_excpt = std::move (e);
}
- END_CATCH
}
else
{
bp_excpt.message ? ":" : ".\n");
if (bp_excpt.message != NULL)
fprintf_unfiltered (tmp_error_stream, "%s.\n",
- bp_excpt.message);
+ bp_excpt.what ());
}
else
{
fprintf_unfiltered (tmp_error_stream,
"Cannot insert breakpoint %d: %s\n",
bl->owner->number,
- bp_excpt.message);
+ bp_excpt.what ());
}
}
return 1;
std::vector<probe *> exception_probes;
};
-static const struct objfile_data *breakpoint_objfile_key;
+static const struct objfile_key<breakpoint_objfile_data>
+ breakpoint_objfile_key;
/* Minimal symbol not found sentinel. */
static struct minimal_symbol msym_not_found;
{
struct breakpoint_objfile_data *bp_objfile_data;
- bp_objfile_data = ((struct breakpoint_objfile_data *)
- objfile_data (objfile, breakpoint_objfile_key));
+ bp_objfile_data = breakpoint_objfile_key.get (objfile);
if (bp_objfile_data == NULL)
- {
- bp_objfile_data = new breakpoint_objfile_data ();
- set_objfile_data (objfile, breakpoint_objfile_key, bp_objfile_data);
- }
+ bp_objfile_data = breakpoint_objfile_key.emplace (objfile);
return bp_objfile_data;
}
-static void
-free_breakpoint_objfile_data (struct objfile *obj, void *data)
-{
- struct breakpoint_objfile_data *bp_objfile_data
- = (struct breakpoint_objfile_data *) data;
-
- delete bp_objfile_data;
-}
-
static void
create_overlay_event_breakpoint (void)
{
{
wp_check_result e;
- TRY
+ try
{
e = watchpoint_check (bs);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
exception_fprintf (gdb_stderr, ex,
"Error evaluating expression "
watchpoint_del_at_next_stop (b);
e = WP_DELETED;
}
- END_CATCH
switch (e)
{
}
if (within_current_scope)
{
- TRY
+ try
{
condition_result = breakpoint_cond_eval (cond);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
exception_fprintf (gdb_stderr, ex,
"Error in testing breakpoint condition:\n");
}
- END_CATCH
}
else
{
}
}
+/* See breakpoint.h. */
+
+bool fix_multi_location_breakpoint_output_globally = false;
+
static void
print_one_breakpoint (struct breakpoint *b,
struct bp_location **last_loc,
int allflag)
{
struct ui_out *uiout = current_uiout;
- bool use_fixed_output = mi_multi_location_breakpoint_output_fixed (uiout);
+ bool use_fixed_output
+ = (uiout->test_flags (fix_multi_location_breakpoint_output)
+ || fix_multi_location_breakpoint_output_globally);
gdb::optional<ui_out_emit_tuple> bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt");
print_one_breakpoint_location (b, NULL, 0, last_loc, allflag);
if (extra_string != NULL && *extra_string == '\0')
extra_string = NULL;
- TRY
+ try
{
ops->create_sals_from_location (location, &canonical, type_wanted);
}
- CATCH (e, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &e)
{
/* If caller is interested in rc value from parse, set
value. */
error. */
if (pending_break_support == AUTO_BOOLEAN_FALSE)
- throw_exception (e);
+ throw;
exception_print (gdb_stderr, e);
pending = 1;
}
else
- throw_exception (e);
+ throw;
}
- END_CATCH
if (!pending && canonical.lsals.empty ())
return 0;
/* 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.reset ();
std::string expression (arg, exp_end - arg);
exp_start = arg = expression.c_str ();
- expression_up exp = parse_exp_1 (&arg, 0, 0, 0);
+ innermost_block_tracker tracker;
+ expression_up exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
exp_end = arg;
/* Remove trailing whitespace from the expression before saving it.
This makes the eventual display of the expression string a bit
error (_("Cannot watch constant value `%.*s'."), len, exp_start);
}
- exp_valid_block = innermost_block.block ();
+ exp_valid_block = tracker.block ();
struct value *mark = value_mark ();
struct value *val_as_value = nullptr;
fetch_subexp_value (exp.get (), &pc, &val_as_value, &result, NULL,
toklen = end_tok - tok;
if (toklen >= 1 && strncmp (tok, "if", toklen) == 0)
{
- innermost_block.reset ();
tok = cond_start = end_tok + 1;
- parse_exp_1 (&tok, 0, 0, 0);
+ innermost_block_tracker if_tracker;
+ parse_exp_1 (&tok, 0, 0, 0, &if_tracker);
/* 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.block ();
+ cond_exp_valid_block = if_tracker.block ();
cond_end = tok;
}
if (arg
&& (check_for_argument (&arg, "-location", sizeof ("-location") - 1)
|| check_for_argument (&arg, "-l", sizeof ("-l") - 1)))
- {
- arg = skip_spaces (arg);
- just_location = 1;
- }
+ just_location = 1;
watch_command_1 (arg, accessflag, from_tty, just_location, 0);
}
update_global_location_list_nothrow (enum ugll_insert_mode insert_mode)
{
- TRY
+ try
{
update_global_location_list (insert_mode);
}
- CATCH (e, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &e)
{
}
- END_CATCH
}
/* Clear BKP from a BPS. */
const char *s;
s = b->cond_string;
- TRY
+ try
{
new_loc->cond = parse_exp_1 (&s, sal.pc,
block_for_pc (sal.pc),
0);
}
- CATCH (e, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &e)
{
warning (_("failed to reevaluate condition "
"for breakpoint %d: %s"),
- b->number, e.message);
+ b->number, e.what ());
new_loc->enabled = 0;
}
- END_CATCH
}
if (!sals_end.empty ())
location_to_sals (struct breakpoint *b, struct event_location *location,
struct program_space *search_pspace, int *found)
{
- struct gdb_exception exception = exception_none;
+ struct gdb_exception exception;
gdb_assert (b->ops != NULL);
std::vector<symtab_and_line> sals;
- TRY
+ try
{
sals = b->ops->decode_location (b, location, search_pspace);
}
- CATCH (e, RETURN_MASK_ERROR)
+ catch (gdb_exception_error &e)
{
int not_found_and_ok = 0;
- exception = e;
-
/* For pending breakpoints, it's expected that parsing will
fail until the right shared library is loaded. User has
already told to create pending breakpoints and don't need
happens only when a binary has changed, I don't know
which approach is better. */
b->enable_state = bp_disabled;
- throw_exception (e);
+ throw;
}
+
+ exception = std::move (e);
}
- END_CATCH
if (exception.reason == 0 || exception.error != NOT_FOUND_ERROR)
{
ALL_BREAKPOINTS_SAFE (b, b_tmp)
{
- TRY
+ try
{
breakpoint_re_set_one (b);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
exception_fprintf (gdb_stderr, ex,
"Error in re-setting breakpoint %d: ",
b->number);
}
- END_CATCH
}
jit_breakpoint_re_set ();
/* Initialize it just to avoid a GCC false warning. */
enum enable_state orig_enable_state = bp_disabled;
- TRY
+ try
{
struct watchpoint *w = (struct watchpoint *) bpt;
bpt->enable_state = bp_enabled;
update_watchpoint (w, 1 /* reparse */);
}
- CATCH (e, RETURN_MASK_ALL)
+ catch (const gdb_exception &e)
{
bpt->enable_state = orig_enable_state;
exception_fprintf (gdb_stderr, e, _("Cannot enable watchpoint %d: "),
bpt->number);
return;
}
- END_CATCH
}
bpt->enable_state = bp_enabled;
fp.puts (" commands\n");
current_uiout->redirect (&fp);
- TRY
+ try
{
print_command_lines (current_uiout, tp->commands.get (), 2);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
current_uiout->redirect (NULL);
- throw_exception (ex);
+ throw;
}
- END_CATCH
current_uiout->redirect (NULL);
fp.puts (" end\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"
+specified name as a complete fully-qualified name instead."
/* This help string is used for the break, hbreak, tbreak and thbreak
commands. It is defined as a macro to prevent duplication.
\n\
THREADNUM is the number from \"info threads\".\n\
CONDITION is a boolean expression.\n\
-\n" LOCATION_HELP_STRING "\n\
+\n" LOCATION_HELP_STRING "\n\n\
Multiple breakpoints at one place are permitted, and useful if their\n\
conditions are different.\n\
\n\
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);
-
breakpoint_chain = 0;
/* Don't bother to call set_breakpoint_count. $bpnum isn't useful
before a breakpoint is set. */
Enable some breakpoints.\n\
Give breakpoint numbers (separated by spaces) as arguments.\n\
This is used to cancel the effect of the \"disable\" command.\n\
-May be abbreviated to simply \"enable\".\n"),
+May be abbreviated to simply \"enable\"."),
&enablebreaklist, "enable breakpoints ", 1, &enablelist);
add_cmd ("once", no_class, enable_once_command, _("\
\n\
With no argument, clears all breakpoints in the line that the selected frame\n\
is executing in.\n"
-"\n" LOCATION_HELP_STRING "\n\
+"\n" LOCATION_HELP_STRING "\n\n\
See also the \"delete\" command which clears breakpoints by number."));
add_com_alias ("cl", "clear", class_breakpoint, 1);
by printing the $_sdata variable like any other convenience variable.\n\
\n\
CONDITION is a boolean expression.\n\
-\n" LOCATION_HELP_STRING "\n\
+\n" LOCATION_HELP_STRING "\n\n\
Multiple tracepoints at one place are permitted, and useful if their\n\
conditions are different.\n\
\n\