Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
@ 2003-10-28 17:41 Andrew Cagney
  2003-10-28 20:59 ` Kevin Buettner
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2003-10-28 17:41 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

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

[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 12565 bytes --]

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);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-28 17:41 [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment Andrew Cagney
@ 2003-10-28 20:59 ` Kevin Buettner
  2003-10-28 23:39   ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Buettner @ 2003-10-28 20:59 UTC (permalink / raw)
  To: Andrew Cagney, gdb-patches

On Oct 27, 12:39pm, Andrew Cagney wrote:

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

I think this part is fine.  (Don't forget about the docs though.)

> 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.

And this part too.

> 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?

I would prefer that gdb issue warnings both at the time the breakpoint
was set and when it gets hit.  Or at least until we have more
experience with it and find that the second warning unduly annoys
users.

How about calling gdbarch_adjust_breakpoint_address() to find out if
the second warning should be printed?  Alternately, we could add a
field to the breakpoint struct, but this seems like overkill.

Kevin


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-28 20:59 ` Kevin Buettner
@ 2003-10-28 23:39   ` Andrew Cagney
  2003-10-29  3:27     ` Kevin Buettner
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2003-10-28 23:39 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches


>> 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?
> 
> 
> I would prefer that gdb issue warnings both at the time the breakpoint
> was set and when it gets hit.  Or at least until we have more
> experience with it and find that the second warning unduly annoys
> users.

As a user, it annoyed me :-)

If you'd prefer I'll let PPC64 print both warnings as well.

> How about calling gdbarch_adjust_breakpoint_address() to find out if
> the second warning should be printed?  Alternately, we could add a
> field to the breakpoint struct, but this seems like overkill.

Andrew



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-28 23:39   ` Andrew Cagney
@ 2003-10-29  3:27     ` Kevin Buettner
  2003-10-29 16:09       ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Buettner @ 2003-10-29  3:27 UTC (permalink / raw)
  To: Andrew Cagney, Kevin Buettner; +Cc: gdb-patches

On Oct 27,  6:38pm, Andrew Cagney wrote:

> >> 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?
> > 
> > 
> > I would prefer that gdb issue warnings both at the time the breakpoint
> > was set and when it gets hit.  Or at least until we have more
> > experience with it and find that the second warning unduly annoys
> > users.
> 
> As a user, it annoyed me :-)
> 
> If you'd prefer I'll let PPC64 print both warnings as well.

ppc and frv are very different.  I don't think any warnings should
be printed for ppc, but I think both warnings should be printed for
frv.  Over time, we may find that that second warning for frv is too
annoying to stay, but for the moment I think it should stay.

Kevin


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-29  3:27     ` Kevin Buettner
@ 2003-10-29 16:09       ` Andrew Cagney
  2003-10-29 16:30         ` Kevin Buettner
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2003-10-29 16:09 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: Andrew Cagney, gdb-patches

> As a user, it annoyed me :-)
>> 
>> If you'd prefer I'll let PPC64 print both warnings as well.
> 
> 
> ppc and frv are very different.

I'm not so sure.  Here's the interaction:

(gdb) print &main
$1 = (<data variable, no debug info> *) 0x104e5a60
(gdb) break main
Breakpoint 2 at 0x100895d0
(gdb) run
Starting program: 
/home/cagney/PENDING/YYYY-MM-DD-target-convert-func/64/gdb/stripped.gdb
...
Breakpoint 2, 0x00000000100895d0 in .main ()
(gdb)

