From: Kevin Buettner <kevinb@redhat.com>
To: gdb-patches@sourceware.org
Cc: pedro@palves.net, simark@simark.ca, tdevries@suse.de,
Kevin Buettner <kevinb@redhat.com>
Subject: [PATCH v4 6/8] Call quit_force for gdb_exception_forced_quit in safe_execute_command
Date: Wed, 11 Jan 2023 18:56:28 -0700 [thread overview]
Message-ID: <20230112015630.32999-7-kevinb@redhat.com> (raw)
In-Reply-To: <20230112015630.32999-1-kevinb@redhat.com>
In gdb/cli/cli-interp.c, safe_execute_command catches gdb_exception.
In the previous series, I had changed it to instead catch
gdb_exception_error, which would allow gdb_exception_quit and
gdb_exception_forced_quit to not be caught, thus propagating as
normal.
Pedro found some problems with doing this for safe_execute_command.
See:
https://sourceware.org/pipermail/gdb-patches/2022-March/186320.html
Pedro suggested: "Maybe we can just eliminate safe_execute_command and
let exceptions propagate normally."
I'm not doing that here, though I think it might be worth trying.
Instead, what I've done is to catch gdb_exception_forced_quit and,
when caught, call quit_force() thus forcing GDB to terminate.
After (re)reading Pedro's remarks, I think there's still a problem
with this area of the code (in which gdb_exception_quit is turned into
an error in interpreter_exec_cmd), but that problem existed before this
patch series and I think that fully addressing it should be the
subject of a different set of patches.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26761
---
gdb/cli/cli-interp.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 5f2ff726f26..066e55b64f1 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -353,6 +353,17 @@ safe_execute_command (struct ui_out *command_uiout, const char *command,
{
execute_command (command, from_tty);
}
+ catch (gdb_exception_forced_quit &exception)
+ {
+ /* Due to the way that the cli_inter::exec is structured, it is
+ not safe to only catch gdb_exception_error below, thus
+ allowing quit exceptions to propagate through. (The CLI
+ stream won't be reset as it should be.) So, for
+ gdb_exception_forced_quit, which corresponds to GDB having
+ received a SIGTERM signal, call quit_force() here which will
+ cause GDB to terminate. */
+ quit_force (NULL, 0);
+ }
catch (gdb_exception &exception)
{
e = std::move (exception);
--
2.34.3
next prev parent reply other threads:[~2023-01-12 1:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 1:56 [PATCH v4 0/8] Fix gdb.base/gdb-sigterm.exp failure/error Kevin Buettner
2023-01-12 1:56 ` [PATCH v4 1/8] Introduce gdb_exception_forced_quit Kevin Buettner
2023-01-30 18:56 ` Pedro Alves
2023-01-12 1:56 ` [PATCH v4 2/8] Handle gdb SIGTERM by throwing / catching gdb_exception_force_quit Kevin Buettner
2023-01-30 18:57 ` Pedro Alves
2023-01-12 1:56 ` [PATCH v4 3/8] Catch gdb_exception_error instead of gdb_exception (in many places) Kevin Buettner
2023-01-30 19:00 ` Pedro Alves
2023-02-16 10:52 ` Pedro Alves
2023-01-12 1:56 ` [PATCH v4 4/8] Python QUIT processing updates Kevin Buettner
2023-01-30 19:01 ` Pedro Alves
2023-02-20 2:52 ` Kevin Buettner
2023-02-23 12:50 ` Pedro Alves
2023-01-12 1:56 ` [PATCH v4 5/8] Guile " Kevin Buettner
2023-01-12 1:56 ` Kevin Buettner [this message]
2023-01-30 19:01 ` [PATCH v4 6/8] Call quit_force for gdb_exception_forced_quit in safe_execute_command Pedro Alves
2023-01-12 1:56 ` [PATCH v4 7/8] QUIT processing w/ explicit throw for gdb_exception_forced_quit Kevin Buettner
2023-01-30 19:02 ` Pedro Alves
2023-01-12 1:56 ` [PATCH v4 8/8] Forced quit cases handled by resetting sync_quit_force_run Kevin Buettner
2023-01-30 19:02 ` Pedro Alves
2023-01-12 12:37 ` [PATCH v4 0/8] Fix gdb.base/gdb-sigterm.exp failure/error Tom de Vries
2023-01-27 22:03 ` Kevin Buettner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230112015630.32999-7-kevinb@redhat.com \
--to=kevinb@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=pedro@palves.net \
--cc=simark@simark.ca \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).