gdb/breakpoint: refactor 'set_breakpoint_condition'
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 30 Jul 2020 17:23:38 +0000 (19:23 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 30 Jul 2020 17:23:38 +0000 (19:23 +0200)
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.

gdb/ChangeLog
gdb/breakpoint.c

index cfc5b6db5f29b0cfbc017026e4df54c4ecec44d7..5d5535692c8848d5cdcebe96caf5321b24461fd1 100644 (file)
@@ -1,3 +1,7 @@
+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
index 7e020c5f666a6ddbb2c886dafa3d6ed018dc5b84..977599db1db40ceccf3814f38e8ef54e8c156a72 100644 (file)
@@ -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);