deliverable/binutils-gdb.git
6 years agoMake abbrev_table::abbrevs private
Yao Qi [Thu, 18 Jan 2018 15:29:31 +0000 (15:29 +0000)] 
Make abbrev_table::abbrevs private

abbrev_table::abbrevs is only access within abbrev_table's methods, so
it can be private.  Add "m_" prefix.

gdb:

2018-01-18  Yao Qi  <yao.qi@linaro.org>

* dwarf2read.c (abbrev_table) <abbrevs>: Rename it to
m_abbrevs.
(abbrev_table::add_abbrev): Update.
(abbrev_table::lookup_abbrev): Update.

6 years agoCall cooked_read in ppu2spu_prev_register
Yao Qi [Thu, 18 Jan 2018 12:21:01 +0000 (12:21 +0000)] 
Call cooked_read in ppu2spu_prev_register

The code in ppu2spu_prev_register is in fact regcache_cooked_read,
because spu doesn't have gdbarch method pseudo_register_read_value.

gdb:

2018-01-18  Yao Qi  <yao.qi@linaro.org>

* ppc-linux-tdep.c (ppu2spu_prev_register): Call cooked_read.

6 years agoPowerPC PLT stub alignment fixes
Alan Modra [Thu, 18 Jan 2018 11:36:40 +0000 (22:06 +1030)] 
PowerPC PLT stub alignment fixes

Asking for ppc32 plt call stubs to be aligned at 32 byte boundaries
didn't quite work.  For ld.bfd they were spaced 32 bytes apart, but
only started on a 16 byte boundary.  ld.gold also didn't get it right.

Finding that bug made me check over the ppc64 plt stub alignment,
where I found that negative values for alignment (meaning align to
minimize boundary crossing) were not accepted.  Since no one has
complained about that, I guess I could have removed the feature from
ld.bfd documentation, but I've opted instead to correct the code.

I've also added an optional alignment paramenter for ppc32
--plt-align, for some consistency with gold and ppc64 ld.bfd.

bfd/
* elf32-ppc.c (ppc_elf_create_glink): Correct alignment of .glink.
* elf64-ppc.c (ppc64_elf_size_stubs): Handle negative plt_stub_align.
(ppc64_elf_build_stubs): Likewise.
gold/
* powerpc.cc (param_plt_align): New function supplying default
--plt-align values.  Use it..
(Stub_table::plt_call_align): ..here, and..
(Output_data_glink::global_entry_align): ..here.
(Stub_table::stub_align): Correct 32-bit minimum alignment.
ld/
* emultempl/ppc32elf.em: Support optional --plt-align arg.
* emultempl/ppc64elf.em: Support negative --plt-align arg.

6 years agoUpdate Bulgarian translation of the binutils sub-directory
Nick Clifton [Thu, 18 Jan 2018 09:38:59 +0000 (09:38 +0000)] 
Update Bulgarian translation of the binutils sub-directory

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 18 Jan 2018 00:00:24 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoFix warning on gdb/compile/compile.c (C++-ify "triplet_rx")
Sergio Durigan Junior [Tue, 16 Jan 2018 19:41:17 +0000 (14:41 -0500)] 
Fix warning on gdb/compile/compile.c (C++-ify "triplet_rx")

