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]

[rfc] [09/18] Cell multi-arch: Pass GDBARCH to gdbarch_pointer_to_address


Hello,

another change related to pointer <-> address conversion: as the SPU version
of gdbarch_pointer_to_address requires access to the gdbarch where the 
conversion is performed, those functions need to be changed to type 'm'
in gdbarch.sh.  This (mechanical) patch performs that change.

Bye,
Ulrich


ChangeLog:

	* gdbarch.sh (pointer_to_address): Change to type 'm'.
	(address_to_pointer): Likewise.
	* gdbarch.c, gdbarch.h: Regenerate.

	* inferior.h (unsigned_pointer_to_address): Add GDBARCH argument.
	(signed_pointer_to_address): Likewise.
	(unsigned_address_to_pointer, address_to_signed_pointer): Likewise.
	* findvar.c (unsigned_pointer_to_address): Likewise.
	(signed_pointer_to_address): Likewise.
	(unsigned_address_to_pointer, address_to_signed_pointer): Likewise.

	* avr-tdep.c (avr_address_to_pointer): Likewise.
	(avr_pointer_to_address): Likewise.
	* iq2000-tdep.c (iq2000_pointer_to_address): Likewise.
	(iq2000_address_to_pointer): Likewise.
	* m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise.
	(m32c_m16c_pointer_to_address): Likewise.
	* spu-tdep.c (spu_pointer_to_address): Likewise.
	* xstormy16-tdep.c (xstormy16_pointer_to_address): Likewise.
	(xstormy16_address_to_pointer): Likewise.


Index: src/gdb/avr-tdep.c
===================================================================
--- src.orig/gdb/avr-tdep.c
+++ src/gdb/avr-tdep.c
@@ -278,7 +278,8 @@ avr_convert_saddr_to_raw (CORE_ADDR x)
 /* Convert from address to pointer and vice-versa. */
 
 static void
