From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by sourceware.org (Postfix) with ESMTPS id 7FFA53858D1E for ; Mon, 30 Jan 2023 19:01:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FFA53858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f49.google.com with SMTP id o36so2702303wms.1 for ; Mon, 30 Jan 2023 11:01:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4FPD7UerM1d8CnPPTeS27lJX2KDPHUn9dpCWNTNTjFo=; b=ci4Iw4NDKJPSY3nlhg6zIBepI8YGmXv3h58cHBqFtcgjTHnFqTfqYWHcRK7hAHOw1d 5j25LHVPRly6rd9cV2nEwTe6HV02YzUjnU019tTc/auitXJLU9rXIR78/fHiHM/JFTxZ Xa7qpq+hshCSfV2Hh0bCWqOka78UGKXZEAB3B9riVWDHOs+YeRTXIRhkMCb9H+Zh9jfy kmLV0p0O8lVX/fad5LNv8xLcdecOG92TPcLPCogYrAKBGnP13oUbE0v6Vp70Ww1jIXde 9Iix3ICD+qW3owAhoDW9Umc1B8jgKpY6LNOIc0F5NV/Cncj+6dUfiEtBZyHzIu2vjGbr Rs9Q== X-Gm-Message-State: AO0yUKUKd5/usVZZHjnSldWBp0RKv65o+kxhzPV8ShI/anwopk+U/oQv +iIhiELfAuDT9lOltipSQBGFtvnX02+hZw== X-Google-Smtp-Source: AK7set/Ctw+6JD8WIVqQfJWc0OgJpbo1SP5qw0zKJyol2h38v6d8PhaxmwWwPIyYDMptXWfTUTn/ig== X-Received: by 2002:a05:600c:1da4:b0:3dc:50b8:67d7 with SMTP id p36-20020a05600c1da400b003dc50b867d7mr564804wms.11.1675105307435; Mon, 30 Jan 2023 11:01:47 -0800 (PST) Received: from ?IPv6:2001:8a0:f92b:9e00::1fe? ([2001:8a0:f92b:9e00::1fe]) by smtp.gmail.com with ESMTPSA id v14-20020a1cf70e000000b003db0b0cc2afsm17441137wmh.30.2023.01.30.11.01.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Jan 2023 11:01:47 -0800 (PST) Subject: Re: [PATCH v4 6/8] Call quit_force for gdb_exception_forced_quit in safe_execute_command To: Kevin Buettner , gdb-patches@sourceware.org Cc: simark@simark.ca, tdevries@suse.de References: <20230112015630.32999-1-kevinb@redhat.com> <20230112015630.32999-7-kevinb@redhat.com> From: Pedro Alves Message-ID: <611b23d2-e6f1-1269-b59b-e161d09157db@palves.net> Date: Mon, 30 Jan 2023 19:01:46 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20230112015630.32999-7-kevinb@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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); >