From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 97D8A3858C2C for ; Fri, 1 Dec 2023 16:29:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97D8A3858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 97D8A3858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::434 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701448146; cv=none; b=kge18BH5AHDY+z5NZZCCSggX0rUoOK31lcSErCIG2ywIzwG/ADCoYnKC+FgYjb44LcvRZWIHQreq0UN0x2JGcxuZAuKeZnim1GrFiMFAgrYoX/XedIMt/c6lppg5o5pThqOEk5Y8AqwvhMli5rU9GJA8gXHj7mURYPG58bMOL7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701448146; c=relaxed/simple; bh=thsyIHzKJNZaJvd08iBwfIEBGHaBPXSpYNn+kO688/s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tHkJYfqplVxK5QSBnqnFvbPuZjxSfHvLOBCFQ04ZZrq+oqkh7QoPiC9Dg0g/u7dTv7Cr24d4n7VtH2Sc88/WIcGe/wPbqhJHv81GpOr3r2X010n1icelrIauC5FFzwxT4Og/oHoQHowfjVUQoogKVQx447jmB+IXKiA+ohCF7dQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3332ad5b3e3so1102585f8f.2 for ; Fri, 01 Dec 2023 08:29:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701448142; x=1702052942; darn=sourceware.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=gRcCQDG4u/fIuDMLav3R8C8HYiM4OmcyP5pdKg1Vowk=; b=Xg+PM6gjcsRUOmnFveMrz1+tsqxcR1+hVPA+nb0/mrN6zfNb29Bo1QIBmcEAC4T8AE s1Imgq0sCEphMgfxKgsX86yr7kwDI9lLcDuHxnEZMNnxo0D8qhWyyUEEw6AKA2i9Mpji mtPXf79AWvJ1d0O5iUoN95APcojPsxw3DQzsfQRGp8LqXY/CZ79misXvi2Jt0aeP4Tk8 c7YWHXfeV+ccYsb7A0kfZc+k7S7595XtUMgkjyTwGjA3Z+GizmEyP7QV+gpT9gSnaymb 22EuK1btFlmQH1LFCrmNtRbrknZgCSBhkPnYlELoe17gwiwf8r0aOR9wUf6n1Bw4K1xW wIxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701448142; x=1702052942; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gRcCQDG4u/fIuDMLav3R8C8HYiM4OmcyP5pdKg1Vowk=; b=t+SbIK2FiB2v9ivMYucDT+Qh5g/tFPu3nCgSu4/Pgp5L9+Ead28URA7m1YMko+HlRM j4xxTC6A47Ciid/A5y6kGMaXGtIFptehyzWF8FeFeIVE6NcqnvjIg/0lL5mEsU/mY4Ns g4V/1xQ+/ImHXOf4Bw0KHCKUhrfRiqqO2VF1VNOrBwGdOtv7zcN/3fHC9gX7f4fuOZGr b1AlQ07X910pQk6p4BgXEhA0cbnytfTD6wa1LAT1sOKscnlPYr6FW+S8mddWVQkDrrhu 3U5YJICEaKFQcgPEw1Z0N8XDbN0WRdhGy2Tw6b39fDQR3CAG7lAhINxKYPYacspx8TMA 8ThQ== X-Gm-Message-State: AOJu0Yy60sk4F0Q+7dbDeFQLCo4keAvTGtBEJLX6sDzPf+TXXGvQ2b55 j79pbcpj6Vw0rlAWIr+AfYS/yJzbZJzJUeVtIgCN3Q== X-Google-Smtp-Source: AGHT+IHJcrBI6IzTIMb5wX5egXdGc7zhbRgXhRbc0hrcsR85erYzHWtfsznKPJ0N3xSmP5HEmnY1cQ== X-Received: by 2002:a5d:69cd:0:b0:333:2fd2:51dc with SMTP id s13-20020a5d69cd000000b003332fd251dcmr1126346wrw.85.1701448142089; Fri, 01 Dec 2023 08:29:02 -0800 (PST) Received: from legouguec-Precision-7550 ([2.57.72.67]) by smtp.gmail.com with ESMTPSA id e5-20020a5d4e85000000b0033333bee379sm1275861wru.107.2023.12.01.08.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:29:01 -0800 (PST) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 5/6] Catch BaseException in send_gdb_with_response In-Reply-To: <20231201-dap-cancel-v1-5-872022fc328a@adacore.com> (Tom Tromey's message of "Fri, 01 Dec 2023 08:41:01 -0700") References: <20231201-dap-cancel-v1-0-872022fc328a@adacore.com> <20231201-dap-cancel-v1-5-872022fc328a@adacore.com> Date: Fri, 01 Dec 2023 17:29:00 +0100 Message-ID: <875y1hga43.fsf@adacore.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Tom Tromey writes: > Cancellation will generally be seen by the DAP code as a > KeyboardInterrupt. However, this derives from BaseException and not > Exception, so a small change is needed to send_gdb_with_response, to > forward the exception to the DAP server thread. > --- > gdb/python/lib/gdb/dap/startup.py | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py > index a16b51f7cf5..1a7ec17e5e3 100644 > --- a/gdb/python/lib/gdb/dap/startup.py > +++ b/gdb/python/lib/gdb/dap/startup.py > @@ -172,11 +172,11 @@ def send_gdb_with_response(fn): > try: > val = fn() > result_q.put(val) > - except Exception as e: > + except BaseException as e: > result_q.put(e) > > send_gdb(message) > val = result_q.get() > - if isinstance(val, Exception): > + if isinstance(val, BaseException): > raise val > return val Looking at [the hierarchy], it looks like BaseException will catch more than we really want? Should we go for except (Exception, KeyboardInterrupt) as e: if isinstance(val, (Exception, KeyboardInterrupt)): ? [the hierarchy]: https://docs.python.org/3/library/exceptions.html#exception-hierarchy