platform/upstream/binutils.git
7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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.

7 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

7 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.

7 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.

7 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.

7 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.

7 years agoAdd 2 testcases for PR ld/22269
H.J. Lu [Sat, 7 Oct 2017 10:07:36 +0000 (03:07 -0700)]
Add 2 testcases for PR ld/22269

Since undefined weak symbols in static PIE are always resolved to 0 at
run-time, linker should resolve them as 0 at link-time, regardless of
whether "-z dynamic-undefined-weak" is used.  "-z dynamic-undefined-weak"
only makes undefined weak symbols dynamic, but doesn't change undefined
weak symbol resolution in static PIE at link-time.  These tests currently
pass on x86, but fails on many other targets.

The framework to resolve weak symbols in static PE at link-time is
posted at

https://sourceware.org/ml/binutils/2017-10/msg00087.html

which requires users/hjl/check_relocs branch to call check_relocs after
opening all inputs.  I will submit backend patches for failling targets
after merging users/hjl/check_relocs branch next.

* PR ld/22269
* testsuite/ld-elf/pr22269.s: New file.
* testsuite/ld-elf/pr22269a.d: Likewise.
* testsuite/ld-elf/pr22269b.d: Likewise.

7 years agox86: Run PR ld/19636 tests with -z dynamic-undefined-weak
H.J. Lu [Wed, 11 Oct 2017 20:32:20 +0000 (13:32 -0700)]
x86: Run PR ld/19636 tests with -z dynamic-undefined-weak

"-z dynamic-undefined-weak" makes undefined weak symbols dynamic, but
undefined weak symbols are still resolved to 0 at link-time if there
is no dynamic linker in executable.

* testsuite/ld-i386/i386.exp: Run pr19636-1j, pr19636-1k,
pr19636-1l, pr19636-3h and pr19636-3i.
* testsuite/ld-i386/pr19636-1j.d: New file.
* testsuite/ld-i386/pr19636-1k.d: Likewise.
* testsuite/ld-i386/pr19636-1l.d: Likewise.
* testsuite/ld-i386/pr19636-3h.d: Likewise.
* testsuite/ld-i386/pr19636-3i.d: Likewise.
* testsuite/ld-x86-64/pr19636-1h.d: Likewise.
* testsuite/ld-x86-64/pr19636-1i.d: Likewise.
* testsuite/ld-x86-64/pr19636-1j.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.
* testsuite/ld-x86-64/x86-64.exp: Run pr19636-1h, pr19636-1i,
pr19636-1j, pr19636-2j, pr19636-2k, pr19636-2l and pr19636-2m.

7 years agoAdd native target for FreeBSD/arm.
John Baldwin [Wed, 11 Oct 2017 18:16:34 +0000 (11:16 -0700)]
Add native target for FreeBSD/arm.

gdb/ChangeLog:

* Makefile.in (ALLDEPFILES): Add arm-fbsd-nat.c.
* NEWS: Mention new FreeBSD/arm native configuration.
* configure.host: Add arm*-*-freebsd*.
* configure.nat: Likewise.
* arm-fbsd-nat.c: New file.

7 years agoAdd FreeBSD/arm architecture.
John Baldwin [Wed, 11 Oct 2017 18:16:34 +0000 (11:16 -0700)]
Add FreeBSD/arm architecture.

Support for collecting and supplying general purpose and floating
point registers is provided along with signal frame unwinding.  While
FreeBSD/arm kernels do populate NT_FPREGSET notes, they are always
zero-filled, so this implementation ignores them.  Recent FreeBSD/arm
kernels generate NT_ARM_VFP notes which are used to supply
floating-point registers.  As with Linux, the AT_HWCAP feature flags
are used to determine the correct target description.

gdb/ChangeLog:

* Makefile.in (ALL_TARGET_OBS): Add arm-fbsd-tdep.o.
(ALLDEPFILES): Add arm-fbsd-tdep.c.
* NEWS: Mention new FreeBSD/arm target.
* configure.tgt: Add arm*-*-freebsd*.
* arm-fbsd-tdep.c: New file.
* arm-fbsd-tdep.h: New file.

7 years agoDisable the inclusion of logical input files in the assembler listing output unless...
Nick Clifton [Wed, 11 Oct 2017 15:48:16 +0000 (16:48 +0100)]
Disable the inclusion of logical input files in the assembler listing output unless high level source listing has been enabled.

PR 21977
* listing.c (listing_newline): Use the name of the current
physical input file, rather than the current logical input file,
unless including high level source in the listing.
* input-scrub.c (as_where_physical): New function.  Returns the
name of the current physical input file.
* as.h: Add prototype for as_where_physical.

7 years agoGDB: Remove Linux core PRPSINFO note writer override
Maciej W. Rozycki [Wed, 11 Oct 2017 14:01:41 +0000 (15:01 +0100)]
GDB: Remove Linux core PRPSINFO note writer override