(I've yet to figure out why GDB keeps reporting those breakpoints).

Notice how "main" is in the data space yet GDB set a code space 
breakpoint (and even stopped on a different symbol).  Might as well 
notify the user of this adjustment.

Andrew



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-29 16:09       ` Andrew Cagney
@ 2003-10-29 16:30         ` Kevin Buettner
  2003-10-29 22:03           ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Buettner @ 2003-10-29 16:30 UTC (permalink / raw)
  To: Andrew Cagney, Kevin Buettner; +Cc: gdb-patches

On Oct 28, 11:08am, Andrew Cagney wrote:

> > As a user, it annoyed me :-)
> >> 
> >> If you'd prefer I'll let PPC64 print both warnings as well.
> > 
> > ppc and frv are very different.
> 
> I'm not so sure.  Here's the interaction:
> 
> (gdb) print &main
> $1 = (<data variable, no debug info> *) 0x104e5a60
> (gdb) break main
> Breakpoint 2 at 0x100895d0
> (gdb) run
> Starting program: 
> /home/cagney/PENDING/YYYY-MM-DD-target-convert-func/64/gdb/stripped.gdb
> ...
> Breakpoint 2, 0x00000000100895d0 in .main ()
> (gdb)
> 
> (I've yet to figure out why GDB keeps reporting those breakpoints).

??

> Notice how "main" is in the data space yet GDB set a code space 
> breakpoint (and even stopped on a different symbol).  Might as well 
> notify the user of this adjustment.

Okay, I see your point.  This is surprising enough to merit a warning.

Kevin


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-29 16:30         ` Kevin Buettner
@ 2003-10-29 22:03           ` Andrew Cagney
  2003-10-30 23:29             ` Kevin Buettner
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2003-10-29 22:03 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

> On Oct 28, 11:08am, Andrew Cagney wrote:
> 
> 
>> > As a user, it annoyed me :-)
> 
>> >> 
>> >> If you'd prefer I'll let PPC64 print both warnings as well.
> 
>> > 
>> > ppc and frv are very different.
> 
>> 
>> I'm not so sure.  Here's the interaction:
>> 
>> (gdb) print &main
>> $1 = (<data variable, no debug info> *) 0x104e5a60
>> (gdb) break main
>> Breakpoint 2 at 0x100895d0
>> (gdb) run
>> Starting program: 
>> /home/cagney/PENDING/YYYY-MM-DD-target-convert-func/64/gdb/stripped.gdb
>> ...
>> Breakpoint 2, 0x00000000100895d0 in .main ()
>> (gdb)
>> 
>> (I've yet to figure out why GDB keeps reporting those breakpoints).

Oops, lost the message.  GDB sometimes prints:

Breakpoint 2 at 0x100895d0

which, I think is from GDB doing a "if breakpoint.one_addr != 
breakpoint.second_addr then print message" comparison everytime a shared 
library breakpoint is hit.

>> Notice how "main" is in the data space yet GDB set a code space 
>> breakpoint (and even stopped on a different symbol).  Might as well 
>> notify the user of this adjustment.
> 
> 
> Okay, I see your point.  This is surprising enough to merit a warning.

Attached is a much simplified patch.  Ok?

Andrew


[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 4871 bytes --]

2003-10-29  Andrew Cagney  <cagney@redhat.com>

	* rs6000-tdep.c (rs6000_gdbarch_init): For 64-bit ABI, set
	adjust_breakpoint_address.
	* Makefile.in (ppc-sysv-tdep.o): Add $(target_h).
	* ppc-tdep.h (ppc64_sysv_abi_adjust_breakpoint_address): Declare.
	* ppc-sysv-tdep.c: Include "target.h".  Update copyright.
	(ppc64_sysv_abi_adjust_breakpoint_address): New function.

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	29 Oct 2003 22:00:30 -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: 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	29 Oct 2003 22:00:31 -0000
@@ -1,7 +1,7 @@
 /* Target-dependent code for PowerPC systems using the SVR4 ABI
    for GDB, the GNU debugger.
 
-   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -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,22 @@
 {
   if (!ppc64_sysv_abi_return_value (valtype, regbuf, valbuf, NULL))
     error ("Function return value location unknown");
+}
+
+CORE_ADDR
+ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
+					  CORE_ADDR bpaddr)
+{
+  /* PPC64 SYSV specifies that the minimal-symbol "FN" should point at
+     a function-descriptor while the corresponding minimal-symbol
+     ".FN" should point at the entry point.  Consequently, a command
+     like "break FN" applied to an object file with only minimal
+     symbols, will insert the breakpoint into the descriptor at "FN"
+     and not the function at ".FN".  Avoid this confusion by adjusting
+     any attempt to set a descriptor breakpoint into a corresponding
+     function breakpoint.  Note that GDB warns the user when this
+     adjustment is applied - that's ok as otherwise the user will have
+     no way of knowing why their breakpoint at "FN" resulted in the
+     program stopping at ".FN".  */
+  return gdbarch_convert_from_func_ptr_addr (gdbarch, bpaddr, &current_target);
 }
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	29 Oct 2003 22:00:31 -0000
@@ -61,6 +61,8 @@
 					  struct value **args, CORE_ADDR sp,
 					  int struct_return,
 					  CORE_ADDR struct_addr);
+CORE_ADDR 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: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.170
diff -u -r1.170 rs6000-tdep.c
--- rs6000-tdep.c	22 Oct 2003 23:54:11 -0000	1.170
+++ rs6000-tdep.c	29 Oct 2003 22:00:31 -0000
@@ -2895,6 +2895,15 @@
   set_gdbarch_function_start_offset (gdbarch, 0);
   set_gdbarch_breakpoint_from_pc (gdbarch, rs6000_breakpoint_from_pc);
 
+  /* Handle the 64-bit SVR4 minimal-symbol convention of using "FN"
+     for the descriptor and ".FN" for the entry-point -- a user
+     specifying "break FN" will unexpectedly end up with a breakpoint
+     on the descriptor and not the function.  This architecture method
+     transforms any breakpoints on descriptors into breakpoints on the
+     corresponding entry point.  */
+  if (sysv_abi && wordsize == 8)
+    set_gdbarch_adjust_breakpoint_address (gdbarch, ppc64_sysv_abi_adjust_breakpoint_address);
+
   /* Not sure on this. FIXMEmgo */
   set_gdbarch_frame_args_skip (gdbarch, 8);
 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-29 22:03           ` Andrew Cagney
@ 2003-10-30 23:29             ` Kevin Buettner
  2003-10-31 16:39               ` Andrew Cagney
  0 siblings, 1 reply; 9+ messages in thread
From: Kevin Buettner @ 2003-10-30 23:29 UTC (permalink / raw)
  To: Andrew Cagney, Kevin Buettner; +Cc: gdb-patches

On Oct 29,  5:03pm, Andrew Cagney wrote:
> Attached is a much simplified patch.  Ok?

Yes.  Thanks!

> 2003-10-29  Andrew Cagney  <cagney@redhat.com>
> 
> 	* rs6000-tdep.c (rs6000_gdbarch_init): For 64-bit ABI, set
> 	adjust_breakpoint_address.
> 	* Makefile.in (ppc-sysv-tdep.o): Add $(target_h).
> 	* ppc-tdep.h (ppc64_sysv_abi_adjust_breakpoint_address): Declare.
> 	* ppc-sysv-tdep.c: Include "target.h".  Update copyright.
> 	(ppc64_sysv_abi_adjust_breakpoint_address): New function.
[...]

Kevin


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment
  2003-10-30 23:29             ` Kevin Buettner
@ 2003-10-31 16:39               ` Andrew Cagney
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cagney @ 2003-10-31 16:39 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: Andrew Cagney, gdb-patches

> 2003-10-29  Andrew Cagney  <cagney@redhat.com>
>> 
>> 	* rs6000-tdep.c (rs6000_gdbarch_init): For 64-bit ABI, set
>> 	adjust_breakpoint_address.
>> 	* Makefile.in (ppc-sysv-tdep.o): Add $(target_h).
>> 	* ppc-tdep.h (ppc64_sysv_abi_adjust_breakpoint_address): Declare.
>> 	* ppc-sysv-tdep.c: Include "target.h".  Update copyright.
>> 	(ppc64_sysv_abi_adjust_breakpoint_address): New function.

Committed,
Andrew



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-10-31 16:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-28 17:41 [patch, rfa:ppc64, rfa:breakpoint] Add non-verbose breakpoint adjustment Andrew Cagney
2003-10-28 20:59 ` Kevin Buettner
2003-10-28 23:39   ` Andrew Cagney
2003-10-29  3:27     ` Kevin Buettner
2003-10-29 16:09       ` Andrew Cagney
2003-10-29 16:30         ` Kevin Buettner
2003-10-29 22:03           ` Andrew Cagney
2003-10-30 23:29             ` Kevin Buettner
2003-10-31 16:39               ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox