This is the mail archive of the gdb-patches@sources.redhat.com 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, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment


Hello,

The attached patch is to address a problem with PPC64 where the minimal symbol table provides addresses for function descriptors and not proper functions.

First the "adjust_breakpoint_address" interface is changed so that it returns non-zero if GDB should warn the user of any breakpoint adjustment.

It then modifies breakpoint.c to work with that new interface. And ppc64 to provide a version of that interface that doesn't require any warning.

For breakpoint.c, I've also modified the warnings so that the warning:

warning: Breakpoint 2 address previously adjusted from 0x104e5a60 to 0x100895d0.

no longer occures - I figure that the user will have noted it when the breakpoint was set. It could also be made per-breakpoint?

so, thoughts?
ok?

Andrew

PS: Here's the original hack.
http://sources.redhat.com/ml/gdb-patches/2003-09/msg00415.html
And kevin's original adjust_breakpoint_address posthttp://sources.redhat.com/ml/gdb-patches/2003-10/msg00404.html
2003-10-27  Andrew Cagney  <cagney@redhat.com>

	* gdbarch.sh (adjust_breakpoint_address): Change return type to
	int, make "bpaddr" a reference parameter.
	* gdbarch.h, gdbarch.c: Re-generate.
	* breakpoint.c (adjust_breakpoint_address): Make printing a
	warning conditional on adjust_breakpoint_address.
	(print_it_typical): Do not print breakpoint_adjustment_warning.
	* ppc-linux-tdep.c (ppc_linux_init_abi): For 64-bit ABI, set
	adjust_breakpoint_address.
	* ppc-tdep.h (ppc64_sysv_abi_adjust_breakpoint_address): Declare.
	* Makefile.in (ppc-sysv-tdep.o): Update dependencies.
	* ppc-sysv-tdep.c: Include "target.h".
	(ppc64_sysv_abi_adjust_breakpoint_address): New function.
	* frv-tdep.c (frv_gdbarch_adjust_breakpoint_address): Return
	non-zero.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.463
diff -u -r1.463 Makefile.in
--- Makefile.in	24 Oct 2003 20:24:05 -0000	1.463
+++ Makefile.in	28 Oct 2003 17:30:12 -0000
@@ -2126,7 +2126,8 @@
 	$(target_h) $(breakpoint_h) $(value_h) $(osabi_h) $(ppc_tdep_h) \
 	$(ppcnbsd_tdep_h) $(nbsd_tdep_h) $(solib_svr4_h)
 ppc-sysv-tdep.o: ppc-sysv-tdep.c $(defs_h) $(gdbcore_h) $(inferior_h) \
-	$(regcache_h) $(value_h) $(gdb_string_h) $(gdb_assert_h) $(ppc_tdep_h)
+	$(regcache_h) $(value_h) $(gdb_string_h) $(gdb_assert_h) $(ppc_tdep_h) \
+	$(target_h)
 printcmd.o: printcmd.c $(defs_h) $(gdb_string_h) $(frame_h) $(symtab_h) \
 	$(gdbtypes_h) $(value_h) $(language_h) $(expression_h) $(gdbcore_h) \
 	$(gdbcmd_h) $(target_h) $(breakpoint_h) $(demangle_h) $(valprint_h) \
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.133
diff -u -r1.133 breakpoint.c
--- breakpoint.c	21 Oct 2003 22:56:38 -0000	1.133
+++ breakpoint.c	28 Oct 2003 17:30:13 -0000
@@ -2027,10 +2027,6 @@
     {
     case bp_breakpoint:
     case bp_hardware_breakpoint:
-      if (bs->breakpoint_at->address != bs->breakpoint_at->requested_address)
-	breakpoint_adjustment_warning (bs->breakpoint_at->requested_address,
-	                               bs->breakpoint_at->address,
-				       bs->breakpoint_at->number, 1);
       annotate_breakpoint (bs->breakpoint_at->number);
       ui_out_text (uiout, "\nBreakpoint ");
       if (ui_out_is_mi_like_p (uiout))
@@ -3879,19 +3875,22 @@
     }
   else
     {
-      CORE_ADDR adjusted_bpaddr;
-
-      /* Some targets have architectural constraints on the placement
-         of breakpoint instructions.  Obtain the adjusted address.  */
-      adjusted_bpaddr = gdbarch_adjust_breakpoint_address (current_gdbarch,
-                                                           bpaddr);
-
-      /* An adjusted breakpoint address can significantly alter
-         a user's expectations.  Print a warning if an adjustment
-	 is required.  */
-      if (adjusted_bpaddr != bpaddr)
-	breakpoint_adjustment_warning (bpaddr, adjusted_bpaddr, 0, 0);
+      CORE_ADDR adjusted_bpaddr = bpaddr;
 
+      /* Some architectures have constraints on the placement of
+         breakpoint instructions (see FRV), some ABIs have symbols
+         that point at a descriptor, instead of the code (see PPC64).
+         Obtain the adjusted address.  */
+      if (gdbarch_adjust_breakpoint_address (current_gdbarch,
+					     &adjusted_bpaddr))
+	{
+	  /* An adjusted breakpoint address can significantly alter a
+	     user's expectations.  If the architecture indicates
+	     (returns non-zero) that the adjustment should be
+	     considered "unexpected", print a warning..  */
+	  if (adjusted_bpaddr != bpaddr)
+	    breakpoint_adjustment_warning (bpaddr, adjusted_bpaddr, 0, 0);
+	}
       return adjusted_bpaddr;
     }
 }
