Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc]: Replace current_gdbarch in hppa
@ 2008-02-15  6:48 Markus Deuling
  2008-02-15 18:39 ` Ulrich Weigand
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Deuling @ 2008-02-15  6:48 UTC (permalink / raw)
  To: GDB Patches; +Cc: Ulrich Weigand

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

Hi,

ups, sorry. Forgot the subject. Here's one ...

This patch replaces some current_gdbarch's in hppa. Tested by gdb_buildall.sh.
Ok to commit?



ChangeLog:

    * hppa-tdep.h (find_global_pointer): Add gdbarch as parameter.

    * hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer): Likewise. Replace
    current_gdbarch by gdbarch.
    (hppa64_hpux_find_global_pointer): Likewise.
    * hppa-tdep.c (hppa_find_global_pointer): Likewise.
    (hppa32_push_dummy_call, hppa64_push_dummy_call): Update call for
    find_global_pointer.

    * hppabsd-tdep.c (hppabsd_find_global_pointer): Add gdbarch as
    parameter.
    * hppa-linux-tdep.c (hppa_linux_find_global_pointer): Likewise.

    * hppa-linux-nat.c (hppa_linux_register_addr): Add gdbarch as parameter.
    (fetch_register, store_register): Update call for
    hppa_linux_register_addr.

    * hppa-hpux-tdep.c (hppa_hpux_sr_for_addr): Add gdbarch as parameter and
    replace current_gdbarch by gdbarch.    
    (hppa_hpux_push_dummy_code): Update call for hppa_hpux_sr_for_addr.


Regards,
Markus 

-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


[-- Attachment #2: diff-hppa --]
[-- Type: text/plain, Size: 6255 bytes --]

diff -urpN src/gdb/hppabsd-tdep.c dev/gdb/hppabsd-tdep.c
--- src/gdb/hppabsd-tdep.c	2008-01-21 06:48:46.000000000 +0100
+++ dev/gdb/hppabsd-tdep.c	2008-02-15 07:18:00.000000000 +0100
@@ -28,7 +28,7 @@
 #include "solib-svr4.h"
 
 CORE_ADDR
-hppabsd_find_global_pointer (struct value *function)
+hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   CORE_ADDR faddr = value_as_address (function);
   struct obj_section *faddr_sec;
diff -urpN src/gdb/hppa-hpux-tdep.c dev/gdb/hppa-hpux-tdep.c
--- src/gdb/hppa-hpux-tdep.c	2008-01-16 12:21:15.000000000 +0100
+++ dev/gdb/hppa-hpux-tdep.c	2008-02-15 06:54:44.000000000 +0100
@@ -741,7 +741,8 @@ hppa_hpux_sigtramp_unwind_sniffer (struc
 }
 
 static CORE_ADDR
-hppa32_hpux_find_global_pointer (struct value *function)
+hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
+				 struct value *function)
 {
   CORE_ADDR faddr;
   
@@ -760,11 +761,12 @@ hppa32_hpux_find_global_pointer (struct 
 	return extract_unsigned_integer (buf, sizeof (buf));
     }
 
-  return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+  return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
 }
 
 static CORE_ADDR
-hppa64_hpux_find_global_pointer (struct value *function)
+hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
+				 struct value *function)
 {
   CORE_ADDR faddr;
   char buf[32];
@@ -778,7 +780,7 @@ hppa64_hpux_find_global_pointer (struct 
     }
   else
     {
-      return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+      return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
     }
 }
 
@@ -1031,11 +1033,11 @@ hppa_hpux_find_import_stub_for_addr (COR
 }
 
 static int
-hppa_hpux_sr_for_addr (CORE_ADDR addr)
+hppa_hpux_sr_for_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   int sr;
   /* The space register to use is encoded in the top 2 bits of the address.  */
-  sr = addr >> (gdbarch_tdep (current_gdbarch)->bytes_per_address * 8 - 2);
+  sr = addr >> (gdbarch_tdep (gdbarch)->bytes_per_address * 8 - 2);
   return sr + 4;
 }
 
@@ -1112,7 +1114,8 @@ hppa_hpux_push_dummy_code (struct gdbarc
 
   /* The simple case is where we call a function in the same space that we are
      currently in; in that case we don't really need to do anything.  */
-  if (hppa_hpux_sr_for_addr (pc) == hppa_hpux_sr_for_addr (funcaddr))
+  if (hppa_hpux_sr_for_addr (gdbarch, pc)
+      == hppa_hpux_sr_for_addr (gdbarch, funcaddr))
     {
       /* Intraspace call.  */
       *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
diff -urpN src/gdb/hppa-linux-nat.c dev/gdb/hppa-linux-nat.c
--- src/gdb/hppa-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-linux-nat.c	2008-02-15 06:52:13.000000000 +0100
@@ -149,11 +149,12 @@ static const int u_offsets[] =
   };
 
 static CORE_ADDR
-hppa_linux_register_addr (int regno, CORE_ADDR blockend)
+hppa_linux_register_addr (struct gdbarch *gdbarch, int regno,
+			  CORE_ADDR blockend)
 {
   CORE_ADDR addr;
 
-  if ((unsigned) regno >= gdbarch_num_regs (current_gdbarch))
+  if ((unsigned) regno >= gdbarch_num_regs (gdbarch))
     error (_("Invalid register number %d."), regno);
 
   if (u_offsets[regno] == -1)
@@ -229,7 +230,8 @@ fetch_register (struct regcache *regcach
     tid = PIDGET (inferior_ptid); /* Not a threaded program.  */
 
   errno = 0;
-  val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
+  val = ptrace (PTRACE_PEEKUSER, tid,
+		hppa_linux_register_addr (gdbarch, regno, 0), 0);
   if (errno != 0)
     error (_("Couldn't read register %s (#%d): %s."), 
 	   gdbarch_register_name (gdbarch, regno),
@@ -257,7 +259,8 @@ store_register (const struct regcache *r
 
   errno = 0;
   regcache_raw_collect (regcache, regno, &val);
-  ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val);
+  ptrace (PTRACE_POKEUSER, tid,
+	  hppa_linux_register_addr (gdbarch, regno, 0), val);
   if (errno != 0)
     error (_("Couldn't write register %s (#%d): %s."),
 	   gdbarch_register_name (gdbarch, regno),
diff -urpN src/gdb/hppa-linux-tdep.c dev/gdb/hppa-linux-tdep.c
--- src/gdb/hppa-linux-tdep.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-linux-tdep.c	2008-02-15 07:18:56.000000000 +0100
@@ -325,7 +325,7 @@ hppa_linux_sigtramp_unwind_sniffer (stru
    d_un.d_ptr value is the global pointer.  */
 
 static CORE_ADDR
-hppa_linux_find_global_pointer (struct value *function)
+hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   struct obj_section *faddr_sect;
   CORE_ADDR faddr;
diff -urpN src/gdb/hppa-tdep.c dev/gdb/hppa-tdep.c
--- src/gdb/hppa-tdep.c	2008-01-11 15:42:52.000000000 +0100
+++ dev/gdb/hppa-tdep.c	2008-02-15 06:55:23.000000000 +0100
@@ -828,7 +828,7 @@ hppa32_push_dummy_call (struct gdbarch *
   if (struct_return)
     regcache_cooked_write_unsigned (regcache, 28, struct_addr);
 
-  gp = tdep->find_global_pointer (function);
+  gp = tdep->find_global_pointer (gdbarch, function);
 
   if (gp != 0)
     regcache_cooked_write_unsigned (regcache, 19, gp);
@@ -1087,7 +1087,7 @@ hppa64_push_dummy_call (struct gdbarch *
     regcache_cooked_write_unsigned (regcache, HPPA_RET0_REGNUM, struct_addr);
 
   /* Set up GR27 (%dp) to hold the global pointer (gp).  */
-  gp = tdep->find_global_pointer (function);
+  gp = tdep->find_global_pointer (gdbarch, function);
   if (gp != 0)
     regcache_cooked_write_unsigned (regcache, HPPA_DP_REGNUM, gp);
 
@@ -2705,7 +2705,7 @@ hppa_pseudo_register_read (struct gdbarc
 }
 
 static CORE_ADDR
-hppa_find_global_pointer (struct value *function)
+hppa_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   return 0;
 }
diff -urpN src/gdb/hppa-tdep.h dev/gdb/hppa-tdep.h
--- src/gdb/hppa-tdep.h	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-tdep.h	2008-02-15 06:44:48.000000000 +0100
@@ -87,7 +87,7 @@ struct gdbarch_tdep
 
   /* Given a function address, try to find the global pointer for the 
      corresponding shared object.  */
-  CORE_ADDR (*find_global_pointer) (struct value *);
+  CORE_ADDR (*find_global_pointer) (struct gdbarch *, struct value *);
 
   /* For shared libraries, each call goes through a small piece of
      trampoline code in the ".plt", or equivalent, section.

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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-15  6:48 [rfc]: Replace current_gdbarch in hppa Markus Deuling
@ 2008-02-15 18:39 ` Ulrich Weigand
  2008-02-15 20:19   ` Pedro Alves
  2008-02-18 14:28   ` Markus Deuling
  0 siblings, 2 replies; 9+ messages in thread
