summaryrefslogtreecommitdiff
path: root/gdb/break-catch-throw.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/break-catch-throw.c')
-rw-r--r--gdb/break-catch-throw.c156
1 files changed, 62 insertions, 94 deletions
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 15c290b0ad1..4b79e0ffcba 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -27,13 +27,13 @@
#include "valprint.h"
#include "cli/cli-utils.h"
#include "completer.h"
-#include "gdb_obstack.h"
+#include "gdbsupport/gdb_obstack.h"
#include "mi/mi-common.h"
#include "linespec.h"
#include "probe.h"
#include "objfiles.h"
#include "cp-abi.h"
-#include "gdb_regex.h"
+#include "gdbsupport/gdb_regex.h"
#include "cp-support.h"
#include "location.h"
#include "cli/cli-decode.h"
@@ -63,12 +63,26 @@ static const struct exception_names exception_functions[] =
{ "-probe-stap libstdcxx:catch", "__cxa_begin_catch" }
};
-static struct breakpoint_ops gnu_v3_exception_catchpoint_ops;
-
/* The type of an exception catchpoint. */
-struct exception_catchpoint : public breakpoint
+struct exception_catchpoint : public base_breakpoint
{
+ void re_set () override;
+ enum print_stop_action print_it (struct bpstat *bs) override;
+ bool print_one (struct bp_location **) override;
+ void print_mention () override;
+ void print_recreate (struct ui_file *fp) override;
+ void print_one_detail (struct ui_out *) const override;
+ void check_status (struct bpstat *bs) override;
+ struct bp_location *allocate_location () override;
+
+ /* FIXME this is temporary - until ordinary breakpoints have been
+ converted. */
+ int resources_needed (const struct bp_location *) override
+ {
+ return 1;
+ }
+
/* The kind of exception catchpoint. */
enum exception_event_kind kind;
@@ -89,7 +103,7 @@ struct exception_catchpoint : public breakpoint
bool
is_exception_catchpoint (breakpoint *bp)
{
- return bp->ops == &gnu_v3_exception_catchpoint_ops;
+ return dynamic_cast<exception_catchpoint *> (bp) != nullptr;
}
@@ -130,27 +144,16 @@ fetch_probe_arguments (struct value **arg0, struct value **arg1)
-/* A helper function that returns a value indicating the kind of the
- exception catchpoint B. */
-
-static enum exception_event_kind
-classify_exception_breakpoint (struct breakpoint *b)
-{
- struct exception_catchpoint *cp = (struct exception_catchpoint *) b;
-
- return cp->kind;
-}
-
/* Implement the 'check_status' method. */
-static void
-check_status_exception_catchpoint (struct bpstat *bs)
+void
+exception_catchpoint::check_status (struct bpstat *bs)
{
struct exception_catchpoint *self
= (struct exception_catchpoint *) bs->breakpoint_at;
std::string type_name;
- bkpt_breakpoint_ops.check_status (bs);
+ this->breakpoint::check_status (bs);
if (bs->stop == 0)
return;
@@ -185,11 +188,10 @@ check_status_exception_catchpoint (struct bpstat *bs)
/* Implement the 're_set' method. */
-static void
-re_set_exception_catchpoint (struct breakpoint *self)
+void
+exception_catchpoint::re_set ()
{
std::vector<symtab_and_line> sals;
- enum exception_event_kind kind = classify_exception_breakpoint (self);
struct program_space *filter_pspace = current_program_space;
/* We first try to use the probe interface. */
@@ -211,8 +213,7 @@ re_set_exception_catchpoint (struct breakpoint *self)
explicit_loc.function_name
= ASTRDUP (exception_functions[kind].function);
event_location_up location = new_explicit_location (&explicit_loc);
- sals = self->ops->decode_location (self, location.get (),
- filter_pspace);
+ sals = this->decode_location (location.get (), filter_pspace);
}
catch (const gdb_exception_error &ex)
{
@@ -223,24 +224,22 @@ re_set_exception_catchpoint (struct breakpoint *self)
}
}
- update_breakpoint_locations (self, filter_pspace, sals, {});
+ update_breakpoint_locations (this, filter_pspace, sals, {});
}
-static enum print_stop_action
-print_it_exception_catchpoint (bpstat *bs)
+enum print_stop_action
+exception_catchpoint::print_it (bpstat *bs)
{
struct ui_out *uiout = current_uiout;
- struct breakpoint *b = bs->breakpoint_at;
int bp_temp;
- enum exception_event_kind kind = classify_exception_breakpoint (b);
- annotate_catchpoint (b->number);
+ annotate_catchpoint (number);
maybe_print_thread_hit_breakpoint (uiout);
- bp_temp = b->disposition == disp_del;
+ bp_temp = disposition == disp_del;
uiout->text (bp_temp ? "Temporary catchpoint "
: "Catchpoint ");
- uiout->field_signed ("bkptno", b->number);
+ uiout->field_signed ("bkptno", number);
uiout->text ((kind == EX_EVENT_THROW ? " (exception thrown), "
: (kind == EX_EVENT_CATCH ? " (exception caught), "
: " (exception rethrown), ")));
@@ -248,18 +247,16 @@ print_it_exception_catchpoint (bpstat *bs)
{
uiout->field_string ("reason",
async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
- uiout->field_string ("disp", bpdisp_text (b->disposition));
+ uiout->field_string ("disp", bpdisp_text (disposition));
}
return PRINT_SRC_AND_LOC;
}
-static void
-print_one_exception_catchpoint (struct breakpoint *b,
- struct bp_location **last_loc)
+bool
+exception_catchpoint::print_one (struct bp_location **last_loc)
{
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
- enum exception_event_kind kind = classify_exception_breakpoint (b);
get_user_print_options (&opts);
@@ -287,75 +284,70 @@ print_one_exception_catchpoint (struct breakpoint *b,
uiout->field_string ("catch-type", "catch");
break;
}
+
+ return true;
}
/* Implement the 'print_one_detail' method. */
-static void
-print_one_detail_exception_catchpoint (const struct breakpoint *b,
- struct ui_out *uiout)
+void
+exception_catchpoint::print_one_detail (struct ui_out *uiout) const
{
- const struct exception_catchpoint *cp
- = (const struct exception_catchpoint *) b;
-
- if (!cp->exception_rx.empty ())
+ if (!exception_rx.empty ())
{
uiout->text (_("\tmatching: "));
- uiout->field_string ("regexp", cp->exception_rx);
+ uiout->field_string ("regexp", exception_rx);
uiout->text ("\n");
}
}
-static void
-print_mention_exception_catchpoint (struct breakpoint *b)
+void
+exception_catchpoint::print_mention ()
{
struct ui_out *uiout = current_uiout;
int bp_temp;
- enum exception_event_kind kind = classify_exception_breakpoint (b);
- bp_temp = b->disposition == disp_del;
+ bp_temp = disposition == disp_del;
uiout->message ("%s %d %s",
(bp_temp ? _("Temporary catchpoint ") : _("Catchpoint")),
- b->number,
+ number,
(kind == EX_EVENT_THROW
? _("(throw)") : (kind == EX_EVENT_CATCH
? _("(catch)") : _("(rethrow)"))));
}
-/* Implement the "print_recreate" breakpoint_ops method for throw and
- catch catchpoints. */
+/* Implement the "print_recreate" method for throw and catch
+ catchpoints. */
-static void
-print_recreate_exception_catchpoint (struct breakpoint *b,
- struct ui_file *fp)
+void
+exception_catchpoint::print_recreate (struct ui_file *fp)
{
int bp_temp;
- enum exception_event_kind kind = classify_exception_breakpoint (b);
- bp_temp = b->disposition == disp_del;
- fprintf_unfiltered (fp, bp_temp ? "tcatch " : "catch ");
+ bp_temp = disposition == disp_del;
+ gdb_printf (fp, bp_temp ? "tcatch " : "catch ");
switch (kind)
{
case EX_EVENT_THROW:
- fprintf_unfiltered (fp, "throw");
+ gdb_printf (fp, "throw");
break;
case EX_EVENT_CATCH:
- fprintf_unfiltered (fp, "catch");
+ gdb_printf (fp, "catch");
break;
case EX_EVENT_RETHROW:
- fprintf_unfiltered (fp, "rethrow");
+ gdb_printf (fp, "rethrow");
break;
}
- print_recreate_thread (b, fp);
+ print_recreate_thread (this, fp);
}
-/* Implement the "allocate_location" breakpoint_ops method for throw
- and catch catchpoints. */
+/* Implement the "allocate_location" method for throw and catch
+ catchpoints. */
-static bp_location *
-allocate_location_exception_catchpoint (breakpoint *self)
+bp_location *
+exception_catchpoint::allocate_location ()
{
- return new bp_location (self, bp_loc_software_breakpoint);
+ return new bp_location (this, bp_loc_software_breakpoint);
}
static void
@@ -373,13 +365,12 @@ handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx,
std::unique_ptr<exception_catchpoint> cp (new exception_catchpoint ());
- init_catchpoint (cp.get (), get_current_arch (), tempflag, cond_string,
- &gnu_v3_exception_catchpoint_ops);
+ init_catchpoint (cp.get (), get_current_arch (), tempflag, cond_string);
cp->kind = ex_event;
cp->exception_rx = std::move (except_rx);
cp->pattern = std::move (pattern);
- re_set_exception_catchpoint (cp.get ());
+ cp->re_set ();
install_breakpoint (0, std::move (cp), 1);
}
@@ -510,37 +501,14 @@ static const struct internalvar_funcs exception_funcs =
{
compute_exception,
NULL,
- NULL
};
-static void
-initialize_throw_catchpoint_ops (void)
-{
- struct breakpoint_ops *ops;
-
- initialize_breakpoint_ops ();
-
- /* GNU v3 exception catchpoints. */
- ops = &gnu_v3_exception_catchpoint_ops;
- *ops = bkpt_breakpoint_ops;
- ops->re_set = re_set_exception_catchpoint;
- ops->print_it = print_it_exception_catchpoint;
- ops->print_one = print_one_exception_catchpoint;
- ops->print_mention = print_mention_exception_catchpoint;
- ops->print_recreate = print_recreate_exception_catchpoint;
- ops->print_one_detail = print_one_detail_exception_catchpoint;
- ops->check_status = check_status_exception_catchpoint;
- ops->allocate_location = allocate_location_exception_catchpoint;
-}
-
void _initialize_break_catch_throw ();
void
_initialize_break_catch_throw ()
{
- initialize_throw_catchpoint_ops ();
-
/* Add catch and tcatch sub-commands. */
add_catch_command ("catch", _("\
Catch an exception, when caught."),