Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 4/4] gdb/mi: add a '--force-condition' flag to the '-break-insert' cmd
Date: Thu,  8 Apr 2021 16:22:39 +0200	[thread overview]
Message-ID: <b74c99ece1389942444dedac26b241ce73343e02.1617875845.git.tankut.baris.aktemur@intel.com> (raw)
In-Reply-To: <cover.1617875844.git.tankut.baris.aktemur@intel.com>
In-Reply-To: <cover.1617875844.git.tankut.baris.aktemur@intel.com>

Add a '--force-condition' 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 '--force-condition' flag, too.

gdb/ChangeLog:
2021-04-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* 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-06  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* 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  <tankut.baris.aktemur@intel.com>

	* gdb.texinfo (GDB/MI Breakpoint Commands): Mention the
	'--force-condition' flag of the '-break-insert' and
	'-dprintf-insert' commands, and the '--force' flag of the
	'-break-condition' command.
---
 gdb/NEWS                          |  8 ++++++++
 gdb/doc/gdb.texinfo               | 16 ++++++++++++----
 gdb/mi/mi-cmd-break.c             |  8 +++++++-
 gdb/testsuite/gdb.mi/mi-break.exp | 26 ++++++++++++++++++++++++++
 4 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 6cf76a14317..66f9d756fc4 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 438dcca5039..ab0e4b2d7a8 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30402,13 +30402,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
 
@@ -30574,7 +30576,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
 
