From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7Wr1NOky8molqTsAWB0awg (envelope-from ) for ; Mon, 09 Nov 2026 15:54:01 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Ddnf8+du; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id BD61B378002; Mon, 09 Nov 2026 15:54:01 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C1E321E043 for ; Mon, 09 Nov 2026 15:53:59 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3774B4B920E0 for ; Mon, 9 Nov 2026 20:53:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3774B4B920E0 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=Ddnf8+du Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [IPv6:2607:f8b0:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 25E934B99F6A for ; Mon, 9 Nov 2026 20:53:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25E934B99F6A 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 25E934B99F6A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794257613; cv=none; b=MOuqbKPVxZDBKG7uG7nuNERS1YCtHEo+TWaxeuzEWpuMzAlLVItFMkK+ojBPcuuuWIk3KcKu+X7R33/XctvBnUDt7xp4IHFEiRGFltClbNZFlfhfBdQBnMx68DIYo8r0MZcgAvr7+EhHu4NXZ/KO494B+hF8+OzVDGY14kW/Cz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794257613; c=relaxed/simple; bh=+3MkXE8mHcffCNr0AjZKPtN+I7H5TP9NGWmKZU4Ee0g=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=g+Uv6yg+Lxj5S7oYEKVb/cv9pc5UU05bYo+UJTDz4sjAbRUZ9l99k5sG+8pkR+1LEWy/Fyo6FAnFcnGQGh+wZycSEoDESdN4ZZUrtzgCvps27pzLyMDJJHBk4WQVr2tx72EMX09GfXRZQXxcwOL4sIAJ6GMGqWelRhYi/H9Zfrg= ARC-Authentication-Results: i=1; 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=Ddnf8+du DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 25E934B99F6A Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-85f39332862so550829a34.3 for ; Mon, 09 Nov 2026 12:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1794257612; x=1794862412; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=VBJ69/FcZKOwhH542GY3ZwRcRK13q5zy2h5zv3zy9+U=; b=Ddnf8+duNYqwRGqNOYPIGCQpdFCjDPRHHbTDalGOgCVZlcDBhfmjH+5GCihTowPtIO RCbsB9TbXQn248rfEQhY0E3hZvsSor7DqsXqRSCA87h5HwvV/5tNOxPXbuOZzkVJjx3I zbsVosx3kJOvwjCzI6EfusOrBHHDfx49wZnG0EPhji1ScqFXSSxQ8wGAk3NZ/ElKtYu9 EgHxMc2KwkBOfz+rwzdHw7TzZkgVW5ETyzSx1xmjAyM4l+lg3L1eaOQDUXBcLkrF2eIg mC4yBDn4LvovsEw8ib8y2oQalDYezk36ssgr7n2vVfihe8x/7J/hmwSPJH2nktFMRkrw PYfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794257612; x=1794862412; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VBJ69/FcZKOwhH542GY3ZwRcRK13q5zy2h5zv3zy9+U=; b=p6k5c7d+a0TY3UcXUjuevjAa4vzvzQNRnGjVp0m2WMFu271TD2+qQu8lvtThIAIhUb Z2LExb6EEmccSkc4+tfjygCbg4AhTlQyHUJOksjchO1+v79JAlAxVfZJ9nKEFXEdC4Yd JG9+TR9k4s4JTjePiY497+SGpTX1fNMfcTFCFZwClGh1ksLOACKU8czH3e10sPFgP2L7 EWSKiYBBN7u5nG0CV9Xf77dWE4MrpqfLlh4xIAEMtQeZgumbohrIR23CDfJtfEskjSBy Q3ff2uXSX2KQQv8hBurzrLkOgCFdZkYaFPY16QdiisJ/2KN7c0F0ccmrio6tfRTPSoy7 SwtA== X-Gm-Message-State: APuU4Z9CRtifTgIq+n9A0hIvuSNvnKgV7BMMSXzibtp+q6EFAlvKrGvS dbysxLeUqQl7yXpqXm/uXu4GCao6PEwvdCTghjvB+Os3NtuKSnEVqG/jKe7PL3fkQChp0CbJZoY DFZQWRw== X-Gm-Gg: AYBFou26XewyCPbMEB12TyfwE0RpEiesxbH9TFYt8DWHxtlbg5eYENZnxPEmyhgxXlK t34oB2PvXXIml+DyugDoKkHMzNihzqDzaePHudqTA9e2MqF3k/K9LF+BfRP+pIHcdoo+3iH/EBd qxpSCEL5ZxQoCE4IVP8N5hzKQ1cLYTJaVudEUSfGDHHOSft9MWADknJTvP8N5m8Skaoylo7mcWv C/HpNp4lL3jT6uLlchUrbPG0E1bgEWNDYq+lnK9BetGPYMoiv/jgmK/+FkJe1ugzCa9vaNJo4Ac 9ZcudixhJc4HnBg1IV8/1hEeKRbdjswvRsyRuGvNFk1Wz/PBTh7ybIDhsa1eK03GBFLA69sf8NF uc7uuqO2V5ZbkdMJyhUDcwX6qbgWyUUCcxZjhpaVbtzTbzeSpr8dDitbmorREd4UXr+t/WeJP53 Y0FMoElGzX+NqpGJivhIDeorkdKN1s7fVsW0kZeaNPU1/uARniAOdUl6xM/a6nibpH8fSO7fR1O P9EncGRiZwwoZO3sgWO0IupY4tPXsjKi5iO0KLa7vfP7TGMYyn+sMwtoXdO96escaLwBJ0M+0it f5QKd+H5d34Av3B6MgQWDRFkswPKw0NQ41UuMVNodblpvQT57TOryv4szfehAQ== X-Received: by 2002:a05:6808:3209:b0:4a4:744:a4ff with SMTP id 5614622812f47-5683c99ce5bmr714585b6e.4.1794257612418; Mon, 09 Nov 2026 12:53:32 -0800 (PST) Received: from [192.168.0.26] (97-122-110-129.hlrn.qwest.net. [97.122.110.129]) by smtp.gmail.com with ESMTPSA id 5614622812f47-56905735edasm222369b6e.7.2026.11.09.12.53.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 12:53:32 -0800 (PST) From: Tom Tromey Date: Mon, 09 Nov 2026 13:53:25 -0700 Subject: [PATCH v2 2/2] Let Python breakpoints be created silently MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261109-submit-py-bp-announce-v2-2-aac3f3d98da6@adacore.com> References: <20261109-submit-py-bp-announce-v2-0-aac3f3d98da6@adacore.com> In-Reply-To: <20261109-submit-py-bp-announce-v2-0-aac3f3d98da6@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.15.2 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~public-inbox=simark.ca@sourceware.org Currently, a breakpoint created from Python will always announce its presence; and in some cases (for example a pending breakpoint), other information will be printed as well. When scripting gdb, it's useful to be able to control the output in cases like this. I debated whether to simply disable the output entirely, but I thought perhaps some existing code acts as a simple "break"-like command and wants the output. This patch adds a new "announce" flag to gdb.Breakpoint. Setting this to False will cause gdb to be silent here. --- gdb/doc/python.texi | 10 ++++++++-- gdb/python/py-breakpoint.c | 29 ++++++++++++++++++++++------- gdb/testsuite/gdb.python/py-breakpoint.exp | 3 ++- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index d8f47098ec8..49eae367f71 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -6953,7 +6953,7 @@ create both breakpoints and watchpoints. The second accepts separate Python arguments similar to @ref{Explicit Locations}, and can only be used to create breakpoints. -@defun Breakpoint.__init__ (spec @r{[}, type @r{][}, wp_class @r{][}, internal @r{][}, temporary @r{][}, qualified @r{][}, allow_pending @r{]}) +@defun Breakpoint.__init__ (spec @r{[}, type @r{][}, wp_class @r{][}, internal @r{][}, temporary @r{][}, qualified @r{][}, allow_pending @r{][}, announce @r{]}) Create a new breakpoint according to @var{spec}, which is a string naming the location of a breakpoint, or an expression that defines a watchpoint. The string should describe a location in a format recognized by the @code{break} @@ -6992,9 +6992,15 @@ the @var{allow_pending} argument is set to @code{False} and the breakpoint location cannot be resolved, a @code{gdb.error} exception is raised instead of creating a pending breakpoint. +The optional @var{announce} argument is a boolean that controls +whether @var{GDBN} announces the existence of the breakpoint. The +default is to announce, meaning that a message is printed. Setting +this argument to false will suppress all output from breakpoint +creation. + @end defun -@defun Breakpoint.__init__ (@r{[} source @r{][}, function @r{][}, label @r{][}, line @r{]}, @r{][} internal @r{][}, temporary @r{][}, qualified @r{][}, allow_pending @r{]}) +@defun Breakpoint.__init__ (@r{[} source @r{][}, function @r{][}, label @r{][}, line @r{]}, @r{][} internal @r{][}, temporary @r{][}, qualified @r{][}, allow_pending @r{][}, announce @r{]}) This second form of creating a new breakpoint specifies the explicit location (@pxref{Explicit Locations}) using keywords. The new breakpoint will be created in the specified source file @var{source}, at the specified diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 72b55cf7d5f..14aa0621283 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "source.h" +#include "top.h" #include "value.h" #include "python-internal.h" #include "python.h" @@ -1075,7 +1076,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) static const char *keywords[] = { "spec", "type", "wp_class", "internal", "temporary","source", "function", "label", "line", "qualified", - "allow_pending", nullptr }; + "allow_pending", "announce", nullptr }; const char *spec = NULL; enum bptype type = bp_breakpoint; int access_type = hw_write; @@ -1090,15 +1091,17 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) char *function = NULL; PyObject *qualified = Py_False; PyObject *allow_pending = Py_True; + PyObject *announce_obj = Py_True; - if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssOO!O!", + if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|siiOOsssOO!O!O!", keywords, &spec, &type, &access_type, &internal, &temporary, &source, &function, &label, &lineobj, &PyBool_Type, &qualified, - &PyBool_Type, &allow_pending)) + &PyBool_Type, &allow_pending, + &PyBool_Type, &announce_obj)) return -1; @@ -1140,10 +1143,22 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) try { - bppy_create_breakpoint (type, access_type, temporary_bp, internal_bp, - spec, qualified == Py_True, - allow_pending == Py_True, source, function, - label, line.get ()); + if (announce_obj == Py_True) + bppy_create_breakpoint (type, access_type, temporary_bp, internal_bp, + spec, qualified == Py_True, + allow_pending == Py_True, source, function, + label, line.get ()); + else + { + std::string ignore; + execute_fn_to_string (ignore, [&] () + { + bppy_create_breakpoint (type, access_type, temporary_bp, internal_bp, + spec, qualified == Py_True, + allow_pending == Py_True, source, function, + label, line.get ()); + }, false); + } } catch (const gdb_exception &except) { diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 1cfb156eb3c..a2e320c3ae0 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -635,7 +635,8 @@ proc_with_prefix test_bkpt_pending {} { clean_restart ${testfile} delete_breakpoints - gdb_breakpoint "nosuchfunction" -allow-pending + gdb_test_no_output "python gdb.Breakpoint(\"nosuchfunction\", announce=False)" \ + "create pending breakpoint" gdb_test "python print (gdb.breakpoints()\[0\].pending)" "True" \ "Check pending status of pending breakpoint" -- 2.56.0