deliverable/binutils-gdb.git
6 years agoPR22306, Invalid free() in slurp_symtab()
Alan Modra [Tue, 17 Oct 2017 06:13:47 +0000 (16:43 +1030)] 
PR22306, Invalid free() in slurp_symtab()

PR 22306
* aoutx.h (aout_get_external_symbols): Handle stringsize of zero,
and error for any other size that doesn't cover the header word.

6 years agoCorrect -z text and other -z documentation
Alan Modra [Tue, 17 Oct 2017 06:17:05 +0000 (16:47 +1030)] 
Correct -z text and other -z documentation

-z text applies to all dynamic binaries, not just shared libraries.
A lot of the other options needed attention too.

* ld.texinfo (-z): Combine negative options with corresponding
positive option.  Sort the table.  Expand and correct "combreloc",
"common", "common-page-size", "interpose", "loadfltr",
"max-page-size", "muldefs", "nodefaultlib", "nodelete", "nodlopen",
"nodump", "noextern-protected-data", "now", "origin", and "text".

6 years agoAdd missing ChangeLog entries.
Keith Seitz [Tue, 17 Oct 2017 05:19:55 +0000 (22:19 -0700)] 
Add missing ChangeLog entries.

6 years agoFix segfault processing nios2 pseudo-instructions with too few arguments.
Sandra Loosemore [Tue, 17 Oct 2017 03:45:55 +0000 (20:45 -0700)] 
Fix segfault processing nios2 pseudo-instructions with too few arguments.

2017-10-16  Sandra Loosemore  <sandra@codesourcery.com>
    Henry Wong  <henry@stuffedcow.net>

gas/
* config/tc-nios2.c (nios2_translate_pseudo_insn): Check for
correct number of arguments.
(md_assemble): Handle failure of nios2_translate_pseudo_insn.
* testsuite/gas/nios2/illegal_pseudoinst.l: New file.
* testsuite/gas/nios2/illegal_pseudoinst.s: New file.
* testsuite/gas/nios2/nios2.exp: Add illegal_pseudoinst test.

6 years agoRecord and output access specifiers for nested typedefs
Keith Seitz [Tue, 17 Oct 2017 00:19:29 +0000 (17:19 -0700)] 
Record and output access specifiers for nested typedefs

We currently do not record access information for typedefs defined inside
classes.  Consider:

struct foo
{
   typedef int PUBLIC;
 private:
   typedef int PRIVATE;
   PRIVATE b;
};

(gdb) ptype foo
type = struct foo {
  private:
    PRIVATE b;

    typedef int PRIVATE;
    typedef int PUBLIC;
}

This patch fixes this:

(gdb) ptype foo
type = struct foo {
  private:
    PRIVATE b;

    typedef int PRIVATE;
  public:
    typedef int PUBLIC;
}

gdb/ChangeLog:

* c-typeprint.c (enum access_specifier): Moved here from
c_type_print_base.
(output_access_specifier): New function.
(c_type_print_base): Consider typedefs when assessing
whether access labels are needed.
Use output_access_specifier as needed.
Output access specifier for typedefs, if needed.
* dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility.
* gdbtypes.h (struct typedef_field) <is_protected, is_private>: New
fields.
(TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New
accessor macros.

gdb/testsuite/ChangeLog:

* gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef)
(class_with_protected_typedef, class_with_private_typedef)
(struct_with_public_typedef, struct_with_protected_typedef)
(struct_with_private_typedef): New classes/structs.
* gdb.cp/classes.exp (test_ptype_class_objects): Add tests for
typedefs and access specifiers.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 17 Oct 2017 00:00:26 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoReturn unique_xmalloc_ptr from target_fileio_read_stralloc
Tom Tromey [Fri, 13 Oct 2017 00:20:09 +0000 (18:20 -0600)] 
Return unique_xmalloc_ptr from target_fileio_read_stralloc

Change target_fileio_read_stralloc to return unique_xmalloc_ptr and
fix up the callers.  This removes a number of cleanups.

ChangeLog
2017-10-16  Tom Tromey  <tom@tromey.com>

* linux-tdep.c (linux_info_proc, linux_find_memory_regions_full)
(linux_fill_prpsinfo, linux_vsyscall_range_raw): Update.
* target.c (target_fileio_read_stralloc): Update.
* sparc64-tdep.c (adi_is_addr_mapped): Update.
* target.h (target_fileio_read_stralloc): Return
unique_xmalloc_ptr.

6 years agoReturn unique_xmalloc_ptr from target_read_stralloc
Tom Tromey [Thu, 12 Oct 2017 22:48:35 +0000 (16:48 -0600)] 
Return unique_xmalloc_ptr from target_read_stralloc

This changes target_read_stralloc to return a unique_xmalloc_ptr, and
then fixes all the callers.  unique_xmalloc_ptr is used, rather than
std::string, because target_read_stralloc gives a special meaning to a
NULL return.

ChangeLog
2017-10-16  Tom Tromey  <tom@tromey.com>

* xml-syscall.c (xml_init_syscalls_info): Update.
* xml-support.c (xinclude_start_include): Update.
(xml_fetch_content_from_file): Return unique_xmalloc_ptr.
* xml-support.h (xml_fetch_another): Return unique_xmalloc_ptr.
(xml_fetch_content_from_file): Likewise.
* osdata.c (get_osdata): Update.
* target.h (target_read_stralloc, target_get_osdata): Return
unique_xmalloc_ptr.
* solib-aix.c (solib_aix_get_library_list): Update.
* solib-target.c (solib_target_current_sos): Update.
* solib-svr4.c (svr4_current_sos_via_xfer_libraries): Update.
* xml-tdesc.c (fetch_available_features_from_target): Update.
(target_fetch_description_xml): Update.
(file_read_description_xml): Update.
* remote.c (remote_get_threads_with_qxfer, remote_memory_map)
(remote_traceframe_info, btrace_read_config, remote_read_btrace)
(remote_pid_to_exec_file): Update.
* target.c (target_read_stralloc): Return unique_xmalloc_ptr.
(target_get_osdata): Likewise.

6 years agoSimple cleanup removals in remote.c
Tom Tromey [Thu, 12 Oct 2017 22:40:01 +0000 (16:40 -0600)] 
Simple cleanup removals in remote.c

This removes a few cleanups in remote.c using the usual techniques:
std::vector, unique_xmalloc_ptr, and gdb::def_vector.

ChangeLog
2017-10-16  Tom Tromey  <tom@tromey.com>

* remote.c (remote_register_number_and_offset): Use std::vector.
(remote_set_syscall_catchpoint): Use gdb::unique_xmalloc_ptr.
(putpkt_binary): Use gdb::def_vector.
(compare_sections_command): Use gdb::byte_vector.

6 years agoRemove cleanup from ppc-linux-nat.c
Tom Tromey [Thu, 12 Oct 2017 22:24:13 +0000 (16:24 -0600)] 
Remove cleanup from ppc-linux-nat.c

This removes a cleanup from ppc-linux-nat.c, by using
unique_xmalloc_ptr.  It also slightly simplifies the code by using
XDUP rather than XNEW and memcpy.

ChangeLog
2017-10-16  Tom Tromey  <tom@tromey.com>

* ppc-linux-nat.c (hwdebug_insert_point): Use
gdb::unique_xmalloc_ptr, XDUP.

6 years agoRemove some cleanups from probe.c
Tom Tromey [Thu, 12 Oct 2017 22:19:55 +0000 (16:19 -0600)] 
Remove some cleanups from probe.c

This removes some cleanups from parse_probes by using std::string; and
removes some unnecessary cleanups from elsewhere in probe.c.

ChangeLog
2017-10-16  Tom Tromey  <tom@tromey.com>

* probe.c (parse_probes): Use std::string.
(info_probes_for_ops, enable_probes_command)
(disable_probes_command): Remove cleanups.

6 years agoUse std::vector in end_symtab_get_static_block
Tom Tromey [Thu, 12 Oct 2017 21:46:42 +0000 (15:46 -0600)] 
Use std::vector in end_symtab_get_static_block

Change end_symtab_get_static_block to use std::vector.  This removes a
cleanup.

ChangeLog
2017-10-16  Tom Tromey  <tom@tromey.com>

* buildsym.c (block_compar): Remove.
(end_symtab_get_static_block): Use std::vector.

6 years agoMake native gdbserver boards no longer be "remote" (in DejaGnu terms)
Pedro Alves [Mon, 16 Oct 2017 19:24:21 +0000 (20:24 +0100)] 
Make native gdbserver boards no longer be "remote" (in DejaGnu terms)

This commit finally clears the "isremote" flag in the native-gdbserver
and native-stdio-gdbserver boards.  The goal is to make all "native"
boards be considered not remote in DejaGnu terms, like the
native-extended-gdbserver board is too.

DejaGnu automatically considers boards remote if their names don't
match the local hostname.  That means that native-gdbserver and
native-extended-gdbserver are considered remote by default by DejaGnu,
even though they run locally.  native-extended-gdbserver, however,
overrides its isremote flag to force it to be not remote.  So we are
in that weird state where native-gdbserver is considered remote, and
native-extended-gdbserver is considered not remote.

A recent set of commits fixed all the problems (and some more) exposed
by testing with --target_board=native-gdbserver and
--target_board=native-stdio-gdbserver with isremote forced off on
x86-64 GNU/Linux.  I believe we're good to go now.

The native-stdio-gdbserver.exp/remote-stdio-gdbserver.exp boards
required deep non-obvious modifications unfortunately...  The problem
is that if a board is not remote, then DejaGnu doesn't call
${board}_spawn / ${board}_exec at all, and the
native-stdio-gdbserver.exp board relies on those procedures being
called.  To fix that, this commit redesigns how the stdio boards hook
into the testing framework to spawn gdbserver.  IMO, this is a good
change anyway, because the way its done currently is a bit of a hack,
and the result turns out to be simpler, even.  With this commit, they
now no longer load the "gdbserver" generic config, and hook at the
mi_gdb_target_load/gdb_reload level instead, making them more like
traditional board files.

To share code between native-stdio-gdbserver.exp and
remote-stdio-gdbserver.exp, a new shared stdio-gdbserver-base.exp file
is created.

Instead of having each native board clear isremote manually, boards
source the new "local-board.exp" file.

This also adds a new section to testsuite/README file discussing
local/remote/native, so that we can easily refer to it.

gdb/testsuite/ChangeLog:
2017-10-16  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@polymtl.ca>

* README (Local vs Remote vs Native): New section.
* boards/local-board.exp: New file, with bits factored out from
...
* boards/native-extended-gdbserver.exp: ... here.  Load
"local-board".
* boards/native-gdbserver.exp: Load "local-board".
(${board}_spawn, ${board}_exec): Delete.
* boards/native-stdio-gdbserver.exp: Most contents factored out to
...
* boards/stdio-gdbserver-base.exp: ... this new file.
* boards/native-stdio-gdbserver.exp: Reimplement, by loading
"stdio-gdbserver-base" and defining a get_target_remote_pipe_cmd
procedure.
* boards/remote-stdio-gdbserver.exp: Load stdio-gdbserver-base
instead of native-stdio-gdbserver.  Don't set gdb_server_prog nor
stdio_gdbserver_command.
(${board}_get_remote_address, ${board}_get_comm_port)
(${board}_download, ${board}_upload): Delete.
(get_target_remote_pipe_cmd): New.

6 years agoUse proc_with_prefix in py-breakpoint.exp
Simon Marchi [Mon, 16 Oct 2017 19:06:14 +0000 (15:06 -0400)] 
Use proc_with_prefix in py-breakpoint.exp

Use proc_with_prefix to avoid having to call with_test_prefix with a
duplicate of the proc name.  The diff is mostly lines being re-indented.

gdb/testsuite/ChangeLog:

* gdb.python/py-breakpoint.exp (test_bkpt_basic,
test_bkpt_deletion, test_bkpt_cond_and_cmds,
test_bkpt_invisible, test_watchpoints, test_bkpt_internal,
test_bkpt_eval_funcs, test_bkpt_temporary, test_bkpt_address,
test_bkpt_pending, test_bkpt_events): Use proc_with_prefix,
remove with_test_prefix.

6 years agoGet rid of VEC(mem_range_s)
Simon Marchi [Mon, 16 Oct 2017 14:14:53 +0000 (10:14 -0400)] 
Get rid of VEC(mem_range_s)

This patch replaces the last usages of VEC(mem_range_s) with
std::vector<mem_range>.  This allows getting rid of a few cleanups and
of the DEF_VEC_O(mem_range_s).

I added a test for normalize_mem_ranges to make sure I didn't break
anything there.

Regtested on the buildbot.

gdb/ChangeLog:

