struct exception_catchpoint : public breakpoint
{
- ~exception_catchpoint () override;
-
/* The kind of exception catchpoint. */
enum exception_event_kind kind;
- /* If non-NULL, an xmalloc'd string holding the source form of the
- regular expression to match against. */
+ /* If not empty, a string holding the source form of the regular
+ expression to match against. */
- char *exception_rx;
+ std::string exception_rx;
/* If non-NULL, a compiled regular expression which is used to
determine which exceptions to stop on. */
return cp->kind;
}
-/* exception_catchpoint destructor. */
-
-exception_catchpoint::~exception_catchpoint ()
-{
- xfree (this->exception_rx);
-}
-
/* Implement the 'check_status' method. */
static void
const struct exception_catchpoint *cp
= (const struct exception_catchpoint *) b;
- if (cp->exception_rx != NULL)
+ if (!cp->exception_rx.empty ())
{
uiout->text (_("\tmatching: "));
- uiout->field_string ("regexp", cp->exception_rx);
+ uiout->field_string ("regexp", cp->exception_rx.c_str ());
uiout->text ("\n");
}
}
}
static void
-handle_gnu_v3_exceptions (int tempflag, char *except_rx,
+handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx,
const char *cond_string,
enum exception_event_kind ex_event, int from_tty)
{
std::unique_ptr<compiled_regex> pattern;
- if (except_rx != NULL)
+ if (!except_rx.empty ())
{
- pattern.reset (new compiled_regex (except_rx, REG_NOSUB,
+ pattern.reset (new compiled_regex (except_rx.c_str (), REG_NOSUB,
_("invalid type-matching regexp")));
}
STRING is updated to point to the "if" token, if it exists, or to
the end of the string. */
-static char *
+static std::string
extract_exception_regexp (const char **string)
{
const char *start;
*string = last;
if (last_space > start)
- return savestring (start, last_space - start);
- return NULL;
+ return std::string (start, last_space - start);
+ return std::string ();
}
/* Deal with "catch catch", "catch throw", and "catch rethrow"
char *arg_entry,
int tempflag, int from_tty)
{
- char *except_rx;
const char *cond_string = NULL;
- struct cleanup *cleanup;
const char *arg = arg_entry;
if (!arg)
arg = "";
arg = skip_spaces_const (arg);
- except_rx = extract_exception_regexp (&arg);
- cleanup = make_cleanup (xfree, except_rx);
+ std::string except_rx = extract_exception_regexp (&arg);
cond_string = ep_parse_optional_if_clause (&arg);
&& ex_event != EX_EVENT_RETHROW)
error (_("Unsupported or unknown exception event; cannot catch it"));
- handle_gnu_v3_exceptions (tempflag, except_rx, cond_string,
+ handle_gnu_v3_exceptions (tempflag, std::move (except_rx), cond_string,
ex_event, from_tty);
-
- discard_cleanups (cleanup);
}
/* Implementation of "catch catch" command. */