From patchwork Fri Jun 2 10:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schimpe, Christina" X-Patchwork-Id: 70505 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A54243857438 for ; Fri, 2 Jun 2023 11:01:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A54243857438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685703669; bh=kARHQnjIYFyVY3l8ayet/ifioFzUbwmW1bdwM2x/h4k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=wNmp20agDk2q2o6Gm0MqVuxH4i9WLRQJmUlUVlsMALOS80sysOMNCv9bwAwKWTeA5 Bjw0q07iGoHTtEx2z5SALuUHyfzy8LsE3Q4CGzH2dthqhRSsXUBPiY/ijcWAq7qYs5 6mzw185Pc3tnz6eegZ+nn0Z/Y6wrOV5TesH7WbZY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 4FB4C3858C36 for ; Fri, 2 Jun 2023 11:00:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FB4C3858C36 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="345421803" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="345421803" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:00:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10728"; a="954458122" X-IronPort-AV: E=Sophos;i="6.00,212,1681196400"; d="scan'208";a="954458122" Received: from labpc2315.iul.intel.com (HELO localhost) ([172.28.50.57]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2023 04:00:18 -0700 To: gdb-patches@sourceware.org Subject: [PATCH 1/1] gdb, python: fix python breakpoint with extra spec Date: Fri, 2 Jun 2023 12:59:46 +0200 Message-Id: <20230602105946.3798356-2-christina.schimpe@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230602105946.3798356-1-christina.schimpe@intel.com> References: <20230602105946.3798356-1-christina.schimpe@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 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: , X-Patchwork-Original-From: Christina Schimpe via Gdb-patches From: "Schimpe, Christina" Reply-To: Christina Schimpe Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Mihails Strasuns Python module `Breakpoint` constructor implementation is not passing through any remaining spec tail after parsing location. For example this works as expected: (gdb) python bp1 = Breakpoint ("file:42") But here "thread 1000" is silently ignored: (gdb) python bp1 = Breakpoint ("file:42 thread 1000") This patch modifies `create_breakpoint` function call from the Python implementation so that full spec string is processed. Unnecessary string duplication for "spec" is removed as it is not used after the call (tests still pass). --- gdb/python/py-breakpoint.c | 12 +++++------- gdb/testsuite/gdb.python/py-breakpoint.exp | 4 +++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index d11fc64df20..3a2f8f5f2b8 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -893,6 +893,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) bppy_pending_object->number = -1; bppy_pending_object->bp = NULL; + spec = skip_spaces (spec); + try { switch (type) @@ -908,11 +910,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) if (spec != NULL) { - gdb::unique_xmalloc_ptr - copy_holder (xstrdup (skip_spaces (spec))); - const char *copy = copy_holder.get (); - - locspec = string_to_location_spec (©, + locspec = string_to_location_spec (&spec, current_language, func_name_match_type); } @@ -941,8 +939,8 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) = breakpoint_ops_for_location_spec (locspec.get (), false); create_breakpoint (gdbpy_enter::get_gdbarch (), - locspec.get (), NULL, -1, NULL, false, - 0, + locspec.get (), NULL, -1, spec, false, + 1, temporary_bp, type, 0, AUTO_BOOLEAN_TRUE, diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 76094c95d10..3c747677fc7 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -170,8 +170,10 @@ proc_with_prefix test_bkpt_cond_and_cmds { } { # Test conditional setting. set bp_location1 [gdb_get_line_number "Break at multiply."] - gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"$bp_location1\")" \ + gdb_py_test_silent_cmd "python bp1 = gdb.Breakpoint (\"$bp_location1 thread 1\")" \ "Set breakpoint" 0 + gdb_test "python print (bp1.thread == 1)" "True" \ + "Extra thread spec has been parsed" gdb_continue_to_breakpoint "Break at multiply" \ ".*Break at multiply.*" gdb_py_test_silent_cmd "python bp1.condition = \"i == 5\"" \