Index: frv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/frv-tdep.c,v
retrieving revision 1.57
diff -u -r1.57 frv-tdep.c
--- frv-tdep.c	27 Oct 2003 06:30:49 -0000	1.57
+++ frv-tdep.c	28 Oct 2003 17:30:13 -0000
@@ -37,7 +37,6 @@
 
 static gdbarch_register_name_ftype frv_register_name;
 static gdbarch_breakpoint_from_pc_ftype frv_breakpoint_from_pc;
-static gdbarch_adjust_breakpoint_address_ftype frv_gdbarch_adjust_breakpoint_address;
 static gdbarch_skip_prologue_ftype frv_skip_prologue;
 static gdbarch_deprecated_extract_return_value_ftype frv_extract_return_value;
 static gdbarch_deprecated_extract_struct_value_address_ftype frv_extract_struct_value_address;
@@ -269,12 +268,12 @@
 /* Adjust a breakpoint's address to account for the FR-V architecture's
    constraint that a break instruction must not appear as any but the
    first instruction in the bundle.  */
-static CORE_ADDR
-frv_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
+static int
+frv_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR *bpaddr)
 {
   int count = max_instrs_per_bundle;
-  CORE_ADDR addr = bpaddr - frv_instr_size;
-  CORE_ADDR func_start = get_pc_function_start (bpaddr);
+  CORE_ADDR addr = (*bpaddr) - frv_instr_size;
+  CORE_ADDR func_start = get_pc_function_start ((*bpaddr));
 
   /* Find the end of the previous packing sequence.  This will be indicated
      by either attempting to access some inaccessible memory or by finding
@@ -299,9 +298,11 @@
     }
 
   if (count > 0)
-    bpaddr = addr + frv_instr_size;
+    (*bpaddr) = addr + frv_instr_size;
 
-  return bpaddr;
+  /* Return non-zero indicating that any adjustment made should be
+     reported to the user.  */
+  return 1;
 }
 
 
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.255
diff -u -r1.255 gdbarch.c
--- gdbarch.c	22 Oct 2003 23:54:10 -0000	1.255
+++ gdbarch.c	28 Oct 2003 17:30:14 -0000
@@ -820,6 +820,12 @@
                       "gdbarch_dump: return_value = 0x%08lx\n",
                       (long) current_gdbarch->return_value);
   fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_adjust_breakpoint_address_p() = %d\n",
+                      gdbarch_adjust_breakpoint_address_p (current_gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: adjust_breakpoint_address = 0x%08lx\n",
+                      (long) current_gdbarch->adjust_breakpoint_address);
+  fprintf_unfiltered (file,
                       "gdbarch_dump: in_function_epilogue_p = 0x%08lx\n",
                       (long) current_gdbarch->in_function_epilogue_p);
   fprintf_unfiltered (file,
@@ -891,12 +897,6 @@
                       (long) current_gdbarch->addr_bits_remove
                       /*ADDR_BITS_REMOVE ()*/);
 #endif
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: gdbarch_adjust_breakpoint_address_p() = %d\n",
-                      gdbarch_adjust_breakpoint_address_p (current_gdbarch));
-  fprintf_unfiltered (file,
-                      "gdbarch_dump: adjust_breakpoint_address = 0x%08lx\n",
-                      (long) current_gdbarch->adjust_breakpoint_address);
 #ifdef BELIEVE_PCC_PROMOTION
   fprintf_unfiltered (file,
                       "gdbarch_dump: BELIEVE_PCC_PROMOTION # %s\n",
@@ -4576,8 +4576,8 @@
   return gdbarch->adjust_breakpoint_address != NULL;
 }
 
