aboutsummaryrefslogtreecommitdiff
path: root/gdb/ia64-hpux-nat.c
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-01-13 16:24:42 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-01-13 16:24:42 +0000
commitc4de7027e3081f32895dc41d121a96e9e6717128 (patch)
tree36730eec41334dadc4705ab54af4423421b65833 /gdb/ia64-hpux-nat.c
parent77ca787b12516ebb1b0d23710021b26b9c81b018 (diff)
downloadgdb-c4de7027e3081f32895dc41d121a96e9e6717128.zip
gdb-c4de7027e3081f32895dc41d121a96e9e6717128.tar.gz
gdb-c4de7027e3081f32895dc41d121a96e9e6717128.tar.bz2
[ia64-hpux] inferior function call support
We have two stacks to deal with on ia64, when making a function call. The first is the usual stack frame, and the second is the register stack frame. On ia64-linux, the register frame is setup by adjusting the BSP register. Unfortunately for us, the HP-UX kernel does not allow the debugger to change the value of the BSP. To work around that limitation, the method I am using here is to push some assembly code on the stack. This assembly code contains, among other things, a call to the alloc insn, which sets up our frame for us. An extensive comment in ia64-hpux-tdep.c explains the entire procedure. Despite this approach, most of the code in ia64-tdep.c which sets up the function call is still applicable - and only a few things need to be done differently: For instance, instead of changing the BSP, we do nothing. We store the parameters at a different location, etc. So this patch also adjusts the inf-call code in ia64-tdep.c to make it a little more extensible: I create a new ia64_infcall_ops structure which allows an ABI to define how the few things that need to be differentiated. Another element that turned out to be necessary but is more of a detail is that the computation of the linkage pointer needs to be handled specially for symbols inside shared libraries. This is especially visible when calling malloc, which happens everytime memory needs to be allocated in inferior memory... The special treatment included again the necessity to use some routines only available on the host. So another target object TARGET_OBJECT_HPUX_SOLIB_GOT was created for that purpose. gdb/ChangeLog: * ia64-tdep.h (struct regcache): Forward declare. (struct ia64_infcall_ops): New struct type. (struct gdbarch_tdep): New fields "find_global_pointer_from_solib" and "infcall_ops". * ia64-tdep.c (ia64_find_global_pointer_from_dynamic_section): Renames ia64_find_global_pointer. (ia64_find_global_pointer, ia64_allocate_new_rse_frame) (ia64_store_argument_in_slot, ia64_set_function_addr: New function. (ia64_push_dummy_call): Adjust to use the new tdep ia64_infocall_ops methods. (ia64_infcall_ops): New static global constant. (ia64_gdbarch_init): Set tdep->infcall_ops. * ia64-hpux-nat.c (ia64_hpux_xfer_solib_got): New function. (ia64_hpux_xfer_partial): Add TARGET_OBJECT_HPUX_SOLIB_GOT handing. * ia64-hpux-tdep.c: Include "regcache.h", "gdbcore.h" and "inferior.h". (ia64_hpux_dummy_code): New static global constant. (ia64_hpux_push_dummy_code, ia64_hpux_allocate_new_rse_frame) (ia64_hpux_store_argument_in_slot, ia64_hpux_set_function_addr) (ia64_hpux_dummy_id, ia64_hpux_find_global_pointer_from_solib): New function. (ia64_hpux_infcall_ops): New static global constant. (ia64_hpux_init_abi): Install gdbarch and tdep methods needed for inferior function calls to work properly on ia64-hpux.
Diffstat (limited to 'gdb/ia64-hpux-nat.c')
-rw-r--r--gdb/ia64-hpux-nat.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/ia64-hpux-nat.c b/gdb/ia64-hpux-nat.c
index fd58bba..32160aa 100644
--- a/gdb/ia64-hpux-nat.c
+++ b/gdb/ia64-hpux-nat.c
@@ -590,6 +590,40 @@ ia64_hpux_xfer_uregs (struct target_ops *ops, const char *annex,
return len;
}
+/* Handle the transfer of TARGET_OBJECT_HPUX_SOLIB_GOT objects on ia64-hpux.
+
+ The current implementation does not support write transfers (because
+ we do not currently do not need these transfers), and will raise
+ a failed assertion if WRITEBUF is not NULL. */
+
+static LONGEST
+ia64_hpux_xfer_solib_got (struct target_ops *ops, const char *annex,
+ gdb_byte *readbuf, const gdb_byte *writebuf,
+ ULONGEST offset, LONGEST len)
+{
+ CORE_ADDR fun_addr;
+ /* The linkage pointer. We use a uint64_t to make sure that the size
+ of the object we are returning is always 64 bits long, as explained
+ in the description of the TARGET_OBJECT_HPUX_SOLIB_GOT object.
+ This is probably paranoia, but we do not use a CORE_ADDR because
+ it could conceivably be larger than uint64_t. */
+ uint64_t got;
+
+ gdb_assert (writebuf == NULL);
+
+ if (offset > sizeof (got))
+ return 0;
+
+ fun_addr = string_to_core_addr (annex);
+ got = ia64_hpux_get_solib_linkage_addr (fun_addr);
+
+ if (len > sizeof (got) - offset)
+ len = sizeof (got) - offset;
+ memcpy (readbuf, &got + offset, len);
+
+ return len;
+}
+
/* The "to_xfer_partial" target_ops routine for ia64-hpux. */
static LONGEST
@@ -603,6 +637,9 @@ ia64_hpux_xfer_partial (struct target_ops *ops, enum target_object object,
val = ia64_hpux_xfer_memory (ops, annex, readbuf, writebuf, offset, len);
else if (object == TARGET_OBJECT_HPUX_UREGS)
val = ia64_hpux_xfer_uregs (ops, annex, readbuf, writebuf, offset, len);
+ else if (object == TARGET_OBJECT_HPUX_SOLIB_GOT)
+ val = ia64_hpux_xfer_solib_got (ops, annex, readbuf, writebuf, offset,
+ len);
else
val = super_xfer_partial (ops, object, annex, readbuf, writebuf, offset,
len);