* memrange.h (struct mem_range): Define operator< and operator==.
(mem_range_s): Remove.
(DEF_VEC_O (mem_range_s)): Remove.
(normalize_mem_ranges): Change parameter type to std::vector.
* memrange.c (compare_mem_ranges): Remove.
(normalize_mem_ranges): Change parameter type to std::vector,
adjust to vector change.
* exec.c (section_table_available_memory): Return vector, remove
parameter.
(section_table_read_available_memory): Adjust to std::vector
change.
* remote.c (remote_read_bytes): Adjust to std::vector
change.
* tracepoint.h (traceframe_available_memory): Change parameter
type to std::vector.
* tracepoint.c (traceframe_available_memory): Change parameter
type to std::vector, adjust.
* gdb/mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to
std::vector change.
* gdb/Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/memrange-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add memrange-selftests.o.
* gdb/unittests/memrange-selftests.c: New file.

6 years agoWork around GCC 6.3.1 bug
Pedro Alves [Mon, 16 Oct 2017 12:39:12 +0000 (13:39 +0100)] 
Work around GCC 6.3.1 bug

This commit works around a GCC 6.3.1 bug several people are hitting:

  https://sourceware.org/ml/gdb-patches/2017-09/msg00270.html
  https://sourceware.org/ml/gdb-patches/2017-10/msg00418.html

It manifests like this:

  ../../../binutils-gdb/gdb/probe.c:68:12: error: types may not be defined in a for-range-declaration [-Werror]
 for (struct probe *probe : probes)
      ^~~~~~

Fix it by renaming the range-for named variables to something different
from their type's name.

gdb/ChangeLog:
2017-10-16  Pedro Alves  <palves@redhat.com>

* elfread.c (probe_key_free): Rename range-for variable.
* probe.c (parse_probes_in_pspace, find_probes_in_objfile)
(find_probe_by_pc, collect_probes): Rename range-for variable.

6 years agoELF: Call check_relocs after opening all inputs
H.J. Lu [Mon, 16 Oct 2017 10:49:54 +0000 (03:49 -0700)] 
ELF: Call check_relocs after opening all inputs

For all ELF targers, call check_relocs after opening all inputs and
garbage collection.  Since the symbol resolution is known, check_relocs
can be simplified.  Also garbage collection doesn't need to undo what
check_relocs has done for symbols which have been garbage collected.
Since ELF targets never see the removed sections, gc_sweep_hook can be
removed from elf_backend_data and we can avoid GOT/PLT with garbage
collection now.

Set link_info.check_relocs_after_open_input to TRUE for all linker
targets which use ELF linker and update garbage collection tests to
remove unused GOT section.

ldemul_after_check_relocs is added for powerpc to support --secure-plt,
--bss-plt and --sdata-got.

Tested natively without regressions on i686, x86-64 and x32.  Tested
cross binutils on x86-64 without regressions for aarch64-linux,
alpha-linux, arm-linux, bfin-elf, cr16-elf, cris-elf, crx-elf, frv-linux,
hppa64-linux, hppa-linux, ia64-linux, lm32-elf, m32r-elf, m68k-linux,
mcore-elf, metag-elf, microblaze-linux, mips-linux, mmix, mn10300-elf,
nds32le-linux, nios2-linux, or1k-elf, powerpc64-linux, powerpc-linux,
riscv32-linux, riscv64-linux, s390-linux, s390x-linux, score-elf,
sh3-linux, sparc64-linux, sparc-linux, tic6x-elf, tilegx-linux,
tilepro-linux, vax-linux, x86_64-mingw32 and xtensa-linux.

bfd/