This fixes a GCC warning that happens when compiling
gdb/compile/compile.c on some GCC versions (e.g., "gcc (GCC) 7.2.1
20180104 (Red Hat 7.2.1-6)"):

../../gdb/compile/compile.c: In function 'void eval_compile_command(command_line*, const char*, compile_i_scope_types, void*)':
../../gdb/compile/compile.c:548:19: warning: 'triplet_rx' may be used uninitialized in this function [-Wmaybe-uninitialized]
     error_message = compiler->fe->ops->set_arguments_v0 (compiler->fe, triplet_rx,
     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         argc, argv);
         ~~~~~~~~~~~
../../gdb/compile/compile.c:466:9: note: 'triplet_rx' was declared here
   char *triplet_rx;
         ^~~~~~~~~~

It's a simple patch that converts "triplet_rx" from "char *" to
"std::string", thus guaranteeing that it will be always initialized.

I've regtested this patch and did not find any regressions.  OK to
apply on both master and 8.1 (after creating a bug for it)?

gdb/ChangeLog:
2018-01-17  Sergio Durigan Junior  <sergiodj@redhat.com>

* compile/compile.c (compile_to_object): Convert "triplet_rx"
to "std::string".

6 years agoRISC-V: Fix bug in prior addi/c.nop patch.
Jim Wilson [Wed, 17 Jan 2018 22:04:16 +0000 (14:04 -0800)] 
RISC-V: Fix bug in prior addi/c.nop patch.

gas/
* config/tc-riscv.c (validate_riscv_insn) <'z'>: New.
(riscv_ip) <'z'>: New.
opcodes/
* riscv-opc.c (riscv_opcodes) <addi>: Use z instead of 0.

6 years agoRemove symbolp typedef
Tom Tromey [Sat, 6 Jan 2018 00:26:21 +0000 (17:26 -0700)] 
Remove symbolp typedef

This removes the symbolp typedef from dwarf2read.c.  It is no longer
used.

2018-01-17  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (symbolp): Remove typedef.  Don't instantiate VEC.

6 years agoRemove objfile argument from add_dyn_prop
Tom Tromey [Sat, 6 Jan 2018 00:26:20 +0000 (17:26 -0700)] 
Remove objfile argument from add_dyn_prop

The objfile argument to add_dyn_prop is redundant, so this patch
removes it.

2018-01-17  Tom Tromey  <tom@tromey.com>

* gdbtypes.h (add_dyn_prop): Remove objfile parameter.
* gdbtypes.c (add_dyn_prop): Remove objfile parameter.
(create_array_type_with_stride): Update.
* dwarf2read.c (set_die_type): Update.

6 years agoChange dwarf2_cu::method_info to be a std::vector
Tom Tromey [Sat, 6 Jan 2018 00:26:19 +0000 (17:26 -0700)] 
Change dwarf2_cu::method_info to be a std::vector

This changes the type of dwarf2_cu::method_info and fixes up the uses.
In order to remove cleanups from process_full_comp_unit and
process_full_type_unit, psymtab_include_file_name also had to be
changed to avoid leaving dangling cleanups.

2018-01-17  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (delayed_method_info): Remove typedef.
(dwarf2_cu::method_info): Now a std::vector.
(add_to_method_list): Update.
(free_delayed_list): Remove.
(compute_delayed_physnames): Update.
(process_full_comp_unit, process_full_type_unit): Clear the method
list.  Remove cleanups.
(psymtab_include_file_name): Add name_holder parameter.  Use
unique_xmalloc_ptr.
(dwarf_decode_lines): Update.

6 years agoAllocate dwarf2_cu with new
Simon Marchi [Sun, 7 Jan 2018 16:41:09 +0000 (11:41 -0500)] 
Allocate dwarf2_cu with new

This changes dwarf2_cu to be allocated with new, and fixes up the
users.

2018-01-17  Tom Tromey  <tom@tromey.com>
    Simon Marchi  <simon.marchi@ericsson.com>

* dwarf2read.c (struct dwarf2_cu): Add constructor, destructor.
(dwarf2_per_objfile::free_cached_comp_units)
(init_tu_and_read_dwo_dies, init_cutu_and_read_dies)
(init_cutu_and_read_dies_no_follow): Update.
(dwarf2_cu::dwarf2_cu): Rename from init_one_comp_unit.
(dwarf2_cu::~dwarf2_cu): New.
(free_heap_comp_unit, free_stack_comp_unit): Remove.
(age_cached_comp_units, free_one_cached_comp_unit): Update.

6 years agoAllocate abbrev_table with new
Tom Tromey [Sat, 6 Jan 2018 00:26:17 +0000 (17:26 -0700)] 
Allocate abbrev_table with new

This changes dwarf2read.c to allocate abbrev tables using "new", and
then updates the users.

This version of the patch incorporates the changes that Simon
implemented.  These changes simplify the ownership rules for abbrev
tables.

2018-01-17  Tom Tromey  <tom@tromey.com>
    Simon Marchi  <simon.marchi@ericsson.com>

* dwarf2read.c (struct dwarf2_cu) <abbrev_table>: Remove.
(struct die_reader_specs) <abbrev_table>: New member.
(struct abbrev_table): Add constructor.
<alloc_abbrev, add_abbrev, lookup_abbrev>: Declare.
<abbrev_obstack>: Now an auto_obstack.
(abbrev_table_up): New typedef.
(init_cu_die_reader): Add abbrev_table parameter.
(read_cutu_die_from_dwo): Remove abbrev_table_provided parameter.
Add result_dwo_abbrev_table.
(init_tu_and_read_dwo_dies, init_cutu_and_read_dies)
(init_cutu_and_read_dies_no_follow, build_type_psymtabs_1):
Update.
(peek_die_abbrev): Take die_reader_specs, not dwarf_cu as
parameter.
(skip_children): Update.
(abbrev_table::alloc_abbrev): Rename from
abbrev_table_alloc_abbrev.
(abbrev_table::add_abbrev): Rename from abbrev_table_add_abbrev.
(abbrev_table::lookup_abbrev): Rename from
abbrev_table_lookup_abbrev.
(abbrev_table_read_table): Return abbrev_table_up.
(abbrev_table_free, abbrev_table_free_cleanup)
(dwarf2_read_abbrevs, dwarf2_free_abbrev_table): Remove.
(load_partial_dies): Update.

6 years agoUnify new_symbol and new_symbol_full
Tom Tromey [Sat, 6 Jan 2018 00:26:16 +0000 (17:26 -0700)] 
Unify new_symbol and new_symbol_full

This patch unifies new_symbol with new_symbol_full, replacing a
wrapper function with a default parameter.

2018-01-17  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (dwarf2_compute_name): Update comment.
(read_func_scope, read_variable): Update.
(new_symbol): Remove.
(new_symbol_full): Rename to new_symbol.

6 years agoFix ChangeLog dates of previous commit
Simon Marchi [Wed, 17 Jan 2018 17:59:51 +0000 (12:59 -0500)] 
Fix ChangeLog dates of previous commit

6 years agoFix gdb segv when objfile can't be opened
Mike Gulick [Mon, 30 Oct 2017 22:13:44 +0000 (18:13 -0400)] 
Fix gdb segv when objfile can't be opened

This fixes PR 16577.

This patch changes gdb_bfd_map_section to issue a warning rather than an error
if it is unable to read the object file, and sets the size of the section/frame
that it attempted to read to 0 on error.

The description of gdb_bfd_map_section states that it will try to read or map
the contents of the section SECT, and if successful, the section data is
returned and *SIZE is set to the size of the section data.  This function was
throwing an error and leaving *SIZE as-is.  Setting the section size to 0
indicates to dwarf2_build_frame_info that there is no data to read, otherwise
it will try to read from an invalid frame pointer.

Changing the error to a warning allows this to be handled gracefully.
Additionally, the error was clobbering the breakpoint output indicating the
current frame (function name, arguments, source file, and line number).  E.g.

Thread 3 "foo" hit Breakpoint 1, BFD: reopening /tmp/jna-1013829440/jna2973250704389291330.tmp: No such file or directory
BFD: reopening /tmp/jna-1013829440/jna2973250704389291330.tmp: No such file or directory
(gdb)

While the "BFD: reopening ..." messages will still appear interspersed in the
breakpoint output, the current frame info is now displayed:

Thread 3 "foo" hit Breakpoint 1, BFD: reopening /tmp/jna-1013829440/jna1875755897659885075.tmp: No such file or directory
BFD: reopening /tmp/jna-1013829440/jna1875755897659885075.tmp: No such file or directory
warning: Can't read data for section '.eh_frame' in file '/tmp/jna-1013829440/jna1875755897659885075.tmp'
do_something () at file.cpp:80
80 {
(gdb)

6 years agoMake linux_ptrace_attach_fail_reason return an std::string
Simon Marchi [Wed, 17 Jan 2018 17:33:57 +0000 (12:33 -0500)] 
Make linux_ptrace_attach_fail_reason return an std::string

This patch makes linux_ptrace_attach_fail_reason and
linux_ptrace_attach_fail_reason_string return std::string.  It also
replaces usages of struct buffer with std::string.  This allows getting
rid of a cleanup in in linux_ptrace_attach_fail_reason_string and
simplifies the code in general.

Something that looks odd to me is that in
linux_ptrace_attach_fail_reason, if the two messages are appended, there
is no separating space or \n, so the result won't be very nice.  I left
it as-is for now though.

gdb/ChangeLog:

* nat/linux-ptrace.h (linux_ptrace_attach_fail_reason): Return
std::string.
(linux_ptrace_attach_fail_reason_string): Likewise.
* nat/linux-ptrace.c (linux_ptrace_attach_fail_reason):
Likewise.
(linux_ptrace_attach_fail_reason_string): Likewise.
* linux-nat.c (attach_proc_task_lwp_callback): Adjust.

gdb/gdbserver/ChangeLog:

* linux-low.c (attach_proc_task_lwp_callback): Adjust to
linux_ptrace_attach_fail_reason_string now returning an
std::string.
(linux_attach): Likewise.
* thread-db.c (attach_thread): Likewise.

6 years agolinux-nat: Remove unnecessary xstrdup
Simon Marchi [Wed, 17 Jan 2018 17:33:45 +0000 (12:33 -0500)] 
linux-nat: Remove unnecessary xstrdup

I think this xstrdup is not useful.  We can pass ex.message directly to
throw_error instead.

gdb/ChangeLog:

* linux-nat.c (linux_nat_attach): Remove xstrdup.

6 years agoReplace CET bit with IBT and SHSTK bits.
Igor Tsimbalist [Wed, 17 Jan 2018 16:45:52 +0000 (19:45 +0300)] 
Replace CET bit with IBT and SHSTK bits.

The latest specification for Intel CET technology defined two
new bits instead of previously used CET bit. These are IBT and
SHSTK bits. The patch replaces CET bit with IBT and SHSTK bits.

gas/
* config/tc-i386.c (cpu_arch): Delete .cet. Add .ibt, .shstk.
(cpu_noarch): Add noibt, noshstk.
(parse_insn): Change cpucet to cpuibt.
* doc/c-i386.texi: Delete .cet. Add .ibt, .shstk.
* testsuite/gas/i386/cet-ibt-inval.l: New test.
* testsuite/gas/i386/cet-ibt-inval.s: Likewise.
* testsuite/gas/i386/cet-shstk-inval.l: Likewise.
* testsuite/gas/i386/cet-shstk-inval.s: Likewise.
* testsuite/gas/i386/x86-64-cet-ibt-inval.l: Likewise.
* testsuite/gas/i386/x86-64-cet-ibt-inval.s: Likewise.
* testsuite/gas/i386/x86-64-cet-shstk-inval.l: Likewise.
* testsuite/gas/i386/x86-64-cet-shstk-inval.s: Likewise.

opcodes/
* i386-gen.c (cpu_flag_init): Delete CPU_CET_FLAGS,
CpuCET. Add CPU_IBT_FLAGS, CPU_SHSTK_FLAGS, CPY_ANY_IBT_FLAGS,
CPU_ANY_SHSTK_FLAGS, CpuIBT, CpuSHSTK.
(cpu_flags): Add CpuIBT, CpuSHSTK.
* i386-opc.h (enum): Add CpuIBT, CpuSHSTK.
(i386_cpu_flags): Add cpuibt, cpushstk.
* i386-opc.tbl: Change CpuCET to CpuSHSTK and CpuIBT.
* i386-init.h: Regenerate.
* i386-tbl.h: Likewise.

6 years agoUpdate Ukranian and Russian translations in bfd library
Nick Clifton [Wed, 17 Jan 2018 15:52:37 +0000 (15:52 +0000)] 
Update Ukranian and Russian translations in bfd library

6 years agoconfigure: Fix test for fs_base/gs_base in <sys/user.h>
Eldar Abusalimov [Mon, 15 Jan 2018 13:57:42 +0000 (16:57 +0300)] 
configure: Fix test for fs_base/gs_base in <sys/user.h>

Make <sys/types.h> be included prior to including <sys/user.h>.

glibc versions older than 2.14 use __uintNN_t types within certain
structures defined in <sys/user.h> probably assuming these types are
defined prior to including the header. This results in the following
`configure` feature test compilation error that makes it think that
`struct user_regs_struct` doesn't have `fs_base`/`gs_base` fields,
althouh it does.

    configure:13617: checking for struct user_regs_struct.fs_base
    configure:13617: gcc -c -g -O2 -I/linux/include conftest.c >&5
    In file included from conftest.c:158:0:
    /usr/include/sys/user.h:32:3: error: unknown type name '__uint16_t'
       __uint16_t  cwd;
       ^
    /usr/include/sys/user.h:33:3: error: unknown type name '__uint16_t'
       __uint16_t  swd;
       ^
    /usr/include/sys/user.h:34:3: error: unknown type name '__uint16_t'
       __uint16_t  ftw;
       ^
    /usr/include/sys/user.h:35:3: error: unknown type name '__uint16_t'
       __uint16_t  fop;
       ^
    /usr/include/sys/user.h:36:3: error: unknown type name '__uint64_t'
       __uint64_t  rip;
       ^
    /usr/include/sys/user.h:37:3: error: unknown type name '__uint64_t'
       __uint64_t  rdp;
       ^
    /usr/include/sys/user.h:38:3: error: unknown type name '__uint32_t'
       __uint32_t  mxcsr;
       ^
    /usr/include/sys/user.h:39:3: error: unknown type name '__uint32_t'
       __uint32_t  mxcr_mask;
       ^
    /usr/include/sys/user.h:40:3: error: unknown type name '__uint32_t'
       __uint32_t  st_space[32];   /* 8*16 bytes for each FP-reg = 128 bytes */
       ^
    /usr/include/sys/user.h:41:3: error: unknown type name '__uint32_t'
       __uint32_t  xmm_space[64];  /* 16*16 bytes for each XMM-reg = 256 bytes */
       ^
    /usr/include/sys/user.h:42:3: error: unknown type name '__uint32_t'
       __uint32_t  padding[24];
       ^
    configure:13617: $? = 1
    configure: failed program was:
    | /* confdefs.h */
    ...
    | /* end confdefs.h.  */
    | #include <sys/user.h>
    |
    | int
    | main ()
    | {
    | static struct user_regs_struct ac_aggr;
    | if (ac_aggr.fs_base)
    | return 0;
    |   ;
    |   return 0;
    | }

Recent glibc versions don't use typedef'ed int types in <sys/user.h>,
thus allowing it to be included as is
(glibc commit d79a9c949c84e7f0ba33e87447c47af833e9f11a).
However there're still some distros alive that use older glibc,
for instance, RHEL/CentOS 6 package glibc 2.12.

Also affects PR gdb/21559:

    ../../gdb/regcache.c:1087: internal-error: void regcache_raw_supply(regcache, int, const void): Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.

As noted by Andrew Paprocki, who submitted the PR
(https://sourceware.org/bugzilla/show_bug.cgi?id=21559#c3):

    > It should be noted that modifying `configure` to force on
    > `HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE` and
    > `HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE` fixes this issue. For some
    > reason the `configure` tests for `fs_base` and `gs_base` fail
    > even though `sys/user.h` on RHEL5 has the fields defined in
    > `user_regs_struct`.

Note that this patch does NOT fix the root cause of PR gdb/21559,
although now that `configure` properly detects the presence of the
fields and sets HAVE_XXX accordingly, the execution takes another
path, which doesn't lead to the assertion failure in question.

gdb/ChangeLog:
2018-01-17  Eldar Abusalimov  <eldar.abusalimov@jetbrains.com>

PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2018-01-17  Eldar Abusalimov  <eldar.abusalimov@jetbrains.com>

PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.

6 years agoDon't pass -m64 to libcc1 on aarch64-linux.
Yao Qi [Wed, 17 Jan 2018 12:48:52 +0000 (12:48 +0000)] 
Don't pass -m64 to libcc1 on aarch64-linux.

Nowadays, if we use "compile" on aarch64-linux, we'll get the following
error,

(gdb) compile code -- ;
aarch64-none-linux-gnu-gcc: error: unrecognized command line option '-m64'

because the default gcc_target_options returns "-m64" and
"-mcmodel=large", neither is useful to aarch64-linux.

gdb:

2018-01-17  Yao Qi  <yao.qi@linaro.org>

* aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): New
function.
(aarch64_linux_init_abi): Install it to gdbarch hook
gcc_target_options.

6 years agoRelax gdb.compile/compile.exp to match the address printed for frame
Yao Qi [Wed, 17 Jan 2018 11:19:03 +0000 (11:19 +0000)] 
Relax gdb.compile/compile.exp to match the address printed for frame

One test in gdb.compile/compile.exp passes on one fedora builder,

 bt
 #0  0x00007ffff7ff43f6 in _gdb_expr (__regs=0x7ffff7ff2000) at gdb
 command line:1^M
 #1  <function called from gdb>^M
 #2  main () at /home/gdb-buildbot/fedora-x86-64-1/fedora-x86-64/build/gdb/testsuite/../../../binutils-gdb/gdb/testsuite/gdb.compile/compile.c:106^M
 (gdb) PASS: gdb.compile/compile.exp: bt

but fails on my machine with gcc trunk,

 bt^M
 #0  _gdb_expr (__regs=0x7ffff7ff3000) at gdb command line:1^M
 #1  <function called from gdb>^M
 #2  main () at gdb/testsuite/gdb.compile/compile.c:106^M
 (gdb) FAIL: gdb.compile/compile.exp: bt

The test should be tweaked to match both cases (pc in the start of line
vs pc in the middle of line).  Note that I am not clear that why libcc1
emits debug info this way so that the address is in the middle of line.

gdb/testsuite:

2018-01-17  Yao Qi  <yao.qi@linaro.org>

* gdb.compile/compile.exp: Match the address printed for
frame in the output of command "bt".

6 years agoWarning fix
Alan Modra [Wed, 17 Jan 2018 10:54:32 +0000 (21:24 +1030)] 
Warning fix

* elf64-ppc.c (ppc64_elf_build_stubs): Silence gcc warning.

6 years agoPowerPC PLT speculative execution barriers
Alan Modra [Wed, 17 Jan 2018 03:49:08 +0000 (14:19 +1030)] 
PowerPC PLT speculative execution barriers

Spectre variant 2 mitigation for PowerPC and PowerPC64.

bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Handle speculation barrier.
(CRSETEQ, BEQCTRM): Define.
(is_nonpic_glink_stub): Don't check bctr.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(ppc_elf_relax_section): Size speculation barrier.
(output_bctr): New function.
(write_glink_stub): Use output_bctr.
(ppc_elf_relocate_section): Use output_bctr for long branch stub.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Use output_bctr.
* elf32-ppc.h (struct ppc_elf_params): Add speculate_indirect_jumps.
* elf64-ppc.c (CRSETEQ, BEQCTRM, BEQCTRLM): Define.
(GLINK_PLTRESOLVE_SIZE): Size speculation barrier.
(size_global_entry_stubs): Handle speculation barrier sizing.
(plt_stub_size): Likewise.
(output_bctr): New function.
(build_plt_stub, build_tls_get_addr_stub): Output speculation
barrier.
(ppc_build_one_stub): Likewise for ppc_stub_plt_branch.
(ppc_size_one_stub): Size speculation barrier in ppc_stub_plt_branch.
(build_global_entry_stubs): Output speculation barrier.
(ppc64_elf_build_stubs): Likewise in __glink_PLTresolve stub.
* elf64-ppc.h (struct ppc64_elf_params): Add speculate_indirect_jumps.
gold/
* options.h (speculate_indirect_jumps): New option.
* powerpc.cc (beqctrm, beqctrlm, crseteq): New insn constants.
(output_bctr): New function.
(Stub_table::plt_call_size): Add space for speculation barrier.
(Stub_table::branch_stub_size): Likewise.
(Output_data_glink::pltresolve_size): Likewise.
(Stub_table::do_write): Output speculation barriers.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(OPTION_SPECULATE_INDIRECT_JUMPS): Define.
(OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise.
* emultempl/ppc64elf.em (params): Init new field.
(OPTION_SPECULATE_INDIRECT_JUMPS): Define.
(OPTION_NO_SPECULATE_INDIRECT_JUMPS): Define.
(PARSE_AND_LIST_LONGOPTS): Handle --speculate-indirect-jumps.
(PARSE_AND_LIST_OPTIONS): Likewise.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
* ld.texinfo (--no-plt-thread-safe): Correct itemx.
(--speculate-indirect-jumps): Document.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/powerpc.exp: Disable plt alignment and
speculation barriers on various tests.

6 years agoPowerPC PLT stub tidy
Alan Modra [Sat, 13 Jan 2018 08:23:41 +0000 (18:53 +1030)] 
PowerPC PLT stub tidy

This is in preparation for the next patch adding Spectre variant 2
mitigation for PowerPC and PowerPC64.  Besides tidying code involved
in stub output (to reduce the number of places where bctr is output),
the patch adds some user visible features:

1) PowerPC64 ELFv2 global entry stubs now are aligned under the
   control of --plt-align, with a default alignment of 32 bytes.
2) PowerPC64 __glink_PLTresolve is no longer padded out with nops.
3) PowerPC32 PLT stubs are aligned under the control of --plt-align,
   with the default alignment being 16 bytes as before.