-avr_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr)
+avr_address_to_pointer (struct gdbarch *gdbarch,
+			struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
   /* Is it a code address?  */
   if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
@@ -296,7 +297,8 @@ avr_address_to_pointer (struct type *typ
 }
 
 static CORE_ADDR
-avr_pointer_to_address (struct type *type, const gdb_byte *buf)
+avr_pointer_to_address (struct gdbarch *gdbarch,
+			struct type *type, const gdb_byte *buf)
 {
   CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
 
Index: src/gdb/findvar.c
===================================================================
--- src.orig/gdb/findvar.c
+++ src/gdb/findvar.c
@@ -308,13 +308,15 @@ value_of_register_lazy (struct frame_inf
 /* Given a pointer of type TYPE in target form in BUF, return the
    address it represents.  */
 CORE_ADDR
-unsigned_pointer_to_address (struct type *type, const gdb_byte *buf)
+unsigned_pointer_to_address (struct gdbarch *gdbarch,
+			     struct type *type, const gdb_byte *buf)
 {
   return extract_unsigned_integer (buf, TYPE_LENGTH (type));
 }
 
 CORE_ADDR
-signed_pointer_to_address (struct type *type, const gdb_byte *buf)
+signed_pointer_to_address (struct gdbarch *gdbarch,
+			   struct type *type, const gdb_byte *buf)
 {
   return extract_signed_integer (buf, TYPE_LENGTH (type));
 }
@@ -322,14 +324,15 @@ signed_pointer_to_address (struct type *
 /* Given an address, store it as a pointer of type TYPE in target
    format in BUF.  */
 void
-unsigned_address_to_pointer (struct type *type, gdb_byte *buf,
-			     CORE_ADDR addr)
+unsigned_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
+			     gdb_byte *buf, CORE_ADDR addr)
 {
   store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
 }
 
 void
-address_to_signed_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr)
+address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type,
+			   gdb_byte *buf, CORE_ADDR addr)
 {
   store_signed_integer (buf, TYPE_LENGTH (type), addr);
 }
Index: src/gdb/gdbarch.c
===================================================================
--- src.orig/gdb/gdbarch.c
+++ src/gdb/gdbarch.c
@@ -312,8 +312,8 @@ struct gdbarch startup_gdbarch =
   0,  /* register_to_value */
   0,  /* value_to_register */
   0,  /* value_from_register */
-  0,  /* pointer_to_address */
-  0,  /* address_to_pointer */
+  unsigned_pointer_to_address,  /* pointer_to_address */
+  unsigned_address_to_pointer,  /* address_to_pointer */
   0,  /* integer_to_address */
   0,  /* return_value */
   0,  /* skip_prologue */
@@ -2056,7 +2056,7 @@ gdbarch_pointer_to_address (struct gdbar
   gdb_assert (gdbarch->pointer_to_address != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_pointer_to_address called\n");
-  return gdbarch->pointer_to_address (type, buf);
+  return gdbarch->pointer_to_address (gdbarch, type, buf);
 }
 
 void
@@ -2073,7 +2073,7 @@ gdbarch_address_to_pointer (struct gdbar
   gdb_assert (gdbarch->address_to_pointer != NULL);
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_address_to_pointer called\n");
-  gdbarch->address_to_pointer (type, buf, addr);
+  gdbarch->address_to_pointer (gdbarch, type, buf, addr);
 }
 
 void
Index: src/gdb/gdbarch.h
===================================================================
--- src.orig/gdb/gdbarch.h
+++ src/gdb/gdbarch.h
@@ -348,11 +348,11 @@ typedef struct value * (gdbarch_value_fr
 extern struct value * gdbarch_value_from_register (struct gdbarch *gdbarch, struct type *type, int regnum, struct frame_info *frame);
 extern void set_gdbarch_value_from_register (struct gdbarch *gdbarch, gdbarch_value_from_register_ftype *value_from_register);
 
-typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct type *type, const gdb_byte *buf);
+typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
 extern CORE_ADDR gdbarch_pointer_to_address (struct gdbarch *gdbarch, struct type *type, const gdb_byte *buf);
 extern void set_gdbarch_pointer_to_address (struct gdbarch *gdbarch, gdbarch_pointer_to_address_ftype *pointer_to_address);
 
-typedef void (gdbarch_address_to_pointer_ftype) (struct type *type, gdb_byte *buf, CORE_ADDR addr);
+typedef void (gdbarch_address_to_pointer_ftype) (struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr);
 extern void gdbarch_address_to_pointer (struct gdbarch *gdbarch, struct type *type, gdb_byte *buf, CORE_ADDR addr);
 extern void set_gdbarch_address_to_pointer (struct gdbarch *gdbarch, gdbarch_address_to_pointer_ftype *address_to_pointer);
 
Index: src/gdb/gdbarch.sh
===================================================================
--- src.orig/gdb/gdbarch.sh
+++ src/gdb/gdbarch.sh
@@ -466,8 +466,8 @@ f:void:value_to_register:struct frame_in
 # (but not the value contents) filled in.
 f:struct value *:value_from_register:struct type *type, int regnum, struct frame_info *frame:type, regnum, frame::default_value_from_register::0
 #
-f:CORE_ADDR:pointer_to_address:struct type *type, const gdb_byte *buf:type, buf::unsigned_pointer_to_address::0
-f:void:address_to_pointer:struct type *type, gdb_byte *buf, CORE_ADDR addr:type, buf, addr::unsigned_address_to_pointer::0
+m:CORE_ADDR:pointer_to_address:struct type *type, const gdb_byte *buf:type, buf::unsigned_pointer_to_address::0
+m:void:address_to_pointer:struct type *type, gdb_byte *buf, CORE_ADDR addr:type, buf, addr::unsigned_address_to_pointer::0
 M:CORE_ADDR:integer_to_address:struct type *type, const gdb_byte *buf:type, buf
 
 # Return the return-value convention that will be used by FUNCTYPE
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h
+++ src/gdb/inferior.h
@@ -156,13 +156,17 @@ extern CORE_ADDR read_pc (void);
 
 extern void write_pc (CORE_ADDR);
 
-extern CORE_ADDR unsigned_pointer_to_address (struct type *type,
+extern CORE_ADDR unsigned_pointer_to_address (struct gdbarch *gdbarch,
+					      struct type *type,
 					      const gdb_byte *buf);
-extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf,
+extern void unsigned_address_to_pointer (struct gdbarch *gdbarch,
+					 struct type *type, gdb_byte *buf,
 					 CORE_ADDR addr);
-extern CORE_ADDR signed_pointer_to_address (struct type *type,
+extern CORE_ADDR signed_pointer_to_address (struct gdbarch *gdbarch,
+					    struct type *type,
 					    const gdb_byte *buf);
-extern void address_to_signed_pointer (struct type *type, gdb_byte *buf,
+extern void address_to_signed_pointer (struct gdbarch *gdbarch,
+				       struct type *type, gdb_byte *buf,
 				       CORE_ADDR addr);
 
 extern void wait_for_inferior (int treat_exec_as_sigtrap);
Index: src/gdb/iq2000-tdep.c
===================================================================
--- src.orig/gdb/iq2000-tdep.c
+++ src/gdb/iq2000-tdep.c
@@ -86,7 +86,8 @@ insn_addr_from_ptr (CORE_ADDR ptr)	/* ta
    Convert a target pointer to an address in host (CORE_ADDR) format. */
 
 static CORE_ADDR
-iq2000_pointer_to_address (struct type * type, const gdb_byte * buf)
+iq2000_pointer_to_address (struct gdbarch *gdbarch,
+			   struct type * type, const gdb_byte * buf)
 {
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
   CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
@@ -103,7 +104,8 @@ iq2000_pointer_to_address (struct type *
    Convert a host-format address (CORE_ADDR) into a target pointer.  */
 
 static void
-iq2000_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr)
+iq2000_address_to_pointer (struct gdbarch *gdbarch,
+			   struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
 
Index: src/gdb/m32c-tdep.c
===================================================================
--- src.orig/gdb/m32c-tdep.c
+++ src/gdb/m32c-tdep.c
@@ -2397,7 +2397,8 @@ m32c_skip_trampoline_code (struct frame_
    programmer!  :)  */
 
 static void
-m32c_m16c_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr)
+m32c_m16c_address_to_pointer (struct gdbarch *gdbarch,
+			      struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
   enum type_code target_code;
   gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
@@ -2445,7 +2446,8 @@ m32c_m16c_address_to_pointer (struct typ
 
 
 static CORE_ADDR
-m32c_m16c_pointer_to_address (struct type *type, const gdb_byte *buf)
+m32c_m16c_pointer_to_address (struct gdbarch *gdbarch,
+			      struct type *type, const gdb_byte *buf)
 {
   CORE_ADDR ptr;
   enum type_code target_code;
Index: src/gdb/spu-tdep.c
===================================================================
--- src.orig/gdb/spu-tdep.c
+++ src/gdb/spu-tdep.c
@@ -325,7 +325,8 @@ spu_register_reggroup_p (struct gdbarch 
 /* Address conversion.  */
 
 static CORE_ADDR
-spu_pointer_to_address (struct type *type, const gdb_byte *buf)
+spu_pointer_to_address (struct gdbarch *gdbarch,
+			struct type *type, const gdb_byte *buf)
 {
   ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
   ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size.  */
Index: src/gdb/xstormy16-tdep.c
===================================================================
--- src.orig/gdb/xstormy16-tdep.c
+++ src/gdb/xstormy16-tdep.c
@@ -592,7 +592,8 @@ xstormy16_skip_trampoline_code (struct f
    and vice versa.  */
 
 static CORE_ADDR
-xstormy16_pointer_to_address (struct type *type, const gdb_byte *buf)
+xstormy16_pointer_to_address (struct gdbarch *gdbarch,
+			      struct type *type, const gdb_byte *buf)
 {
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
   CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
@@ -608,7 +609,8 @@ xstormy16_pointer_to_address (struct typ
 }
 
 static void
-xstormy16_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr)
+xstormy16_address_to_pointer (struct gdbarch *gdbarch,
+			      struct type *type, gdb_byte *buf, CORE_ADDR addr)
 {
   enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
 
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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