Make exceptions use std::string and be self-managing
authorTom Tromey <tom@tromey.com>
Mon, 28 Jan 2019 17:11:10 +0000 (10:11 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Apr 2019 15:05:38 +0000 (09:05 -0600)
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.

43 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ada-valprint.c
gdb/breakpoint.c
gdb/cli/cli-script.c
gdb/common/common-exceptions.c
gdb/common/common-exceptions.h
gdb/common/selftest.c
gdb/compile/compile-c-symbols.c
gdb/compile/compile-cplus-symbols.c
gdb/cp-valprint.c
gdb/darwin-nat.c
gdb/dwarf-index-cache.c
gdb/dwarf2-frame.c
gdb/exceptions.c
gdb/exec.c
gdb/f-valprint.c
gdb/frame.c
gdb/gdbserver/ChangeLog
gdb/gdbserver/gdbreplay.c
gdb/gdbserver/server.c
gdb/gnu-v3-abi.c
gdb/guile/scm-exception.c
gdb/infcall.c
gdb/infrun.c
gdb/linux-fork.c
gdb/linux-nat.c
gdb/mi/mi-cmd-stack.c
gdb/mi/mi-interp.c
gdb/mi/mi-main.c
gdb/printcmd.c
gdb/python/py-utils.c
gdb/record-btrace.c
gdb/remote.c
gdb/riscv-tdep.c
gdb/rust-exp.y
gdb/stack.c
gdb/target.c
gdb/thread.c
gdb/unittests/cli-utils-selftests.c
gdb/value.c
gdb/x86-linux-nat.c
gdb/xml-support.c

index cc2c270f09a3cdba9d81ea3484c5792ceb7fd882..fb579b955bc0204e9578cc249ccf8cc5441a570d 100644 (file)
@@ -1,3 +1,79 @@
+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)
index 51615dcd36132b9a1fdc71ebb46113d079f86920..19cc22d306e149a7302d8d3a59c2e51326765ab1 100644 (file)
@@ -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
        }
index d4661e1f1d4c451220092ad9958a900b8b0a831a..ac963a67561783fc10b0f61a96173d7106f5f217 100644 (file)
@@ -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
 }
index 7799d1c1b487419d4201ae67a4e593c105582110..6e835a5f6bc6ef6d669d945a1cf5ce21b9d4f922 100644 (file)
@@ -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
index e2fa8807130cf6fa0c4524baeb83de3da2f86944..f558c06f830abaeabe16141d162397ae39446011 100644 (file)
@@ -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
 }
index c3529c989fdc8e3bb726b5654c37b3670fb01380..b2d8e25793286e80f95bc45831f256c6934bde54 100644 (file)
@@ -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);
index 6cc09eab93851c60b2f8ad53b56b44a9db0d9744..54e7404f046e7a2391e22ad7cc17c84e99e21cb2 100644 (file)
@@ -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;
   }
 };
 
index fe060ff64f15712121f3e641c4f9dfae01534ff3..1e73708aeeada0e776b66611a47d1a9d4529c88f 100644 (file)
@@ -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
 
index a0f833e6f01449968a880b0e4a532c4aa27592e9..10d9ada46127b0d10561280dd3b2bf07920fc92f 100644 (file)
@@ -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
 }
index 0979784466e8aa2dfbf5d3adace4469c2d552a1b..4914c7c3c933e5b2dc72837dc59e9189abd6da3e 100644 (file)
@@ -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
 
index 443c3b06dac8986e5b07774d053eb75b2d92dc25..308c25bc795c5d5444213517439b34e5cae282cb 100644 (file)
@@ -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
 
index 6247b0656c9507de3a8f89e1b74a42b8b4dc30a5..79a6599828aed740300ac627b53166324ddd7d71 100644 (file)
@@ -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
index 445f8b199e6d50f680b77884972c1060d1dd83a1..6e087f94d920dd1f075c96d42c07ac90f2410106 100644 (file)
@@ -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
 
index 178ac44ecbe65aea684937b816fb6b2d2bca0f16..f1ba0c97c6bd2626afac74487663874651366a9a 100644 (file)
@@ -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)
            {
index a29ef0cde5062b1ab6a2227c447146dcc64e0e8d..078f3c3bf00c995c052b6624826078958aa532f5 100644 (file)
@@ -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
index 77bd140a8e84243dfed35eb042718a2ab1986a4d..3f3092201fc443cdb0ca3f1618473effae502f71 100644 (file)
@@ -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
     }
index 5f9dd4dedb8453ce2a6b66bf5a3271ba1304d5c1..8eb8062496250efaefc101d24fec19bbc386d6e6 100644 (file)
@@ -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
 
