Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
When running on ia64-hpux a program that calls fork, GDB currently
reports the following internal error:
internal-error: Can't determine the current address space of thread process 1882
Here is what happens:
1. GDB receives a "fork" event;
2. handle_inferior_event calls detach_breakpoints for the child process;
3. detach_breakpoints calls ia64's gdbarch remove_breakpoint hook,
which needs to read an entire instruction slot in order to remove
a breakpoint instruction from memory;
4. To read inferior memory, the ia64-hpux code needs to know where
that memory is located relative to the bsp..bspstore area,
and thus needs to read the value of those registers;
5. To get the value of those registers, ia64_hpux_xfer_memory current
uses the current regcache.
The problem is that at the time we are trying to remove the breakpoints
from the child, the child process is not part of the list of inferiors
really known to GDB (it has not been added to inferior_list), so trying
to create a regcache for it triggers an internal error when creating
address space for the regcache (as the address space is ultimately
fetched from the inferior).
To work around this limitation, ia64_hpux_xfer_memory has been modified
to detect the fact the current inferior is not in our inferior list,
and to go, in that case, straight to the source to fetch the registers
it needs.
gdb/ChangeLog:
* ia64-hpux-nat.c (ia64_hpux_get_register_from_save_state_t):
New function.
(ia64_hpux_xfer_memory): Check if inferior_ptid is known before
using the regache. Use ia64_hpux_get_register_from_save_state_t
to access the bsp and bspstore registers if not.
... into _initialize_ia64_hpux_nat. Looks like a harmless but
unfortunate copy/paste error.
gdb/ChangeLog:
* ia64-hpux-nat.c (_initialize_ia64_hpux_nat): Renames
_initialize_hppa_hpux_nat.
gdb/ChangeLog:
* ia64-hpux-nat.c (ia64_hpux_fetch_register): Remove trailing
new-line at end of warning message.
(ia64_hpux_store_register): Remove trailing new-line at end of
error message.
* ia64-hpux-tdep.c: Rephrase comment.
* solib-ia64-hpux.c (struct dld_info): Change type of field
dld_flags from "long long" to ULONGEST.
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.
This fixes unwinding from a thread that is stopped inside a system call.
This can be seen when switching to a thread that is stopped doing a
pthread_cond_wait, for instance...
The comments inside the code should explain what is happening in our
case (the HP-UX exception in the case of system calls): Under certain
circumstances (program stopped inside syscall), the offset to apply to
the current BSP in order to compute the previous BSP is not the usual
CFM & 0x7f.
We parts in this patch:
1. Figuring out that we are stopped inside a syscal: This requires
a TT_LWP_RUREGS ttrace call, which is not directly possible from
ia64-tdep.c. So use defined a new TARGET_OBJECT_HPUX_UREGS object
to request it from the -nat side.
2. Add a gdbarch_tdep method that allows us to change the default
behavior on ia64-hpux, permitting us to have a different "size of
register frame" in that one particular case.
gdb/ChangeLog:
* target.h (enum target_object): Add TARGET_OBJECT_HPUX_UREGS.
* ia64-tdep.h (struct frame_info): forward declaration.
(struct gdbarch_tdep): Add field size_of_register_frame.
* ia64-tdep.c (ia64_access_reg): Use tdep->size_of_register_frame
to determine the size of the register frame.
(ia64_size_of_register_frame): New function.
(ia64_gdbarch_init): Set tdep->size_of_register_frame.
* ia64-hpux-tdep.c: Include "target.h" and "frame.h".
(IA64_HPUX_UREG_REASON): New macro.
(ia64_hpux_stopped_in_syscall, ia64_hpux_size_of_register_frame):
New functions.
(ia64_hpux_init_abi): Set tdep->size_of_register_frame.
* ia64-hpux-nat.c (ia64_hpux_xfer_uregs): New function.
(ia64_hpux_xfer_partial): Add handling of TARGET_OBJECT_HPUX_UREGS
objects.