From: Pedro Alves <pedro@palves.net>
To: Kevin Buettner <kevinb@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3 3/7] Catch gdb_exception_error instead of gdb_exception (in many places)
Date: Thu, 3 Mar 2022 21:11:50 +0000 [thread overview]
Message-ID: <c30e961f-d037-ee62-c3b4-cbd613e3ebd9@palves.net> (raw)
In-Reply-To: <20220227000051.3336149-4-kevinb@redhat.com>
Hi Kevin,
I've started giving the series an initial skim, but haven't read it all yet. Meanwhile,
here's one spot I noticed isn't correct.
On 2022-02-27 00:00, Kevin Buettner wrote:
> --- a/gdb/cli/cli-interp.c
> +++ b/gdb/cli/cli-interp.c
> @@ -368,7 +368,7 @@ safe_execute_command (struct ui_out *command_uiout, const char *command,
> {
> execute_command (command, from_tty);
> }
> - catch (gdb_exception &exception)
> + catch (gdb_exception_error &exception)
> {
> e = std::move (exception);
> }
This one here, as is, can leave things in a messed up state. Note that the function returns
the exception. And then the caller does this:
gdb_exception
cli_interp::exec (const char *command_str)
{
struct cli_interp *cli = this;
struct ui_file *old_stream;
struct gdb_exception result;
/* gdb_stdout could change between the time cli_uiout was
initialized and now. Since we're probably using a different
interpreter which has a new ui_file for gdb_stdout, use that one
instead of the default.
It is important that it gets reset everytime, since the user
could set gdb to use a different interpreter. */
old_stream = cli->cli_uiout->set_stream (gdb_stdout);
result = safe_execute_command (cli->cli_uiout, command_str, 1);
cli->cli_uiout->set_stream (old_stream); <<<<<<<<<<<<
return result;
}
Note the "<<<<" line. If a QUIT exception propagates, the line doesn't execute.
Looking at the caller higher up the in chain, we get to interpreter_exec_cmd,
which does:
for (i = 1; i < nrules; i++)
{
struct gdb_exception e = interp_exec (interp_to_use, prules[i]);
if (e.reason < 0)
{
interp_set (old_interp, 0);
error (_("error in command: \"%s\"."), prules[i]);
}
}
That throws plain error, so it won't be sufficient to just revert your hunk, as that
would convert a quit to a plain error. I don't know off hand why
we need to have safe_execute_command and interp_exec catch the exception and
return it via the normal return path. That's normally needed when we need to
cross C code, like readline or ncurses, but that's not the case here. Maybe
we can just eliminate safe_execute_command and let exceptions propagate normally.
next prev parent reply other threads:[~2022-03-03 21:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-27 0:00 [PATCH v3 0/7] glibc-2.34: Fix gdb.base/gdb-sigterm.exp failure/error Kevin Buettner
2022-02-27 0:00 ` [PATCH v3 1/7] Introduce gdb_exception_forced_quit Kevin Buettner
2022-02-27 0:00 ` [PATCH v3 2/7] Handle gdb SIGTERM by throwing / catching gdb_exception_force_quit Kevin Buettner
2022-02-27 0:00 ` [PATCH v3 3/7] Catch gdb_exception_error instead of gdb_exception (in many places) Kevin Buettner
2022-03-03 21:11 ` Pedro Alves [this message]
2022-02-27 0:00 ` [PATCH v3 4/7] Python QUIT processing updates Kevin Buettner
2022-02-27 0:00 ` [PATCH v3 5/7] Guile " Kevin Buettner
2022-02-27 0:00 ` [PATCH v3 6/7] QUIT processing w/ explicit throw for gdb_exception_forced_quit Kevin Buettner
2022-03-03 21:26 ` Pedro Alves
2022-02-27 0:00 ` [PATCH v3 7/7] Handle QUIT processing in the scoped_switch_fork_info destructor Kevin Buettner
2022-07-20 1:53 ` [PATCH v3 0/7] glibc-2.34: Fix gdb.base/gdb-sigterm.exp failure/error Simon Marchi
2023-01-05 13:35 ` Tom de Vries
2023-01-10 15:19 ` Pedro Alves
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=c30e961f-d037-ee62-c3b4-cbd613e3ebd9@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
/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).