From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4G8MLwdhGGF+TgAAWB0awg (envelope-from ) for ; Sat, 14 Aug 2021 20:34:15 -0400 Received: by simark.ca (Postfix, from userid 112) id A85021EDFB; Sat, 14 Aug 2021 20:34:15 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BC29D1E813 for ; Sat, 14 Aug 2021 20:34:14 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA5823891018 for ; Sun, 15 Aug 2021 00:34:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA5823891018 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628987653; bh=ygXgKOuc7KP0V48IVrgt1lq0SjLGQfUVqn4bY52jns0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Mu2+qRwKrxIgL7syhKl0mov9S+xteBIXzkcBzLjmecbjr8ePD3FJdJ04cnPTS0lIH TNXQBh0PqbWhenNUsTV7AmQ6A1f181mqu89RdYxDH/UP28BgaS1AuP2lqDwbNv5GJP vMXoha96zcLZFXKvAckXKbL17KtVhAnFKhpTOwRc= Received: from vimdzmsp-nwas02.bluewin.ch (vimdzmsp-nwas02.bluewin.ch [195.186.228.50]) by sourceware.org (Postfix) with ESMTPS id 4E2C1385E828 for ; Sun, 15 Aug 2021 00:33:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E2C1385E828 Received: from patrick.monnerat ([178.193.82.56]) by vimdzmsp-nwas02.bluewin.ch Swisscom AG with ESMTP id F45omsGxKslQjF45tm1vBk; Sun, 15 Aug 2021 02:33:41 +0200 Received: from patrick.monnerat (localhost [127.0.0.1]) by patrick.monnerat (8.16.1/8.16.1) with ESMTPS id 17F0XP9Z010266 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 15 Aug 2021 02:33:26 +0200 Received: (from patrick@localhost) by patrick.monnerat (8.16.1/8.16.1/Submit) id 17F0XPCG010265; Sun, 15 Aug 2021 02:33:25 +0200 X-Authentication-Warning: patrick.monnerat: patrick set sender to patrick@monnerat.net using -f To: gdb-patches@sourceware.org Subject: [PATCH] Notify observer of breakpoint auto-disabling Date: Sun, 15 Aug 2021 02:33:08 +0200 Message-Id: <20210815003308.10218-1-patrick@monnerat.net> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4xfHZLcu/WVxYRJeBSe/7iCO6QF6X4UeHj/Yk2+Wco3/V+ulwBmkNsaf4o3T8toxKLNyfBdZX6XNFhWJvQadmMZtz/Bvc4wV38gIbQLeK9sBLBULHujgGD 8JIlHJsUC2+lzUb6FXiA911pzf32/qrctn/vvjQcsx8Q2b0SLTmoizm1ChH3ruk+5ZfdVNs64fKSa7TYKB8mUcr/twI1SvnofC8= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Patrick Monnerat via Gdb-patches Reply-To: Patrick Monnerat Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" As breakpoint_modified observer is currently notified upon breakpoint stop before handling auto-disabling when enable count is reached, the observer is never notified of the disabling. The problem affects: - The MI interpreter enabled= value when reporting =breakpoint-modified - A Python event handler for breakpoint_modified using the "enabled" member of its parameter - insight: breakpoint GUI window is not properly updated upon auto-disable This patch moves the observer notification after the auto-disabling code and implements corresponding tests for the MI and Python cases. Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=23336 --- gdb/breakpoint.c | 2 +- .../gdb.mi/mi-breakpoint-changed.exp | 41 +++++++++++++++++++ gdb/testsuite/gdb.python/py-breakpoint.exp | 21 ++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 89af44ee4c6..feca224ccf4 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5491,7 +5491,6 @@ bpstat_stop_status (const address_space *aspace, if (bs->stop) { ++(b->hit_count); - gdb::observers::breakpoint_modified.notify (b); /* We will stop here. */ if (b->disposition == disp_disable) @@ -5501,6 +5500,7 @@ bpstat_stop_status (const address_space *aspace, b->enable_state = bp_disabled; removed_any = 1; } + gdb::observers::breakpoint_modified.notify (b); if (b->silent) bs->print = 0; bs->commands = b->commands; diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp index 3f7ef8a79b6..0b814443b06 100644 --- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp +++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp @@ -257,3 +257,44 @@ proc test_pending_resolved { } { with_test_prefix "test_pending_resolved" { test_pending_resolved } + +# Test auto-disable is effective when notifying breakpoint-modified. + +proc test_auto_disable { } { + global mi_gdb_prompt + global lib_sl1 lib_sl2 + global binfile + + mi_clean_restart $binfile + + mi_load_shlibs $lib_sl1 $lib_sl2 + + mi_runto_main + + # Set the breakpoint. + mi_gdb_test "-break-insert -f pendfunc1" \ + {(&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,bkpt=\{number="2",type="breakpoint".*\}.*\n\^done} + + # Enable for one shot only. + mi_gdb_test "-break-enable count 1 2" \ + {=breakpoint-modified,bkpt=\{number="2",type="breakpoint",disp="dis",enabled="y".*\}.*\n\^done} + + mi_send_resuming_command "exec-continue" "continuing execution to breakpoint" + + set test "breakpoint auto-disabling after enable count reached" + gdb_expect { + -re ".*=breakpoint-modified,bkpt=\{number=\"2\".*enabled=\"n\"" { + pass $test + } + -re ".*${mi_gdb_prompt}$" { + fail $test + } + timeout { + fail "$test (timeout)" + } + } +} + +with_test_prefix "test_auto_disable" { + test_auto_disable +} diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index e2ffe8cbe46..e9102e7e3ea 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -799,6 +799,26 @@ proc_with_prefix test_catchpoints {} { gdb_test "continue" "Stopped at catchpoint event: ${num}" } +proc_with_prefix test_bkpt_auto_disable { } { + global srcfile testfile hex decimal + + # Start with a fresh gdb. + clean_restart ${testfile} + + if ![runto_main] then { + fail "cannot run to main." + return 0 + } + delete_breakpoints + + set mult_line [gdb_get_line_number "Break at multiply."] + gdb_breakpoint ${mult_line} + gdb_test "enable count 1 2" "" "One shot enable." + gdb_test "python gdb.events.breakpoint_modified.connect(lambda bp: print(bp.enabled))" \ + "" "Trap breakpoint_modified event" + gdb_test "continue" "False.*" "auto-disabling after enable count reached" +} + test_bkpt_basic test_bkpt_deletion test_bkpt_cond_and_cmds @@ -815,3 +835,4 @@ test_bkpt_events test_bkpt_explicit_loc test_bkpt_qualified test_bkpt_probe +test_bkpt_auto_disable -- 2.31.1