aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-01-28 10:11:10 -0700
committerTom Tromey <tom@tromey.com>2019-04-08 09:05:38 -0600
commit3d6e9d2336c9ffcedb10f89631981a23dd518e8e (patch)
tree39663735f1d7848d067ea80bc23ee88c09aabc4a
parentc5c10118216867e133c132b4f46e19fb6aa9258a (diff)
downloadgdb-3d6e9d2336c9ffcedb10f89631981a23dd518e8e.zip
gdb-3d6e9d2336c9ffcedb10f89631981a23dd518e8e.tar.gz
gdb-3d6e9d2336c9ffcedb10f89631981a23dd518e8e.tar.bz2
Make exceptions use std::string and be self-managing
This changes the exception's "message" member to be a shared_ptr wrapping a std::string. This allows removing the stack of exception messages, because now exceptions will self-destruct when needed. This also adds a noexcept copy constructor and operator= to gdb_exception, plus a "what" method. gdb/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * xml-support.c (gdb_xml_parser::parse): Update. * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update. * value.c (show_convenience): Update. * unittests/cli-utils-selftests.c (test_number_or_range_parser) (test_parse_flags_qcs): Update. * thread.c (thr_try_catch_cmd): Update. * target.c (target_translate_tls_address): Update. * stack.c (print_frame_arg, read_frame_local, read_frame_arg) (info_frame_command_core, frame_apply_command_count): Update. * rust-exp.y (rust_lex_exception_test): Update. * riscv-tdep.c (riscv_print_one_register_info): Update. * remote.c (remote_target::enable_btrace): Update. * record-btrace.c (record_btrace_enable_warn): Update. * python/py-utils.c (gdbpy_convert_exception): Update. * printcmd.c (do_one_display, print_variable_and_value): Update. * mi/mi-main.c (mi_print_exception): Update. * mi/mi-interp.c (mi_cmd_interpreter_exec): Use SCOPE_EXIT. * mi/mi-cmd-stack.c (list_arg_or_local): Update. * linux-nat.c (linux_nat_target::attach): Update. * linux-fork.c (class scoped_switch_fork_info): Update. * infrun.c (displaced_step_prepare): Update. * infcall.c (call_function_by_hand_dummy): Update. * guile/scm-exception.c (gdbscm_scm_from_gdb_exception): Update. * gnu-v3-abi.c (print_one_vtable): Update. * frame.c (get_prev_frame_always): Update. * f-valprint.c (info_common_command_for_block): Update. * exec.c (try_open_exec_file): Update. * exceptions.c (print_exception, exception_print) (exception_fprintf, exception_print_same): Update. * dwarf2-frame.c (dwarf2_build_frame_info): Update. * dwarf-index-cache.c (index_cache::store) (index_cache::lookup_gdb_index): Update. * darwin-nat.c (maybe_cache_shell): Update. * cp-valprint.c (cp_print_value_fields): Update. * compile/compile-cplus-symbols.c (gcc_cplus_convert_symbol) (gcc_cplus_symbol_address): Update. * compile/compile-c-symbols.c (gcc_convert_symbol) (gcc_symbol_address, generate_c_for_for_one_variable): Update. * common/selftest.c: Update. * common/common-exceptions.h (struct gdb_exception) <message>: Now a std::string. (exception_try_scope_entry, exception_try_scope_exit): Don't declare. (struct exception_try_scope): Remove. (TRY): Don't use exception_try_scope. (struct gdb_exception): Add constructor, operator=. <what>: New method. (struct gdb_exception_RETURN_MASK_ALL) (struct gdb_exception_RETURN_MASK_ERROR) (struct gdb_exception_RETURN_MASK_QUIT): Add constructor. (struct gdb_quit_bad_alloc): Update. * common/common-exceptions.c (exception_none): Change initializer. (struct catcher) <state, exception>: Initialize inline. <prev>: Remove member. (current_catcher): Remove. (catchers): New global. (exceptions_state_mc_init): Simplify. (catcher_pop): Remove. (exceptions_state_mc, exceptions_state_mc_catch): Update. (try_scope_depth, exception_try_scope_entry) (exception_try_scope_exit): Remove. (throw_exception_sjlj): Update. (exception_messages, exception_messages_size): Remove. (throw_it): Simplify. (gdb_exception_sliced_copy): Remove. (throw_exception_cxx): Update. * cli/cli-script.c (script_from_file): Update. * breakpoint.c (insert_bp_location, update_breakpoint_locations): Update. * ada-valprint.c (ada_val_print): Update. * ada-lang.c (ada_to_fixed_type_1, ada_exception_name_addr) (create_excep_cond_exprs): Update. gdb/gdbserver/ChangeLog 2019-04-08 Tom Tromey <tom@tromey.com> * server.c (handle_btrace_general_set, handle_qxfer_btrace) (handle_qxfer_btrace_conf, detach_or_kill_for_exit_cleanup) (captured_main, main): Update. * gdbreplay.c (main): Update.
-rw-r--r--gdb/ChangeLog76
-rw-r--r--gdb/ada-lang.c6
-rw-r--r--gdb/ada-valprint.c2
-rw-r--r--gdb/breakpoint.c6
-rw-r--r--gdb/cli/cli-script.c3
-rw-r--r--gdb/common/common-exceptions.c133
-rw-r--r--gdb/common/common-exceptions.h81
-rw-r--r--gdb/common/selftest.c2
-rw-r--r--gdb/compile/compile-c-symbols.c6
-rw-r--r--gdb/compile/compile-cplus-symbols.c4
-rw-r--r--gdb/cp-valprint.c2
-rw-r--r--gdb/darwin-nat.c2
-rw-r--r--gdb/dwarf-index-cache.c4
-rw-r--r--gdb/dwarf2-frame.c4
-rw-r--r--gdb/exceptions.c11
-rw-r--r--gdb/exec.c12
-rw-r--r--gdb/f-valprint.c3
-rw-r--r--gdb/frame.c4
-rw-r--r--gdb/gdbserver/ChangeLog7
-rw-r--r--gdb/gdbserver/gdbreplay.c2
-rw-r--r--gdb/gdbserver/server.c13
-rw-r--r--gdb/gnu-v3-abi.c2
-rw-r--r--gdb/guile/scm-exception.c2
-rw-r--r--gdb/infcall.c2
-rw-r--r--gdb/infrun.c4
-rw-r--r--gdb/linux-fork.c3
-rw-r--r--gdb/linux-nat.c5
-rw-r--r--gdb/mi/mi-cmd-stack.c9
-rw-r--r--gdb/mi/mi-interp.c17
-rw-r--r--gdb/mi/mi-main.c2
-rw-r--r--gdb/printcmd.c11
-rw-r--r--gdb/python/py-utils.c2
-rw-r--r--gdb/record-btrace.c2
-rw-r--r--gdb/remote.c2
-rw-r--r--gdb/riscv-tdep.c2
-rw-r--r--gdb/rust-exp.y2
-rw-r--r--gdb/stack.c32
-rw-r--r--gdb/target.c4
-rw-r--r--gdb/thread.c2
-rw-r--r--gdb/unittests/cli-utils-selftests.c4
-rw-r--r--gdb/value.c2
-rw-r--r--gdb/x86-linux-nat.c2
-rw-r--r--gdb/xml-support.c2
43 files changed, 253 insertions, 245 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cc2c270..fb579b9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,81 @@
2019-04-08 Tom Tromey <tom@tromey.com>
+ * xml-support.c (gdb_xml_parser::parse): Update.
+ * x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
+ * value.c (show_convenience): Update.
+ * unittests/cli-utils-selftests.c (test_number_or_range_parser)
+ (test_parse_flags_qcs): Update.
+ * thread.c (thr_try_catch_cmd): Update.
+ * target.c (target_translate_tls_address): Update.
+ * stack.c (print_frame_arg, read_frame_local, read_frame_arg)
+ (info_frame_command_core, frame_apply_command_count): Update.
+ * rust-exp.y (rust_lex_exception_test): Update.
+ * riscv-tdep.c (riscv_print_one_register_info): Update.
+ * remote.c (remote_target::enable_btrace): Update.
+ * record-btrace.c (record_btrace_enable_warn): Update.
+ * python/py-utils.c (gdbpy_convert_exception): Update.
+ * printcmd.c (do_one_display, print_variable_and_value): Update.
+ * mi/mi-main.c (mi_print_exception): Update.
+ * mi/mi-interp.c (mi_cmd_interpreter_exec): Use SCOPE_EXIT.
+ * mi/mi-cmd-stack.c (list_arg_or_local): Update.
+ * linux-nat.c (linux_nat_target::attach): Update.
+ * linux-fork.c (class scoped_switch_fork_info): Update.
+ * infrun.c (displaced_step_prepare): Update.
+ * infcall.c (call_function_by_hand_dummy): Update.
+ * guile/scm-exception.c (gdbscm_scm_from_gdb_exception): Update.
+ * gnu-v3-abi.c (print_one_vtable): Update.
+ * frame.c (get_prev_frame_always): Update.
+ * f-valprint.c (info_common_command_for_block): Update.
+ * exec.c (try_open_exec_file): Update.
+ * exceptions.c (print_exception, exception_print)
+ (exception_fprintf, exception_print_same): Update.
+ * dwarf2-frame.c (dwarf2_build_frame_info): Update.
+ * dwarf-index-cache.c (index_cache::store)
+ (index_cache::lookup_gdb_index): Update.
+ * darwin-nat.c (maybe_cache_shell): Update.
+ * cp-valprint.c (cp_print_value_fields): Update.
+ * compile/compile-cplus-symbols.c (gcc_cplus_convert_symbol)
+ (gcc_cplus_symbol_address): Update.
+ * compile/compile-c-symbols.c (gcc_convert_symbol)
+ (gcc_symbol_address, generate_c_for_for_one_variable): Update.
+ * common/selftest.c: Update.
+ * common/common-exceptions.h (struct gdb_exception) <message>: Now
+ a std::string.
+ (exception_try_scope_entry, exception_try_scope_exit): Don't
+ declare.
+ (struct exception_try_scope): Remove.
+ (TRY): Don't use exception_try_scope.
+ (struct gdb_exception): Add constructor, operator=.
+ <what>: New method.
+ (struct gdb_exception_RETURN_MASK_ALL)
+ (struct gdb_exception_RETURN_MASK_ERROR)
+ (struct gdb_exception_RETURN_MASK_QUIT): Add constructor.
+ (struct gdb_quit_bad_alloc): Update.
+ * common/common-exceptions.c (exception_none): Change
+ initializer.
+ (struct catcher) <state, exception>: Initialize inline.
+ <prev>: Remove member.
+ (current_catcher): Remove.
+ (catchers): New global.
+ (exceptions_state_mc_init): Simplify.
+ (catcher_pop): Remove.
+ (exceptions_state_mc, exceptions_state_mc_catch): Update.
+ (try_scope_depth, exception_try_scope_entry)
+ (exception_try_scope_exit): Remove.
+ (throw_exception_sjlj): Update.
+ (exception_messages, exception_messages_size): Remove.
+ (throw_it): Simplify.
+ (gdb_exception_sliced_copy): Remove.
+ (throw_exception_cxx): Update.
+ * cli/cli-script.c (script_from_file): Update.
+ * breakpoint.c (insert_bp_location, update_breakpoint_locations):
+ Update.
+ * ada-valprint.c (ada_val_print): Update.
+ * ada-lang.c (ada_to_fixed_type_1, ada_exception_name_addr)
+ (create_excep_cond_exprs): Update.
+
+2019-04-08 Tom Tromey <tom@tromey.com>
+
* common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY)
(GDB_XCPT_RAW_TRY, GDB_XCPT): Remove.
(TRY, CATCH, END_CATCH): Remove some definitions.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 51615dc..19cc22d 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9067,7 +9067,7 @@ ada_to_fixed_type_1 (struct type *type, const gdb_byte *valaddr,
optimized out). */
throw_error (except.error,
_("unable to read value of %s (%s)"),
- xvz_name, except.message);
+ xvz_name, except.what ());
}
END_CATCH
@@ -12377,7 +12377,7 @@ ada_exception_name_addr (enum ada_exception_catchpoint_kind ex,
CATCH (e, RETURN_MASK_ERROR)
{
- warning (_("failed to get exception name: %s"), e.message);
+ warning (_("failed to get exception name: %s"), e.what ());
return 0;
}
END_CATCH
@@ -12471,7 +12471,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c,
{
warning (_("failed to reevaluate internal exception condition "
"for catchpoint %d: %s"),
- c->number, e.message);
+ c->number, e.what ());
}
END_CATCH
}
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index d4661e1..ac963a6 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1212,7 +1212,7 @@ ada_val_print (struct type *type,
CATCH (except, RETURN_MASK_ERROR)
{
fprintf_filtered (stream, _("<error reading variable: %s>"),
- except.message);
+ except.what ());
}
END_CATCH
}
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7799d1c..6e835a5 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2675,7 +2675,7 @@ insert_bp_location (struct bp_location *bl,
bp_excpt.message ? ":" : ".\n");
if (bp_excpt.message != NULL)
fprintf_unfiltered (tmp_error_stream, "%s.\n",
- bp_excpt.message);
+ bp_excpt.what ());
}
else
{
@@ -2695,7 +2695,7 @@ insert_bp_location (struct bp_location *bl,
fprintf_unfiltered (tmp_error_stream,
"Cannot insert breakpoint %d: %s\n",
bl->owner->number,
- bp_excpt.message);
+ bp_excpt.what ());
}
}
return 1;
@@ -13539,7 +13539,7 @@ update_breakpoint_locations (struct breakpoint *b,
{
warning (_("failed to reevaluate condition "
"for breakpoint %d: %s"),
- b->number, e.message);
+ b->number, e.what ());
new_loc->enabled = 0;
}
END_CATCH
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index e2fa880..f558c06 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1550,7 +1550,8 @@ script_from_file (FILE *stream, const char *file)
prepended. */
throw_error (e.error,
_("%s:%d: Error in sourced command file:\n%s"),
- source_file_name.c_str (), source_line_number, e.message);
+ source_file_name.c_str (), source_line_number,
+ e.what ());
}
END_CATCH
}
diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c
index c3529c9..b2d8e25 100644
--- a/gdb/common/common-exceptions.c
+++ b/gdb/common/common-exceptions.c
@@ -19,8 +19,9 @@
#include "common-defs.h"
#include "common-exceptions.h"
+#include <forward_list>
-const struct gdb_exception exception_none = { (enum return_reason) 0, GDB_NO_ERROR, NULL };
+const struct gdb_exception exception_none;
/* Possible catcher states. */
enum catcher_state {
@@ -42,42 +43,21 @@ enum catcher_action {
struct catcher
{
- enum catcher_state state;
+ enum catcher_state state = CATCHER_CREATED;
/* Jump buffer pointing back at the exception handler. */
jmp_buf buf;
/* Status buffer belonging to the exception handler. */
- struct gdb_exception exception;
- /* Back link. */
- struct catcher *prev;
+ struct gdb_exception exception = exception_none;
};
/* Where to go for throw_exception(). */
-static struct catcher *current_catcher;
+static std::forward_list<struct catcher> catchers;
jmp_buf *
-exceptions_state_mc_init (void)
+exceptions_state_mc_init ()
{
- struct catcher *new_catcher = XCNEW (struct catcher);
-
- /* Start with no exception. */
- new_catcher->exception = exception_none;
-
- /* Push this new catcher on the top. */
- new_catcher->prev = current_catcher;
- current_catcher = new_catcher;
- new_catcher->state = CATCHER_CREATED;
-
- return &new_catcher->buf;
-}
-
-static void
-catcher_pop (void)
-{
- struct catcher *old_catcher = current_catcher;
-
- current_catcher = old_catcher->prev;
-
- xfree (old_catcher);
+ catchers.emplace_front ();
+ return &catchers.front ().buf;
}
/* Catcher state machine. Returns non-zero if the m/c should be run
@@ -86,14 +66,14 @@ catcher_pop (void)
static int
exceptions_state_mc (enum catcher_action action)
{
- switch (current_catcher->state)
+ switch (catchers.front ().state)
{
case CATCHER_CREATED:
switch (action)
{
case CATCH_ITER:
/* Allow the code to run the catcher. */
- current_catcher->state = CATCHER_RUNNING;
+ catchers.front ().state = CATCHER_RUNNING;
return 1;
default:
internal_error (__FILE__, __LINE__, _("bad state"));
@@ -105,10 +85,10 @@ exceptions_state_mc (enum catcher_action action)
/* No error/quit has occured. */
return 0;
case CATCH_ITER_1:
- current_catcher->state = CATCHER_RUNNING_1;
+ catchers.front ().state = CATCHER_RUNNING_1;
return 1;
case CATCH_THROWING:
- current_catcher->state = CATCHER_ABORTING;
+ catchers.front ().state = CATCHER_ABORTING;
/* See also throw_exception. */
return 1;
default:
@@ -121,10 +101,10 @@ exceptions_state_mc (enum catcher_action action)
/* The did a "break" from the inner while loop. */
return 0;
case CATCH_ITER_1:
- current_catcher->state = CATCHER_RUNNING;
+ catchers.front ().state = CATCHER_RUNNING;
return 0;
case CATCH_THROWING:
- current_catcher->state = CATCHER_ABORTING;
+ catchers.front ().state = CATCHER_ABORTING;
/* See also throw_exception. */
return 1;
default:
@@ -152,8 +132,8 @@ int
exceptions_state_mc_catch (struct gdb_exception *exception,
int mask)
{
- *exception = current_catcher->exception;
- catcher_pop ();
+ *exception = std::move (catchers.front ().exception);
+ catchers.pop_front ();
if (exception->reason < 0)
{
@@ -185,29 +165,6 @@ exceptions_state_mc_action_iter_1 (void)
return exceptions_state_mc (CATCH_ITER_1);
}
-/* How many nested TRY blocks we have. See exception_messages and
- throw_it. */
-
-static int try_scope_depth;
-
-/* Called on entry to a TRY scope. */
-
-void *
-exception_try_scope_entry (void)
-{
- ++try_scope_depth;
- return nullptr;
-}
-
-/* Called on exit of a TRY scope, either normal exit or exception
- exit. */
-
-void
-exception_try_scope_exit (void *saved_state)
-{
- --try_scope_depth;
-}
-
/* Called by the default catch block. IOW, we'll get here before
jumping out to the next outermost scope an exception if a GDB
exception is not caught. */
@@ -218,14 +175,6 @@ exception_rethrow (void)
throw;
}
-/* Copy the 'gdb_exception' portion of FROM to TO. */
-
-static void
-gdb_exception_sliced_copy (struct gdb_exception *to, const struct gdb_exception *from)
-{
- *to = *from;
-}
-
/* Return EXCEPTION to the nearest containing CATCH_SJLJ block. */
void
@@ -235,8 +184,8 @@ throw_exception_sjlj (struct gdb_exception exception)
that call via setjmp's return value. Note that REASON can't be
zero, by definition in common-exceptions.h. */
exceptions_state_mc (CATCH_THROWING);
- current_catcher->exception = exception;
- longjmp (current_catcher->buf, exception.reason);
+ catchers.front ().exception = exception;
+ longjmp (catchers.front ().buf, exception.reason);
}
/* Implementation of throw_exception that uses C++ try/catch. */
@@ -246,16 +195,12 @@ throw_exception_cxx (struct gdb_exception exception)
{
if (exception.reason == RETURN_QUIT)
{
- gdb_exception_RETURN_MASK_QUIT ex;
-
- gdb_exception_sliced_copy (&ex, &exception);
+ gdb_exception_RETURN_MASK_QUIT ex (exception);
throw ex;
}
else if (exception.reason == RETURN_ERROR)
{
- gdb_exception_RETURN_MASK_ERROR ex;
-
- gdb_exception_sliced_copy (&ex, &exception);
+ gdb_exception_RETURN_MASK_ERROR ex (exception);
throw ex;
}
else
@@ -268,52 +213,16 @@ throw_exception (struct gdb_exception exception)
throw_exception_cxx (exception);
}
-/* A stack of exception messages.
- This is needed to handle nested calls to throw_it: we don't want to
- xfree space for a message before it's used.
- This can happen if we throw an exception during a cleanup:
- An outer TRY_CATCH may have an exception message it wants to print,
- but while doing cleanups further calls to throw_it are made.
-
- This is indexed by the size of the current_catcher list.
- It is a dynamically allocated array so that we don't care how deeply
- GDB nests its TRY_CATCHs. */
-static char **exception_messages;
-
-/* The number of currently allocated entries in exception_messages. */
-static int exception_messages_size;
-
static void ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (3, 0)
throw_it (enum return_reason reason, enum errors error, const char *fmt,
va_list ap)
{
struct gdb_exception e;
- char *new_message;
- int depth = try_scope_depth;
-
- gdb_assert (depth > 0);
-
- /* Note: The new message may use an old message's text. */
- new_message = xstrvprintf (fmt, ap);
-
- if (depth > exception_messages_size)
- {
- int old_size = exception_messages_size;
-
- exception_messages_size = depth + 10;
- exception_messages = XRESIZEVEC (char *, exception_messages,
- exception_messages_size);
- memset (exception_messages + old_size, 0,
- (exception_messages_size - old_size) * sizeof (char *));
- }
-
- xfree (exception_messages[depth - 1]);
- exception_messages[depth - 1] = new_message;
/* Create the exception. */
e.reason = reason;
e.error = error;
- e.message = new_message;
+ e.message.reset (new std::string (string_vprintf (fmt, ap)));
/* Throw the exception. */
throw_exception (e);
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index 6cc09ea..54e7404 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -22,6 +22,7 @@
#include <setjmp.h>
#include <new>
+#include <memory>
/* Reasons for calling throw_exceptions(). NOTE: all reason values
must be different from zero. enum value 0 is reserved for internal
@@ -110,9 +111,47 @@ enum errors {
struct gdb_exception
{
+ gdb_exception ()
+ : reason ((enum return_reason) 0),
+ error (GDB_NO_ERROR)
+ {
+ }
+
+ gdb_exception (enum return_reason r, enum errors e)
+ : reason (r),
+ error (e)
+ {
+ }
+
+ /* The copy constructor exists so that we can mark it "noexcept",
+ which is a good practice for any sort of exception object. */
+ gdb_exception (const gdb_exception &other) noexcept
+ : reason (other.reason),
+ error (other.error),
+ message (other.message)
+ {
+ }
+
+ /* The assignment operator exists so that we can mark it "noexcept",
+ which is a good practice for any sort of exception object. */
+ gdb_exception &operator= (const gdb_exception &other) noexcept
+ {
+ reason = other.reason;
+ error = other.error;
+ message = other.message;
+ return *this;
+ }
+
+ /* Return the contents of the exception message, as a C string. The
+ string remains owned by the exception object. */
+ const char *what () const noexcept
+ {
+ return message->c_str ();
+ }
+
enum return_reason reason;
enum errors error;
- const char *message;
+ std::shared_ptr<std::string> message;
};
/* Functions to drive the sjlj-based exceptions state machine. Though
@@ -127,8 +166,6 @@ extern int exceptions_state_mc_catch (struct gdb_exception *, int);
/* For the C++ try/catch-based TRY/CATCH mechanism. */
-extern void *exception_try_scope_entry (void);
-extern void exception_try_scope_exit (void *saved_state);
extern void exception_rethrow (void) ATTRIBUTE_NORETURN;
/* Macro to wrap up standard try/catch behavior.
@@ -178,23 +215,6 @@ extern void exception_rethrow (void) ATTRIBUTE_NORETURN;
#define END_CATCH_SJLJ \
}
-/* Prevent error/quit during TRY from calling cleanups established
- prior to here. This pops out the scope in either case of normal
- exit or exception exit. */
-struct exception_try_scope
-{
- exception_try_scope ()
- {
- saved_state = exception_try_scope_entry ();
- }
- ~exception_try_scope ()
- {
- exception_try_scope_exit (saved_state);
- }
-
- void *saved_state;
-};
-
/* We still need to wrap TRY/CATCH in C++ so that cleanups and C++
exceptions can coexist.
@@ -214,7 +234,6 @@ struct exception_try_scope
{ \
try \
{ \
- exception_try_scope exception_try_scope_instance; \
do \
{
@@ -236,14 +255,26 @@ struct exception_try_scope
struct gdb_exception_RETURN_MASK_ALL : public gdb_exception
{
+ explicit gdb_exception_RETURN_MASK_ALL (const gdb_exception &ex) noexcept
+ : gdb_exception (ex)
+ {
+ }
};
struct gdb_exception_RETURN_MASK_ERROR : public gdb_exception_RETURN_MASK_ALL
{
+ explicit gdb_exception_RETURN_MASK_ERROR (const gdb_exception &ex) noexcept
+ : gdb_exception_RETURN_MASK_ALL (ex)
+ {
+ }
};
struct gdb_exception_RETURN_MASK_QUIT : public gdb_exception_RETURN_MASK_ALL
{
+ explicit gdb_exception_RETURN_MASK_QUIT (const gdb_exception &ex) noexcept
+ : gdb_exception_RETURN_MASK_ALL (ex)
+ {
+ }
};
/* An exception type that inherits from both std::bad_alloc and a gdb
@@ -256,12 +287,10 @@ struct gdb_quit_bad_alloc
: public gdb_exception_RETURN_MASK_QUIT,
public std::bad_alloc
{
- explicit gdb_quit_bad_alloc (gdb_exception ex)
- : std::bad_alloc ()
+ explicit gdb_quit_bad_alloc (const gdb_exception &ex) noexcept
+ : gdb_exception_RETURN_MASK_QUIT (ex),
+ std::bad_alloc ()
{
- gdb_exception *self = this;
-
- *self = ex;
}
};
diff --git a/gdb/common/selftest.c b/gdb/common/selftest.c
index fe060ff..1e73708 100644
--- a/gdb/common/selftest.c
+++ b/gdb/common/selftest.c
@@ -90,7 +90,7 @@ run_tests (const char *filter)
CATCH (ex, RETURN_MASK_ERROR)
{
++failed;
- debug_printf ("Self test failed: %s\n", ex.message);
+ debug_printf ("Self test failed: %s\n", ex.what ());
}
END_CATCH
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index a0f833e..10d9ada 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -369,7 +369,7 @@ gcc_convert_symbol (void *datum,
CATCH (e, RETURN_MASK_ALL)
{
- context->plugin ().error (e.message);
+ context->plugin ().error (e.what ());
}
END_CATCH
@@ -432,7 +432,7 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
CATCH (e, RETURN_MASK_ERROR)
{
- context->plugin ().error (e.message);
+ context->plugin ().error (e.what ());
}
END_CATCH
@@ -602,7 +602,7 @@ generate_c_for_for_one_variable (compile_instance *compiler,
CATCH (e, RETURN_MASK_ERROR)
{
- compiler->insert_symbol_error (sym, e.message);
+ compiler->insert_symbol_error (sym, e.what ());
}
END_CATCH
}
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 0979784..4914c7c 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -392,7 +392,7 @@ gcc_cplus_convert_symbol (void *datum,
{
/* We can't allow exceptions to escape out of this callback. Safest
is to simply emit a gcc error. */
- instance->plugin ().error (e.message);
+ instance->plugin ().error (e.what ());
}
END_CATCH
@@ -469,7 +469,7 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
CATCH (e, RETURN_MASK_ERROR)
{
- instance->plugin ().error (e.message);
+ instance->plugin ().error (e.what ());
}
END_CATCH
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 443c3b0..308c25b 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -329,7 +329,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
{
fprintf_filtered (stream,
_("<error reading variable: %s>"),
- ex.message);
+ ex.what ());
}
END_CATCH
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 6247b06..79a6599 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1962,7 +1962,7 @@ caching a copy of your shell. However, this failed:\n\
If you correct the problem, gdb will automatically try again the next time\n\
you \"run\". To prevent these attempts, you can use:\n\
set startup-with-shell off"),
- ex.message);
+ ex.what ());
return false;
}
END_CATCH
diff --git a/gdb/dwarf-index-cache.c b/gdb/dwarf-index-cache.c
index 445f8b1..6e087f9 100644
--- a/gdb/dwarf-index-cache.c
+++ b/gdb/dwarf-index-cache.c
@@ -133,7 +133,7 @@ index_cache::store (struct dwarf2_per_objfile *dwarf2_per_objfile)
{
if (debug_index_cache)
printf_unfiltered ("index cache: couldn't store index cache for objfile "
- "%s: %s", objfile_name (obj), except.message);
+ "%s: %s", objfile_name (obj), except.what ());
}
END_CATCH
}
@@ -193,7 +193,7 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id,
{
if (debug_index_cache)
printf_unfiltered ("index cache: couldn't read %s: %s\n",
- filename.c_str (), except.message);
+ filename.c_str (), except.what ());
}
END_CATCH
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 178ac44..f1ba0c9 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -2257,7 +2257,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
CATCH (e, RETURN_MASK_ERROR)
{
warning (_("skipping .eh_frame info of %s: %s"),
- objfile_name (objfile), e.message);
+ objfile_name (objfile), e.what ());
if (fde_table.num_entries != 0)
{
@@ -2298,7 +2298,7 @@ dwarf2_build_frame_info (struct objfile *objfile)
CATCH (e, RETURN_MASK_ERROR)
{
warning (_("skipping .debug_frame info of %s: %s"),
- objfile_name (objfile), e.message);
+ objfile_name (objfile), e.what ());
if (fde_table.num_entries != 0)
{
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index a29ef0c..078f3c3 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -81,7 +81,7 @@ print_exception (struct ui_file *file, struct gdb_exception e)
const char *start;
const char *end;
- for (start = e.message; start != NULL; start = end)
+ for (start = e.what (); start != NULL; start = end)
{
end = strchr (start, '\n');
if (end == NULL)
@@ -143,13 +143,8 @@ exception_fprintf (struct ui_file *file, struct gdb_exception e,
int
exception_print_same (struct gdb_exception e1, struct gdb_exception e2)
{
- const char *msg1 = e1.message;
- const char *msg2 = e2.message;
-
- if (msg1 == NULL)
- msg1 = "";
- if (msg2 == NULL)
- msg2 = "";
+ const char *msg1 = e1.message == nullptr ? "" : e1.what ();
+ const char *msg2 = e2.message == nullptr ? "" : e2.what ();
return (e1.reason == e2.reason
&& e1.error == e2.error
diff --git a/gdb/exec.c b/gdb/exec.c
index 77bd140..3f30922 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -161,7 +161,6 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
Even without a symbol file, the remote-based debugging session should
continue normally instead of ending abruptly. Hence we catch thrown
errors/exceptions in the following code. */
- std::string saved_message;
TRY
{
/* We must do this step even if exec_file_host is NULL, so that
@@ -171,16 +170,9 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
CATCH (err, RETURN_MASK_ERROR)
{
if (err.message != NULL)
- warning ("%s", err.message);
+ warning ("%s", err.what ());
prev_err = err;
-
- /* Save message so it doesn't get trashed by the catch below. */
- if (err.message != NULL)
- {
- saved_message = err.message;
- prev_err.message = saved_message.c_str ();
- }
}
END_CATCH
@@ -193,7 +185,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
CATCH (err, RETURN_MASK_ERROR)
{
if (!exception_print_same (prev_err, err))
- warning ("%s", err.message);
+ warning ("%s", err.what ());
}
END_CATCH
}
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 5f9dd4d..8eb8062 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -415,7 +415,8 @@ info_common_command_for_block (const struct block *block, const char *comname,
CATCH (except, RETURN_MASK_ERROR)
{
- printf_filtered ("<error reading variable: %s>", except.message);
+ printf_filtered ("<error reading variable: %s>",
+ except.what ());
}
END_CATCH
diff --git a/gdb/frame.c b/gdb/frame.c
index d8b5f81..b71cd6f 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2110,9 +2110,9 @@ get_prev_frame_always (struct frame_info *this_frame)
Allocate using stack local STOP_STRING then assign the
pointer to the frame, this allows the STOP_STRING on the
frame to be of type 'const char *'. */
- size = strlen (ex.message) + 1;
+ size = ex.message->size () + 1;
stop_string = (char *) frame_obstack_zalloc (size);
- memcpy (stop_string, ex.message, size);
+ memcpy (stop_string, ex.what (), size);
this_frame->stop_string = stop_string;
}
prev_frame = NULL;
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 3871ca0..f0923a6 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2019-04-08 Tom Tromey <tom@tromey.com>
+
+ * server.c (handle_btrace_general_set, handle_qxfer_btrace)
+ (handle_qxfer_btrace_conf, detach_or_kill_for_exit_cleanup)
+ (captured_main, main): Update.
+ * gdbreplay.c (main): Update.
+
2019-04-05 Pedro Franco de Carvalho <pedromfc@linux.ibm.com>
* linux-low.c (linux_get_auxv): Remove static. Return auxv entry
diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c
index 63303ee..1acd24b 100644
--- a/gdb/gdbserver/gdbreplay.c
+++ b/gdb/gdbserver/gdbreplay.c
@@ -537,7 +537,7 @@ main (int argc, char *argv[])
if (exception.reason == RETURN_ERROR)
{
fflush (stdout);
- fprintf (stderr, "%s\n", exception.message);
+ fprintf (stderr, "%s\n", exception.what ());
}
exit (1);
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index bfd120d..0f4341c 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -474,7 +474,7 @@ handle_btrace_general_set (char *own_buf)
}
CATCH (exception, RETURN_MASK_ERROR)
{
- sprintf (own_buf, "E.%s", exception.message);
+ sprintf (own_buf, "E.%s", exception.what ());
}
END_CATCH
@@ -1884,7 +1884,7 @@ handle_qxfer_btrace (const char *annex,
}
CATCH (exception, RETURN_MASK_ERROR)
{
- sprintf (cs.own_buf, "E.%s", exception.message);
+ sprintf (cs.own_buf, "E.%s", exception.what ());
result = -1;
}
END_CATCH
@@ -1956,7 +1956,7 @@ handle_qxfer_btrace_conf (const char *annex,
}
CATCH (exception, RETURN_MASK_ERROR)
{
- sprintf (cs.own_buf, "E.%s", exception.message);
+ sprintf (cs.own_buf, "E.%s", exception.what ());
result = -1;
}
END_CATCH
@@ -3559,7 +3559,8 @@ detach_or_kill_for_exit_cleanup ()
CATCH (exception, RETURN_MASK_ALL)
{
fflush (stdout);
- fprintf (stderr, "Detach or kill failed: %s\n", exception.message);
+ fprintf (stderr, "Detach or kill failed: %s\n",
+ exception.what ());
exit_code = 1;
}
END_CATCH
@@ -3933,7 +3934,7 @@ captured_main (int argc, char *argv[])
CATCH (exception, RETURN_MASK_ERROR)
{
fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.message);
+ fprintf (stderr, "gdbserver: %s\n", exception.what ());
if (response_needed)
{
@@ -3963,7 +3964,7 @@ main (int argc, char *argv[])
if (exception.reason == RETURN_ERROR)
{
fflush (stdout);
- fprintf (stderr, "%s\n", exception.message);
+ fprintf (stderr, "%s\n", exception.what ());
fprintf (stderr, "Exiting\n");
exit_code = 1;
}
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 15c7c66..786f416 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -912,7 +912,7 @@ print_one_vtable (struct gdbarch *gdbarch, struct value *value,
}
CATCH (ex, RETURN_MASK_ERROR)
{
- printf_filtered (_("<error: %s>"), ex.message);
+ printf_filtered (_("<error: %s>"), ex.what ());
got_error = 1;
}
END_CATCH
diff --git a/gdb/guile/scm-exception.c b/gdb/guile/scm-exception.c
index e37edd0..44cd7b3 100644
--- a/gdb/guile/scm-exception.c
+++ b/gdb/guile/scm-exception.c
@@ -446,7 +446,7 @@ gdbscm_scm_from_gdb_exception (struct gdb_exception exception)
return gdbscm_make_error (key, NULL, "~A",
scm_list_1 (gdbscm_scm_from_c_string
- (exception.message)),
+ (exception.what ())),
SCM_BOOL_F);
}
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 0deb37d..50fae6d 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1193,7 +1193,7 @@ An error occurred while in a function called from GDB.\n\
Evaluation of the expression containing the function\n\
(%s) will be abandoned.\n\
When the function is done executing, GDB will silently stop."),
- e.message, name);
+ e.what (), name);
case RETURN_QUIT:
default:
throw_exception (e);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2826741..e441281 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1792,7 +1792,7 @@ displaced_step_prepare (thread_info *thread)
{
fprintf_unfiltered (gdb_stdlog,
"infrun: disabling displaced stepping: %s\n",
- ex.message);
+ ex.what ());
}
/* Be verbose if "set displaced-stepping" is "on", silent if
@@ -1800,7 +1800,7 @@ displaced_step_prepare (thread_info *thread)
if (can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
{
warning (_("disabling displaced stepping: %s"),
- ex.message);
+ ex.what ());
}
/* Disable further displaced stepping attempts. */
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index dde63d5..fe401b2 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -436,7 +436,8 @@ public:
CATCH (ex, RETURN_MASK_ALL)
{
warning (_("Couldn't restore checkpoint state in %s: %s"),
- target_pid_to_str (m_oldfp->ptid).c_str (), ex.message);
+ target_pid_to_str (m_oldfp->ptid).c_str (),
+ ex.what ());
}
END_CATCH
}
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 58da62a..13b76f8 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1198,9 +1198,10 @@ linux_nat_target::attach (const char *args, int from_tty)
std::string reason = linux_ptrace_attach_fail_reason (pid);
if (!reason.empty ())
- throw_error (ex.error, "warning: %s\n%s", reason.c_str (), ex.message);
+ throw_error (ex.error, "warning: %s\n%s", reason.c_str (),
+ ex.what ());
else
- throw_error (ex.error, "%s", ex.message);
+ throw_error (ex.error, "%s", ex.what ());
}
END_CATCH
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 119e887..0cec856 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -527,10 +527,8 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
if (arg->val || arg->error)
{
- const char *error_message = NULL;
-
if (arg->error)
- error_message = arg->error;
+ stb.printf (_("<error reading variable: %s>"), arg->error);
else
{
TRY
@@ -544,12 +542,11 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
}
CATCH (except, RETURN_MASK_ERROR)
{
- error_message = except.message;
+ stb.printf (_("<error reading variable: %s>"),
+ except.what ());
}
END_CATCH
}
- if (error_message != NULL)
- stb.printf (_("<error reading variable: %s>"), error_message);
uiout->field_stream ("value", stb);
}
}
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 3c5a0d8..9c20016 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -38,6 +38,7 @@
#include "cli-out.h"
#include "thread-fsm.h"
#include "cli/cli-interp.h"
+#include "common/scope-exit.h"
/* These are the interpreter setup, etc. functions for the MI
interpreter. */
@@ -211,22 +212,18 @@ mi_cmd_interpreter_exec (const char *command, char **argv, int argc)
/* Now run the code. */
- std::string mi_error_message;
+ SCOPE_EXIT
+ {
+ mi_remove_notify_hooks ();
+ };
+
for (i = 1; i < argc; i++)
{
struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
if (e.reason < 0)
- {
- mi_error_message = e.message;
- break;
- }
+ error ("%s", e.what ());
}
-
- mi_remove_notify_hooks ();
-
- if (!mi_error_message.empty ())
- error ("%s", mi_error_message.c_str ());
}
/* This inserts a number of hooks that are meant to produce
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 0655985..2fbcd65 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1884,7 +1884,7 @@ mi_print_exception (const char *token, struct gdb_exception exception)
if (exception.message == NULL)
fputs_unfiltered ("unknown error", mi->raw_stdout);
else
- fputstr_unfiltered (exception.message, '"', mi->raw_stdout);
+ fputstr_unfiltered (exception.what (), '"', mi->raw_stdout);
fputs_unfiltered ("\"", mi->raw_stdout);
switch (exception.error)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index be12ef5..5a55a1c 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1892,7 +1892,7 @@ do_one_display (struct display *d)
/* Can't re-parse the expression. Disable this display item. */
d->enabled_p = 0;
warning (_("Unable to display \"%s\": %s"),
- d->exp_string, ex.message);
+ d->exp_string, ex.what ());
return;
}
END_CATCH
@@ -1955,7 +1955,8 @@ do_one_display (struct display *d)
}
CATCH (ex, RETURN_MASK_ERROR)
{
- fprintf_filtered (gdb_stdout, _("<error: %s>\n"), ex.message);
+ fprintf_filtered (gdb_stdout, _("<error: %s>\n"),
+ ex.what ());
}
END_CATCH
}
@@ -1989,7 +1990,7 @@ do_one_display (struct display *d)
}
CATCH (ex, RETURN_MASK_ERROR)
{
- fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message);
+ fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.what ());
}
END_CATCH
@@ -2193,8 +2194,8 @@ print_variable_and_value (const char *name, struct symbol *var,
}
CATCH (except, RETURN_MASK_ERROR)
{
- fprintf_filtered(stream, "<error reading variable %s (%s)>", name,
- except.message);
+ fprintf_filtered (stream, "<error reading variable %s (%s)>", name,
+ except.what ());
}
END_CATCH
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index d470000..87715ee 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -240,7 +240,7 @@ gdbpy_convert_exception (struct gdb_exception exception)
else
exc_class = gdbpy_gdb_error;
- PyErr_Format (exc_class, "%s", exception.message);
+ PyErr_Format (exc_class, "%s", exception.what ());
}
/* Converts OBJ to a CORE_ADDR value.
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 4c89694..2a2140b 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -288,7 +288,7 @@ record_btrace_enable_warn (struct thread_info *tp)
}
CATCH (error, RETURN_MASK_ERROR)
{
- warning ("%s", error.message);
+ warning ("%s", error.what ());
}
END_CATCH
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 657a4a2..2b21aea 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -13797,7 +13797,7 @@ remote_target::enable_btrace (ptid_t ptid, const struct btrace_config *conf)
CATCH (err, RETURN_MASK_ERROR)
{
if (err.message != NULL)
- warning ("%s", err.message);
+ warning ("%s", err.what ());
}
END_CATCH
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index ff5f36e..1f88683 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -660,7 +660,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
{
/* Handle failure to read a register without interrupting the entire
'info registers' flow. */
- fprintf_filtered (file, "%s\n", ex.message);
+ fprintf_filtered (file, "%s\n", ex.what ());
return;
}
END_CATCH
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index 6e22620..ba145b1 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -2623,7 +2623,7 @@ rust_lex_exception_test (rust_parser *parser, const char *input,
}
CATCH (except, RETURN_MASK_ERROR)
{
- SELF_CHECK (strcmp (except.message, err) == 0);
+ SELF_CHECK (strcmp (except.what (), err) == 0);
}
END_CATCH
}
diff --git a/gdb/stack.c b/gdb/stack.c
index bce8d58..7773ef9 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -229,7 +229,6 @@ static void
print_frame_arg (const struct frame_arg *arg)
{
struct ui_out *uiout = current_uiout;
- const char *error_message = NULL;
string_file stb;
@@ -265,7 +264,7 @@ print_frame_arg (const struct frame_arg *arg)
else
{
if (arg->error)
- error_message = arg->error;
+ stb.printf (_("<error reading variable: %s>"), arg->error);
else
{
TRY
@@ -299,12 +298,11 @@ print_frame_arg (const struct frame_arg *arg)
}
CATCH (except, RETURN_MASK_ERROR)
{
- error_message = except.message;
+ stb.printf (_("<error reading variable: %s>"),
+ except.what ());
}
END_CATCH
}
- if (error_message != NULL)
- stb.printf (_("<error reading variable: %s>"), error_message);
}
uiout->field_stream ("value", stb);
@@ -328,7 +326,7 @@ read_frame_local (struct symbol *sym, struct frame_info *frame,
}
CATCH (except, RETURN_MASK_ERROR)
{
- argp->error = xstrdup (except.message);
+ argp->error = xstrdup (except.what ());
}
END_CATCH
}
@@ -354,8 +352,8 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
}
CATCH (except, RETURN_MASK_ERROR)
{
- val_error = (char *) alloca (strlen (except.message) + 1);
- strcpy (val_error, except.message);
+ val_error = (char *) alloca (except.message->size () + 1);
+ strcpy (val_error, except.what ());
}
END_CATCH
}
@@ -377,8 +375,8 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
{
if (except.error != NO_ENTRY_VALUE_ERROR)
{
- entryval_error = (char *) alloca (strlen (except.message) + 1);
- strcpy (entryval_error, except.message);
+ entryval_error = (char *) alloca (except.message->size () + 1);
+ strcpy (entryval_error, except.what ());
}
}
END_CATCH
@@ -438,8 +436,9 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
val_equal = 1;
else if (except.message != NULL)
{
- entryval_error = (char *) alloca (strlen (except.message) + 1);
- strcpy (entryval_error, except.message);
+ entryval_error
+ = (char *) alloca (except.message->size () + 1);
+ strcpy (entryval_error, except.what ());
}
}
END_CATCH
@@ -480,8 +479,8 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame,
}
CATCH (except, RETURN_MASK_ERROR)
{
- val_error = (char *) alloca (strlen (except.message) + 1);
- strcpy (val_error, except.message);
+ val_error = (char *) alloca (except.message->size () + 1);
+ strcpy (val_error, except.what ());
}
END_CATCH
}
@@ -1410,7 +1409,8 @@ info_frame_command_core (struct frame_info *fi, bool selected_frame_p)
val_print_not_saved (gdb_stdout);
break;
default:
- fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message);
+ fprintf_filtered (gdb_stdout, _("<error: %s>"),
+ ex.what ());
break;
}
}
@@ -2723,7 +2723,7 @@ frame_apply_command_count (const char *which_command,
if (!flags.quiet)
print_stack_frame (fi, 1, LOCATION, 0);
if (flags.cont)
- printf_filtered ("%s\n", ex.message);
+ printf_filtered ("%s\n", ex.what ());
else
throw_exception (ex);
}
diff --git a/gdb/target.c b/gdb/target.c
index 6c05b6b..646f913 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -759,12 +759,12 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset)
error (_("Cannot find thread-local storage for %s, "
"shared library %s:\n%s"),
target_pid_to_str (ptid).c_str (),
- objfile_name (objfile), ex.message);
+ objfile_name (objfile), ex.what ());
else
error (_("Cannot find thread-local storage for %s, "
"executable file %s:\n%s"),
target_pid_to_str (ptid).c_str (),
- objfile_name (objfile), ex.message);
+ objfile_name (objfile), ex.what ());
break;
default:
throw_exception (ex);
diff --git a/gdb/thread.c b/gdb/thread.c
index 91741c7..a86f269 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -1480,7 +1480,7 @@ thr_try_catch_cmd (thread_info *thr, const char *cmd, int from_tty,
print_thread_id (thr),
target_pid_to_str (inferior_ptid).c_str ());
if (flags.cont)
- printf_filtered ("%s\n", ex.message);
+ printf_filtered ("%s\n", ex.what ());
else
throw_exception (ex);
}
diff --git a/gdb/unittests/cli-utils-selftests.c b/gdb/unittests/cli-utils-selftests.c
index dd4a7a0..e357b06 100644
--- a/gdb/unittests/cli-utils-selftests.c
+++ b/gdb/unittests/cli-utils-selftests.c
@@ -87,7 +87,7 @@ test_number_or_range_parser ()
{
SELF_CHECK (ex.reason == RETURN_ERROR);
SELF_CHECK (ex.error == GENERIC_ERROR);
- SELF_CHECK (strcmp (ex.message, "negative value") == 0);
+ SELF_CHECK (strcmp (ex.what (), "negative value") == 0);
SELF_CHECK (strcmp (minus_one.cur_tok (), "-1") == 0);
}
END_CATCH;
@@ -225,7 +225,7 @@ test_parse_flags_qcs ()
SELF_CHECK (ex.reason == RETURN_ERROR);
SELF_CHECK (ex.error == GENERIC_ERROR);
SELF_CHECK
- (strcmp (ex.message,
+ (strcmp (ex.what (),
"test_parse_flags_qcs.t4.cs: "
"-c and -s are mutually exclusive") == 0);
}
diff --git a/gdb/value.c b/gdb/value.c
index c0f8a58..02307c1 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2544,7 +2544,7 @@ show_convenience (const char *ignore, int from_tty)
}
CATCH (ex, RETURN_MASK_ERROR)
{
- fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message);
+ fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.what ());
}
END_CATCH
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 9a451e0..f60ed8a 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -224,7 +224,7 @@ x86_linux_nat_target::enable_btrace (ptid_t ptid,
CATCH (exception, RETURN_MASK_ERROR)
{
error (_("Could not enable branch tracing for %s: %s"),
- target_pid_to_str (ptid).c_str (), exception.message);
+ target_pid_to_str (ptid).c_str (), exception.what ());
}
END_CATCH
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 2b19a00..587a3af 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -595,7 +595,7 @@ gdb_xml_parser::parse (const char *buffer)
&& m_error.error == XML_PARSE_ERROR)
{
gdb_assert (m_error.message != NULL);
- error_string = m_error.message;
+ error_string = m_error.what ();
}
else if (status == XML_STATUS_ERROR)
{