summaryrefslogtreecommitdiff
path: root/gdbsupport/common-exceptions.cc
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2023-02-27 16:11:37 -0700
committerKevin Buettner <kevinb@redhat.com>2023-02-27 16:20:38 -0700
commit522044dc5fa76f9fef70fe746274daf09bbf64fe (patch)
tree9e4d312f20173d7ef86e6e94cd077dc6e731ad35 /gdbsupport/common-exceptions.cc
parentf3d3bbbcdd8af6295458eee3b023447c13edabd3 (diff)
downloadbinutils-gdb-522044dc5fa76f9fef70fe746274daf09bbf64fe.tar.gz
Introduce gdb_exception_forced_quit
This commit adds a new exception 'gdb_exception_forced_quit', reason code 'REASON_FORCED_QUIT', return mask 'RETURN_MASK_FORCED_QUIT', and a wrapper for throwing the exception, throw_forced_quit(). The addition of this exception plus supporting code will allow us to recognize that a SIGTERM has been received by GDB and then propagate recognition of that fact to the upper levels of GDB where it can be correctly handled. At the moment, when GDB receives a SIGTERM, it will attempt to exit via a series of calls from the QUIT checking code. However, before it can exit, it must do various cleanups, such as killing or detaching all inferiors. Should these cleanups be attempted while GDB is executing very low level code, such as reading target memory from within ps_xfer_memory(), it can happen that some of GDB's state is out of sync with regard to the cleanup code's expectations. In the case just mentioned, it's been observed that inferior_ptid and the current_thread_ are not in sync; this triggers an assert / internal error. This commit only introduces the exception plus supporting machinery; changes which use this new exception are in later commits in this series. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761 Tested-by: Tom de Vries <tdevries@suse.de> Approved-by: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdbsupport/common-exceptions.cc')
-rw-r--r--gdbsupport/common-exceptions.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdbsupport/common-exceptions.cc b/gdbsupport/common-exceptions.cc
index d0dd8081c41..edc1b56181a 100644
--- a/gdbsupport/common-exceptions.cc
+++ b/gdbsupport/common-exceptions.cc
@@ -184,6 +184,8 @@ throw_exception (gdb_exception &&exception)
{
if (exception.reason == RETURN_QUIT)
throw gdb_exception_quit (std::move (exception));
+ else if (exception.reason == RETURN_FORCED_QUIT)
+ throw gdb_exception_forced_quit (std::move (exception));
else if (exception.reason == RETURN_ERROR)
throw gdb_exception_error (std::move (exception));
else
@@ -196,6 +198,8 @@ throw_it (enum return_reason reason, enum errors error, const char *fmt,
{
if (reason == RETURN_QUIT)
throw gdb_exception_quit (fmt, ap);
+ else if (reason == RETURN_FORCED_QUIT)
+ throw gdb_exception_forced_quit (fmt, ap);
else if (reason == RETURN_ERROR)
throw gdb_exception_error (error, fmt, ap);
else
@@ -233,3 +237,13 @@ throw_quit (const char *fmt, ...)
throw_vquit (fmt, args);
va_end (args);
}
+
+void
+throw_forced_quit (const char *fmt, ...)
+{
+ va_list args;
+
+ va_start (args, fmt);
+ throw_it (RETURN_FORCED_QUIT, GDB_NO_ERROR, fmt, args);
+ va_end (args);
+}