public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/3] Change location_to_sals to a method
Date: Fri, 27 May 2022 20:42:30 -0600	[thread overview]
Message-ID: <20220528024231.474534-3-tom@tromey.com> (raw)
In-Reply-To: <20220528024231.474534-1-tom@tromey.com>

location_to_sals is only ever called for code breakpoints, so make it
a protected method there.
---
 gdb/breakpoint.c | 58 ++++++++++++++++++++++++------------------------
 gdb/breakpoint.h |  8 +++++++
 2 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index cc0d527fd30..ee34733e6cd 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -12621,9 +12621,10 @@ update_breakpoint_locations (code_breakpoint *b,
 /* Find the SaL locations corresponding to the given LOCATION.
    On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
 
-static std::vector<symtab_and_line>
-location_to_sals (struct breakpoint *b, struct event_location *location,
-		  struct program_space *search_pspace, int *found)
+std::vector<symtab_and_line>
+code_breakpoint::location_to_sals (struct event_location *location,
+				   struct program_space *search_pspace,
+				   int *found)
 {
   struct gdb_exception exception;
 
@@ -12631,7 +12632,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 
   try
     {
-      sals = b->decode_location (location, search_pspace);
+      sals = decode_location (location, search_pspace);
     }
   catch (gdb_exception_error &e)
     {
@@ -12645,13 +12646,13 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 	 breakpoint being disabled, and don't want to see more
 	 errors.  */
       if (e.error == NOT_FOUND_ERROR
-	  && (b->condition_not_parsed
-	      || (b->loc != NULL
+	  && (condition_not_parsed
+	      || (loc != NULL
 		  && search_pspace != NULL
-		  && b->loc->pspace != search_pspace)
-	      || (b->loc && b->loc->shlib_disabled)
-	      || (b->loc && b->loc->pspace->executing_startup)
-	      || b->enable_state == bp_disabled))
+		  && loc->pspace != search_pspace)
+	      || (loc && loc->shlib_disabled)
+	      || (loc && loc->pspace->executing_startup)
+	      || enable_state == bp_disabled))
 	not_found_and_ok = 1;
 
       if (!not_found_and_ok)
@@ -12662,7 +12663,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
 	     have separate 'warning emitted' flag.  Since this
 	     happens only when a binary has changed, I don't know
 	     which approach is better.  */
-	  b->enable_state = bp_disabled;
+	  enable_state = bp_disabled;
 	  throw;
 	}
 
@@ -12673,26 +12674,26 @@ location_to_sals (struct breakpoint *b, struct event_location *location,
     {
       for (auto &sal : sals)
 	resolve_sal_pc (&sal);
-      if (b->condition_not_parsed && b->extra_string != NULL)
+      if (condition_not_parsed && extra_string != NULL)
 	{
-	  gdb::unique_xmalloc_ptr<char> cond_string, extra_string;
+	  gdb::unique_xmalloc_ptr<char> local_cond, local_extra;
 	  int thread, task;
 
-	  find_condition_and_thread_for_sals (sals, b->extra_string.get (),
-					      &cond_string, &thread,
-					      &task, &extra_string);
-	  gdb_assert (b->cond_string == NULL);
-	  if (cond_string)
-	    b->cond_string = std::move (cond_string);
-	  b->thread = thread;
-	  b->task = task;
-	  if (extra_string)
-	    b->extra_string = std::move (extra_string);
-	  b->condition_not_parsed = 0;
+	  find_condition_and_thread_for_sals (sals, extra_string.get (),
+					      &local_cond, &thread,
+					      &task, &local_extra);
+	  gdb_assert (cond_string == nullptr);
+	  if (local_cond != nullptr)
+	    cond_string = std::move (local_cond);
+	  thread = thread;
+	  task = task;
+	  if (local_extra != nullptr)
+	    extra_string = std::move (local_extra);
+	  condition_not_parsed = 0;
 	}
 
-      if (b->type == bp_static_tracepoint)
-	sals[0] = update_static_tracepoint (b, sals[0]);
+      if (type == bp_static_tracepoint)
+	sals[0] = update_static_tracepoint (this, sals[0]);
 
       *found = 1;
     }
@@ -12713,7 +12714,7 @@ code_breakpoint::re_set_default ()
   std::vector<symtab_and_line> expanded, expanded_end;
 
   int found;
-  std::vector<symtab_and_line> sals = location_to_sals (this, location.get (),
+  std::vector<symtab_and_line> sals = location_to_sals (location.get (),
 							filter_pspace, &found);
   if (found)
     expanded = std::move (sals);
@@ -12721,8 +12722,7 @@ code_breakpoint::re_set_default ()
   if (location_range_end != NULL)
     {
       std::vector<symtab_and_line> sals_end
-	= location_to_sals (this, location_range_end.get (),
-			    filter_pspace, &found);
+	= location_to_sals (location_range_end.get (), filter_pspace, &found);
       if (found)
 	expanded_end = std::move (sals_end);
     }
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 4fdd50324e3..5ce6edf6efc 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -890,6 +890,14 @@ struct code_breakpoint : public breakpoint
 
   /* Helper method that does the basic work of re_set.  */
   void re_set_default ();
+
+  /* Find the SaL locations corresponding to the given LOCATION.
+     On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
+
+  std::vector<symtab_and_line> location_to_sals
+       (struct event_location *location,
+	struct program_space *search_pspace,
+	int *found);
 };
 
 /* An instance of this type is used to represent a watchpoint,
-- 
2.34.1


  parent reply	other threads:[~2022-05-28  2:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28  2:42 [PATCH 0/3] More minor breakpoint cleanups Tom Tromey
2022-05-28  2:42 ` [PATCH 1/3] Change breakpoint_re_set_default to a method Tom Tromey
2022-05-30 15:32   ` Pedro Alves
2022-05-28  2:42 ` Tom Tromey [this message]
2022-05-30 15:32   ` [PATCH 2/3] Change location_to_sals " Pedro Alves
2022-06-01  4:50     ` Tom Tromey
2022-06-01 16:38       ` Pedro Alves
2022-06-10 21:34         ` Tom Tromey
2022-06-13 14:36           ` Pedro Alves
2022-08-14  0:44     ` Tom Tromey
2022-05-28  2:42 ` [PATCH 3/3] Move decode_location to code_breakpoint Tom Tromey
2022-05-30 15:42   ` Pedro Alves
2022-08-14  0:41     ` Tom Tromey
2022-08-14  0:45 ` [PATCH 0/3] More minor breakpoint cleanups Tom Tromey

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=20220528024231.474534-3-tom@tromey.com \
    --to=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).