This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] [3/9] Remove adress conversion macros
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Fri, 01 Jun 2007 13:39:44 +0200
- Subject: [rfc] [3/9] Remove adress conversion macros
Hello,
this patch removes POINTER_TO_ADDRESS and ADDRESS_TO_POINTER macros from gdbarch.sh
ChangeLog:
* gdbarch.sh (ADDRESS_TO_POINTER): Replace by
gdbarch_address_to_pointer.
* findvar.c (store_typed_address): Likewise.
* gdbtypes.c (make_pointer_type): Likewise (comment).
* procfs.c (procfs_address_to_host_pointer): Likewise.
* std-regs.c (value_of_builtin_frame_reg): Likewise.
(value_of_builtin_frame_fp_reg): Likewise.
(value_of_builtin_frame_pc_reg): Likewise.
* utils.c (paddress): Likewise (comment).
* gdbarch.sh (POINTER_TO_ADDRESS): Replace by
gdbarch_pointer_to_address.
* findvar.c (extract_typed_address): Likewise.
* gdbtypes.c (make_pointer_type): Likewise (comment).
* valops.c (value_cast): Likewise (comment).
* gdbarch.c, gdbarch.h: Regenerate.
Is this ok to commit?
Regards,
Markus
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
diff -urN src/gdb/findvar.c dev/gdb/findvar.c
--- src/gdb/findvar.c 2007-05-07 13:21:04.000000000 +0200
+++ dev/gdb/findvar.c 2007-05-21 06:05:17.000000000 +0200
@@ -174,7 +174,7 @@
_("extract_typed_address: "
"type is not a pointer or reference"));
- return POINTER_TO_ADDRESS (type, buf);
+ return gdbarch_pointer_to_address (current_gdbarch, type, buf);
}
@@ -243,7 +243,7 @@
_("store_typed_address: "
"type is not a pointer or reference"));
- ADDRESS_TO_POINTER (type, buf, addr);
+ gdbarch_address_to_pointer (current_gdbarch, type, buf, addr);
}
diff -urN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/gdbarch.c 2007-05-21 06:04:18.000000000 +0200
@@ -703,12 +703,6 @@
fprintf_unfiltered (file,
"gdbarch_dump: address_class_type_flags_to_name = <0x%lx>\n",
(long) current_gdbarch->address_class_type_flags_to_name);
-#ifdef ADDRESS_TO_POINTER
- fprintf_unfiltered (file,
- "gdbarch_dump: %s # %s\n",
- "ADDRESS_TO_POINTER(type, buf, addr)",
- XSTRING (ADDRESS_TO_POINTER (type, buf, addr)));
-#endif
fprintf_unfiltered (file,
"gdbarch_dump: address_to_pointer = <0x%lx>\n",
(long) current_gdbarch->address_to_pointer);
@@ -1238,12 +1232,6 @@
fprintf_unfiltered (file,
"gdbarch_dump: pc_regnum = %s\n",
paddr_d (current_gdbarch->pc_regnum));
-#ifdef POINTER_TO_ADDRESS
- fprintf_unfiltered (file,
- "gdbarch_dump: %s # %s\n",
- "POINTER_TO_ADDRESS(type, buf)",
- XSTRING (POINTER_TO_ADDRESS (type, buf)));
-#endif
fprintf_unfiltered (file,
"gdbarch_dump: pointer_to_address = <0x%lx>\n",
(long) current_gdbarch->pointer_to_address);
diff -urN src/gdb/gdbarch.h dev/gdb/gdbarch.h
--- src/gdb/gdbarch.h 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/gdbarch.h 2007-05-21 06:04:09.000000000 +0200
@@ -206,7 +206,8 @@
/ addr_bit will be set from it.
If TARGET_PTR_BIT and TARGET_ADDR_BIT are different, you'll probably
- also need to set POINTER_TO_ADDRESS and ADDRESS_TO_POINTER as well.
+ also need to set gdbarch_pointer_to_address and gdbarch_address_to_pointer
+ as well.
ptr_bit is the size of a pointer on the target */
@@ -661,22 +662,10 @@
typedef CORE_ADDR (gdbarch_pointer_to_address_ftype) (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);
-#if !defined (GDB_TM_FILE) && defined (POINTER_TO_ADDRESS)
-#error "Non multi-arch definition of POINTER_TO_ADDRESS"
-#endif
-#if !defined (POINTER_TO_ADDRESS)
-#define POINTER_TO_ADDRESS(type, buf) (gdbarch_pointer_to_address (current_gdbarch, type, buf))
-#endif
typedef void (gdbarch_address_to_pointer_ftype) (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);
-#if !defined (GDB_TM_FILE) && defined (ADDRESS_TO_POINTER)
-#error "Non multi-arch definition of ADDRESS_TO_POINTER"
-#endif
-#if !defined (ADDRESS_TO_POINTER)
-#define ADDRESS_TO_POINTER(type, buf, addr) (gdbarch_address_to_pointer (current_gdbarch, type, buf, addr))
-#endif
extern int gdbarch_integer_to_address_p (struct gdbarch *gdbarch);
diff -urN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh 2007-05-15 05:41:29.000000000 +0200
+++ dev/gdb/gdbarch.sh 2007-05-21 06:03:22.000000000 +0200
@@ -407,7 +407,8 @@
# / addr_bit will be set from it.
#
# If TARGET_PTR_BIT and TARGET_ADDR_BIT are different, you'll probably
-# also need to set POINTER_TO_ADDRESS and ADDRESS_TO_POINTER as well.
+# also need to set gdbarch_pointer_to_address and gdbarch_address_to_pointer
+# as well.
#
# ptr_bit is the size of a pointer on the target
v:TARGET_PTR_BIT:int:ptr_bit:::8 * sizeof (void*):TARGET_INT_BIT::0
@@ -496,8 +497,8 @@
# (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
+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:integer_to_address:struct type *type, const gdb_byte *buf:type, buf
# It has been suggested that this, well actually its predecessor,
diff -urN src/gdb/gdbtypes.c dev/gdb/gdbtypes.c
--- src/gdb/gdbtypes.c 2007-05-18 05:34:56.000000000 +0200
+++ dev/gdb/gdbtypes.c 2007-05-21 06:06:18.000000000 +0200
@@ -317,8 +317,8 @@
TYPE_CODE (ntype) = TYPE_CODE_PTR;
/* Mark pointers as unsigned. The target converts between pointers
- and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
- ADDRESS_TO_POINTER(). */
+ and addresses (CORE_ADDRs) using gdbarch_pointer_to_address and
+ gdbarch_address_to_pointer. */
TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
diff -urN src/gdb/procfs.c dev/gdb/procfs.c
--- src/gdb/procfs.c 2007-05-07 13:21:05.000000000 +0200
+++ dev/gdb/procfs.c 2007-05-21 05:57:06.000000000 +0200
@@ -2847,7 +2847,8 @@
void *ptr;
gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
- ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
+ gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
+ &ptr, addr);
return ptr;
}
diff -urN src/gdb/std-regs.c dev/gdb/std-regs.c
--- src/gdb/std-regs.c 2007-02-08 22:00:34.000000000 +0100
+++ dev/gdb/std-regs.c 2007-05-21 05:57:06.000000000 +0200
@@ -64,8 +64,8 @@
memset (buf, 0, TYPE_LENGTH (value_type (val)));
/* frame.base. */
if (frame != NULL)
- ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,
- get_frame_base (frame));
+ gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
+ buf, get_frame_base (frame));
buf += TYPE_LENGTH (builtin_type_void_data_ptr);
/* frame.XXX. */
return val;
@@ -89,8 +89,8 @@
if (frame == NULL)
memset (buf, 0, TYPE_LENGTH (value_type (val)));
else
- ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,
- get_frame_base_address (frame));
+ gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
+ buf, get_frame_base_address (frame));
return val;
}
}
@@ -107,8 +107,8 @@
if (frame == NULL)
memset (buf, 0, TYPE_LENGTH (value_type (val)));
else
- ADDRESS_TO_POINTER (builtin_type_void_data_ptr, buf,
- get_frame_pc (frame));
+ gdbarch_address_to_pointer (current_gdbarch, builtin_type_void_data_ptr,
+ buf, get_frame_pc (frame));
return val;
}
}
diff -urN src/gdb/utils.c dev/gdb/utils.c
--- src/gdb/utils.c 2007-04-02 05:53:36.000000000 +0200
+++ dev/gdb/utils.c 2007-05-21 05:57:06.000000000 +0200
@@ -2559,7 +2559,7 @@
when it won't occur. */
/* NOTE: This assumes that the significant address information is
kept in the least significant bits of ADDR - the upper bits were
- either zero or sign extended. Should ADDRESS_TO_POINTER() or
+ either zero or sign extended. Should gdbarch_address_to_pointer or
some ADDRESS_TO_PRINTABLE() be used to do the conversion? */
int addr_bit = TARGET_ADDR_BIT;
diff -urN src/gdb/valops.c dev/gdb/valops.c
--- src/gdb/valops.c 2007-02-27 20:46:04.000000000 +0100
+++ dev/gdb/valops.c 2007-05-21 06:05:48.000000000 +0200
@@ -389,7 +389,7 @@
}
/* When we cast pointers to integers, we mustn't use
- POINTER_TO_ADDRESS to find the address the pointer
+ gdbarch_pointer_to_address to find the address the pointer
represents, as value_as_long would. GDB should evaluate
expressions just as the compiler would --- and the compiler
sees a cast as a simple reinterpretation of the pointer's