Commit Graph

79809 Commits

Author SHA1 Message Date
Alan Modra 45965137be Support R_PPC64_ADDR64_LOCAL
This adds support for "func@localentry", an expression that returns the
ELFv2 local entry point address of function "func".  I've excluded
dynamic relocation support because that obviously would require glibc
changes.

include/elf/
	* ppc64.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
bfd/
	* elf64-ppc.c (ppc64_elf_howto_raw): Add R_PPC64_ADDR64_LOCAL entry.
	(ppc64_elf_reloc_type_lookup): Support R_PPC64_ADDR64_LOCAL.
	(ppc64_elf_check_relocs): Likewise.
	(ppc64_elf_relocate_section): Likewise.
	* Add BFD_RELOC_PPC64_ADDR64_LOCAL.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
gas/
	* config/tc-ppc.c (ppc_elf_suffix): Support @localentry.
	(md_apply_fix): Support R_PPC64_ADDR64_LOCAL.
ld/testsuite/
	* ld-powerpc/elfv2-2a.s, ld-powerpc/elfv2-2b.s: New files.
	* ld-powerpc/elfv2-2exe.d, ld-powerpc/elfv2-2so.d: New files.
	* ld-powerpc/powerpc.exp: Run new test.
elfcpp/
	* powerpc.h (R_PPC64_REL24_NOTOC, R_PPC64_ADDR64_LOCAL): Define.
gold/
	* powerpc.cc (Target_powerpc::Scan::local, global): Support
	R_PPC64_ADDR64_LOCAL.
	(Target_powerpc::Relocate::relocate): Likewise.
2014-03-05 19:57:39 +10:30
Alan Modra a0593ad956 Support more relocs on 16-bit insn fields
This patch allows gas to assemble a testcase like
	li 3,ext_sym
which oddly was not accepted while the following is OK:
	li 3,ext_sym@l

	* config/tc-ppc.c (md_assemble): Move code adjusting reloc types
	later.  Merge absolute and relative branch reloc selection.
	Generate 16-bit relocs for most 16-bit insn fields given a
	non-constant expression.
