Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/3] gdb/breakpoint: refactor 'set_breakpoint_condition'
Date: Mon, 29 Jun 2020 15:48:28 +0200	[thread overview]
Message-ID: <453f3c95a7e485dd900541defcc98f0c9cf1dd62.1593438119.git.tankut.baris.aktemur@intel.com> (raw)
In-Reply-To: <cover.1593438119.git.tankut.baris.aktemur@intel.com>
In-Reply-To: <cover.1593438119.git.tankut.baris.aktemur@intel.com>

Apply minor refactoring to 'set_breakpoint_condition'.

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

	* breakpoint.c (set_breakpoint_condition): Do minor refactoring.
---
 gdb/breakpoint.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index abda470fe21..aebc123f86f 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,31 +858,26 @@ 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;
-
-	  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;
 	      expression_up new_exp
 		= parse_exp_1 (&arg, loc->address,
 			       block_for_pc (loc->address), 0);
-	      if (*arg)
+	      if (*arg != 0)
 		error (_("Junk at end of expression"));
 	      loc->cond = std::move (new_exp);
 	    }
-- 
2.17.1



  parent reply	other threads:[~2020-06-29 13:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 13:48 [PATCH 0/3] Prevent bad conditions from putting breakpoints into broken state Tankut Baris Aktemur
2020-06-29 13:48 ` [PATCH 1/3] gdb/breakpoint: do not update the condition string if parsing the condition fails Tankut Baris Aktemur
2020-07-22 13:12   ` Simon Marchi
2020-07-22 13:15     ` Simon Marchi
2020-06-29 13:48 ` [PATCH 2/3] gdb/breakpoint: set the condition exp after parsing the condition successfully Tankut Baris Aktemur
2020-07-22 13:21   ` Simon Marchi
2020-07-22 13:28     ` Simon Marchi
2020-07-22 15:29       ` Aktemur, Tankut Baris
2020-07-22 16:06         ` Simon Marchi
2020-07-23  7:11           ` Aktemur, Tankut Baris
2020-07-30 10:56             ` Aktemur, Tankut Baris
2020-07-30 15:15               ` Simon Marchi
2020-06-29 13:48 ` Tankut Baris Aktemur [this message]
2020-07-13  8:45 ` [PATCH 0/3] Prevent bad conditions from putting breakpoints into broken state Tankut Baris Aktemur
2020-07-21  9:08 ` Tankut Baris Aktemur
2020-07-22 18:24   ` Pedro Alves
2020-07-23  7:13     ` Aktemur, Tankut Baris

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=453f3c95a7e485dd900541defcc98f0c9cf1dd62.1593438119.git.tankut.baris.aktemur@intel.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    /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