diff options
author | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-10-27 10:56:03 +0100 |
---|---|---|
committer | Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> | 2020-10-27 11:00:57 +0100 |
commit | 733d554a4625db4ffb89b7a20e1cf27ab071ef4d (patch) | |
tree | d80ff024b78e88d2eba1c53d91766761a0ee92e8 /gdb/doc | |
parent | b5fa468fef441528147c3a47b085612d5305f181 (diff) | |
download | fsf-binutils-gdb-733d554a4625db4ffb89b7a20e1cf27ab071ef4d.zip fsf-binutils-gdb-733d554a4625db4ffb89b7a20e1cf27ab071ef4d.tar.gz fsf-binutils-gdb-733d554a4625db4ffb89b7a20e1cf27ab071ef4d.tar.bz2 |
gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition
The previous patch made it possible to define a condition if it's
valid at some locations. If the condition is invalid at all of the
locations, it's rejected. However, there may be cases where the user
knows the condition *will* be valid at a location in the future,
e.g. due to a shared library load.
To make it possible that such condition can be defined, this patch
adds an optional '-force' flag to the 'condition' command, and,
respectively, a '-force-condition' flag to the 'break'command. When
the force flag is passed, the condition is not rejected even when it
is invalid for all the current locations (note that all the locations
would be internally disabled in this case).
For instance:
(gdb) break test.c:5
Breakpoint 1 at 0x1155: file test.c, line 5.
(gdb) cond 1 foo == 42
No symbol "foo" in current context.
Defining the condition was not possible because 'foo' is not
available. The user can override this behavior with the '-force'
flag:
(gdb) cond -force 1 foo == 42
warning: failed to validate condition at location 1.1, disabling:
No symbol "foo" in current context.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
stop only if foo == 42
1.1 N 0x0000000000001155 in main at test.c:5
Now the condition is accepted, but the location is automatically
disabled. If a future location has a context in which 'foo' is
available, that location would be enabled.
For the 'break' command, -force-condition has the same result:
(gdb) break test.c:5 -force-condition if foo == 42
warning: failed to validate condition at location 0x1169, disabling:
No symbol "foo" in current context.
Breakpoint 1 at 0x1169: file test.c, line 5.
gdb/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* breakpoint.h (set_breakpoint_condition): Add a new bool parameter.
* breakpoint.c: Update the help text of the 'condition' and 'break'
commands.
(set_breakpoint_condition): Take a new bool parameter
to control whether condition definition should be forced even when
the condition expression is invalid in all of the current locations.
(condition_command): Update the call to 'set_breakpoint_condition'.
(find_condition_and_thread): Take the "-force-condition" flag into
account.
* linespec.c (linespec_keywords): Add "-force-condition" as an
element.
(FORCE_KEYWORD_INDEX): New #define.
(linespec_lexer_lex_keyword): Update to consider "-force-condition"
as a keyword.
* ada-lang.c (create_ada_exception_catchpoint): Ditto.
* guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x): Ditto.
* python/py-breakpoint.c (bppy_set_condition): Ditto.
* NEWS: Mention the changes to the 'break' and 'condition' commands.
gdb/testsuite/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.base/condbreak-multi-context.exp: Expand to test forcing
the condition.
* gdb.linespec/cpcompletion.exp: Update to consider the
'-force-condition' keyword.
* gdb.linespec/explicit.exp: Ditto.
* lib/completion-support.exp: Ditto.
gdb/doc/ChangeLog:
2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdb.texinfo (Set Breaks): Document the '-force-condition' flag
of the 'break'command.
* gdb.texinfo (Conditions): Document the '-force' flag of the
'condition' command.
Diffstat (limited to 'gdb/doc')
-rw-r--r-- | gdb/doc/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 30 |
2 files changed, 37 insertions, 0 deletions
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 84c173b..b8a4429 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,5 +1,12 @@ 2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + * gdb.texinfo (Set Breaks): Document the '-force-condition' flag + of the 'break'command. + * gdb.texinfo (Conditions): Document the '-force' flag of the + 'condition' command. + +2020-10-27 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + * gdb.texinfo (Set Breaks): Document disabling of breakpoint locations for which the breakpoint condition is invalid. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9da79ed..d779d4a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4318,6 +4318,30 @@ undefined variable: No symbol "foo" in current context. @end smallexample +@item break @dots{} -force-condition if @var{cond} +There may be cases where the condition @var{cond} is invalid at all +the current locations, but the user knows that it will be valid at a +future location; for example, because of a library load. In such +cases, by using the @code{-force-condition} keyword before @samp{if}, +@value{GDBN} can be forced to define the breakpoint with the given +condition expression instead of refusing it. + +@smallexample +(@value{GDBP}) break func -force-condition if foo +warning: failed to validate condition at location 1, disabling: + No symbol "foo" in current context. +warning: failed to validate condition at location 2, disabling: + No symbol "foo" in current context. +warning: failed to validate condition at location 3, disabling: + No symbol "foo" in current context. +Breakpoint 1 at 0x1158: test.c:18. (3 locations) +@end smallexample + +This causes all the present locations where the breakpoint would +otherwise be inserted, to be disabled, as seen in the example above. +However, if there exist locations at which the condition is valid, the +@code{-force-condition} keyword has no effect. + @kindex tbreak @item tbreak @var{args} Set a breakpoint enabled only for one stop. The @var{args} are the @@ -5503,6 +5527,12 @@ not actually evaluate @var{expression} at the time the @code{condition} command (or a command that sets a breakpoint with a condition, like @code{break if @dots{}}) is given, however. @xref{Expressions, ,Expressions}. +@item condition -force @var{bnum} @var{expression} +When the @code{-force} flag is used, define the condition even if +@var{expression} is invalid at all the current locations of breakpoint +@var{bnum}. This is similar to the @code{-force-condition} option +of the @code{break} command. + @item condition @var{bnum} Remove the condition from breakpoint number @var{bnum}. It becomes an ordinary unconditional breakpoint. |