From patchwork Fri Dec 1 15:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 81123 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 926B63861825 for ; Fri, 1 Dec 2023 15:41:19 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id AD8F7385DC0D for ; Fri, 1 Dec 2023 15:41:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD8F7385DC0D 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 AD8F7385DC0D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701445263; cv=none; b=YA+YHu2WL4YoccjqeSWEqaPgEqsanWWewNDQ41d4JKTvFSAcAwGAF63paYzew8XMcvEQ/AkVPxTy92MyaJdnVgYGbKJw0QbzKCFz9Qe8DzUqjhFRF5qtmbOtoDizgg/DYoUO5B6hp+PdOkW0oDFuNZ/xbehsYJeA6yGFHpvYvWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701445263; c=relaxed/simple; bh=tQ4OLopZ2FaFLpwlh4JAOhsGUBBESGhdzLUeZ6z98NI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=KSIZAQRXqBhmZKY2+/I4fpCgR6QJOX+kA53AwG9Wyc1LCuaWiStwe0ec6atSiWSyakibUub1OOZ42csZSgbHLZekLWtaGrW9KQGfif7A7IdYfa4auFkIxJ6e++GpBmJCWTC4KkP/PB2SpGY2fV5nyldl8Fr6qGTPuWe9bDSDDDU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-7b38a2db18aso69133139f.1 for ; Fri, 01 Dec 2023 07:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701445260; x=1702050060; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ZuM/IEtMBeeR1G193sEDacsh4B4ivTD5KZADJpvn2LU=; b=PGHD4nUi/SYH7moca89h8HIrfA2Mv14kmQ3NZ0r68PrYb2Bw78GjHtTAizAHyz979v /rKbsuodc9B0SHmBDZ/KPxZXD1l6T2V8erSrydLCqDNBFGDxg26kdvsy+Ged/gt/1et2 z4QgmyVl79SzX1fUpy7sarXG98nnWDF1T7Hg4nU0aSpwy/e9BdyvrGFqdzuu2ITYQP4A ueLTmkeY9l7qS1v5z83RcLRwN2lDV97KMx50arL+q/ShKvctE3tEGh9qZYJvChFu2OyL 4rAox5379Z9qMqmUp1qM3XDq/SX/XGVt1QYvaEmW9TByxFG5GVBGvTSodHk3p7/ZKAJE DZmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701445260; x=1702050060; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZuM/IEtMBeeR1G193sEDacsh4B4ivTD5KZADJpvn2LU=; b=RZOcWDyv4GZKGxHKl7SrCd1Il9gl7gaczMC8SuvXUs739x6tB7GelqbA7rbux0KBTS M7AuWERsFBIZCMuI1JTPv3ZHtIGrZvMzM0dvSpWlWlNypz+EnIzLlFWGkDPQBILnrJSQ n0Gn4WzvuSlUTfDCu4f2xZcs5EeB4GnR4VDyFu/PdkYuMyF+dTARx6RSPJZxfggn9DTC eb089s8gwI/rYVIg2bm1a6+MF3FbV/GisxVTvdNpuA2Z0OtCG1dcdoInWUe0AOcCeAI9 asL0HLMMh/fK+EjMJO/6LV87JlT+cdfTSJaigyjOqujWtIYW59IaKNZS0qB2fwCpQcGh Yx7A== X-Gm-Message-State: AOJu0YxG8AcB5irjKlXv0uFhLrctgarlAUZDMUwSPQWHZUlzEWyk00Yq 3B4owo00K7oKbZASFTMkye8f0od4Ibwak3zm8IQ= X-Google-Smtp-Source: AGHT+IEigQhqTbCsKdoFUzhM5V45T9vlQKNLpK+wvLwQls7kdQUhIJZSGBpewJZWY7Rx3/OIzeHVDA== X-Received: by 2002:a05:6602:341d:b0:7b3:5ac0:3a58 with SMTP id n29-20020a056602341d00b007b35ac03a58mr31948853ioz.10.1701445260433; Fri, 01 Dec 2023 07:41:00 -0800 (PST) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id f4-20020a02cac4000000b0046662226e54sm906829jap.168.2023.12.01.07.40.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 07:41:00 -0800 (PST) From: Tom Tromey Date: Fri, 01 Dec 2023 08:40:57 -0700 Subject: [PATCH 1/6] Clean up handling of DAP not-stopped response MIME-Version: 1.0 Message-Id: <20231201-dap-cancel-v1-1-872022fc328a@adacore.com> References: <20231201-dap-cancel-v1-0-872022fc328a@adacore.com> In-Reply-To: <20231201-dap-cancel-v1-0-872022fc328a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.7 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch introduces a new NotStoppedException type and changes the DAP implementation of "not stopped" to use it. I was already touching some code in this area and I thought this looked a little cleaner. This also has the advantage that we can now choose not to log the exception -- previously I was sometimes a bit alarmed when seeing this in the logs, even though it is harmless. --- gdb/python/lib/gdb/dap/server.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py index ead911d11da..d865dee31a8 100644 --- a/gdb/python/lib/gdb/dap/server.py +++ b/gdb/python/lib/gdb/dap/server.py @@ -42,6 +42,12 @@ _commands = {} _server = None +# A subclass of Exception that is used solely for reporting that a +# request needs the inferior to be stopped, but it is not stopped. +class NotStoppedException(Exception): + pass + + class Server: """The DAP server class.""" @@ -78,6 +84,9 @@ class Server: if body is not None: result["body"] = body result["success"] = True + except NotStoppedException: + result["success"] = False + result["message"] = "notStopped" except BaseException as e: log_stack() result["success"] = False @@ -169,7 +178,7 @@ def _check_not_running(func): from .events import inferior_running if inferior_running: - raise Exception("notStopped") + raise NotStoppedException() return func(*args, **kwargs) return check