This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Partially revert init_breakpoint_sal new_address_location change


Hi.

Sorry I didn't catch this during the initial review.

Here's the code as it is today:

  if (location != NULL)
    b->location = location;
  else
    {
      const char *addr_string = NULL;
      int addr_string_len = 0;

   if (location != NULL) <<<
	addr_string = event_location_to_string (location);
      if (addr_string != NULL)
	addr_string_len = strlen (addr_string);

      b->location = new_address_location (b->loc->address,
					  addr_string, addr_string_len);
    }

This test ">>> ... <<<" is pointless because we only enter the else clause
if location == NULL. Instead, assuming(!) the patch is otherwise correct,
we just need to update the call to new_address_location, which the
patch below does.

I have more changes I wish to make related to this change:
https://sourceware.org/ml/gdb-patches/2016-01/msg00352.html
but I think they can be handled separately (time will tell).

btw, a separate question I have is: Should we even allow passing
a NULL location to init_breakpoint_sal? Seems like it introduces
some fragility, if not bugs.

2016-01-21  Doug Evans  <dje@google.com>

	Partially revert:
	2016-01-21  Joel Brobecker  <brobecker@adacore.com>
	* breakpoint.c (init_breakpoint_sal): Get the event location's string,
	if any, and use it to update call to new_address_location.
	Instead, just update call to new_address_location.

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7b610ef..494cb33 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9370,18 +9370,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdbarch *gdbarch,
   if (location != NULL)
     b->location = location;
   else
-    {
-      const char *addr_string = NULL;
-      int addr_string_len = 0;
-
-      if (location != NULL)
-	addr_string = event_location_to_string (location);
-      if (addr_string != NULL)
-	addr_string_len = strlen (addr_string);
-
-      b->location = new_address_location (b->loc->address,
-					  addr_string, addr_string_len);
-    }
+    b->location = new_address_location (b->loc->address, NULL, 0);
   b->filter = filter;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]