From 56ecd069f031d6bcdaa46664c68a16cb27b379c3 Mon Sep 17 00:00:00 2001 From: Xavier Roirand Date: Thu, 25 Jan 2018 11:09:23 +0100 Subject: (Ada) C++fy conditional string when catching exception. This commit C++fy the conditional string used when catching Ada exception. gdb/ChangeLog: * ada-lang.c (catch_ada_exception_command_split) (create_ada_exception_catchpoint) : Change parameter type. Update code accordingly. (catch_ada_exception_command, catch_ada_handlers_command): Use C++ string instead of char* for conditional var. (catch_ada_assert_command_split) : Change parameter type. Update code accordingly. (catch_assert_command): Use C++ string instead of char* for conditional var. * ada-lang.h (create_ada_exception_catchpoint) : Update declaration. * mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception): Use std::string instead of char* for condition string. Tested on x86_64-linux. --- gdb/mi/mi-cmd-catch.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'gdb/mi') diff --git a/gdb/mi/mi-cmd-catch.c b/gdb/mi/mi-cmd-catch.c index 38b96cc..a0f311a 100644 --- a/gdb/mi/mi-cmd-catch.c +++ b/gdb/mi/mi-cmd-catch.c @@ -32,7 +32,7 @@ void mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) { struct gdbarch *gdbarch = get_current_arch(); - char *condition = NULL; + std::string condition; int enabled = 1; int temp = 0; @@ -62,7 +62,7 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) switch ((enum opt) opt) { case OPT_CONDITION: - condition = oarg; + condition.assign (oarg); break; case OPT_DISABLED: enabled = 0; @@ -79,10 +79,6 @@ mi_cmd_catch_assert (const char *cmd, char *argv[], int argc) error (_("Invalid argument: %s"), argv[oind]); scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); - /* create_ada_exception_catchpoint needs CONDITION to be xstrdup'ed, - and will assume control of its lifetime. */ - if (condition != NULL) - condition = xstrdup (condition); create_ada_exception_catchpoint (gdbarch, ada_catch_assert, NULL, condition, temp, enabled, 0); } @@ -93,7 +89,7 @@ void mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) { struct gdbarch *gdbarch = get_current_arch(); - char *condition = NULL; + std::string condition; int enabled = 1; char *exception_name = NULL; int temp = 0; @@ -128,7 +124,7 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) switch ((enum opt) opt) { case OPT_CONDITION: - condition = oarg; + condition.assign (oarg); break; case OPT_DISABLED: enabled = 0; @@ -156,12 +152,10 @@ mi_cmd_catch_exception (const char *cmd, char *argv[], int argc) error (_("\"-e\" and \"-u\" are mutually exclusive")); scoped_restore restore_breakpoint_reporting = setup_breakpoint_reporting (); - /* create_ada_exception_catchpoint needs EXCEPTION_NAME and CONDITION - to be xstrdup'ed, and will assume control of their lifetime. */ + /* create_ada_exception_catchpoint needs EXCEPTION_NAME to be + xstrdup'ed, and will assume control of its lifetime. */ if (exception_name != NULL) exception_name = xstrdup (exception_name); - if (condition != NULL) - condition = xstrdup (condition); create_ada_exception_catchpoint (gdbarch, ex_kind, exception_name, condition, temp, enabled, 0); -- cgit v1.1