aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2000-06-04 13:46:37 +0000
committerAndrew Cagney <cagney@redhat.com>2000-06-04 13:46:37 +0000
commitac2e2ef7e2214be3672096ea7e6641d6a0651fd7 (patch)
tree7205cea8571355be893617fae45005b4ab5901a7 /gdb/utils.c
parent0b5454486cd4b2e34f4ac7eb51092ef55fa97b07 (diff)
downloadgdb-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.c23
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;
+}