2014-03-05 19:31:45 +10:30
Alan Modra f50c47f118 Remove magic treatment of toc symbols for powerpc ELF
The XCOFF assembler does some wierd things with instructions like
`lwz 9,sym(30'.  See the comment in md_apply_fix.  From an ELF
perspective, it's weird even to magically select a TOC16 reloc
when a symbol is in the TOC/GOT.  ELF assemblers generally use
modifiers like @toc to select relocs, so remove this "feature"
for ELF.  I believe this was to support gcc -m32 -mcall-aixdesc
but that combination of gcc options has been broken for a long
time.

	* config/tc-ppc.c (ppc_is_toc_sym): Remove OBJ_ELF support.
	(md_assemble): Don't call ppc_is_toc_sym for ELF.
2014-03-05 19:27:57 +10:30
Mike Frysinger b2b255bdf3 sim: constify prog_name
There's no need for the prog_name handed down to the core to be mutable,
so add const markings to it and all the related funcs.
2014-03-05 01:42:44 -05:00
Alan Modra cfa7ea2a96 daily update 2014-03-05 09:31:07 +10:30
Richard Sandiford cd0c81e90f Fix changelog formatting in last commit -- sorry 2014-03-04 21:30:39 +00:00
Richard Sandiford 4ba154f579 bfd/
2014-02-04  Heiher <r@hev.cc>

	* elfxx-mips.c (mips_set_isa_flags): Use E_MIPS_ARCH_64R2 for
	Loongson-3A.
	(mips_mach_extensions): Make bfd_mach_mips_loongson_3a an
	extension of bfd_mach_mipsisa64r2.

opcodes/
2014-02-04  Heiher <r@hev.cc>

	* mips-dis.c (mips_arch_choices): Usee ISA_MIPS64R2 for Loongson-3A.

gas/
2014-02-04  Heiher <r@hev.cc>

	* config/tc-mips.c (mips_cpu_info_table): Use ISA_MIPS64R2 for
	Loongson-3A.
2014-03-04 21:18:02 +00:00
Richard Sandiford 079b5aec63 opcodes/
* mips-opc.c (mips_builtin_opcodes): Move the udi* instructions
	so that they come after the Loongson extensions.
2014-03-04 21:16:38 +00:00
Nick Clifton 0b55a33ebe Remove default-manifest from ALL_EMUL_EXTRA_BINARIES so that it is not mistakenly
built when constructing a toolchain configued from all targets.

	* Makefile.am (ALL_EMUL_EXTRA_BINARIES): Remove default-manifest.
	* Makefile.in: Regenerate.
2014-03-04 17:22:46 +00:00
Nick Clifton eed94f8f8e Install patch for PR ld/16017. This adds support for generating PLT entries
using Thumb2 instructions for those cores which do not support the ARM ISA.

	* elf32-arm.c (elf32_thumb2_plt0_entry): New array.
	(elf32_thumb2_plt_entry): New array.
	(elf32_arm_create_dynamic_sections): Set PLT entry sizes when
	using thumb2 based PLT.
	(elf32_arm_populate_plt_entry): Handle generating Thumb2 based PLT
	entries.
	(elf32_arm_final_link_relocate): Do not bias jumps to Thumb based
	PLT entries.
	(elf32_arm_finish_dynamic_sections): Handle creation of Thumb2
	based PLT 0-entry.
	(elf32_arm_output_plt_map_1): Handle creation of local symbols for
	Thumb2 based PLT 0-entry.
	(elf32_arm_output_arch_local_syms): Handle creation of local
	symbols for Thumb2 based PLT entries.
2014-03-04 15:25:53 +00:00
Mike Frysinger 1a8a700e3a sim: convert old style prototypes
Most of these prototypes have been killed off, but we have a few left
in the sim tree.  Clean them up so we can enable the -W flag for it.
2014-03-04 02:54:50 -05:00
Alan Modra f97a10f1dc daily update 2014-03-04 09:30:37 +10:30
Tom Tromey 5d9cf8a4d3 move probes to be per-bfd
This patch moves the probe data from the objfile to the per-BFD
object.  This lets the probes be shared between different inferiors
(and different objfiles when dlmopen is in use, should gdb ever handle
that).

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* elfread.c (probe_key): Change to bfd_data.
	(elf_get_probes, probe_key_free, _initialize_elfread): Probes are
	now per-BFD, not per-objfile.
	* stap-probe.c (stap_probe_destroy): Update comment.
	(handle_stap_probe): Allocate on the per-BFD obstack.
2014-03-03 12:47:25 -07:00
Tom Tromey 729662a522 change probes to be program-space-independent
This changes the probes to be independent of the program space.

After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.

This introduces a bound_probe object, similar to bound minimal
symbols.  Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.

This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.

This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address.  Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
	* breakpoint.c (create_longjmp_master_breakpoint): Use
	get_probe_address.
	(add_location_to_breakpoint, bkpt_probe_insert_location)
	(bkpt_probe_remove_location): Update.
	* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
	* elfread.c (elf_symfile_relocate_probe): Remove.
	(elf_probe_fns): Update.
	(insert_exception_resume_breakpoint): Change type of "probe"
	parameter to bound_probe.
	(check_exception_resume): Update.
	* objfiles.c (objfile_relocate1): Don't relocate probes.
	* probe.c (bound_probe_s): New typedef.
	(parse_probes): Use get_probe_address.  Set sal's objfile.
	(find_probe_by_pc): Return a bound_probe.
	(collect_probes): Return a VEC(bound_probe_s).
	(compare_probes): Update.
	(gen_ui_out_table_header_info): Change type of "probes"
	parameter.  Update.
	(info_probes_for_ops): Update.
	(get_probe_address): New function.
	(probe_safe_evaluate_at_pc): Update.
	* probe.h (struct probe_ops) <get_probe_address>: New field.
	<set_semaphore, clear_semaphore>: Add objfile parameter.
	(struct probe) <objfile>: Remove field.
	<arch>: New field.
	<address>: Update comment.
	(struct bound_probe): New.
	(find_probe_by_pc): Return a bound_probe.
	(get_probe_address): Declare.
	* solib-svr4.c (struct probe_and_action) <address>: New field.
	(hash_probe_and_action, equal_probe_and_action): Update.
	(register_solib_event_probe): Add address parameter.
	(solib_event_probe_at): Update.
	(svr4_create_probe_breakpoints): Add objfile parameter.  Use
	get_probe_address.
	* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
	(stap_get_probe_address): New function.
	(stap_can_evaluate_probe_arguments, compute_probe_arg)
	(compile_probe_arg): Update.
	(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
	address.
	(handle_stap_probe): Don't relocate the probe.
	(stap_relocate): Remove.
	(stap_gen_info_probes_table_values): Update.
	(stap_probe_ops): Remove stap_relocate.
	* symfile-debug.c (debug_sym_relocate_probe): Remove.
	(debug_sym_probe_fns): Update.
	* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
	* symtab.c (init_sal): Use memset.
	* symtab.h (struct symtab_and_line) <objfile>: New field.
	* tracepoint.c (start_tracing, stop_tracing): Update.
2014-03-03 12:47:20 -07:00
Tom Tromey ff8879201a comment fixes
This fixes up a few mildly erroneous comments in probe.h.

2014-03-03  Tom Tromey  <tromey@redhat.com>

	* probe.h (parse_probes, find_probe_by_pc)
	(find_probes_in_objfile): Fix comments.
2014-03-03 12:36:43 -07:00
Nick Clifton 65d7bab591 This patch enhances the MSP430 port of GAS so that, if requested, it will
generate warning messages about an instruction that changes the interrupt
state not being followed by a NOP instruction.

	* config/msp430/msp430.c: Replace known mcu array with known
	msp430 ISA mcu name array.
	Accept any name for -mmcu option.
	Add -mz option to warn about missing NOP following an interrupt
	status change.
	(check_for_nop): New.
	(msp430_operands): Emit a warning, if requested, when an interrupt
	changing instruction is not followed by a NOP.
	* doc/c-msp430.c: Document -mz option.

	* gas/msp430/bad.d: Add -mz option.
	* gas/msp430/bad.s: Add more cases where warnings should be
	generated.
	* gas/msp430/bad.l: Add expected warning messages.
2014-03-03 17:27:55 +00:00
Alan Modra c1a3e85c37 More copyright fixes
* config/obj-fdpicelf.c: Correct copyright date.
	* config/obj-fdpicelf.h: Likewise.
2014-03-03 14:06:56 +10:30
Alan Modra 2c80b75360 Fix various copyright issues
binutils/
	* README: Add "Copyright Notices" paragraph.
gas/
	* config/bfin-lex-wrapper.c: Correct copyright date.
	* config/tc-frv.c: Correct copyright punctuation.
	* config/tc-ip2k.c: Likewise.
	* config/tc-iq2000.c: Likewise.
	* config/tc-mep.c: Likewise.
	* config/tc-tic4x.c: Likewise.
	* config/tc-tic4x.h: Likewise.
ld/testsuite/
	* ld-scripts/phdrs2.exp: Correct copyright punctuation.
	* ld-v850/v850.exp: Correct copyright typo.
opcodes/
	* i386-gen.c (process_copyright): Emit copyright notice on one line.
gold/
	* dwp.cc (print_version): Update copyright year to current.
2014-03-03 11:03:08 +10:30
Alan Modra 74cc2cc592 daily update 2014-03-03 09:30:42 +10:30
Doug Evans f0407826d9 * infrun.c (handle_signal_stop): Replace test for
TARGET_WAITKIND_STOPPED with an assert.
2014-03-02 16:51:35 -05:00
Doug Evans 35e6a7111e guile/scm-objfile.c (ofscm_mark_objfile_smob): Fix typo in comment. 2014-03-02 10:30:46 -08:00
Doug Evans 667f9d0bdd guile/lib/gdb/printing.scm (append-pretty-printer!): Fix thinko. 2014-03-02 09:17:46 -08:00
Alan Modra 8913591154 daily update 2014-03-02 09:30:37 +10:30
Mark Kettenis dc92ace053 Silence ARI warning.
gdb/ChangeLog:

        * obsd-nat.c: Include "gdb_wait.h" instead of <sys/wait.h>.
2014-03-01 17:13:47 +01:00
Mark Kettenis a900370fa1 Enable rhreads support on OpenBSD/i386.
gdb/ChangeLog:

        * i386obsd-nat.c: Include "obsd-nat.h".
        (_initialize_i386obsd_nat): Call obsd_add_target instead of
        add_target.
        * config/i386/obsd.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01 15:29:34 +01:00
Mark Kettenis b72a79813d Eliminate pointer signedness warning.
gdb/ChangeLog:

        * i386obsd-nat.c (i386obsd_supply_pcb): Cast 'sf' to 'gdb_byte *'.
2014-03-01 13:10:32 +01:00
Yuri Gribov 512c56d662 ld-arm/long-plt-format.d, ld-arm/arm-elf.exp: Adjust for arm-eabi. 2014-03-01 12:19:53 +01:00
Mark Kettenis 8fd408f130 Fix ChangeLog. 2014-03-01 12:03:30 +01:00
Mark Kettenis 96c70abaef Enable rthreads support on OpenBSD/mips64.
gdb/ChangeLog:

        * mips64obsd-nat.c: Include "obsd-nath".
        (_initialize_mips64obsd_nat): Call obsd_add_target instead of
        add_target
        * config/mips/obsd64.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01 12:00:19 +01:00
Mark Kettenis 874a80af9f Enable rthreads support on OpenBSD/amd64.
gdb/ChangeLog:

        * amd64obsd-nat.c (_initialize_amd64obsd_nat): Call
        obsd_add_target instead of add_target.
        * config/i386/obsd64.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01 11:49:58 +01:00
Denis Chertykov 83046454b5 * config/tc-avr.c: Remove atxmega16x1. 2014-03-01 13:12:49 +04:00
Siva Chandra 9cf953733a Remove the unnecesary argument METHOD to valops.c:find_oload_champ.
* valops.c (find_oload_champ): Remove unneccesary argument METHOD.
	(find_overload_match): Update call to find_oload_champ.
	(find_oload_champ_namespace_loop): Likewise
2014-02-28 15:03:22 -08:00
Alan Modra 7b3858e08a daily update 2014-03-01 09:31:08 +10:30
Mark Kettenis 025cac40e2 Add sparc64obsd-nat.c to ALLDEPFILES.
gdb/ChangeLog:

        * Makefile.in (ALLDEPFILES): Add sparc64obsd-nat.c.
2014-02-28 23:23:40 +01:00
Mark Kettenis 1ed586ce1d Enable rthreads supports on OpenBSD/sparc64.
gdb/ChangeLog:

        * configure.host (sparc64-*-openbsd*): Set gdb_host to obsd64.
        * config/sparc/obsd64.mh: New file.
        * sparc64obsd-nat.c: New file.
2014-02-28 23:07:55 +01:00
Mark Kettenis ab4756af55 Stupid git never fucking does what I want! 2014-02-28 22:58:57 +01:00
Mark Kettenis 863e4da4b6 Support rthreads on OpenBSD 5.2 and later.
OpenBSD 5.2 and later have a proper threads implementation based on
kernel threads.  Debugging support is provided through additional
ptrace(2) requests, so this diff extends the generic code in
inf-ptrace.c with OpenBSD-specific code to discover additional threads.

gdb/ChangeLog:

        * obsd-nat.h: New file.
        * obsd-nat.c: New file.
        * Makefile.in (HFILES_NO_SRCDIR): Add obsd-nat.h.
        (ALLDEPFILES): Add obsd-nat.c.
2014-02-28 22:45:51 +01:00
Tom Tromey 89de4da46b constify ui_out_impl
This patch constifies ui_out_impl in struct ui_out, and various
instances of ui_out_impl.

This removes a couple of FIXME comments (near cli_ui_out_impl and
mi_ui_out_impl) that did not make sense to me.

Tested by rebuilding.

2014-02-28  Tom Tromey  <tromey@redhat.com>

	* cli-out.c (cli_ui_out_impl): Now const.  Remove comment.
	* cli-out.h (cli_ui_out_impl): Now const.
	* mi/mi-out.c (mi_ui_out_impl): Now const.  Remove comment.
	* ui-out.c (struct ui_out) <impl>: Now const.
	(default_ui_out_impl): Now const.
	(ui_out_new): Make 'impl' parameter const.
	* ui-out.h (ui_out_new): Update.
2014-02-28 08:51:15 -07:00
Alan Modra 02fe846e43 Incorrect .debug_line prologue header length for 64-bit DWARF
Don't be clever, calculate the length directly as the difference of
two symbols.

	* dwarf2dbg.c (out_debug_line): Correct .debug_line header_length
	field for 64-bit dwarf.
2014-02-28 15:09:32 +10:30
Alan Modra 9850436d9e Fix check_relocs/gc_sweep_hook mismatch
PR ld/16643
	* elflink.c (elf_gc_sweep): Call gc_sweep_hook for exactly
	the same conditions we called check_relocs.
2014-02-28 14:38:27 +10:30
Alan Modra b721f1faaf Regenerate opcodes/msp430-decode.c
Cosmetic changes.

	* msp430-decode.c: Regenerate.
2014-02-28 14:35:54 +10:30
Alan Modra 67496a9c13 daily update 2014-02-28 09:31:17 +10:30
Mark Kettenis c725e7b687 Prevent compiler warning.
GCC 4.2.1 complains about first_l_name may be used uninitialized, and my brain
agrees.

gdb/ChangeLog:

        * solib-svr4.c (svr4_read_so_list): Initialize first_l_name to 0.
2014-02-27 21:51:08 +01:00
Mark Kettenis 670b46b3a9 StackGhost cookie is per-process.
gdb/ChangeLog:

        * sparc-nat.c (sparc_xfer_wcookie): Always use process ID.
2014-02-27 21:22:29 +01:00
Jan Kratochvil c91550fc5d Additional PR 8882 fix.
runtest gdb.base/corefile.exp

==23174== ERROR: AddressSanitizer: heap-use-after-free on address 0x604400008c88 at pc 0x68f0be bp 0x7fffae9d7490 sp
0x7fffae9d7480
READ of size 8 at 0x604400008c88 thread T0
    #0 0x68f0bd in svr4_read_so_list (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68f0bd)
    #1 0x68f64e in svr4_current_sos_direct (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68f64e)
    #2 0x68f757 in svr4_current_sos (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68f757)
    #3 0xcebbff in update_solib_list (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xcebbff)
0x604400008c88 is located 8 bytes inside of 1104-byte region [0x604400008c80,0x6044000090d0)
freed by thread T0 here:
    #0 0x7f52677500f9 (/lib64/libasan.so.0+0x160f9)
    #1 0xd2c68a in xfree (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xd2c68a)
    #2 0xceb364 in free_so (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xceb364)
    #3 0xca59f8 in do_free_so (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xca59f8)
    #4 0x93432a in do_my_cleanups (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x93432a)
    #5 0x934406 in do_cleanups (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x934406)
    #6 0x68efa9 in svr4_read_so_list (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68efa9)

I did not notice it during my review in:
	Re: [PATCH v2] Skip vDSO when reading SO list (PR 8882)
	https://sourceware.org/ml/gdb-patches/2013-09/msg00888.html

gdb/
2014-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Additional PR 8882 fix.
	* solib-svr4.c (svr4_read_so_list): Change first to first_l_name.

Message-ID: <20140226220918.GA10431@host2.jankratochvil.net>
2014-02-27 21:16:04 +01:00
Yufeng Zhang f17c8bfcc8 opcodes/
* aarch64-tbl.h (aarch64_opcode_table): Replace IMM0 with
	FPIMM0 for fcmeq, fcmgt, fcmge, fcmlt and fcmle.

gas/testsuite/

	* gas/aarch64/fp-const0-parsing.s: New test.
	* gas/aarch64/fp-const0-parsing.d: Likewise.
2014-02-27 15:06:56 +00:00
Yufeng Zhang a58549dda5 opcodes/
* aarch64-opc.c (print_register_offset_address): Call
	get_int_reg_name to prepare the register name.

gas/testsuite/

	* gas/aarch64/ldst-reg-reg-offset.s: Add tests.
	* gas/aarch64/ldst-reg-reg-offset.d: Update.
2014-02-27 14:55:46 +00:00
Pedro Alves 2fa0369e51 Linux waitpid/__WALL emulation wrapper: If WNOHANG is set, don't touch sigprocmask.
Just a small optimization.  No need to block/unblock signals if we're
not going to call sigsuspend.

gdb/
2014-02-27  Pedro Alves  <palves@redhat.com>

	* nat/linux-waitpid.c (my_waitpid): Only block signals if WNOHANG
	isn't set.
2014-02-27 14:44:16 +00:00
Yuri Gribov 1db37fe627 This patch adds support for ARM PLT entries that support a full 32-bit offset range.
Enabled via the use of a new linker command line option: --long-plt.

	* bfd-in.h: Add export of bfd_elf32_arm_use_long_plt.
	* bfd-in2.h: Regenerate.
	* elf32-arm.c (elf32_arm_plt_entry_long): New array.
	(elf32_arm_link_hash_table_create): Set plt_entry_size to 16 if
	using long PLT entries.
	(bfd_elf32_arm_use_long_plt): New function.
	(elf32_arm_populate_plt_entry): Add support for long PLT entries.

	* emultempl/armelf.em (OPTION_LONG_PLT): Define.
	(PARSE_AND_LIST_LONGOPTS): Add long-plt.
	(PARSE_AND_LIST_OPTIONS): Likewise.
	(PARSE_AND_LIST_ARGS_CASES): Handle long-plt.
	* ld.texinfo: Document --long-plt.

	* ld-arm/long-plt-format.s: New test case.
	* ld-arm/long-plt-format.d: Expected disassembly.
	* ld-arm/arm-elf.exp: Run the new test.
2014-02-27 14:35:37 +00:00
Pedro Alves fa96cb382c Teach GDBserver's Linux backend about no unwaited-for children (TARGET_WAITKIND_NO_RESUMED).
GDBserver currently hangs forever in waitpid if the leader thread
exits before other threads, or if all resumed threads exit - e.g.,
next over a thread exit with sched-locking on.  This is exposed by
leader-exit.exp.  leader-exit.exp is part of a series of tests for a
set of related problems.  See
<http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>:

 "
 To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the
 leader thread until all other threads in the group are reaped.  When
 the leader exits, it goes zombie, but waitpid will not return an exit
 status until the other threads are gone.  This is presently exercised
 by the gdb.threads/leader-exit.exp test.  The fix for that test, in
 linux-nat.c:wait_lwp, handles the case where we see the leader gone
 when we're stopping all threads to report an event to some other
 thread to the core.

 (...)

 The latter bit about not blocking if there no resumed threads in the
 process also applies to some other thread exiting, not just the main
 thread.  E.g., this test starts a thread, and runs to a breakpoint in
 that thread:

 ...
 (gdb) c
 Continuing.
 [New Thread 0x7ffff75a4700 (LWP 23397)]
 [Switching to Thread 0x7ffff75a4700 (LWP 23397)]

 Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28
 28        return 0; /* break-here */
 (gdb) info threads
 * 2 Thread 0x7ffff75a4700 (LWP 23397)  thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28
   1 Thread 0x7ffff7fcb720 (LWP 23391)  0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89

 The thread will exit as soon as we resume it.  But if we only resume
 that thread, leaving the rest of the threads stopped:

 (gdb) set scheduler-locking on
 (gdb) c
 Continuing.
 ^C^C^C^C^C^C^C^C
 "

This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED
on GDBserver, similarly to what the patch above did for native
Linux GDB.

gdb.threads/leader-exit.exp now passes.

gdb.threads/no-unwaited-for-left.exp now at least errors out instead
of hanging:

 continue
 Continuing.
 warning: Remote failure reply: E.No unwaited-for children left.

 [Thread 15454] #1 stopped.
 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93
 93          lll_wait_tid (pd->tid);
 (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits

The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver
unfortunately doesn't support fork/exec yet, but I'm confident this
fixes the related issues.

I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a
separate pass.

(BTW, in case of error in response to a vCont, it would be better for
GDB to query the target for the current thread, or re-select one,
instead of assuming current inferior_ptid is still the selected
thread.)

This implementation is a little different from GDB's, because I'm
avoiding bringing in more of this broken use of waitpid(PID) into
GDBserver.  Specifically, this avoids waitpid(PID) when stopping all
threads.  There's really no need for wait_for_sigstop to wait for each
LWP in turn.  Instead, with some refactoring, we make it reuse
linux_wait_for_event.

gdb/gdbserver/
2014-02-27  Pedro Alves  <palves@redhat.com>

	PR 12702
	* inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New
	macros.
	* linux-low.c (delete_lwp, handle_extended_wait): Add debug
	output.
	(last_thread_of_process_p): Take a PID argument instead of a
	thread pointer.
	(linux_wait_for_lwp): Delete.
	(num_lwps, check_zombie_leaders, not_stopped_callback): New
	functions.
	(linux_low_filter_event): New function, party factored out from
	linux_wait_for_event.
	(linux_wait_for_event): Rename to ...
	(linux_wait_for_event_filtered): ... this.  Add new filter ptid
	argument.  Partly rewrite.  Always use waitpid(-1, WNOHANG) and
	sigsuspend.  Check for zombie leaders.
	(linux_wait_for_event): Reimplement as wrapper around
	linux_wait_for_event_filtered.
	(linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED.  Assume that if
	a normal or signal exit is seen, it's the whole process exiting.
	(wait_for_sigstop): No longer a for_each_inferior callback.
	Rewrite on top of linux_wait_for_event_filtered.
	(stop_all_lwps): Call wait_for_sigstop directly.
	* server.c (resume, handle_target_event): Handle
	TARGET_WAITKIND_NO_RESUMED.
2014-02-27 14:30:08 +00:00