4) The PowerPC32 branch/nop table emitted before __glink_PLTresolve
   is now smaller in many cases.  It was sized incorrectly when the
   __tls_get_addr_opt stub was used, and unnecessarily included space
   for local ifuncs.

bfd/
* elf32-ppc.c (GLINK_ENTRY_SIZE): Add parameters, handle
__tls_get_addr_opt, and alignment sizing.
(TLS_GET_ADDR_GLINK_SIZE): Delete.
(is_nonpic_glink_stub): Don't use GLINK_ENTRY_SIZE.
(ppc_elf_get_synthetic_symtab): Recognize stubs spaced at 4, 6,
or 8 insns.
(ppc_elf_link_hash_table_create): Init new ppc_elf_params field.
(allocate_dynrelocs): Use new GLINK_ENTRY_SIZE.
(ppc_elf_size_dynamic_sections): Likewise.  Size branch table
by PLT reloc count.
(write_glink_stub): Handle __tls_get_addr_opt stub.
Pad out to size given by GLINK_ENTRY_SIZE.
(ppc_elf_relocate_section): Adjust write_glink_stub call.
(ppc_elf_finish_dynamic_symbol): Likewise.
(ppc_elf_finish_dynamic_sections): Write PLTresolve without using
insn array since so many need rewriting.
* elf32-ppc.h (struct ppc_elf_params): Add plt_stub_align.
* elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Rename from
GLINK_CALL_STUB_SIZE.  Add htab param and evaluate to size without
nops.  Adjust all uses.
(ppc64_elf_get_synthetic_symtab): Don't use GLINK_CALL_STUB_SIZE
in glink_vma calculation.
(struct ppc_link_hash_table): Add global_entry section pointer.
(create_linkage_sections): Create separate section for global
entry stubs.
(PPC_LO, PPC_HI, PPC_HA): Move earlier.
(size_global_entry_stubs): Handle sizing for aligned stubs.
(ppc64_elf_size_dynamic_sections): Handle global_entry alloc,
and don't stash end of glink branch table in rawsize.
(ppc_build_one_stub): Rewrite stub size calculations.
(build_global_entry_stubs): Use new section.
(ppc64_elf_build_stubs): Don't pad __glink_PLTresolve with nops.
Build lazy link stubs out to end of section.  Build global entry
stubs in new section.
gold/
* options.h (plt_align): Support for PowerPC32 too.
* powerpc.cc (Stub_table::stub_align): Heed --plt-align for 32-bit.
(Stub_table::plt_call_size, branch_stub_size): Tidy.
(Stub_table::plt_call_align): Implement using stub_align.
(Output_data_glink::global_entry_align): New function.
(Output_data_glink::global_entry_off): New function.
(Output_data_glink::global_entry_address): Use global_entry_off.
(Output_data_glink::pltresolve_size): New function, replacing
pltresolve_size_ constant.  Update all uses.
(Output_data_glink::add_global_entry): Align offset.
(Output_data_glink::set_final_data_size): Use global_entry_align.
(Stub_table::do_write): Don't pad __glink_PLTrelsolve with nops.
Tidy stub output.  Use global_entry_off.
ld/
* emultempl/ppc32elf.em (params): Init new field.
(enum ppc32_opt): New enum to define OPTION_* values.  Add
OPTION_PLT_ALIGN and OPTION_NO_PLT_ALIGN.
(PARSE_AND_LIST_LONGOPTS): Handle new options.
(PARSE_AND_LIST_ARGS_CASES): Likewise.
(PARSE_AND_LIST_OPTIONS): Likewise.  Break up help output.
* emultempl/ppc64elf.em (ppc_add_stub_section): Init alignment
correctly for negative --plt-stub-align.
* testsuite/ld-powerpc/elfv2exe.d,
* testsuite/ld-powerpc/elfv2so.d,
* testsuite/ld-powerpc/relbrlt.d,
* testsuite/ld-powerpc/relbrlt.s,
* testsuite/ld-powerpc/tlsexe.d,
* testsuite/ld-powerpc/tlsexe.r,
* testsuite/ld-powerpc/tlsexe32.d,
* testsuite/ld-powerpc/tlsexe32.g,
* testsuite/ld-powerpc/tlsexe32.r,
* testsuite/ld-powerpc/tlsexetoc.d,
* testsuite/ld-powerpc/tlsexetoc.r,
* testsuite/ld-powerpc/tlsopt5_32.d,
* testsuite/ld-powerpc/tlsso.d,
* testsuite/ld-powerpc/tlstocso.d: Update for changed stub order.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 17 Jan 2018 00:00:42 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agobinutils release procedure: Add AI to update branch name in crontab
Joel Brobecker [Tue, 16 Jan 2018 13:18:36 +0000 (14:18 +0100)] 
binutils release procedure: Add AI to update branch name in crontab

binutils/ChangeLog:

        * README-how-to-make-a-release: Add reminder to update the
        branch name in gdbadmin's crontab on sourceware.

6 years agoUpdate translations for various binutils components.
Nick Clifton [Tue, 16 Jan 2018 12:45:44 +0000 (12:45 +0000)] 
Update translations for various binutils components.

ld      * po/pt_BR.po: Updated Brazilian Portugese translation.

opcodes * po/pt_BR.po: Updated Brazilian Portugese translation.
        * po/de.po: Updated German translation.

gas     * po/fr.po: Updated French translation.

binutils* po/fr.po: Updated French translation.

6 years agoRemove trailing spaces in binutils/README-how-to-make-a-release
Joel Brobecker [Tue, 16 Jan 2018 11:20:01 +0000 (12:20 +0100)] 
Remove trailing spaces in binutils/README-how-to-make-a-release

binutils/ChangeLog:

        * README-how-to-make-a-release: Remove trailing spaces.

6 years agoMark register unavailable when PTRACE_PEEKUSER fails
Yao Qi [Tue, 16 Jan 2018 09:05:39 +0000 (09:05 +0000)] 
Mark register unavailable when PTRACE_PEEKUSER fails

As described in PR 18749, GDB/GDBserver may get an error on accessing
memory or register because the thread may disappear.  However, some
path doesn't expect the error.  This patch fixes this problem by
marking the register unavailable when PTRACE_PEEKUSER fails instead
of throwing error.

gdb/gdbserver:

2018-01-16  Yao Qi  <yao.qi@linaro.org>

PR gdb/18749
* linux-low.c (fetch_register): Call supply_register instead of
error.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 16 Jan 2018 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoRISC-V: Add support for addi that compresses to c.nop.
Jim Wilson [Mon, 15 Jan 2018 22:53:44 +0000 (14:53 -0800)] 
RISC-V: Add support for addi that compresses to c.nop.

gas/
* testsuite/gas/riscv/c-zero-imm.s: Test addi that compresses to c.nop.
* testsuite/gas/riscv/c-zero-imm.d: Likewise.
opcodes/
* riscv-opc.c (match_c_nop): New.
(riscv_opcodes) <addi>: Handle an addi that compresses to c.nop.

6 years agogdb/common/signals-state-save-restore.c: Fix typos
Pedro Alves [Mon, 15 Jan 2018 20:03:20 +0000 (20:03 +0000)] 
gdb/common/signals-state-save-restore.c: Fix typos

gdb/ChangeLog:
2018-01-15  Pedro Alves  <palves@redhat.com>

* common/signals-state-save-restore.c
(save_original_signals_state): Fix typos.

6 years agoFix scm-ports.exp regression
Tom Tromey [Wed, 3 Jan 2018 18:12:34 +0000 (11:12 -0700)] 
Fix scm-ports.exp regression

In https://sourceware.org/ml/gdb-patches/2017-12/msg00215.html, Jan
pointed out that the scalar printing patches caused a regression in
scm-ports.exp on x86.

What happens is that on x86, this:

set sp_reg [get_integer_valueof "\$sp" 0]

... ends up setting sp_reg to a negative value, because
get_integer_valueof uses "print/d":

    print /d $sp
    $1 = -11496

Then later the test suite does:

    gdb_test "guile (print (seek rw-mem-port (value->integer sp-reg) SEEK_SET))" \
"= $sp_reg" \
"seek to \$sp"

... expecting this value to be identical to the saved $sp_reg value.
However it gets:

    guile (print (seek rw-mem-port (value->integer sp-reg) SEEK_SET))
    = 4294955800

"print" is just a wrapper for guile's format:

    gdb_test_no_output "guile (define (print x) (format #t \"= ~A\" x) (newline))"

The seek function returns a scm_t_off, the printing of which is
handled by guile, not by gdb.

Tested on x86-64 Fedora 26 using an ordinary build and also a -m32
build.

2018-01-15  Tom Tromey  <tom@tromey.com>

* gdb.guile/scm-ports.exp (test_mem_port_rw): Use get_valueof to
compute sp_reg.

6 years agoFix -fuse-ld option to accept string argument.
Cary Coutant [Mon, 15 Jan 2018 18:05:54 +0000 (10:05 -0800)] 
Fix -fuse-ld option to accept string argument.

PR 22042 complained that garbage text was being printed in the help
for the -fuse-ld option; this was caused by passing an empty string
to the gettext() function, which sometimes returns garbage when passed
an empty string. The quick fix was to replace "" with NULL as the helparg,
but that changed the parsing of the option, as gold uses the helparg to
determine whether an option takes an argument. This patch adds a
non-empty helparg string to fix both problems.

gold/
PR gold/22694
* options.h (-fuse-ld): Add correct helparg.

6 years ago[ARM] Add new macro for Thumb-only opcodes
Thomas Preud'homme [Mon, 15 Jan 2018 14:13:33 +0000 (14:13 +0000)] 
[ARM] Add new macro for Thumb-only opcodes

Armv8-M Security Extensions introduced some Thumb-only opcodes
(eg. sg). These are defined using the TUE and TCE macros, setting the
Arm execution state related fields to 0/NULL.

This patch adds 2 new macros to avoid filling this field and clearly
identify Thumb-only instructions.

2018-01-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (ToC): Define macro.
(ToU): Likewise.
(insns): Make use of above macros for new instructions introduced in
Armv8-M.

6 years ago[ARM] Enable conditional Armv8-M instructions
Thomas Preud'homme [Mon, 15 Jan 2018 14:11:02 +0000 (14:11 +0000)] 
[ARM] Enable conditional Armv8-M instructions

Newly introduced instructions common to ARMv8-M Baseline and Mainline
are currently all marked as unconditional. However, all instructions but
sg (ie. blxns, bxns, tt, ttt, tta, ttat, vlldm and vlstm) do actually
support conditional execution. This patch fixes the definition of these
instructions accordingly.

2018-01-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (insns): Make blxns, bxns, tt, ttt, tta, ttat, vlldm
and vlstm conditionally executable and reindent parameters.
* testsuite/gas/arm/archv8m-cmse-main.s: Add conditional version of
aforementionned instructions.

6 years ago[ARM] No IT usage deprecation for ARMv8-M
Thomas Preud'homme [Mon, 15 Jan 2018 14:09:28 +0000 (14:09 +0000)] 
[ARM] No IT usage deprecation for ARMv8-M

Deprecations related to the use of the IT instruction introduced in
Armv8-A do not apply to Armv8-M Baseline and mainline. However the
warning logic do not distinguish between the various profiles and warn
whenever the architecture version is 8.

This patch adds a check to exclude M profile architectures from this
warning. This works as expected when -march is specified on the
command-line or a .arch/.cpu directive exist. However, in autodetection
mode the CPU/architecture targeted is only known once the instructions
have been all processed but this code is run when IT instruction is
processed. It is therefore not possible to distinguish between Armv8-M
and Armv8-A in that mode.