From: Ulrich Weigand @ 2008-02-15 18:39 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches

Markus Deuling wrote:

>     * hppa-tdep.h (find_global_pointer): Add gdbarch as parameter.
> 
>     * hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer): Likewise. Replace
>     current_gdbarch by gdbarch.
>     (hppa64_hpux_find_global_pointer): Likewise.
>     * hppa-tdep.c (hppa_find_global_pointer): Likewise.
>     (hppa32_push_dummy_call, hppa64_push_dummy_call): Update call for
>     find_global_pointer.
> 
>     * hppabsd-tdep.c (hppabsd_find_global_pointer): Add gdbarch as
>     parameter.
>     * hppa-linux-tdep.c (hppa_linux_find_global_pointer): Likewise.
> 
>     * hppa-linux-nat.c (hppa_linux_register_addr): Add gdbarch as parameter.
>     (fetch_register, store_register): Update call for
>     hppa_linux_register_addr.
> 
>     * hppa-hpux-tdep.c (hppa_hpux_sr_for_addr): Add gdbarch as parameter and
>     replace current_gdbarch by gdbarch.    
>     (hppa_hpux_push_dummy_code): Update call for hppa_hpux_sr_for_addr.

Most of these are OK, except:


> diff -urpN src/gdb/hppa-linux-nat.c dev/gdb/hppa-linux-nat.c
> --- src/gdb/hppa-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
> +++ dev/gdb/hppa-linux-nat.c	2008-02-15 06:52:13.000000000 +0100
> @@ -149,11 +149,12 @@ static const int u_offsets[] =
>    };
>  
>  static CORE_ADDR
> -hppa_linux_register_addr (int regno, CORE_ADDR blockend)
> +hppa_linux_register_addr (struct gdbarch *gdbarch, int regno,
> +			  CORE_ADDR blockend)
>  {
>    CORE_ADDR addr;
>  
> -  if ((unsigned) regno >= gdbarch_num_regs (current_gdbarch))
> +  if ((unsigned) regno >= gdbarch_num_regs (gdbarch))
>      error (_("Invalid register number %d."), regno);
>  
>    if (u_offsets[regno] == -1)

This is really the wrong check.  It should really just verify that
no out-of-bounds access to u_offsets happens, so the line should 
just be something like:

   if ((unsigned) regno >= ARRAY_SIZE (u_offsets))


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-15 18:39 ` Ulrich Weigand
@ 2008-02-15 20:19   ` Pedro Alves
  2008-02-15 20:22     ` Daniel Jacobowitz
  2008-02-18 14:28   ` Markus Deuling
  1 sibling, 1 reply; 9+ messages in thread
From: Pedro Alves @ 2008-02-15 20:19 UTC (permalink / raw)
  To: gdb-patches

A Friday 15 February 2008 18:38:49, Ulrich Weigand wrote:
> This is really the wrong check.  It should really just verify that
> no out-of-bounds access to u_offsets happens, so the line should
> just be something like:
>
>    if ((unsigned) regno >= ARRAY_SIZE (u_offsets))

(Just wondering, since these things have been discussed before.)

Can any user input lead to such a stray regno?  Or are all
those off accesses really GDB bugs?  If so, why not make
it a gdb_assert or internal_error?

-- 
Pedro Alves


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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-15 20:19   ` Pedro Alves
@ 2008-02-15 20:22     ` Daniel Jacobowitz
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel Jacobowitz @ 2008-02-15 20:22 UTC (permalink / raw)
  To: gdb-patches

On Fri, Feb 15, 2008 at 08:19:45PM +0000, Pedro Alves wrote:
> Can any user input lead to such a stray regno?  Or are all
> those off accesses really GDB bugs?  If so, why not make
> it a gdb_assert or internal_error?

It's always a GDB bug.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-15 18:39 ` Ulrich Weigand
  2008-02-15 20:19   ` Pedro Alves
@ 2008-02-18 14:28   ` Markus Deuling
  2008-02-18 14:37     ` Ulrich Weigand
  1 sibling, 1 reply; 9+ messages in thread
From: Markus Deuling @ 2008-02-18 14:28 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: GDB Patches

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

Hi Uli,

> 
> This is really the wrong check.  It should really just verify that
> no out-of-bounds access to u_offsets happens, so the line should 
> just be something like:
> 
>    if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
> 

yes, you're right. This check is much better :-)

I changed the patch. Ok to commit?

ChangeLog:


	* hppa-tdep.h (find_global_pointer): Add gdbarch as parameter.

	* hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer): Likewise. Replace
	current_gdbarch by gdbarch.
	(hppa64_hpux_find_global_pointer): Likewise.
	* hppa-tdep.c (hppa_find_global_pointer): Likewise.
	(hppa32_push_dummy_call, hppa64_push_dummy_call): Update call for
	find_global_pointer.

	* hppabsd-tdep.c (hppabsd_find_global_pointer): Add gdbarch as
	parameter.
	* hppa-linux-tdep.c (hppa_linux_find_global_pointer): Likewise.

	* hppa-linux-nat.c (hppa_linux_register_addr): Add gdbarch as parameter.
	(fetch_register, store_register): Update call for
	hppa_linux_register_addr.

	* hppa-hpux-tdep.c (hppa_hpux_sr_for_addr): Add gdbarch as parameter and
	replace current_gdbarch by gdbarch.	
	(hppa_hpux_push_dummy_code): Update call for hppa_hpux_sr_for_addr.



-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


[-- Attachment #2: diff-hppa --]
[-- Type: text/plain, Size: 6251 bytes --]

diff -urpN src/gdb/hppabsd-tdep.c dev/gdb/hppabsd-tdep.c
--- src/gdb/hppabsd-tdep.c	2008-01-21 06:48:46.000000000 +0100
+++ dev/gdb/hppabsd-tdep.c	2008-02-18 15:15:18.000000000 +0100
@@ -28,7 +28,7 @@
 #include "solib-svr4.h"
 
 CORE_ADDR
-hppabsd_find_global_pointer (struct value *function)
+hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   CORE_ADDR faddr = value_as_address (function);
   struct obj_section *faddr_sec;
diff -urpN src/gdb/hppa-hpux-tdep.c dev/gdb/hppa-hpux-tdep.c
--- src/gdb/hppa-hpux-tdep.c	2008-01-16 12:21:15.000000000 +0100
+++ dev/gdb/hppa-hpux-tdep.c	2008-02-18 15:15:18.000000000 +0100
@@ -741,7 +741,8 @@ hppa_hpux_sigtramp_unwind_sniffer (struc
 }
 
 static CORE_ADDR
-hppa32_hpux_find_global_pointer (struct value *function)
+hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
+				 struct value *function)
 {
   CORE_ADDR faddr;
   
@@ -760,11 +761,12 @@ hppa32_hpux_find_global_pointer (struct 
 	return extract_unsigned_integer (buf, sizeof (buf));
     }
 
-  return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+  return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
 }
 
 static CORE_ADDR
-hppa64_hpux_find_global_pointer (struct value *function)
+hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
+				 struct value *function)
 {
   CORE_ADDR faddr;
   char buf[32];
@@ -778,7 +780,7 @@ hppa64_hpux_find_global_pointer (struct 
     }
   else
     {
-      return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+      return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
     }
 }
 
@@ -1031,11 +1033,11 @@ hppa_hpux_find_import_stub_for_addr (COR
 }
 
 static int
-hppa_hpux_sr_for_addr (CORE_ADDR addr)
+hppa_hpux_sr_for_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   int sr;
   /* The space register to use is encoded in the top 2 bits of the address.  */
-  sr = addr >> (gdbarch_tdep (current_gdbarch)->bytes_per_address * 8 - 2);
+  sr = addr >> (gdbarch_tdep (gdbarch)->bytes_per_address * 8 - 2);
   return sr + 4;
 }
 
@@ -1112,7 +1114,8 @@ hppa_hpux_push_dummy_code (struct gdbarc
 
   /* The simple case is where we call a function in the same space that we are
      currently in; in that case we don't really need to do anything.  */
-  if (hppa_hpux_sr_for_addr (pc) == hppa_hpux_sr_for_addr (funcaddr))
+  if (hppa_hpux_sr_for_addr (gdbarch, pc)
+      == hppa_hpux_sr_for_addr (gdbarch, funcaddr))
     {
       /* Intraspace call.  */
       *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
diff -urpN src/gdb/hppa-linux-nat.c dev/gdb/hppa-linux-nat.c
--- src/gdb/hppa-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-linux-nat.c	2008-02-18 15:20:51.000000000 +0100
@@ -149,11 +149,12 @@ static const int u_offsets[] =
   };
 
 static CORE_ADDR
-hppa_linux_register_addr (int regno, CORE_ADDR blockend)
+hppa_linux_register_addr (struct gdbarch *gdbarch, int regno,
+			  CORE_ADDR blockend)
 {
   CORE_ADDR addr;
 
-  if ((unsigned) regno >= gdbarch_num_regs (current_gdbarch))
+  if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
     error (_("Invalid register number %d."), regno);
 
   if (u_offsets[regno] == -1)
@@ -229,7 +230,8 @@ fetch_register (struct regcache *regcach
     tid = PIDGET (inferior_ptid); /* Not a threaded program.  */
 
   errno = 0;
-  val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
+  val = ptrace (PTRACE_PEEKUSER, tid,
+		hppa_linux_register_addr (gdbarch, regno, 0), 0);
   if (errno != 0)
     error (_("Couldn't read register %s (#%d): %s."), 
 	   gdbarch_register_name (gdbarch, regno),
@@ -257,7 +259,8 @@ store_register (const struct regcache *r
 
   errno = 0;
   regcache_raw_collect (regcache, regno, &val);
-  ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val);
+  ptrace (PTRACE_POKEUSER, tid,
+	  hppa_linux_register_addr (gdbarch, regno, 0), val);
   if (errno != 0)
     error (_("Couldn't write register %s (#%d): %s."),
 	   gdbarch_register_name (gdbarch, regno),
diff -urpN src/gdb/hppa-linux-tdep.c dev/gdb/hppa-linux-tdep.c
--- src/gdb/hppa-linux-tdep.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-linux-tdep.c	2008-02-18 15:15:18.000000000 +0100
@@ -325,7 +325,7 @@ hppa_linux_sigtramp_unwind_sniffer (stru
    d_un.d_ptr value is the global pointer.  */
 
 static CORE_ADDR
-hppa_linux_find_global_pointer (struct value *function)
+hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   struct obj_section *faddr_sect;
   CORE_ADDR faddr;
diff -urpN src/gdb/hppa-tdep.c dev/gdb/hppa-tdep.c
--- src/gdb/hppa-tdep.c	2008-01-11 15:42:52.000000000 +0100
+++ dev/gdb/hppa-tdep.c	2008-02-18 15:15:18.000000000 +0100
@@ -828,7 +828,7 @@ hppa32_push_dummy_call (struct gdbarch *
   if (struct_return)
     regcache_cooked_write_unsigned (regcache, 28, struct_addr);
 
-  gp = tdep->find_global_pointer (function);
+  gp = tdep->find_global_pointer (gdbarch, function);
 
   if (gp != 0)
     regcache_cooked_write_unsigned (regcache, 19, gp);
@@ -1087,7 +1087,7 @@ hppa64_push_dummy_call (struct gdbarch *
     regcache_cooked_write_unsigned (regcache, HPPA_RET0_REGNUM, struct_addr);
 
   /* Set up GR27 (%dp) to hold the global pointer (gp).  */
-  gp = tdep->find_global_pointer (function);
+  gp = tdep->find_global_pointer (gdbarch, function);
   if (gp != 0)
     regcache_cooked_write_unsigned (regcache, HPPA_DP_REGNUM, gp);
 
@@ -2705,7 +2705,7 @@ hppa_pseudo_register_read (struct gdbarc
 }
 
 static CORE_ADDR
-hppa_find_global_pointer (struct value *function)
+hppa_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   return 0;
 }
diff -urpN src/gdb/hppa-tdep.h dev/gdb/hppa-tdep.h
--- src/gdb/hppa-tdep.h	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-tdep.h	2008-02-18 15:15:18.000000000 +0100
@@ -87,7 +87,7 @@ struct gdbarch_tdep
 
   /* Given a function address, try to find the global pointer for the 
      corresponding shared object.  */
-  CORE_ADDR (*find_global_pointer) (struct value *);
+  CORE_ADDR (*find_global_pointer) (struct gdbarch *, struct value *);
 
   /* For shared libraries, each call goes through a small piece of
      trampoline code in the ".plt", or equivalent, section.

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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-18 14:28   ` Markus Deuling
@ 2008-02-18 14:37     ` Ulrich Weigand
  2008-02-18 14:47       ` Markus Deuling
  0 siblings, 1 reply; 9+ messages in thread
From: Ulrich Weigand @ 2008-02-18 14:37 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches

Markus Deuling wrote:

> > This is really the wrong check.  It should really just verify that
> > no out-of-bounds access to u_offsets happens, so the line should 
> > just be something like:
> > 
> >    if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
> > 
> 
> yes, you're right. This check is much better :-)


> diff -urpN src/gdb/hppa-linux-nat.c dev/gdb/hppa-linux-nat.c
> --- src/gdb/hppa-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
> +++ dev/gdb/hppa-linux-nat.c	2008-02-18 15:20:51.000000000 +0100
> @@ -149,11 +149,12 @@ static const int u_offsets[] =
>    };
>  
>  static CORE_ADDR
> -hppa_linux_register_addr (int regno, CORE_ADDR blockend)
> +hppa_linux_register_addr (struct gdbarch *gdbarch, int regno,
> +			  CORE_ADDR blockend)

