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]

delete shlib_event breakpoints from a previous run in common code


This patches makes us always delete solib event breakpoints from a
previous run in common code.

Currently, shlib_event breakpoints are only removed by the inferior's
solib-*.c backend, just before the latter tries to install a new
shlib_event breakpoint.  This is usually done within the
solib_ops' ops->solib_create_inferior_hook implementation.  But,
if the user switches to debug a different program against a
different target (target/arch/osabi) in the same gdb session, the
solib-*.c backend used by the new inferior process incarnation may
not be the same as it was in the previous incarnation.  E.g.,

	   (gdb) file prog-linux
	   (gdb) run           # native linux target
	   ...
	   (gdb) kill

This used solib-svr4.c, and left the solib event
breakpoint behind.


	   (gdb) run           # native linux target
	   ...
	   (gdb) kill

This used solib-svr4.c again, and so cleared the previous
solib event breakpoint before creating a new one.


	   (gdb) file prog-win.exe
	   (gdb) tar rem :9999  # remote Windows gdbserver.

But this used solib-target.c.  Nothing in solib-target.c calls remove_solib_event_breakpoints (nor should it need to), because
this solib_ops doesn't need a shlib_event breakpoint.  So, we
end up with a left over solib event breakpoint in the
breakpoint table:

              (gdb) maint info breakpoints
              Num     Type           Disp Enb Address    What
              -15     shlib events   keep y   0x00408247 <main> inf 1
              -16     longjmp master keep n   0x0040fd60 <longjmp> inf 1
              (gdb)

Note breakpoint -15.

Due to getting at the shlib_event breakpoint final address
in two stages, solib-frv.c still needs to be able to delete
the first stage's shlib_event breakpoint, and so is now
the only caller of remove_solib_event_breakpoints.

Tested on x86_64-linux and checked in.

-- 
Pedro Alves

2010-02-24  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* breakpoint.c (breakpoint_init_inferior): Also delete
	bp_shlib_event breakpoints.
	* solib-frv.c (enable_break): Remove call to
	remove_solib_event_breakpoints.
	* solib-svr4.c (enable_break): Ditto.
	* solib-darwin.c (darwin_solib_create_inferior_hook): Ditto.
	* solib-pa64.c (pa64_solib_create_inferior_hook): Ditto.
	* solib-som.c (som_solib_create_inferior_hook): Ditto.
	* solib-spu.c (spu_enable_break): Ditto.

---
 gdb/breakpoint.c   |   26 ++++++++++++++++++++++----
 gdb/solib-darwin.c |    4 ----
 gdb/solib-frv.c    |    4 ----
 gdb/solib-pa64.c   |    4 ----
 gdb/solib-som.c    |    4 ----
 gdb/solib-spu.c    |    4 ----
 gdb/solib-svr4.c   |    4 ----
 7 files changed, 22 insertions(+), 28 deletions(-)

Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/breakpoint.c	2010-02-24 00:25:00.000000000 +0000
@@ -2248,13 +2248,31 @@ breakpoint_init_inferior (enum inf_conte
     switch (b->type)
       {
       case bp_call_dummy:
-      case bp_watchpoint_scope:
 
 	/* If the call dummy breakpoint is at the entry point it will
-	   cause problems when the inferior is rerun, so we better
-	   get rid of it. 
+	   cause problems when the inferior is rerun, so we better get
+	   rid of it.  */
+
+      case bp_watchpoint_scope:
+
+	/* Also get rid of scope breakpoints.  */
+
+      case bp_shlib_event:
+
+	/* Also remove solib event breakpoints.  Their addresses may
+	   have changed since the last time we ran the program.
+	   Actually we may now be debugging against different target;
+	   and so the solib backend that installed this breakpoint may
+	   not be used in by the target.  E.g.,
+
+	   (gdb) file prog-linux
+	   (gdb) run               # native linux target
+	   ...
+	   (gdb) kill
+	   (gdb) file prog-win.exe
+	   (gdb) tar rem :9999     # remote Windows gdbserver.
+	*/
 
-	   Also get rid of scope breakpoints.  */
 	delete_breakpoint (b);
 	break;
 
Index: src/gdb/solib-frv.c
===================================================================
--- src.orig/gdb/solib-frv.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/solib-frv.c	2010-02-24 00:12:57.000000000 +0000
@@ -818,10 +818,6 @@ enable_break (void)
 {
   asection *interp_sect;
 
-  /* Remove all the solib event breakpoints.  Their addresses
-     may have changed since the last time we ran the program.  */
-  remove_solib_event_breakpoints ();
-
   if (symfile_objfile == NULL)
     {
       if (solib_frv_debug)
Index: src/gdb/solib-svr4.c
===================================================================
--- src.orig/gdb/solib-svr4.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/solib-svr4.c	2010-02-23 23:15:45.000000000 +0000
@@ -1315,10 +1315,6 @@ enable_break (struct svr4_info *info, in
   gdb_byte *interp_name;
   CORE_ADDR sym_addr;
 
-  /* First, remove all the solib event breakpoints.  Their addresses
-     may have changed since the last time we ran the program.  */
-  remove_solib_event_breakpoints ();
-
   info->interp_text_sect_low = info->interp_text_sect_high = 0;
   info->interp_plt_sect_low = info->interp_plt_sect_high = 0;
 
Index: src/gdb/solib-darwin.c
===================================================================
--- src.orig/gdb/solib-darwin.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/solib-darwin.c	2010-02-23 23:15:45.000000000 +0000
@@ -309,10 +309,6 @@ darwin_solib_create_inferior_hook (int f
   bfd *dyld_bfd = NULL;
   struct inferior *inf = current_inferior ();
 
-  /* First, remove all the solib event breakpoints.  Their addresses
-     may have changed since the last time we ran the program.  */
-  remove_solib_event_breakpoints ();
-
   /* Find the program interpreter.  */
   interp_name = find_program_interpreter ();
   if (!interp_name)
Index: src/gdb/solib-pa64.c
===================================================================
--- src.orig/gdb/solib-pa64.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/solib-pa64.c	2010-02-23 23:15:45.000000000 +0000
@@ -338,10 +338,6 @@ pa64_solib_create_inferior_hook (int fro
   struct objfile *objfile;
   CORE_ADDR anaddr;
 
-  /* First, remove all the solib event breakpoints.  Their addresses
-     may have changed since the last time we ran the program.  */
-  remove_solib_event_breakpoints ();
-
   if (symfile_objfile == NULL)
     return;
 
Index: src/gdb/solib-som.c
===================================================================
--- src.orig/gdb/solib-som.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/solib-som.c	2010-02-23 23:15:45.000000000 +0000
@@ -192,10 +192,6 @@ som_solib_create_inferior_hook (int from
   char buf[4];
   CORE_ADDR anaddr;
 
-  /* First, remove all the solib event breakpoints.  Their addresses
-     may have changed since the last time we ran the program.  */
-  remove_solib_event_breakpoints ();
-
   if (symfile_objfile == NULL)
     return;
 
Index: src/gdb/solib-spu.c
===================================================================
--- src.orig/gdb/solib-spu.c	2010-02-23 23:15:43.000000000 +0000
+++ src/gdb/solib-spu.c	2010-02-23 23:15:45.000000000 +0000
@@ -367,10 +367,6 @@ spu_enable_break (struct objfile *objfil
 static void
 spu_solib_create_inferior_hook (int from_tty)
 {
-  /* Remove all previously installed solib breakpoints.  Both the SVR4
-     code and us will re-install all required breakpoints.  */
-  remove_solib_event_breakpoints ();
-
   /* Handle SPE stand-alone executables.  */
   if (spu_standalone_p ())
     {


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