mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
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.
This commit is contained in:
23
gdb/utils.c
23
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user