@@ -30630,6 +30632,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}
@@ -30699,7 +30704,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
@@ -30724,6 +30729,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 e46a6cc0ec6..e84577f8628 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -408,6 +408,30 @@ 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.*"
+
+    # Define a plain breakpoint first, and a condition later.
+    mi_create_breakpoint "callme" "define a bp" ""
+    mi_gdb_test "-break-condition -force \$bpnum bad" \
+        "${warning}\\^done" \
+        "invalid condition is forced"
+
+    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 123" \
+        "${warning}\\^done,$bp" \
+        "dprintf with forced condition"
+}
+
 proc test_break {mi_mode} {
     global srcdir subdir binfile
 
@@ -440,6 +464,8 @@ proc test_break {mi_mode} {
     test_abreak_creation
 
     test_explicit_breakpoints
+
+    test_forced_conditions
 }
 
 if [gdb_debug_enabled] {
-- 
2.17.1


  parent reply	other threads:[~2021-04-08 14:23 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-31 15:42 [PATCH 0/2] Breakpoint conditions at locations with differing contexts Tankut Baris Aktemur
     [not found] ` <cover.1596209606.git.tankut.baris.aktemur@intel.com>
2020-07-31 15:42   ` [PATCH 1/2] gdb/breakpoint: disable a bp location if condition is invalid at that location Tankut Baris Aktemur
2020-07-31 15:42   ` [RFC][PATCH 2/2] gdb/breakpoint: add a '-force' flag to the 'condition' command Tankut Baris Aktemur
2020-08-03 10:28     ` Andrew Burgess
2020-08-20 21:24 ` [PATCH v2 0/2] Breakpoint conditions at locations with differing contexts Tankut Baris Aktemur
2020-08-20 21:24   ` [PATCH v2 1/2] gdb/breakpoint: disable a bp location if condition is invalid at that location Tankut Baris Aktemur
2020-09-19  3:05     ` Simon Marchi
2020-09-25 15:49       ` Aktemur, Tankut Baris via Gdb-patches
2020-09-25 16:10         ` Simon Marchi
2020-09-25 18:15           ` Aktemur, Tankut Baris via Gdb-patches
2020-10-13 12:24             ` Aktemur, Tankut Baris via Gdb-patches
2020-08-20 21:24   ` [PATCH v2 2/2] gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition Tankut Baris Aktemur
2020-09-04 11:02   ` [PATCH v2 0/2] Breakpoint conditions at locations with differing contexts Tankut Baris Aktemur
2020-09-11 11:56   ` Tankut Baris Aktemur
2020-09-18 20:36   ` [PING][PATCH " Tankut Baris Aktemur
2020-09-25 15:51 ` [PATCH v3 " Tankut Baris Aktemur via Gdb-patches
2020-09-25 15:51   ` [PATCH v3 1/2] gdb/breakpoint: disable a bp location if condition is invalid at that location Tankut Baris Aktemur via Gdb-patches
2020-09-25 15:51   ` [PATCH v3 2/2] gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition Tankut Baris Aktemur via Gdb-patches
2020-10-13 12:25 ` [PATCH v4 0/2] Breakpoint conditions at locations with differing contexts Tankut Baris Aktemur via Gdb-patches
2020-10-13 12:25   ` [PATCH v4 1/2] gdb/breakpoint: disable a bp location if condition is invalid at that location Tankut Baris Aktemur via Gdb-patches
2020-10-13 15:06     ` Eli Zaretskii via Gdb-patches
2020-10-13 15:17       ` Aktemur, Tankut Baris via Gdb-patches
2020-10-16 22:20     ` Simon Marchi
2020-10-13 12:25   ` [PATCH v4 2/2] gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition Tankut Baris Aktemur via Gdb-patches
2020-10-13 15:08     ` Eli Zaretskii via Gdb-patches
2020-10-13 15:46       ` Aktemur, Tankut Baris via Gdb-patches
2020-10-13 16:12         ` Eli Zaretskii via Gdb-patches
2020-10-16 22:45     ` Simon Marchi
2020-10-19 13:58       ` Aktemur, Tankut Baris via Gdb-patches
2020-10-19 14:07         ` Simon Marchi
2020-10-27 10:13         ` Aktemur, Tankut Baris via Gdb-patches
2020-10-29 10:10           ` Tom de Vries
2020-10-29 10:30             ` Aktemur, Tankut Baris via Gdb-patches
2020-10-29 17:30     ` Pedro Alves
2020-11-10 19:33       ` Aktemur, Tankut Baris via Gdb-patches
2020-12-05 17:30         ` Pedro Alves
2020-12-10 20:30           ` Tom Tromey
2020-12-15 11:20             ` Aktemur, Tankut Baris via Gdb-patches
2020-11-10 19:51       ` Aktemur, Tankut Baris via Gdb-patches
2020-10-28 16:57   ` [PATCH v4 0/2] Breakpoint conditions at locations with differing contexts Gary Benson via Gdb-patches
2020-10-29  7:43     ` Aktemur, Tankut Baris via Gdb-patches
2021-04-05 17:45 ` [PATCH " Jonah Graham
2021-04-06 14:11   ` Aktemur, Tankut Baris via Gdb-patches
2021-04-06 14:37     ` Jonah Graham
2021-04-07  7:09       ` Aktemur, Tankut Baris via Gdb-patches
2021-04-07 11:26         ` Jonah Graham
2021-04-07 14:55   ` [PATCH 0/4] Multi-context invalid breakpoint conditions and MI Tankut Baris Aktemur via Gdb-patches
2021-04-07 14:55     ` [PATCH 1/4] gdb/doc: update the 'enabled' field's description for BP locations in MI Tankut Baris Aktemur via Gdb-patches
2021-04-07 15:15       ` Eli Zaretskii via Gdb-patches
2021-04-07 21:42       ` Simon Marchi via Gdb-patches
2021-04-07 14:55     ` [PATCH 2/4] testsuite, gdb.mi: fix duplicate test names in mi-break.exp Tankut Baris Aktemur via Gdb-patches
2021-04-07 21:49       ` Simon Marchi via Gdb-patches
2021-04-07 14:55     ` [PATCH 3/4] gdb/breakpoint: add a 'force_condition' parameter to 'create_breakpoint' Tankut Baris Aktemur via Gdb-patches
2021-04-07 22:08       ` Simon Marchi via Gdb-patches
2021-04-08  7:44         ` Aktemur, Tankut Baris via Gdb-patches
2021-04-08 13:59           ` Simon Marchi via Gdb-patches
2021-04-08 14:19             ` Aktemur, Tankut Baris via Gdb-patches
2021-04-07 14:55     ` [PATCH 4/4] gdb/mi: add a '-b' flag to the '-break-insert' cmd to force the condition Tankut Baris Aktemur via Gdb-patches
2021-04-07 15:18       ` Eli Zaretskii via Gdb-patches
2021-04-07 15:27         ` Aktemur, Tankut Baris via Gdb-patches
2021-04-07 15:53           ` Eli Zaretskii via Gdb-patches
2021-04-07 16:05             ` Aktemur, Tankut Baris via Gdb-patches
2021-04-07 16:50               ` Eli Zaretskii via Gdb-patches
2021-04-07 22:26       ` Simon Marchi via Gdb-patches
2021-04-08 14:22     ` [PATCH v2 0/4] Multi-context invalid breakpoint conditions and MI Tankut Baris Aktemur via Gdb-patches
2021-04-08 14:22       ` [PATCH v2 1/4] gdb/breakpoint: display "N" on MI for disabled-by-condition locations Tankut Baris Aktemur via Gdb-patches
2021-04-08 15:04         ` Eli Zaretskii via Gdb-patches
2021-04-08 14:22       ` [PATCH v2 2/4] testsuite, gdb.mi: fix duplicate test names in mi-break.exp Tankut Baris Aktemur via Gdb-patches
2021-04-08 14:22       ` [PATCH v2 3/4] gdb/breakpoint: add a 'force_condition' parameter to 'create_breakpoint' Tankut Baris Aktemur via Gdb-patches
2021-04-08 14:22       ` Tankut Baris Aktemur via Gdb-patches [this message]
2021-04-08 15:06         ` [PATCH v2 4/4] gdb/mi: add a '--force-condition' flag to the '-break-insert' cmd Eli Zaretskii via Gdb-patches
2021-04-08 15:12           ` Aktemur, Tankut Baris via Gdb-patches
2021-04-11  1:06         ` Jonah Graham
2021-04-11  1:12           ` Simon Marchi via Gdb-patches
2021-04-21 12:06             ` Aktemur, Tankut Baris via Gdb-patches
2021-04-21 12:36               ` Simon Marchi via Gdb-patches
2021-04-11  1:13       ` [PATCH v2 0/4] Multi-context invalid breakpoint conditions and MI Jonah Graham
2021-04-21 12:17       ` [PATCH v3 " Tankut Baris Aktemur via Gdb-patches
2021-04-21 12:17         ` [PATCH v3 1/4] gdb/breakpoint: display "N" on MI for disabled-by-condition locations Tankut Baris Aktemur via Gdb-patches
2021-04-21 12:48           ` Eli Zaretskii via Gdb-patches
2021-04-21 12:17         ` [PATCH v3 2/4] testsuite, gdb.mi: fix duplicate test names in mi-break.exp Tankut Baris Aktemur via Gdb-patches
2021-04-21 12:17         ` [PATCH v3 3/4] gdb/breakpoint: add a 'force_condition' parameter to 'create_breakpoint' Tankut Baris Aktemur via Gdb-patches
2021-04-21 13:18           ` Simon Marchi via Gdb-patches
2021-04-21 13:29             ` Aktemur, Tankut Baris via Gdb-patches
2021-04-21 14:28               ` Simon Marchi via Gdb-patches
2021-04-21 12:17         ` [PATCH v3 4/4] gdb/mi: add a '--force-condition' flag to the '-break-insert' cmd Tankut Baris Aktemur via Gdb-patches
2021-04-21 12:50           ` Eli Zaretskii via Gdb-patches
2021-04-21 13:37           ` Simon Marchi via Gdb-patches
2021-04-21 13:49             ` Aktemur, Tankut Baris via Gdb-patches
2021-04-21 14:26               ` Simon Marchi via Gdb-patches
2021-04-22 14:35         ` [PATCH v4 0/2] Multi-context invalid breakpoint conditions and MI Tankut Baris Aktemur via Gdb-patches
2021-04-22 14:35           ` [PATCH v4 1/2] gdb/mi: add a '--force-condition' flag to the '-break-insert' cmd Tankut Baris Aktemur via Gdb-patches
2021-05-06  2:40             ` Simon Marchi via Gdb-patches
2021-04-22 14:35           ` [PATCH v4 2/2] gdb/mi: add a '--force' flag to the '-break-condition' command Tankut Baris Aktemur via Gdb-patches
2021-04-22 14:47             ` Aktemur, Tankut Baris via Gdb-patches
2021-05-06  2:46             ` Simon Marchi via Gdb-patches
2021-05-06  8:50               ` Aktemur, Tankut Baris via Gdb-patches
2021-07-11 18:51               ` Jonah Graham
2021-07-12  0:25                 ` Jonah Graham
2021-07-12  8:33                 ` Aktemur, Tankut Baris via Gdb-patches
2021-05-05 15:57           ` [PATCH v4 0/2] Multi-context invalid breakpoint conditions and MI Aktemur, Tankut Baris via Gdb-patches
2021-04-07 21:24   ` [PATCH 0/2] Breakpoint conditions at locations with differing contexts Simon Marchi via Gdb-patches
2021-04-07 21:36     ` Jonah Graham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b74c99ece1389942444dedac26b241ce73343e02.1617875845.git.tankut.baris.aktemur@intel.com \
    --to=gdb-patches@sourceware.org \
    --cc=tankut.baris.aktemur@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox