From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OZtHJvEy8molqTsAWB0awg (envelope-from ) for ; Mon, 09 Nov 2026 15:54:09 -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=JUpCblBs; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 98C53378002; Mon, 09 Nov 2026 15:54:09 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.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,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 CC42E1E043 for ; Mon, 09 Nov 2026 15:54:08 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 928DE4BBC0E6 for ; Mon, 9 Nov 2026 20:54:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 928DE4BBC0E6 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=JUpCblBs Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id 223FC4B99F65 for ; Mon, 9 Nov 2026 20:53:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 223FC4B99F65 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 223FC4B99F65 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794257612; cv=none; b=G0y56/21tTMRSTO1zNOXzXTZPQpcRaIcuEdk+YCy3VEpoaVKXoYIU+A7jj55BS5m4Cy8RDQ/MmtueFGpysfLWVf0QGfnwwRKsDR5ThtEsPxajshdT2M6TYzQOfdYh34XjQfbjmcRK+yB3JsIwvPJsoxDGFX8cPdfkON2UXi5+7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794257612; c=relaxed/simple; bh=wS4fL88tmSf1nXLqBwkByCT8lZ2nsVG8lsoEP1dQbBg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=xoqytP2zGa6ljiQcVM+/YKJzhO5Gdvg9baWSTBqlFKcGoGTTA9Qa6v+JejmmPZA2Wac1cNMIJolTKdjPKScD0IskgdUP8n3iZGHJz16nrEPJVBS4f95u+5fz2ThTpAaK6m/X5fhZ4NSLQ3ibhKoMizvW/rks9wlaFLQ0BKsxVmw= 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=JUpCblBs DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 223FC4B99F65 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-5058b105df7so405613b6e.1 for ; Mon, 09 Nov 2026 12:53:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1794257611; x=1794862411; 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=DO39gwGF65tTFjces98dqF+oPKA+fR7cGGsCVGqSKl8=; b=JUpCblBskVTSApPTAIinprWri3fab/lUBuKM5IRh+5Fk/PdpTUy26M780pNs/Rp8+v hoxkJnFNERnk+tyN+KDTFzavNys8i6wwLDg9LtgJcMX8I6dXyMkWVPDlM3tmoQ4CmXxn ddDC6aOB/YhQsPoGmjLRkaEb0gH319K5XPfmDwUMge5XPnYVkVrWZQPOhIKFA8gx0NZN fG5ZyVwTjnSSAbxSpPh1d/4exmemBwKfeWw+AVOf3vBjB/AAIzaI7gChEMyhgZoUFz9V P2tObXax3N+KAPzwRoIjlY3b3o2LapK2PPh3hdVuCLH+0mFgAPSE44rVtYj8EJOEWJnX wH2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794257611; x=1794862411; 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=DO39gwGF65tTFjces98dqF+oPKA+fR7cGGsCVGqSKl8=; b=DSepRNLlPYWKyMZIfA/xgWa5pGUYOCjxjm6OQvUHe05A3AiA+itsnrM+RUKTJStxIL 8h7qGEwR0bmQBwZtyCxyTlwxEmp/oCDhZLmlljYFxe4jHjiYq7G9wowYTMVx5CDo+OWU /8SKy+o8SUvx9/jwVrDGKhfIBTE6sROJp9fwFZgfJETLSfAyMWTcXSdFPQgty6yqvZBA OqRHii/DXCvhi+jiFL0h3bRfacDDJS0EqhIcZG+cHbe7Th/RqzCrvNN1UNJmNH1iM6GY snGAssNjUIWmfkL7sfkbzbfpJ/53ogedec0NN7LEznRtZwkFZdreVwoB5plfRtijcQbx g+ZQ== X-Gm-Message-State: APuU4Z9cLD/CR6xNfNvaKyFQxW7WgvFVR0N51ZIlJ4Yem2qfifJY9lO2 NnDu242oYi9oCGeZcLHPUJjFZTz8nzU+gWZFkYRTGHFdstE1LjnX7mx14mc2UjsDWVrLFqKnu+d W+AR6Cg== X-Gm-Gg: AYBFou2BE1zKQtuZECUYfAcM8OSKs7C7kC0Mb6n2BPYaR8QiYD7TCGHF05/TCZV6Xwy +YNLbYJTVSWcinNPj5TV9KB1BvGu0fG/PXcjIqXqL9XCuKCZ8GVSbrtEJJyEawdjq1rEL0PikWk 6N+KI8vWVjEKgw6oTRnobPKO1qix76KA7YrUbiGYoKGK0amag3mwsDmUfldQXWkI8HasnMvEONG 2eMNs8ELK09206mEMHQCvba3HJxHxWoSeH1qUE2l903BnI+m7jH3kAWm0gMRdJigOfrSS3qc/Tu MHXSa2n8YpVCbCegqI/Hd291chO/uzwQOZ1pOTkNPVhrGXMF1szF95vWm9Boxvj4qEmRhHqc9Nz AKZ0zO0lNA8Dol1jgTIiw4Up0F6oxplFtsGHz6L8842NzAD/Ltxor8FoI89lewIBZ3KdyDLfYtb SQkGis1TYK2rSeH3j9NBDCBp/5GJNRdFkI5uC3t07dIcgY/SK6pmfRqPrtE1MAzZS57dBxecugh 1gnWs9HjP/I9NzJJjOd+EaUwPRtY5bwgu+dx0Xi465D1e7G9DlqF9beY7KxfPOBo9LDnxsUs9g4 /TpWmv/g2dt50wrXFKs1HKj1S8fxZB/lwUVitUl2ZDbU6ZI1wxAqvwA14lX8yw== X-Received: by 2002:a05:6808:4f6c:b0:55c:928:6a0f with SMTP id 5614622812f47-5683cd9690cmr810864b6e.52.1794257611401; Mon, 09 Nov 2026 12:53:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2026 12:53:31 -0800 (PST) From: Tom Tromey Date: Mon, 09 Nov 2026 13:53:24 -0700 Subject: [PATCH v2 1/2] Refactor body of bppy_init MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261109-submit-py-bp-announce-v2-1-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 This patch pulls the body of bppy_init out into a separate function. This will simplify a subsequent patch. --- gdb/python/py-breakpoint.c | 172 ++++++++++++++++++++++++--------------------- 1 file changed, 93 insertions(+), 79 deletions(-) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index ee7276f1792..72b55cf7d5f 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -979,6 +979,95 @@ bppy_init_validate_args (const char *spec, char *source, return 1; } +/* Helper function for breakpoint creation. */ + +static void +bppy_create_breakpoint (enum bptype type, int access_type, bool temporary_bp, + bool internal_bp, const char *spec, + bool qualified, bool allow_pending, + const char *source, const char *function, + const char *label, const char *line) +{ + switch (type) + { + case bp_breakpoint: + case bp_hardware_breakpoint: + { + location_spec_up locspec; + symbol_name_match_type func_name_match_type + = (qualified + ? symbol_name_match_type::FULL + : symbol_name_match_type::WILD); + + if (spec != NULL) + { + gdb::unique_xmalloc_ptr + copy_holder (xstrdup (skip_spaces (spec))); + const char *copy = copy_holder.get (); + + locspec = string_to_location_spec (©, + current_language, + func_name_match_type); + } + else + { + std::unique_ptr explicit_loc + (new explicit_location_spec ()); + + if (source != nullptr) + explicit_loc->source_filename = make_unique_xstrdup (source); + if (function != nullptr) + explicit_loc->function_name = make_unique_xstrdup (function); + if (label != nullptr) + explicit_loc->label_name = make_unique_xstrdup (label); + + if (line != NULL) + explicit_loc->line_offset + = linespec_parse_line_offset (line); + + explicit_loc->func_name_match_type = func_name_match_type; + + locspec.reset (explicit_loc.release ()); + } + + const struct breakpoint_ops *ops + = breakpoint_ops_for_location_spec (locspec.get (), false); + + auto_boolean pending_enabled + = (allow_pending + ? AUTO_BOOLEAN_TRUE + : AUTO_BOOLEAN_FALSE); + create_breakpoint (gdbpy_enter::get_gdbarch (), + locspec.get (), NULL, -1, -1, NULL, false, + 0, + temporary_bp, type, + 0, + pending_enabled, + ops, + 0, 1, internal_bp, 0); + break; + } + case bp_watchpoint: + { + spec = skip_spaces (spec); + + if (access_type == hw_write) + watch_command_wrapper (spec, 0, internal_bp); + else if (access_type == hw_access) + awatch_command_wrapper (spec, 0, internal_bp); + else if (access_type == hw_read) + rwatch_command_wrapper (spec, 0, internal_bp); + else + error(_("Cannot understand watchpoint access type.")); + break; + } + case bp_catchpoint: + error (_("BP_CATCHPOINT not supported")); + default: + error(_("Do not understand breakpoint type to set.")); + } +} + /* Python function to create a new breakpoint. */ static int bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) @@ -1051,85 +1140,10 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) try { - switch (type) - { - case bp_breakpoint: - case bp_hardware_breakpoint: - { - location_spec_up locspec; - gdb_assert (PyBool_Check (qualified)); - symbol_name_match_type func_name_match_type - = (qualified == Py_True - ? symbol_name_match_type::FULL - : symbol_name_match_type::WILD); - - if (spec != NULL) - { - gdb::unique_xmalloc_ptr - copy_holder (xstrdup (skip_spaces (spec))); - const char *copy = copy_holder.get (); - - locspec = string_to_location_spec (©, - current_language, - func_name_match_type); - } - else - { - std::unique_ptr explicit_loc - (new explicit_location_spec ()); - - if (source != nullptr) - explicit_loc->source_filename = make_unique_xstrdup (source); - if (function != nullptr) - explicit_loc->function_name = make_unique_xstrdup (function); - if (label != nullptr) - explicit_loc->label_name = make_unique_xstrdup (label); - - if (line != NULL) - explicit_loc->line_offset - = linespec_parse_line_offset (line.get ()); - - explicit_loc->func_name_match_type = func_name_match_type; - - locspec.reset (explicit_loc.release ()); - } - - const struct breakpoint_ops *ops - = breakpoint_ops_for_location_spec (locspec.get (), false); - - auto_boolean pending_enabled - = (allow_pending == Py_True - ? AUTO_BOOLEAN_TRUE - : AUTO_BOOLEAN_FALSE); - create_breakpoint (gdbpy_enter::get_gdbarch (), - locspec.get (), NULL, -1, -1, NULL, false, - 0, - temporary_bp, type, - 0, - pending_enabled, - ops, - 0, 1, internal_bp, 0); - break; - } - case bp_watchpoint: - { - spec = skip_spaces (spec); - - if (access_type == hw_write) - watch_command_wrapper (spec, 0, internal_bp); - else if (access_type == hw_access) - awatch_command_wrapper (spec, 0, internal_bp); - else if (access_type == hw_read) - rwatch_command_wrapper (spec, 0, internal_bp); - else - error(_("Cannot understand watchpoint access type.")); - break; - } - case bp_catchpoint: - error (_("BP_CATCHPOINT not supported")); - default: - error(_("Do not understand breakpoint type to set.")); - } + bppy_create_breakpoint (type, access_type, temporary_bp, internal_bp, + spec, qualified == Py_True, + allow_pending == Py_True, source, function, + label, line.get ()); } catch (const gdb_exception &except) { -- 2.56.0