aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-04-23 07:29:49 -0600
committerTom Tromey <tromey@adacore.com>2019-04-25 12:59:35 -0600
commitc6fdd8b2052baa9b7a27d4d34f109c9622b53509 (patch)
tree98fecba5793b6509802d1f653f4f5c8f46ee3463 /gdb/common
parentcc06b668978e542ecbc2aff1beca40e5baff86b0 (diff)
downloadgdb-c6fdd8b2052baa9b7a27d4d34f109c9622b53509.zip
gdb-c6fdd8b2052baa9b7a27d4d34f109c9622b53509.tar.gz
gdb-c6fdd8b2052baa9b7a27d4d34f109c9622b53509.tar.bz2
Make SJLJ exceptions more efficient
This changes the SJLJ exception handling code to be a bit more efficient, by using rvalue references and move assignment when possible. Tested by the buildbot. gdb/ChangeLog 2019-04-25 Tom Tromey <tromey@adacore.com> * event-top.c (gdb_rl_callback_read_char_wrapper_noexcept) (gdb_rl_callback_handler): Use std::move. * common/common-exceptions.h (struct gdb_exception): Add move assignment operator. (throw_exception_sjlj): Change "exception" to const reference. * common/common-exceptions.c (exceptions_state_mc_catch): Update. (throw_exception_sjlj): Change "exception" to const reference.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/common-exceptions.c5
-rw-r--r--gdb/common/common-exceptions.h4
2 files changed, 6 insertions, 3 deletions
diff --git a/gdb/common/common-exceptions.c b/gdb/common/common-exceptions.c
index 59c27ab..0b96cc6 100644
--- a/gdb/common/common-exceptions.c
+++ b/gdb/common/common-exceptions.c
@@ -166,14 +166,15 @@ exceptions_state_mc_action_iter_1 (void)
/* Return EXCEPTION to the nearest containing CATCH_SJLJ block. */
void
-throw_exception_sjlj (struct gdb_exception exception)
+throw_exception_sjlj (const struct gdb_exception &exception)
{
/* Jump to the nearest CATCH_SJLJ block, communicating REASON to
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);
+ enum return_reason reason = exception.reason;
catchers.front ().exception = exception;
- longjmp (catchers.front ().buf, exception.reason);
+ longjmp (catchers.front ().buf, reason);
}
/* Implementation of throw_exception that uses C++ try/catch. */
diff --git a/gdb/common/common-exceptions.h b/gdb/common/common-exceptions.h
index 33fa8a9..d7b2550 100644
--- a/gdb/common/common-exceptions.h
+++ b/gdb/common/common-exceptions.h
@@ -152,6 +152,8 @@ struct gdb_exception
return *this;
}
+ gdb_exception &operator= (gdb_exception &&other) noexcept = default;
+
/* Return the contents of the exception message, as a C string. The
string remains owned by the exception object. */
const char *what () const noexcept
@@ -281,7 +283,7 @@ extern void throw_exception (const gdb_exception &exception)
containing exception handler established using TRY_SJLJ. Necessary
in some cases where we need to throw GDB exceptions across
third-party library code (e.g., readline). */
-extern void throw_exception_sjlj (struct gdb_exception exception)
+extern void throw_exception_sjlj (const struct gdb_exception &exception)
ATTRIBUTE_NORETURN;
/* Convenience wrappers around throw_exception that throw GDB