The approach chosen here is not to warn in autodetection mode. The udf.d
testcase that relied on that behavior to test deprecation warning for
Armv8-A is therefore updated to explicitely pass -march=armv8-a.

2018-01-15  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (it_fsm_post_encode): Do not warn if targeting M
profile architecture or if in autodetection mode.  Clarify that
deprecation is for performance reason and concerns Armv8-A and Armv8-R.
* testsuite/gas/arm/armv8-ar-bad.l: Adapt to new IT deprecation warning
message.
* testsuite/gas/arm/armv8-ar-it-bad.l: Likewise.
* testsuite/gas/arm/sp-pc-validations-bad-t-v8a.l: Likewise.
* testsuite/gas/arm/udf.l: Likewise.
* testsuite/gas/arm/udf.d: Assemble for Armv8-A explicitely.

6 years agoFix gdb.texinfo more
Szabolcs Nagy [Mon, 15 Jan 2018 13:06:45 +0000 (13:06 +0000)] 
Fix gdb.texinfo more

Add incorrectly removed @pindex back.

gdb/doc/ChangeLog:

* gdb.texinfo (gdb-add-index man): Add pindex.

6 years agoUpdate Ukranian translations for bfd, binutils, gas, gold, ld and opcodes
Nick Clifton [Mon, 15 Jan 2018 12:09:11 +0000 (12:09 +0000)] 
Update Ukranian translations for bfd, binutils, gas, gold, ld and opcodes

6 years agoFix gdb.texinfo for old makeinfo (again)
Szabolcs Nagy [Mon, 15 Jan 2018 10:44:12 +0000 (10:44 +0000)] 
Fix gdb.texinfo for old makeinfo (again)

With old makeinfo (version 4.13) the changes introduced in

commit ba643918cf869fa0d064d733f69b453b6fe642ea
Author:     Sergio Durigan Junior <sergiodj@redhat.com>

    Install and generate docs for gdb-add-index

fail to build with