Revert parts of commit b3ac9c77560a ("Put more info in NT_PRPSINFO Linux
notes"), <https://sourceware.org/ml/binutils/2013-02/msg00024.html>, and
remove support for a Linux core PRPSINFO note writer override, now that
all variants are handled automatically within BFD itself.

gdb/
* linux-tdep.c (linux_make_corefile_notes): Remove call to
`gdbarch_elfcore_write_linux_prpsinfo'.
* gdbarch.sh (elfcore_write_linux_prpsinfo): Remove architecture
method.
(elf_internal_linux_prpsinfo): Remove declaration.
* gdbarch.h: Regenerate.
* gdbarch.c: Regenerate.

7 years agoELF/BFD: Handle both variants of the 64-bit Linux core PRPSINFO note
Maciej W. Rozycki [Wed, 11 Oct 2017 14:01:41 +0000 (15:01 +0100)]
ELF/BFD: Handle both variants of the 64-bit Linux core PRPSINFO note

Fix commit 70a38d42c5b3 ("New entry points for writing Linux NT_PRPSINFO
notes."), <https://sourceware.org/ml/binutils/2013-02/msg00023.html>,
and handle both variants of the 64-bit Linux core PRPSINFO note across
all targets.

The 64-bit Linux core PRPSINFO note matches the 64-bit kernel structure,
defined as follows:

(gdb) ptype struct elf_prpsinfo
type = struct elf_prpsinfo {
    char pr_state;
    char pr_sname;
    char pr_zomb;
    char pr_nice;
    unsigned long pr_flag;
    __kernel_uid_t pr_uid;
    __kernel_gid_t pr_gid;
    pid_t pr_pid;
    pid_t pr_ppid;
    pid_t pr_pgrp;
    pid_t pr_sid;
    char pr_fname[16];
    char pr_psargs[80];
}
(gdb)

where the individual data types of most members are the same across all
64-bit Linux ports, with the exception of `__kernel_uid_t' and
`__kernel_gid_t'.  These are defined in <asm-generic/posix_types.h> as
32-bit `unsigned int' by default, however overridden as 16-bit `unsigned
short' in port-specific <asm/posix_types.h> for the SuperH target.

The default is already handled, as from the commit referred.  Add the
other variant then and provide a backend flag to switch between the two
cases possible, with the 32-bit one being the default and the 16-bit one
explicitly selected.  Set the flag in the SuperH target backend.  This
arrangement is analogous to how the 32-bit Linux core PRPSINFO note is
handled.

bfd/
* elf-bfd.h (elf_backend_data): Add `linux_prpsinfo64_ugid16'
member.
* elf-linux-core.h (elf_external_linux_prpsinfo64): Rename to...
(elf_external_linux_prpsinfo64_ugid32): ... this.
(swap_linux_prpsinfo32_out): Rename to...
(swap_linux_prpsinfo32_ugid32_out): ... this.
(elf_external_linux_prpsinfo64_ugid16): New structure.
(swap_linux_prpsinfo64_ugid16_out): New function.
* elfxx-target.h [!elf_backend_linux_prpsinfo64_ugid16]
(elf_backend_linux_prpsinfo64_ugid16): Define.
(elfNN_bed): Initialize `linux_prpsinfo64_ugid16' member.
* elf.c (elfcore_write_linux_prpsinfo64): Handle both variants
of the 64-bit Linux core PRPSINFO note.
* elf64-sh64.c (elf_backend_linux_prpsinfo64_ugid16): Define.

7 years agoELF/BFD,GDB: Handle both variants of the 32-bit Linux core PRPSINFO note
Maciej W. Rozycki [Wed, 11 Oct 2017 14:01:40 +0000 (15:01 +0100)]
ELF/BFD,GDB: Handle both variants of the 32-bit Linux core PRPSINFO note

Fix commit 70a38d42c5b3 ("New entry points for writing Linux NT_PRPSINFO
notes."), <https://sourceware.org/ml/binutils/2013-02/msg00023.html>,
and commit b3ac9c77560a ("Put more info in NT_PRPSINFO Linux notes"),
<https://sourceware.org/ml/binutils/2013-02/msg00024.html>, and handle
both variants of the 32-bit Linux core PRPSINFO note across all targets.

The 32-bit Linux core PRPSINFO note matches the 32-bit kernel structure,
defined as follows:

(gdb) ptype struct elf_prpsinfo
type = struct elf_prpsinfo {
    char pr_state;
    char pr_sname;
    char pr_zomb;
    char pr_nice;
    unsigned long pr_flag;
    __kernel_uid_t pr_uid;
    __kernel_gid_t pr_gid;
    pid_t pr_pid;
    pid_t pr_ppid;
    pid_t pr_pgrp;
    pid_t pr_sid;
    char pr_fname[16];
    char pr_psargs[80];
}
(gdb)

where the individual data types of most members are the same across all
32-bit Linux ports, with the exception of `__kernel_uid_t' and
`__kernel_gid_t'.  These are defined in <asm-generic/posix_types.h> as
32-bit `unsigned int' by default, however overridden as 16-bit `unsigned
short' in port-specific <asm/posix_types.h> for a few targets, mostly
earlier ports of Linux, specifically: ARM, CRIS, FR-V, M32R, m68k,
MN10300/AM33, s390, SuperH, SPARC and i386.

The default is the same as the PowerPC variant already handled, as from
the commits referred.  Make the special PowerPC case generic then,
removing the GDB part, and provide a backend flag to switch between the
two cases possible, with the 32-bit one being the default and the 16-bit
one explicitly selected.  Set the flag in the target backends affected.

bfd/
* elf-bfd.h (elf_backend_data): Add `linux_prpsinfo32_ugid16'
member.
(elfcore_write_ppc_linux_prpsinfo32): Remove prototype.
* elf32-ppc.c (elfcore_write_ppc_linux_prpsinfo32): Remove.
(elf_external_ppc_linux_prpsinfo32)
(swap_ppc_linux_prpsinfo32_out): Move to...
* elf-linux-core.h (elf_external_linux_prpsinfo32_ugid32)
(swap_linux_prpsinfo32_ugid32_out): ... these.
(elf_external_linux_prpsinfo32): Rename to...
(elf_external_linux_prpsinfo32_ugid16): ... this.
(swap_linux_prpsinfo32_out): Rename to...
(swap_linux_prpsinfo32_ugid16_out): ... this.
* elfxx-target.h [!elf_backend_linux_prpsinfo32_ugid16]
(elf_backend_linux_prpsinfo32_ugid16): Define.
(elfNN_bed): Initialize `linux_prpsinfo32_ugid16' member.
* elf.c (elfcore_write_linux_prpsinfo32): Handle both variants
of the 32-bit Linux core PRPSINFO note.
* elf32-am33lin.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-arm.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-cris.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-frv.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-i386.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-m32r.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-m68k.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-s390.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-sh.c (elf_backend_linux_prpsinfo32_ugid16): Define.
* elf32-sparc.c (elf_backend_linux_prpsinfo32_ugid16): Define.

gdb/
* ppc-linux-tdep.c (ppc_linux_init_abi): Remove call to
`set_gdbarch_elfcore_write_linux_prpsinfo'.

7 years agoELF/BFD: Fix padding in `elf_external_linux_prpsinfo64'
Maciej W. Rozycki [Wed, 11 Oct 2017 14:01:40 +0000 (15:01 +0100)]
ELF/BFD: Fix padding in `elf_external_linux_prpsinfo64'

Fix commit 70a38d42c5b3 ("New entry points for writing Linux NT_PRPSINFO
notes."), <https://sourceware.org/ml/binutils/2013-02/msg00023.html>,
and move the padding of the `elf_external_linux_prpsinfo64' structure to
match the corresponding 64-bit Linux kernel `elf_prpsinfo' structure.

The 64-bit kernel structure is defined as follows:

(gdb) ptype struct elf_prpsinfo
type = struct elf_prpsinfo {
    char pr_state;
    char pr_sname;
    char pr_zomb;
    char pr_nice;
    unsigned long pr_flag;
    __kernel_uid_t pr_uid;
    __kernel_gid_t pr_gid;
    pid_t pr_pid;
    pid_t pr_ppid;
    pid_t pr_pgrp;
    pid_t pr_sid;
    char pr_fname[16];
    char pr_psargs[80];
}
(gdb) print /x &((struct elf_prpsinfo *)0)->pr_nice
$1 = 0x3
(gdb) print /x &((struct elf_prpsinfo *)0)->pr_flag
$2 = 0x8
(gdb) print /x &((struct elf_prpsinfo *)0)->pr_uid
$3 = 0x10
(gdb) print sizeof(((struct elf_prpsinfo *)0)->pr_flag)
$4 = 8
(gdb)

with implicit padding present before the `pr_flag' member, to correctly
align it to a multiple of 8.  Conversely `elf_external_linux_prpsinfo64'
has padding after its `pr_flag' member:

(top-gdb) ptype struct elf_external_linux_prpsinfo64
type = struct elf_external_linux_prpsinfo64 {
    char pr_state;
    char pr_sname;
    char pr_zomb;
    char pr_nice;
    char pr_flag[8];
    char gap[4];
    char pr_uid[4];
    char pr_gid[4];
    char pr_pid[4];
    char pr_ppid[4];
    char pr_pgrp[4];
    char pr_sid[4];
    char pr_fname[16];
    char pr_psargs[80];
}
(top-gdb) print /x &((struct elf_external_linux_prpsinfo64 *)0)->pr_nice
$1 = 0x3
(top-gdb) print /x &((struct elf_external_linux_prpsinfo64 *)0)->pr_flag
$2 = 0x4
(top-gdb) print /x &((struct elf_external_linux_prpsinfo64 *)0)->pr_uid
$3 = 0x10
(top-gdb)

and consequently `pr_flag' is misplaced.  Move `gap' ahead of `pr_flag'
then.

bfd/
* elf-linux-core.h (elf_external_linux_prpsinfo64): Move the
`gap' member ahead of `pr_flag'.

7 years agoGarbage collect reattach_breakpoints
Pedro Alves [Wed, 11 Oct 2017 13:45:17 +0000 (14:45 +0100)]
Garbage collect reattach_breakpoints

Not used anywhere.

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

* breakpoint.c (reattach_breakpoints): Delete.
* breakpoint.h (reattach_breakpoints): Delete.

7 years agoUse std::vector for symtab_fns
Simon Marchi [Wed, 11 Oct 2017 13:34:08 +0000 (09:34 -0400)]
Use std::vector for symtab_fns

Simple replacement of VEC with std::vector.

gdb/ChangeLog:

* symfile.c (registered_sym_fns): Make struct, not typedef.
(DEF_VEC_O (registered_sym_fns)): Remove.
(symtab_fns): Change type to std::vector.
(add_symtab_fns): Adjust.
(find_sym_fns): Adjust.

7 years agoarc: Pass proper CPU value to the disassembler
Anton Kolesov [Tue, 27 Jun 2017 16:12:14 +0000 (19:12 +0300)]
arc: Pass proper CPU value to the disassembler

There was a problem with generation of the disassembler options for ARC in GDB,
because a BFD architecture name was used as a CPU name, but they have different
meaning even if some architectures have same name as respective CPUs.  Target
description specifies a BFD architecture, which is different from ARC CPU, as
accepted by the disassembler (and most other ARC tools), because CPU values are
much more fine grained - there can be multiple CPU values per single BFD
architecture.  As a result this code should translate architecture to some CPU
value.  Since there is no info on exact CPU configuration, it is best to use
the most feature-rich CPU, so that the disassembler will recognize all
instructions available to the specified architecture.

gdb/ChangeLog
yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>

* arc-tdep.c (arc_gdbarch_init): Pass proper cpu value to disassembler.
* arc-tdep.h (arc_arch_is_em): New function.
(arc_arch_is_hs): Likewise.

gdb/testsuite/ChangeLog
yyyy-mm-dd  Anton Kolesov  <Anton.Kolesov@synopsys.com>

* gdb.arch/arc-tdesc-cpu.exp: New file.
* gdb.arch/arc-tdesc-cpu.xml: Likewise.

7 years agoRename _doprnt -> _bfd_doprnt to fix DJGPP bfd build (and likely others)
Pedro Alves [Wed, 11 Oct 2017 11:47:25 +0000 (12:47 +0100)]
Rename _doprnt -> _bfd_doprnt to fix DJGPP bfd build (and likely others)

Building bfd/ for DJGPP, I see:

 ../../src/bfd/bfd.c:642:1: error: conflicting types for '_doprnt'
  _doprnt (FILE *stream, const char *format, va_list ap)
  ^~~~~~~
 In file included from ../../src/bfd/sysdep.h:37:0,
  from ../../src/bfd/bfd.c:367:
 /usr/lib64/gcc/i586-pc-msdosdjgpp/6.1.0/include-fixed/stdio.h:171:5: note: previous declaration of '_doprnt' was here
  int _doprnt(const char *_fmt, va_list _args, FILE *_f);
      ^~~~~~~

Possible fixes the build on other systems too -- _doprnt was/is an
exported symbol on old Unix/BSD systems too.

bfd/ChangeLog:
2017-10-11  Pedro Alves  <palves@redhat.com>

* bfd.c (_doprnt): Rename to ...
(_bfd_doprnt): ... this.
(error_handler_internal): Adjust.

7 years agoDisplay more information when decoding DW_AT_endianity, DW_AT_decimal_sign, DW_AT_def...
Nick Clifton [Wed, 11 Oct 2017 11:02:51 +0000 (12:02 +0100)]
Display more information when decoding DW_AT_endianity, DW_AT_decimal_sign, DW_AT_defaulted and DW_AT_discr_list DWARF attributes.

* dwarf.c (read_and_display_attr_value): Handle DW_AT_endianity,
DW_END_default, DW_END_big, DW_END_little, DW_ATE_UCS,
DW_ATE_ASCII, DW_CC_pass_by_reference, DW_CC_pass_by_value,
DW_CC_GNU_renesas_sh, DW_CC_GNU_borland_fastcall_i386,
DW_AT_decimal_sign, DW_AT_defaulted, DW_AT_discr_list.
(get_TAG_name): Report user generated tag values.
* testsuite/binutils-all/dwarf-attributes.S: New test.
* testsuite/binutils-all/dwarf-attributes.W. Expected output from
readelf.
* testsuite/binutils-all/readelf.exp: Run the new test.

7 years agoRemove unnecessary parentheses in declarations
Egeyar Bagcioglu [Wed, 11 Oct 2017 10:00:48 +0000 (11:00 +0100)]
Remove unnecessary parentheses in declarations

GCC commit a94975e57 ("C++ warning on vexing parse") introduces new
warnings "unnecessary parentheses in the declaration of ...".  These
cause the build of binutils and gdb to fail.  This patch removes those
parentheses for a successful build.

gdb/ChangeLog:
2017-10-11  Egeyar Bagcioglu  <egeyar.bagcioglu@oracle.com>

* macrotab.h (macro_lookup_inclusion): Remove unnecessary
parentheses in the declaration.
(macro_lookup_inclusion): Likewise.
(macro_lookup_definition): Likewise.
* p-lang.h (pascal_builtin_types): Likewise.
* tui/tui-data.c (tui_win_list): Likewise.
* tui/tui-data.h (tui_win_list): Likewise.
* utils.h (make_cleanup_free_section_addr_info): Likewise.

7 years agoFlash memory size not aligned to address
Kevin Buettner [Wed, 11 Oct 2017 05:47:01 +0000 (22:47 -0700)]
Flash memory size not aligned to address

(This patch is from Mark Rages <markrages@gmail.com>.)

The Nordic nRF52 memory map, reported from black magic probe:

Num Enb Low Addr High Addr Attrs
0 y 0x00000000 0x00080000 flash blocksize 0x1000 nocache
1 y 0x10001000 0x10001210 flash blocksize 0x210 nocache
2 y 0x20000000 0x20010000 rw nocache

The region at 0x10001000 is "UICR" and it is a section of flash that is
erased all at once.

Notice the odd size: 0x210 is the size of the region defined in the
datasheet.

But because the block size was listed as 0x210, gdb was insisting on
issuing two erase commands divisible by 0x210, starting below 0x10001000.

This patch fixes it by doing the alignment computation from the start of
the region, not from address 0.

gdb/ChangeLog:

* target-memory.c (block_boundaries): Fix for block address not
aligned on block size.

7 years agold internationalization fixes
Alan Modra [Wed, 11 Oct 2017 04:18:45 +0000 (14:48 +1030)]
ld internationalization fixes

* emultempl/aarch64elf.em: Wrap einfo strings in _().  Formatting.
* emultempl/aix.em: Likewise.
* emultempl/armcoff.em: Likewise.
* emultempl/armelf.em: Likewise.
* emultempl/avrelf.em: Likewise.
* emultempl/beos.em: Likewise.
* emultempl/cr16elf.em: Likewise.
* emultempl/elf-generic.em: Likewise.
* emultempl/elf32.em: Likewise.
* emultempl/genelf.em: Likewise.
* emultempl/hppaelf.em: Likewise.
* emultempl/linux.em: Likewise.
* emultempl/lnk960.em: Likewise.
* emultempl/m68hc1xelf.em: Likewise.
* emultempl/m68kcoff.em: Likewise.
* emultempl/m68kelf.em: Likewise.
* emultempl/metagelf.em: Likewise.
* emultempl/mipself.em: Likewise.
* emultempl/mmix-elfnmmo.em: Likewise.
* emultempl/mmo.em: Likewise.
* emultempl/msp430.em: Likewise.
* emultempl/nds32elf.em: Likewise.
* emultempl/nios2elf.em: Likewise.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/ppc32elf.em: Likewise.
* emultempl/ppc64elf.em: Likewise.
* emultempl/riscvelf.em: Likewise.
* emultempl/s390.em: Likewise.
* emultempl/scoreelf.em: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/sunos.em: Likewise.
* emultempl/tic6xdsbt.em: Likewise.
* emultempl/v850elf.em: Likewise.
* emultempl/vms.em: Likewise.
* emultempl/vxworks.em: Likewise.
* ldcref.c: Likewise.
* ldlang.c: Likewise.
* ldlex.l: Likewise.
* ldmain.c: Likewise.
* pe-dll.c: Likewise.
* plugin.c: Likewise.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 11 Oct 2017 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agox86: Set GOT refcount to 1
H.J. Lu [Tue, 10 Oct 2017 22:52:39 +0000 (15:52 -0700)]
x86: Set GOT refcount to 1

Since x86 check_relocs is called after opening all inputs and garbage
collection, they never see the removed sections.  There is no need
for incrementing GOT refcount.  But since PLT refcount is also used in

  /* Don't create the PLT entry if there are only function pointer
     relocations which can be resolved at run-time.  */
  else if (htab->elf.dynamic_sections_created
           && (h->plt.refcount > eh->func_pointer_refcount
               || eh->plt_got.refcount > 0))
    {

we must increment it.

* elf32-i386.c (elf_i386_check_relocs): Set GOT refcount to 1
instead of incrementing it.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.

7 years agoget_integer_valueof: Don't output value in test name
Simon Marchi [Tue, 10 Oct 2017 19:10:25 +0000 (15:10 -0400)]
get_integer_valueof: Don't output value in test name

The get_integer_valueof outputs the value it has read as part of the
test name.  This causes test names to vary from run to run, and adds
some noise when diffing test results.  e.g.:

-PASS: gdb.threads/process-dies-while-detaching.exp: multi-process: continue: killed outside: get integer valueof "mypid" (28770)
+PASS: gdb.threads/process-dies-while-detaching.exp: multi-process: continue: killed outside: get integer valueof "mypid" (32238)

This patch removes that, since it's probably not very useful.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (get_integer_valueof): Don't output read value in test name.

7 years agoBump dwarf-mode version number
Tom Tromey [Fri, 6 Oct 2017 20:38:36 +0000 (14:38 -0600)]
Bump dwarf-mode version number

Bump the dwarf-mode version number, so it can be installed by package.el
users who installed an earlier verision.

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

* dwarf-mode.el: Bump to version 1.4.

7 years agoAsynchronous insertion for dwarf-mode.el
Tom Tromey [Fri, 6 Oct 2017 20:36:44 +0000 (14:36 -0600)]
Asynchronous insertion for dwarf-mode.el

I was recently examining a very large .debug file.  I tried to use
dwarf-mode, but it blocked Emacs for a very long time while reading
output.

This patch changes dwarf-mode to run the objdump process asynchronously.
This way, I can still do other things in Emacs while waiting for the
dumping to finish.

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

* dwarf-mode.el (dwarf--process, dwarf--deletion-region): New
defvar.
(dwarf--check-running, dwarf--sentinel, dwarf--invoke)
(dwarf--filter): New functions.
(dwarf-do-insert-substructure, dwarf-do-refresh): Call
dwarf--check-running, dwarf--invoke.
(dwarf-browse): Initialize new variables.

7 years agoSet lexical-binding in dwarf-mode
Tom Tromey [Fri, 6 Oct 2017 19:42:49 +0000 (13:42 -0600)]
Set lexical-binding in dwarf-mode

Emacs has had lexical binding for a while, and it's a good practice to
use it; so enable it in dwarf-mode.el.

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

* dwarf-mode.el: Set lexical-binding.

7 years agoBind keys in dwarf-mode-map definition
Tom Tromey [Fri, 6 Oct 2017 19:18:31 +0000 (13:18 -0600)]
Bind keys in dwarf-mode-map definition

It's bad Emacs style to define keys from a top-level form.  Instead, one
should define a mode map separately and binding keys in the definition.
This lets users completely override the map by defining it before
loading the mode.

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

* dwarf-mode.el (dwarf-mode-map): New defvar.

7 years agoEliminate catch_exceptions/catch_exceptions_with_msg
Pedro Alves [Tue, 10 Oct 2017 15:45:51 +0000 (16:45 +0100)]
Eliminate catch_exceptions/catch_exceptions_with_msg

This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays.  This results in a good number of simplifications.

(I checked that Insight doesn't use those functions.)

The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.

I.e., before:
 -thread-select 123456789
 &"Thread ID 123456789 not known.\n"
 ^error,msg="Thread ID 123456789 not known."
 (gdb)

After:
 -thread-select 123456789
 ^error,msg="Thread ID 123456789 not known."
 (gdb)

gdb/ChangeLog
2017-10-10  Pedro Alves <palves@redhat.com>
    Tom Tromey  <tom@tromey.com>

* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here.  Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type.  Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.

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

* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.

7 years agoEliminate catch_errors
Pedro Alves [Tue, 10 Oct 2017 15:45:50 +0000 (16:45 +0100)]
Eliminate catch_errors

If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.

https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures.  However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code.  This is what this commit does.

Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.

I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.

(Another approach could be to make catch_errors a variadic template
like:

  template<typename Function, typename... Args>
  int catch_errors (const char *errstring, return_mask mask,
    Function &&func, Args... args);

and then with:

  extern void function_with_args (int, int);
  extern void function_with_no_args ();

calls to the above functions would be wrapped like this:

  catch_errors ("some error happened", RETURN_MASK_ERROR,
                function_with_args, arg1, arg2);

  catch_errors ("some error happened", RETURN_MASK_ERROR,
                function_with_no_args);

but I'm thinking that that doesn't improve much if at all either.)

gdb/ChangeLog
2017-10-10  Pedro Alves  <palves@redhat.com>
    Tom Tromey  <tom@tromey.com>

* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros.  Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors.  Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter.  Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.

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

* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.

7 years ago[ARM] PR ld/21402, only override the symbol dynamic decision on undefined weak symbol.
Renlin Li [Mon, 25 Sep 2017 10:41:54 +0000 (11:41 +0100)]
[ARM] PR ld/21402, only override the symbol dynamic decision on undefined weak symbol.

Similar as aarch64 backend, arm backend only overrides the decision on undefined
weak symbols. arm backend part already emits necessary relative relocation for
this case.

bfd/

PR ld/21402
* elf32-arm.c (allocate_dynrelocs_for_symbol): Only make undefined weak
symbols into dynamic.

ld/

PR ld/21402
* testsuite/ld-arm/tls-app.d: Update address.
* testsuite/ld-arm/tls-app.r: Remove relocations.
* testsuite/ld-arm/unresolved-1-dyn.d: Update.

7 years agoImprove the speed of the --dwarf-start option by skipping processing of any comp...
Nick Clifton [Tue, 10 Oct 2017 12:37:58 +0000 (13:37 +0100)]
Improve the speed of the --dwarf-start option by skipping processing of any comp unit that ends before the specified start address.

PR 22249
* dwarf.c (process_debug_info): Skip any comp unit that ends
before dwarf_start_die.

7 years agoriscv: Cache the max alignment of output sections
H.J. Lu [Tue, 10 Oct 2017 05:03:42 +0000 (22:03 -0700)]
riscv: Cache the max alignment of output sections

Cache the max alignment of output sections instead of scanning all
output sections for each input section, which can take a very long
time if there are millions of input/output sections.

PR ld/22274
* elfnn-riscv.c (riscv_elf_link_hash_table): Add max_alignment.
(riscv_elf_link_hash_table_create): Initialize max_alignment to
(bfd_vma) -1.
(_bfd_riscv_relax_section): Cache the max alignment of output
sections if possible.

7 years agoPrepare powerpc64 for late check_relocs
Alan Modra [Tue, 10 Oct 2017 01:22:06 +0000 (11:52 +1030)]
Prepare powerpc64 for late check_relocs

check_relocs was setting up some data used by the --gc-sections
gc_mark_hook.  If we change ld to run check_relocs after gc_sections
that data needs to be set up elsewhere.  Done by this patch in the
backend check_directives function (ppc64_elf_before_check_relocs).

* elf64-ppc.c (ppc64_elf_before_check_relocs): Set sec_type for
.opd whenever .opd is present and non-zero size.  Move code
setting abiversion to/from output file earlier.  Only set
u.opd.func_sec when --gc-sections.  Read relocs and set up
u.opd.func_sec values here..
(ppc64_elf_check_relocs): ..rather than here.  Simplify opd
section tests.
(ppc64_elf_edit_opd): Don't set sec_type for .opd here.

7 years agoCorrect ld/Makefile earmelfb_fuchsia dependencies
Alan Modra [Tue, 10 Oct 2017 01:11:10 +0000 (11:41 +1030)]
Correct ld/Makefile earmelfb_fuchsia dependencies

There were two copies of earmelf_fuchsia.c dependencies.

* Makefile.am (earmelfb_fuchsia.c): Rename rule from earmelf_fuchsia.c.
* Makefile.in: Regenerate.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 10 Oct 2017 00:00:24 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoRemove free_splay_tree cleanup
Tom Tromey [Sun, 8 Oct 2017 22:37:46 +0000 (16:37 -0600)]
Remove free_splay_tree cleanup

One spot in gdb uses a cleanup to free a splay tree.  This patch
introduces a unique_ptr specialization for this case.

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

* mi/mi-main.c (free_splay_tree): Remove.
(list_available_thread_groups): Use splay_tree_up.
* common/gdb_splay_tree.h: New file.

7 years agoRemove "do_nothing"
Tom Tromey [Sun, 8 Oct 2017 22:19:48 +0000 (16:19 -0600)]
Remove "do_nothing"

The do_nothing function in mi-main.c is used as a splay tree
key-deleting function; but NULL serves the same purpose and is used
elsewhere in gdb.  This patch removes the unneeded function.

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

* mi/mi-main.c (do_nothing): Remove.
(list_available_thread_groups): Update.

7 years agomn10300: Don't free cached internal symbol table
H.J. Lu [Mon, 9 Oct 2017 22:05:03 +0000 (15:05 -0700)]
mn10300: Don't free cached internal symbol table

Since ELF linker may cache internal symbol table in init_reloc_cookie,
we should check if it is cached, before free it.

* elf-m10300.c (mn10300_elf_check_relocs): Don't free cached
isymbuf.

7 years agobfin: Don't create .interp section for info->nointerp
H.J. Lu [Mon, 9 Oct 2017 19:45:57 +0000 (12:45 -0700)]
bfin: Don't create .interp section for info->nointerp

Don't create the .interp section with "ld --no-dynamic-linker".  This
fixed:

FAIL: PR ld/20828 forcibly exported symbol version without section GC
FAIL: PR ld/20828 forcibly exported symbol version with section GC
FAIL: readelf version information

* elf32-bfin.c (bfin_size_dynamic_sections): Don't create the
.interp section with "ld --no-dynamic-linker".

7 years agogdb.multi/multi-arch-exec.exp: Also test -m32 => -m64
Pedro Alves [Mon, 9 Oct 2017 17:11:02 +0000 (18:11 +0100)]
gdb.multi/multi-arch-exec.exp: Also test -m32 => -m64

The gdb.multi/multi-arch-exec.exp testcase currently tests execing
from -m64 to -m32, but does not test the other direction.  For
thoroughness, this commit fixes that.  Without the fix in the previous
commit for example ("Multi-arch exec, more register reading
avoidance"), on x86_64 we would get different symptoms depending on
"execing direction".  Vis:

  Continuing.
  Truncated register 50 in remote 'g' packet
  Truncated register 50 in remote 'g' packet
  (gdb) FAIL: gdb.multi/multi-arch-exec.exp: first_arch=1: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture

Vs:

  Continuing.
  Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): daffffffffffffff0000[snip]
  Remote 'g' packet reply is too long (expected 440 bytes, got 816 bytes): daffffffffffffff0000[snip]
  (gdb) FAIL: gdb.multi/multi-arch-exec.exp: first_arch=2: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture

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

Test both arch1=>arch2 and arch2=>arch1.

* gdb.multi/multi-arch-exec.exp (exec1, srcfile1, binfile1, exec2)
(srcfile2, binfile2, march1, march2): Remove globals.  Largely
factored out to...
(append_arch1_options, append_arch2_options, append_arch_options)
(build_executables): New procedures.
(do_test): New 'first_arch' parameter.  Use it to define 'from_exec'
local.
(top level): Add new 'first_arch' testing axis.

7 years agoMulti-arch exec, more register reading avoidance
Pedro Alves [Mon, 9 Oct 2017 17:11:01 +0000 (18:11 +0100)]
Multi-arch exec, more register reading avoidance

As mentioned in commit bf93d7ba9931 ("Add thread after updating
gdbarch when exec'ing"), we should avoid doing register reads after a
process does an exec and before we've updated that inferior's gdbarch.
Otherwise, we may interpret the registers using the wrong
architecture.

There's still (at least) one case where we still read registers
post-exec with the pre-exec architecture.  That's when infrun decides
it needs to switch context to the exec'ing thread.  I.e., if the exec
event is processed at a time when the current thread is not already
the exec'ing thread, then we get (with the test added by this commit):

  continue
  Continuing.
  Truncated register 50 in remote 'g' packet
  Truncated register 50 in remote 'g' packet
  (gdb) FAIL: gdb.multi/multi-arch-exec.exp: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture

The fix is to avoid reading registers when switching context in this
case.

(I'd be nice to get rid of the constant stop_pc reading when switching
threads, but that'd be a deeper change.)

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

* infrun.c (handle_inferior_event_1) <TARGET_WAITKIND_EXECD>: Skip
reading registers when switching context.

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

* gdb.multi/multi-arch-exec.c: Include <pthread.h> and <assert.h>.
(barrier): New.
(thread_start, all_started): New functions.
(main): Spawn new thread and wait until it is scheduled.
* gdb.multi/multi-arch-exec.exp: Build $srcfile1 with the pthreads
option.
(do_test): Add 'selected_thread' parameter.  Run to all_started
instead of main.  Explicitly set the breakpoint at main.  Switch
to the SELECTED_THREAD thread.
(top level): Test handling the exec event with either the main
thread or the second thread selected.

7 years agoUse gdbarch_long_bit to determine layout of FreeBSD siginfo_t.
John Baldwin [Mon, 9 Oct 2017 16:54:42 +0000 (09:54 -0700)]
Use gdbarch_long_bit to determine layout of FreeBSD siginfo_t.

FreeBSD architectures are either ILP32 or LP64 resulting in two
different layouts for siginfo_t.  Previously, the 'bits_per_word'
member of bfd_arch_info was used to determine the layout to use for a
given FreeBSD architecture.  However, mipsn32 architectures inherit
from a 64-bit mips architecture where bits_per_word is 64.  As a
result, $_siginfo was not properly extracted from FreeBSD/mipsn32 core
dumps.  Fix this by using gdbarch_long_bit instead of 'bits_per_word'
to determine if a FreeBSD architecture is ILP32 or LP64.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_siginfo_size): Use gdbarch_long_bit.
(fbsd_convert_siginfo): Likewise.
* fbsd-tdep.c (fbsd_core_xfer_siginfo): Likewise.

7 years agoDon't try building gdb against guile-2.2
Simon Marchi [Mon, 9 Oct 2017 16:50:58 +0000 (12:50 -0400)]
Don't try building gdb against guile-2.2

GDB currently doesn't build with Guile 2.2 (see PR 21104).  If one has
both Guile 2.2 and 2.0 installed, GDB will pick up Guile 2.2 first and
fail building.  Until somebody does the work of adapting the GDB code to
Guile 2.2, we should not try using it.  This patch therefore removes it
from configure.

gdb/ChangeLog:

* configure.ac (try_guile_versions): Remove guile-2.2.
* configure: Regenerate.

7 years agoS/390: Sync with latest POP - 3 new instructions
Andreas Krebbel [Mon, 9 Oct 2017 16:37:53 +0000 (18:37 +0200)]
S/390: Sync with latest POP - 3 new instructions

prno, tpei, and irbm are missing in the optable.

gas/ChangeLog:

2017-10-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* testsuite/gas/s390/zarch-arch12.d (prno, tpei, irbm): New
instructions added.
* testsuite/gas/s390/zarch-arch12.s: Likewise.
* testsuite/gas/s390/zarch-z13.d: Rename ppno to prno.

opcodes/ChangeLog:

2017-10-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-opc.txt (prno, tpei, irbm): New instructions added.

7 years agoS/390: Sync with IBM z14 POP - SI_RD format
Andreas Krebbel [Mon, 9 Oct 2017 16:37:53 +0000 (18:37 +0200)]
S/390: Sync with IBM z14 POP - SI_RD format

The recent POP adjusted a few of the instruction formats.  This patch
adjusts our optable accordingly.  No user visible change - hopefully.

opcodes/ChangeLog:

2017-10-09  Heiko Carstens  <heiko.carstens@de.ibm.com>

* s390-opc.c (INSTR_SI_RD): New macro.
(INSTR_S_RD): Adjust example instruction.
* s390-opc.txt (lpsw, ssm, ts): Change S_RD instruction format to
SI_RD.

7 years agoFix automatic dependency tracking
Tom Tromey [Sun, 8 Oct 2017 23:12:19 +0000 (17:12 -0600)]
Fix automatic dependency tracking

Commit f38307f5 changed COMPILE.post and POSTCOMPILE to remove
$(basename) from the dependency file name computation.  However, it
did not update the `-include' at the end of the Makefile.in; this in
effect disabled automatic dependency tracking.

This patch restores the $(basename) wrapper so that the dependency
files are named "file.Po" rather than "file.o.Po".

I also tested the non-gcc3 dependency mode, which pointed out that
this case hadn't been working since the switch to C++.  This is also
fixed in this patch.

Tested by rebuilding.

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

* Makefile.in (COMPILE.post, POSTCOMPILE): Restore $(basename).
(COMPILE.pre): Use $(CXX).

7 years agoMake cp_remove_params return a gdb::unique_xmalloc_ptr
Pedro Alves [Mon, 9 Oct 2017 14:57:36 +0000 (15:57 +0100)]
Make cp_remove_params return a gdb::unique_xmalloc_ptr

Use the type system instead of callers needing to know how the
returned string's memory is supposed to be managed.

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

* cp-support.c (cp_remove_params): Return a gdb::unique_xmalloc_ptr.
Use bool.
(overload_list_add_symbol): Adjust to use gdb::unique_xmalloc_ptr.
* cp-support.h (cp_remove_params): Now returns a
gdb::unique_xmalloc_ptr.
* dwarf2read.c (find_slot_in_mapped_hash): Now returns bool.
Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr.
* psymtab.c (psymtab_search_name): Adjust to cp_remove_params
returning a gdb::unique_xmalloc_ptr.
(lookup_partial_symbol): Adjust to use gdb::unique_xmalloc_ptr.
* stack.c (find_frame_funname): Adjust to cp_remove_params
returning a gdb::unique_xmalloc_ptr.

7 years agoFix link time warning message when running the srec linker tests.
Nick Clifton [Mon, 9 Oct 2017 14:32:09 +0000 (15:32 +0100)]
Fix link time warning message when running the srec linker tests.

* testsuite/ld-srec/srec.exp (run_srec_test): Set start address.

7 years agoFix compile time warning message when running the PR19874 linker test.
Nick Clifton [Mon, 9 Oct 2017 14:00:31 +0000 (15:00 +0100)]
Fix compile time warning message when running the PR19874 linker test.

PR ld/19874
* testsuite/ld-x86-64/pr19784c.c (bar): Change return type to void.

7 years agoAdd missing changelog entries
Andreas Krebbel [Mon, 9 Oct 2017 13:40:15 +0000 (15:40 +0200)]
Add missing changelog entries

7 years agoFix gdb.base/print-file-var-main.c value check logic
Pedro Alves [Mon, 9 Oct 2017 11:33:31 +0000 (12:33 +0100)]
Fix gdb.base/print-file-var-main.c value check logic

Fix a typo introduced in commit c56e7c4390ed ("Make ctxobj.exp and
print-file-var.exp work on all platforms.").

This doesn't really affect the outcome of the testcase.  I only
noticed the typo because I stepped through the program manually.

To avoid such problems if the test is extended, this moves the STOP
marker until after the program self-validates the values.  With the
typo in place, this alone would have resulted in a test FAIL.  I.e.,
it'd have caught the typo.

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

* gdb.base/print-file-var-main.c: Fix get_version_2 value check
logic.  Move STOP marker after the value checks.
* gdb.base/print-file-var.exp (continue to STOP marker): Tighten
regexp.

7 years agold: Don't allow '~' as the first char in symbol name
H.J. Lu [Mon, 9 Oct 2017 11:17:10 +0000 (04:17 -0700)]
ld: Don't allow '~' as the first char in symbol name

Don't allow '~' as the first character in symbol name in linker script.

PR ld/22267
* ldlex.l (SYMBOLNAMECHAR1) New.
(DEFSYMEXP): Replace FILENAMECHAR1 with SYMBOLNAMECHAR1.
(EXPRESSION): Likewise.
* testsuite/ld-scripts/expr.exp: Run pr22267.
* testsuite/ld-scripts/pr22267.d: New file.
* testsuite/ld-scripts/pr22267.s: Likewise.
* testsuite/ld-scripts/pr22267.t: Likewise.

7 years agoReplace nop in fill-1.s testcase.
Andreas Krebbel [Mon, 9 Oct 2017 10:24:11 +0000 (12:24 +0200)]
Replace nop in fill-1.s testcase.

gas/ChangeLog:

2017-10-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* testsuite/gas/all/fill-1.s: Replace nop with .word 42

7 years agoEnable .fill forward labels
Andreas Krebbel [Fri, 6 Oct 2017 11:12:32 +0000 (13:12 +0200)]
Enable .fill forward labels

gas/ChangeLog:

2017-10-09  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* read.c (s_fill): Invoke expression instead of
get_known_segmented_expression.
* testsuite/gas/all/fill-1.s: New testcase.
* testsuite/gas/all/gas.exp: Run fill-1 testcase

7 years agoRemove some cleanups from dwarf2read.c
Tom Tromey [Sun, 8 Oct 2017 19:29:18 +0000 (13:29 -0600)]
Remove some cleanups from dwarf2read.c

This removes a number of cleanups from dwarf2read.c in a
straightforward way.

Note that some places in dwarf2read create dangling cleanups.  I don't
believe any of the changes in this patch interact with those spots.

Regression tested by the buildbot.

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

* dwarf2read.c (dwarf2_get_dwz_file): Use
gdb::unique_xmalloc_ptr.
(find_slot_in_mapped_hash): Likewise.
(dwarf2_physname): Likewise.
(create_dwo_unit_in_dwp_v1): Use std::string.
(create_dwo_unit_in_dwp_v2): Likewise.
(lookup_dwo_cutu): Likewise.
(inherit_abstract_dies): Use std::vector.
(read_array_type): Likewise.
(dwarf_decode_macros): Remove unused declaration.
(unsigned_int_compar): Remove.
(dwarf2_build_psymtabs_hard): Use scoped_restore.
(psymtabs_addrmap_cleanup): Remove.

7 years agoRemove cleanup from frame_prepare_for_sniffer
Tom Tromey [Sun, 8 Oct 2017 18:40:07 +0000 (12:40 -0600)]
Remove cleanup from frame_prepare_for_sniffer

Currently frame_prepare_for_sniffer returns a cleanup.  This patch
changes it to return void, and exposes frame_cleanup_after_sniffer to
the caller.

Normally I would write an RAII class for this sort of thing; but
because there was just a single caller of frame_prepare_for_sniffer,
and because this caller is already using try/catch, I thought it
seemed ok to require explicit calls in this instance.

Regression tested by the buildbot.

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

* frame-unwind.c (frame_unwind_try_unwinder): Update.
* frame.h (frame_cleanup_after_sniffer): Declare.
(frame_prepare_for_sniffer): Return void.
* frame.c (frame_cleanup_after_sniffer): No longer static.  Change
type of argument.
(frame_prepare_for_sniffer): Return void.

7 years agoRemove make_cleanup_value_free
Tom Tromey [Sun, 8 Oct 2017 18:20:49 +0000 (12:20 -0600)]
Remove make_cleanup_value_free

This removes make_cleanup_value_free, in favor of a unique_ptr
specialization.

Regression tested by the buildbot.

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

* utils.h (make_cleanup_value_free): Remove.
* utils.c (do_value_free, struct cleanup): Remove.
* dwarf2loc.c (dwarf2_evaluate_loc_desc_full) <DWARF_VALUE_STACK>:
Use gdb_value_up.
* value.h (struct value_deleter): New.
(gdb_value_up): New typedef.

7 years agoChange search_symbols to return std::vector
Tom Tromey [Sun, 8 Oct 2017 18:11:18 +0000 (12:11 -0600)]
Change search_symbols to return std::vector

This changes search_symbols to return a std::vector, replacing the
previous linked list approach.  This allows the removal of some
cleanups, as well as the use of std::sort and std::unique, saving some
code and extra allocations in sort_search_symbols_remove_dups.

Regression tested by the buildbot.

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

* symtab.c (free_search_symbols, do_free_search_symbols_cleanup)
(make_cleanup_free_search_symbols): Remove.
(search_symbols): Return std::vector.
(symbol_search::compare_search_syms): Now member of
symbol_search.  Change arguments.
(sort_search_symbols_remove_dups): Change arguments.  Rewrite.
(symtab_symbol_info, rbreak_command): Update.
* symtab.h (struct symbol_search) <next>: Remove.
Add constructors.
(symbol_search::operator<): New function.
(symbol_search::operator==): New function.
(search_symbols): Remove std::vector.
(free_search_symbols, make_cleanup_free_search_symbols): Remove.
(symbol_search::compare_search_syms): Declare.

7 years agoPR22212, memory leak in nm
Alan Modra [Mon, 9 Oct 2017 02:51:44 +0000 (13:21 +1030)]
PR22212, memory leak in nm

PR 22212
* dwarf2.c (_bfd_dwarf2_cleanup_debug_info): Free
funcinfo_hash_table and varinfo_hash_table.

7 years agosh: Dump dynamic relocation info to the map file
H.J. Lu [Mon, 9 Oct 2017 00:17:29 +0000 (17:17 -0700)]
sh: Dump dynamic relocation info to the map file

Dump dynamic relocation info to the map file when generating dynamic
relocation in read-only section relocations if -Map is used.

* elf32-sh.c (readonly_dynrelocs): Dump dynamic relocation
in read-only section with minfo.
(sh_elf_size_dynamic_sections): Likewise.

7 years agosparc: Remove a strayed comment
H.J. Lu [Mon, 9 Oct 2017 00:09:26 +0000 (17:09 -0700)]
sparc: Remove a strayed comment

* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Remove
a strayed comment.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 9 Oct 2017 00:00:30 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agotilegx: Set this_hdr.sh_entsize only if section size > 0
H.J. Lu [Sun, 8 Oct 2017 21:29:52 +0000 (14:29 -0700)]
tilegx: Set this_hdr.sh_entsize only if section size > 0

This fixes:

/export/build/gnu/binutils-cross/build-tilegx-linux/ld/ld-new   -o tmpdir/comm-data -z norelro -L/export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-elf  -T comm-data2.ld -Ltmpdir -lcomm-data tmpdir/comm-data2.o
sh: line 1:  9208 Segmentation fault      (core dumped) /export/build/gnu/binutils-cross/build-tilegx-linux/ld/ld-new -o tmpdir/comm-data -z norelro -L/export/gnu/import/git/sources/binutils-gdb/ld/testsuite/ld-elf -T comm-data2.ld -Ltmpdir -lcomm-data tmpdir/comm-data2.o 2>&1
FAIL: Common symbol override test

* elfxx-tilegx.c (tilegx_elf_finish_dynamic_sections): Set
this_hdr.sh_entsize only if section size > 0.