index d8b5f819f1d4162f3302cfd13e5d2cd73dc9c18f..b71cd6faade87350bb02c5d4ff2a7355fbb495d1 100644 (file)
@@ -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;
index 3871ca098ae27e3e4b2275f75a18529ebca3e979..f0923a62e9791babdd4604a17c3288013c2a6585 100644 (file)
@@ -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
index 63303eebc40b17b90d0547099c87af53628843a5..1acd24bf1099e8229ba34d9a2afb1d5ab55d13b5 100644 (file)
@@ -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);
index bfd120d2fb333325dd109ddb874a5456e3b4ea66..0f4341c28be72676bc0a47a050695a462560c1e8 100644 (file)
@@ -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;
        }
index 15c7c66700133c119e7b556946f5b886c17761cb..786f416153731f58b9cde7297f86a4408bcdbf62 100644 (file)
@@ -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
index e37edd0178775aa8b9509c7bdf8e036cbe9f507c..44cd7b3575003b42bcaa3138935491f51074a49e 100644 (file)
@@ -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);
 }
 
index 0deb37da962de9a644955c8bc15d4c034b2593ae..50fae6d64f531a0c04ece078742530ffeb80c586 100644 (file)
@@ -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);
index 282674116973a7bd0d18a493f2149f2284b82124..e441281ca8a9f27a6ed450d59b200e2290cf3e43 100644 (file)
@@ -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.  */
index dde63d5572f0b4f1664fb1b6ea85d219eb46cf6d..fe401b2b3b2cac910cb1810a12733de253e88bdb 100644 (file)
@@ -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
       }
index 58da62a79640b5d5784779bc4344408a572d1a73..13b76f813e6a4dd15e6b4bcc18f995738bb4df80 100644 (file)
@@ -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
 
index 119e887e6b3873241651e13bf6fe8b6b34c03d10..0cec856b8375852adb5fe2ca8e2a6c9df580205f 100644 (file)
@@ -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);
     }
 }
index 3c5a0d8fb78e608b43c6f897b59cc28ff8aff5bd..9c20016a3bdf82b9b26ac17ef007f220211a9a6f 100644 (file)
@@ -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
index 065598517459fbffbba69a4662249e6500dafbc5..2fbcd6556d002b9ba1c87f547f7760e643bda2a5 100644 (file)
@@ -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)
index be12ef5e636f8bd0b8b5ea196a793552694dfa0e..5a55a1c3f09a3f802715f958cb52e1c4676980f5 100644 (file)
@@ -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
 
index d470000219589f7a9f40c6280f138becc367bd95..87715eed557e9375d6039ca7e1e0a6b0fcbb8d7a 100644 (file)
@@ -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.
index 4c896944d7a8830a66777c51bfff7e25bd798291..2a2140bd553246490094f1f9b8a1a998d56e54cf 100644 (file)
@@ -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
 }
index 657a4a25cac5609b4a7d3386d5be1fa0bd86421c..2b21aeacdc29638827b8a0e0635c7508ee55b41f 100644 (file)
@@ -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
 
index ff5f36e76217eee62da3fe2b2b97bcd743934389..1f88683d1dc67b55fbfbad780f6ddb5696c70e44 100644 (file)
@@ -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
index 6e22620600ebdc4c633e9e654ffbc3386bbdf148..ba145b168364c908074035f0414c34e9175dfd94 100644 (file)
@@ -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
 }
index bce8d58f543fd5bdb975fae64599b4bb8a03deb9..7773ef9fe2a42ec914f57d36e48af63adbcb7260 100644 (file)
@@ -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);
            }
index 6c05b6b83ef8a70550616e50d5a0316fdff756bb..646f913e0a9b5766dad1f918bc01c55e7c179ffb 100644 (file)
@@ -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);
index 91741c76f0d322b57aee824b4c6c60aaea1425e6..a86f26947c766bb4a7e277869e04499c1d3d656b 100644 (file)
@@ -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);
        }
index dd4a7a0f0f96cb936d7a8d9af3e7cfb75c95b15f..e357b06555f6e058824ec4b036af3cf9f44ab9d0 100644 (file)
@@ -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);
       }
index c0f8a58168a45f72343ffa5f44b0e2f830cc82a2..02307c1a836941f8bd19d5ec599b63af3a7aafe3 100644 (file)
@@ -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
 
index 9a451e0e1aa0a41d49273c34231d6ef0ad95ae0f..f60ed8a9bdedc0f276200b02fb77f4cc278f0b86 100644 (file)
@@ -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
 
index 2b19a000471e7aafca4d1bbff97a54d2fa00b00d..587a3af74cb3013c18c3f1710263a470c07464d8 100644 (file)
@@ -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)
     {
This page took 0.082579 seconds and 4 git commands to generate.