aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-07-30 19:23:38 +0200
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-07-30 19:23:38 +0200
commit78319c1568ce20c41f5002e61bd9427a1cf59aac (patch)
treec7f8dc048bdd40d13a5065e231504fceb6cbd198
parent4c55e9702527b73ff301e5c06f2055a606348de1 (diff)
downloadgdb-78319c1568ce20c41f5002e61bd9427a1cf59aac.zip
gdb-78319c1568ce20c41f5002e61bd9427a1cf59aac.tar.gz
gdb-78319c1568ce20c41f5002e61bd9427a1cf59aac.tar.bz2
gdb/breakpoint: refactor 'set_breakpoint_condition'
Apply minor refactoring to 'set_breakpoint_condition'. gdb/ChangeLog: 2020-07-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * breakpoint.c (set_breakpoint_condition): Do minor refactoring.
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/breakpoint.c29
2 files changed, 13 insertions, 20 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cfc5b6d..5d55356 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2020-07-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+ * breakpoint.c (set_breakpoint_condition): Do minor refactoring.
+
+2020-07-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
* breakpoint.c (set_breakpoint_condition): Update the condition
expressions after checking that the input condition string parses
successfully and does not contain junk at the end.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7e020c5..977599d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -840,16 +840,10 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
b->cond_string = nullptr;
if (is_watchpoint (b))
- {
- struct watchpoint *w = (struct watchpoint *) b;
-
- w->cond_exp.reset ();
- }
+ static_cast<watchpoint *> (b)->cond_exp.reset ();
else
{
- struct bp_location *loc;
-
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc = b->loc; loc != nullptr; loc = loc->next)
{
loc->cond.reset ();
@@ -864,24 +858,19 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
}
else
{
- const char *arg = exp;
-
if (is_watchpoint (b))
{
- struct watchpoint *w = (struct watchpoint *) b;
-
innermost_block_tracker tracker;
- arg = exp;
+ const char *arg = exp;
expression_up new_exp = parse_exp_1 (&arg, 0, 0, 0, &tracker);
- if (*arg)
+ if (*arg != 0)
error (_("Junk at end of expression"));
+ watchpoint *w = static_cast<watchpoint *> (b);
w->cond_exp = std::move (new_exp);
w->cond_exp_valid_block = tracker.block ();
}
else
{
- struct bp_location *loc;
-
/* Parse and set condition expressions. We make two passes.
In the first, we parse the condition string to see if it
is valid in all locations. If so, the condition would be
@@ -890,9 +879,9 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
the error and the condition string will be rejected.
This two-pass approach is taken to avoid setting the
state of locations in case of a reject. */
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc = b->loc; loc != nullptr; loc = loc->next)
{
- arg = exp;
+ const char *arg = exp;
parse_exp_1 (&arg, loc->address,
block_for_pc (loc->address), 0);
if (*arg != 0)
@@ -900,9 +889,9 @@ set_breakpoint_condition (struct breakpoint *b, const char *exp,
}
/* If we reach here, the condition is valid at all locations. */
- for (loc = b->loc; loc; loc = loc->next)
+ for (bp_location *loc = b->loc; loc != nullptr; loc = loc->next)
{
- arg = exp;
+ const char *arg = exp;
loc->cond =
parse_exp_1 (&arg, loc->address,
block_for_pc (loc->address), 0);