From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id 0A2343857340 for ; Tue, 25 Jul 2023 13:49:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A2343857340 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-785cbc5bfd2so280757639f.2 for ; Tue, 25 Jul 2023 06:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1690292983; x=1690897783; 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=t5sEn7yk8fQPJNEZGTgykqqWrONJwiyxhgA3KxjDPBw=; b=Pk509dHaE5yip9iZYyNK/yq+2Tuf0ltFOmGu4DTtHahwjVP3P43yY0SENHl00hxHMn Y2tGxBo2grwhjF6aUCqAlfFA1ZBg3clVZQzxv+4WmyUzKIUGLbOcMHaYKrdp2cVN+ehv oQYAw6fp4AZhxp29QMztEAMNmDYAdmOxRD6XfDtmMwRPFn5oBcDE7LSk+Vr2z3DoDocr wpNbm6w+yI2qRcDgfjwkE824FQ6a69B/rsXNo54ahQA3FN71fgnxarDEocDm7XJfIy+i KMn5431llggIIzOVNShbMW/yCU5O3yWvf9GVVtqOiRUOYVVcblSew6VZDtCm9EhHTsQJ CBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690292983; x=1690897783; 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=t5sEn7yk8fQPJNEZGTgykqqWrONJwiyxhgA3KxjDPBw=; b=bnbjE3z2n8tHjMXie9aGUgDcyP1SzRLCc22FpTnR5JlTU0e0/ss+vXMnGdg7aLn2LZ 0RXWJFddjcLYZu6jMQtbMQ716QdhrunpF4nzTglKfy1LFa7LZQsydQ5dFd7SpdxsPRAy dXSmlO7HoCdJ7Q2vRdbIm4gTfbcNh6FA2Af70OYv2Dw/t4GXL4deshb0emqayTGyG6hb 2h1fhPi4mAtcLTLiWYpBHM/QpiBeAbbf5rM/6+/ozjboWoVMshJcE+jgbUfPAlUuZbiT /L7srWvcIBo6+Pvy7rLJY+445kfLiHYcwef9IVLJZpcP0t87JvtMgdi+gVUjjsicYWdd vP0w== X-Gm-Message-State: ABy/qLaRDq81IwbGWY16szOsGg1RZZQNtbaifiG/s9YJ9EiF4wB/GMVu g3scrRgNC6vJZx00YuuAbZ63JpPibel837Q9Jw2lJg== X-Google-Smtp-Source: APBJJlGWBTGdCe3jN+TAn7EumrXmzDm10T8TO5pOVNmgmOtLNs8PX3WzB+yzEzx7qxdBnkGMbvFtgw== X-Received: by 2002:a5d:9b8f:0:b0:783:5e20:768d with SMTP id r15-20020a5d9b8f000000b007835e20768dmr2954587iom.18.1690292983328; Tue, 25 Jul 2023 06:49:43 -0700 (PDT) Received: from localhost.localdomain (75-166-135-140.hlrn.qwest.net. [75.166.135.140]) by smtp.gmail.com with ESMTPSA id c3-20020a02a403000000b00418a5e0e93esm3595018jal.162.2023.07.25.06.49.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 06:49:43 -0700 (PDT) From: Tom Tromey Date: Tue, 25 Jul 2023 07:49:43 -0600 Subject: [PATCH 6/6] Do not send "new breakpoint" event when breakpoint is set MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230725-dap-bt-path-v1-6-bb015b0d8e54@adacore.com> References: <20230725-dap-bt-path-v1-0-bb015b0d8e54@adacore.com> In-Reply-To: <20230725-dap-bt-path-v1-0-bb015b0d8e54@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.5 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: When the DAP client sets a breakpoint, gdb currently sends a "new breakpoint" event. However, Vladimir Makaev discovered that this causes VSCode to think there are two breakpoints. This patch changes gdb to suppress the event in this case. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30678 --- gdb/python/lib/gdb/dap/breakpoint.py | 36 ++++++++++++++++++++++++++++-------- gdb/testsuite/gdb.dap/basic-dap.exp | 11 ++++++----- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py index 4a1c98efd87..e612c512a89 100644 --- a/gdb/python/lib/gdb/dap/breakpoint.py +++ b/gdb/python/lib/gdb/dap/breakpoint.py @@ -17,6 +17,8 @@ import gdb import os import re +from contextlib import contextmanager + # These are deprecated in 3.9, but required in older versions. from typing import Optional, Sequence @@ -36,15 +38,32 @@ def _bp_modified(event): ) +# True when suppressing new breakpoint events. +_suppress_bp = False + + +@contextmanager +def suppress_new_breakpoint_event(): + """Return a new context manager that suppresses new breakpoint events.""" + global _suppress_bp + _suppress_bp = True + try: + yield None + finally: + _suppress_bp = False + + @in_gdb_thread def _bp_created(event): - send_event( - "breakpoint", - { - "reason": "new", - "breakpoint": _breakpoint_descriptor(event), - }, - ) + global _suppress_bp + if not _suppress_bp: + send_event( + "breakpoint", + { + "reason": "new", + "breakpoint": _breakpoint_descriptor(event), + }, + ) @in_gdb_thread @@ -141,7 +160,8 @@ def _set_breakpoints_callback(kind, specs, creator): if keyspec in saved_map: bp = saved_map.pop(keyspec) else: - bp = creator(**spec) + with suppress_new_breakpoint_event(): + bp = creator(**spec) bp.condition = condition if hit_condition is None: diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index ef3c535f6a2..c4a1698beda 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -54,7 +54,7 @@ set obj [dap_check_request_and_response "set breakpoint by line number" \ set line_bpno [dap_get_breakpoint_number $obj] # Check the new breakpoint event. -set ok 0 +set ok 1 foreach d [lindex $obj 1] { if {[dict get $d type] != "event" || [dict get $d event] != "breakpoint"} { @@ -62,13 +62,14 @@ foreach d [lindex $obj 1] { } if {[dict get $d body reason] == "new" && [dict get $d body breakpoint verified] == "true"} { - set ok 1 - pass "check new breakpoint event" + set ok 0 break } } -if {!$ok} { - fail "check new breakpoint event" +if {$ok} { + pass "check lack of new breakpoint event" +} else { + fail "check lack of new breakpoint event" } # Check that there are breakpoint locations on each line between FIRST -- 2.40.1