From patchwork Wed Dec 17 16:54:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 126724 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 13F004BA2E37 for ; Wed, 17 Dec 2025 16:55:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13F004BA2E37 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=DJYzS5pE X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by sourceware.org (Postfix) with ESMTPS id 95F6F4BA2E24 for ; Wed, 17 Dec 2025 16:54:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 95F6F4BA2E24 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine 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 95F6F4BA2E24 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765990498; cv=none; b=s/FoSUTnFyhlh6EOZptnN3XLxQAMPVXGFecfuLujcbHD+dafGSGQXZLp/hEm54FtF1l8OmIw/n6lwbuBQNBwJbWGu5DYB2d1NVRHF2A+5gBxJIgWoR2dRoC3m9erKmnJZbj5XrqUhdwH2gJFvl/FbNC7J43T4axJtImii0aKZBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765990498; c=relaxed/simple; bh=NuqQ8SjwCuoHDqFaFzpfoofvaybN20RoqhKi4H6HF8s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Fm9hyFEzisI91d3rYl5Yz53LVzHJteK/DF/Grn0G6/4OrWrgSwFb8x30m4a3ikYKB/n9mxbHUTABIoPEGsOcF31evwdjt41WWyhuY00xbh4xtpgpJKPb6DCLIiPiR7Xe2UvCs/HpW/JlCZfYSJfKDQvV/BDRfnpuIRru3JeTgYk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95F6F4BA2E24 Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-7c75dd36b1bso4798951a34.2 for ; Wed, 17 Dec 2025 08:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1765990498; x=1766595298; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=2+RgeMzE44J5yCWsttx5TYTa3zZFEdtjyqd4j4kwXE4=; b=DJYzS5pEAXU5ejyae6a1vUxXd+MYz+wLqzPZzxnq0M5URcR4KAanMpqZpUQPbQ2xQe 8L0X6dfJrD8ccdW7OvKmGeAbIo6OQpxNGs64cb2B5d+TI0yQHvaWyCd67nrnVJlM20LI aMDjCXHr1WiNU4sGsJXhrXNjpWzPItCH7E2iOxGUUuX3GweRlt9sgod2tHIeayb+l4Ql y7U7OeTkt63HlsUI3j5rkYB+HLXU0RrONe7/L288MrRsnFjadXvpvr5IQY93jMfM88I6 J1assiayGwkt47cvNqS9+m77olAENEkxBKfamMIA7dE8od11vzuX6Bbvne/Cs4/DvxEe /9kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765990498; x=1766595298; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=2+RgeMzE44J5yCWsttx5TYTa3zZFEdtjyqd4j4kwXE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sHbh8aQ== X-Received: by 2002:a05:6830:442a:b0:7c7:68d8:f702 with SMTP id 46e09a7af769-7cae82e25bdmr9721455a34.9.1765990497846; Wed, 17 Dec 2025 08:54:57 -0800 (PST) Received: from bapiya (97-122-120-205.hlrn.qwest.net. [97.122.120.205]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cadb321230sm13590033a34.20.2025.12.17.08.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 08:54:57 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add Ada unhandled exception filter to DAP Date: Wed, 17 Dec 2025 09:54:55 -0700 Message-ID: <20251217165455.3312359-1-tromey@adacore.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, PROLO_LEO1, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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 adds a way for DAP clients to catch unhandled Ada exceptions, similar to the "catch exception unhandled" CLI command. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 5 ++ gdb/python/lib/gdb/dap/breakpoint.py | 9 +++- gdb/testsuite/gdb.dap/catch-unhandled.exp | 48 +++++++++++++++++++ gdb/testsuite/gdb.dap/catch-unhandled/pck.adb | 21 ++++++++ gdb/testsuite/gdb.dap/catch-unhandled/pck.ads | 18 +++++++ .../gdb.dap/catch-unhandled/prog.adb | 21 ++++++++ 6 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.dap/catch-unhandled.exp create mode 100644 gdb/testsuite/gdb.dap/catch-unhandled/pck.adb create mode 100644 gdb/testsuite/gdb.dap/catch-unhandled/pck.ads create mode 100644 gdb/testsuite/gdb.dap/catch-unhandled/prog.adb base-commit: e607549f2495ed68da314642d5c4c51bdd470933 diff --git a/gdb/NEWS b/gdb/NEWS index ba37dc89f76..b068697bc5c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -90,6 +90,11 @@ New command class for help commands that we, as developers, believe would be close to a minimal set of commands for a new user of GDB. +* Debugger Adapter Protocol changes + + ** Unhandled Ada exceptions can now be caught using the "unhandled" + exception filter. + * Changed remote packets single-inf-arg in qSupported diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 060e4d8878c..b1d42ed3d8b 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -367,7 +367,9 @@ def set_insn_breakpoints( @in_gdb_thread def _catch_exception(filterId, **args): - if filterId in ("assert", "exception", "throw", "rethrow", "catch"): + if filterId == "unhandled": + cmd = ["-catch-exception", "-u"] + elif filterId in ("assert", "exception", "throw", "rethrow", "catch"): cmd = ["-catch-" + filterId] else: raise DAPException("Invalid exception filterID: " + str(filterId)) @@ -424,6 +426,11 @@ def _rewrite_exception_breakpoint( "label": "Ada exceptions", "supportsCondition": True, }, + { + "filter": "unhandled", + "label": "Ada exceptions without a handler", + "supportsCondition": True, + }, { "filter": "throw", "label": "C++ exceptions, when thrown", diff --git a/gdb/testsuite/gdb.dap/catch-unhandled.exp b/gdb/testsuite/gdb.dap/catch-unhandled.exp new file mode 100644 index 00000000000..e2eb77195c5 --- /dev/null +++ b/gdb/testsuite/gdb.dap/catch-unhandled.exp @@ -0,0 +1,48 @@ +# Copyright 2025 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib ada.exp +load_lib dap-support.exp + +require allow_ada_tests allow_dap_tests gnat_runtime_has_debug_info + +standard_ada_testfile prog + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} { + return -1 +} + +if {[dap_initialize] == ""} { + return +} + +set launch_id [dap_launch $testfile] + +set obj [dap_check_request_and_response "set exception catchpoints" \ + setExceptionBreakpoints \ + {o filters [a [s unhandled]]}] + +set bps [dict get [lindex $obj 0] body breakpoints] +gdb_assert {[llength $bps] == 1} "one breakpoint" + +dap_check_request_and_response "configurationDone" configurationDone + +dap_check_response "launch response" launch $launch_id + +dap_wait_for_event_and_check "stopped at unhandled exception" stopped \ + "body reason" breakpoint \ + "body hitBreakpointIds" 1 + +dap_shutdown diff --git a/gdb/testsuite/gdb.dap/catch-unhandled/pck.adb b/gdb/testsuite/gdb.dap/catch-unhandled/pck.adb new file mode 100644 index 00000000000..367af8eafd7 --- /dev/null +++ b/gdb/testsuite/gdb.dap/catch-unhandled/pck.adb @@ -0,0 +1,21 @@ +-- Copyright 2025 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package body Pck is + procedure Throw_Something (Val : Integer) is + begin + raise Program_Error; + end Throw_Something; +end Pck; diff --git a/gdb/testsuite/gdb.dap/catch-unhandled/pck.ads b/gdb/testsuite/gdb.dap/catch-unhandled/pck.ads new file mode 100644 index 00000000000..513554fa0d8 --- /dev/null +++ b/gdb/testsuite/gdb.dap/catch-unhandled/pck.ads @@ -0,0 +1,18 @@ +-- Copyright 2025 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package Pck is + procedure Throw_Something (Val : Integer); +end Pck; diff --git a/gdb/testsuite/gdb.dap/catch-unhandled/prog.adb b/gdb/testsuite/gdb.dap/catch-unhandled/prog.adb new file mode 100644 index 00000000000..9db1a3e1587 --- /dev/null +++ b/gdb/testsuite/gdb.dap/catch-unhandled/prog.adb @@ -0,0 +1,21 @@ +-- Copyright 2025 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Pck; use Pck; + +procedure Prog is +begin + Throw_Something (23); +end Prog;