-CORE_ADDR
-gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr)
+int
+gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR *bpaddr)
 {
   gdb_assert (gdbarch != NULL);
   gdb_assert (gdbarch->adjust_breakpoint_address != NULL);
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.223
diff -u -r1.223 gdbarch.h
--- gdbarch.h	22 Oct 2003 23:54:11 -0000	1.223
+++ gdbarch.h	28 Oct 2003 17:30:14 -0000
@@ -1665,8 +1665,8 @@
 
 extern int gdbarch_adjust_breakpoint_address_p (struct gdbarch *gdbarch);
 
-typedef CORE_ADDR (gdbarch_adjust_breakpoint_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
-extern CORE_ADDR gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
+typedef int (gdbarch_adjust_breakpoint_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR *bpaddr);
+extern int gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR *bpaddr);
 extern void set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address);
 
 typedef int (gdbarch_memory_insert_breakpoint_ftype) (CORE_ADDR addr, char *contents_cache);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.280
diff -u -r1.280 gdbarch.sh
--- gdbarch.sh	22 Oct 2003 23:54:11 -0000	1.280
+++ gdbarch.sh	28 Oct 2003 17:30:14 -0000
@@ -628,7 +628,7 @@
 f:2:PROLOGUE_FRAMELESS_P:int:prologue_frameless_p:CORE_ADDR ip:ip::0:generic_prologue_frameless_p::0
 f:2:INNER_THAN:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs::0:0
 f::BREAKPOINT_FROM_PC:const unsigned char *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr:::0:
-M:2:ADJUST_BREAKPOINT_ADDRESS:CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
+M:2::int:adjust_breakpoint_address:CORE_ADDR *bpaddr:bpaddr
 f:2:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_insert_breakpoint::0
 f:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0:default_memory_remove_breakpoint::0
 v:2:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:-1
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.45
diff -u -r1.45 ppc-linux-tdep.c
--- ppc-linux-tdep.c	24 Oct 2003 20:24:06 -0000	1.45
+++ ppc-linux-tdep.c	28 Oct 2003 17:30:15 -0000
@@ -1073,7 +1073,13 @@
          function descriptors).  */
       set_gdbarch_convert_from_func_ptr_addr
         (gdbarch, ppc64_linux_convert_from_func_ptr_addr);
-
+      /* Handle PPC64 GNU/Linux minimal-symbol convention of using
+         "FUNC" for the descriptor and ".FUNC" or the entry-point -- a
+         user specifying "break FUNC" unintentionally setting a
+         breakpoint on the descriptor.  This architecture method
+         transforms any breapoints on descriptors into breakpoints on
+         that corresponding entry point.  */
+      set_gdbarch_adjust_breakpoint_address (gdbarch, ppc64_sysv_abi_adjust_breakpoint_address);
       set_gdbarch_in_solib_call_trampoline
         (gdbarch, ppc64_in_solib_call_trampoline);
       set_gdbarch_skip_trampoline_code (gdbarch, ppc64_skip_trampoline_code);
Index: ppc-sysv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-sysv-tdep.c,v
retrieving revision 1.17
diff -u -r1.17 ppc-sysv-tdep.c
--- ppc-sysv-tdep.c	20 Oct 2003 15:38:02 -0000	1.17
+++ ppc-sysv-tdep.c	28 Oct 2003 17:30:15 -0000
@@ -28,6 +28,7 @@
 #include "gdb_string.h"
 #include "gdb_assert.h"
 #include "ppc-tdep.h"
+#include "target.h"
 
 /* Pass the arguments in either registers, or in the stack. Using the
    ppc sysv ABI, the first eight words of the argument list (that might
@@ -1012,4 +1013,15 @@
 {
   if (!ppc64_sysv_abi_return_value (valtype, regbuf, valbuf, NULL))
     error ("Function return value location unknown");
+}
+
+int
+ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
+					  CORE_ADDR *bpaddr)
+{
+  /* Convert any function descriptors into function entry points.  */
+  (*bpaddr) = gdbarch_convert_from_func_ptr_addr (gdbarch, (*bpaddr), &current_target);
+  /* Don't bother warning the user that the transformation has been
+     made.  */
+  return 0;
 }
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.22
diff -u -r1.22 ppc-tdep.h
--- ppc-tdep.h	10 Oct 2003 21:32:47 -0000	1.22
+++ ppc-tdep.h	28 Oct 2003 17:30:15 -0000
@@ -61,6 +61,8 @@
 					  struct value **args, CORE_ADDR sp,
 					  int struct_return,
 					  CORE_ADDR struct_addr);
+int ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
+					      CORE_ADDR *bpaddr);
 int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
 struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
 void ppc_linux_supply_gregset (char *buf);

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