gdb/doc/gdb.texinfo:2498: warning: `.' or `,' must follow @xref, not `@'.
gdb/doc/gdb.texinfo:2517: warning: `.' or `,' must follow @xref, not `@'.
gdb/doc/gdb.texinfo:43443: Node `gdb-add-index man' requires a sectioning command (e.g., @unnumberedsubsec).
gdb/doc/gdb.texinfo:43443: `gdb-add-index man' has no Up field (perhaps incorrect sectioning?).
gdb/doc/gdb.texinfo:43350: Next field of node `gdbinit man' not pointed to (perhaps incorrect sectioning?).
gdb/doc/gdb.texinfo:43443: This node (gdb-add-index man) has the bad Prev.

This patch fixes the warnings too.

gdb/doc/ChangeLog:

* gdb.texinfo (set cwd): Add period.
(gdb-add-index man): Move anchor.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 15 Jan 2018 00:00:29 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 14 Jan 2018 00:00:44 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoUpdate notes on how to make a release
Nick Clifton [Sat, 13 Jan 2018 14:29:27 +0000 (14:29 +0000)] 
Update notes on how to make a release

6 years agoUpdate pot files
Nick Clifton [Sat, 13 Jan 2018 13:56:48 +0000 (13:56 +0000)] 
Update pot files

6 years agoBump version number to 2.30.51
Nick Clifton [Sat, 13 Jan 2018 13:31:12 +0000 (13:31 +0000)] 
Bump version number to 2.30.51

bfd/
* version.m4: Bump version to 2.30.51
* configure: Regenerate.

binutils/
* configure: Regenerate.

gas/
* configure: Regenerate.

gprof/
* configure: Regenerate.

ld/
* configure: Regenerate.

opcodes/
* configure: Regenerate.

6 years agoAdd note about 2.30 branch creation to changelogs
Nick Clifton [Sat, 13 Jan 2018 13:26:38 +0000 (13:26 +0000)] 
Add note about 2.30 branch creation to changelogs

6 years agoAdd 2.30 markers to NEWS files.
Nick Clifton [Sat, 13 Jan 2018 13:20:55 +0000 (13:20 +0000)] 
Add 2.30 markers to NEWS files.

binutils/
* NEWS: Add marker for 2.30.

gas/
* NEWS: Add marker for 2.30.

ld/
* NEWS: Add marker for 2.30.

6 years agoUpdate gold version number to 1.15.
Cary Coutant [Sat, 13 Jan 2018 02:38:11 +0000 (18:38 -0800)] 
Update gold version number to 1.15.

gold/
* NEWS: Add new features in 1.15.
* version.cc (version_string): Bump to 1.15.

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 13 Jan 2018 00:00:33 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agogdb/testsuite: Don't attempt tests if they fail to compile
Andrew Burgess [Thu, 11 Jan 2018 18:58:10 +0000 (18:58 +0000)] 
gdb/testsuite: Don't attempt tests if they fail to compile

In the gdb.base/whatis-ptype-typedefs.exp test, if the test program
fails to compile, don't run the tests.

gdb/testsuite/ChangeLog:

* gdb.base/whatis-ptype-typedefs.exp: Don't run tests if we failed
to prepare.
(prepare): Return 0 on error, 1 on success.

6 years agoInstall and generate docs for gdb-add-index
Sergio Durigan Junior [Thu, 11 Jan 2018 21:12:05 +0000 (16:12 -0500)] 
Install and generate docs for gdb-add-index

The "gdb-add-index" script has been resurrected on:

  commit caf26be91a584ef141ac5d3cb31007731af8b8e3
  Author: Samuel Bronson <naesten@gmail.com>
  Date:   Fri Nov 15 16:09:33 2013 -0500

      Resurrect gdb-add-index as a contrib script

However, for some reason (I couldn't find it in the archives), only
the script has been checked-in; the Makefile parts responsible for
installing it in the system were left out.  This commit fixes that, by
also resurrecting the Makefile and documentation bits.

This commit is part of our effort to upstream the local Fedora GDB
changes.  With this commit, we'll only carry a very small
Fedora-specific modification to the script.

gdb/ChangeLog:
2017-01-12  Tom Tromey  <tom@tromey.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (install-only): Install gdb-add-index.

gdb/doc/ChangeLog:
2017-01-12  Tom Tromey  <tom@tromey.com>
    Sergio Durigan Junior  <sergiodj@redhat.com>

* gdb.texinfo (Index Files): Mention gdb-add-index.
(gdb-add-index man): New section.
* Makefile.in (gdb-add-index.1): New rule to generate manpage
from gdb.texinfo.

6 years agoUse the correct value for the offset of 'kve_protection'.
John Baldwin [Fri, 12 Jan 2018 20:05:50 +0000 (12:05 -0800)] 
Use the correct value for the offset of 'kve_protection'.

I had forgotten to convert the decimal output of 'ptype /o' to hex
(but still used a 0x prefix) for the KVE_PROTECTION constant defining
the offset of the 'kve_protection' field in the 'kinfo_vmentry'
structure.  This resulted in garbage permissions for entries in 'info
proc mappings' for FreeBSD core dumps.

gdb/ChangeLog:

* fbsd-tdep.c (KVE_PROTECTION): Correct value.

6 years agoApply:
Eric Christopher [Fri, 12 Jan 2018 19:05:58 +0000 (11:05 -0800)] 
Apply:

2018-01-12 Sterling Augustine <saugustine@google.com>

   * cref.cc (Cref_inputs::Cref_table_compare::operator): Add
   conditionals and calls to is_forwarder.

6 years agoAdd testcase for GDB hang fixed by previous commit
Pedro Alves [Fri, 12 Jan 2018 18:52:39 +0000 (18:52 +0000)] 
Add testcase for GDB hang fixed by previous commit

This adds a testcase for the previous commit.  The regression was
related to in-line step overs.  The reason we didn't see it on native
x86-64/s390 GNU/Linux testing is that native debugging uses displaced
stepping by default (because native debugging defaults to "maint set
target-non-stop on"), unlike remote debugging.

So in order to trigger the bug with native debugging as well, the
testcase disables displaced stepping explicitly.

Also, instead of using watchpoints to trigger the regression, the
testcase uses a breakpoint at address 0, which should be more
portable.

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

* gdb.base/continue-after-aborted-step-over.c: New.
* gdb.base/continue-after-aborted-step-over.exp: New.

6 years agoFix GDB hang with remote after error from resume
Andreas Arnez [Fri, 12 Jan 2018 18:52:39 +0000 (18:52 +0000)] 
Fix GDB hang with remote after error from resume

Since this commit --

  Fix PR18360 - internal error when using "interrupt -a"
  (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=c65d6b55)

-- the testsuite shows long delays on s390 with native-gdbserver when
executing certain tests, such as watchpoints.exp.  These hangs have been
discussed before in the context of buildbot problems, see here:

  https://sourceware.org/ml/gdb-patches/2017-12/msg00413.html

The problem can easily be triggered by stopping on a breakpoint, then
setting impossible watchpoints, and finally doing "continue".  Then, after
having set the step-over state (in keep_going_pass_signal in infrun.c),
GDB tries to insert breakpoints and watchpoints into the inferior.  This
fails, and the "continue" command is aborted.  But the step-over state is
not cleared in this case, which causes future step-over attempts to be
skipped since GDB thinks that "we already have an in-line step-over
operation ongoing" (see start_step_over in infrun.c).  Thus the next
"continue" just goes on to wait for events from the remote, which will
never occur.

The problem can also be reproduced on amd64 with native-gdbserver, using
the following change to watchpoints.exp:

 -- >8 --
 --- a/gdb/testsuite/gdb.base/watchpoints.exp
 +++ b/gdb/testsuite/gdb.base/watchpoints.exp
 @@ -61,2 +61,3 @@ with_test_prefix "before inferior start" {
      gdb_test "watch ival3" ".*" ""
 +    gdb_test "watch *(char \[256\] *) main"

 -- >8 --

To fix the hang, this patch clears the step-over info when
insert_breakpoints has failed.  Of course, with native-gdbserver the
watchpoints.exp test case still causes many FAILs on s390, because
gdbserver does not support watchpoints for that target.  This is a
separate issue.

gdb/ChangeLog:
2018-01-12  Andreas Arnez  <arnez@linux.vnet.ibm.com>

* infrun.c (keep_going_pass_signal): Clear step-over info when
insert_breakpoints fails.

6 years agoAdd notes on how to make a branch and a pre-release snapshot.
Nick Clifton [Fri, 12 Jan 2018 17:52:38 +0000 (17:52 +0000)] 
Add notes on how to make a branch and a pre-release snapshot.

* README-how-to-make-a-release: Add notes on how to make the
branch and prelease snapshot.
* BRANCHES: Add binutils-2_29-branch.

6 years agoOptimize the performance of the group_setup function.
Jens Widell [Fri, 12 Jan 2018 13:16:17 +0000 (13:16 +0000)] 
Optimize the performance of the group_setup function.

When processing a section that is a member of a group, the group
that contains it is looked up using a linear search. The resulting
O(n^2) complexity causes significant performance issues when
dealing with object files with very many groups.

By remembering the index of the last found group and restarting
the next search from that index, the search instead becomes O(n)
in common cases.

* elf.c (setup_group): Optimize search for group by remembering
last found group and restarting search at that index.
* elf-bfd.h (struct elf_obj_tdata): Add group_search_offset field.

6 years agoFix compile time warning building aout targeted architectures.
Gunther Nikl [Fri, 12 Jan 2018 13:12:17 +0000 (13:12 +0000)] 
Fix compile time warning building aout targeted architectures.

Occasionally I build an out-of-tree a.out target (m68k-amigaos). After
a system upgrade which included a newer compiler (clang 4) the build
produces warnings like this:

  warning: macro expansion producing 'defined' has undefined behavior
  [-Wexpansion-to-defined]

This is caused by the macro gas/config/aout_gnu.h:USE_EXTENDED_RELOC.
Since it is in a header file, the warning triggers for several files.
I am unsure what solution is preferable, thus I am suggesting two
patches:

  a) keep the offending macro but define it explicitly to 0 and 1
  b) replace the macro usage with its value where it is used.

Either patch removes the warning for clang. I did not check with a
recent GCC.

* gas/config/aout_gnu.h (USE_EXTENDED_RELOC): Explicitly
define to 0 and 1. Remove a dangling reference to "AMD 29000"
in a comment.

6 years agopr22374 function pointer initialization
Alan Modra [Fri, 12 Jan 2018 10:40:48 +0000 (21:10 +1030)] 
pr22374 function pointer initialization

When I added this test I said I'd look at fixing more targets.
That hasn't happened yet, so xfail to tidy results.

* testsuite/ld-elf/elf.exp: xfail "pr22374 function pointer
initialization" for currently failing targets.

6 years agoFix override of common symbols for a.out
Alan Modra [Fri, 12 Jan 2018 00:07:28 +0000 (10:37 +1030)] 
Fix override of common symbols for a.out

The default should be bfd_link_common_skip_none, as in the original
patch at https://sourceware.org/ml/binutils/2002-07/msg00717.html

* aoutx.h (aout_link_check_ar_symbols): Remove default and handle
bfd_link_common_skip_none in switch.

6 years agoFixes for "Ignore dynamic references on forced local symbols"
Alan Modra [Fri, 12 Jan 2018 06:28:04 +0000 (16:58 +1030)] 
Fixes for "Ignore dynamic references on forced local symbols"

PowerPC64 has its own mark_dynamic_ref, which needs the same change as
made by d664fd41e1 to the generic ELF version.  Some other targets
discard more than just .data, so allow for that too in expected ld
messages.

bfd/
PR ld/22649
* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref): Ignore dynamic
references on forced local symbols.
ld/
PR ld/22649
* testsuite/ld-elf/pr22649.msg: Allow other messages.
* testsuite/ld-elf/shared.exp: Check that --gc-sections is
supported before running ld/22649 tests.

6 years ago_bfd_mips_elf_final_link: Notify user about wrong .reginfo size
Vlad Ivanov [Fri, 12 Jan 2018 09:25:11 +0000 (09:25 +0000)] 
_bfd_mips_elf_final_link: Notify user about wrong .reginfo size

One of assertions in _bfd_mips_elf_final_link could be triggered by
a combination of input files and a linker script.  This happens when
either the input doesn't contain .reginfo section or when this section
is oversized.  This patch replaces the assertion with a more useful
error message.

* elfxx-mips.c (_bfd_mips_elf_final_link): Notify user when
.reginfo section has wrong size.

6 years agoAdd -z undefs option to the ELF linker.
Nick Clifton [Fri, 12 Jan 2018 08:15:55 +0000 (08:15 +0000)] 
Add -z undefs option to the ELF linker.

  Currently we have no obvious way to revert the action of the "-z defs"
  command line option.  The "--unresolved-symbols=ignore-in-object-files"
  does pretty much what is needed, but it is non-obvious and it also
  touches the setting for reporting unresolved symbol references from
  shared libraries.  So I am proposing adding a "-z undefs" option to be
  the inverse of "-z defs".  (I thought that "-z nodefs" might be
  confusing since it implies banning all definitions, rather than
  allowing them).

  In addition the description of the "-z defs" option in the linker
  documentation is misleading in one place, where it says:

    'defs'
       Disallows undefined symbols in object files.  Undefined
       symbols in shared libraries are still allowed.

  whereas later on it gets it right:

    '-z defs'
       Report unresolved symbol references from regular object files.
       This is done even if the linker is creating a non-symbolic shared
       library.  The switch '--[no-]allow-shlib-undefined' controls the
       behaviour for reporting unresolved references found in shared
       libraries being linked in.

* emultempl/elf32.em (_handle_option): Add support for "-z undefs"
as the opposite of "-z defs".
* ld.texinfo: Document the new option.  Update the description of
the -z defs option to make it clear that it does generate an error
if an undefined symbol reference is found in an object file whilst
creating a shared library.
* NEWS: Document this new feature.

6 years agold: Replace "-z textonly" with "-z separate-code"
H.J. Lu [Fri, 12 Jan 2018 04:46:01 +0000 (20:46 -0800)] 
ld: Replace "-z textonly" with "-z separate-code"

Although they aren't passed to linker, we should get it right.

* testsuite/ld-elf/pr22393-2a.rd: Replace "-z textonly" with
"-z separate-code".
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.

6 years agox86-64: Add tests for -z separate-code -z max-page-size=0x1000
H.J. Lu [Fri, 12 Jan 2018 03:19:22 +0000 (19:19 -0800)] 
x86-64: Add tests for -z separate-code -z max-page-size=0x1000

PR ld/22393
* testsuite/ld-x86-64/pr22393-3a.c: New file.
* testsuite/ld-x86-64/pr22393-3a.rd: Likewise.
* testsuite/ld-x86-64/pr22393-3b.c: Likewise.
* testsuite/ld-x86-64/pr22393-3b.rd: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run tests for -z separate-code
-z max-page-size=0x1000.

6 years agold: Add tests for -z separate-code and -z noseparate-code
H.J. Lu [Fri, 12 Jan 2018 03:17:46 +0000 (19:17 -0800)] 
ld: Add tests for -z separate-code and -z noseparate-code

Verify that -z separate-code works and -z noseparate-code doesn't disable
-z relro.

PR ld/22393
* testsuite/ld-elf/pr16322.d: Add -z noseparate-code.
* testsuite/ld-elf/pr22393-1.s: New file.
* testsuite/ld-elf/pr22393-1a.d: Likewise.
* testsuite/ld-elf/pr22393-1b.d: Likewise.
* testsuite/ld-elf/pr22393-1c.d: Likewise.
* testsuite/ld-elf/pr22393-1d.d: Likewise.
* testsuite/ld-elf/pr22393-1e.d: Likewise.
* testsuite/ld-elf/pr22393-1f.d: Likewise.
* testsuite/ld-elf/pr22393-2a.c: Likewise.
* testsuite/ld-elf/pr22393-2a.rd: Likewise.
* testsuite/ld-elf/pr22393-2b.c: Likewise.
* testsuite/ld-elf/pr22393-2b.rd: Likewise.
* testsuite/ld-elf/shared.exp: Run tests for -z separate-code.

6 years agold: Create a new LOAD segment for separate code segment
H.J. Lu [Fri, 12 Jan 2018 03:04:55 +0000 (19:04 -0800)] 
ld: Create a new LOAD segment for separate code segment

When generating separate code LOAD segment, create a new LOAD segment
if the previous section contains text and the current section doesn't
or vice versa:

Elf file type is DYN (Shared object file)
Entry point 0x200020
There are 7 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00000000 0x00000000 0x00200 0x00200 R   0x200000
  LOAD           0x200000 0x00200000 0x00200000 0x00036 0x00036 R E 0x200000
  LOAD           0x400000 0x00400000 0x00400000 0x00064 0x00064 R   0x200000
  LOAD           0x400f80 0x00600f80 0x00600f80 0x000a0 0x000a0 RW  0x200000
  DYNAMIC        0x400f80 0x00600f80 0x00600f80 0x00080 0x00080 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10
  GNU_RELRO      0x400f80 0x00600f80 0x00600f80 0x00080 0x00080 R   0x1

 Section to Segment mapping:
  Segment Sections...
   00     .hash .gnu.hash .dynsym .dynstr .rela.plt
   01     .plt .text
   02     .rodata .eh_frame
   03     .dynamic .got.plt
   04     .dynamic
   05
   06     .dynamic

to prevent fetching or executing data in code pages as instructions.

Also don't put a writable section in a read-only segment if there is a
RELRO segment.

Since code segment is aligned and padded to the maximum page size on
disk, the minimum file size is bigger than the maximum page size which
is 2MB (0x200000):

-rwxr-xr-x 1 hjl hjl 4201932 Jan 10 10:41 libfoo.so

"-z max-page-size=0x1000" can be used to reduce the maximum page size to
4KB (0x1000):

-rwxr-xr-x 1 hjl hjl   15820 Jan 10 10:44 libfoo.so

PR ld/22393
* elf.c (_bfd_elf_map_sections_to_segments): When generating
separate code and read-only data LOAD segments, create a new
LOAD segment if the previous section contains text and the
current section doesn't or vice versa.  Don't put a writable
section in a read-only segment if there is a RELRO segment.

6 years agold: Add "-z separate-code" option to ELF linker
H.J. Lu [Fri, 12 Jan 2018 03:01:39 +0000 (19:01 -0800)] 
ld: Add "-z separate-code" option to ELF linker

The new "-z separate-code" option will generate separate code LOAD
segment which must be in wholly disjoint pages from any other data.

include/

PR ld/22393
* bfdlink.h (bfd_link_info): Add separate_code.

ld/

PR ld/22393
* NEWS: Mention "-z separate-code".
* emultempl/elf32.em (gld${EMULATION_NAME}_get_script): Get
builtin linker scripts and return linker scripts from disk for
"-z separate-code".
(gld${EMULATION_NAME}_handle_option): Handle "-z separate-code"
and "-z noseparate-code".
* genscripts.sh: Generate linker scripts for "-z separate-code".
(LD_FLAG): Set to *textonly for "-z separate-code".
* ld.texinfo: Document "-z separate-code".
* lexsup.c (elf_shlib_list_options): Add linker help messsages
for "-z separate-code" and "-z noseparate-code".
* scripttempl/elf.sc (SEPARATE_TEXT): New
(TEXT_SEGMENT_ALIGN): Likewise.
Use ${TEXT_SEGMENT_ALIGN} to align and pad text segment to
${MAXPAGESIZE}.

6 years agogdb_compile_shlib: Only consider shlib= options when building executables
Simon Marchi [Fri, 12 Jan 2018 02:08:23 +0000 (21:08 -0500)] 
gdb_compile_shlib: Only consider shlib= options when building executables

Trying to use gdb_compile_shlib with the shlib= option to build a shared
library that depends on another shared library does not work as of
today.  See:

  https://sourceware.org/ml/gdb-patches/2017-10/msg00733.html

The problem is that building the lib is done in two steps, compilation
(.c -> .o) and linking (.o -> .so) and the shlib= options are passed to
both steps.  When compiling the object file (.o), it results in gcc
complaining:

  gcc: warning: .../solib-vanish-lib2.so: linker input file unused because linking not done

The first solution I came up with was to filter the options inside
gdb_compile_shlib to remove the shlib= options from the options we pass
when compiling the .o file.

I then thought it would be simpler to ignore the shlib= options in
gdb_compile when not building an executable (the executable category
includes the shared libraries).  For other compilation types (object
file, preprocess and generate assembly), it doesn't make sense to add
shared libraries to the source file list.

Regtested on the buildbot.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_compile): Ignore shlib= and shlib_load
options when not creating an executable.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 12 Jan 2018 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoIgnore dynamic references on forced local symbols
H.J. Lu [Thu, 11 Jan 2018 23:36:40 +0000 (15:36 -0800)] 
Ignore dynamic references on forced local symbols

We should ignore dynamic references on forced local symbols during
garbage collection since they can never be referenced dynamically.

bfd/

PR ld/22649
* elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Ignore dynamic
references on forced local symbols.

ld/

PR ld/22649
* testsuite/ld-elf/pr22649-1.s: New file.
* testsuite/ld-elf/pr22649-2a.s: Likewise.
* testsuite/ld-elf/pr22649-2b.s: Likewise.
* testsuite/ld-elf/pr22649.msg: Likewise.
* testsuite/ld-elf/shared.exp: Run ld/22649 tests.

6 years agogdb.base/breakpoint-in-ro-region.exp regression on sss targets (PR gdb/22583)
Pedro Alves [Thu, 11 Jan 2018 17:50:31 +0000 (17:50 +0000)] 
gdb.base/breakpoint-in-ro-region.exp regression on sss targets (PR gdb/22583)

As Maciej reported at
<https://sourceware.org/ml/gdb-patches/2017-12/msg00212.html>, this
commit:

 commit d930703d68ae160ddfe8ebe5fdcf416fb6090e1e
 Date: Thu Nov 16 18:44:43 2017 +0000
 Subject: Don't ever Quit out of resume

caused regressions on software single-set targets, specifically:

 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw on: single-step breakpoint is not left behind
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: step in ro region (cannot insert hw break)
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw off: single-step breakpoint is not left behind
 FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted on: auto-hw on: single-step breakpoint is not left behind

and indeed detailed logs indicate a breakpoint is left lingering, e.g.:

 (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
 maint info breakpoints 0
 Num     Type           Disp Enb Address    What
 0       sw single-step keep y   0x00400774 in main at [...]/gdb/testsuite/gdb.base/breakpoint-in-ro-region.c:24 inf 1 thread 1
 stop only in thread 1
 (gdb) FAIL: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind

vs:

 (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: step in ro region (cannot insert sw break)
 maint info breakpoints 0
 No breakpoint or watchpoint matching '0'.
 (gdb) PASS: gdb.base/breakpoint-in-ro-region.exp: always-inserted off: auto-hw off: single-step breakpoint is not left behind

as at commit d930703d68ae^.

Before commit d930703d68ae, we had a cleanup installed in 'resume'
that would delete single-step breakpoints on error:

  /* Resuming.  */

  /* Things to clean up if we QUIT out of resume ().  */
  static void
  resume_cleanups (void *ignore)
  {
    if (!ptid_equal (inferior_ptid, null_ptid))
     delete_single_step_breakpoints (inferior_thread ());

    normal_stop ();
  }

That whole function was removed by d930703d68ae mainly to eliminate
the normal_stop call:

~~~~
    Note that the exception called from within resume ends up calling
    normal_stop via resume_cleanups.  That's very borked though, because
    normal_stop is going to re-handle whatever was the last reported
    event, possibly even re-running a hook stop...
~~~~

But as the regression shows, removing resume_cleanups completely went
a bit too far, as the delete_single_step_breakpoints call is still
necessary.

So fix the regression by reinstating the
delete_single_step_breakpoints call on error.  However, since we're
trying to eliminate cleanups, restore it in a different form (using
TRY/CATCH).

Tested on x86-64 GNU/Linux both top of master and on top of a series
that implements software single-step on x86.

gdb/ChangeLog:
2018-01-11  Pedro Alves  <palves@redhat.com>

PR gdb/22583
* infrun.c (resume): Rename to ...
(resume_1): ... this.
(resume): Reimplement as wrapper around resume_1.

6 years agold: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-sections
H.J. Lu [Thu, 11 Jan 2018 17:42:12 +0000 (09:42 -0800)] 
ld: Keep PREINIT_ARRAY/INIT_ARRAY/FINI_ARRAY sections for -r --gc-sections

We must keep all PREINIT_ARRAY, INIT_ARRAY as well as FINI_ARRAY sections
for ld -r --gc-sections.

bfd/

PR ld/22677
* elflink.c (bfd_elf_gc_sections): Keep all PREINIT_ARRAY,
INIT_ARRAY as well as FINI_ARRAY sections for ld -r --gc-sections.

ld/

PR ld/22677
* scripttempl/elf.sc (PREINIT_ARRAY): New.
Don't add .preinit_array for ld -r.
* testsuite/ld-elf/pr22677.d: New file.
* testsuite/ld-elf/pr22677.s: Likewise.

6 years agold: Remove unused expression state
Andrew Burgess [Fri, 5 Jan 2018 14:59:05 +0000 (14:59 +0000)] 
ld: Remove unused expression state

Previous commit removed all uses of the defsym field within the linker
expression union.  This commit cleans up the now redundant state.

ld/ChangeLog:

* ldexp.h (union etree_union): Remove defsym field.
* ldexp.c (exp_assop): Remove defsym parameter, and use of defsym
parameter.
(exp_assign): Remove passing of defsym parameter.
(exp_defsym): Likewise.
(exp_provide): Likewise.

6 years agold: Fix issue where PROVIDE overrides defined symbol
Andrew Burgess [Thu, 27 Apr 2017 17:05:08 +0000 (18:05 +0100)] 
ld: Fix issue where PROVIDE overrides defined symbol

In a linker script, a sequence like this:

  foo = ADDR (.some_section);
  bar = foo;
  PROVIDE (foo = 0);

will result in 'bar = ADDR (.some_section)' and 'foo = 0', which seems
like incorrect behaviour, foo is clearly defined elsewhere, and so the
PROVIDE should not trigger.

The problem is that an expression like this:

    foo = ADDR (.some_section);

can't be evaluated until a late phase of the linker, due to the need
for the section '.some_section' to have been placed, then the PROVIDE
was being marked as being used during an earlier phase.  At the end of
the link, both lines:

    foo = ADDR (.some_section);
    PROVIDE (foo = 0);

are active, and this causes the final value of 'foo' to be 0.

The solution proposed in this commit is that, during earlier phases of
the linker, when we see the expression 'foo = ADDR (.some_section);',
instead of ignoring the expression, we create a "fake" definition of
'foo'.  The existence of this "fake" definition prevents the PROVIDE
from being marked used, and during the final phase the real definition
of 'foo' will replace the "fake" definition.

The new test provide-6 covers the exact case described above.  The
provide-7 test is similar to the above, but using constant
expressions, this was never broken, but is added here to increase
coverage.

The provide-8 case also didn't fail before this commit, but I did
manage to break this case during development of this patch.  This case
was only covered by a mmix test before, so I've added this here to
increase coverage.

ld/ChangeLog:

* ldexp.c (exp_fold_tree_1): Rework condition underwhich provide
nodes are ignored in the tree walk, and move the location at which
we change provide nodes into provided nodes.
(exp_init_os): Add etree_provided.
* testsuite/ld-scripts/provide-6.d: New file.
* testsuite/ld-scripts/provide-6.t: New file.
* testsuite/ld-scripts/provide-7.d: New file.
* testsuite/ld-scripts/provide-7.t: New file.
* testsuite/ld-scripts/provide-8.d: New file.
* testsuite/ld-scripts/provide-8.t: New file.

6 years agold: Find and run some tests using a wildcard pattern
Andrew Burgess [Thu, 27 Apr 2017 16:53:28 +0000 (17:53 +0100)] 
ld: Find and run some tests using a wildcard pattern

Find the ld-script/provide-*.d tests using a wildcard, then run them in
a loop.  This will make it easier to add more tests in the future.  Some
associated clean up is required.

ld/ChangeLog:

* testsuite/ld-scripts/provide-3.d: Add xfail directive.
* testsuite/ld-scripts/provide-4.d: Use new map file name.
* testsuite/ld-scripts/provide-5.d: Use new map file name.
* testsuite/ld-scripts/provide-4-map.d: Renamed to...
* testsuite/ld-scripts/provide-4.map: ...this.
* testsuite/ld-scripts/provide-5-map.d: Renamed to...
* testsuite/ld-scripts/provide-5.map: ...this.
* testsuite/ld-scripts/provide.exp: Move xfail into provide-3.d
file, and run tests in a loop.

6 years agold: In map file use '=' in PROVIDE statements
Andrew Burgess [Fri, 5 Jan 2018 22:41:55 +0000 (22:41 +0000)] 
ld: In map file use '=' in PROVIDE statements

Currently when recording a PROVIDE statement in a linker map file we
display something like:

    PROVIDE (SYMBOL, VALUE)

However, in a linker script we write these statements like this:

    PROVIDE (SYMBOL = VALUE);

This commit changes the output in the map file to be closer to linker
script format, the map file now contains:

    PROVIDE (SYMBOL = VALUE)

The ';' is still missing from the end, but map files are not intended
to be valid linker script input, so adding the ';' just seems like
clutter.

ld/ChangeLog:

* ldexp.c (exp_print_tree): Use '=' instead of ',' when printing
PROVIDE statements.
* testsuite/ld-scripts/provide-4.map: Update expected output.
* testsuite/ld-scripts/provide-5.map: Likewise.

6 years agoFix the order of SHLIB_RODATA_ADDR in elf.sc
H.J. Lu [Thu, 11 Jan 2018 13:05:25 +0000 (05:05 -0800)] 
Fix the order of SHLIB_RODATA_ADDR in elf.sc

elf.sc has

  if test -n "${RODATA_ADDR}"; then
    RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    ^^^^^^^^^^ Set RODATA_ADDR
    RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${RODATA_ADDR})"
    ^^^^^^^^^^ Set RODATA_ADDR with ${RODATA_ADDR}
  fi
  if test -n "${SHLIB_RODATA_ADDR}"; then
    SHLIB_RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
    ^^^^^^^^^^ Set SHLIB_RODATA_ADDR
    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    ^^^^^^^^^^ Override SHLIB_RODATA_ADDR
  fi

The order should be:

  if test -n "${SHLIB_RODATA_ADDR}"; then
    SHLIB_RODATA_ADDR="\
SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR}) + SIZEOF_HEADERS"
  else
    SHLIB_RODATA_ADDR="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))"
    SHLIB_RODATA_ADDR="SEGMENT_START(\"rodata-segment\", ${SHLIB_RODATA_ADDR})"
  fi

PR ld/22696
* scripttempl/elf.sc: Fix the order of SHLIB_RODATA_ADDR.

6 years agoFix gdb.texinfo for old makeinfo
Szabolcs Nagy [Thu, 11 Jan 2018 12:13:39 +0000 (12:13 +0000)] 
Fix gdb.texinfo for old makeinfo

With old makeinfo (version 4.13) the changes introduced in

commit 2d97a5d9d33aea87c3bd02fd1fa417f5d4e1fa05
Author:     John Baldwin <jhb@FreeBSD.org>

    Document support for 'info proc' on FreeBSD.

fail to build.

gdb/doc/ChangeLog:

* gdb.texinfo (pwd): Fix whitespace.

6 years agoFix backwards compatibility with old GDBservers (PR remote/22597)
Pedro Alves [Thu, 11 Jan 2018 00:23:04 +0000 (00:23 +0000)] 
Fix backwards compatibility with old GDBservers (PR remote/22597)

At <https://sourceware.org/ml/gdb-patches/2017-12/msg00285.html>,
Maciej reported that commit:

  commit 5cd63fda035d4ba949e6478406162c4673b3c9ef
  Date: Wed Oct 4 18:21:10 2017 +0100
  Subject: Fix "Remote 'g' packet reply is too long" problems with multiple inferiors

made GDB stop working with older stubs.  Any attempt to continue
execution after the initial connection fails with:

  [...]
  Process .../gdb/testsuite/outputs/gdb.base/advance/advance created; pid = 2670
  Listening on port 2346
  target remote [...]:2346
  Remote debugging using [...]:2346
  Reading symbols from .../lib64/ld.so.1...done.
  [Switching to Thread <main>]
  (gdb) continue
  Cannot execute this command without a live selected thread.
  (gdb)

The problem is:

  (gdb) c
  Cannot execute this command without a live selected thread.
  (gdb) info threads
    Id   Target Id         Frame
    1    Thread 14917      0x00007f341cd98ed0 in _start () from /lib64/ld-linux-x86-64.so.2

  The current thread <Thread ID 2> has terminated.  See `help thread'.
      ^^^^^^^^^^^
  (gdb)

