diff options
author | Andrew Cagney <cagney@redhat.com> | 2000-06-04 13:46:37 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2000-06-04 13:46:37 +0000 |
commit | ac2e2ef7e2214be3672096ea7e6641d6a0651fd7 (patch) | |
tree | 7205cea8571355be893617fae45005b4ab5901a7 /gdb/utils.c | |
parent | 0b5454486cd4b2e34f4ac7eb51092ef55fa97b07 (diff) | |
download | gdb-ac2e2ef7e2214be3672096ea7e6641d6a0651fd7.zip gdb-ac2e2ef7e2214be3672096ea7e6641d6a0651fd7.tar.gz gdb-ac2e2ef7e2214be3672096ea7e6641d6a0651fd7.tar.bz2 |
Add host_pointer_to_address() and address_to_host_pointer(). Add
signed_pointer_to_address() etc. Rename generic_pointer_to_address()
to unsigned_pointer_to_address() etc.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r-- | gdb/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gdb/utils.c b/gdb/utils.c index f5088af..b3a3ad9 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -50,6 +50,8 @@ #include "language.h" #include "annotate.h" +#include "inferior.h" /* for signed_pointer_to_address */ + #include <readline/readline.h> #undef XMALLOC @@ -2962,3 +2964,24 @@ phex_nz (ULONGEST l, int sizeof_l) } return str; } + + +/* 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) +{ + if (sizeof (ptr) != TYPE_LENGTH (builtin_type_ptr)) + internal_error ("core_addr_to_void_ptr: bad cast"); + return POINTER_TO_ADDRESS (builtin_type_ptr, &ptr); +} + +void * +address_to_host_pointer (CORE_ADDR addr) +{ + void *ptr; + if (sizeof (ptr) != TYPE_LENGTH (builtin_type_ptr)) + internal_error ("core_addr_to_void_ptr: bad cast"); + ADDRESS_TO_POINTER (builtin_type_ptr, &ptr, addr); + return ptr; +} |