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.
Before this change, detach_breakpoints would take a pid, and then
set inferior_ptid to a ptid that it constructs using pid_to_ptid (pid).
Unfortunately, this ptid is not necessarily valid. Consider for
instance the case of ia64-hpux, where ttrace refuses a register-read
operation if the LWP is not provided.
This problems shows up when GDB is trying to handle fork events.
Assuming GDB is configured to follow the parent, GDB will try to
detach from the child. But before doing so, it needs to remove
all breakpoints inside that child. On ia64, this involves reading
inferior (the child's) memory. And on ia64-hpux, reading memory
requires us to read the bsp and bspstore registers, in order to
determine where that memory is relative to the value of those
registers, and thus to determine which ttrace operation to use in
order to fetch that memory (see ia64_hpux_xfer_memory).
This patch therefore changes detach_breakpoints to take a ptid instead
of a pid, and then updates all callers.
One of the consequences of this patch is that it trips an assert
on GNU/Linux targets. But this assert appears to have not actual
purpose, and is thus removed.
gdb/ChangeLog:
* breakpoint.h (detach_breakpoints): pid parameter is now a ptid.
* breakpoint.c (detach_breakpoints): Change pid parameter into
a ptid. Adjust code accordingly.
* infrun.c (handle_inferior_event): Delete variable child_pid.
Update call to detach_breakpoints to pass the child ptid for
fork events.
* linux-nat.c (linux_nat_iterate_watchpoint_lwps): Remove
assert that inferior_ptid's lwp is zero.
(linux_handle_extended_wait): Update call to detach_breakpoints.
* inf-ttrace.c (inf_ttrace_follow_fork): Update call to
detach_breakpoints.
When debugging a program that forks with follow-fork set to follow
the parent, we end up calling detach_breakpoints for the child twice.
On ia64-hpux, this leads to a warning when trying to remove the
breakpoints the second time around, because the ia64 code detects
that the address does not point to a breakpoint instruction.
gdb/ChangeLog:
* inf-ttrace.c (inf_ttrace_follow_fork): When following the
parent, only call detach_breakpoints if tts.tts_event ==
TTEVT_VFORK.
The problem is trying to unwind from a function where %ebp is NOT
used as the frame pointer, and the size of the frame changes over
the lifetime of that function.
For instance, trying to unwind past the GNAT runtime function
called system.tasking.rendezvous.timed_selective_wait on x86-linux,
one can get:
(gdb) bt
[...]
#3 0x0805364b in system.tasking.rendezvous.timed_selective_wait ()
#4 0xb7fe5068 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
Looking at the CFI, we find the following initial instructions...
> DW_CFA_def_cfa: %esp+4 (r4 ofs 4)
> DW_CFA_offset: %eip at cfa-4 (r8 = %eip)
... and the associated FDE:
> 00001be4 00000054 00001be8 FDE cie=00000000 pc=08053310..08053951
[...]
> DW_CFA_advance_loc: 8 to 080534ad
> DW_CFA_def_cfa_offset: 112
> DW_CFA_advance_loc2: 414 to 0805364b
> DW_CFA_def_cfa_offset: 108
[...]
The problem is that the DWARF frame unwinder executed the FDE until
the row for PC == 0x0805364b. But in reality, our program hasn't
executed the instruction at that address yet (it is the return address).
So GDB executed a little too much of the FDE, giving us the wrong
offset for the frame base, and thus the wrong address where %eip
got saved.
This patch fixes the problem by using a more correct PC as the bound
for executing the FDE.
gdb/ChangeLog:
* dwarf2-frame.c (dwarf2_frame_cache): Use
get_frame_address_in_block instead of get_frame_pc as
the bound for executing the frame's FDE.
gdb/testsuite/ChangeLog:
* gdb.ada/rdv_wait: New testcase.
operands, so that data addresses can be corrected when not
ES-overridden.
* rl78-decode.c: Regenerate.
* rl78-dis.c (print_insn_rl78): Make order of modifiers
irrelevent. When the 'e' specifier is used on an operand and no
ES prefix is provided, adjust address to make it absolute.
(gdb_bfd_ref): Initialize new field.
(gdb_bfd_unref): Unref the archive BFD.
(gdb_bfd_openr_next_archived_file): Acquire a reference to the
parent archive.
This adds Usage strings to a bunch of commands, tweaks the grammar in a
few, and improves the help text for the handle command.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
macros, use local variables for info struct member accesses,
update the type of the variable used to hold the instruction
word.
(print_insn_mips, print_mips16_insn_arg): Likewise.
(print_insn_mips16): Add GET_OP and GET_OP_S local macros, use
local variables for info struct member accesses.
(print_insn_micromips): Add GET_OP_S local macro.
(_print_insn_mips): Update the type of the variable used to hold
the instruction word.
* script-sections.cc (Sections_element::output_section_name): Add
keep return parameter.
(Output_section_element::match_name): Add keep return parameter.
Return the value of the keep_ member.
* script-sections.h (class Output_section): Update
output_section_name prototype.
* layout.cc (Layout::keep_input_section): New public member
function.
(Layout::choose_output_section): Pass keep parameter to
output_section_name.
* layout.h (class Layout): Add keep_input_section.
* object.cc (Sized_relobj_file::do_layout): Check for kept input
sections.
* testsuite/Makefile.am: Add a test.
* testsuite/Makefile.in: Regenerate.
* testsuite/pr14265.c: Source file for the test.
* testsuite/pr14265.t: Linker script for the test.
* testsuite/pr14265.sh: Shell script for the test.
* ld-gc/gc.exp: Add a new test.
* ld-gc/pr14265.c: Source file for the new test.
* ld-gc/pr14265.t: Linker script for the new test.
* ld-gc/pr14265.d: Expected symbol dump.
(Target::do_output_section_name): New function.
* layout.cc (Layout::choose_output_section): Call the above.
* powerpc.cc (Target_powerpc::do_output_section_name): New function.
(mmix_greg_internal): Handle expressions not determinable at first
pass.
(s_loc): Ditto. Record expressions where the section isn't
determinable at the first pass, and assume they don't refer to
other sections.
(mmix_md_end): Verify that recorded LOC expressions weren't
to other sections, else emit error messages.
* powerpc.h: Add more relocs.
(R_PPC_REL16*): Rename to R_POWERPC_REL16*.
gold/
* powerpc.cc: Update for renamed R_PPC_REL16 relocs.
(Output_data_got_powerpc::do_write): Don't rely on base class lookup
for replace_constant call.
(Output_data_plt_powerpc::do_print_to_mapfile): New function.
(Output_data_glink::do_print_to_mapfile): New function.
(Target_powerpc::Scan::local): Ignore R_PPC64_TOCSAVE.
(Target_powerpc::Relocate::relocate): Likewise.
(Powerpc_relobj::do_find_special_sections): Don't use set_got2_shndx.
(Output_data_glink::add_entry,find_entry): Remove shndx param.
(class Glink_sym_ent): Rename from struct Glink_sym_ent. Remove
all references to shndx_. Handle special case for R_PPC_PLTREL24
here.
(class Glink_sym_ent_hash): Rename from struct Glink_sym_ent_hash.
(Output_data_glink::do_write): Retrieve got2_shdnx from object.
(Target_powerpc::make_plt_entry): Don't special case R_PPC_PLTREL24
here.
(Target_powerpc::Scan::global): Nor on make_plt_entry call.
(Target_powerpc::Relocate::relocate): Nor on glink->find_entry call.
* ld-mips-elf/export-class-call16-o32-irix.dd: New test.
* ld-mips-elf/export-class-call16-o32.gd: New test.
* ld-mips-elf/export-class-call16-n32.dd: New test.
* ld-mips-elf/export-class-call16-n32.gd: New test.
* ld-mips-elf/export-class-call16-n64.dd: New test.
* ld-mips-elf/export-class-call16-n64.gd: New test.
* ld-mips-elf/export-class-call16-def.s: New test source.
* ld-mips-elf/export-class-call16-o32.s: New test source.
* ld-mips-elf/export-class-call16-n32.s: New test source.
* ld-mips-elf/export-class-call16-n64.s: New test source.
* ld-mips-elf/export-class-call16.ld: New test linker script.
* ld-mips-elf/mips-elf.exp: Run the new tests.