public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Kevin Buettner <kevinb@redhat.com>, gdb-patches@sourceware.org
Cc: simark@simark.ca, tdevries@suse.de
Subject: Re: [PATCH v4 6/8] Call quit_force for gdb_exception_forced_quit in safe_execute_command
Date: Mon, 30 Jan 2023 19:01:46 +0000	[thread overview]
Message-ID: <611b23d2-e6f1-1269-b59b-e161d09157db@palves.net> (raw)
In-Reply-To: <20230112015630.32999-7-kevinb@redhat.com>

On 2023-01-12 1:56 a.m., Kevin Buettner wrote:
> 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.
> 

I sent a patch implementing my suggestion, here:

  https://inbox.sourceware.org/gdb-patches/20230127230545.77750-1-pedro@palves.net/

I think that when that goes in, this patch can be dropped.

Pedro Alves


> 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);
> 


  reply	other threads:[~2023-01-30 19:01 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 ` [PATCH v4 6/8] Call quit_force for gdb_exception_forced_quit in safe_execute_command Kevin Buettner
2023-01-30 19:01   ` Pedro Alves [this message]
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=611b23d2-e6f1-1269-b59b-e161d09157db@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    --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).