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]

[commit] localize address to/from host pointer


Hello,

This patch makes the nasty address_to_host_pointer() and host_pointer_to_address() methods static. The HP/UX ones should be deleted. Not sure about the procfs ones.

Andrew
2003-02-01  Andrew Cagney  <ac131313@redhat.com>

	* defs.h (host_pointer_to_address): Delete declaration.
	(address_to_host_pointer): Delete declaration.
	* utils.c (host_pointer_to_address): Delete function.
	(address_to_host_pointer): Delete function.
	* procfs.c (procfs_address_to_host_pointer): New function.
	* procfs.c (proc_set_watchpoint): Use.
	(procfs_can_use_hw_breakpoint): Update comments.
	* somsolib.c (hpux_address_to_host_pointer_hack): New function.
	(som_solib_add): Use.
	* hppa-tdep.c (hppa_pointer_to_address_hack): New function.
	* hppa-tdep.c (unwind_command): Use.
	
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.110
diff -u -r1.110 defs.h
--- defs.h	23 Jan 2003 23:03:31 -0000	1.110
+++ defs.h	1 Feb 2003 23:20:45 -0000
@@ -374,9 +374,6 @@
 
 extern void init_page_info (void);
 
-extern CORE_ADDR host_pointer_to_address (void *ptr);
-extern void *address_to_host_pointer (CORE_ADDR addr);
-
 extern char *gdb_realpath (const char *);
 extern char *xfullpath (const char *);
 
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.47
diff -u -r1.47 hppa-tdep.c
--- hppa-tdep.c	18 Jan 2003 15:55:52 -0000	1.47
+++ hppa-tdep.c	1 Feb 2003 23:21:04 -0000
@@ -4555,6 +4555,16 @@
   return &current_ex_event;
 }
 
+/* Instead of this nasty cast, add a method pvoid() that prints out a
+   host VOID data type (remember %p isn't portable).  */
+
+static CORE_ADDR
+hppa_pointer_to_address_hack (void *ptr)
+{
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
+  return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &ptr);
+}
+
 static void
 unwind_command (char *exp, int from_tty)
 {
@@ -4577,7 +4587,7 @@
     }
 
   printf_unfiltered ("unwind_table_entry (0x%s):\n",
-		     paddr_nz (host_pointer_to_address (u)));
+		     paddr_nz (hppa_pointer_to_address_hack (u)));
 
   printf_unfiltered ("\tregion_start = ");
   print_address (u->region_start, gdb_stdout);
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.41
diff -u -r1.41 procfs.c
--- procfs.c	11 Sep 2002 00:13:58 -0000	1.41
+++ procfs.c	1 Feb 2003 23:21:12 -0000
@@ -2841,6 +2841,19 @@
 }
 
 
+/* Convert a target address (a.k.a. CORE_ADDR) into a host address
+   (a.k.a void pointer)!  */
+
+static void *
+procfs_address_to_host_pointer (CORE_ADDR addr)
+{
+  void *ptr;
+
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
+  ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
+  return ptr;
+}
+
 /*
  * Function: proc_set_watchpoint
  *
@@ -2863,10 +2876,13 @@
   prwatch_t *pwatch;
 
   pwatch            = (prwatch_t *) &arg.watch;
+  /* NOTE: cagney/2003-02-01: Even more horrible hack.  Need to
+     convert a target address into something that can be stored in a
+     native data structure.  */
 #ifdef PCAGENT	/* Horrible hack: only defined on Solaris 2.6+ */
-  pwatch->pr_vaddr  = (uintptr_t) address_to_host_pointer (addr);
+  pwatch->pr_vaddr  = (uintptr_t) procfs_address_to_host_pointer (addr);
 #else
-  pwatch->pr_vaddr  = (caddr_t) address_to_host_pointer (addr);
+  pwatch->pr_vaddr  = (caddr_t) procfs_address_to_host_pointer (addr);
 #endif
   pwatch->pr_size   = len;
   pwatch->pr_wflags = wflags;
@@ -5163,10 +5179,11 @@
   /* Due to the way that proc_set_watchpoint() is implemented, host
      and target pointers must be of the same size.  If they are not,
      we can't use hardware watchpoints.  This limitation is due to the
-     fact that proc_set_watchpoint() calls address_to_host_pointer();
-     a close inspection of address_to_host_pointer will reveal that
-     an internal error will be generated when the host and target
-     pointer sizes are different.  */
+     fact that proc_set_watchpoint() calls
+     procfs_address_to_host_pointer(); a close inspection of
+     procfs_address_to_host_pointer will reveal that an internal error
+     will be generated when the host and target pointer sizes are
+     different.  */
   if (sizeof (void *) != TYPE_LENGTH (builtin_type_void_data_ptr))
     return 0;
 
Index: somsolib.c
===================================================================
RCS file: /cvs/src/src/gdb/somsolib.c,v
retrieving revision 1.22
diff -u -r1.22 somsolib.c
--- somsolib.c	14 Jan 2003 00:49:04 -0000	1.22
+++ somsolib.c	1 Feb 2003 23:21:18 -0000
@@ -401,6 +401,21 @@
 }
 
 
+/* FIXME: cagney/2003-02-01: This just isn't right.  Given an address
+   within the target's address space, this converts the value into an
+   address within the host's (i.e., GDB's) address space.  Given that
+   the host/target address spaces are separate, this can't be right.  */
+
+static void *
+hpux_address_to_host_pointer_hack (CORE_ADDR addr)
+{
+  void *ptr;
+
+  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
+  ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
+  return ptr;
+}
+
 /* Add symbols from shared libraries into the symtab list, unless the
    size threshold specified by auto_solib_limit (in megabytes) would
    be exceeded.  */
@@ -715,8 +730,10 @@
       if (status != 0)
 	goto err;
 
+      /* FIXME: cagney/2003-02-01: I think som_solib.next should be a
+         CORE_ADDR.  */
       new_so->som_solib.next =
-	address_to_host_pointer (extract_unsigned_integer (buf, 4));
+	hpux_address_to_host_pointer_hack (extract_unsigned_integer (buf, 4));
 
       /* Note that we don't re-set "addr" to the next pointer
        * until after we've read the trailing data.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.92
diff -u -r1.92 utils.c
--- utils.c	31 Jan 2003 23:22:07 -0000	1.92
+++ utils.c	1 Feb 2003 23:21:50 -0000
@@ -2602,25 +2602,6 @@
 }
 
 
-/* Convert to / from the hosts pointer to GDB's internal CORE_ADDR
-   using the target's conversion routines. */
-CORE_ADDR
-host_pointer_to_address (void *ptr)
-{
-  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
-  return POINTER_TO_ADDRESS (builtin_type_void_data_ptr, &ptr);
-}
-
-void *
-address_to_host_pointer (CORE_ADDR addr)
-{
-  void *ptr;
-
-  gdb_assert (sizeof (ptr) == TYPE_LENGTH (builtin_type_void_data_ptr));
-  ADDRESS_TO_POINTER (builtin_type_void_data_ptr, &ptr, addr);
-  return ptr;
-}
-
 /* Convert a CORE_ADDR into a string.  */
 const char *
 core_addr_to_string (const CORE_ADDR addr)

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