Note, thread _2_.  There's really only one thread in the inferior
(it's still at the entry point), but still GDB added a bogus second
thread.

The reason GDB started adding a second thread after 5cd63fda035d is
this hunk:

+                 if (event->ptid == null_ptid)
+                   {
+                     const char *thr = strstr (p1 + 1, ";thread:");
+                     if (thr != NULL)
+                       event->ptid = read_ptid (thr + strlen (";thread:"),
+                                                NULL);
+                     else
+                       event->ptid = magic_null_ptid;
+                   }

Note the else branch that falls back to magic_null_ptid.  We reach
that when we process the initial stop reply sent back in response to
the the "?" (status) packet early in the connection setup:

 Sending packet: $?#3f...Ack
 Packet received: T0506:0000000000000000;07:40a510f4fd7f0000;10:d0fe1201577f0000;

And note that that response does not include a ";thread:XXX" part.

This stop reply is processed after listing threads with qfThreadInfo /
qsThreadInfo :

 Sending packet: $qfThreadInfo#bb...Ack
 Packet received: m3915
 Sending packet: $qsThreadInfo#c8...Ack
 Packet received: l

meaning, when we process that stop reply, we treat the event as coming
from a thread with ptid == magic_null_ptid, which is not yet in the
thread list, so we add it then:

  (top-gdb) p ptid
  $1 = {m_pid = 42000, m_lwp = -1, m_tid = 1}
  (top-gdb) bt
  #0  0x0000000000840a8c in add_thread_silent(ptid_t) (ptid=...) at src/gdb/thread.c:269
  #1  0x00000000007ad61d in remote_add_thread(ptid_t, int, int) (ptid=..., running=0, executing=0)
      at src/gdb/remote.c:1838
  #2  0x00000000007ad8de in remote_notice_new_inferior(ptid_t, int) (currthread=..., executing=0)
      at src/gdb/remote.c:1921
  #3  0x00000000007b758b in process_stop_reply(stop_reply*, target_waitstatus*) (stop_reply=0x1158860, status=0x7fffffffcc00)
      at src/gdb/remote.c:7217
  #4  0x00000000007b7a38 in remote_wait_as(ptid_t, target_waitstatus*, int) (ptid=..., status=0x7fffffffcc00, options=0)
      at src/gdb/remote.c:7380
  #5  0x00000000007b7cd1 in remote_wait(target_ops*, ptid_t, target_waitstatus*, int) (ops=0x102fac0 <remote_ops>, ptid=..., status=0x7fffffffcc00, options=0) at src/gdb/remote.c:7446
  #6  0x000000000081587b in delegate_wait(target_ops*, ptid_t, target_waitstatus*, int) (self=0x102fac0 <remote_ops>, arg1=..., arg2=0x7fffffffcc00, arg3=0) at src/gdb/target-delegates.c:138
  #7  0x0000000000827d77 in target_wait(ptid_t, target_waitstatus*, int) (ptid=..., status=0x7fffffffcc00, options=0)
      at src/gdb/target.c:2179
  #8  0x0000000000715fda in do_target_wait(ptid_t, target_waitstatus*, int) (ptid=..., status=0x7fffffffcc00, options=0)
      at src/gdb/infrun.c:3589
  #9  0x0000000000716351 in wait_for_inferior() () at src/gdb/infrun.c:3707
  #10 0x0000000000715435 in start_remote(int) (from_tty=1) at src/gdb/infrun.c:3212

things go downhill from this.

We don't see the problem with current master gdbserver, because that
version always sends the ";thread:" part in the initial stop reply:

 Sending packet: $?#3f...Packet received: T0506:0000000000000000;07:a0d4ffffff7f0000;10:d05eddf7ff7f0000;thread:p3cea.3cea;core:3;

Years ago I had added a "--disable-packet=" command line option to
gdbserver which comes in handy for testing this, since the existing
"--disable-packet=Tthread" precisely makes gdbserver not send that
";thread:" part in stop replies.  The testcase added by this commit
emulates old gdbserver making use of that.

I've compared a testrun at 5cd63fda035d^ (before regression) with
'current master+patch', against old gdbserver at f8b73d13b7ca^.  I
hacked out --once, and "monitor exit" to be able to test.  The results
are a bit too unstable to tell accurately, but it looked like there
were no regressions.  Maciej confirmed this worked for him as well.

No regressions on master (against master gdbserver).

gdb/ChangeLog:
2018-01-11  Pedro Alves  <palves@redhat.com>

PR remote/22597
* remote.c (remote_parse_stop_reply): Default to the last-set
general thread instead of to 'magic_null_ptid'.

gdb/testsuite/ChangeLog:
2018-01-11  Pedro Alves  <palves@redhat.com>

PR remote/22597
* gdb.server/stop-reply-no-thread.c: New file.
* gdb.server/stop-reply-no-thread.exp: New file.

6 years agoRemove VL variants for 4FMAPS and 4VNNIW insns.
Igor Tsimbalist [Wed, 10 Jan 2018 23:56:45 +0000 (02:56 +0300)] 
Remove VL variants for 4FMAPS and 4VNNIW insns.

AVX512_4FMAPS and AVX512_4VNNIW insns are marked as having AVX512VL
variants.  That is wrong as SDM doesn't define such instructions. The
patch removes these VL variants.

gas/
* testsuite/gas/i386/avx512_4fmaps-warn.l: Change xmm to zmm.
* testsuite/gas/i386/avx512_4fmaps-warn.s: Likewise.
* testsuite/gas/i386/avx512_4fmaps_vl-intel.d: Delete.
* testsuite/gas/i386/avx512_4fmaps_vl-warn.l: Likewise.
* testsuite/gas/i386/avx512_4fmaps_vl-warn.s: Likewise.
* testsuite/gas/i386/avx512_4fmaps_vl.d: Likewise.
* testsuite/gas/i386/avx512_4fmaps_vl.s: Likewise.
* testsuite/gas/i386/avx512_4vnniw_vl-intel.d: Likewise.
* testsuite/gas/i386/avx512_4vnniw_vl.d: Likewise.
* testsuite/gas/i386/avx512_4vnniw_vl.s: Likewise.
* testsuite/gas/i386/i386.exp: Delete _vl tests for 4fmaps an
4vnniw tests.
* testsuite/gas/i386/x86-64-avx512_4fmaps_vl-intel.d: Delete.
* testsuite/gas/i386/x86-64-avx512_4fmaps_vl-warn.l: Likewise.
* testsuite/gas/i386/x86-64-avx512_4fmaps_vl-warn.s: Likewise.
* testsuite/gas/i386/x86-64-avx512_4fmaps_vl.d: Likewise.
* testsuite/gas/i386/x86-64-avx512_4fmaps_vl.s: Likewise.
* testsuite/gas/i386/x86-64-avx512_4vnniw_vl-intel.d: Likewise.
* testsuite/gas/i386/x86-64-avx512_4vnniw_vl.d: Likewise.
* testsuite/gas/i386/x86-64-avx512_4vnniw_vl.s: Likewise.

opcodes/
* i386-opc.tbl: Remove VL variants for 4FMAPS and 4VNNIW
insns.
* i386-tbl.h: Regenerate.

6 years agoAutomatic date update in version.in
GDB Administrator [Thu, 11 Jan 2018 00:00:23 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agogas tc-arm.c warning fix
Alan Modra [Wed, 10 Jan 2018 23:04:58 +0000 (09:34 +1030)] 
gas tc-arm.c warning fix

* config/tc-arm.c (aeabi_set_public_attributes): Avoid false
positive "‘profile’ may be used uninitialized".

6 years agolanguage_get_symbol_name_matcher -> get_symbol_name_matcher
Pedro Alves [Wed, 10 Jan 2018 20:38:08 +0000 (20:38 +0000)] 
language_get_symbol_name_matcher -> get_symbol_name_matcher

Rename language_get_symbol_name_matcher -> get_symbol_name_matcher,
since the function is no longer a straight "language method".

gdb/ChangeLog:
2018-01-10  Pedro Alves  <palves@redhat.com>

* language.h (language_get_symbol_name_matcher): Rename ...
(get_symbol_name_matcher): ... this.
* language.c (language_get_symbol_name_matcher): Ditto.
* dictionary.c, linespec.c, minsyms.c, psymtab.c, symtab.c: All
callers adjusted.

6 years agoAda: make verbatim matcher override other language matchers (PR gdb/22670)
Pedro Alves [Wed, 10 Jan 2018 20:38:07 +0000 (20:38 +0000)] 
Ada: make verbatim matcher override other language matchers (PR gdb/22670)

A previous patch fixed verbatim matching in the lookup at the minimal
symbol level, but we should also be finding that same symbol through
the partial/full symtab search.

For example, this is what happens if we use "print" instead of
"break":

    (gdb) p <MixedCaseFunc>
    $1 = {<text variable, no debug info>} 0x4024dc <MixedCaseFunc>

Before the C++ wildmatching series, GDB knows that MixedCaseFunc is a
function without parameters, and the expression above means calling
it.  If you try it before having started the inferior, you'd get the
following (expected) error:

    (gdb) print  <MixedCaseFunc>
    You can't do that without a process to debug.

The main idea behind making the name matcher be determined by the
symbol's language is so that C++ (etc.) wildmatching in linespecs
works even if the current language is not C++, as e.g., when you step
through C or assembly code.

Ada's verbatim matching syntax however ("<...>") isn't quite the same.
It is more a property of the current language than of a particular
symbol's language.  We want to support this syntax when debugging an
Ada program, but it's reason of existence is to find non-Ada symbols.
This suggests going back to enabling it depending on current language
instead of language of the symbol being matched.

I'm not entirely happy with the "current_language" reference (though I
think that it's harmless).  I think we could try storing the current
language in the lookup_name_info object, and then convert a bunch of
functions more to pass around lookup_name_info objects instead of
"const char *" names.  I.e., build the lookup_name_info higher up.
I'm not sure about that, I'll have to think more about it.  Maybe
something different will be better.  Meanwhile, this gets us going.

I've extended the testcase to also exercise a no-debug-info function,
for extra coverage of the minsyms-only paths.

gdb/ChangeLog:
2018-01-10  Pedro Alves  <palves@redhat.com>

PR gdb/22670
* dwarf2read.c
(gdb_index_symbol_name_matcher::gdb_index_symbol_name_matcher):
Adjust to use language_get_symbol_name_matcher instead of
language_defn::la_get_symbol_name_matcher.
* language.c (language_get_symbol_name_matcher): If in Ada mode
and the lookup name is a verbatim match, return Ada's matcher.
* language.h (language_get_symbol_name_matcher): Adjust comment.
(ada_lookup_name_info::verbatim_p):: New method.

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

PR gdb/22670
* gdb.ada/bp_c_mixed_case.exp: Add intro comment.  Test printing C
functions too.  Test setting breakpoints and printing C functions
with no debug info too.
* gdb.ada/bp_c_mixed_case/qux.c: New file.

6 years agoFix gdb.ada/complete.exp's "complete break ada" test (PR gdb/22670)
Pedro Alves [Wed, 10 Jan 2018 20:38:07 +0000 (20:38 +0000)] 
Fix gdb.ada/complete.exp's "complete break ada" test (PR gdb/22670)

This patch fixes the regression covered by the test added by:

    commit 344420da6beac1e0b2f7964e7101f8dcdb509b0d
    Date: Thu Jan 4 03:30:37 2018 -0500
    Subject: Add "complete break ada" test to gdb.ada/complete.exp

The regression had been introduced by:

    commit b5ec771e60c1a0863e51eb491c85c674097e9e13
    Date:   Wed Nov 8 14:22:32 2017 +0000
    Subject: Introduce lookup_name_info and generalize Ada's FULL/WILD name matching

The gist of it is that linespec completion in Ada mode is generating
additional matches that should not appear in the match list
(internally generated symbols, or symbols that should be enclosed
between "<...>").  These extraneous entries have uppercase characters, such as:

    break ada__stringsS
    break ada__strings__R11s
    [etc]

These matches come from minimal symbols.  The problem is that Ada
minsyms end up with no language set (language_auto), and thus we end
up using the generic symbol name matcher for those instead of Ada's.
We already had a special case for in compare_symbol_name to handle
this, but it was limited to expressions, while the case at hand is
completing a linespec.  Fix this by applying the special case to
linespec completion as well.  I.e., remove the EXPRESSION check from
compare_symbol_name.  That alone turns out to not be sufficient still
-- GDB would still show a couple entries that shouldn't be there:

~~
    break ada__exceptions__exception_data__append_info_exception_name__2Xn
    break ada__exceptions__exception_data__exception_name_length__2Xn
~~

The reason is that these minimal symbols end up with their language
set to language_cplus / C++, because those encoded names manage to
demangle successfully as C++ symbols (using an old C++ mangling
scheme):

  $ echo ada__exceptions__exception_data__append_info_exception_name__2Xn | c++filt
  Xn::ada__exceptions__exception_data__append_info_exception_name(void)

It's unfortunate that Ada's encoding scheme doesn't start with some
unique prefix like "_Z" in the C++ Itanium ABI mangling scheme.  For
now, paper over that by treating C++ minsyms as Ada minsyms.

gdb/ChangeLog:
2018-01-10  Pedro Alves  <palves@redhat.com>

        PR gdb/22670
* ada-lang.c (ada_collect_symbol_completion_matches): If the
minsym's language is language_auto or language_cplus, pass down
language_ada instead.
* symtab.c (compare_symbol_name): Don't frob symbol language here.

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

        PR gdb/22670
* gdb.ada/complete.exp ("complete break ada"): Replace kfail with
a fail.

6 years agoFix gdb.ada/bp_c_mixed_case.exp (PR gdb/22670)
Pedro Alves [Wed, 10 Jan 2018 20:38:06 +0000 (20:38 +0000)] 
Fix gdb.ada/bp_c_mixed_case.exp (PR gdb/22670)

The problem here is that we are using the user-provided lookup name
literally for name comparisons.  I.e., "<MixedCase>" with the "<>"s
included.

This commit fixes the minsym lookup case.  psymbol/symbol lookup will
be fixed in a follow up.

In the minsym case, we're using using the user-provided lookup name
literally for linkage name comparisons.  That obviously can't work
since the "<>" are not really part of the linkage name.

The original idea was that we'd use the symbol's language to select
the right symbol name matching algorithm, but that doesn't work for
Ada because it's not really possible to unambiguously tell from the
linkage name alone whether we're dealing with Ada symbols, so Ada
minsyms end up with no language set, or sometimes C++ set.

So fix this by treating Ada mode specially when determining the
linkage name to match against.

gdb/ChangeLog:
2018-01-10  Pedro Alves  <palves@redhat.com>

PR gdb/22670
* minsyms.c (linkage_name_str): New function.
(iterate_over_minimal_symbols): Use it.

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

PR gdb/22670
* gdb.ada/bp_c_mixed_case.exp: Remove setup_kfail calls.

6 years agooops - updates to ChangeLog omitted by accident from previous delta.
Nick Clifton [Wed, 10 Jan 2018 15:35:34 +0000 (15:35 +0000)] 
oops - updates to ChangeLog omitted by accident from previous delta.

6 years agoUpdate top level configure files by synchronizing them with gcc.
Nick Clifton [Wed, 10 Jan 2018 15:29:21 +0000 (15:29 +0000)] 
Update top level configure files by synchronizing them with gcc.

. * config-ml.in: Sync with gcc sources.
* config.guess: Likewise.
* config.sub: Likewise.
* configure.ac: Likewise.
* configure: Regenerate.

config * Sync with GCC sources:

2017-11-14 Boris Kolpackov  <boris@codesynthesis.com>

* gcc-plugin.m4: Add support for MinGW.

2017-11-17  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>

* cet.m4: New file.

2017-11-15  Alexandre Oliva <aoliva@redhat.com>

* bootstrap-debug-lean.mk (do-compare): Use the
contrib/compare-debug script.

2017-10-24  H.J. Lu  <hongjiu.lu@intel.com>

* bootstrap-cet.mk: New file.

2017-06-19  Martin Liska  <mliska@suse.cz>

* bootstrap-lto-noplugin.mk: Enable -flto in all PGO stages.
* bootstrap-lto.mk: Likewise.

2017-06-03  Eric Botcazou  <ebotcazou@adacore.com>

* mt-android: New file.

2017-02-13  Richard Biener  <rguenther@suse.de>

* isl.m4: Remove support for ISL 0.14.

2017-01-19  Uros Bizjak  <ubizjak@gmail.com>

PR target/78478
* ax_check_define.m4: New file.

2017-01-17  Jakub Jelinek  <jakub@redhat.com>

PR other/79046
* acx.m4 (GCC_BASE_VER): New m4 function.
(ACX_TOOL_DIRS): Require GCC_BASE_VER, for
--with-gcc-major-version-only use just major number from BASE-VER.

2017-01-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

PR go/78978
* hwcaps.m4 (GCC_CHECK_ASSEMBLER_HWCAP): New macro.

6 years agoUpdate the libiberty sources with the latest patches found in the master sources.
Nick Clifton [Wed, 10 Jan 2018 13:57:48 +0000 (13:57 +0000)] 
Update the libiberty sources with the latest patches found in the master sources.

2017-01-02  Richard Biener  <rguenther@suse.de>

PR lto/83452
* simple-object-elf.c (simple_object_elf_copy_lto_debug_section):
Do not use UNDEF locals for removed symbols but instead just
define them in the first prevailing section and with no name.
Use the same gnu_lto_v1 name for all removed globals we promote to
WEAK UNDEFs so hpux can use a stub to provide this symbol.  Clear
sh_info and sh_link in removed sections.

2017-10-30  Richard Biener  <rguenther@suse.de>

PR lto/82757
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Strip two leading _s from the __gnu_lto_* symbols.

2017-10-24  Alan Modra  <amodra@gmail.com>

PR lto/82687
PR lto/82575
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Only make __gnu_lto symbols hidden.

2017-10-20  Alan Modra  <amodra@gmail.com>

PR lto/82575
* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
Make discarded non-local symbols weak and hidden.

2017-10-18  Jakub Jelinek  <jakub@redhat.com>

PR lto/82598
* simple-object.c (handle_lto_debug_sections): Copy over also
.note.GNU-stack section with unchanged name.
* simple-object-elf.c (SHF_EXECINSTR): Define.
(simple_object_elf_copy_lto_debug_section): Drop SHF_EXECINSTR bit
on .note.GNU-stack section.

2017-09-25  Nathan Sidwell  <nathan@acm.org>

PR demangler/82195
* cp-demangle.c (d_encoding): Strip return type when name is a
LOCAL_NAME.
(d_local_name): Strip return type of enclosing TYPED_NAME.
* testsuite/demangle-expected: Add and adjust tests.

2017-09-21  Nathan Sidwell  <nathan@acm.org>

PR demangler/82195
* cp-demangle.c (d_name): Revert addition of 'toplevel' parm.
(has_return_type): Recurse for DEMANGLE_COMPONENT_LOCAL_NAME.
(d_encoding): Revert d_name change.  Use is_fnqual_component_type
to strip modifiers that do not belong.
(d_special_name, d_class_enum_type): Revert d_name call change.
(d_expresion_1): Commonize DEMANGLE_COMPONENT_UNARY building.
(d_local_name): Revert parsing of a function type.
(d_print_comp_inner): An inner LOCAL_NAME might contain a
TEMPLATE.
* testsuite/demangle-expected: Add & adjust tests

6 years agox86: fix Disp8 handling for scalar AVX512_4FMAPS insns
Jan Beulich [Wed, 10 Jan 2018 13:53:43 +0000 (14:53 +0100)] 
x86: fix Disp8 handling for scalar AVX512_4FMAPS insns

Just like their packed counterparts the memory operand is always 16
bytes wide, and the Disp8 scaling is the same for all of them. (As a
side note: I'm also surprised by there being AVX512VL variants of
these as well as the AVX512_4VNNIW ones - the SDM doesn't define any
such.)

Adjust the test cases also for the packed forms to actually live up to
their promise of testing correct Disp8 encoding.

6 years agox86: fix Disp8 handling for AVX512VL VPCMP*{B,W} variants
Jan Beulich [Wed, 10 Jan 2018 13:53:05 +0000 (14:53 +0100)] 
x86: fix Disp8 handling for AVX512VL VPCMP*{B,W} variants

In commit 2645e1d079 ("x86: add support for AVX-512 VPCMP*{B,W}
pseudo-ops") I screwed up the Disp8MemShift values of the AVX512VL
variants.

6 years agoRISC-V: Disassemble x0 based addresses as 0.
Jim Wilson [Wed, 10 Jan 2018 00:40:06 +0000 (16:40 -0800)] 
RISC-V: Disassemble x0 based addresses as 0.

gas/
* testsuite/gas/riscv/auipc-x0.d: New.
* testsuite/gas/riscv/auipc-x0.s: New.

opcodes/
* riscv-dis.c (maybe_print_address): If base_reg is zero,
then the hi_addr value is zero.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 10 Jan 2018 00:00:34 +0000 (00:00 +0000)] 
Automatic date update in version.in

6 years agoDocument support for 'info proc' on FreeBSD.
John Baldwin [Tue, 9 Jan 2018 21:35:17 +0000 (13:35 -0800)] 
Document support for 'info proc' on FreeBSD.

Since the 'info proc' support on FreeBSD does not use /proc, reword
the documentation for 'info proc' to not assume /proc.  This includes
renaming the node to 'Process Information' and suggesting that
additional process information can be queried via different
OS-specific interfaces.  This is also cleans up the description of
'info proc' support for core files a bit as /proc is not used for core
file support on any current platform.

gdb/ChangeLog:

* NEWS: Document that 'info proc' now works on FreeBSD.

gdb/doc/ChangeLog:

* gdb.texinfo (pwd): Update cross-reference for Process Information
node and remove explicit /proc reference.
(Native): Rename subsection from SVR4 Process Information to
Process Information.
(Process Information): Reword introduction to be less /proc
centric.  Document support for "info proc" on FreeBSD.

6 years agoSupport 'info proc' for native FreeBSD processes.
John Baldwin [Tue, 9 Jan 2018 21:35:17 +0000 (13:35 -0800)] 
Support 'info proc' for native FreeBSD processes.

- Command line arguments are fetched via the kern.proc.args.<pid>
  sysctl.
- The 'cwd' and 'exe' values are obtained from the per-process
  file descriptor table returned by kinfo_getfile() from libutil.
- 'mappings' is implemented by walking the array of VM map entries
  returned by kinfo_getvmmap() from libutil.
- 'status' output is generated by outputting fields from the structure
  returned by the kern.proc.pid.<pid> sysctl.
- 'stat' is aliased to 'status'.

gdb/ChangeLog:

* configure.ac: Check for kinfo_getfile in libutil.
* configure: Regenerate.
* config.in: Regenerate.
* fbsd-nat.c: Include "fbsd-tdep.h".
(fbsd_fetch_cmdline): New.
(fbsd_fetch_kinfo_proc): Move earlier and change to return a bool
rather than calling error.
(fbsd_info_proc): New.
(fbsd_thread_name): Report error if fbsd_fetch_kinfo_proc fails.
(fbsd_wait): Report warning if fbsd_fetch_kinfo_proc fails.
(fbsd_nat_add_target): Set "to_info_proc" to "fbsd_info_proc".

6 years agoUse gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free().
John Baldwin [Tue, 9 Jan 2018 21:35:17 +0000 (13:35 -0800)] 
Use gdb::unique_xmalloc_ptr<> instead of a deleter that invokes free().

Since xfree() always wraps free(), it is safe to use the xfree deleter
for buffers allocated by library routines such as kinfo_getvmmap() that
must be released via free().

gdb/ChangeLog:

* fbsd-nat.c (struct free_deleter): Remove.
(fbsd_find_memory_regions): Use gdb::unique_xmalloc_ptr<>.

6 years agoDon't return stale data from fbsd_pid_to_exec_file for kernel processes.
John Baldwin [Tue, 9 Jan 2018 21:35:17 +0000 (13:35 -0800)] 
Don't return stale data from fbsd_pid_to_exec_file for kernel processes.

For processes without an associated executable (such as kernel processes),
the kern.proc.pathname.<pid> system control node returns a length of zero
without modifying the user's buffer.  Detect this case and return NULL
rather than the previous contents of the static buffer 'buf'.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_pid_to_exec_file) [KERN_PROC_PATHNAME]: Return
NULL for an empty pathname.

6 years agoSupport 'info proc' for FreeBSD process core dumps.
John Baldwin [Tue, 9 Jan 2018 21:35:17 +0000 (13:35 -0800)] 
Support 'info proc' for FreeBSD process core dumps.

- Command line arguments are obtained from the pr_psargs[] array
  saved in the NT_PRPSINFO note.
- The 'cwd' and 'exe' values are obtained from the per-process file
  descriptor table stored in the NT_PROCSTAT_FILES core note.
- 'mappings' is implemented by walking the array of VM map entries
  stored in the NT_PROCSTAT_VMMAP core note.
- 'status' output is generated by outputting fields from
  the first structure stored in the NT_PROCSTAT_PROC core note.
- 'stat' is aliased to 'status'.

gdb/ChangeLog:

* fbsd-tdep.c (KVE_STRUCTSIZE, KVE_START, KVE_END, KVE_OFFSET)
(KVE_FLAGS, KVE_PROTECTION, KVE_PATH, KINFO_VME_PROT_READ)
(KINFO_VME_PROT_WRITE, KINFO_VME_PROT_EXEC, KINFO_VME_FLAG_COW)
(KINFO_VME_FLAG_NEEDS_COPY, KINFO_VME_FLAG_NOCOREDUMP)
(KINFO_VME_FLAG_SUPER, KINFO_VME_FLAG_GROWS_UP)
(KINFO_VME_FLAG_GROWS_DOWN, KF_STRUCTSIZE, KF_TYPE, KF_FD)
(KF_PATH, KINFO_FILE_TYPE_VNODE, KINFO_FILE_FD_TYPE_CWD)
(KINFO_FILE_FD_TYPE_TEXT, SIG_WORDS, struct kinfo_proc_layout)
(kinfo_proc_layout_32, kinfo_proc_layout_i386)
(kinfo_proc_layout_64, fbsd_vm_map_entry_flags)
(fbsd_core_info_proc_mappings, fbsd_core_vnode_path)
(fbsd_core_fetch_timeval, fbsd_print_sigset)
(fbsd_core_info_proc_status, fbsd_core_info_proc): New.
(fbsd_init_abi):  Install gdbarch "core_info_proc" method.
* fbsd-tdep.h (fbsd_vm_map_entry_flags): New.

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