* elf-bfd.h (elf_backend_data): Remove gc_sweep_hook.
* elf32-arm.c (elf32_arm_gc_sweep_hook): Removed.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-bfin.c (bfin_gc_sweep_hook): Likewise.
(bfinfdpic_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-cr16.c (elf32_cr16_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-cris.c (cris_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-hppa.c (elf32_hppa_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-lm32.c (lm32_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-m32r.c (m32r_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-m68k.c (elf_m68k_got_entry): Remove elf_m68k_gc_sweep_hook
from comments.
(elf_m68k_remove_got_entry_type): Removed.
(elf_m68k_find_got_entry_ptr): Likewise.
(elf_m68k_remove_got_entry): Likewise.
(elf_m68k_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-mcore.c (mcore_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-metag.c (elf_metag_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-microblaze.c (elf_backend_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-mips.c (elf_backend_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-nds32.c (nds32_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-nios2.c (nios2_elf32_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-or1k.c (or1k_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-ppc.c (ppc_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-s390.c (elf_s390_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-sparc.c (elf_backend_gc_sweep_hook): Likewise.
* elf32-tic6x.c (elf32_tic6x_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-tilegx.c (elf_backend_gc_sweep_hook): Likewise.
* elf32-tilepro.c (tilepro_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-vax.c (elf_vax_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-alpha.c (elf64_alpha_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-mips.c (elf_backend_gc_sweep_hook): Likewise.
* elf64-mmix.c (mmix_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-ppc.c (elf_backend_gc_sweep_hook): Likewise.
(ppc64_elf_gc_sweep_hook): Likewise.
* elf64-s390.c (elf_s390_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elf64-sparc.c (elf_backend_gc_sweep_hook): Likewise.
* elf64-tilegx.c (elf_backend_gc_sweep_hook): Likewise.
* elflink.c (elf_link_add_object_symbols): Don't call
_bfd_elf_link_check_relocs here.
(gc_sweep_hook_fn): Removed.
(elf_gc_sweep): Remove gc_sweep_hook.
* elfnn-aarch64.c (elfNN_aarch64_gc_sweep_hook): Removed.
(elf_backend_gc_sweep_hook): Likewise.
* elfnn-riscv.c (riscv_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elfxx-mips.c (_bfd_mips_elf_gc_sweep_hook): Likewise.
* elfxx-mips.h (_bfd_mips_elf_gc_sweep_hook): Likewise.
(elf_backend_gc_sweep_hook): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_sweep_hook): Likewise.
* elfxx-sparc.h (_bfd_sparc_elf_gc_sweep_hook): Likewise.
* elfxx-target.h (elf_backend_gc_sweep_hook): Likewise.
(elfNN_bed): Remove elf_backend_gc_sweep_hook.
* elfxx-tilegx.c (tilegx_elf_gc_sweep_hook): Removed.
* elfxx-tilegx.h (tilegx_elf_gc_sweep_hook): Likewise.

ld/

* emulparams/elf32_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Removed.
* emulparams/elf_i386_be.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_chaos.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_ldso.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_i386_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_iamcu.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_k1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_l1om.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/elf_x86_64.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386lynx.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386moss.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/i386nw.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf32.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shelf_vxworks.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shlelf32_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shlelf_linux.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emulparams/shlelf_nto.sh (CHECK_RELOCS_AFTER_OPEN_INPUT):
Likewise.
* emultempl/aarch64elf.em (gld${EMULATION_NAME}_before_parse):
Set link_info.check_relocs_after_open_input to TRUE.
* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse):
Likewise.
* emultempl/scoreelf.em (gld${EMULATION_NAME}_before_parse):
Likewise.
* emultempl/aix.em (ld_${EMULATION_NAME}_emulation): Add
after_parse_default.
* emultempl/armcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/beos.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/generic.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/gld960.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/gld960c.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/lnk960.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/m68kcoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/msp430.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pe.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/pep.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/sunos.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/ticoff.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/vanilla.em (ld_${EMULATION_NAME}_emulation): Likewise.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Always
set link_info.check_relocs_after_open_input to TRUE.
(ld_${EMULATION_NAME}_emulation): Add $LDEMUL_AFTER_CHECK_RELOCS.
* emultempl/linux.em (gld${EMULATION_NAME}_before_parse):
Set link_info.check_relocs_after_open_input to TRUE.
(ld_${EMULATION_NAME}_emulation): Add after_check_relocs_default.
* emultempl/mmix-elfnmmo.em (mmix_before_parse): New function.
(LDEMUL_BEFORE_PARSE): New.
* emultempl/mmixelf.em (elfmmix_before_parse): Replace
gld${EMULATION_NAME}_before_parse with mmix_before_parse.
* emultempl/ppc32elf.em (ppc_after_open): Renamed to ...
(ppc_after_check_relocs): This.  Call after_check_relocs_default
instead of gld${EMULATION_NAME}_after_open.
(LDEMUL_AFTER_OPEN): Removed.
(LDEMUL_AFTER_CHECK_RELOCS): New.
* ldemul.c (ldemul_after_check_relocs): New.
(after_check_relocs_default): Likewise.
* ldemul.h (ldemul_after_check_relocs): Likewise.
(after_check_relocs_default): Likewise.
(ld_emulation_xfer_struct): Add after_check_relocs.
* ldlang.c (lang_process): Call ldemul_after_check_relocs after
lang_check_relocs.
* testsuite/ld-aarch64/gc-got-relocs.d: Don't expect GOT section.
* testsuite/ld-aarch64/gc-tls-relocs.d: Likewise.
* testsuite/ld-cris/tls-gc-68.d: Likewise.
* testsuite/ld-cris/tls-gc-69.d: Likewise.
* testsuite/ld-cris/tls-gc-70.d: Likewise.
* testsuite/ld-cris/tls-gc-75.d: Likewise.
* testsuite/ld-cris/tls-gc-79.d: Likewise.
* testsuite/ld-mmix/bpo-10.d: Don't expect .MMIX.reg_contents
section.

6 years agoRegenerate gdbserver/configure
Yao Qi [Mon, 16 Oct 2017 10:26:38 +0000 (11:26 +0100)] 
Regenerate gdbserver/configure

4fa7574 (Fix gdb 8.1 Solaris compilation) changes warning.m4 and updates
configure, but gdbserver/configure is not updated.

gdb/gdbserver:

2017-10-16  Yao Qi  <yao.qi@linaro.org>

* configure: Regenerated.

6 years agoRemove features/tic6x-*.c files
Yao Qi [Mon, 16 Oct 2017 08:27:43 +0000 (09:27 +0100)] 
Remove features/tic6x-*.c files

features/*.c are generated from *.xml files, in order to get pre-defined
target descriptions, (for native debugging, for example).  However, these
pre-generated tdesc_tic6x_* are not used in GDB at all.  This patch removes
features/tic6x-*.c files.

gdb:

2017-10-16  Yao Qi  <yao.qi@linaro.org>

* features/Makefile (XMLTOC): Remove tic6x-*.xml.
* features/tic6x-c62x.c: Remove.
* features/tic6x-c64x-linux.c: Remove.
* features/tic6x-c64x.c: Remove.
* features/tic6x-c64xp-linux.c: Remove.
* features/tic6x-c64xp.c: Remove.
* tic6x-linux-tdep.c (_initialize_tic6x_linux_tdep): Don't call
initialize_tdesc_tic6x_*_linux functions.
* tic6x-tdep.c (_initialize_tic6x_tdep): Don't call
initialize_tdesc_tic6x_* functions.

6 years agoRemove regformats/tic6x-{c62x,c64x,c64xp}.dat
Yao Qi [Mon, 16 Oct 2017 08:15:07 +0000 (09:15 +0100)] 
Remove regformats/tic6x-{c62x,c64x,c64xp}.dat

tic6x-uclinux GDBserver uses linux target descriptions, instead of these
non-linux target descriptions.  So we can remove these *.dat files.

gdb:

2017-10-16  Yao Qi  <yao.qi@linaro.org>

* features/Makefile (WHICH): Remove tic6x-c64xp, tic6x-c64x
tic6x-c62x.
* regformats/tic6x-c62x.dat: Remove.
* regformats/tic6x-c64x.dat: Remove.
* regformats/tic6x-c64xp.dat: Remove.

6 years agoFix GDB build without expat
Simon Marchi [Mon, 16 Oct 2017 02:13:22 +0000 (22:13 -0400)] 
Fix GDB build without expat

An earlier patch of mine changed parse_traceframe_info to make it return
a unique_ptr.  I forgot to update the version of the function used in an
expat-less build, this patch fixes it.

gdb/ChangeLog:

* tracepoint.c (parse_traceframe_info): Return a unique_ptr
(the !HAVE_LIBEXPAT version).

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 16 Oct 2017 00:00:19 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 15 Oct 2017 00:00:28 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agox86: Add elf_x86_backend_data
H.J. Lu [Sat, 14 Oct 2017 18:32:29 +0000 (11:32 -0700)] 
x86: Add elf_x86_backend_data

Add plt0_pad_byte and target_os fields to elf_x86_link_hash_table.
Replace elf_i386_backend_data and elf_x86_64_backend_data with
elf_x86_backend_data.

* elf32-i386.c (elf_i386_backend_data): Removed.
(get_elf_i386_backend_data): Likewise.
(elf_i386_arch_bed): Replace elf_i386_backend_data with
elf_x86_backend_data.
(elf_i386_get_synthetic_symtab): Likewise.
(elf_i386_nacl_arch_bed): Likewise.
(elf_i386_vxworks_arch_bed): Likewise.
(elf_i386_relocate_section): Check target_os instead of
is_vxworks.
(elf_i386_finish_dynamic_symbol): Likewise.
(elf_i386_finish_dynamic_sections): Use htab->plt0_pad_byte.
Check target_os instead of is_vxworks.
(elf_i386_link_setup_gnu_properties): Remove normal_target and
is_vxworks.  Initialize plt0_pad_byte.
* elf64-x86-64.c (elf_x86_64_backend_data); Removed.
(get_elf_x86_64_arch_data): Likewise.
(get_elf_x86_64_backend_data): Likewise.
(elf_x86_64_arch_bed): Replace elf_x86_64_backend_data with
elf_x86_backend_data.
(elf_x86_64_get_synthetic_symtab): Likewise.
(elf_x86_64_nacl_arch_bed): Likewise.
(elf_x86_64_link_setup_gnu_properties): Remove is_vxworks and
normal_target.  Initialize plt0_pad_byte.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check target_os
instead of is_vxworks.
(_bfd_x86_elf_size_dynamic_sections): Likewise.
(_bfd_x86_elf_finish_dynamic_sections): Likewise.
(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.
(_bfd_x86_elf_link_hash_table_create): Initialize target_os.
(_bfd_x86_elf_link_setup_gnu_properties): Remove is_vxworks.
Update normal_target.  Set up plt0_pad_byte.  Check target_os
instead of is_vxworks.
* elfxx-x86.h (elf_x86_target_os): New.
(elf_x86_backend_data): Likewise.
(get_elf_x86_backend_data): Likewise.
(elf_x86_link_hash_table): Remove is_vxworks.  Add plt0_pad_byte
and target_os.
(elf_x86_init_table): Remove normal_target and is_vxworks.  Add
plt0_pad_byte.

6 years agox86: Add _bfd_x86_elf_finish_dynamic_sections
H.J. Lu [Sat, 14 Oct 2017 18:29:58 +0000 (11:29 -0700)] 
x86: Add _bfd_x86_elf_finish_dynamic_sections

Extract the common parts of elf_i386_finish_dynamic_sections and
elf_x86_64_finish_dynamic_sections into a separate function in
elfxx-x86.c.

* elf32-i386.c (elf_i386_finish_dynamic_sections): Call
_bfd_x86_elf_finish_dynamic_sections.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_sections): Likewise.
* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): New
function.
* elfxx-x86.h (_bfd_x86_elf_finish_dynamic_sections): New
prototype.

6 years agocris: Don't hide symbol which was forced to be dynamic
H.J. Lu [Sat, 14 Oct 2017 18:23:45 +0000 (11:23 -0700)] 
cris: Don't hide symbol which was forced to be dynamic

h->root.dynamic is set on symbols which were forced to be dynamic due
to a version script file.  Don't remove such symbols from dynamic symbol
table.  This fixes:

FAIL: ld-elf/pr21384

PR ld/21384
* elf32-cris.c (elf_cris_discard_excess_program_dynamics): Don't
hide symbol which was forced to be dynamic.

6 years agocris: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 18:09:29 +0000 (11:09 -0700)] 
cris: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

bfd/

PR ld/22269
* elf32-cris.c (cris_elf_relocate_section): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(cris_elf_check_relocs): Don't allocate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

ld/

PR ld/22269
* testsuite/ld-cris/weakhiddso.d: Update and remove R_CRIS_NONE.

6 years agosh: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 18:07:18 +0000 (11:07 -0700)] 
sh: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-sh.c (allocate_dynrelocs): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(sh_elf_relocate_section): Don't generate dynamic relocation if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agos390: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 18:06:00 +0000 (11:06 -0700)] 
s390: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-s390.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_s390_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
* elf64-s390.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_s390_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agonios2: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 18:04:32 +0000 (11:04 -0700)] 
nios2: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-nios2.c (nios2_elf32_relocate_section): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agomicroblaze: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 18:03:26 +0000 (11:03 -0700)] 
microblaze: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-microblaze.c (microblaze_elf_relocate_section): Don't
generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agom68k: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 18:02:20 +0000 (11:02 -0700)] 
m68k: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-m68k.c (elf_m68k_check_relocs): Don't allocate dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_m68k_adjust_dynamic_symbol): Don't make symbol dynamic if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_m68k_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agohppa: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 17:54:50 +0000 (10:54 -0700)] 
hppa: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-hppa.c (ensure_undef_dynamic): Don't make undefined
symbol dynamic if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf32_hppa_relocate_section): Don't generate dynamic
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agoia64: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 17:53:43 +0000 (10:53 -0700)] 
ia64: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elfnn-ia64.c (elfNN_ia64_check_relocs): Don't allocate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_fptr): Don't allocate function pointer if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrel_entries): Don't allocate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(set_got_entry): Don't set GOT entry if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(set_pltoff_entry): Don't set PLTOFF entry if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elfNN_ia64_relocate_section): Don't install dynamic relocation
UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agomips: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 17:52:12 +0000 (10:52 -0700)] 
mips: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elfxx-mips.c (mips_elf_calculate_relocation): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Don't allocate dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agoarm: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 17:27:33 +0000 (10:27 -0700)] 
arm: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-arm.c (elf32_arm_final_link_relocate): Don't generate
dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs_for_symbol): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agotile: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 17:25:33 +0000 (10:25 -0700)] 
tile: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elf32-tilepro.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(tilepro_elf_relocate_section): Don't generate dynamic
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
* elfxx-tilegx.c (allocate_dynrelocs): Discard dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(tilegx_elf_relocate_section): Don't generate dynamic
relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agoaarch64: Check UNDEFWEAK_NO_DYNAMIC_RELOC
H.J. Lu [Sat, 14 Oct 2017 17:23:48 +0000 (10:23 -0700)] 
aarch64: Check UNDEFWEAK_NO_DYNAMIC_RELOC

Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero.  FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.

PR ld/22269
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Don't
generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
true.
(elfNN_aarch64_allocate_dynrelocs): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.

6 years agoMove UNDEFWEAK_NO_DYNAMIC_RELOC to elf-bfd.h
H.J. Lu [Sat, 14 Oct 2017 17:19:30 +0000 (10:19 -0700)] 
Move UNDEFWEAK_NO_DYNAMIC_RELOC to elf-bfd.h

Move UNDEFWEAK_NO_DYNAMIC_RELOC to elf-bfd.h so that it can be used by
other ELF linker backends.

* elf32-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Moved to ...
* elf-bfd.h (UNDEFWEAK_NO_DYNAMIC_RELOC): Here.
* elf64-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Removed.

6 years agoFix build failure in linux-osdata.c
Simon Marchi [Sat, 14 Oct 2017 13:28:07 +0000 (09:28 -0400)] 
Fix build failure in linux-osdata.c

Commit

  Use std::vector in linux_xfer_osdata_processgroups
  b129dcac882da87767cb863ad8b2572f90e9e5bc

broke the build with older gcc (at least 4.7 and 4.8):

In file included from /usr/include/c++/4.7/algorithm:63:0,
                 from /home/emaisin/src/binutils-gdb/gdb/nat/linux-osdata.c:40:
/usr/include/c++/4.7/bits/stl_algo.h: In instantiation of â€˜_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >; _Tp = pid_pgid_entry]’:
/usr/include/c++/4.7/bits/stl_algo.h:2315:70:   required from â€˜_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >]’
/usr/include/c++/4.7/bits/stl_algo.h:2347:54:   required from â€˜void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >; _Size = long int]’
/usr/include/c++/4.7/bits/stl_algo.h:5483:4:   required from â€˜void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pid_pgid_entry*, std::vector<pid_pgid_entry> >]’
/home/emaisin/src/binutils-gdb/gdb/nat/linux-osdata.c:480:57:   required from here
/usr/include/c++/4.7/bits/stl_algo.h:2277:4: error: passing â€˜const pid_pgid_entry’ as â€˜this’ argument of â€˜bool pid_pgid_entry::operator<(const pid_pgid_entry&)’ discards qualifiers [-fpermissive]

Making the operator< method const fixes it.

gdb/ChangeLog:

* nat/linux-osdata.c (struct pid_pgid_entry) <operator<>: Make
const.

6 years agogdbserver: use std::list for all_threads
Simon Marchi [Sat, 14 Oct 2017 13:11:12 +0000 (09:11 -0400)] 
gdbserver: use std::list for all_threads

Remove the usage of inferior_list for the all_threads list in
gdbserver.  The entry field in thread_info is removed, and replaced by a
simple ptid field.

I added some functions to iterate (for_each_thread) and find threads
(find_thread).  However, changing all the users of find_inferior & co to
use these new functions would have made the patch way too big.  So I
opted instead to make find_inferior & co some shims, so that the
existing code only needs to be updated minimally.  We can then update
the existing code to use the new functions incrementally (I've started
to do the work, but I'll post it afterwards, see [1] if you want a peek).

This patch has been built-tested on all relevant platforms, except
lynx.  I also regtested using the native-gdbserver and
native-extended-gdbserver boards on x86.

[1] https://github.com/simark/binutils-gdb/commits/kill-inferior-list-entry

gdb/gdbserver/ChangeLog:

* inferiors.h: (struct inferior_list): Remove.
(struct inferior_list_entry); Remove.
(add_inferior_to_list, clear_inferior_list, one_inferior_p,
A_I_NEXT, ALL_INFERIORS_TYPE, ALL_INFERIORS, remove_inferior,
get_first_inferior): Remove.
(for_each_inferior, for_each_inferior_with_data, find_inferior,
find_inferior_id, find_inferior_in_random): Change signature.
* inferiors.c (all_threads): Change type to
std::list<thread_info *>.
(get_thread): Remove macro.
(find_inferior, find_inferior_id): Change signature, implement
using find_thread.
(find_inferior_in_random): Change signature, implement using
find_thread_in_random.
(for_each_inferior, for_each_inferior_with_data): Change
signature, implement using for_each_thread.
(add_inferior_to_list, remove_inferior): Remove.
(add_thread, get_first_thread, thread_of_pid,
find_any_thread_of_pid, free_one_thread, remove_thread): Update.
(get_first_inferior, one_inferior_p, clear_inferior_list):
Remove.
(clear_inferiors, get_thread_process): Update.
* gdbthread.h: Include <list>.
(struct thread_info) <entry>: Remove field.
<id>: New field.
(all_threads): Change type to std::list<thread_info *>.
(get_first_inferior): Add doc.
(find_thread, for_each_thread, find_thread_in_random): New
functions.
(current_ptid, pid_of, ptid_of, lwpid_of): Update.
* linux-arm-low.c (update_registers_callback): Update.
* linux-low.c (second_thread_of_pid_p): Update.
(kill_one_lwp_callback, linux_detach_lwp_callback,
delete_lwp_callback, status_pending_p_callback, same_lwp,
find_lwp_pid, num_lwps, iterate_over_lwps_filter,
iterate_over_lwps, not_stopped_callback,
resume_stopped_resumed_lwps, count_events_callback,
select_singlestep_lwp_callback, select_event_lwp_callback,
unsuspend_one_lwp, linux_wait_1, send_sigstop_callback,
suspend_and_send_sigstop_callback, wait_for_sigstop,
stuck_in_jump_pad_callback, move_out_of_jump_pad_callback,
lwp_running, linux_set_resume_request, resume_status_pending_p,
need_step_over_p, start_step_over, linux_resume_one_thread,
proceed_one_lwp, unsuspend_and_proceed_one_lwp,
reset_lwp_ptrace_options_callback): Update.
* linux-mips-low.c (update_watch_registers_callback): Update.
* regcache.c (regcache_invalidate_one, regcache_invalidate):
Update.
(free_register_cache_thread_one): Remove.
(regcache_release): Update.
* server.c (handle_btrace_enable_bts, handle_btrace_enable_pt,
handle_qxfer_threads_worker): Update.
(handle_query): Update, use list iterator.
(visit_actioned_threads, handle_pending_status,
queue_stop_reply_callback, gdb_wants_all_threads_stopped,
clear_pending_status_callback, set_pending_status_callback,
find_status_pending_thread_callback, handle_status,
process_serial_event): Update.
* target.c (thread_search_callback): Update.
* thread-db.c (thread_db_get_tls_address): Update.
* tracepoint.c (tracepoint_finished_step, tracepoint_was_hit):
Update.
* win32-i386-low.c (update_debug_registers_callback): Update.
* win32-low.c (delete_thread_info, child_delete_thread,
continue_one_thread, suspend_one_thread,
get_child_debug_event): Adjust.

6 years agogdbserver: Use std::list for all_processes
Simon Marchi [Sat, 14 Oct 2017 13:10:42 +0000 (09:10 -0400)] 
gdbserver: Use std::list for all_processes

Remove the usage of inferior_list for the all_processes list in
gdbserver, replace it with an std::list. The entry field in process_info
is removed, and replaced by a simple pid field.

The pid_of macro, used for both processes and threads, is replaced with
separate functions.  For completeness, I changed ptid_of and lwpid_of to
functions as well.

gdb/gdbserver/ChangeLog:

* gdbthread.h (ptid_of, pid_of, lwpid_of): New functions.
* inferiors.h: Include <list>.
(struct process_info) <entry>: Remove field.
<pid>: New field.
(pid_of): Change macro to function.
(ptid_of, lwpid_of): Remove macro.
(all_processes): Change type to std::list<process_info *>.
(ALL_PROCESSES): Remove macro.
(for_each_process, find_process): New function.
* inferiors.c (all_processes): Change type to
std::list<process_info *>.
(find_thread_process): Adjust.
(add_process): Likewise.
(remove_process): Likewise.
(find_process_pid): Likewise.
(get_first_process): Likewise.
(started_inferior_callback): Remove.
(have_started_inferiors_p): Adjust.
(attached_inferior_callback): Remove.
(have_attached_inferiors_p): Adjust.
* linux-low.c (check_zombie_leaders): Likewise.
* linux-x86-low.c (x86_arch_setup_process_callback): Remove.
(x86_linux_update_xmltarget): Adjust.
* server.c (handle_query): Likewise.
(gdb_reattached_process): Remove.
(handle_status): Adjust.
(kill_inferior_callback): Likewise.
(detach_or_kill_inferior): Remove.
(print_started_pid): Likewise.
(print_attached_pid): Likewise.
(detach_or_kill_for_exit): Update.
(process_serial_event): Likewise.
* linux-arm-low.c (arm_new_fork): Likewise.

6 years agogdbserver: Use std::list for all_dlls
Simon Marchi [Sat, 14 Oct 2017 13:09:21 +0000 (09:09 -0400)] 
gdbserver: Use std::list for all_dlls

As a small step towards removing inferior_list/inferior_list_entry, this
patch replaces the usage of inferior_list for the list of dlls by an
std::list.  The dll_info type now uses an std::string for name and has a
simple constructor.

I am able to build gdbserver with mingw on Linux, but I am not able to
test this on a Windows machine (the only platform that uses this code).

gdb/gdbserver/ChangeLog:

* dll.h: Include <list>.
(struct dll_info): Add constructor.
<entry>: Remove field.
(all_dlls): Change type to std::list<dll_info>.
* dll.c: Include <algorithm>.
(get_dll): Remove macro.
(all_dlls): Change type to std::list<dll_info *>.
(free_one_dll): Remove.
(match_dll): Likewise.
(loaded_dll): Adjust.
(unloaded_dll): Adjust to all_dlls type change, use
std::find_if.  Inline code from match_dll.
(clear_dlls): Adjust to all_dlls type change.
* server.c (emit_dll_description): Remove.
(handle_qxfer_libraries): Adjust to all_dlls type change,
integrate emit_dll_description's functionality.

6 years agoMake to_traceframe_info return a unique_ptr
Simon Marchi [Sat, 14 Oct 2017 12:47:44 +0000 (08:47 -0400)] 
Make to_traceframe_info return a unique_ptr

Since this target method returns an allocated object, return a
unique_ptr.  It allows getting rid a some cleanups here and there.

I had to shuffle the includes around.  First, target.h now needs to
include tracepoint.h, to get the definition of traceframe_info_up.
However, the definition of enum trace_find_type was later in target, so
I had to move it to tracepoint.h, so that the declaration of tfind_1
could know about it.  I then had to remove the include of target.h from
tracepoint.h, which caused a circular dependency (it was probably
included to get enum trace_find_type in the first place anyway).

Regression tested on the buildbot.

gdb/ChangeLog:

* target.h: Include tracepoint.h.
(enum trace_find_type): Move to tracepoint.h.
(struct target_ops) <to_traceframe_info>: Return a unique ptr.
* tracepoint.h: Don't include target.h
(enum trace_find_type): Move from target.h.
(parse_traceframe_info): Return a unique ptr.
* tracepoint.c (current_traceframe_info): Change type to unique
ptr.
(free_traceframe_info): Remove.
(clear_traceframe_info): Don't manually free
current_traceframe_info.
(free_result): Remove.
(parse_traceframe_info): Return a unique ptr.
(get_traceframe_info): Adjust to unique ptr.
* ctf.c (ctf_traceframe_info): Return a unique ptr.
* remote.c (remote_traceframe_info): Return a unique ptr.
* tracefile-tfile.c (tfile_traceframe_info): Return a unique
ptr.
* target-debug.h (target_debug_print_traceframe_info_up): New
macro.
* target-delegates.c: Regenerate.

6 years agoUse std::vector for traceframe_info::memory
Simon Marchi [Sat, 14 Oct 2017 12:43:54 +0000 (08:43 -0400)] 
Use std::vector for traceframe_info::memory

Straightforward change from a VEC to std::vector.  This allows making
the destruction of a traceframe_info trivial.

I added a constructor with parameters to mem_range to be able to
emplace_back directly with the values.  It is necessary to leave a
default constructor there because mem_range is still used in a VEC.

gdb/ChangeLog:

* memrange.h (struct mem_range): Add constructors.
* tracepoint.h (struct traceframe_info) <memory>: Change type to
std::vector<mem_range>.
* tracepoint.c (free_traceframe_info): Don't manually free
vector.
(traceframe_info_start_memory): Adjust to vector change.
(traceframe_available_memory): Likewise.
* tracefile-tfile.c (build_traceframe_info): Likewise.
* ctf.c (ctf_traceframe_info): Likewise.

6 years agoUse std::vector for traceframe_info::tvars
Simon Marchi [Sat, 14 Oct 2017 12:42:23 +0000 (08:42 -0400)] 
Use std::vector for traceframe_info::tvars

Straightforward change to get rid of a VEC.  We need to new/delete
traceframe_info instead of malloc/free it.  I found three places that
allocate a traceframe_info (ctf_traceframe_info, tfile_traceframe_info
and parse_traceframe_info) and only one that frees it
(free_traceframe_info).

gdb/ChangeLog:

* tracepoint.h (struct traceframe_info) <tvars>: Change type to
std::vector<int>.
* tracepoint.c (free_traceframe_info): Deallocate with delete.
(traceframe_info_start_tvar): Adjust to vector change.
(parse_traceframe_info): Allocate with new.
* ctf.c (ctf_traceframe_info): Allocate with new, adjust to
vector change.
* tracefile-tfile.c (build_traceframe_info): Adjust to vector
change.
tfile_traceframe_info): Allocate with new.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to vector
change.

6 years agoRename traceframe_info variable to current_traceframe_info
Simon Marchi [Sat, 14 Oct 2017 12:41:01 +0000 (08:41 -0400)] 
Rename traceframe_info variable to current_traceframe_info

... so it doesn't shadow the traceframe_info type.  It think it's a
clearer name anyway.

gdb/ChangeLog:

* tracepoint.c (traceframe_info): Rename to...
(current_traceframe_info): ...this.
(clear_traceframe_info): Adjust.
(get_traceframe_info): Adjust.

6 years agoUse std::vector in linux_xfer_osdata_processgroups
Simon Marchi [Sat, 14 Oct 2017 12:38:02 +0000 (08:38 -0400)] 
Use std::vector in linux_xfer_osdata_processgroups

This simplifies the code quite a bit, by removing the array of PID_T
that's actually an array of pairs of PID_T.

This code is only used to implement "info os procgroups".  I tested by hand
as well as by running gdb.base/info-os.exp for unix, native-gdbserver
and native-extended-gdbserver.

gdb/ChangeLog:

* nat/linux-osdata.c: Include algorithm.
(compare_processes): Remove.
(struct pid_pgid_entry): New struct.
(linux_xfer_osdata_processgroups): Use std::vector instead of
XNEWVEC.

6 years agoReplace psymbol_allocation_list with std::vector
Simon Marchi [Sat, 14 Oct 2017 12:06:29 +0000 (08:06 -0400)] 
Replace psymbol_allocation_list with std::vector

psymbol_allocation_list is basically a vector implementation.  We can
replace it with an std::vector, now that objfile has been C++-ified.

I sent this to the buildbot, there are a few suspicious failures, but
I don't think they are related to this patch.  For example on powerpc:

new FAIL: gdb.base/catch-syscall.exp: execve: syscall execve has returned
new FAIL: gdb.base/catch-syscall.exp: execve: continue to main
new FAIL: gdb.base/catch-syscall.exp: execve: continue until exit

I get the same failures when testing manually on gcc112, without this
patch.

gdb/ChangeLog:

* objfiles.h: Don't include symfile.h.
(struct partial_symbol): Remove forward-declaration.
(struct objfile) <global_psymbols, static_psymbols>: Change type
to std::vector<partial_symbol *>.
* objfiles.c (objfile::objfile): Don't memset those fields.
(objfile::~objfile): Don't free those fields.
* psympriv.h (struct psymbol_allocation_list): Remove
forward-declaration.
(add_psymbol_to_list): Change psymbol_allocation_list parameter
to std::vector.
(start_psymtab_common): Change parameters to std::vector.
* psymtab.c: Include algorithm.
(require_partial_symbols): Call shrink_to_fit.
(find_pc_sect_psymbol): Adjust to vector change.
(match_partial_symbol): Likewise.
(lookup_partial_symbol): Likewise.
(psym_relocate): Likewise.
(dump_psymtab): Likewise.
(recursively_search_psymtabs): Likewise.
(compare_psymbols): Remove.
(sort_pst_symbols): Adjust to vector change.
(start_psymtab_common): Likewise.
(end_psymtab_common): Likewise.
(psymbol_bcache_full): De-constify return value.
(add_psymbol_to_bcache): Likewise.
(extend_psymbol_list): Remove.
(append_psymbol_to_list): Adjust to vector change.
(add_psymbol_to_list): Likewise.
(init_psymbol_list): Likewise.
(maintenance_info_psymtabs): Likewise.
(maintenance_check_psymtabs): Likewise.
* symfile.h (struct psymbol_allocation_list): Remove.
* symfile.c (reread_symbols): Adjust to vector change.
* dbxread.c (start_psymtab): Change type of parameters.
(dbx_symfile_read): Adjust to vector change.
(read_dbx_symtab): Likewise.
(start_psymtab): Change type of parameters.
* dwarf2read.c (dwarf2_build_psymtabs): Adjust to vector change.
(create_partial_symtab): Likewise.
(add_partial_symbol): Likewise.
(write_one_signatured_type): Likewise.
(recursively_write_psymbols): Likewise.
* mdebugread.c (parse_partial_symbols): Likewise.
* xcoffread.c (xcoff_start_psymtab): Change type of parameters.
(scan_xcoff_symtab): Adjust to vector change.
(xcoff_initial_scan): Likewise.

6 years agoada: Use std::string in print_dynamic_range_bound
Simon Marchi [Sat, 14 Oct 2017 02:45:14 +0000 (22:45 -0400)] 
ada: Use std::string in print_dynamic_range_bound

Replace this usage of GROW_VECT with an std::string.  I don't think
there's a reason for this variable to be static, other than it was
cumbersome to manage its lifetime (i.e. use a cleanup) before.

Tested by comparing the gdb.ada/*.exp test results before and after the
patch.

gdb/ChangeLog:

* ada-typeprint.c (print_dynamic_range_bound): Use std::string.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 14 Oct 2017 00:00:20 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoSkip a few tests on targets that can't use the "run" commmand.
Pedro Alves [Thu, 12 Oct 2017 17:20:25 +0000 (18:20 +0100)] 
Skip a few tests on targets that can't use the "run" commmand.

These tests want to use raw "run", so skip them on targets that can't
do that.

Also adds a small utility procedure that clearly conveys intent instead of
explicitly checking use_gdb_stub in the testcases.

This makes sure these testcases continue to be skipped with
--target_board=native-gdbserver once that board stops setting
is_remote.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* lib/gdb.exp (target_can_use_run_cmd): New procedure.
* gdb.base/annota1.exp: Use it instead of is_remote.
* gdb.base/annota3.exp: Use it instead of is_remote.
* gdb.cp/annota2.exp: Use it instead of is_remote.
* gdb.cp/annota3.exp: Use it instead of is_remote.
* gdb.multi/bkpt-multi-exec.exp: Use it instead of is_remote.

6 years agoFix gdb.base/testenv.exp against --target_board=native-extended-gdbserver
Pedro Alves [Thu, 12 Oct 2017 17:27:20 +0000 (18:27 +0100)] 
Fix gdb.base/testenv.exp against --target_board=native-extended-gdbserver

Currently we get:

  Running ..../src/gdb/testsuite/gdb.base/testenv.exp ...
  FAIL: gdb.base/testenv.exp: test no TEST_GDB var
  FAIL: gdb.base/testenv.exp: test with one TEST_GDB var
  FAIL: gdb.base/testenv.exp: test with two TEST_GDB var
  FAIL: gdb.base/testenv.exp: test with one TEST_GDB var, after unset
  FAIL: gdb.base/testenv.exp: test with TEST_GDB_GLOBAL
  FAIL: gdb.base/testenv.exp: test with TEST_GDB_GLOBAL unset

The problem is that the testcase relies on stdio.  While we could fix
this for gdbserver by read output from inferior_spawn_id, a better fix
it to not rely on stdio at all.  That's what this commit does.
Instead, it reads variables off of the inferior to extract the
necessary information.

Along the way, most of the .exp file is reimplemented/cleaned up using
more modern mechanisms.  E.g., with_test_prefix, proc_with_prefix,
save_vars, etc.  Also, a missing check for "is_remote host" is added.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/testenv.exp: Check use_gdb_stub instead of is_remote.
(test_num_test_vars, run_and_count_vars, find_env)
(test_set_unset_env, test_inherit_env_var): New procedures.
(top level): Use them.

6 years agoDon't run gdb.gdb/ selftests if use_gdb_stub is true
Pedro Alves [Thu, 12 Oct 2017 17:29:21 +0000 (18:29 +0100)] 
Don't run gdb.gdb/ selftests if use_gdb_stub is true

If we make the native-gdbserver board be !is_remote, then the few
tests that use the selftest-support.exp routines to debug gdb itself
start running, and fail, with something like:

  Running ..../src/gdb/testsuite/gdb.gdb/selftest.exp ...
  ERROR: tcl error sourcing ..../src/gdb/testsuite/gdb.gdb/selftest.exp.
  ERROR: gdbserver does not support run [....] without extended-remote
      while executing
  "error "gdbserver does not support $command without extended-remote""
      (procedure "gdb_test_multiple" line 25)
      invoked from within
  "gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
  -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb..."
      (procedure "selftest_setup" line 45)

This commit makes sure those tests continue to be skipped.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* lib/selftest-support.exp (selftest_setup): Extend comments, and
also skip on stub-like targets.

6 years agoMake gdb.base/find-unmapped.exp pass on remote targets
Pedro Alves [Fri, 13 Oct 2017 15:34:50 +0000 (16:34 +0100)] 
Make gdb.base/find-unmapped.exp pass on remote targets

Currently, with --target_board=native-extended-gdbserver, we get:

  Running .../src/gdb/testsuite/gdb.base/find-unmapped.exp ...
  FAIL: gdb.base/find-unmapped.exp: find global_var_0, global_var_2, 0xff
  FAIL: gdb.base/find-unmapped.exp: find global_var_1, global_var_2, 0xff
  FAIL: gdb.base/find-unmapped.exp: find global_var_2, (global_var_2 + 16), 0xff

This commit makes the test pass there, and also enables in on
--target_board=native-gdbserver, and other remote targets.

I've filed PR gdb/22293 to track the missing-warning problem.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

PR gdb/22293
* gdb.base/find-unmapped.exp: Don't skip if is_remote target.
(top level): Move some tests to ...
(test_not_found): ... this new procedure.
(top level): Call it.

6 years agoSimplify tic6x and s390x expedite registers
Yao Qi [Fri, 13 Oct 2017 14:36:49 +0000 (15:36 +0100)] 
Simplify tic6x and s390x expedite registers

Nowadays, we have six tic6x expedite registers, which are duplicated.

tic6x-c64xp-expedite = A15,PC
tic6x-c64x-expedite = A15,PC
tic6x-c62x-expedite = A15,PC
tic6x-c64xp-linux-expedite = A15,PC
tic6x-c64x-linux-expedite = A15,PC
tic6x-c62x-linux-expedite = A15,PC

in features/Makefile, we have

   echo "expedite:$(if $($*-expedite),$($*-expedite),$($(firstword $(subst -, ,$(notdir $*)))-expedite))" \
        >> $(outdir)/$*.tmp

which means for a given bar/foo-baz.xml, we'll look for either
bar/foo-baz-expedite or foo-expedite.  We can define only one generic
expedite register for all different ti6cx and s390x target descriptions.
Actually, we've done that for x86 target descriptions.

Re-run 'make GDB=/path/build/gdb all' to regenerate regformats/*.dat files,
and they are not changed.

gdb:

2017-10-13  Yao Qi  <yao.qi@linaro.org>

* features/Makefile: Remove tic6x-*-expedite, add tic6x-expedite.
Remove s390x-*-expedite, add s390x-expedite.

6 years agoRegenerate features/s390-gs-linux64.c and features/s390x-gs-linux64.c
Yao Qi [Fri, 13 Oct 2017 14:28:10 +0000 (15:28 +0100)] 
Regenerate features/s390-gs-linux64.c and features/s390x-gs-linux64.c

gdb:

2017-10-13  Yao Qi  <yao.qi@linaro.org>

* features/s390-gs-linux64.c: Regenerated.
* features/s390x-gs-linux64.c: Regenerated.

6 years agoPR22263 testcase
Alan Modra [Fri, 13 Oct 2017 04:53:35 +0000 (15:23 +1030)] 
PR22263 testcase

A number of targets need dynamic relocs in PIEs for reasons other than
relocating thread variables.  The PR is about text relocations, and,
reading between the lines, unnecessary dynamic tprel relocations.
Change the test to check for those conditions rather than no dynamic
relocations

PR ld/22263
* testsuite/ld-elf/tls.exp: Link with -z text.
* testsuite/ld-elf/pr22263-1.rd: Test for tprel relocs.

6 years agoChange objfile to use new/delete
Tom Tromey [Wed, 11 Oct 2017 20:43:57 +0000 (14:43 -0600)] 
Change objfile to use new/delete

This changes objfiles to use new and delete rather than xmalloc and
free.  Simon noticed that it uses a non-POD and so shouldn't be
allocated with XCNEW; and I wanted to be able to use another non-POD as
a member; this patch is the result.

Regression tested by the buildbot.

2017-10-13  Tom Tromey  <tom@tromey.com>

* compile/compile-object-run.c (do_module_cleanup): Use delete.
* solib.c (update_solib_list, reload_shared_libraries_1): Use
delete.
* symfile.c (symbol_file_add_with_addrs): Use new.
(symbol_file_add_separate): Update comment.
(syms_from_objfile_1, remove_symbol_file_command): Use delete.
* jit.c (jit_object_close_impl): Use new.
(jit_unregister_code): Use delete.
* objfiles.c (objfile::objfile): Rename from allocate_objfile.
(~objfile): Rename from free_objfile.
(free_objfile_separate_debug, do_free_objfile_cleanup)
(free_all_objfiles, objfile_purge_solibs): Use delete.
* objfiles.h (struct objfile): Add constructor and destructor.
Use DISABLE_COPY_AND_ASSIGN.  Add initializers to data members.
(allocate_objfile, free_objfile): Don't declare.
(struct objstats): Add initializers.

6 years agoFix gdb.base/term.exp on non-"target native" boards
Pedro Alves [Fri, 13 Oct 2017 12:38:24 +0000 (13:38 +0100)] 
Fix gdb.base/term.exp on non-"target native" boards

With --target_board=native-extended-gdbserver, we get:

  Running .../src/gdb/testsuite/gdb.base/term.exp ...
  FAIL: gdb.base/term.exp: info terminal at breakpoint

  (gdb) info terminal
  No saved terminal information.

Fix it by running the test everywhere, and expecting different output
on non-native targets.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/term.exp: Don't skip if is_remote target.  Instead,
expect different "info terminal" output if testing with a
non-native target.

6 years agoRemove is_remote kfail from gdb.python/py-evthreads.exp
Pedro Alves [Fri, 13 Oct 2017 12:25:20 +0000 (13:25 +0100)] 
Remove is_remote kfail from gdb.python/py-evthreads.exp

This testcase works fine with gdbserver nowadays.  So remove the
kfail.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@polymtl.ca>

PR python/12966
* gdb.python/py-evthreads.exp: Remove is_remote target kfail.

6 years agoFix gdb.python/py-evthreads.exp with --target_board=native-extended-gdbserver
Pedro Alves [Fri, 13 Oct 2017 12:15:04 +0000 (13:15 +0100)] 
Fix gdb.python/py-evthreads.exp with --target_board=native-extended-gdbserver

Fixes:
  Running ..../src/gdb/testsuite/gdb.python/py-evthreads.exp ...
  FAIL: gdb.python/py-evthreads.exp: run to breakpoint 1
  FAIL: gdb.python/py-evthreads.exp: reached breakpoint 2
  FAIL: gdb.python/py-evthreads.exp: thread 2
  FAIL: gdb.python/py-evthreads.exp: reached breakpoint 3
  FAIL: gdb.python/py-evthreads.exp: thread 3
  FAIL: gdb.python/py-evthreads.exp: continue thread 1
  [... cascading time outs ...]

By following the usual pattern that makes sure that non-stop is enabled
before connecting to gdbserver.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.python/py-evthreads.exp: Start GDB with "set non-stop on"
already.

6 years agokfail gdb.python/py-evsignal.exp on RSP targets properly
Pedro Alves [Fri, 13 Oct 2017 11:27:49 +0000 (12:27 +0100)] 
kfail gdb.python/py-evsignal.exp on RSP targets properly

Fixes, with --target_board=native-extended-gdbserver:

   Running ..../src/gdb/testsuite/gdb.python/py-evsignal.exp ...
   FAIL: gdb.python/py-evsignal.exp: signal Thread 3

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.python/py-evsignal.exp: Check gdb_protocol instead of
is_remote.

6 years agoSkip gdb.threads/thread_events.exp on RSP targets properly
Pedro Alves [Fri, 13 Oct 2017 11:18:50 +0000 (12:18 +0100)] 
Skip gdb.threads/thread_events.exp on RSP targets properly

Fixes, with --target_board=native-extended-gdbserver:

  Running ..../src/gdb/testsuite/gdb.threads/thread_events.exp ...
  FAIL: gdb.threads/thread_events.exp: continue to after_join_func with messages enabled (saw 0, expected 1)

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.threads/thread_events.exp: Check gdb_protocol instead of
is_remote.

6 years agoTweak gdb.base/corefile.exp is_remote check
Pedro Alves [Fri, 13 Oct 2017 10:25:42 +0000 (11:25 +0100)] 
Tweak gdb.base/corefile.exp is_remote check

1. Otherwise, when we make native-gdbserver board no longer is_remote,
   we get:

  Running .../src/gdb/testsuite/gdb.base/corefile.exp ...
  ERROR: tcl error sourcing .../src/gdb/testsuite/gdb.base/corefile.exp.
  ERROR: gdbserver does not support attach 9327 without extended-remote
      while executing
  "error "gdbserver does not support $command without extended-remote""

  That's fixed by using can_spawn_for_attach instead.

2. The gdb_protocol check fixes this current problem with
   --target_board=extended-remote-gdbserver:

     Running .../src/gdb/testsuite/gdb.base/corefile.exp ...
     FAIL: gdb.base/corefile.exp: run: with core
     FAIL: gdb.base/corefile.exp: run: core file is cleared
     FAIL: gdb.base/corefile.exp: attach: with core
     FAIL: gdb.base/corefile.exp: attach: core file is cleared

   gdb.log:
     (...)
     attach 10859
     Don't know how to attach.  Try "help target".
     (...)

The fix for #2 alone would fix #1 too, but can_spawn_for_attach
expresses the requirement directly, so I still left it there.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/corefile.exp (corefile_test_run): Skip if gdb_protocol
is set.
(corefile_test_attach): Likewise.  Check can_spawn_for_attach
instead of is_remote.

6 years agoFix is_remote check in gdb.base/remote.exp
Pedro Alves [Fri, 13 Oct 2017 09:48:42 +0000 (10:48 +0100)] 
Fix is_remote check in gdb.base/remote.exp

1. Otherwise, when the native-gdbserver board stops setting is_remote,
   this test would stop running there.

2. Makes the test run with --target_board=native-extended-gdbserver
   too.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/remote.exp: Check gdb_protocol instead of is_remote.
(top level): Add comment.

6 years agogdb.base/remote.exp: Fix typo and add missing return
Pedro Alves [Fri, 13 Oct 2017 10:14:06 +0000 (11:14 +0100)] 
gdb.base/remote.exp: Fix typo and add missing return

(Dropped 'u' while at it because we're supposed to prefer American
English spelling...)

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/remote.exp (top level): Fix comment typo and add
missing return.

6 years agoMake gdb.base/solib-nodir.exp work with --target_board=native-extended-gdbserver
Pedro Alves [Fri, 13 Oct 2017 09:26:06 +0000 (10:26 +0100)] 
Make gdb.base/solib-nodir.exp work with --target_board=native-extended-gdbserver

Fixes:
 Running .../src/gdb/testsuite/gdb.base/solib-nodir.exp ...
 FAIL: gdb.base/solib-nodir.exp: library loaded

... by using the new "set cwd" command.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>
    Simon Marchi <simon.marchi@polymtl.ca>

* gdb.base/solib-nodir.exp: Split is_remote and skip_shlib_tests
calls and add comments.  Skip test if use_gdb_stub is set.
(top level): Use "set cwd" command instead of "cd" command.

6 years agoEliminate is_remote check in gdb.base/shlib-call.exp
Pedro Alves [Fri, 13 Oct 2017 09:11:57 +0000 (10:11 +0100)] 
Eliminate is_remote check in gdb.base/shlib-call.exp

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/shlib-call.exp (top level): Use gdb_run_cmd and remove
is_remote target check.

6 years agoRemove simple_displaced_step_copy_insn
Simon Marchi [Fri, 13 Oct 2017 01:42:05 +0000 (21:42 -0400)] 
Remove simple_displaced_step_copy_insn

Nothing uses this function.  Remove it, and adjust comments referring to
it.

gdb/ChangeLog:

* arch-utils.h (simple_displaced_step_copy_insn): Remove.
* arch-utils.c (simple_displaced_step_copy_insn): Remove.
* gdbarch.sh (displaced_step_copy_insn): Adjust comment.
* gdbarch.h: Regenerate.
* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn):
Adjust comment.
* i386-tdep.c (i386_displaced_step_copy_insn): Adjust comment.
(i386_displaced_step_fixup): Adjust comment.
* rs6000-tdep.c (ppc_displaced_step_copy_insn): Adjust comment.

6 years agoFT32: support for FT32B processor - part 1
James Bowman [Fri, 13 Oct 2017 01:37:40 +0000 (18:37 -0700)] 
FT32: support for FT32B processor - part 1

FT32B is a new FT32 family member. It has a code
compression scheme, which requires the use of linker
relaxations. The change is quite large, so submission
is in several parts.

Part 1 adds a 15-bit instruction field, and CPU-specific functions for
the code compression that are used in binutils and GDB.

bfd/ChangeLog:

2017-10-12  James Bowman  <james.bowman@ftdichip.com>

* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-ft32.c: Add HOWTO R_FT32_15.
* reloc.c: Add BFD_RELOC_FT32_15.

gas/ChangeLog:

2017-10-12  James Bowman  <james.bowman@ftdichip.com>

* config/tc-ft32.c (md_assemble): Replace FT32_FLD_K8 with
K15.
(md_apply_fix, tc_gen_reloc): Add BFD_RELOC_FT32_15.

include/ChangeLog:

2017-10-12  James Bowman  <james.bowman@ftdichip.com>

* elf/ft32.h: Add R_FT32_15.
* opcode/ft32.h: Replace FT32_FLD_K8 with K15.
(ft32_shortcode, sc_compar, ft32_split_shortcode,
ft32_merge_shortcode, ft32_merge_shortcode): New functions.

opcodes/ChangeLog:

2017-10-12  James Bowman  <james.bowman@ftdichip.com>

* opcodes/ft32-dis.c (print_insn_ft32): Replace FT32_FLD_K8 with K15.
* opcodes/ft32-opc.c (ft32_opc_info): Replace FT32_FLD_K8 with
K15. Add jmpix pattern.

sim/ChangeLog:

2017-10-12  James Bowman  <james.bowman@ftdichip.com>

* sim/ft32/interp.c (step_once): Replace FT32_FLD_K8 with K15.

6 years agoAdd myself as ft32 maintainer for sim.
James Bowman [Fri, 13 Oct 2017 01:12:42 +0000 (18:12 -0700)] 
Add myself as ft32 maintainer for sim.

sim/ChangeLog:
2017-10-12  James Bowman  <james.bowman@ftdichip.com>

* MAINTAINERS (ft32): Add myself.

6 years agoEliminate is_remote check in gdb.base/scope.exp
Pedro Alves [Fri, 13 Oct 2017 00:27:18 +0000 (01:27 +0100)] 
Eliminate is_remote check in gdb.base/scope.exp

This commit makes --target_board=native-gdbserver (and in principle
all other is_remote boards) pass all the same gdb.base/scope.exp tests
as native testing.

I first wrote the gdb.base/scope.exp change described in the ChangeLog
below and in the new comments in the patch, knowing that gdb_file_cmd
was the right thing to use here.

However, that revealed that the native-extended-gdbserver board should
be overriding gdb_file_cmd+gdb_reload instead of gdb_load, as is
hinted at by the comments on top of the default implementations in
testsuite/lib/gdb.exp, because otherwise a gdb_run_cmd after
gdb_file_cmd misses setting "set remote exec-file".  However, if we do
that and remove gdb_load, then we regress gdb.base/dbx.exp, so for now
keep the gdb_load override as well.

gdb/testsuite/ChangeLog:
2017-10-13  Pedro Alves  <palves@redhat.com>

* gdb.base/scope.exp: Use build_executable + clean_restart +
gdb_file_cmd instead of prepare_for_testing and no longer skip
"before run" tests on is_remote target boards.  Update comments.
* boards/native-extended-gdbserver.exp
(extended_gdbserver_load_last_file): New, factored out from ...
(gdb_load): ... this.  Move further below and add comment.
(extended_gdbserver_gdb_file_cmd, gdb_file_cmd, gdb_reload): New.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 13 Oct 2017 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRemove references to gdb64 in the testsuite
Pedro Alves [Thu, 12 Oct 2017 23:40:23 +0000 (00:40 +0100)] 
Remove references to gdb64 in the testsuite

I'm not sure whether this gdb64 was ever a thing in the upstream repo,
but it certainly doesn't exist nowadays.

AFAICT, this came in with the original big merge with the HP tree:
https://sourceware.org/ml/gdb-patches/1999-q2/msg00149.html

gdb/testsuite/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>

* gdb.base/attach.exp: Remove references to gdb64.
* gdb.base/dbx.exp: Remove references to gdb64.

6 years agoRemove is_remote check in labels.exp
Simon Marchi [Thu, 12 Oct 2017 22:14:09 +0000 (23:14 +0100)] 
Remove is_remote check in labels.exp

This works fine with remote target boards.

gdb/testsuite/ChangeLog:
2017-10-12  Simon Marchi  <simon.marchi@polymtl.ca>
    Pedro Alves  <palves@redhat.com>

* gdb.base/label.exp: Remove is_remote target check.

6 years agoMake gdb.base/auvx.exp work with --target_board=native-extended-gdbserver
Pedro Alves [Thu, 12 Oct 2017 22:06:15 +0000 (23:06 +0100)] 
Make gdb.base/auvx.exp work with --target_board=native-extended-gdbserver

Currently we get:
 Running .../src/gdb/testsuite/gdb.base/auxv.exp ...
 WARNING: can't generate a core file - core tests suppressed - check ulimit -c

After this commit we get all the same PASSes as when native testing.

The problem is that the testcase wants to create a core dump in a
temporary directory and it is using the "cd" command to start the
inferior with that directory as current directory, but that command
only affects the inferior's cwd when native debugging.  Fix it by
using using the new "set cwd" command instead, which works with
gdbserver as well.

This still won't work with stub-like targets, because with those when
we connect the inferior is already running.  It'd be possible to make
it work by making the inferior itself change dirs, but we'll need to
make the native-gdbserver board no longer set is_remote first.

gdb/testsuite/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>

* gdb.base/auvx.exp (coredir): Update comment.
(top level) <core_works>: Use "set cwd" command instead of "cd"
command.

6 years agoAdd a compile-time test for PR ld/22263
H.J. Lu [Thu, 12 Oct 2017 21:41:22 +0000 (14:41 -0700)] 
Add a compile-time test for PR ld/22263

This compile-time test requires a target C compiler to run.  It fails
on many targets where ELF backend linkers incorrectly check bfd_link_pic
for TLS relocations, which should check bfd_link_executable instead.

PR ld/22263
* testsuite/ld-elf/pr22263-1.rd: New file.
* testsuite/ld-elf/pr22263-1a.c: Likewise.
* testsuite/ld-elf/pr22263-1b.c: Likewise.
* testsuite/ld-elf/tls.exp: Likewise.

6 years agoUse bool in pv_area
Tom Tromey [Sun, 8 Oct 2017 02:13:42 +0000 (20:13 -0600)] 
Use bool in pv_area

This updates a couple of member functions in pv_area to return bool.

gdb/ChangeLog
2017-10-12  Tom Tromey  <tom@tromey.com>

* prologue-value.h (pv_area::store_would_trash): Return bool.
(pv_area::find_reg): Likewise.
* prologue-value.c (pv_area::store_would_trash): Return bool.
(pv_area::find_reg): Likewise.

6 years agoC++-ify prologue-value's pv_area
Tom Tromey [Sun, 8 Oct 2017 00:23:36 +0000 (18:23 -0600)] 
C++-ify prologue-value's pv_area

This patch is an initial C++-ification of pv_area, from
prologue-value.  It turns pv_area into a class with a constructor and
destructor; renames the data members; and changes various functions to
be member functions.  This allows the removal of
make_cleanup_free_pv_area.

gdb/ChangeLog
2017-10-12  Tom Tromey  <tom@tromey.com>

* s390-linux-tdep.c (s390_store, s390_load)
(s390_check_for_saved, s390_analyze_prologue): Update.
* rx-tdep.c (check_for_saved, rx_analyze_prologue): Update.
* rl78-tdep.c (rl78_analyze_prologue, check_for_saved): Update.
* prologue-value.h (class pv_area): Move from prologue-value.c.
Change names of members.  Add constructor, destructor, member
functions.
(make_pv_area, free_pv_area, make_cleanup_free_pv_area)
(pv_area_store, pv_area_fetch, pv_area_store_would_trash)
(pv_area_fetch, pv_area_scan): Don't declare.
* prologue-value.c (struct pv_area::area_entry): Now member of
pv_area.
(struct pv_area): Move to prologue-value.h.
(pv_area::pv_area): Rename from make_pv_area.
(pv_area::~pv_area): Rename from free_pv_area.
(do_free_pv_area_cleanup, make_cleanup_free_pv_area): Remove.
(clear_entries, find_entry, overlaps, store_would_trash, store)
(fetch, find_reg, scan): Now member of pv_area.
Remove "area" argument.  Update.
* msp430-tdep.c (check_for_saved, msp430_analyze_prologue):
Update.
* mn10300-tdep.c (push_reg, check_for_saved)
(mn10300_analyze_prologue): Update.
* mep-tdep.c (is_arg_spill, check_for_saved)
(mep_analyze_prologue): Update.
* m32c-tdep.c (m32c_pv_push, m32c_srcdest_fetch)
(m32c_srcdest_store, m32c_pv_enter, m32c_is_arg_spill)
(m32c_is_struct_return, m32c_analyze_prologue): Update.
* arm-tdep.c (thumb_analyze_prologue, arm_analyze_prologue):
Update.
* arc-tdep.c (arc_is_in_prologue, arc_analyze_prologue): Update.
* aarch64-tdep.c (aarch64_analyze_prologue): Update.

6 years agolinux low: Make the arch code free arch_process_info
Simon Marchi [Thu, 12 Oct 2017 20:49:27 +0000 (16:49 -0400)] 
linux low: Make the arch code free arch_process_info

For the same reason as the previous patch, we need to make the
arch-specific code free the arch_process_info structure it allocates.

gdb/gdbserver/ChangeLog:

* linux-low.h (struct linux_target_ops) <delete_process>: New
field.
* linux-low.c (linux_mourn): Call the_low_target.delete_process.
* linux-aarch64-low.c (aarch64_linux_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-arm-low.c (arm_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-bfin-low.c (struct linux_target_ops): Likewise.
* linux-crisv32-low.c (struct linux_target_ops): Likewise.
* linux-m32r-low.c (struct linux_target_ops): Likewise.
* linux-mips-low.c (mips_linux_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-ppc-low.c (struct linux_target_ops): Likewise.
* linux-s390-low.c (struct linux_target_ops): Likewise.
* linux-sh-low.c (struct linux_target_ops): Likewise.
* linux-tic6x-low.c (struct linux_target_ops): Likewise.
* linux-tile-low.c (struct linux_target_ops): Likewise.
* linux-x86-low.c (x86_linux_delete_process): New.
(struct linux_target_ops): Add delete_process callback.
* linux-xtensa-low.c (struct linux_target_ops): Likewise.

6 years agolwp_info: Make the arch code free arch_lwp_info
Simon Marchi [Thu, 12 Oct 2017 20:48:22 +0000 (16:48 -0400)] 
lwp_info: Make the arch code free arch_lwp_info

I have the goal of "poisoning" the XNEW/xfree-family of functions, so
that we catch their usages with non-POD types.  A few things need to be
fixed in the mean time, this is one.

The common lwp code in linux-nat.c and gdbserver/linux-low.c xfrees the
private lwp data of type arch_lwp_info.  However, that type is opaque
from its point of view, as its defined differently in each arch-specific
implementation.  This trips on the std::is_pod<T> check, since the
compiler can't tell whether the type is POD or not if it doesn't know
about it.

My initial patch [1] made a class hierarchy with a virtual destructor.
However, as Pedro pointed out, we only have one native architecture at
the time built in gdb and gdbserver, so that's overkill.  Instead, we
can move the responsibility of free'ing arch_lwp_info to the arch code
(which is also the one that allocated it in the first place).  This is
what this patch does.

Also, I had the concern that if we wanted to use C++ features in these
structures, we would have a problem with the one-definition rule.
However, since a build will only have one version of arch_lwp_info,
that's not a problem.

There are changes in arch-specific files, I was only able to built-test
this patch with the following cross-compilers:

  aarch64-linux-gnu
  alpha-linux-gnu
  arm-linux-gnueabihf
  hppa-linux-gnu
  m68k-linux-gnu
  mips64el-linux-gnuabi64
  powerpc64-linux-gnu
  s390x-linux-gnu
  sh4-linux-gnu
  sparc64-linux-gnu
  x86_64-linux-gnu
  x86_64-w64-mingw32

A buildbot run didn't find any regression.

[1] https://sourceware.org/ml/gdb-patches/2017-08/msg00255.html

gdb/ChangeLog:

* linux-nat.h (linux_nat_set_delete_thread): New declaration.
* linux-nat.c (linux_nat_delete_thread): New variable.
(lwp_free): Invoke linux_nat_delete_thread if set.
(linux_nat_set_delete_thread): New function.
* aarch64-linux-nat.c (_initialize_aarch64_linux_nat): Assign
thread delete callback.
* arm-linux-nat.c (arm_linux_delete_thread): New function.
(_initialize_arm_linux_nat): Assign thread delete callback.
* s390-linux-nat.c (s390_delete_thread): New function.
(_initialize_s390_nat): Assign thread delete callback.
* x86-linux-nat.c (x86_linux_add_target): Likewise.
* nat/aarch64-linux.c (aarch64_linux_delete_thread): New
function.
* nat/aarch64-linux.h (aarch64_linux_delete_thread): New
declaration.
* nat/x86-linux.c (x86_linux_delete_thread): New function.
* nat/x86-linux.h (x86_linux_delete_thread): New declaration.

gdb/gdbserver/ChangeLog:

* linux-aarch64-low.c (the_low_target): Add thread delete
callback.
* linux-arm-low.c (arm_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-bfin-low.c (the_low_target): Likewise.
* linux-crisv32-low.c (the_low_target): Likewise.
* linux-low.c (delete_lwp): Invoke delete_thread callback if
set.
* linux-low.h (struct linux_target_ops) <delete_thread>: New
field.
* linux-m32r-low.c (the_low_target): Add thread delete callback.
* linux-mips-low.c (mips_linux_delete_thread): New function.
(the_low_target): Add thread delete callback.
* linux-ppc-low.c (the_low_target): Likewise.
* linux-s390-low.c (the_low_target): Likewise.
* linux-sh-low.c (the_low_target): Likewise.
* linux-tic6x-low.c (the_low_target): Likewise.
* linux-tile-low.c (the_low_target): Likewise.
* linux-x86-low.c (the_low_target): Likewise.
* linux-xtensa-low.c (the_low_target): Likewise.

6 years agoRun gdb.base/catch-fork-static.exp on remote target boards
Pedro Alves [Thu, 12 Oct 2017 19:06:59 +0000 (20:06 +0100)] 
Run gdb.base/catch-fork-static.exp on remote target boards

Another case of a stale check.  We support following forks in the
remote protocol nowadays.

gdb/testsuite/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@polymtl.ca>

* gdb.base/catch-fork-static.exp: No longer skip on is_remote
target boards.

6 years agocheckpoint.exp: Check for non-"target native" instead of isnative/is_remote
Pedro Alves [Thu, 12 Oct 2017 18:54:34 +0000 (19:54 +0100)] 
checkpoint.exp: Check for non-"target native" instead of isnative/is_remote

This gets rid of a number of FAILs with
--target_board=native-extended-gdbserver.

The fact that checkpointing does not work has nothing to do with
dejagnu's native and remote concepts.  It only works with native Linux
targets because the implementation is currently baked with
linux-nat.c.

gdb/testsuite/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@polymtl.ca>

* gdb.base/checkpoint.exp: Don't check is_remote or isnative.
Instead skip if there's any gdb_protocol set.

6 years agoRemove is_remote target check from gdb.base/dprintf-non-stop.exp
Simon Marchi [Sun, 24 Jan 2016 16:22:24 +0000 (11:22 -0500)] 
Remove is_remote target check from gdb.base/dprintf-non-stop.exp

1. is_remote is not the right check.

2. Both Simon & Pedro ran it continuously for some time against
   native-gdbserver and didn't see a failure.

3. The test has been running against native-extended-gdbserver anyway.

gdb/testsuite/ChangeLog:
2017-10-12  Simon Marchi  <simon.marchi@polymtl.ca>
    Pedro Alves  <palves@redhat.com>

* gdb.base/dprintf-non-stop.exp: Remove is_remote target check.

6 years agoTighten remote check in gdb.base/argv0-symlink.exp
Pedro Alves [Thu, 12 Oct 2017 18:16:47 +0000 (19:16 +0100)] 
Tighten remote check in gdb.base/argv0-symlink.exp

Check for gdbserver instead of dejagnu remote.  Unlike what the
comment says, the test actually fails with target remote + gdbserver
(it does pass with extended-remote).  The result is:

 FAIL -> KFAIL with --target_board=native-gdbserver
 KPASS -> PASS with --target_board=native-extended-gdbserver

gdb/testsuite/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>
    Simon Marchi  <simon.marchi@polymtl.ca>

* gdb.base/argv0-symlink.exp: kfail on remote gdbserver,
instead of on dejagnu remote boards.

6 years agoEnable gdb.base/inferior-died.exp on is_remote target boards
Pedro Alves [Thu, 12 Oct 2017 17:36:08 +0000 (18:36 +0100)] 
Enable gdb.base/inferior-died.exp on is_remote target boards

We support follow-fork in the remote protocol nowadays.

Also, the right way to enable non-stop mode is to do it before
connecting, and for use_gdb_stub boards, that means we have to do it
at gdb_load time.  The "modern" pattern for that is to pass non-stop
in GDBFLAGS.

This makes the test pass with --target_board=native-gdbserver.

gdb/testsuite/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>
    Simon Marchi <simon.marchi@polymtl.ca>

* gdb.base/inferior-died.exp: Remove is_remote and isnative
checks.  Use build_executable + clean_restart instead of
prepare_for_testing.  Pass "set non-stop on" via GDBFLAGS instead
of enabling non-stop after starting gdb.

6 years agoEnable gdb.threads/non-ldr-exc-*.exp on is_remote target boards
Pedro Alves [Thu, 12 Oct 2017 17:05:33 +0000 (18:05 +0100)] 
Enable gdb.threads/non-ldr-exc-*.exp on is_remote target boards

This commit makes the gdb.threads/non-ldr-exc-*.exp tests run (and
pass) with --target_board=native-gdbserver.

(These tests were already running with
--target_board=native-extended-gdbserver, because that board is not
is_remote.)

The "No exec event support in the remote protocol." comment is stale.
It's actually supported.

gdb/ChangeLog:
2017-10-12  Pedro Alves  <palves@redhat.com>

* gdb.threads/non-ldr-exc-1.exp: No longer skip if is_remote target.
* gdb.threads/non-ldr-exc-2.exp: Ditto.
* gdb.threads/non-ldr-exc-3.exp: Ditto.
* gdb.threads/non-ldr-exc-4.exp: Ditto.

6 years agold whitespace fixes
Alan Modra [Thu, 12 Oct 2017 10:58:30 +0000 (21:28 +1030)] 
ld whitespace fixes

* pe-dll.c: Formatting, whitespace fixes.
* NEWS: Whitespace fixes.
* configure.ac: Likewise.
* configure.tgt: Likewise.
* deffilep.y: Likewise.
* genscripts.sh: Likewise.
* ld.texinfo: Likewise.
* ldgram.y: Likewise.
* ldlang.c: Likewise.
* ldlex.l: Likewise.
* lexsup.c: Likewise.
* plugin.c: Likewise.
* emulparams/arc-endianness.sh: Likewise.
* emulparams/elf32_x86_64.sh: Likewise.
* emulparams/elf64mmix.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/h8300elf.sh: Likewise.
* emulparams/h8300elf_linux.sh: Likewise.
* emulparams/vxworks.sh: Likewise.
* emultempl/aarch64elf.em: Likewise.
* emultempl/aix.em: Likewise.
* emultempl/armelf.em: Likewise.
* emultempl/avrelf.em: Likewise.
* emultempl/beos.em: Likewise.
* emultempl/hppaelf.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/m68kelf.em: Likewise.
* emultempl/metagelf.em: Likewise.
* emultempl/msp430.em: Likewise.
* emultempl/nds32elf.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/sh64elf.em: Likewise.
* emultempl/spu_ovl.S: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/tic6xdsbt.em: Likewise.
* emultempl/ticoff.em: Likewise.
* emultempl/vms.em: Likewise.
* po/Make-in: Likewise.
* scripttempl/DWARF.sc: Likewise.
* scripttempl/aix.sc: Likewise.
* scripttempl/alpha.sc: Likewise.
* scripttempl/alphavms.sc: Likewise.
* scripttempl/aout.sc: Likewise.
* scripttempl/arclinux.sc: Likewise.
* scripttempl/armaout.sc: Likewise.
* scripttempl/armbpabi.sc: Likewise.
* scripttempl/armcoff.sc: Likewise.
* scripttempl/avr.sc: Likewise.
* scripttempl/crisaout.sc: Likewise.
* scripttempl/delta68.sc: Likewise.
* scripttempl/dlx.sc: Likewise.
* scripttempl/elf.sc: Likewise.
* scripttempl/elf32cr16.sc: Likewise.
* scripttempl/elf32cr16c.sc: Likewise.
* scripttempl/elf32crx.sc: Likewise.
* scripttempl/elf32msp430.sc: Likewise.
* scripttempl/elf32msp430_3.sc: Likewise.
* scripttempl/elf32sh-symbian.sc: Likewise.
* scripttempl/elf32xc16x.sc: Likewise.
* scripttempl/elf32xc16xl.sc: Likewise.
* scripttempl/elf32xc16xs.sc: Likewise.
* scripttempl/elf64hppa.sc: Likewise.
* scripttempl/elf_chaos.sc: Likewise.
* scripttempl/elfarc.sc: Likewise.
* scripttempl/elfarcv2.sc: Likewise.
* scripttempl/elfd10v.sc: Likewise.
* scripttempl/elfd30v.sc: Likewise.
* scripttempl/elfi370.sc: Likewise.
* scripttempl/elfm68hc11.sc: Likewise.
* scripttempl/elfm68hc12.sc: Likewise.
* scripttempl/elfmicroblaze.sc: Likewise.
* scripttempl/elfxgate.sc: Likewise.
* scripttempl/elfxtensa.sc: Likewise.
* scripttempl/epiphany_4x4.sc: Likewise.
* scripttempl/epocpe.sc: Likewise.
* scripttempl/h8300.sc: Likewise.
* scripttempl/h8300h.sc: Likewise.
* scripttempl/h8300hn.sc: Likewise.
* scripttempl/h8300s.sc: Likewise.
* scripttempl/h8300sn.sc: Likewise.
* scripttempl/h8300sx.sc: Likewise.
* scripttempl/h8300sxn.sc: Likewise.
* scripttempl/h8500.sc: Likewise.
* scripttempl/h8500b.sc: Likewise.
* scripttempl/h8500c.sc: Likewise.
* scripttempl/h8500m.sc: Likewise.
* scripttempl/h8500s.sc: Likewise.
* scripttempl/hppaelf.sc: Likewise.
* scripttempl/i386beos.sc: Likewise.
* scripttempl/i386coff.sc: Likewise.
* scripttempl/i386go32.sc: Likewise.
* scripttempl/i386msdos.sc: Likewise.
* scripttempl/i860coff.sc: Likewise.
* scripttempl/i960.sc: Likewise.
* scripttempl/ia64vms.sc: Likewise.
* scripttempl/ip2k.sc: Likewise.
* scripttempl/iq2000.sc: Likewise.
* scripttempl/m68kaux.sc: Likewise.
* scripttempl/m68kcoff.sc: Likewise.
* scripttempl/m88kbcs.sc: Likewise.
* scripttempl/mcorepe.sc: Likewise.
* scripttempl/mep.sc: Likewise.
* scripttempl/mips.sc: Likewise.
* scripttempl/mipsbsd.sc: Likewise.
* scripttempl/mmo.sc: Likewise.
* scripttempl/moxie.sc: Likewise.
* scripttempl/nds32elf.sc: Likewise.
* scripttempl/nw.sc: Likewise.
* scripttempl/pe.sc: Likewise.
* scripttempl/pep.sc: Likewise.
* scripttempl/pj.sc: Likewise.
* scripttempl/ppcpe.sc: Likewise.
* scripttempl/psos.sc: Likewise.
* scripttempl/riscix.sc: Likewise.
* scripttempl/sh.sc: Likewise.
* scripttempl/sparccoff.sc: Likewise.
* scripttempl/st2000.sc: Likewise.
* scripttempl/tic30aout.sc: Likewise.
* scripttempl/tic30coff.sc: Likewise.
* scripttempl/tic4xcoff.sc: Likewise.
* scripttempl/tic54xcoff.sc: Likewise.
* scripttempl/tic80coff.sc: Likewise.
* scripttempl/v850.sc: Likewise.
* scripttempl/v850_rh850.sc: Likewise.
* scripttempl/vanilla.sc: Likewise.
* scripttempl/visium.sc: Likewise.
* scripttempl/w65.sc: Likewise.
* scripttempl/xstormy16.sc: Likewise.
* scripttempl/z80.sc: Likewise.
* scripttempl/z8000.sc: Likewise.
* configure: Regenerate.

6 years agoForce the AArch64 linker backend to refuse to link when it encounters unresoleable...
Nick Clifton [Thu, 12 Oct 2017 12:38:20 +0000 (13:38 +0100)] 
Force the AArch64 linker backend to refuse to link when it encounters unresoleable relocations.

* reloc.c (enum bfd_reloc_status): Start values at 2.
* bfd-in2.h: Regenerate.
* elfnn-aarch64.c (aarch64_relocate): Invert sense of function, so
that a TRUE return indicates success.  Compare the result of
calling _bfd_aarch64_elf_put_addend against bfd_reloc_ok.
(build_one_stub): Change sense of tests against aarch64_relocate
return value.
(elfNN_aarch64_tls_relax): Return bfd_reloc_notsupported, rather
than FALSE, when an error is detected.
(elfNN_aarch64_final_link_relocate): Likewise.

* testsuite/ld-aarch64/pcrel_pic_defined.d: Expect errors not
warnings.  Expect errors about unsupported relocations.
* testsuite/ld-aarch64/pcrel_pic_undefined.d: Likewise.

6 years agox86: Add _bfd_x86_elf_hide_symbol
H.J. Lu [Thu, 12 Oct 2017 09:12:47 +0000 (02:12 -0700)] 
x86: Add _bfd_x86_elf_hide_symbol

When there is no dynamic interpreter in PIE, make the undefined weak
symbol dynamic so that PC relative branch to the undefined weak symbol
will land to address 0.

* elf32-i386.c (elf_backend_hide_symbol): New.
* elf64-x86-64.c (elf_backend_hide_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_hide_symbol): Likewise.
* elfxx-x86.h (_bfd_x86_elf_hide_symbol): Likewise.

6 years agold: Update tests for warning of "-z dynamic-undefined-weak ignored"
H.J. Lu [Thu, 12 Oct 2017 08:52:33 +0000 (01:52 -0700)] 
ld: Update tests for warning of "-z dynamic-undefined-weak ignored"

Update tests to expect warning of "-z dynamic-undefined-weak ignored"
from

commit 22b1ee183d19a92cc57859c04307d31c06792d13
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Oct 12 13:19:10 2017 +1030

    Set dynamic_undefined_weak to zero for static PIEs

* testsuite/ld-elf/pr22269b.d: Expect warning of
"-z dynamic-undefined-weak ignored".
* testsuite/ld-i386/pr19636-1j.d: Likewise.
* testsuite/ld-i386/pr19636-1k.d: Likewise.
* testsuite/ld-i386/pr19636-1l.d: Likewise.
* testsuite/ld-x86-64/pr19636-2j.d: Likewise.
* testsuite/ld-x86-64/pr19636-2k.d: Likewise.
* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
* testsuite/ld-x86-64/pr19636-2m.d: Likewise.

6 years agoSet dynamic_undefined_weak to zero for static PIEs
Alan Modra [Thu, 12 Oct 2017 02:49:10 +0000 (13:19 +1030)] 
Set dynamic_undefined_weak to zero for static PIEs

I believe we should be warning if ld is given both --no-dynamic-linker
and -z dynamic-undefined-weak.  The two options are contradictory, the
first says an executable has no dynamic interpreter to resolve dynamic
symbols, while the second is asking for dynamic symbols to be emitted.
(And even if a static PIE's relocation code, which is needed to
process R_*_RELATIVE relocs, could process symbols, there are no
DT_NEEDED dynamic objects to define such symbols.)

I also think that dynamic_undefined_weak is the right flag to control
whether undefined weaks are made dynamic, whether in static PIEs or
anywhere else.  So force it to 0 for static PIEs, fixing PR 22269 for
powerpc and any other target where the backend usually defaults to
undefined weaks being made dynamic.

This patch introduces regressions.  I'd normally not do that, but
these are all in very recently added test cases, or expose bugs in the
x86 backend.  The test cases were added after I'd made it known that
this patch or one like it was imminent.

PR 22269
* emultempl/elf32.em (after_parse): Warn on --no-dynamic-linker
-z dynamic-undefined-weak combination.  Set dynamic_undefined_weak
to zero when nointerp.

6 years ago_bfd_elf_link_hash_hide_symbol calls in generic ELF code
Alan Modra [Wed, 11 Oct 2017 22:31:54 +0000 (09:01 +1030)] 
_bfd_elf_link_hash_hide_symbol calls in generic ELF code

This function shouldn't be called directly, except from backend code.

bfd/
* elflink.c (_bfd_elf_adjust_dynamic_symbol): Call
elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol.
(bfd_elf_define_start_stop): Likewise.
ld/
* emultempl/elf32.em (before_allocation): Call
elf_backend_hide_symbol, not _bfd_elf_link_hash_hide_symbol.
Formatting.

6 years agoFix remaining targets using wrong .interp conditions
Alan Modra [Wed, 11 Oct 2017 12:13:42 +0000 (22:43 +1030)] 
Fix remaining targets using wrong .interp conditions

* elf32-nds32.c (nds32_elf_size_dynamic_sections): Set .interp
when executable rather than non-PIC.
* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 12 Oct 2017 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRemove cleanups from TUI
Tom Tromey [Tue, 10 Oct 2017 01:13:31 +0000 (19:13 -0600)] 
Remove cleanups from TUI

This removes the last cleanups from the TUI, by using std::string
rather than manual memory management.

Regression tested against gdb.tui/*.exp on Fedora 26 x86-64.

gdb/ChangeLog
2017-10-09  Tom Tromey  <tom@tromey.com>

* tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use
std::string.
* tui/tui-layout.c (enum tui_status): Use std::string.

6 years agoConstify add_prefix_cmd
Tom Tromey [Tue, 26 Sep 2017 04:28:30 +0000 (22:28 -0600)] 
Constify add_prefix_cmd

This changes add_prefix_cmd to accept a const-taking function as an
argument; then fixes up all the callers.

In a couple of spots I had to add a non-const overload of a function,
because the function is passed to two different command-adding
"constructors".  These overloads are temporary; once constification is
complete they can be removed.

This patch also fixes a typo I happened to notice while constifying.

Note that this touches a couple of files (gnu-nat.c and go32-nat.c)
that I can't build.  So, while I made a best-effort there, I am not
certain they will still compile.

Tested by rebuilding.

gdb/ChangeLog
2017-10-11  Tom Tromey  <tom@tromey.com>

* gdbthread.h (thread_command): Constify.
* inferior.h (detach_command): Constify.
* top.h (set_history, show_history): Constify.
* arm-tdep.c (set_arm_command, show_arm_command): Constify.
* serial.c (serial_set_cmd, serial_show_cmd): Constify.
* bsd-kvm.c (bsd_kvm_cmd): Constify.
* printcmd.c (set_command): Constify.
(non_const_set_command): New function.
* dcache.c (set_dcache_command, show_dcache_command): Constify.
* breakpoint.c (enable_command, disable_command, delete_command)
(catch_command, tcatch_command, set_breakpoint_cmd)
(show_breakpoint_cmd): Constify.
* macrocmd.c (macro_command): Constify.
* infcmd.c (unset_command, kill_command, detach_command)
(info_proc_cmd): Constify.
* i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Constify.
* auto-load.c (show_auto_load_cmd, set_auto_load_cmd)
(info_auto_load_cmd): Constify.
* target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd)
(unset_tdesc_cmd): Constify.
* ada-lang.c (set_ada_command, show_ada_command)
(maint_set_ada_cmd, maint_show_ada_cmd): Constify.
* guile/guile.c (set_guile_command, show_guile_command)
(info_guile_command): Constify.
* tui/tui-win.c (tui_command, set_tui_cmd, show_tui_cmd):
Constify.
* skip.c (skip_command): Constify.
* compile/compile.c (_initialize_compile): Constify.
* dwarf2read.c (set_dwarf_cmd, show_dwarf_cmd): Constify.
* btrace.c (maint_btrace_cmd, maint_btrace_set_cmd)
(maint_btrace_show_cmd, maint_btrace_pt_set_cmd)
(maint_btrace_pt_show_cmd): Constify.
* remote.c (set_remote_cmd, show_remote_cmd, remote_command):
Constify.
* python/python.c (user_show_python, user_set_python): Constify.
* mips-tdep.c (set_mips_command, show_mips_command)
(set_mipsfpu_command): Constify.
* record-btrace.c (cmd_record_btrace_start)
(cmd_set_record_btrace, cmd_show_record_btrace)
(cmd_set_record_btrace_bts, cmd_show_record_btrace_bts)
(cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): Constify.
* rs6000-tdep.c (set_powerpc_command, show_powerpc_command):
Constify.
* symfile.c (overlay_command): Constify.
* spu-tdep.c (set_spu_command, show_spu_command): Constify.
* cli/cli-logging.c (set_logging_command, show_logging_command):
Constify.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, verilog_dump_command)
(tekhex_dump_command, binary_dump_command)
(binary_append_command): Constify.
* cli/cli-decode.c (struct cmd_list_element): Change type of
"fun".
* cli/cli-cmds.c (info_command, show_command, set_debug)
(show_debug): Constify.
(show_command): Add non-const overload.
* top.c (set_history, show_history): Constify.
* sh-tdep.c (set_sh_command, show_sh_command): Constify.
* command.h (add_prefix_cmd): Accept a cmd_const_cfunc_ftype.
* target.c (target_command): Constify.
* sparc64-tdep.c (info_adi_command): Constify.
* record-full.c (cmd_record_full_start): Constify.
(set_record_full_command): Constify.  Fix typo.
(show_record_full_command): Constify.
* thread.c (thread_command, thread_apply_command): Constify.
* memattr.c (dummy_cmd): Constify.
* value.c (function_command): Constify.
* frame.c (set_backtrace_cmd, show_backtrace_cmd): Constify.
* probe.c (info_probes_command): Constify.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Constify.
* gnu-nat.c (set_task_cmd, show_task_cmd, set_thread_cmd)
(show_thread_cmd, set_thread_default_cmd)
(show_thread_default_cmd): Constify.
(check_empty): Constify.
* tracepoint.c (tfind_command): Constify.
* cp-support.c (maint_cplus_command): Constify.
* windows-tdep.c (info_w32_command): Constify.
* record.c (cmd_record_start, set_record_command)
(show_record_command, info_record_command, cmd_record_goto):
Constify.
* ravenscar-thread.c (set_ravenscar_command)
(show_ravenscar_command): Constify.
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Constify.
(add_internal_problem_command): Remove casts.
* arc-tdep.c (maintenance_print_arc_command): Constify.
* valprint.c (set_print, show_print, set_print_raw)
(show_print_raw): Constify.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd)
(maintenance_show_cmd, set_per_command_cmd)
(show_per_command_cmd, maintenance_check_command): Constify.
* language.c (set_check, show_check): Constify.
* typeprint.c (show_print_type, set_print_type): Constify.
* go32-nat.c (go32_info_dos_command): Constify.

6 years agoRemove prepare_re_set_context
Tom Tromey [Sun, 8 Oct 2017 20:03:41 +0000 (14:03 -0600)] 
Remove prepare_re_set_context

prepare_re_set_context returns a null cleanup and doesn't seem
generally useful.  This patch removes it plus a few more cleanups; and
changes breakpoint_re_set to use scoped_restore rather than its own
manual mechanism.

2017-10-11  Tom Tromey  <tom@tromey.com>

* breakpoint.c (prepare_re_set_context): Remove.
(breakpoint_re_set_one): Update.  Don't use cleanups.
(breakpoint_re_set): Use scoped_restore, std::string, and
scoped_restore_current_language.

6 years agoRemove some cleanups from breakpoint.c
Tom Tromey [Sun, 8 Oct 2017 19:58:07 +0000 (13:58 -0600)] 
Remove some cleanups from breakpoint.c

This removes some cleanups from breakpoint.c, replacing them with C++
data structures.

2017-10-11  Tom Tromey  <tom@tromey.com>

* breakpoint.c (commands_command_1): Use std::string.
(cleanup_executing_breakpoints): Remove.
(bpstat_do_actions_1): Use scoped_restore.
(bpstat_check_watchpoint): Use std::string.
(decode_static_tracepoint_spec): Likewise.
(break_range_command): Likewise.
(watch_command_1): Likewise.
(compare_breakpoints): Change argument types.
(clear_command): Use std::vector.
(cleanup_executing_breakpoints): Remove.
(update_global_location_list): Use unique_xmalloc_ptr.
(strace_command): Remove unused declaration.

This page took 0.059865 seconds and 4 git commands to generate.