From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id A1733398B8AC for ; Thu, 22 Apr 2021 14:36:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A1733398B8AC IronPort-SDR: uneK1bpx7vbC656nzRsM5ZFXgzQXnY7Dob8Vqv5g+cd3HY9417lhBYpQdhGBqC/8T5Bi7T4Y2A 0S2uOLcQFlJQ== X-IronPort-AV: E=McAfee;i="6200,9189,9962"; a="176018589" X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="176018589" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 07:36:05 -0700 IronPort-SDR: cDEVQH6FDc36FZLl1Ti5PJfMb+nWW2nM2L3J/ujT7/VL2I7zsomeDvfCdi9IvbCgOC0x4jXYUM NoYaesy0qOwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="614416114" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by fmsmga006.fm.intel.com with ESMTP; 22 Apr 2021 07:36:03 -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 13MEa3xG018622; Thu, 22 Apr 2021 15:36:03 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id 13MEa31m028883; Thu, 22 Apr 2021 16:36:03 +0200 Received: (from taktemur@localhost) by ulvlx001.iul.intel.com with LOCAL id 13MEa2QY028879; Thu, 22 Apr 2021 16:36:02 +0200 From: Tankut Baris Aktemur To: gdb-patches@sourceware.org Subject: [PATCH v4 1/2] gdb/mi: add a '--force-condition' flag to the '-break-insert' cmd Date: Thu, 22 Apr 2021 16:35:49 +0200 Message-Id: <692903afde3124b862962da3f11722ef778c4eed.1619101936.git.tankut.baris.aktemur@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Thu, 22 Apr 2021 14:36:17 -0000 Add a '--force-condition' flag to the '-break-insert' command to be able to force conditions. Because the '-dprintf-insert' command uses the same mechanism as the '-break-insert' command, it obtains the '--force-condition' flag, too. gdb/ChangeLog: 2021-04-21 Tankut Baris Aktemur * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Recognize the '--force-condition' flag to force the condition in the '-break-insert' and '-dprintf-insert' commands. * NEWS: Mention the change. gdb/testsuite/ChangeLog: 2021-04-21 Tankut Baris Aktemur * gdb.mi/mi-break.exp (test_forced_conditions): New proc that is called by the test. gdb/doc/ChangeLog: 2021-04-21 Tankut Baris Aktemur * gdb.texinfo (GDB/MI Breakpoint Commands): Mention the '--force-condition' flag of the '-break-insert' and '-dprintf-insert' commands. --- gdb/NEWS | 8 ++++++++ gdb/doc/gdb.texinfo | 10 ++++++++-- gdb/mi/mi-cmd-break.c | 8 +++++++- gdb/testsuite/gdb.mi/mi-break.exp | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index faccf40dd41..72bceb7266f 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -31,6 +31,14 @@ equivalent of the CLI's "break -qualified" and "dprintf -qualified". + ** '-break-insert --force-condition' and '-dprintf-insert --force-condition' + + The MI -break-insert and -dprintf-insert commands now support a + '--force-condition' 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 fd04aeee8fc..cac7ceb4665 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30681,7 +30681,7 @@ N.A. @smallexample -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] [ --qualified ] - [ -c @var{condition} ] [ -i @var{ignore-count} ] + [ -c @var{condition} ] [ --force-condition ] [ -i @var{ignore-count} ] [ -p @var{thread-id} ] [ @var{location} ] @end smallexample @@ -30737,6 +30737,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 --force-condition +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} @@ -30806,7 +30809,7 @@ times="0"@}]@} @smallexample -dprintf-insert [ -t ] [ -f ] [ -d ] [ --qualified ] - [ -c @var{condition} ] [ -i @var{ignore-count} ] + [ -c @var{condition} ] [--force-condition] [ -i @var{ignore-count} ] [ -p @var{thread-id} ] [ @var{location} ] [ @var{format} ] [ @var{argument} ] @end smallexample @@ -30831,6 +30834,9 @@ cannot be parsed. Create a disabled breakpoint. @item -c @var{condition} Make the breakpoint conditional on @var{condition}. +@item --force-condition +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..fec75a8da5a 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -183,12 +183,14 @@ 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 { HARDWARE_OPT, TEMP_OPT, CONDITION_OPT, IGNORE_COUNT_OPT, THREAD_OPT, PENDING_OPT, DISABLE_OPT, TRACEPOINT_OPT, + FORCE_CONDITION_OPT, QUALIFIED_OPT, EXPLICIT_SOURCE_OPT, EXPLICIT_FUNC_OPT, EXPLICIT_LABEL_OPT, EXPLICIT_LINE_OPT @@ -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}, + {"-force-condition", 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 b2db2d41d1f..3b264ecdebd 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -408,6 +408,24 @@ proc_with_prefix test_explicit_breakpoints {} { ".*Source filename requires function, label, or line offset.*" } +# Test forcing an invalid condition. + +proc_with_prefix test_forced_conditions {} { + set warning ".*warning: failed to validate condition .* disabling.*" + + set loc [mi_make_breakpoint_loc -enabled "N"] + set args [list -cond "bad" -locations "\\\[$loc\\\]"] + set bp [eval mi_make_breakpoint_multi $args] + + mi_gdb_test "-break-insert -c bad --force-condition callme" \ + "${warning}\\^done,$bp" \ + "breakpoint with forced condition" + + mi_gdb_test "-dprintf-insert -c bad --force-condition callme \"Hello\"" \ + "${warning}\\^done,$bp" \ + "dprintf with forced condition" +} + proc test_break {mi_mode} { global srcdir subdir binfile @@ -440,6 +458,8 @@ proc test_break {mi_mode} { test_abreak_creation test_explicit_breakpoints + + test_forced_conditions } if [gdb_debug_enabled] { -- 2.17.1