Transfer ownership of exception string to ada_catchpoint

This changes the ada_catchpoint to require an rvalue ref, so that
ownership of the exception string can be transferred to the catchpoint
object.
This commit is contained in:
Tom Tromey
2023-02-16 10:46:04 -07:00
parent dc3f8fa94a
commit 898db0f75d
3 changed files with 12 additions and 10 deletions

View File

@@ -12066,8 +12066,10 @@ struct ada_catchpoint : public code_breakpoint
const char *addr_string_, const char *addr_string_,
bool tempflag, bool tempflag,
bool enabled, bool enabled,
bool from_tty) bool from_tty,
std::string &&excep_string_)
: code_breakpoint (gdbarch_, bp_catchpoint, tempflag), : code_breakpoint (gdbarch_, bp_catchpoint, tempflag),
excep_string (std::move (excep_string_)),
m_kind (kind) m_kind (kind)
{ {
add_location (sal); add_location (sal);
@@ -12732,7 +12734,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex,
void void
create_ada_exception_catchpoint (struct gdbarch *gdbarch, create_ada_exception_catchpoint (struct gdbarch *gdbarch,
enum ada_exception_catchpoint_kind ex_kind, enum ada_exception_catchpoint_kind ex_kind,
const std::string &excep_string, std::string &&excep_string,
const std::string &cond_string, const std::string &cond_string,
int tempflag, int tempflag,
int enabled, int enabled,
@@ -12743,8 +12745,8 @@ create_ada_exception_catchpoint (struct gdbarch *gdbarch,
std::unique_ptr<ada_catchpoint> c std::unique_ptr<ada_catchpoint> c
(new ada_catchpoint (gdbarch, ex_kind, sal, addr_string.c_str (), (new ada_catchpoint (gdbarch, ex_kind, sal, addr_string.c_str (),
tempflag, enabled, from_tty)); tempflag, enabled, from_tty,
c->excep_string = excep_string; std::move (excep_string)));
create_excep_cond_exprs (c.get (), ex_kind); create_excep_cond_exprs (c.get (), ex_kind);
if (!cond_string.empty ()) if (!cond_string.empty ())
set_breakpoint_condition (c.get (), cond_string.c_str (), from_tty, false); set_breakpoint_condition (c.get (), cond_string.c_str (), from_tty, false);
@@ -12771,7 +12773,7 @@ catch_ada_exception_command (const char *arg_entry, int from_tty,
catch_ada_exception_command_split (arg, false, &ex_kind, &excep_string, catch_ada_exception_command_split (arg, false, &ex_kind, &excep_string,
&cond_string); &cond_string);
create_ada_exception_catchpoint (gdbarch, ex_kind, create_ada_exception_catchpoint (gdbarch, ex_kind,
excep_string, cond_string, std::move (excep_string), cond_string,
tempflag, 1 /* enabled */, tempflag, 1 /* enabled */,
from_tty); from_tty);
} }
@@ -12796,7 +12798,7 @@ catch_ada_handlers_command (const char *arg_entry, int from_tty,
catch_ada_exception_command_split (arg, true, &ex_kind, &excep_string, catch_ada_exception_command_split (arg, true, &ex_kind, &excep_string,
&cond_string); &cond_string);
create_ada_exception_catchpoint (gdbarch, ex_kind, create_ada_exception_catchpoint (gdbarch, ex_kind,
excep_string, cond_string, std::move (excep_string), cond_string,
tempflag, 1 /* enabled */, tempflag, 1 /* enabled */,
from_tty); from_tty);
} }
@@ -12863,7 +12865,7 @@ catch_assert_command (const char *arg_entry, int from_tty,
arg = ""; arg = "";
catch_ada_assert_command_split (arg, cond_string); catch_ada_assert_command_split (arg, cond_string);
create_ada_exception_catchpoint (gdbarch, ada_catch_assert, create_ada_exception_catchpoint (gdbarch, ada_catch_assert,
"", cond_string, {}, cond_string,
tempflag, 1 /* enabled */, tempflag, 1 /* enabled */,
from_tty); from_tty);
} }

View File

@@ -341,7 +341,7 @@ extern const char *ada_main_name ();
extern void create_ada_exception_catchpoint extern void create_ada_exception_catchpoint
(struct gdbarch *gdbarch, enum ada_exception_catchpoint_kind ex_kind, (struct gdbarch *gdbarch, enum ada_exception_catchpoint_kind ex_kind,
const std::string &excep_string, const std::string &cond_string, int tempflag, std::string &&excep_string, const std::string &cond_string, int tempflag,
int enabled, int from_tty); int enabled, int from_tty);
/* Return true if BP is an Ada catchpoint. */ /* Return true if BP is an Ada catchpoint. */

View File

@@ -153,7 +153,7 @@ mi_cmd_catch_exception (const char *cmd, const char *const *argv, int argc)
scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting ();
create_ada_exception_catchpoint (gdbarch, ex_kind, create_ada_exception_catchpoint (gdbarch, ex_kind,
exception_name, std::move (exception_name),
condition, temp, enabled, 0); condition, temp, enabled, 0);
} }
@@ -217,7 +217,7 @@ mi_cmd_catch_handlers (const char *cmd, const char *const *argv, int argc)
scoped_restore restore_breakpoint_reporting scoped_restore restore_breakpoint_reporting
= setup_breakpoint_reporting (); = setup_breakpoint_reporting ();
create_ada_exception_catchpoint (gdbarch, ada_catch_handlers, create_ada_exception_catchpoint (gdbarch, ada_catch_handlers,
exception_name, std::move (exception_name),
condition, temp, enabled, 0); condition, temp, enabled, 0);
} }