With the changed test you do not need to modify this routine
to pass in an gdbarch parameter.

>  {
>    CORE_ADDR addr;
>  
> -  if ((unsigned) regno >= gdbarch_num_regs (current_gdbarch))
> +  if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
>      error (_("Invalid register number %d."), regno);
>  
>    if (u_offsets[regno] == -1)



> @@ -229,7 +230,8 @@ fetch_register (struct regcache *regcach
>      tid = PIDGET (inferior_ptid); /* Not a threaded program.  */
>  
>    errno = 0;
> -  val = ptrace (PTRACE_PEEKUSER, tid, hppa_linux_register_addr (regno, 0), 0);
> +  val = ptrace (PTRACE_PEEKUSER, tid,
> +		hppa_linux_register_addr (gdbarch, regno, 0), 0);
>    if (errno != 0)
>      error (_("Couldn't read register %s (#%d): %s."), 
>  	   gdbarch_register_name (gdbarch, regno),
> @@ -257,7 +259,8 @@ store_register (const struct regcache *r
>  
>    errno = 0;
>    regcache_raw_collect (regcache, regno, &val);
> -  ptrace (PTRACE_POKEUSER, tid, hppa_linux_register_addr (regno, 0), val);
> +  ptrace (PTRACE_POKEUSER, tid,
> +	  hppa_linux_register_addr (gdbarch, regno, 0), val);
>    if (errno != 0)
>      error (_("Couldn't write register %s (#%d): %s."),
>  	   gdbarch_register_name (gdbarch, regno),

Likewise those changes can then go away.


Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-18 14:37     ` Ulrich Weigand
@ 2008-02-18 14:47       ` Markus Deuling
  2008-02-18 16:04         ` Ulrich Weigand
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Deuling @ 2008-02-18 14:47 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: GDB Patches

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

Ulrich Weigand schrieb:
> Likewise those changes can then go away.
> 

Absolutely, yes! I reworked the patch again. Thank you very much ! 

Ok ?


ChangeLog:

	* hppa-tdep.h (find_global_pointer): Add gdbarch as parameter.

	* hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer): Likewise. Replace
	current_gdbarch by gdbarch.
	(hppa64_hpux_find_global_pointer): Likewise.
	* hppa-tdep.c (hppa_find_global_pointer): Likewise.
	(hppa32_push_dummy_call, hppa64_push_dummy_call): Update call for
	find_global_pointer.

	* hppabsd-tdep.c (hppabsd_find_global_pointer): Add gdbarch as
	parameter.
	* hppa-linux-tdep.c (hppa_linux_find_global_pointer): Likewise.

	* hppa-linux-nat.c (hppa_linux_register_addr): Use ARRAY_SIZE instead
	of gdbarch_num_regs.

	* hppa-hpux-tdep.c (hppa_hpux_sr_for_addr): Add gdbarch as parameter and
	replace current_gdbarch by gdbarch.	
	(hppa_hpux_push_dummy_code): Update call for hppa_hpux_sr_for_addr.



-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


[-- Attachment #2: diff-hppa --]
[-- Type: text/plain, Size: 5240 bytes --]

diff -urpN src/gdb/hppabsd-tdep.c dev/gdb/hppabsd-tdep.c
--- src/gdb/hppabsd-tdep.c	2008-01-21 06:48:46.000000000 +0100
+++ dev/gdb/hppabsd-tdep.c	2008-02-18 15:36:27.000000000 +0100
@@ -28,7 +28,7 @@
 #include "solib-svr4.h"
 
 CORE_ADDR
-hppabsd_find_global_pointer (struct value *function)
+hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   CORE_ADDR faddr = value_as_address (function);
   struct obj_section *faddr_sec;
diff -urpN src/gdb/hppa-hpux-tdep.c dev/gdb/hppa-hpux-tdep.c
--- src/gdb/hppa-hpux-tdep.c	2008-01-16 12:21:15.000000000 +0100
+++ dev/gdb/hppa-hpux-tdep.c	2008-02-18 15:36:27.000000000 +0100
@@ -741,7 +741,8 @@ hppa_hpux_sigtramp_unwind_sniffer (struc
 }
 
 static CORE_ADDR
-hppa32_hpux_find_global_pointer (struct value *function)
+hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
+				 struct value *function)
 {
   CORE_ADDR faddr;
   
@@ -760,11 +761,12 @@ hppa32_hpux_find_global_pointer (struct 
 	return extract_unsigned_integer (buf, sizeof (buf));
     }
 
-  return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+  return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
 }
 
 static CORE_ADDR
-hppa64_hpux_find_global_pointer (struct value *function)
+hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
+				 struct value *function)
 {
   CORE_ADDR faddr;
   char buf[32];
@@ -778,7 +780,7 @@ hppa64_hpux_find_global_pointer (struct 
     }
   else
     {
-      return gdbarch_tdep (current_gdbarch)->solib_get_got_by_pc (faddr);
+      return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
     }
 }
 
@@ -1031,11 +1033,11 @@ hppa_hpux_find_import_stub_for_addr (COR
 }
 
 static int
-hppa_hpux_sr_for_addr (CORE_ADDR addr)
+hppa_hpux_sr_for_addr (struct gdbarch *gdbarch, CORE_ADDR addr)
 {
   int sr;
   /* The space register to use is encoded in the top 2 bits of the address.  */
-  sr = addr >> (gdbarch_tdep (current_gdbarch)->bytes_per_address * 8 - 2);
+  sr = addr >> (gdbarch_tdep (gdbarch)->bytes_per_address * 8 - 2);
   return sr + 4;
 }
 
@@ -1112,7 +1114,8 @@ hppa_hpux_push_dummy_code (struct gdbarc
 
   /* The simple case is where we call a function in the same space that we are
      currently in; in that case we don't really need to do anything.  */
-  if (hppa_hpux_sr_for_addr (pc) == hppa_hpux_sr_for_addr (funcaddr))
+  if (hppa_hpux_sr_for_addr (gdbarch, pc)
+      == hppa_hpux_sr_for_addr (gdbarch, funcaddr))
     {
       /* Intraspace call.  */
       *bp_addr = hppa_hpux_find_dummy_bpaddr (pc);
diff -urpN src/gdb/hppa-linux-nat.c dev/gdb/hppa-linux-nat.c
--- src/gdb/hppa-linux-nat.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-linux-nat.c	2008-02-18 15:39:32.000000000 +0100
@@ -153,7 +153,7 @@ hppa_linux_register_addr (int regno, COR
 {
   CORE_ADDR addr;
 
-  if ((unsigned) regno >= gdbarch_num_regs (current_gdbarch))
+  if ((unsigned) regno >= ARRAY_SIZE (u_offsets))
     error (_("Invalid register number %d."), regno);
 
   if (u_offsets[regno] == -1)
diff -urpN src/gdb/hppa-linux-tdep.c dev/gdb/hppa-linux-tdep.c
--- src/gdb/hppa-linux-tdep.c	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-linux-tdep.c	2008-02-18 15:36:27.000000000 +0100
@@ -325,7 +325,7 @@ hppa_linux_sigtramp_unwind_sniffer (stru
    d_un.d_ptr value is the global pointer.  */
 
 static CORE_ADDR
-hppa_linux_find_global_pointer (struct value *function)
+hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   struct obj_section *faddr_sect;
   CORE_ADDR faddr;
diff -urpN src/gdb/hppa-tdep.c dev/gdb/hppa-tdep.c
--- src/gdb/hppa-tdep.c	2008-01-11 15:42:52.000000000 +0100
+++ dev/gdb/hppa-tdep.c	2008-02-18 15:36:27.000000000 +0100
@@ -828,7 +828,7 @@ hppa32_push_dummy_call (struct gdbarch *
   if (struct_return)
     regcache_cooked_write_unsigned (regcache, 28, struct_addr);
 
-  gp = tdep->find_global_pointer (function);
+  gp = tdep->find_global_pointer (gdbarch, function);
 
   if (gp != 0)
     regcache_cooked_write_unsigned (regcache, 19, gp);
@@ -1087,7 +1087,7 @@ hppa64_push_dummy_call (struct gdbarch *
     regcache_cooked_write_unsigned (regcache, HPPA_RET0_REGNUM, struct_addr);
 
   /* Set up GR27 (%dp) to hold the global pointer (gp).  */
-  gp = tdep->find_global_pointer (function);
+  gp = tdep->find_global_pointer (gdbarch, function);
   if (gp != 0)
     regcache_cooked_write_unsigned (regcache, HPPA_DP_REGNUM, gp);
 
@@ -2705,7 +2705,7 @@ hppa_pseudo_register_read (struct gdbarc
 }
 
 static CORE_ADDR
-hppa_find_global_pointer (struct value *function)
+hppa_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
 {
   return 0;
 }
diff -urpN src/gdb/hppa-tdep.h dev/gdb/hppa-tdep.h
--- src/gdb/hppa-tdep.h	2008-01-01 23:53:10.000000000 +0100
+++ dev/gdb/hppa-tdep.h	2008-02-18 15:36:27.000000000 +0100
@@ -87,7 +87,7 @@ struct gdbarch_tdep
 
   /* Given a function address, try to find the global pointer for the 
      corresponding shared object.  */
-  CORE_ADDR (*find_global_pointer) (struct value *);
+  CORE_ADDR (*find_global_pointer) (struct gdbarch *, struct value *);
 
   /* For shared libraries, each call goes through a small piece of
      trampoline code in the ".plt", or equivalent, section.

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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-18 14:47       ` Markus Deuling
@ 2008-02-18 16:04         ` Ulrich Weigand
  2008-02-18 16:12           ` Markus Deuling
  0 siblings, 1 reply; 9+ messages in thread
From: Ulrich Weigand @ 2008-02-18 16:04 UTC (permalink / raw)
  To: Markus Deuling; +Cc: GDB Patches

Markus Deuling wrote:

> 	* hppa-tdep.h (find_global_pointer): Add gdbarch as parameter.
> 
> 	* hppa-hpux-tdep.c (hppa32_hpux_find_global_pointer): Likewise. Replace
> 	current_gdbarch by gdbarch.
> 	(hppa64_hpux_find_global_pointer): Likewise.
> 	* hppa-tdep.c (hppa_find_global_pointer): Likewise.
> 	(hppa32_push_dummy_call, hppa64_push_dummy_call): Update call for
> 	find_global_pointer.
> 
> 	* hppabsd-tdep.c (hppabsd_find_global_pointer): Add gdbarch as
> 	parameter.
> 	* hppa-linux-tdep.c (hppa_linux_find_global_pointer): Likewise.
> 
> 	* hppa-linux-nat.c (hppa_linux_register_addr): Use ARRAY_SIZE instead
> 	of gdbarch_num_regs.
> 
> 	* hppa-hpux-tdep.c (hppa_hpux_sr_for_addr): Add gdbarch as parameter and
> 	replace current_gdbarch by gdbarch.	
> 	(hppa_hpux_push_dummy_code): Update call for hppa_hpux_sr_for_addr.

This is OK, thanks.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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

* Re: [rfc]: Replace current_gdbarch in hppa
  2008-02-18 16:04         ` Ulrich Weigand
@ 2008-02-18 16:12           ` Markus Deuling
  0 siblings, 0 replies; 9+ messages in thread
From: Markus Deuling @ 2008-02-18 16:12 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: GDB Patches

Ulrich Weigand schrieb:
> This is OK, thanks.
> 

Thank you, committed this one.

Regards,
Markus

-- 
  Markus Deuling
  GNU Toolchain for Linux on Cell BE
  deuling@de.ibm.com


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

end of thread, other threads:[~2008-02-18 16:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-15  6:48 [rfc]: Replace current_gdbarch in hppa Markus Deuling
2008-02-15 18:39 ` Ulrich Weigand
2008-02-15 20:19   ` Pedro Alves
2008-02-15 20:22     ` Daniel Jacobowitz
2008-02-18 14:28   ` Markus Deuling
2008-02-18 14:37     ` Ulrich Weigand
2008-02-18 14:47       ` Markus Deuling
2008-02-18 16:04         ` Ulrich Weigand
2008-02-18 16:12           ` Markus Deuling

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