From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2FVvOinIbWB9bgAAWB0awg (envelope-from ) for ; Wed, 07 Apr 2021 10:56:41 -0400 Received: by simark.ca (Postfix, from userid 112) id EDAE71EE0E; Wed, 7 Apr 2021 10:56:41 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 0BEE51E789 for ; Wed, 7 Apr 2021 10:56:40 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 26F813938C10; Wed, 7 Apr 2021 14:56:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26F813938C10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617807399; bh=xy91wbcDQsaL/EDWVRWZbCWiv9EfYZOExTbE9bUGYd8=; h=To:Subject:Date:In-Reply-To:References:In-Reply-To:References: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:From:Reply-To:From; b=sZx7DlvxjpBRF3Gt5w//rFYFH/g92HRjTqXodjFNbSS5TsieNaE+DI5m6hH++9e7l EHuJhRdSjDiD/4RBrxq7Tg6+vYbDbh5p9e2OC9yQJISIw1/VFbgMdQ1OOaeaQm0rsQ xKHX/mxRriepy6VG619TIgfaYJO1c7IhMUGegSi4= Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id 7A95D3938C05 for ; Wed, 7 Apr 2021 14:56:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7A95D3938C05 IronPort-SDR: D001zZtU1FsHGHkNSEKQJWMarPZ6JCd5g2Y6OkGwEx+ePCFgyC1VY7nibhEJbq5+3OrXazhimo TCAQOMKSbyJg== X-IronPort-AV: E=McAfee;i="6000,8403,9947"; a="173402368" X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="173402368" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2021 07:56:34 -0700 IronPort-SDR: NLjx/uoLfQoLltxLAt5E1OLTapxDwYSOmoVqMMWm5bCCDpIV+GWeqWZ7mQewpCe/debc93TfmA szByZw+kRxwg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,203,1613462400"; d="scan'208";a="448277848" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by FMSMGA003.fm.intel.com with ESMTP; 07 Apr 2021 07:56:33 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 137EuWL0012841; Wed, 7 Apr 2021 15:56:32 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 137EuW5O011127; Wed, 7 Apr 2021 16:56:32 +0200 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 137EuWbg011123; Wed, 7 Apr 2021 16:56:32 +0200 To: gdb-patches@sourceware.org Subject: [PATCH 4/4] gdb/mi: add a '-b' flag to the '-break-insert' cmd to force the condition Date: Wed, 7 Apr 2021 16:55:59 +0200 Message-Id: <30001cddf6183155c7355df3c74848881f2d80c4.1617806599.git.tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: 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: Tankut Baris Aktemur via Gdb-patches Reply-To: Tankut Baris Aktemur Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Add a '-b' flag to the '-break-insert' command to be able to force conditions. The '-break-condition' command directly uses the CLI's 'cond' command; hence, it already recognizes the '-force' flag. Because the '-dprintf-insert' command uses the same mechanism as the '-break-insert' command, it obtains the '-b' flag, too. gdb/ChangeLog: 2021-04-06 Tankut Baris Aktemur * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Recognize the '-b' flag to force the condition in the '-break-insert' and '-dprintf-insert' commands. * NEWS: Mention the change. gdb/testsuite/ChangeLog: 2021-04-06 Tankut Baris Aktemur * gdb.mi/mi-break.exp (test_forced_conditions): New proc that is called by the test. gdb/doc/ChangeLog: 2021-04-06 Tankut Baris Aktemur * gdb.texinfo (GDB/MI Breakpoint Commands): Mention the '-b' flag of the '-break-insert' and '-dprintf-insert' commands, and the '--force' flag of the '-break-condition' command. --- gdb/NEWS | 7 +++++++ gdb/doc/gdb.texinfo | 16 ++++++++++++---- gdb/mi/mi-cmd-break.c | 10 ++++++++-- gdb/testsuite/gdb.mi/mi-break.exp | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 6cf76a14317..0232ab92419 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -31,6 +31,13 @@ equivalent of the CLI's "break -qualified" and "dprintf -qualified". + ** '-break-insert -b' and '-dprintf-insert -b' + + The MI -break-insert and -dprintf-insert commands now support a + '-b' flag to forcibly define a condition even when the condition + is invalid at all locations of the breakpoint. This is equivalent + to the '--force-condition' flag of the CLI's "break" command. + * GDB now supports core file debugging for x86_64 Cygwin programs. * GDB will now look for the .gdbinit file in a config directory before diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index bfac2b6d245..79839bdfbd5 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30396,13 +30396,15 @@ times="0"@} @subsubheading Synopsis @smallexample - -break-condition @var{number} @var{expr} + -break-condition [ -force ] @var{number} @var{expr} @end smallexample Breakpoint @var{number} will stop the program only if the condition in @var{expr} is true. The condition becomes part of the @samp{-break-list} output (see the description of the @samp{-break-list} -command below). +command below). If the @samp{-force} flag is passed, the condition +is forcibly defined even when it is invalid for all locations of +Breakpoint @var{number}. @subsubheading @value{GDBN} Command @@ -30567,7 +30569,7 @@ N.A. @subsubheading Synopsis @smallexample - -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] [ --qualified ] + -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] [ -b ] [ --qualified ] [ -c @var{condition} ] [ -i @var{ignore-count} ] [ -p @var{thread-id} ] [ @var{location} ] @end smallexample @@ -30624,6 +30626,9 @@ Create a tracepoint. @xref{Tracepoints}. When this parameter is used together with @samp{-h}, a fast tracepoint is created. @item -c @var{condition} Make the breakpoint conditional on @var{condition}. +@item -b +Forcibly define the breakpoint even if the condition is invalid at +all of the breakpoint locations. @item -i @var{ignore-count} Initialize the @var{ignore-count}. @item -p @var{thread-id} @@ -30692,7 +30697,7 @@ times="0"@}]@} @subsubheading Synopsis @smallexample - -dprintf-insert [ -t ] [ -f ] [ -d ] [ --qualified ] + -dprintf-insert [ -t ] [ -f ] [ -d ] [ -b ] [ --qualified ] [ -c @var{condition} ] [ -i @var{ignore-count} ] [ -p @var{thread-id} ] [ @var{location} ] [ @var{format} ] [ @var{argument} ] @@ -30718,6 +30723,9 @@ cannot be parsed. Create a disabled breakpoint. @item -c @var{condition} Make the breakpoint conditional on @var{condition}. +@item -b +Forcibly define the breakpoint even if the condition is invalid at +all of the breakpoint locations. @item -i @var{ignore-count} Set the ignore count of the breakpoint (@pxref{Conditions, ignore count}) to @var{ignore-count}. diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 5a4a62ce8c3..09517d67927 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -183,6 +183,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) int is_explicit = 0; struct explicit_location explicit_loc; std::string extra_string; + bool force_condition = false; enum opt { @@ -191,7 +192,8 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) TRACEPOINT_OPT, QUALIFIED_OPT, EXPLICIT_SOURCE_OPT, EXPLICIT_FUNC_OPT, - EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT + EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT, + FORCE_CONDITION_OPT }; static const struct mi_opt opts[] = { @@ -203,6 +205,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) {"f", PENDING_OPT, 0}, {"d", DISABLE_OPT, 0}, {"a", TRACEPOINT_OPT, 0}, + {"b", FORCE_CONDITION_OPT, 0}, {"-qualified", QUALIFIED_OPT, 0}, {"-source" , EXPLICIT_SOURCE_OPT, 1}, {"-function", EXPLICIT_FUNC_OPT, 1}, @@ -269,6 +272,9 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) is_explicit = 1; explicit_loc.line_offset = linespec_parse_line_offset (oarg); break; + case FORCE_CONDITION_OPT: + force_condition = true; + break; } } @@ -353,7 +359,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) create_breakpoint (get_current_arch (), location.get (), condition, thread, extra_string.c_str (), - false, + force_condition, 0 /* condition and thread are valid. */, temp_p, type_wanted, ignore_count, diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index ac13e4d1e09..87724dea185 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -408,6 +408,22 @@ proc test_explicit_breakpoints {} { ".*Source filename requires function, label, or line offset.*" } +proc test_forced_conditions {} { + # Test forcing an invalid condition. + mi_gdb_test "info break" + mi_gdb_test "-break-condition -force 15 bad" \ + ".*warning: failed to validate condition at location 15.1, disabling:.*" \ + "invalid condition is forced" + + mi_gdb_test "-break-insert -c bad -b callme" \ + ".*warning: failed to validate condition at location 1, disabling:.*" \ + "breakpoint with bad condition is forced" + + mi_gdb_test "-dprintf-insert -c bad -b callme 123" \ + ".*warning: failed to validate condition at location 1, disabling:.*" \ + "dprintf with bad condition is forced" +} + proc test_break {mi_mode} { global srcdir subdir binfile @@ -440,6 +456,8 @@ proc test_break {mi_mode} { test_abreak_creation test_explicit_breakpoints + + test_forced_conditions } if [gdb_debug_enabled] { -- 2.17.1