From 9a043c1d0c3e8a873b2cd90f6e048c77d2efdc8a Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Sat, 1 Feb 2003 23:34:05 +0000 Subject: [PATCH] 2003-02-01 Andrew Cagney * 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. --- gdb/ChangeLog | 14 ++++++++++++++ gdb/defs.h | 3 --- gdb/hppa-tdep.c | 12 +++++++++++- gdb/procfs.c | 29 +++++++++++++++++++++++------ gdb/somsolib.c | 19 ++++++++++++++++++- gdb/utils.c | 19 ------------------- 6 files changed, 66 insertions(+), 30 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6e544a3b8bd..e82f4be7bc5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2003-02-01 Andrew Cagney + + * 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. + 2003-02-01 Andrew Cagney * gdb_dirent.h: Mark up valid uses of , d_namelen and diff --git a/gdb/defs.h b/gdb/defs.h index 0d413d4acd0..d2a16158d37 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -374,9 +374,6 @@ extern int query (const char *, ...) ATTR_FORMAT (printf, 1, 2); 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 *); diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index ba3d63c89b6..6c009340714 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -4555,6 +4555,16 @@ child_get_current_exception_event (void) return ¤t_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 @@ unwind_command (char *exp, int from_tty) } 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); diff --git a/gdb/procfs.c b/gdb/procfs.c index fe5987601c6..bf488a61c94 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -2841,6 +2841,19 @@ proc_parent_pid (procinfo *pi) } +/* 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 @@ proc_set_watchpoint (procinfo *pi, CORE_ADDR addr, int len, int wflags) 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 @@ procfs_can_use_hw_breakpoint (int type, int cnt, int othertype) /* 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; diff --git a/gdb/somsolib.c b/gdb/somsolib.c index 474e2574c15..c66946bfb7d 100644 --- a/gdb/somsolib.c +++ b/gdb/somsolib.c @@ -401,6 +401,21 @@ som_solib_load_symbols (struct so_list *so, char *name, int from_tty, } +/* 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 @@ som_solib_add (char *arg_string, int from_tty, struct target_ops *target, int re 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. diff --git a/gdb/utils.c b/gdb/utils.c index e7353bf5d06..0e92b21b041 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2602,25 +2602,6 @@ phex_nz (ULONGEST l, int sizeof_l) } -/* 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) -- 2.39.2