+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)
optimized out). */
throw_error (except.error,
_("unable to read value of %s (%s)"),
- xvz_name, except.message);
+ xvz_name, except.what ());
}
END_CATCH
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
{
warning (_("failed to reevaluate internal exception condition "
"for catchpoint %d: %s"),
- c->number, e.message);
+ c->number, e.what ());
}
END_CATCH
}
CATCH (except, RETURN_MASK_ERROR)
{
fprintf_filtered (stream, _("<error reading variable: %s>"),
- except.message);
+ except.what ());
}
END_CATCH
}
bp_excpt.message ? ":" : ".\n");
if (bp_excpt.message != NULL)
fprintf_unfiltered (tmp_error_stream, "%s.\n",
- bp_excpt.message);
+ bp_excpt.what ());
}
else
{
fprintf_unfiltered (tmp_error_stream,
"Cannot insert breakpoint %d: %s\n",
bl->owner->number,
- bp_excpt.message);
+ bp_excpt.what ());
}
}
return 1;
{
warning (_("failed to reevaluate condition "
"for breakpoint %d: %s"),
- b->number, e.message);
+ b->number, e.what ());
new_loc->enabled = 0;
}
END_CATCH
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
}
#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 {
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
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"));
/* 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:
/* 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:
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)
{
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. */
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
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. */
{
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
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);
#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
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
/* 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.
#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.
{ \
try \
{ \
- exception_try_scope exception_try_scope_instance; \
do \
{
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
: 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;
}
};
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
CATCH (e, RETURN_MASK_ALL)
{
- context->plugin ().error (e.message);
+ context->plugin ().error (e.what ());
}
END_CATCH
CATCH (e, RETURN_MASK_ERROR)
{
- context->plugin ().error (e.message);
+ context->plugin ().error (e.what ());
}
END_CATCH
CATCH (e, RETURN_MASK_ERROR)
{
- compiler->insert_symbol_error (sym, e.message);
+ compiler->insert_symbol_error (sym, e.what ());
}
END_CATCH
}
{
/* 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
CATCH (e, RETURN_MASK_ERROR)
{
- instance->plugin ().error (e.message);
+ instance->plugin ().error (e.what ());
}
END_CATCH
{
fprintf_filtered (stream,
_("<error reading variable: %s>"),
- ex.message);
+ ex.what ());
}
END_CATCH
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
{
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
}
{
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
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)
{
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)
{
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)
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
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
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
CATCH (err, RETURN_MASK_ERROR)
{
if (!exception_print_same (prev_err, err))
- warning ("%s", err.message);
+ warning ("%s", err.what ());
}
END_CATCH
}
CATCH (except, RETURN_MASK_ERROR)
{
- printf_filtered ("<error reading variable: %s>", except.message);
+ printf_filtered ("<error reading variable: %s>",
+ except.what ());
}
END_CATCH
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;
+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
if (exception.reason == RETURN_ERROR)
{
fflush (stdout);
- fprintf (stderr, "%s\n", exception.message);
+ fprintf (stderr, "%s\n", exception.what ());
}
exit (1);
}
CATCH (exception, RETURN_MASK_ERROR)
{
- sprintf (own_buf, "E.%s", exception.message);
+ sprintf (own_buf, "E.%s", exception.what ());
}
END_CATCH
}
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
}
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
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
CATCH (exception, RETURN_MASK_ERROR)
{
fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.message);
+ fprintf (stderr, "gdbserver: %s\n", exception.what ());
if (response_needed)
{
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;
}
}
CATCH (ex, RETURN_MASK_ERROR)
{
- printf_filtered (_("<error: %s>"), ex.message);
+ printf_filtered (_("<error: %s>"), ex.what ());
got_error = 1;
}
END_CATCH
return gdbscm_make_error (key, NULL, "~A",
scm_list_1 (gdbscm_scm_from_c_string
- (exception.message)),
+ (exception.what ())),
SCM_BOOL_F);
}
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);
{
fprintf_unfiltered (gdb_stdlog,
"infrun: disabling displaced stepping: %s\n",
- ex.message);
+ ex.what ());
}
/* Be verbose if "set displaced-stepping" is "on", silent if
if (can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
{
warning (_("disabling displaced stepping: %s"),
- ex.message);
+ ex.what ());
}
/* Disable further displaced stepping attempts. */
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
}
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
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
}
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);
}
}
#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. */
/* 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
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)
/* 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
}
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
}
}
CATCH (ex, RETURN_MASK_ERROR)
{
- fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message);
+ fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.what ());
}
END_CATCH
}
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
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.
}
CATCH (error, RETURN_MASK_ERROR)
{
- warning ("%s", error.message);
+ warning ("%s", error.what ());
}
END_CATCH
}
CATCH (err, RETURN_MASK_ERROR)
{
if (err.message != NULL)
- warning ("%s", err.message);
+ warning ("%s", err.what ());
}
END_CATCH
{
/* 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
}
CATCH (except, RETURN_MASK_ERROR)
{
- SELF_CHECK (strcmp (except.message, err) == 0);
+ SELF_CHECK (strcmp (except.what (), err) == 0);
}
END_CATCH
}
print_frame_arg (const struct frame_arg *arg)
{
struct ui_out *uiout = current_uiout;
- const char *error_message = NULL;
string_file stb;
else
{
if (arg->error)
- error_message = arg->error;
+ stb.printf (_("<error reading variable: %s>"), arg->error);
else
{
TRY
}
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);
}
CATCH (except, RETURN_MASK_ERROR)
{
- argp->error = xstrdup (except.message);
+ argp->error = xstrdup (except.what ());
}
END_CATCH
}
}
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
}
{
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
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
}
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
}
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;
}
}
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);
}
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);
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);
}
{
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;
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);
}
}
CATCH (ex, RETURN_MASK_ERROR)
{
- fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.message);
+ fprintf_filtered (gdb_stdout, _("<error: %s>"), ex.what ());
}
END_CATCH
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
&& 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)
{