external/binutils.git
6 years agoUse TRY/CATCH in remove_prev_frame
Tom Tromey [Fri, 25 May 2018 00:23:37 +0000 (18:23 -0600)]
Use TRY/CATCH in remove_prev_frame

This changes remove_prev_frame to use TRY/CATCH instead of a cleanup.
TRY/CATCH seemed appropriate here because the cleanup is only needed
in the case where an exception is thrown.

Tested by the buildbot.

ChangeLog
2018-05-25  Tom Tromey  <tom@tromey.com>

* frame.c (remove_prev_frame): Remove.
(get_prev_frame_if_no_cycle): Use TRY/CATCH.

6 years agoMIPS/Linux: Correct o32 core file FGR interpretation
Maciej W. Rozycki [Fri, 25 May 2018 11:37:45 +0000 (12:37 +0100)]
MIPS/Linux: Correct o32 core file FGR interpretation

Our interpretation of the layout of floating-point general registers
(FGRs) in o32 MIPS/Linux core files is different from how the kernel
makes them, affecting the CP0 Status.FR=0 aka FP32 mode (we don't
currently support the CP0 Status.FR=1 aka FP64 mode with the o32 ABI).

In the FP32 mode pairs of consecutive even/odd-numbered 32-bit registers
are placed together as 64-bit values in even-indexed 64-bit slots
corresponding to the even index, leaving the odd-indexed 64-bit slots
unused.  These 64-bit values are stored according to the endianness in
effect, which is how the MIPS II SDC1 instruction would store them.

It has always been like that with the Linux kernel for MIPS II and
higher ISA processors, which are the vast majority ever supported, as it
is indeed SDC1 that the kernel uses to store FGRs in a floating-point
context.

With MIPS I processors, which lack the SDC1 instruction, a layout that
we expect used to be used long ago, but it was corrected for consistency
with newer processors back in 2002, with `linux-mips.org' (LMO) commit
42533948caac ("Major pile of FP emulator changes."), the fix corrected
with LMO commit 849fa7a50dff ("R3k FPU ptrace() handling fixes."), and
then broken and fixed over and over again, until last time fixed with
commit 80cbfad79096 ("MIPS: Correct MIPS I FP context layout").

Consequently the values we see in FP32 core files or produce with the
`gcore' command are different from those obtained from the same FP
context of a live process, e.g. with a big-endian configuration these
live values:

(gdb) info registers float
f0:  0x4b5c6d7e flt: 14445950          dbl: 1.7446153562345001e-274
f1:  0x0718293a flt: 1.14473244e-34
f2:  0xc3d4e5f6 flt: -425.79657        dbl: -1.046160437414959e-233
f3:  0x8f90a1b2 flt: -1.42617791e-29
f4:  0x4c5d6e7f flt: 58046972          dbl: 1.1908587841220294e-269
f5:  0x08192a3b flt: 4.60914044e-34
f6:  0xc4d5e6f7 flt: -1711.21765       dbl: -6.2784661835068965e-306
f7:  0x8091a2b3 flt: -1.33745124e-38
f8:  0x45566778 flt: 3430.4668         dbl: 1.6530355595710607e-303
f9:  0x01122334 flt: 2.68412219e-38
f10: 0xcddeeff0 flt: -467533312        dbl: -2.1174864564135575e-262
f11: 0x899aabbc flt: -3.72356497e-33
f12: 0x46576879 flt: 13786.1182        dbl: 1.143296486773654e-298
f13: 0x02132435 flt: 1.08102453e-37
f14: 0xcedfe0f1 flt: -1.87803046e+09   dbl: -1.4399511533369862e-257
f15: 0x8a9bacbd flt: -1.4990934e-32
f16: 0x4758697a flt: 55401.4766        dbl: 7.8856820439568725e-294
f17: 0x03142536 flt: 4.3536007e-37
f18: 0xcfd0e1f2 flt: -7.00893696e+09   dbl: -9.7791926757340559e-253
f19: 0x8b9cadbe flt: -6.03504325e-32
f20: 0x48596a7b flt: 222633.922        dbl: 5.4255001483306113e-289
f21: 0x04152637 flt: 1.75324132e-36
f22: 0xc0d1e2f3 flt: -6.55895376       dbl: -6.6332401002310683e-248
f23: 0x8c9daebf flt: -2.42948516e-31
f24: 0x495a6b7c flt: 894647.75         dbl: 3.7244369058749787e-284
f25: 0x05162738 flt: 7.06016945e-36
f26: 0xc1d2e3f4 flt: -26.3613052       dbl: -4.4941535759306202e-243
f27: 0x8d9eafb0 flt: -9.77979703e-31
f28: 0x4a5b6c7d flt: 3595039.25        dbl: 2.5514593711161396e-279
f29: 0x06172839 flt: 2.84294945e-35
f30: 0xc2d3e4f5 flt: -105.947182       dbl: -3.035646690850097e-238
f31: 0x8e9fa0b1 flt: -3.93512664e-30
fcsr: 0x0
fir: 0xf30000
(gdb)

show up in a core file as these:

(gdb) info registers float
f0:  0x0718293a flt: 1.14473244e-34    dbl: nan
f1:  0x7ff80000 flt: nan
f2:  0x8f90a1b2 flt: -1.42617791e-29   dbl: nan
f3:  0x7ff80000 flt: nan
f4:  0x08192a3b flt: 4.60914044e-34    dbl: nan
f5:  0x7ff80000 flt: nan
f6:  0x8091a2b3 flt: -1.33745124e-38   dbl: nan
f7:  0x7ff80000 flt: nan
f8:  0x01122334 flt: 2.68412219e-38    dbl: nan
f9:  0x7ff80000 flt: nan
f10: 0x899aabbc flt: -3.72356497e-33   dbl: nan
f11: 0x7ff80000 flt: nan
f12: 0x02132435 flt: 1.08102453e-37    dbl: nan
f13: 0x7ff80000 flt: nan
f14: 0x8a9bacbd flt: -1.4990934e-32    dbl: nan
f15: 0x7ff80000 flt: nan
f16: 0x03142536 flt: 4.3536007e-37     dbl: nan
f17: 0x7ff80000 flt: nan
f18: 0x8b9cadbe flt: -6.03504325e-32   dbl: nan
f19: 0x7ff80000 flt: nan
f20: 0x04152637 flt: 1.75324132e-36    dbl: nan
f21: 0x7ff80000 flt: nan
f22: 0x8c9daebf flt: -2.42948516e-31   dbl: nan
f23: 0x7ff80000 flt: nan
f24: 0x05162738 flt: 7.06016945e-36    dbl: nan
f25: 0x7ff80000 flt: nan
f26: 0x8d9eafb0 flt: -9.77979703e-31   dbl: nan
f27: 0x7ff80000 flt: nan
f28: 0x06172839 flt: 2.84294945e-35    dbl: nan
f29: 0x7ff80000 flt: nan
f30: 0x8e9fa0b1 flt: -3.93512664e-30   dbl: nan
f31: 0x7ff80000 flt: nan
(gdb)

Notice how values from odd-numbered registers are shown in corresponding
even-numbered registers and how dummy 0x7ff80000 NaN values, which the
kernel places in unused slots, are reported in odd-numbered registers.

Correct our intepretation then, to match the kernel's.  As it happens
the o32 FGR core file representation matches that used by the `ptrace'
PTRACE_GETFPREGS request, which means our 64-bit handlers can be readily
used, as they already correctly handle the differences between o32 FP32
mode vs n32/n64 representations.

Adjust comments accordingly throughout, in particular remove a reference
to the r3000/tx39 MIPS I processor peculiarity, long irrelevant.

Add a test case to verify correctness.  Avoid GCC bugs and limitations
in the test case where possible; the test case still fails to build with
GCC 8 and the o32 FP64 mode (i.e. with `-mips32r2 -mfp64' options)
giving:

mips-fpregset-core.c: In function 'main':
mips-fpregset-core.c:66:3: error: inconsistent operand constraints in an 'asm'
   asm (
   ^~~

(GCC PR target/85909), but that is not a concern for us as yet, because
as noted above we do not currently support the o32 FP64 mode anyway.

gdb/
* mips-linux-tdep.h (mips_supply_fpregset, mips_fill_fpregset):
Remove prototypes.
* mips-linux-nat.c (supply_fpregset): Always call
`mips64_supply_fpregset' rather than `mips_supply_fpregset'.
(fill_fpregset): Always call `mips64_fill_fpregset' rather than
`mips_fill_fpregset'.
* mips-linux-tdep.c (mips_supply_fpregset)
(mips_supply_fpregset_wrapper, mips_fill_fpregset)
(mips_fill_fpregset_wrapper): Remove functions.
(mips64_supply_fpregset, mips64_fill_fpregset): Update comments.
(mips_linux_fpregset): Remove variable.
(mips_linux_iterate_over_regset_sections): Use
`mips64_linux_fpregset' in place of `mips_linux_fpregset'.
(mips_linux_o32_sigframe_init): Remove comment.

gdb/testsuite/
* gdb.arch/mips-fpregset-core.exp: New test.
* gdb.arch/mips-fpregset-core.c: New test source.

6 years agoremote_target::m_remote_state, pointer -> object
Pedro Alves [Fri, 25 May 2018 10:58:58 +0000 (11:58 +0100)]
remote_target::m_remote_state, pointer -> object

The only reason remote_target::m_remote_state is a pointer is that
struct remote_state is incomplete when struct remote_target is
defined.

This commit thus moves struct remote_state (and its dependencies)
higher up and makes remote_target::m_remote_state an object instead of
a pointer.

gdb/ChangeLog:
2018-05-25  Pedro Alves  <palves@redhat.com>

* remote.c (struct vCont_action_support, MAXTHREADLISTRESULTS)
(struct readahead_cache, struct packet_reg, struct
remote_arch_state, class remote_state): Move higher up in the
file.
(remote_target::m_remote_state): Now an object instead of a pointer.
(remote_target::get_remote_state): Adjust.

6 years agos12z regen
Alan Modra [Fri, 25 May 2018 06:35:30 +0000 (16:05 +0930)]
s12z regen

This patch regenerates a number of files that either were edited by
hand or not regenerated when s12z support was added to binutils.

bfd/
* Makefile.in: Regenerate.
* po/SRC-POTFILES.in: Regenerate.
gas/
* po/POTFILES.in: Regenerate.
ld/
* po/BLD-POTFILES.in: Regenerate.
opcodes/
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.

6 years agoFix hidden visibility compiler test
Alan Modra [Fri, 25 May 2018 05:37:15 +0000 (15:07 +0930)]
Fix hidden visibility compiler test

Warnings from configure tests aren't usually checked.  gcc's
"visibility attribute not supported in this configuration" warning is
enabled by default so we don't need to add any warning flag except
-Werror.

* configure.ac (bfd_cv_hidden): Run test with -Werror in CFLAGS.
* configure: Regenerate.

6 years agoAutomatic date update in version.in
GDB Administrator [Fri, 25 May 2018 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agogdb: Split func_command into two parts.
Andrew Burgess [Sat, 5 May 2018 14:55:58 +0000 (15:55 +0100)]
gdb: Split func_command into two parts.

The func_command function is used to emulate the dbx 'func' command.
However, finding a stack frame based on function name might be a useful
feature, and so the core of func_command is now split out into a
separate function.

gdb/ChangeLog:

* stack.c (select_and_print_frame): Delete.
(struct function_bounds): Move struct within function.
(func_command): Most content moved into new function
find_frame_for_function, use new function, print result, add
function comment.
(find_frame_for_function): New function, now returns a result.

6 years agoPATCH (obvious): Fix a comment, and pass stream to cb_data.
Philippe Waroquiers [Thu, 24 May 2018 21:19:05 +0000 (23:19 +0200)]
PATCH (obvious): Fix a comment, and pass stream to cb_data.

iterate_over_block_arg_vars is a void function, so does
not return 1 or 0.
print_frame_arg_vars tells it prints on STREAM,
so pass STREAM in the cb_data, not gdb_stdout.

gdb/ChangeLog

2018-05-24  Philippe Waroquiers  <philippe.waroquiers@skynet.be>

* stack.c (iterate_over_block_arg_vars): Fix comment.
(print_frame_arg_vars): Pass stream in cb_data, not gdb_stdout.

6 years agoUpdate help text in record.c
Tom Tromey [Mon, 30 Apr 2018 14:37:31 +0000 (08:37 -0600)]
Update help text in record.c

This updates some help text in record.c to conform to GNU standards.
I also added a "Usage" line to "record save".

2018-04-29  Tom Tromey  <tom@tromey.com>

* record.c (_initialize_record): Update help text.

6 years agoUpdate help text in linux-fork.c
Tom Tromey [Mon, 30 Apr 2018 14:37:30 +0000 (08:37 -0600)]
Update help text in linux-fork.c

This updates some help text in linux-fork.c to conform to GNU
standards.

2018-04-29  Tom Tromey  <tom@tromey.com>

* linux-fork.c (_initialize_linux_fork): Update help text.

6 years agoUpdate help text in record-btrace.c
Tom Tromey [Mon, 30 Apr 2018 14:37:29 +0000 (08:37 -0600)]
Update help text in record-btrace.c

This updates the help text in record-btrace.c to conform to GNU
standards.

2018-04-29  Tom Tromey  <tom@tromey.com>

* record-btrace.c (_initialize_record_btrace): Update help text.

6 years agoUpdate help text in tracepoint.c
Tom Tromey [Mon, 30 Apr 2018 14:37:28 +0000 (08:37 -0600)]
Update help text in tracepoint.c

This changes the help text of a couple of commands in tracepoint.c to
follow the GNU style.

ChangeLog
2018-04-29  Tom Tromey  <tom@tromey.com>

* tracepoint.c (_initialize_tracepoint): Update help text.

testsuite/ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* gdb.trace/tfind.exp: Update help tests.

6 years agoUpdate help text in disasm.c
Tom Tromey [Mon, 30 Apr 2018 14:37:27 +0000 (08:37 -0600)]
Update help text in disasm.c

This changes some help text in disasm.c to follow the GNU style.

2018-04-29  Tom Tromey  <tom@tromey.com>

* disasm.c (_initialize_disasm): Update help text.

6 years agoUpdate help text for "jump" command
Tom Tromey [Mon, 30 Apr 2018 14:37:26 +0000 (08:37 -0600)]
Update help text for "jump" command

This updates the usage text for the "jump" command to conform to the
GNU style.

2018-04-29  Tom Tromey  <tom@tromey.com>

* infcmd.c (_initialize_infcmd): Update help text.

6 years agoUpdate help text in dcache.c
Tom Tromey [Mon, 30 Apr 2018 14:37:25 +0000 (08:37 -0600)]
Update help text in dcache.c

This updates some text in dcache.c to follow GNU standards.
Here, I found a couple of spots needing an update.

2018-04-29  Tom Tromey  <tom@tromey.com>

* dcache.c (dcache_info_1): Update usage text.
(_initialize_dcache): Update help text.

6 years agoUpdate help strings in TUI
Tom Tromey [Mon, 30 Apr 2018 14:37:24 +0000 (08:37 -0600)]
Update help strings in TUI

This updates some help strings in the TUI to more closely follow GNU
standards.  In this case I chose to reuse some existing "usage" macros
in the help text.  Also, I found that XDBWIN_HEIGHT_USAGE is unused,
so I removed it.

ChangeLog
2018-04-29  Tom Tromey  <tom@tromey.com>

* tui/tui-layout.c (_initialize_tui_layout): Update help text.
* tui/tui-win.c (WIN_HEIGHT_USAGE, FOCUS_USAGE): Update
(XDBWIN_HEIGHT_USAGE): Remove.
(_initialize_tui_win): Use macros.  Update help text.

6 years agoUpdate memattr.c help strings
Tom Tromey [Mon, 30 Apr 2018 14:37:23 +0000 (08:37 -0600)]
Update memattr.c help strings

This changes memattr.c to use the GNU style for help strings.

2018-04-29  Tom Tromey  <tom@tromey.com>

* memattr.c (_initialize_mem): Update help string.

6 years agoUpdate core-related help strings
Tom Tromey [Mon, 30 Apr 2018 14:37:22 +0000 (08:37 -0600)]
Update core-related help strings

This updates some help strings in corefile.c and gcore.c.

2018-04-27  Tom Tromey  <tom@tromey.com>

* corefile.c (_initialize_core): Update help string.
* gcore.c (_initialize_gcore): Update help string.

6 years agoUpdate help strings in skip.c
Tom Tromey [Mon, 30 Apr 2018 14:37:21 +0000 (08:37 -0600)]
Update help strings in skip.c

This changes help strings in skip.c to follow the GNU style.

2018-04-27  Tom Tromey  <tom@tromey.com>

* skip.c (_initialize_step_skip): Update help strings.

6 years agoFix help and documentation for inferior commands
Tom Tromey [Mon, 30 Apr 2018 14:37:20 +0000 (08:37 -0600)]
Fix help and documentation for inferior commands

This changes inferior.c to add Usage lines for all commands, and to
change how "metasyntactic variables" are written to conform to GNU
style.

While doing this I noticed that the manual doesn't document the
argument to "info inferiors", so I've added that as well.

ChangeLog
2018-04-27  Tom Tromey  <tom@tromey.com>

* inferior.c (initialize_inferiors): Update help strings.

doc/ChangeLog
2018-04-27  Tom Tromey  <tom@tromey.com>

* gdb.texinfo (Inferiors and Programs): Document argument to "info
inferiors".

6 years agoRISC-V: Fix .align handling when .option norelax.
Jim Wilson [Thu, 24 May 2018 17:35:59 +0000 (10:35 -0700)]
RISC-V: Fix .align handling when .option norelax.

gas/
PR gas/23219
* config/tc-riscv.c (riscv_frag_align_code): Move frag_more call after
!riscv_opts.relax check.
(riscv_handle_align): Rewrite !riscv_opts.relax support.
* config/tc-riscv (MAX_MEM_FOR_RS_ALIGN_CODE): Update.
* testsuite/gas/riscv/no-relax-align.d: New
* testsuite/gas/riscv/no-relax-align.s: New
* testsuite/gas/riscv/no-relax-align-2.d: New
* testsuite/gas/riscv/no-relax-align-2.s: New

6 years agogdb: Restore selected frame in print_frame_local_vars
Andrew Burgess [Fri, 18 May 2018 16:45:16 +0000 (17:45 +0100)]
gdb: Restore selected frame in print_frame_local_vars

PR gdb/23203 reports 'bt full' causing the currently selected frame to
change, this issue is fixed in this commit.

Add a new class scoped_restore_selected_frame that saves and restores
the selected frame.  Make use of this in print_frame_local_vars to
restore the selected frame on exit.

gdb/ChangeLog:

PR gdb/23203
* frame.c
(scoped_restore_selected_frame::scoped_restore_selected_frame):
Define.
(scoped_restore_selected_frame::~scoped_restore_selected_frame):
Define.
* frame.h (class scoped_restore_selected_frame): New class.
* stack.c (print_frame_local_vars): Remove catching and rethrowing
of any exception, use scoped_restore_selected_frame to restore the
frame instead.

gdb/testsuite/ChangeLog:

PR gdb/23203
* gdb.base/bt-selected-frame.c: New file.
* gdb.base/bt-selected-frame.exp: New file.
* lib/gdb.exp (get_current_frame_number): New function.

6 years agotestsuite: Extend TLS core file testing with an OS-generated dump
Maciej W. Rozycki [Thu, 24 May 2018 14:31:32 +0000 (15:31 +0100)]
testsuite: Extend TLS core file testing with an OS-generated dump

Complementing commit 280ca31f4d60 ("Add test for fetching TLS from
core file") extend gdb.threads/tls-core.exp with an OS-generated dump
where supported.

This verifies not only that our core dump interpreter is consistent
with our producer, but that it matches the OS verified as well,
avoiding a possible case where our interpreter would be bug-compatible
with our producer but not the OS and it would go unnoticed in testing.

This results in:

 PASS: gdb.threads/tls-core.exp: native: load core file
 PASS: gdb.threads/tls-core.exp: native: print thread-local storage variable
 PASS: gdb.threads/tls-core.exp: gcore: load core file
 PASS: gdb.threads/tls-core.exp: gcore: print thread-local storage variable

with local testing and:

 UNSUPPORTED: gdb.threads/tls-core.exp: native: load core file
 UNSUPPORTED: gdb.threads/tls-core.exp: native: print thread-local storage variable
 PASS: gdb.threads/tls-core.exp: gcore: load core file
 PASS: gdb.threads/tls-core.exp: gcore: print thread-local storage variable

with remote testing, or for testing on ports that don't supports
cores.

gdb/testsuite/ChangeLog:
2018-05-24  Maciej W. Rozycki  <macro@mips.com>
    Pedro Alves  <palves@redhat.com>

* gdb.threads/tls-core.c: Include <stdlib.h>
(thread_proc): Call `abort'.
* gdb.threads/tls-core.exp: Generate a core with core_find too.
(tls_core_test): New procedure, bits factored out from ...
(top level): ... here.  Test both native cores and gcore cores.

6 years agoFix macOS build, missing override
Pedro Alves [Thu, 24 May 2018 12:07:53 +0000 (13:07 +0100)]
Fix macOS build, missing override

Fixes:

In file included from ../../src/gdb/darwin-nat.c:63:0:
../../src/gdb/darwin-nat.h:28:8: error: 'virtual void darwin_nat_target::create_inferior(const char*, const string&, char**, int)' can be marked override [-Werror=suggest-override]
   void create_inferior (const char *exec_file,
        ^

gdb/ChangeLog:
2018-05-24  Pedro Alves  <palves@redhat.com>

* darwin-nat.h (darwin_nat_target::create_inferior): Mark with
override.

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

6 years agoAdd ATTRIBUTE_NONSTRING to ppc64_elf_write_core_note
H.J. Lu [Wed, 23 May 2018 17:15:11 +0000 (10:15 -0700)]
Add ATTRIBUTE_NONSTRING to ppc64_elf_write_core_note

This patch silences gcc8 -Wstringop-truncation warnings.

* elf64-ppc.c (ppc64_elf_write_core_note): Add ATTRIBUTE_NONSTRING
to data.

6 years agoRemove struct complaints
Tom Tromey [Thu, 17 May 2018 05:25:09 +0000 (23:25 -0600)]
Remove struct complaints

struct complaints now just holds a single enum value, so remove it and
symfile_complaint_book and replace it with a global variable.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (struct complaints): Remove.
(symfile_complaint_book): Remove.
(series): New global.
(complaint_internal): Update.
(clear_complaints): Update.

6 years agoRemove struct complain
Tom Tromey [Thu, 17 May 2018 05:22:54 +0000 (23:22 -0600)]
Remove struct complain

At this point, struct complain is just holds a key, a value, and a
"next" pointer to form a linked list.  It's simpler to replace this
with an unordered map.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (counters): New global.
(struct complain): Remove.
(struct complaints) <root>: Remove.
(complaint_sentinel): Remove.
(symfile_complaint_book): Update.
(find_complaint) Remove.
(complaint_internal, clear_complaints): Update.

gdb/testsuite/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* gdb.gdb/complaints.exp (test_initial_complaints): Simplify.

6 years agoRemove file and line from struct complain
Tom Tromey [Thu, 17 May 2018 05:14:03 +0000 (23:14 -0600)]
Remove file and line from struct complain

The file and line handling in complaints.c wasn't used once
internal_complaint was removed.  This patch removes all the related
code.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (struct complain) <file, line>: Remove.
(find_complaint): Remove file, line parameters.
(complaint_internal): Update.

6 years agoRemove vcomplaint
Tom Tromey [Thu, 17 May 2018 05:10:51 +0000 (23:10 -0600)]
Remove vcomplaint

vcomplaint now has a single caller, so merge it with that caller.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (vcomplaint): Remove.
(complaint_internal) Merge in contents of vcomplaint.

6 years agoRemove struct explanation
Tom Tromey [Thu, 17 May 2018 05:05:54 +0000 (23:05 -0600)]
Remove struct explanation

Now that there's only a single reason for a complaint to be emitted,
this removes "struct explanation" and changes vcomplaint to emit the
desired messages directly.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (struct complaints) <explanation>: Remove.
(symfile_explanations): Remove.
(symfile_complaint_book): Update.
(vcomplaint): Update.
(struct explanation): Remove.

6 years agoRemove symfile_complaints
Tom Tromey [Thu, 17 May 2018 04:54:44 +0000 (22:54 -0600)]
Remove symfile_complaints

The complaint system seems to allow for multiple different complaint
topics.  However, in practice only symfile_complaints has ever been
defined.  Seeing that complaints.c dates to 1992, and that no new
complaints have been added in the intervening years, I think it is
reasonable to admit that complaints are specifically related to
debuginfo reading.

This patch removes symfile_complaints and updates all the callers.
Some of these spots should perhaps be calls to warning instead, but I
did not make that change.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (symfile_complaints): Remove.
(complaint_internal): Remove "complaints" parameter.
(clear_complaints, vcomplaint): Remove "c" parameter.
(get_complaints): Remove.
* dwarf2read.c (dwarf2_statement_list_fits_in_line_number_section_complaint)
(dwarf2_debug_line_missing_file_complaint)
(dwarf2_debug_line_missing_end_sequence_complaint)
(dwarf2_complex_location_expr_complaint)
(dwarf2_const_value_length_mismatch_complaint)
(dwarf2_section_buffer_overflow_complaint)
(dwarf2_macro_malformed_definition_complaint)
(dwarf2_invalid_attrib_class_complaint)
(create_addrmap_from_index, dw2_symtab_iter_next)
(dw2_expand_marked_cus)
(dw2_debug_names_iterator::find_vec_in_debug_names)
(dw2_debug_names_iterator::next, dw2_debug_names_iterator::next)
(create_debug_type_hash_table, init_cutu_and_read_dies)
(partial_die_parent_scope, add_partial_enumeration)
(skip_one_die, fixup_go_packaging, quirk_rust_enum, process_die)
(dwarf2_compute_name, dwarf2_physname, read_namespace_alias)
(read_import_statement, read_file_scope, create_dwo_cu_reader)
(create_cus_hash_table, create_dwp_hash_table)
(inherit_abstract_dies, read_func_scope, read_call_site_scope)
(dwarf2_rnglists_process, dwarf2_ranges_process)
(dwarf2_add_type_defn, dwarf2_attach_fields_to_type)
(dwarf2_add_member_fn, get_alignment, maybe_set_alignment)
(handle_struct_member_die, process_structure_scope)
(read_array_type, read_common_block, read_module_type)
(read_tag_pointer_type, read_typedef, read_base_type)
(read_subrange_type, load_partial_dies, partial_die_info::read)
(partial_die_info::read, partial_die_info::read)
(partial_die_info::read, read_checked_initial_length_and_offset)
(dwarf2_string_attr, read_formatted_entries)
(dwarf_decode_line_header)
(lnp_state_machine::check_line_address, dwarf_decode_lines_1)
(new_symbol, dwarf2_const_value_attr, lookup_die_type)
(read_type_die_1, determine_prefix, dwarf2_get_ref_die_offset)
(dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes)
(get_signatured_type, get_DW_AT_signature_type)
(decode_locdesc, file_file_name, consume_improper_spaces)
(skip_form_bytes, skip_unknown_opcode, dwarf_parse_macro_header)
(dwarf_decode_macro_bytes, dwarf_decode_macros)
(dwarf2_symbol_mark_computed, set_die_type)
(read_attribute_value): Update.
* stap-probe.c (handle_stap_probe, get_stap_base_address):
Update.
* dbxread.c (unknown_symtype_complaint)
(lbrac_mismatch_complaint, repeated_header_complaint)
(set_namestring, function_outside_compilation_unit_complaint)
(read_dbx_symtab, process_one_symbol): Update.
* gdbtypes.c (stub_noname_complaint): Update.
* windows-nat.c (handle_unload_dll): Update.
* coffread.c (coff_symtab_read, enter_linenos, decode_type)
(decode_base_type): Update.
* xcoffread.c (bf_notfound_complaint, ef_complaint)
(eb_complaint, record_include_begin, record_include_end)
(enter_line_range, xcoff_next_symbol_text, read_xcoff_symtab)
(process_xcoff_symbol, read_symbol)
(function_outside_compilation_unit_complaint)
(scan_xcoff_symtab): Update.
* machoread.c (macho_symtab_read, macho_add_oso_symfile): Update.
* buildsym.c (finish_block_internal, make_blockvector)
(end_symtab_get_static_block, augment_type_symtab): Update.
* dtrace-probe.c (dtrace_process_dof)
(dtrace_static_probe_ops::get_probes): Update.
* complaints.h (struct complaint): Don't declare.
(symfile_complaints): Remove.
(complaint_internal): Remove "complaints" parameter.
(complaint): Likewise.
(clear_complaints): Likewise.
* symfile.c (syms_from_objfile_1, finish_new_objfile)
(reread_symbols): Update.
* dwarf2-frame.c (dwarf2_restore_rule, execute_cfa_program)
(dwarf2_frame_cache, decode_frame_entry): Update.
* dwarf2loc.c (dwarf_reg_to_regnum): Update.
* objc-lang.c (lookup_objc_class, lookup_child_selector)
(info_selectors_command): Update.
* macrotab.c (macro_include, check_for_redefinition)
(macro_undef): Update.
* objfiles.c (filter_overlapping_sections): Update.
* stabsread.c (invalid_cpp_abbrev_complaint)
(reg_value_complaint, stabs_general_complaint, dbx_lookup_type)
(define_symbol, error_type, read_type, rs6000_builtin_type)
(stabs_method_name_from_physname, read_member_functions)
(read_cpp_abbrev, read_baseclasses, read_tilde_fields)
(attach_fields_to_type, complain_about_struct_wipeout)
(read_range_type, read_args, common_block_start)
(common_block_end, cleanup_undefined_types_1, scan_file_globals):
Update.
* mdebugread.c (index_complaint, unknown_ext_complaint)
(basic_type_complaint, bad_tag_guess_complaint)
(bad_rfd_entry_complaint, unexpected_type_code_complaint)
(reg_value_complaint, parse_symbol, parse_type, upgrade_type)
(parse_procedure, parse_lines)
(function_outside_compilation_unit_complaint)
(parse_partial_symbols, psymtab_to_symtab_1, cross_ref)
(bad_tag_guess_complaint, reg_value_complaint): Update.
* cp-support.c (demangled_name_complaint): Update.
* macroscope.c (sal_macro_scope): Update.
* dwarf-index-write.c (class debug_names): Update.

gdb/testsuite/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* gdb.gdb/complaints.exp (test_initial_complaints): Don't mention
symfile_complaints.
(test_short_complaints): Likewise.
(test_empty_complaints): Likewise.
(test_initial_complaints): Update.

6 years agoRemove "noisy" parameter from clear_complaints
Tom Tromey [Thu, 17 May 2018 04:27:50 +0000 (22:27 -0600)]
Remove "noisy" parameter from clear_complaints

After the previous patch, the "noisy" parameter to clear_complaints is
no longer used, so this patch removes it.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (clear_complaints): Remove "noisy" parameter.
* complaints.h (clear_complaints): Update.
* symfile.c (syms_from_objfile_1, finish_new_objfile)
(reread_symbols): Update.

gdb/testsuite/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* gdb.gdb/complaints.exp (test_empty_complaints): Update.

6 years agoRemove elements from complaint_series
Tom Tromey [Thu, 17 May 2018 04:23:09 +0000 (22:23 -0600)]
Remove elements from complaint_series

I couldn't find a way to get complaints to use a couple of cases, and
the difference between the actual printed output for these cases was
minimal anyway.  So, this patch removes a couple of constants from
complaint_series, plus the associated code.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (enum complaint_series): Remove FIRST_MESSAGE,
SUBSEQUENT_MESSAGE.
(vcomplaint, clear_complaints): Update.
(symfile_explanations): Remove some messages.

gdb/testsuite/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* gdb.gdb/complaints.exp (test_serial_complaints): Remove.
(test_short_complaints): Update.

6 years agoRemove internal_complaint
Tom Tromey [Wed, 16 May 2018 21:09:32 +0000 (15:09 -0600)]
Remove internal_complaint

I happened to notice that gdb has both complaint_internal and
internal_complaint.  The latter is unused, so this patch removes it.

gdb/ChangeLog
2018-05-23  Tom Tromey  <tom@tromey.com>

* complaints.c (internal_complaint): Remove.
* complaints.h (internal_complaint): Remove.

6 years agoImprove File I/O overflow detection in gdbserver (PR server/23198)
Erik Kurzinger [Wed, 23 May 2018 11:04:39 +0000 (12:04 +0100)]
Improve File I/O overflow detection in gdbserver (PR server/23198)

Currently, the function used by gdbserver to parse integers from
received File I/O commands will detect overflow and fail for any value
over 0xfffffff.  Among other things, this has the effect of limiting
the file offsets for reading or writing to about 268MB which can be
insufficient for particularly large libraries.

This change allows the parsing of integers up to the true maximum
positive value of 0x7fffffff, increasing the file size limit to about
2GB.

gdb/gdbserver/ChangeLog:
2018-05-23  Erik Kurzinger  <ekurzinger@nvidia.com>

PR server/23198
* hostio.c (require_int): Do not report overflow for integers
between 0xfffffff and 0x7fffffff.

6 years agoAutomatic date update in version.in
GDB Administrator [Wed, 23 May 2018 00:00:29 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoFix gdb.base/remote.exp with native-extended-gdbserver board
Pedro Alves [Tue, 22 May 2018 22:26:46 +0000 (23:26 +0100)]
Fix gdb.base/remote.exp with native-extended-gdbserver board

This fixes gdb.base/remote.exp regressions caused by the previous
commit to the testcase, when tested with
--target_board=native-extended-gdbserver.  For example:

  ...
  show remote memory-write-packet-size
  The memory-write-packet-size is 0 (default). Packets are limited to 16383 bytes.
  (gdb) FAIL: gdb.base/remote.exp: write-packet default
  ...

With that board, GDB connects to GDBserver at gdb_start time, so GDB
is showing the actual remote/gdbserver packet size limits.

Fix it using the usual "disconnect" pattern.  While at it, there's no
need to start GDB before compiling the testcase.

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

* gdb.base/remote.exp: Only gdb_start after compiling the
testcase.  Issue "disconnect" before testing "set remote" command
defaults.  Issue clean_restart before running to main.

6 years agogdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'
Maciej W. Rozycki [Tue, 22 May 2018 21:52:14 +0000 (22:52 +0100)]
gdb/x86: Fix `-Wstrict-overflow' build error in `i387_collect_xsave'

Make `i' defined within `i387_collect_xsave' unsigned, removing a
`-Werror=strict-overflow' compilation error:

.../gdb/i387-tdep.c: In function 'void i387_collect_xsave(const regcache*, int, void*, int)':
.../gdb/i387-tdep.c:1348:1: error: assuming signed overflow does not occur when assuming that (X + c) < X is always false [-Werror=strict-overflow]
 i387_collect_xsave (const struct regcache *regcache, int regnum,
 ^
cc1plus: all warnings being treated as errors
Makefile:1610: recipe for target 'i387-tdep.o' failed
make: *** [i387-tdep.o] Error 1

seen with GCC 5.4.0, a commit 8ee22052f690 ("gdb/x86: Handle kernels
using compact xsave format") regression.  While `regnum' can be -1 on
entry to the function, to mean all registers, `i' is only used with
non-negative register numbers.

gdb/
* i387-tdep.c (i387_collect_xsave): Make `i' unsigned.

6 years agoMIPS/gdbserver: Correctly handle narrow big-endian register transfers
Maciej W. Rozycki [Tue, 22 May 2018 21:52:14 +0000 (22:52 +0100)]
MIPS/gdbserver: Correctly handle narrow big-endian register transfers

Fix an issue with `gdbserver' on big-endian n64 MIPS targets, where
$dspctl is 32-bit while the `ptrace' transfer data type is 64-bit.

Such register data is held in the low order 32 bits of the 64-bit data
quantity exchanged with the buffer used by `fetch_register' and
`store_register', however `supply_register' and `collect_register'
access the same data as a 32-bit quantity.  Consequently the register is
presented and written as all-zeros held in the most-significant part of
the big-endian 64-bit data quantity represented in the buffer:

(gdb) info registers
                  zero               at               v0               v1
 R0   0000000000000000 0000000000000001 0000000000000001 0000000000000000
                    a0               a1               a2               a3
 R4   00000001200212b0 0000000000000000 0000000000000021 000000012001a260
                    a4               a5               a6               a7
 R8   000000012001a260 0000000000000004 800000010c60c000 fffffffffffffff8
                    t0               t1               t2               t3
 R12  0000000000000000 000000fff7edab68 0000000000000001 0000000000000000
                    s0               s1               s2               s3
 R16  000000fff7ee2068 0000000120008b80 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  000000000052e5c8 000000000052f008 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000000 00000001200027c0 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  00000001200212b0 000000ffffffc850 000000ffffffc850 0000000120005ee8
                status               lo               hi         badvaddr
      0000000000109cf3 0000000000943efe 000000000000000e 000000012001a008
                 cause               pc
      0000000000800024 0000000120005ee8
                  fcsr              fir              hi1              lo1
              0e800000         00f30000 0000000000000000 0101010101010101
                   hi2              lo2              hi3              lo3
      0202020202020202 0303030303030303 0404040404040404 0505050505050505
                dspctl          restart
              00000000 0000000000000000
(gdb)

Correct this problem then by using the `mips_supply_register'
`mips_collect_register' accessors for 32-bit registers where the
`ptrace' data type is 64-bit.  These accessors already operate on 32-bit
data quantities held in 64-bit containers:

(gdb) info registers
                  zero               at               v0               v1
 R0   0000000000000000 0000000000000001 0000000000000001 0000000000000000
                    a0               a1               a2               a3
 R4   00000001200212b0 0000000000000000 0000000000000021 000000012001a260
                    a4               a5               a6               a7
 R8   000000012001a260 0000000000000004 800000010d82e900 fffffffffffffff8
                    t0               t1               t2               t3
 R12  0000000000000000 000000fff7edab68 0000000000000001 0000000000000000
                    s0               s1               s2               s3
 R16  000000fff7ee2068 0000000120008b80 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  000000000052e5c8 000000000052f008 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000000 00000001200027c0 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  00000001200212b0 000000ffffffc850 000000ffffffc850 0000000120005ee8
                status               lo               hi         badvaddr
      0000000000109cf3 0000000000943efe 000000000000000e 000000012001a008
                 cause               pc
      0000000000800024 0000000120005ee8
                  fcsr              fir              hi1              lo1
              0e800000         00f30000 0000000000000000 0101010101010101
                   hi2              lo2              hi3              lo3
      0202020202020202 0303030303030303 0404040404040404 0505050505050505
                dspctl          restart
              55aa33cc 0000000000000000
(gdb)

gdb/gdbserver/
* linux-mips-low.c [HAVE_PTRACE_GETREGS] (mips_collect_register)
(mips_supply_register): Move outside HAVE_PTRACE_GETREGS.
(mips_collect_ptrace_register, mips_supply_ptrace_register): New
functions.
(the_low_target): Wire them.

6 years agoremote: one struct remote_state per struct remote_target
Pedro Alves [Tue, 22 May 2018 17:22:11 +0000 (18:22 +0100)]
remote: one struct remote_state per struct remote_target

'struct remote_state' today contains per-connection state, however
there's only a single global instance of that type.  In order to
support multiple connections, we must have one such object per
connection.

Thus this patch eliminates the 'remote_state' global in favor of
having a remote_state instance per remote_target instance.

The get_remote_state free function is eliminated as well, by making it
a remote_target method instead.

The patch then fixes the fallout by making all free functions that
refer to get_remote_state() directly or indirectly be methods of
remote_target too.

Likewise, remote-fileio.c and remote-notif.c routines are
parameterized with a remote_target pointer too, so they can call into
the right remote_target instance.

References to the global 'get_remote_state ()->remote_desc' to tell
whether the remote target is open (!= nullptr) must be replaced with
something else:

 - Command implementations use a new get_current_remote_target free
 function.

 - remote_target::open_1 checks the exception type instead.

Finally, remote_target and extended_remote_target are made
heap-allocated targets.  As with the earlier core target patches, it
still won't be possible to have more than one remote_target instance
in practice, but this puts us closer.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote-fileio.c (remote_fileio_reply, remote_fileio_ioerror)
(remote_fileio_badfd, remote_fileio_return_errno)
(remote_fileio_return_success, remote_fileio_func_open)
(remote_fileio_func_open, remote_fileio_func_close)
(remote_fileio_func_read, remote_fileio_func_write)
(remote_fileio_func_lseek, remote_fileio_func_rename)
(remote_fileio_func_unlink, remote_fileio_func_stat)
(remote_fileio_func_fstat, remote_fileio_func_gettimeofday)
(remote_fileio_func_isatty, remote_fileio_func_system): Add
remote_target parameter.
(remote_fio_func_map) <func>: Add remote_target parameter.
(do_remote_fileio_request, remote_fileio_request):
* remote-fileio.h (remote_fileio_request):
* remote-notif.c (remote_notif_ack, remote_notif_parse, ): Add
remote_target parameter.
(remote_notif_process, handle_notification): Adjust to pass down
the remote.
(remote_notif_state_allocate): Add remote_target parameter.  Save
it.
* remote-notif.h (struct remote_target): Forward declare.
(struct notif_client) <parse, ack, can_get_pending_events>: Add
remote_target parameter.
(struct remote_notif_state) <remote>: New field.
(remote_notif_ack, remote_notif_parse): Add remote_target
parameter.
(remote_notif_state_allocate, remote_notif_state_allocate): Add
remote_target parameter.
* remote.c (OPAQUETHREADBYTES, threadref, gdb_ext_thread_info)
(threads_listing_context, rmt_thread_action, protocol_feature)
(packet_reg, stop_reply, stop_reply_p, enum packet_support)
(packet_result, struct threads_listing_context, remote_state):
Move definitions and declarations higher up.
(remote_target) <~remote_target>: Declare.
(remote_download_command_source, remote_file_put, remote_file_get)
(remote_file_delete, remote_hostio_pread, remote_hostio_pwrite)
(remote_hostio_pread_vFile, remote_hostio_send_command)
(remote_hostio_set_filesystem, remote_hostio_open)
(remote_hostio_close, remote_hostio_unlink, remote_state)
(get_remote_state, get_remote_packet_size, get_memory_packet_size)
(get_memory_write_packet_size, get_memory_read_packet_size)
(append_pending_thread_resumptions, remote_detach_1)
(append_resumption, remote_resume_with_vcont)
(add_current_inferior_and_thread, wait_ns, wait_as)
(process_stop_reply, remote_notice_new_inferior)
(process_initial_stop_replies, remote_add_thread)
(btrace_sync_conf, remote_btrace_maybe_reopen)
(remove_new_fork_children, kill_new_fork_children)
(discard_pending_stop_replies, stop_reply_queue_length)
(check_pending_events_prevent_wildcard_vcont)
(discard_pending_stop_replies_in_queue, stop_reply)
(remote_notif_remove_queued_reply, stop_reply *queued_stop_reply)
(peek_stop_reply, remote_parse_stop_reply, remote_stop_ns)
(remote_interrupt_as, remote_interrupt_ns)
(remote_get_noisy_reply, remote_query_attached)
(remote_add_inferior, remote_current_thread, get_current_thread)
(set_thread, set_general_thread, set_continue_thread)
(set_general_process, write_ptid)
(remote_unpack_thread_info_response, remote_get_threadinfo)
(parse_threadlist_response, remote_get_threadlist)
(remote_threadlist_iterator, remote_get_threads_with_ql)
(remote_get_threads_with_qxfer)
(remote_get_threads_with_qthreadinfo, extended_remote_restart)
(get_offsets, remote_check_symbols, remote_supported_packet)
(remote_query_supported, remote_packet_size)
(remote_serial_quit_handler, remote_detach_pid)
(remote_vcont_probe, remote_resume_with_hc)
(send_interrupt_sequence, interrupt_query)
(remote_notif_get_pending_events, fetch_register_using_p)
(send_g_packet, process_g_packet, fetch_registers_using_g)
(store_register_using_P, store_registers_using_G)
(set_remote_traceframe, check_binary_download)
(remote_write_bytes_aux, remote_write_bytes, remote_read_bytes_1)
(remote_xfer_live_readonly_partial, remote_read_bytes)
(remote_send_printf, remote_flash_write, readchar)
(remote_serial_write, putpkt, putpkt_binary, skip_frame)
(read_frame, getpkt, getpkt_or_notif_sane_1, getpkt_sane)
(getpkt_or_notif_sane, remote_vkill, remote_kill_k)
(extended_remote_disable_randomization, extended_remote_run)
(send_environment_packet, extended_remote_environment_support)
(extended_remote_set_inferior_cwd, remote_write_qxfer)
(remote_read_qxfer, push_stop_reply, vcont_r_supported)
(packet_command): Now methods of ...
(remote_target): ... this class.
(m_remote_state) <remote_target>: New field.
(struct remote_state) <stop_reply_queue,
remote_async_inferior_event_token, wait_forever_enabled_p>: New
fields.
(remote_state::remote_state): Allocate stop_reply_queue.
(remote_state): Delete global.
(get_remote_state_raw): Delete.
(remote_target::get_remote_state): Allocate m_remote_state on
demand.
(get_current_remote_target): New.
(remote_ops, extended_remote_ops): Delete.
(wait_forever_enabled_p, remote_async_inferior_event_token):
Delete, moved to struct remote_state.
(remote_target::close): Delete self.  Destruction bits split to
...
(remote_target::~remote_target): ... this.
(show_memory_packet_size): Adjust to use
get_current_remote_target.
(struct protocol_feature) <func>: Add remote_target parameter.
All callers adjusted.
(curr_quit_handler_target): New.
(remote_serial_quit_handler): Reimplement.
(remote_target::open_1): Adjust to use get_current_remote_target.
Heap-allocate remote_target/extended_remote_target instances.
(vcont_builder::vcont_builder): Add remote_target parameter, and
save it in m_remote.  All callers adjusted.
(vcont_builder::m_remote): New field.
(vcont_builder::restart, vcont_builder::flush)
(vcont_builder::push_action): Use it.
(remote_target::commit_resume): Use it.
(struct queue_iter_param) <remote>: New field.
(remote_target::remove_new_fork_children): Fill in 'remote' field.
(check_pending_event_prevents_wildcard_vcont_callback_data): New.
(check_pending_event_prevents_wildcard_vcont_callback)
(remote_target::check_pending_events_prevent_wildcard_vcont)
(remote_target::discard_pending_stop_replies)
(remote_target::discard_pending_stop_replies_in_queue)
(remote_target::remote_notif_remove_queued_reply): Fill in
'remote' field.
(remote_notif_get_pending_events): New.
(remote_target::readchar, remote_target::remote_serial_write):
Save/restore curr_quit_handler_target.
(putpkt): New.
(kill_new_fork_children): Fill in 'remote' field.
(packet_command): Use get_current_remote_target, defer to
remote_target method of same name.
(scoped_remote_fd::scoped_remote_fd): Add 'remote_target'
parameter, and save it in m_remote.  All callers adjusted.
(scoped_remote_fd::release): Use m_remote.
(scoped_remote_fd::m_remote): New field.
(remote_file_put, remote_file_get, remote_file_delete): Use
get_current_remote_target, defer to remote_target method of same
name.
(remote_btrace_reset): Add remote_state paremeter.  Update all
callers.
(remote_async_inferior_event_handler). Pass down 'data'.
(remote_new_objfile): Use get_current_remote_target.
(remote_target::vcont_r_supported): New.
(set_range_stepping): Use get_current_remote_target and
remote_target::vcont_r_supported.
(_initialize_remote): Don't allocate 'remote_state' and
'stop_reply_queue' globals.
* remote.h (struct remote_target): Forward declare.
(getpkt, putpkt, remote_notif_get_pending_events): Add
'remote_target' parameter.

6 years agoremote: Make vcont_builder a class
Pedro Alves [Tue, 22 May 2018 17:22:11 +0000 (18:22 +0100)]
remote: Make vcont_builder a class

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (vcont_builder): Now a class.  Make all data members
private.
(vcont_builder) <vcont_builder, restart, flush, push_action>:
Declare methods.
(vcont_builder_restart): Rename to ...
(vcont_builder::restart): ... this.
(vcont_builder_flush): Rename to ...
(vcont_builder::flush): ... this.
(vcont_builder_push_action): Rename to ...
(vcont_builder::push_action): ... this.
(remote_target::commit_resume): Adjust.

6 years agoHandle "show remote memory-write-packet-size" when not connected
Pedro Alves [Tue, 22 May 2018 17:22:10 +0000 (18:22 +0100)]
Handle "show remote memory-write-packet-size" when not connected

Currently "show remote memory-write-packet-size" says that the packet
size is limited to whatever is stored in the remote_state global, even
if not connected to a target.

When we get to support multiple instances of remote targets, there
won't be a remote_state global anymore, so that must be replaced by
something else.

Since it doesn't make sense to print the limit of the packet size of a
non-existing connection, this patch makes us say that the limit will
be further reduced when we connect.

The text is taken from the command's online help, which says:

 "The actual limit is further reduced dependent on the target."

Note that a value of "0" is special, as per "help set remote
memory-write-packet-size":

 ~~~
 Specify the number of bytes in a packet or 0 (zero) for the
 default packet size.
 ~~~

I've tweaked "show remote memory-write-packet-size" to include
"(default)" in the output in that case, like this:

 (gdb) show remote memory-write-packet-size
 The memory-write-packet-size is 0 (default). The actual limit will be further reduced dependent on the target.

While working on this, I noticed that an explicit "set remote
write-packet-size 0" does not makes GDB go back to the exact same
state as the default state when GDB starts up:

 (gdb) show remote memory-write-packet-size
 The memory-write-packet-size is 0. [...]
                                 ^^

 (gdb) set remote memory-write-packet-size 0
 (gdb) show remote memory-write-packet-size
 The memory-write-packet-size is 16384. [...]
                                 ^^^^^

The "16384" number comes from DEFAULT_MAX_MEMORY_PACKET_SIZE.

This happens because git commit a5c0808e221c ("gdb: remove packet size
limit") at
<https://sourceware.org/ml/gdb-patches/2015-08/msg00743.html>, added
this:

  /* So that the query shows the correct value.  */
  if (size <= 0)
    size = DEFAULT_MAX_MEMORY_PACKET_SIZE;

to set_memory_packet_size, but despite what the comment suggests, that
also has the side-effect of recording DEFAULT_MAX_MEMORY_PACKET_SIZE
in config->size.

Finally, DEFAULT_MAX_MEMORY_PACKET_SIZE only makes sense for "set
remote memory-write-packet-size fixed", so I've renamed it
accordingly, to make it a little bit clearer.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (DEFAULT_MAX_MEMORY_PACKET_SIZE): Rename to ...
(DEFAULT_MAX_MEMORY_PACKET_SIZE_FIXED): ... this.
(get_fixed_memory_packet_size): New.
(get_memory_packet_size): Use it.
(set_memory_packet_size): Don't override the config size with
DEFAULT_MAX_MEMORY_PACKET_SIZE.
(show_memory_packet_size): Use get_fixed_memory_packet_size.
Don't refer to get_memory_packet_size if not connected to a remote
target.  Show "(default)" if configured size is 0.

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

* gdb.base/remote.exp: Adjust expected output of "show remote
memory-write-packet-size".  Add tests for "set remote
memory-write-packet-size 0" and "set remote
memory-write-packet-size fixed/limit".

6 years agoremote: Move discard_pending_stop_replies call
Pedro Alves [Tue, 22 May 2018 17:22:09 +0000 (18:22 +0100)]
remote: Move discard_pending_stop_replies call

This helps because discard_pending_stop_replies will later become a
method of remote_target.  Otherwise, when we have multiple instances
of remote_target, we'd have to make discard_pending_stop_replies find
the inferior's target_ops, and upcast it to remote_target (if indeed a
remote) to find the pending stop replies queue to clear.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (remote_target::mourn_inferior): Move
discard_pending_stop_replies call here from ...
(_initialize_remote): ... here.

6 years agoremote: Small cleanup in compare_section_command
Pedro Alves [Tue, 22 May 2018 17:22:09 +0000 (18:22 +0100)]
remote: Small cleanup in compare_section_command

The set_general_process call in compare_sections_command isn't
actually needed.  remote_target::verify_memory and
remote_target::xfer_partial already handle making sure the remote is
pointing at the right process or thread.

Getting this out of the way helps a bit with further elimination of
the remote_state global, because we have to handle the case of a user
invoking the command even if not connect to a remote target.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (compare_section_command): Remove set_general_process
call.

6 years agoremote: remote_arch_state pointers -> remote_arch_state objects
Pedro Alves [Tue, 22 May 2018 17:22:08 +0000 (18:22 +0100)]
remote: remote_arch_state pointers -> remote_arch_state objects

The previous patch made the map store pointers to remote_arch_state
instead of objects directly, simply because struct remote_arch_state
is still incomplete where struct remote_state is declared.  This patch
thus moves the remote_arch_state declaration higher up in the file,
and makes the map store remote_arch_state objects directly instead of
pointers to objects.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (struct packet_reg, struct remote_arch_state):
Move higher up in the file.
(remote_state) <m_arch_states>: Store remote_arch_state values
instead of remote_arch_state pointers.
(remote_state::get_remote_arch_state): Adjust.

6 years agoremote: multiple remote_arch_state instances per arch
Pedro Alves [Tue, 22 May 2018 17:22:08 +0000 (18:22 +0100)]
remote: multiple remote_arch_state instances per arch

Currently, we associate gdbarch-related remote protocol state on a
per-gdbarch data object.  Things like the size of the g/G packet, and
the max remote packet size.  If we'll support being connected to
different remote servers at the same time, then we need to cope with
each having their own packet sizes, even if they are each debugging
programs of the same architecture.  I.e., a single instance of
remote_arch_state per arch is not sufficient.

This patch moves the remote_arch_state object to a map of
gdbarch-to-remote_arch_state saved in the remote_state structure.
Usually there will only be one entry in the map, though we may see
more with stubs that support multi-process and/or archs with multiple
ABIs (e.g, one remote_arch_state for 64-bit inferiors and another for
32-bit inferiors).

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c: Include <unordered_map>.
(remote_state): Now a class.
(remote_state) <get_remote_arch_state>: Declare method.
<get_remote_arch_state>: New field.
(remote_arch_state) <remote_arch_state>: Declare ctor.
<regs>: Now a unique_ptr.
(remote_gdbarch_data_handle): Delete.
(get_remote_arch_state): Delete.
(remote_state::get_remote_arch_state): New.
(get_remote_state): Adjust to call remote_state's
get_remote_arch_state method.
(init_remote_state): Delete, bits factored out to ...
(remote_arch_state::remote_arch_state): ... this new method.
(get_remote_packet_size, get_memory_packet_size)
(process_g_packet, remote_target::fetch_registers)
(remote_target::prepare_to_store, store_registers_using_G)
(remote_target::store_registers, remote_target::get_trace_status):
Adjust to call remote_state's method.
(_initialize_remote): Remove reference to
remote_gdbarch_data_handle.

6 years agoremote: Make readahead_cache a C++ class
Pedro Alves [Tue, 22 May 2018 17:22:07 +0000 (18:22 +0100)]
remote: Make readahead_cache a C++ class

The idea here is eliminate the get_remote_state calls from within
readahead_cache_invalidate, readahead_cache_invalidate_fd,
remote_hostio_pread_from_cache by making those functions be class
methods instead.  Later on we'll have one readahead_cache instance per
remote connection, and this change makes that easier.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (struct readahead_cache) <invalidate, invalidate_fd,
pread>: New method declarations.
(remote_target::open_1): Adjust.
(readahead_cache_invalidate): Rename to ...
(readahead_cache::invalidate): ... this, and adjust to be a class
method.
(readahead_cache_invalidate_fd): Rename to ...
(readahead_cache::invalidate_fd): ... this, and adjust to be a
class method.
(remote_hostio_pwrite): Adjust.
(remote_hostio_pread_from_cache): Rename to ...
(readahead_cache::pread): ... this, and adjust to be a class
method.
(remote_hostio_close): Adjust.

6 years agoremote: Eliminate remote_hostio_close_cleanup
Pedro Alves [Tue, 22 May 2018 17:22:07 +0000 (18:22 +0100)]
remote: Eliminate remote_hostio_close_cleanup

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

* remote.c (remote_hostio_close_cleanup): Delete.
(class scoped_remote_fd): New.
(remote_file_put, remote_file_get): Use it.

6 years agoremote: struct remote_state, use op new, fix leaks
Pedro Alves [Tue, 22 May 2018 17:22:06 +0000 (18:22 +0100)]
remote: struct remote_state, use op new, fix leaks

A bit of C++ification.  Also plugs a few leaks, since currently
nothing is freeing a few fields of remote_state.  They're now freed in
the added destructor.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>

(struct vCont_action_support): Use bool and initialize all fields.
(struct readahead_cache): Initialize all fields.
(remote_state): Use bool and initialize all fields.
(remote_state::remote_state, remote_state::~remote_state): New.
(new_remote_state): Delete.
(_initialize_remote): Use new to allocate remote_state.

6 years agoSupport UTF-8 identifiers in C/C++ expressions (PR gdb/22973)
Pedro Alves [Tue, 22 May 2018 16:35:38 +0000 (17:35 +0100)]
Support UTF-8 identifiers in C/C++ expressions (PR gdb/22973)

Factor out cp_ident_is_alpha/cp_ident_is_alnum out of
gdb/cp-name-parser.y and use it in the C/C++ expression parser too.

New test included.

gdb/ChangeLog:
2018-05-22  Pedro Alves  <palves@redhat.com>
    張俊芝  <zjz@zjz.name>

PR gdb/22973
* c-exp.y: Include "c-support.h".
(parse_number, c_parse_escape, lex_one_token): Use TOLOWER instead
of tolower.  Use c_ident_is_alpha to scan names.
* c-lang.c: Include "c-support.h".
(convert_ucn, convert_octal, convert_hex, convert_escape): Use
ISXDIGIT instead of isxdigit and ISDIGIT instead of isdigit.
* c-support.h: New file, with bits factored out from ...
* cp-name-parser.y: ... this file.
Include "c-support.h".
(cp_ident_is_alpha, cp_ident_is_alnum): Deleted, moved to
c-support.h and renamed.
(symbol_end, yylex): Adjust.

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

PR gdb/22973
* gdb.base/utf8-identifiers.c: New file.
* gdb.base/utf8-identifiers.exp: New file.

6 years ago[PowerPC] Recognize isa205 in linux core files
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:06 +0000 (11:09 -0300)]
[PowerPC] Recognize isa205 in linux core files

Currently the ppc linux core file target doesn't return target
descriptions with the lager FPSCR introduced in isa205.

This patch changes the core file target so that the auxv is read from
the core file to determine the size of FPSCR, so that the appropriate
target description is selected.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* arch/ppc-linux-common.c (ppc_linux_has_isa205): Change the
parameter type to CORE_ADDR.
* arch/ppc-linux-common.h (ppc_linux_has_isa205): Change the
parameter type in declaration to CORE_ADDR.
* ppc-linux-tdep.c (ppc_linux_core_read_description): Call
target_auxv_search to get AT_HWCAP and use the result to get the
target description.
* ppc-linux-nat.c (ppc_linux_get_hwcap): Change the return type
to CORE_ADDR. Remove the cast of the return value to unsigned
long. Fix error predicate of target_auxv_search.
(ppc_linux_nat_target::read_description): Change the type of the
hwcap variable to CORE_ADDR.

gdb/testsuite/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* gdb.arch/powerpc-fpscr-gcore.exp: New file.

6 years ago[PowerPC] Fix inclusion of dfp pseudoregs in tdep
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Fix inclusion of dfp pseudoregs in tdep

Previously, decimal floating point pseudoregisters were always included
in the target if it had a floating point unit.

This patch changes this to only include them if the target description
indicates that they are present, i.e. if the FPSCR register has more
than 32 bits.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* rs6000-tdep.c (rs6000_gdbarch_init): Assign 1 to have_dfp only
if the size of fpscr is larger than 32 bits.

6 years ago[PowerPC] Fix VSX registers in linux core files
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Fix VSX registers in linux core files

The functions used by the VSX regset to collect and supply registers
from core files where incorrect. This patch changes the regset to use
the standard regset collect/supply functions to fix this. The native
target is also changed to use the same regset.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* ppc-linux-tdep.c (ppc_linux_vsxregset): New function.
(ppc32_linux_vsxregmap): New global.
(ppc32_linux_vsxregset): Initialize with ppc32_linux_vsxregmap,
regcache_supply_regset, and regcache_collect_regset.
* ppc-linux-tdep.h (ppc_linux_vsxregset): Declare.
* ppc-linux-nat.c (supply_vsxregset, fill_vsxregset): Remove.
(fetch_vsx_register, store_vsx_register): Remove.
(fetch_vsx_registers): Add regno parameter. Get regset using
ppc_linux_vsxregset. Use regset to supply registers.
(store_vsx_registers): Add regno parameter. Get regset using
ppc_linux_vsxregset. Use regset to collect registers.
(fetch_register): Call fetch_vsx_registers instead of
fetch_vsx_register.
(store_register): Call store_vsx_registers instead of
store_vsx_register.
(fetch_ppc_registers): Call fetch_vsx_registers with -1 for the
new regno parameter.
(store_ppc_registers): Call store_vsx_registers with -1 for the
new regno parameter.
* rs6000-tdep.c (ppc_vsx_support_p, ppc_supply_vsxreget)
(ppc_collect_vsxregset): Remove.

gdb/testsuite/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* gdb.arch/powerpc-vsx-gcore.exp: New file.

6 years ago[PowerPC] Fix access to VSCR in linux targets
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Fix access to VSCR in linux targets

The 4-byte VSCR register is found inside a 16-byte field in the regset
returned by ptrace and in core files. The position of VSCR depends on
the endianess of the target, which was previously assumed to be
big-endian for the purpose of getting VSCR. This patch removes this
assumption to fix access to VSCR in little-endian mode.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* ppc-tdep.h (struct ppc_reg_offsets): Remove vector register
offset fields.
* ppc-fbsd-tdep.c (ppc32_fbsd_reg_offsets): Remove initializers
for vector register offset fields.
(ppc64_fbsd_reg_offsets): Likewise.
* ppc-nbsd-tdep.c (_initialize_ppcnbsd_tdep): Remove assignment
to vector register offset fields.
* ppc-obsd-tdep.c (_initialize_ppcnbsd_tdep): Remove assignment
to vector register offset fields.
* ppc-obsd-nat.c (_initialize_ppcobsd_nat): Remove assignment to
vector register offset fields.
* rs6000-aix-tdep.c (rs6000_aix32_reg_offsets): Remove
initializers for vector register offset fields.
(rs6000_aix64_reg_offsets): Likewise.
* rs6000-tdep.c (ppc_vrreg_offset): Remove.
(ppc_supply_vrregset): Remove.
(ppc_collect_vrregset): Remove.
* ppc-linux-tdep.c (ppc_linux_collect_vrregset): New function.
(ppc_linux_vrregset) : New function.
(ppc32_le_linux_vrregmap, ppc32_be_linux_vrregmap)
(ppc32_le_linux_vrregset, ppc32_be_linux_vrregset): New globals.
(ppc32_linux_vrregset): Remove.
(ppc_linux_iterate_over_regset_sections): Call ppc_linux_vrregset
and use result instead of ppc32_linux_vrregset.
(ppc32_linux_reg_offsets): Remove initializers for vector register
offset fields.
(ppc64_linux_reg_offsets): Likewise.
* ppc-linux-tdep.h (ppc_linux_vrregset): New declaration.
* ppc-linux-nat.c: Include regset.h.
(gdb_vrregset_t): Adjust comment to account for little-endian
mode.
(supply_vrregset, fill_vrregset): Remove.
(fetch_altivec_register, store_altivec_register): Remove.
(fetch_altivec_registers): Add regno parameter. Get regset using
ppc_linux_vrregset. Use regset to supply registers.
(store_altivec_registers): Add regno parameter. Get regset using
ppc_linux_vrregset. Use regset to collect registers.
(fetch_register): Call fetch_altivec_registers instead of
fetch_altivec_register.
(store_register): Call store_altivec_registers instead of
store_altivec_register.
(fetch_ppc_registers): Call fetch_altivec_registers with -1 for
the new regno parameter.
(store_ppc_registers): Call store_altivec_registers with -1 for
the new regno parameter.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* linux-ppc-low.c (ppc_fill_vrregset): Add vscr_offset variable.
Set vscr_offset to 0 in little-endian mode and 12 in big-endian
mode. Call collect_register_by_name with vscr using
vscr_offset. Zero-pad vscr and vrsave fields in collector buffer.
(ppc_store_vrregset): Add and set vscr_offset variable as in
ppc_fill_vrregset. Call supply_register_by_name with vscr using
vscr_offset.

6 years ago[PowerPC] Consolidate linux vector regset sizes
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Consolidate linux vector regset sizes

This patch defines constants for the sizes of the two vector
regsets (vector-scalar registers and regular vector registers).

The native, gdbserver and core file targets are changed to use these
constants.

The Linux ptrace calls return (or read) a smaller regset than the one
found in core files for vector registers, because ptrace uses a single
4-byte quantity for vrsave at the end of the regset, while the
core-file regset uses a full 16-byte field for vrsave. For simplicity,
the larger size is used in both cases, and so a buffer with 12 unused
additional bytes is passed to ptrace in the native target.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* arch/ppc-linux-common.h (PPC_LINUX_SIZEOF_VRREGSET)
(PPC_LINUX_SIZEOF_VSXREGSET): Define.
* ppc-linux-nat.c (SIZEOF_VSXREGS, SIZEOF_VRREGS): Remove.
(gdb_vrregset_t): Change array type size to
PPC_LINUX_SIZEOF_VRREGSET.
(gdb_vsxregset_t): Change array type size to
PPC_LINUX_SIZEOF_VSXREGSET.
* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections):
Change integer literals to PPC_LINUX_SIZEOF_VRREGSET and
PPC_LINUX_SIZEOF_VSXREGSET.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* linux-ppc-low.c (SIZEOF_VSXREGS, SIZEOF_VRREGS): Remove.
(ppc_arch_setup): Change SIZEOF_VRREGS and SIZEOF_VSXREGS to
PPC_LINUX_SIZEOF_VRREGSET and PPC_LINUX_SIZEOF_VSXREGSET.

6 years ago[PowerPC] Disable regsets using zero sizes in gdbserver
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Disable regsets using zero sizes in gdbserver

Currently the linux-ppc-low.c fill/store functions for extended
regsets check whether they should execute by using the global hwcap
variable.

This patch explicitly sets the regset sizes to zero when needed to
disable them instead, so that the fill/store functions are not called
in the first place by regsets_fetch_inferior_registers in linux-low.c.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* linux-ppc-low.c (ppc_fill_vsxregset): Remove ppc_hwcap check.
(ppc_store_vsxregset): Likewise.
(ppc_fill_vrregset): Likewise.
(ppc_store_vrregset): Likewise.
(ppc_fill_evrregset): Likewise.
(ppc_store_evrregset): Likewise.
(ppc_regsets): Set VSX/VR/EVR regset sizes to 0.
(ppc_arch_setup): Iterate through ppc_regsets and set sizes when
needed.

6 years ago[PowerPC] Consolidate wordsize getter between native and gdbserver
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Consolidate wordsize getter between native and gdbserver

This patch moves the native target wordsize getter for ppc linux to
nat/ so that it can be used to simplify ppc_arch_setup in
gdbserver. The ptrace call used to get MSR for this is ultimately the
same as before, but it is no longer necessary to create a temporary
regcache to call fetch_inferior_registers.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* configure.nat <linux powerpc>: Add ppc-linux.o to NATDEPFILES.
* ppc-linux-nat.c (ppc_linux_target_wordsize): Move to
nat/ppc-linux.c.
(ppc_linux_nat_target::auxv_parse): Get thread id tid. Call
ppc_linux_target_wordsize with tid.
(ppc_linux_nat_target::read_description): Call ppc_linux_target
wordsize with tid.
* nat/ppc-linux.c: Include nat/gdb_ptrace.h.
(ppc64_64bit_inferior_p): Add static and inline specifiers.
(ppc_linux_target_wordsize): Move here from ppc-linux-nat.c. Add
tid parameter. Remove static specifier.
* nat/ppc-linux.h (ppc64_64bit_inferior_p): Remove declaration.
(ppc_linux_target_wordsize): New declaration.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* linux-ppc-low.c (ppc_arch_setup): Remove code for getting the
wordsize of the inferior. Call ppc_linux_target_wordsize.

6 years ago[PowerPC] Consolidate linux target description selection
Pedro Franco de Carvalho [Tue, 22 May 2018 14:09:05 +0000 (11:09 -0300)]
[PowerPC] Consolidate linux target description selection

Share target description declarations and selection among ppc linux
native targets, core files, gdbserver and IPA.

To avoid complicated define guards, gdbserver and IPA now have
declarations for all descriptions, including 64-bit generated
descriptions when compiled in 32-bit mode. These have always been
linked into the gdbserver and IPA binaries. Because they might be
uninitialized, the selection function checks that the selected
description is initialized.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* arch/ppc-linux-common.c: New file.
* arch/ppc-linux-common.h: New file.
* arch/ppc-linux-tdesc.h: New file.
* configure.tgt (powerpc*-*-linux*): Add arch/ppc-linux-common.o.
* Makefile.in (ALL_TARGET_OBS): Add arch/ppc-linux-common.o.
(HFILES_NO_SRCDIR): Add arch/ppc-linux-common.h and
arch/ppc-linux-tdesc.h.
* ppc-linux-nat.c: Include arch/ppc-linux-common.h and
arch/ppc-linux-tdesc.h.
(ppc_linux_nat_target::read_description): Remove target
description matching code. Fill a ppc_linux_features struct and
call ppc_linux_match_description with it. Move comment about ISA
2.05 to ppc-linux-common.c.
* ppc-linux-tdep.c: Include arch/ppc-linux-common.h and
arch/ppc-linux-tdesc.h.
(ppc_linux_core_read_description): Remove target description
matching code. Fill a ppc_linux_features struct and call
ppc_linux_match_description with it.
* ppc-linux-tdep.h (tdesc_powerpc_32l, tdesc_powerpc_64l)
(tdesc_powerpc_altivec32l, tdesc_powerpc_altivec64l)
(tdesc_powerpc_cell32l, tdesc_powerpc_cell64l)
(tdesc_powerpc_vsx32l, tdesc_powerpc_vsx64l)
(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_64l)
(tdesc_powerpc_isa205_altivec32l, tdesc_powerpc_isa205_altivec64l)
(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_isa205_vsx64l)
(tdesc_powerpc_e500l): Remove.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

* configure.srv (srv_tgtobj): Add arch/ppc-linux-common.o.
* Makefile.in (SFILES): Add arch/ppc-linux-common.c.
* linux-ppc-tdesc.h: Rename to linux-ppc-tdesc-init.h.
* linux-ppc-tdesc-init.h (tdesc_powerpc_32l, tdesc_powerpc_64l)
(tdesc_powerpc_altivec32l, tdesc_powerpc_altivec64l)
(tdesc_powerpc_cell32l, tdesc_powerpc_cell64l)
(tdesc_powerpc_vsx32l, tdesc_powerpc_vsx64l)
(tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_64l)
(tdesc_powerpc_isa205_altivec32l, tdesc_powerpc_isa205_altivec64l)
(tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_isa205_vsx64l)
(tdesc_powerpc_e500l): Remove.
* linux-ppc-ipa.c: Include arch/ppc-linux-tdesc.h and
linux-ppc-tdesc-init.h. Don't include linux-ppc-tdesc.h.
* linux-ppc-low.c: Include arch/ppc-linux-common.h,
arch/ppc-linux-tdesc.h, and linux-ppc-tdesc-init.h. Don't include
linux-ppc-tdesc.h.
(ppc_arch_setup): Remove target description matching code. Fill a
ppc_linux_features struct and call ppc_linux_match_description
with it.

6 years agofix "stale cleanup" internal-warning when using "catch assert" command
Joel Brobecker [Tue, 22 May 2018 14:04:15 +0000 (10:04 -0400)]
fix "stale cleanup" internal-warning when using "catch assert" command

Trying to insert a catchpoint on all Ada assertions now triggers
the following internal warning regardless of the situation. For
instance, not even debugging any program:

    (gdb) catch assert
    /[...]/gdb/common/cleanups.c:264: internal-warning:
    restore_my_cleanups has found a stale cleanup

This is due to a small bug in the following C++-ification commit:

    commit bc18fbb575437dd10089ef4619e46c0b9a93097d
    Author: Tom Tromey <tom@tromey.com>
    Date:   Fri May 18 15:58:50 2018 -0600
    Subject: Change ada_catchpoint::excep_string to be a std::string

The stale cleanup in question is the following one in top.c:execute_command:

    cleanup_if_error = make_bpstat_clear_actions_cleanup ();

This cleanup is expected to be discarded if there are no exception.
There were no GDB exception; however, a C++ exception was triggered,
because we passed NULL as the excep_string argument when calling
create_ada_exception_catchpoint, which is a reference to a const
string. So we get a C++ exception during the std::string constructor,
which propagates up, causing the cleanup to unexpectedly remain
in the cleanup chain.

This patch fixes the immediate issue of the incorrect call to
create_ada_exception_catchpoint.

gdb/ChangeLog:

        * ada-lang.c (catch_assert_command): Pass empty string instead
        of NULL for excep_string argument.

Tested on x86_64-linux, fixes the following failures:

  * catch_assert_if.exp: insert catchpoint on failed assertions with condition
  * catch_ex.exp: insert catchpoint on failed assertions

This also fixes about a dozen UNRESOLVED tests that are a consequence
of the two tests above failing and crashing GDB.

6 years agoPR23207, hppa ld SIGSEGVs on invalid object files
Alan Modra [Tue, 22 May 2018 09:04:18 +0000 (18:34 +0930)]
PR23207, hppa ld SIGSEGVs on invalid object files

The last patch was enough to cure the testcase, but not the original
object file.  This patch does the same for hppa as is done for ppc64,
simply test for the section belonging to a group.  I've also
restricted stubs to load, alloc, code sections.

PR 23207
* elf32-hppa.c (hppa_get_stub_entry): Return NULL when link_sec
is NULL.
(elf32_hppa_size_stubs): Only create stubs for load, alloc, code
sections.
(final_link_relocate): Revert last change.

6 years agoPR23207, hppa ld SIGSEGVs on invalid object files
Alan Modra [Mon, 21 May 2018 11:59:25 +0000 (21:29 +0930)]
PR23207, hppa ld SIGSEGVs on invalid object files

We don't create PLT call stubs for anything in non-alloc sections,
so it doesn't pay to go looking for them.  The problem is that
non-alloc sections aren't processed by group_sections and thus don't
get a link_sec set up for them.

PR 23207
* elf32-hppa.c (final_link_relocate): Don't look for plt call
stubs in non-alloc sections.

6 years agold: Adjust tic6x tests
H.J. Lu [Tue, 22 May 2018 03:41:11 +0000 (20:41 -0700)]
ld: Adjust tic6x tests

Adjust tic6x tests for removing local symbol, __c6xabi_DSBT_BASE, defined
by PROVIDE_HIDDEN in linker script from dynamic symbol table.

PR ld/23201
* testsuite/ld-tic6x/shlib-1.rd: Adjusted.
* testsuite/ld-tic6x/shlib-1b.rd: Likewise.
* testsuite/ld-tic6x/shlib-1r.rd: Likewise.
* testsuite/ld-tic6x/shlib-1rb.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1b.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1r.rd: Likewise.
* testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise.
* testsuite/ld-tic6x/shlib-noindex.rd: Likewise.
* testsuite/ld-tic6x/static-app-1.rd: Likewise.
* testsuite/ld-tic6x/static-app-1b.rd: Likewise.
* testsuite/ld-tic6x/static-app-1r.rd: Likewise.
* testsuite/ld-tic6x/static-app-1rb.rd: Likewise.

6 years agold: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN
H.J. Lu [Tue, 22 May 2018 03:39:09 +0000 (20:39 -0700)]
ld: Hide symbols defined by HIDDEN/PROVIDE_HIDDEN

There should be no difference in output for symbols defined by HIDDEN
or PROVIDE_HIDDEN assignments whether they are explicitly marked as
hidden or not.  This patch adds a new BFD function, bfd_link_hide_symbol,
to hide symbols defined by HIDDEN and PROVIDE_HIDDEN assignments.

bfd

PR ld/23201
* aout-target.h (MY_bfd_link_hide_symbol): New.
* aout-tic30.c (MY_bfd_link_hide_symbol): Likewise.
* binary.c (binary_bfd_link_hide_symbol): Likewise.
* coff-alpha.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
* coff-mips.c (_bfd_ecoff_bfd_link_hide_symbol): Likewise.
* coff-rs6000.c (_bfd_xcoff_bfd_link_hide_symbol): Likewise.
* coffcode.h (coff_bfd_link_hide_symbol): Likewise.
* elf-bfd.h (_bfd_elf_link_hide_symbol): Likewise.
* elfxx-target.h (bfd_elfNN_bfd_link_hide_symbol): Likewise.
* i386msdos.c (msdos_bfd_link_hide_symbol): Likewise.
* ihex.c (ihex_bfd_link_hide_symbol): Likewise.
* libbfd-in.h (_bfd_nolink_bfd_link_hide_symbol): Likewise.
* linker.c (_bfd_generic_link_hide_symbol): Likewise.
(bfd_link_hide_symbol): Likewise.
* mach-o-target.c (bfd_mach_o_bfd_link_hide_symbol): Likewise.
* mmo.c (mmo_bfd_link_hide_symbol): Likewise.
* pef.c (bfd_pef_bfd_link_hide_symbol): Likewise.
* plugin.c (bfd_plugin_bfd_link_hide_symbol): Likewise.
* ppcboot.c (ppcboot_bfd_link_hide_symbol): Likewise.
* som.c (som_bfd_link_hide_symbol): Likewise.
* srec.c (srec_bfd_link_hide_symbol): Likewise.
* tekhex.c (tekhex_bfd_link_hide_symbol): Likewise.
* vms-alpha.c (vms_bfd_link_hide_symbol): Likewise.
(alpha_vms_bfd_link_hide_symbol): Likewise.
* xsym.c (bfd_sym_bfd_link_hide_symbol): Likewise.
* coff64-rs6000.c (rs6000_xcoff64_vec): Add
_bfd_generic_link_hide_symbol.
(rs6000_xcoff64_aix_vec): Likewise.
* elflink.c (bfd_elf_record_link_assignment): Don't make forced
local symbol dynamic.
(_bfd_elf_link_hide_symbol): New function.
* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
check root.ldscript_def.
* targets.c (bfd_target): Add _bfd_link_hide_symbol.
(BFD_JUMP_TABLE_LINK): Add NAME##_bfd_link_hide_symbol.
* bfd-in2.h: Regenerated.
* libbfd.h: Likewise.

ld/

PR ld/23201
* ldexp.c (exp_fold_tree_1): Call bfd_link_hide_symbol to hide
a symbol.
* testsuite/ld-elf/provide-hidden-dynabs.nd: Removed.
* testsuite/ld-elf/provide-hidden-dynsec.nd: Likewise.
* testsuite/ld-elf/provide-hidden.exp: Replace
provide-hidden-dynsec.nd with provide-hidden-sec.nd and
provide-hidden-dyn.nd.  Replace provide-hidden-dynabs.nd with
provide-hidden-abs.nd and provide-hidden-dyn.nd.
* testsuite/ld-i386/pr23189.d: Expect no dynamic relocation.
* testsuite/ld-x86-64/pr23189.d: Likewise.

6 years agoMark section in a section group with SHF_GROUP
H.J. Lu [Tue, 22 May 2018 02:25:19 +0000 (19:25 -0700)]
Mark section in a section group with SHF_GROUP

All sections in a section group should be marked with SHF_GROUP.  But
some tools generate broken objects without SHF_GROUP.  This patch fixes
them up for objcopy and strip.

PR binutils/23199
* elf.c (setup_group): Mark section in a section group with
SHF_GROUP.

6 years agoMIPS/Linux: Disable n32 USR `ptrace' accesses to 64-bit registers
Maciej W. Rozycki [Tue, 22 May 2018 00:52:35 +0000 (01:52 +0100)]
MIPS/Linux: Disable n32 USR `ptrace' accesses to 64-bit registers

On the MIPS target DSP ASE registers can only be accessed with the
PTRACE_PEEKUSR and PTRACE_POKEUSR `ptrace' requests.  With the n32 ABI
these requests only pass 32-bit data quantities, which are narrower than
the width of DSP accumulator registers, which are 64-bit.

Generic code is prepared to transfer registers wider than the `ptrace'
data type by offsetting into the USR address space, by the data width
transferred.  That however does not work with the MIPS target, because
of how the API has been defined, where USR register addresses are
actually indices rather than offsets.  Consequently given address `a'
using `a + 4' accesses the fourth next register rather than the upper
half of the original register.

With native debugging this causes clobbered register contents, as well
as access failures as locations beyond the available USR space are
addressed:

(gdb) info registers
                  zero               at               v0               v1
 R0   0000000000000000 0000000000000001 0000000000000001 0000000000000000
                    a0               a1               a2               a3
 R4   0000000010019158 0000000000000000 0000000000000011 0000000010019160
                    a4               a5               a6               a7
 R8   0000000010019160 fffffffffff00000 fffffffffffffff8 0000000000000000
                    t0               t1               t2               t3
 R12  0000000010019150 0000000000000001 0000000000000001 000000000000000f
                    s0               s1               s2               s3
 R16  0000000077ee6f20 0000000010007bb0 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  000000000052e668 000000000052f008 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000001 0000000010019010 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  0000000010020280 000000007fff4c10 000000007fff4c10 0000000010004f48
                status               lo               hi         badvaddr
      0000000000109cf3 0000000000943efe 000000000000000e 000000001001900c
                 cause               pc
      0000000000800024 0000000010004f48
                  fcsr              fir              hi1              lo1
              0e800000         00f30000 0000000004040404 0101010105050505
                   hi2              lo2              hi3              lo3
      0202020255aa33cc Couldn't read register  (#75): Input/output error.
(gdb)

With `gdbserver' this makes debugging impossible due to a fatal failure:

(gdb) target remote :2346
Remote debugging using :2346
Reading symbols from .../sysroot/mips-r2-hard/lib32/ld.so.1...done.
0x77fc3d50 in __start () from .../sysroot/mips-r2-hard/lib32/ld.so.1
(gdb) continue
Continuing.
warning: Remote failure reply: E01
Remote communication error.  Target disconnected.: Connection reset by peer.
(gdb)

Correct the problem by marking any register in the MIPS backend whose
width exceeds the width of the `ptrace' data type unavailable for the
purpose of PTRACE_PEEKUSR and PTRACE_POKEUSR requests:

(gdb) info registers
                  zero               at               v0               v1
 R0   0000000000000000 0000000000000001 0000000000000001 0000000000000000
                    a0               a1               a2               a3
 R4   0000000010019158 0000000000000000 0000000000000011 0000000010019160
                    a4               a5               a6               a7
 R8   0000000010019160 fffffffffff00000 fffffffffffffff8 0000000000000000
                    t0               t1               t2               t3
 R12  0000000010019150 0000000000000001 0000000000000001 000000000000000f
                    s0               s1               s2               s3
 R16  0000000077ee6f20 0000000010007bb0 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  000000000052e5c8 000000000052f008 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000001 0000000010019010 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  0000000010020280 000000007fff4be0 000000007fff4be0 0000000010004f48
                status               lo               hi         badvaddr
      0000000000109cf3 0000000000943efe 000000000000000e 000000001001900c
                 cause               pc
      0000000000800024 0000000010004f48
                  fcsr              fir              hi1              lo1
              0e800000         00f30000    <unavailable>    <unavailable>
                   hi2              lo2              hi3              lo3
         <unavailable>    <unavailable>    <unavailable>    <unavailable>
                dspctl          restart
              55aa33cc 0000000000000000
(gdb)

as there is no way to access full contents of these registers with the
limited API available anyway.

This obviously does not affect general-purpose registers (which use the
PTRACE_GETREGS and PTRACE_SETREGS requests for access) or floating-point
general registers (which use PTRACE_GETFPREGS and PTRACE_SETFPREGS).
And $dspctl, being 32-bit, remains accessible too, which is important
for BPOSGE32 branch decoding in single-stepping.

For DSP accumulator access with the n32 ABI a new `ptrace' API is required
on the kernel side.

gdb/
* mips-linux-nat.c (mips64_linux_register_addr): Return -1 if
the width of the requested register exceeds the width of the
`ptrace' data type.

gdb/gdbserver/
* linux-mips-low.c (mips_cannot_fetch_register): Return 1 if the
width of the requested register exceeds the width of the
`ptrace' data type.
(mips_cannot_store_register): Likewise.

6 years agoAutomatic date update in version.in
GDB Administrator [Tue, 22 May 2018 00:00:37 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoMIPS/gdbserver: Fix issues with $zero register reads
Maciej W. Rozycki [Mon, 21 May 2018 23:55:08 +0000 (00:55 +0100)]
MIPS/gdbserver: Fix issues with $zero register reads

Consistently supply hardwired $zero as a zeroed register, correcting
issues with the PTRACE_GETREGS path that currently copies the value of
$restart into $zero as illustrated by this program:

$ cat read.c

int
main (void)
{
  char buf[1024];
  ssize_t size;

  size = read (0, buf, sizeof (buf));

  return size;
}
$

and this corresponding debug session:

(gdb) break main
Breakpoint 1 at 0x120000970: file read.c, line 9.
(gdb) target remote :2346
Remote debugging using :2346
Reading symbols from .../sysroot/mips-r2-hard/lib64/ld.so.1...done.
0x000000fff7fca5a0 in __start ()
   from .../sysroot/mips-r2-hard/lib64/ld.so.1
(gdb) continue
Continuing.

Breakpoint 1, main () at read.c:9
9   size = read (0, buf, sizeof (buf));
(gdb) info registers
                  zero               at               v0               v1
 R0   0000000000000000 0000000000000001 000000fff7ffe710 0000000000000000
                    a0               a1               a2               a3
 R4   0000000000000001 000000ffffffeb88 000000ffffffeb98 0000000000000000
                    a4               a5               a6               a7
 R8   000000fff7fc8800 000000fff7fc38f0 000000ffffffeb80 2f2f2f2f2f2f2f2f
                    t0               t1               t2               t3
 R12  0000000000000437 0000000000000002 000000fff7ffd000 0000000120000a00
                    s0               s1               s2               s3
 R16  000000fff7fc7068 0000000120000b90 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  0000000000521d88 0000000000522608 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000000 0000000120000970 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  000000fff7fc8800 000000ffffffea50 0000000000000000 000000fff7e4088c
                status               lo               hi         badvaddr
      0000000000109cf3 0000000000005ea5 0000000000000211 000000fff7eadf00
                 cause               pc
      0000000000800024 0000000120000970
                  fcsr              fir          restart
              00000000         00f30000 0000000000000000
(gdb) continue
Continuing.
^C

Program received signal SIGINT, Interrupt.
0x000000fff7f084ac in __GI___libc_read (fd=0, buf=0xffffffe640, nbytes=1024)
    at ../sysdeps/unix/sysv/linux/read.c:27
27   return SYSCALL_CANCEL (read, fd, buf, nbytes);
(gdb) info registers
                  zero               at               v0               v1
 R0   0000000000001388 0000000000000001 0000000000000200 000000fff7ffe710
                    a0               a1               a2               a3
 R4   0000000000000000 000000ffffffe640 0000000000000400 0000000000000001
                    a4               a5               a6               a7
 R8   000000fff7fc8800 000000fff7fc38f0 000000ffffffeb80 2f2f2f2f2f2f2f2f
                    t0               t1               t2               t3
 R12  00000000000005e3 0000000000000002 000000fff7ffd000 000000012000099c
                    s0               s1               s2               s3
 R16  000000fff7fc7068 0000000120000b90 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  0000000000521d88 0000000000522608 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000000 000000fff7f2da20 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  000000fff7fc8800 000000ffffffe600 0000000000000000 000000012000099c
                status               lo               hi         badvaddr
      0000000000109cf3 00000000000001e6 00000000000000be 000000fff7f08470
                 cause               pc
      0000000000800020 000000fff7f084ac
                  fcsr              fir          restart
              00000000         00f30000 0000000000001388
(gdb)

and with the PTRACE_PEEKUSR path that does not supply this register at
all, causing issues analogous to ones addressed for the native MIPS
backend with commit 4e6ff0e1b86f ("MIPS/Linux/native: Supply $zero for
the !PTRACE_GETREGS case"):

(gdb) info registers
                  zero               at               v0               v1
 R0      <unavailable> 0000000000000001 0000000000000001 0000000000000000
                    a0               a1               a2               a3
 R4   00000001200212b0 0000000000000000 0000000000000021 000000012001a260
                    a4               a5               a6               a7
 R8   000000012001a260 0000000000000004 800000010cab1680 fffffffffffffff8
                    t0               t1               t2               t3
 R12  0000000000000000 000000fff7edab68 0000000000000001 0000000000000000
                    s0               s1               s2               s3
 R16  000000fff7ee2068 0000000120008b80 0000000000000000 0000000000000000
                    s4               s5               s6               s7
 R20  000000000052e5c8 000000000052f008 0000000000000000 0000000000000000
                    t8               t9               k0               k1
 R24  0000000000000000 00000001200027c0 0000000000000000 0000000000000000
                    gp               sp               s8               ra
 R28  00000001200212b0 000000ffffffc880 000000ffffffc880 0000000120005ee8
                status               lo               hi         badvaddr
         <unavailable> 0000000000943efe 000000000000000e 000000012001a008
                 cause               pc
      0000000000800024 0000000120005ee8
                  fcsr              fir          restart
              0e800000         00f30000 0000000000000000
(gdb)

and (under certain circumstances):

(gdb) next
Register 0 is not available
(gdb)

The problem with PTRACE_GETREGS happens because `mips_store_gregset'
supplies the contents of register slot #0, occupied by $restart, to
$zero.  The problem with PTRACE_PEEKUSR happens because for $zero
`mips_cannot_fetch_register' returns one, and no alternative way to
supply that register has been defined.

Correct `mips_store_gregset' then for the PTRACE_GETREGS case and add
`mips_fetch_register' for the PTRACE_PEEKUSR case.

gdb/gdbserver/
* linux-mips-low.c (mips_fetch_register): New function.  Update
preceding comment.
(mips_store_gregset): Supply 0 rather than $restart for $zero.
(the_low_target): Wire `mips_fetch_register'.

6 years agoRemove fake operand handling for extended mnemonics.
Peter Bergner [Mon, 21 May 2018 22:31:07 +0000 (17:31 -0500)]
Remove fake operand handling for extended mnemonics.

opcodes/
* ppc-opc.c (insert_bat, extract_bat, insert_bba, extract_bba,
insert_rbs, extract_rbs, insert_xb6s, extract_xb6s): Delete functions.
(insert_bab, extract_bab, insert_btab, extract_btab,
insert_rsb, extract_rsb, insert_xab6, extract_xab6): New functions.
(BAT, BBA VBA RBS XB6S): Delete macros.
(BTAB, BAB, VAB, RAB, RSB, XAB6): New macros.
(BB, BD, RBX, XC6): Update for new macros.
(powerpc_opcodes) <evmr, evnot, vmr, vnot, crnot, crclr, crset,
crmove, not, not., mr, mr., xxspltd, xxswapd, xvmovsp, xvmovdp,
e_crnot, e_crclr, e_crset, e_crmove>: Likewise.
* ppc-dis.c (print_insn_powerpc): Delete handling of fake operands.

include/
* opcode/ppc.h (PPC_OPERAND_FAKE): Delete macro.

gas/
* config/tc-ppc.c (md_assemble): Delete handling of fake operands.
* testsuite/gas/ppc/common.s (crmove, cror, or., or, nor., nor): Add
test of extended mnemonics.
* testsuite/gas/ppc/common.d: Likewise.  Don't match instruction offset.
* testsuite/gas/ppc/spe.s (evor, evnor): Add test of extended mnemonics.
* testsuite/gas/ppc/spe.d: Likewise.  Don't match instruction offset.

6 years agoRemove output_command_const
Tom Tromey [Mon, 21 May 2018 19:28:16 +0000 (13:28 -0600)]
Remove output_command_const

I happened to notice that output_command_const still exists, but is
not needed any more -- commands are always const-correct now.  This
patch removes this leftover.

2018-05-21  Tom Tromey  <tom@tromey.com>

* printcmd.c (output_command): Remove.
(output_command_const): Rename to output_command.
* valprint.h (output_command): Rename from output_command_const.
* tracepoint.c (trace_dump_actions): Call output_command.

6 years agoChange ada_catchpoint::excep_string to be a std::string
Tom Tromey [Fri, 18 May 2018 21:58:50 +0000 (15:58 -0600)]
Change ada_catchpoint::excep_string to be a std::string

This changes ada_catchpoint::excep_string to be a std::string and then
fixes up all t he users.

This found a memory leak in catch_ada_exception_command_split, where
"cond" was copied but never freed.

I changed the type of the "cond_string" argument to
catch_ada_exception_command_split to follow the rule that out
parameters should be pointers and not references.

This patch enables the removal of some cleanups and also the function
ada_get_next_arg.

ChangeLog
2018-05-21  Tom Tromey  <tom@tromey.com>

* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
(mi_cmd_catch_exception, mi_cmd_catch_handlers): Update.
* ada-lang.h (create_ada_exception_catchpoint): Update.
* ada-lang.c (struct ada_catchpoint) <excep_string>: Now a
std::string.
(create_excep_cond_exprs, ~ada_catchpoint)
(should_stop_exception, print_one_exception)
(print_mention_exception, print_recreate_exception): Update.
(ada_get_next_arg): Remove.
(catch_ada_exception_command_split): Use std::string.  Change type
of "excep_string", "cond_string".
(catch_ada_exception_command): Update.
(create_ada_exception_catchpoint): Change type of excep_string.
(ada_exception_sal): Remove excep_string parameter.
(~ada_catchpoint): Remove.

6 years agoRemove cleanup from ada_collect_symbol_completion_matches
Tom Tromey [Fri, 18 May 2018 21:42:27 +0000 (15:42 -0600)]
Remove cleanup from ada_collect_symbol_completion_matches

ada_collect_symbol_completion_matches installs a null_cleanup but not
any other cleanups.  This patch removes it.

ChangeLog
2018-05-21  Tom Tromey  <tom@tromey.com>

* ada-lang.c (ada_collect_symbol_completion_matches): Remove
cleanup.

6 years agoRemove cleanup from ada-lang.c
Tom Tromey [Fri, 18 May 2018 21:41:33 +0000 (15:41 -0600)]
Remove cleanup from ada-lang.c

This removes a cleanup from ada-lang.c by having
ada_exception_message_1 return a unique_xmalloc_ptr.

ChangeLog
2018-05-21  Tom Tromey  <tom@tromey.com>

* ada-lang.c (ada_exception_message_1, ada_exception_message):
Return unique_xmalloc_ptr.
(print_it_exception): Update.

6 years agoRemove a cleanup from trace_dump_actions
Tom Tromey [Fri, 18 May 2018 20:23:27 +0000 (14:23 -0600)]
Remove a cleanup from trace_dump_actions

This changes trace_dump_actions to use std::string, removing a
cleanup.

Tested by the buildbot.

ChangeLog
2018-05-21  Tom Tromey  <tom@tromey.com>

* tracepoint.c (trace_dump_actions): Use std::string.

6 years agoUse std::string in reread_symbols
Tom Tromey [Fri, 18 May 2018 20:30:25 +0000 (14:30 -0600)]
Use std::string in reread_symbols

This removes a cleanup from reread_symbols by using std::string.  This
fixes a memory leak, because this cleanup is ordinarily discarded, not
run.

Tested by the buildbot.

ChangeLog
2018-05-21  Tom Tromey  <tom@tromey.com>

* symfile.c (reread_symbols): Use std::string for original_name.

6 years agoUse std::unique_ptr in dwarf2_read_debug_names
Tom Tromey [Fri, 18 May 2018 20:07:57 +0000 (14:07 -0600)]
Use std::unique_ptr in dwarf2_read_debug_names

This changes dwarf2_read_debug_names to use std::unique_ptr from the
outset.  This simplifies the code that installs the resulting map into
dwarf2_per_objfile.

Tested by the buildbot.

ChangeLog
2018-05-21  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (dwarf2_read_debug_names): Use std::unique_ptr.
(mapped_index_base): Use DISABLE_COPY_AND_ASSIGN.  Default
constructor.

6 years agoFix copy-pasto, allocate objfile_per_bfd_storage with obstack_new
Simon Marchi [Mon, 21 May 2018 03:18:29 +0000 (23:18 -0400)]
Fix copy-pasto, allocate objfile_per_bfd_storage with obstack_new

I realized after pushing that I made a copy-pasto, I had:

  # define HAVE_IS_TRIVIALLY_COPYABLE 1

instead of

  # define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1

with the consequence that IsMallocable was always std::true_type (and
was therefore not enforcing anything).  Fixing that mistake triggered a
build failure:

/home/simark/src/binutils-gdb/gdb/objfiles.c:150:12:   required from here
/home/simark/src/binutils-gdb/gdb/common/poison.h:228:3: error: static assertion failed: Trying to use XOBNEW with a non-POD data type.

I am not sure why I did not see this when I originally wrote the patch
(but I saw and fixed other failures).  In any case, I swapped XOBNEW
with obstack_new to get rid of it.

Regtested on the buildbot.

gdb/ChangeLog:

* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Rename the wrong
instance to...
(HAVE_IS_TRIVIALLY_CONSTRUCTIBLE): ... this.
* objfiles.c (get_objfile_bfd_data): Allocate
objfile_per_bfd_storage with obstack_new when allocating on
obstack.

6 years agoUse XOBNEW/XOBNEWVEC/OBSTACK_ZALLOC when possible
Simon Marchi [Mon, 21 May 2018 01:07:03 +0000 (21:07 -0400)]
Use XOBNEW/XOBNEWVEC/OBSTACK_ZALLOC when possible

Since XOBNEW/XOBNEWVEC/OBSTACK_ZALLOC are now poisoned to prevent using
them with non-trivially-constructible objects, it is worth using them
over plain obstack_alloc.  This patch changes the locations I could find
where we can do that change easily.

gdb/ChangeLog:

* ada-lang.c (cache_symbol): Use XOBNEW and/or XOBNEWVEC and/or
OBSTACK_ZALLOC.
* dwarf2-frame.c (dwarf2_build_frame_info): Likewise.
* hppa-tdep.c (hppa_init_objfile_priv_data): Likewise.
* mdebugread.c (mdebug_build_psymtabs): Likewise.
(add_pending): Likewise.
(parse_symbol): Likewise.
(parse_partial_symbols): Likewise.
(psymtab_to_symtab_1): Likewise.
(new_psymtab): Likewise.
(elfmdebug_build_psymtabs): Likewise.
* minsyms.c (terminate_minimal_symbol_table): Likewise.
* objfiles.c (get_objfile_bfd_data): Likewise.
(objfile_register_static_link): Likewise.
* psymtab.c (allocate_psymtab): Likewise.
* stabsread.c (read_member_functions): Likewise.
* xcoffread.c (xcoff_end_psymtab): Likewise.

6 years agoIntroduce obstack_new, poison other "typed" obstack functions
Simon Marchi [Mon, 21 May 2018 01:06:03 +0000 (21:06 -0400)]
Introduce obstack_new, poison other "typed" obstack functions

Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:

  foo *f = obstack_alloc (obstack, sizeof (foo));
  f = new (f) foo;

It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap.  This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:

  foo *f = obstack_new<foo> (obstack);

Right now there's only one usage (in tdesc_data_init).

To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:

  - OBSTACK_ZALLOC/OBSTACK_CALLOC
  - XOBNEW/XOBNEW
  - GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC

Unfortunately, there's no way to catch wrong usages of obstack_alloc.

By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC.  The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD.  Because it inherits from struct symbol, template_symbol is
not a POD.  This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0.  We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5.  So here I considered
two alternatives:

1. Relax that criterion to use std::is_trivially_constructible and add a
   bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
   are allocated and initialized

I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused.  When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.

gdb/ChangeLog:

* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
compiler supports std::is_trivially_constructible.
* common/poison.h: Include obstack.h.
(IsMallocable): Define to is_trivially_constructible if the
compiler supports it, define to true_type otherwise.
(xobnew): New.
(XOBNEW): Redefine.
(xobnewvec): New.
(XOBNEWVEC): Redefine.
* gdb_obstack.h (obstack_zalloc): New.
(OBSTACK_ZALLOC): Redefine.
(obstack_calloc): New.
(OBSTACK_CALLOC): Redefine.
(obstack_new): New.
* gdbarch.sh: Include gdb_obstack in gdbarch.h.
(gdbarch_obstack): New declaration in gdbarch.h, definition in
gdbarch.c.
(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
obstack_calloc/obstack_zalloc.
(gdbarch_obstack_zalloc): Remove.
* target-descriptions.c (tdesc_data_init): Use obstack_new.

6 years agoAutomatic date update in version.in
GDB Administrator [Mon, 21 May 2018 00:00:50 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agoAutomatic date update in version.in
GDB Administrator [Sun, 20 May 2018 00:01:18 +0000 (00:01 +0000)]
Automatic date update in version.in

6 years agoRemove useless variable int i in backtrace_command_1
Philippe Waroquiers [Sat, 19 May 2018 06:54:44 +0000 (08:54 +0200)]
Remove useless variable int i in backtrace_command_1

value of int i was not used in the loop or after the loop.
Pushed as obvious.

6 years agoFix reference in comment: SRC_AND_LOC instead of LOC_AND_SRC
Philippe Waroquiers [Sat, 19 May 2018 06:38:57 +0000 (08:38 +0200)]
Fix reference in comment: SRC_AND_LOC instead of LOC_AND_SRC

Pushed as obvious

6 years agoAutomatic date update in version.in
GDB Administrator [Sat, 19 May 2018 00:00:39 +0000 (00:00 +0000)]
Automatic date update in version.in

6 years agox86: Don't set eh->local_ref to 1 for versioned symbol
H.J. Lu [Fri, 18 May 2018 21:23:41 +0000 (14:23 -0700)]
x86: Don't set eh->local_ref to 1 for versioned symbol

bfd_hide_sym_by_version can't be used to check if a versioned symbol is
hidden.  It has to be synced with _bfd_elf_link_assign_sym_version to
get the correct answer.

bfd/

PR ld/23194
* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
set eh->local_ref to 1 if a symbol is versioned and there is a
version script.

ld/

PR ld/23194
* testsuite/ld-i386/i386.exp: Run pr23194.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr23194.d: New file.
* testsuite/ld-i386/pr23194.map: Likewise.
* testsuite/ld-i386/pr23194.s: Likewise.
* testsuite/ld-x86-64/pr23194.d: Likewise.
* testsuite/ld-x86-64/pr23194.map: Likewise.
* testsuite/ld-x86-64/pr23194.s: Likewise.

6 years agold: Run pr23189 for all targets
H.J. Lu [Fri, 18 May 2018 21:13:26 +0000 (14:13 -0700)]
ld: Run pr23189 for all targets

Since the pr23189 test isn't Linux specific, run it for all targets.

* testsuite/ld-i386/i386.exp: Run pr23189 for all targets.
* testsuite/ld-x86-64/x86-64.exp: Likewise.

6 years agoAllocate dwz_file with new
Tom Tromey [Wed, 16 May 2018 20:33:15 +0000 (14:33 -0600)]
Allocate dwz_file with new

This adds a constructor to struct dwz_file and arranges for it to be
allocated with "new" and wrapped in a unique_ptr.  This cuts down on
the amount of manual memory management that must be done.

Regression tested by the buildbot.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (struct dwz_file): Add constructor, initializers.
<dwz_bfd>: Now a gdb_bfd_ref_ptr.
(~dwarf2_per_objfile): Update
(dwarf2_get_dwz_file): Use new.
* dwarf2read.h (struct dwarf2_per_objfile) <dwz_file>: Now a
unique_ptr.

6 years agoRISC-V: Add RV32E support.
Jim Wilson [Fri, 18 May 2018 21:03:18 +0000 (14:03 -0700)]
RISC-V: Add RV32E support.

Kito Cheng  <kito.cheng@gmail.com>
Monk Chiang  <sh.chiang04@gmail.com>

bfd/
* elfnn-riscv.c (_bfd_riscv_elf_merge_private_bfd_data): Handle
EF_RISCV_RVE.

binutils/
* readelf.c (get_machine_flags): Handle EF_RISCV_RVE.

gas/
* config/tc-riscv.c (rve_abi): New.
(riscv_set_options): Add rve field.  Initialize it.
(riscv_set_rve) New function.
(riscv_set_arch): Support 'e' ISA subset.
(reg_lookup_internal): If rve, check register is available.
(riscv_set_abi): New parameter rve.
(md_parse_option): Pass new argument to riscv_set_abi.
(riscv_after_parse_args): Call riscv_set_rve.  If rve_abi, set
EF_RISCV_RVE.
* doc/c-riscv.texi (-mabi): Document new ilp32e argument.

include/
* elf/riscv.h (EF_RISCV_RVE): New define.

6 years agoAllocate dwp_file with new
Tom Tromey [Thu, 17 May 2018 06:04:53 +0000 (00:04 -0600)]
Allocate dwp_file with new

This adds a constructor and initializer to dwp_file and changes it to
be allocated with "new".  This removes a bit of manual refcount
management.

Tested by the buildbot.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

* dwarf2read.h (struct dwarf2_per_objfile) <dwp_file>: Now a
unique_ptr.
* dwarf2read.c (struct dwp_file): Add constructor and
initializers.
(open_and_init_dwp_file): Return a unique_ptr.
(dwarf2_per_objfile, create_dwp_hash_table)
(create_dwo_unit_in_dwp_v1, create_dwo_unit_in_dwp_v2)
(lookup_dwo_unit_in_dwp): Update.
(open_and_init_dwp_file, get_dwp_file): Update.

6 years agoUse new to allocate mapped_index
Tom Tromey [Thu, 17 May 2018 22:43:53 +0000 (16:43 -0600)]
Use new to allocate mapped_index

This changes struct mapped_index to be allocated with new.  This
simplifies the creation a bit (see dwarf2_read_index) and also removes
a somewhat ugly explicit destructor call from ~dwarf2_per_objfile.

Tested by the buildbot.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

* dwarf2read.c (dwarf2_per_objfile): Update.
(struct mapped_index): Add initializers.
(dwarf2_read_index): Use new.
(dw2_symtab_iter_init): Update.
* dwarf2read.h (struct dwarf2_per_objfile) <index_table>: Now a
unique_ptr.

6 years agoRISC-V: Fix ld-elf/pr22269* testcases.
Jim Wilson [Fri, 18 May 2018 20:05:21 +0000 (13:05 -0700)]
RISC-V: Fix ld-elf/pr22269* testcases.

bfd/
* elfnn-riscv.c (allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(riscv_elf_relocate_section): Don't generate dynamic relocation if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(riscv_elf_finish_dynamic_symbol): Likewise.

6 years agoRemove mapped_index::total_size
Simon Marchi [Fri, 18 May 2018 20:02:44 +0000 (16:02 -0400)]
Remove mapped_index::total_size

It is unused.

gdb/ChangeLog:

* dwarf2read.c (mapped_index) <total_size>: Remove.

6 years agoformat_pieces-selftests.c: Silence ARI warnings
Simon Marchi [Fri, 18 May 2018 19:47:56 +0000 (15:47 -0400)]
format_pieces-selftests.c: Silence ARI warnings

Silence this:

unittests/format_pieces-selftests.c:51: warning: code: Do not use printf("%ll"), instead use printf("%s",phex()) to dump a `long long' value
unittests/format_pieces-selftests.c:56: warning: code: Do not use printf("%ll"), instead use printf("%s",phex()) to dump a `long long' value

gdb/ChangeLog:

* unittests/format_pieces-selftests.c (test_format_specifier):
Add ARI comments.

6 years agoShow padding in ptype/o output
Tom Tromey [Sat, 12 May 2018 23:04:50 +0000 (17:04 -0600)]
Show padding in ptype/o output

I was recently using ptype/o to look at the layout of some objects in
gdb.  I noticed that trailing padding was not shown -- but I wanted to
be able to look at that, too.

This patch changes ptype/o to also print trailing holes.

Tested on x86-64 Fedora 26.

gdb/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

* c-typeprint.c (maybe_print_hole): New function.
(c_print_type_struct_field_offset): Update.
(c_type_print_base_struct_union): Call maybe_print_hole.

gdb/testsuite/ChangeLog
2018-05-18  Tom Tromey  <tom@tromey.com>

* gdb.base/ptype-offsets.exp: Update.

6 years agoAdd support for the Freescale s12z processor.
John Darrington [Fri, 18 May 2018 14:26:18 +0000 (15:26 +0100)]
Add support for the Freescale s12z processor.

bfd * Makefile.am: Add s12z files.
* Makefile.in: Regenerate.
* archures.c: Add bfd_s12z_arch.
* bfd-in.h: Add exports of bfd_putb24 and bfd_putl24.
* bfd-in2.h: Regenerate.
* config.bfd: Add s12z target.
* configure.ac: Add s12z target.
* configure: Regenerate.
* cpu-s12z.c: New file.
* elf32-s12z.c: New file.
* libbfd.c (bfd_putb24): New function.
(bfd_putl24): New function.
* libbfd.h: Regenerate.
* reloc.c: Add s12z relocations.
(bfd_get_reloc_size): Handle size 5 relocs.
* targets.c: Add s12z_elf32_vec.

opcodes * Makefile.am: Add support for s12z architecture.
* configure.ac: Likewise.
* disassemble.c: Likewise.
* disassemble.h: Likewise.
* Makefile.in: Regenerate.
* configure: Regenerate.
* s12z-dis.c: New file.
* s12z.h: New file.

include * elf/s12z.h: New header.

ld * Makefile.am: Add support for s12z architecture.
* configure.tgt: Likewise.
* Makefile.in: Regenerate.
* emulparams/m9s12zelf.sh: New file.
* scripttempl/elfm9s12z.sc: New file.
* testsuite/ld-discard/static.d: Expect to fail for the s12z
target.
* testsuite/ld-elf/endsym.d: Likewise.
* testsuite/ld-elf/merge.d: Likewise.
* testsuite/ld-elf/pr14926.d: Skip for the s12z target.
* testsuite/ld-elf/sec64k.exp: Likewise.
* testsuite/ld-s12z: New directory.
* testsuite/ld-s12z/opr-linking.d: New file.
* testsuite/ld-s12z/opr-linking.s: New file.
* testsuite/ld-s12z/relative-linking.d: New file.
* testsuite/ld-s12z/relative-linking.s: New file.
* testsuite/ld-s12z/z12s.exp: New file.

gas * Makefile.am: Add support for s12z target.
* Makefile.in: Regenerate.
* NEWS: Mention the new support.
* config/tc-s12z.c: New file.
* config/tc-s12z.h: New file.
* configure.tgt: Add  s12z support.
* doc/Makefile.am: Likewise.
* doc/Makefile.in: Regenerate.
* doc/all.texi: Add s12z documentation.
* doc/as.textinfo: Likewise.
* doc/c-s12z.texi: New file.
* testsuite/gas/s12z: New directory.
* testsuite/gas/s12z/abs.d: New file.
* testsuite/gas/s12z/abs.s: New file.
* testsuite/gas/s12z/adc-imm.d: New file.
* testsuite/gas/s12z/adc-imm.s: New file.
* testsuite/gas/s12z/adc-opr.d: New file.
* testsuite/gas/s12z/adc-opr.s: New file.
* testsuite/gas/s12z/add-imm.d: New file.
* testsuite/gas/s12z/add-imm.s: New file.
* testsuite/gas/s12z/add-opr.d: New file.
* testsuite/gas/s12z/add-opr.s: New file.
* testsuite/gas/s12z/and-imm.d: New file.
* testsuite/gas/s12z/and-imm.s: New file.
* testsuite/gas/s12z/and-opr.d: New file.
* testsuite/gas/s12z/and-opr.s: New file.
* testsuite/gas/s12z/and-or-cc.d: New file.
* testsuite/gas/s12z/and-or-cc.s: New file.
* testsuite/gas/s12z/bfext-special.d: New file.
* testsuite/gas/s12z/bfext-special.s: New file.
* testsuite/gas/s12z/bfext.d: New file.
* testsuite/gas/s12z/bfext.s: New file.
* testsuite/gas/s12z/bit-manip.d: New file.
* testsuite/gas/s12z/bit-manip.s: New file.
* testsuite/gas/s12z/bit.d: New file.
* testsuite/gas/s12z/bit.s: New file.
* testsuite/gas/s12z/bra-expression-defined.d: New file.
* testsuite/gas/s12z/bra-expression-defined.s: New file.
* testsuite/gas/s12z/bra-expression-undef.d: New file.
* testsuite/gas/s12z/bra-expression-undef.s: New file.
* testsuite/gas/s12z/bra.d: New file.
* testsuite/gas/s12z/bra.s: New file.
* testsuite/gas/s12z/brclr-symbols.d: New file.
* testsuite/gas/s12z/brclr-symbols.s: New file.
* testsuite/gas/s12z/brset-clr-opr-imm-rel.d: New file.
* testsuite/gas/s12z/brset-clr-opr-imm-rel.s: New file.
* testsuite/gas/s12z/brset-clr-opr-reg-rel.d: New file.
* testsuite/gas/s12z/brset-clr-opr-reg-rel.s: New file.
* testsuite/gas/s12z/brset-clr-reg-imm-rel.d: New file.
* testsuite/gas/s12z/brset-clr-reg-imm-rel.s: New file.
* testsuite/gas/s12z/brset-clr-reg-reg-rel.d: New file.
* testsuite/gas/s12z/brset-clr-reg-reg-rel.s: New file.
* testsuite/gas/s12z/clb.d: New file.
* testsuite/gas/s12z/clb.s: New file.
* testsuite/gas/s12z/clr-opr.d: New file.
* testsuite/gas/s12z/clr-opr.s: New file.
* testsuite/gas/s12z/clr.d: New file.
* testsuite/gas/s12z/clr.s: New file.
* testsuite/gas/s12z/cmp-imm.d: New file.
* testsuite/gas/s12z/cmp-imm.s: New file.
* testsuite/gas/s12z/cmp-opr-inc.d: New file.
* testsuite/gas/s12z/cmp-opr-inc.s: New file.
* testsuite/gas/s12z/cmp-opr-rdirect.d: New file.
* testsuite/gas/s12z/cmp-opr-rdirect.s: New file.
* testsuite/gas/s12z/cmp-opr-reg.d: New file.
* testsuite/gas/s12z/cmp-opr-reg.s: New file.
* testsuite/gas/s12z/cmp-opr-rindirect.d: New file.
* testsuite/gas/s12z/cmp-opr-rindirect.s: New file.
* testsuite/gas/s12z/cmp-opr-sxe4.d: New file.
* testsuite/gas/s12z/cmp-opr-sxe4.s: New file.
* testsuite/gas/s12z/cmp-opr-xys.d: New file.
* testsuite/gas/s12z/cmp-opr-xys.s: New file.
* testsuite/gas/s12z/cmp-s-imm.d: New file.
* testsuite/gas/s12z/cmp-s-imm.s: New file.
* testsuite/gas/s12z/cmp-s-opr.d: New file.
* testsuite/gas/s12z/cmp-s-opr.s: New file.
* testsuite/gas/s12z/cmp-xy.d: New file.
* testsuite/gas/s12z/cmp-xy.s: New file.
* testsuite/gas/s12z/com-opr.d: New file.
* testsuite/gas/s12z/com-opr.s: New file.
* testsuite/gas/s12z/complex-shifts.d: New file.
* testsuite/gas/s12z/complex-shifts.s: New file.
* testsuite/gas/s12z/db-tb-cc-opr.d: New file.
* testsuite/gas/s12z/db-tb-cc-opr.s: New file.
* testsuite/gas/s12z/db-tb-cc-reg.d: New file.
* testsuite/gas/s12z/db-tb-cc-reg.s: New file.
* testsuite/gas/s12z/dbCC.d: New file.
* testsuite/gas/s12z/dbCC.s: New file.
* testsuite/gas/s12z/dec-opr.d: New file.
* testsuite/gas/s12z/dec-opr.s: New file.
* testsuite/gas/s12z/dec.d: New file.
* testsuite/gas/s12z/dec.s: New file.
* testsuite/gas/s12z/div.d: New file.
* testsuite/gas/s12z/div.s: New file.
* testsuite/gas/s12z/eor.d: New file.
* testsuite/gas/s12z/eor.s: New file.
* testsuite/gas/s12z/exg.d: New file.
* testsuite/gas/s12z/exg.s: New file.
* testsuite/gas/s12z/ext24-ld-xy.d: New file.
* testsuite/gas/s12z/ext24-ld-xy.s: New file.
* testsuite/gas/s12z/inc-opr.d: New file.
* testsuite/gas/s12z/inc-opr.s: New file.
* testsuite/gas/s12z/inc.d: New file.
* testsuite/gas/s12z/inc.s: New file.
* testsuite/gas/s12z/inh.d: New file.
* testsuite/gas/s12z/inh.s: New file.
* testsuite/gas/s12z/jmp.d: New file.
* testsuite/gas/s12z/jmp.s: New file.
* testsuite/gas/s12z/jsr.d: New file.
* testsuite/gas/s12z/jsr.s: New file.
* testsuite/gas/s12z/ld-imm-page2.d: New file.
* testsuite/gas/s12z/ld-imm-page2.s: New file.
* testsuite/gas/s12z/ld-imm.d: New file.
* testsuite/gas/s12z/ld-imm.s: New file.
* testsuite/gas/s12z/ld-immu18.d: New file.
* testsuite/gas/s12z/ld-immu18.s: New file.
* testsuite/gas/s12z/ld-large-direct.d: New file.
* testsuite/gas/s12z/ld-large-direct.s: New file.
* testsuite/gas/s12z/ld-opr.d: New file.
* testsuite/gas/s12z/ld-opr.s: New file.
* testsuite/gas/s12z/ld-s-opr.d: New file.
* testsuite/gas/s12z/ld-s-opr.s: New file.
* testsuite/gas/s12z/ld-small-direct.d: New file.
* testsuite/gas/s12z/ld-small-direct.s: New file.
* testsuite/gas/s12z/lea-immu18.d: New file.
* testsuite/gas/s12z/lea-immu18.s: New file.
* testsuite/gas/s12z/lea.d: New file.
* testsuite/gas/s12z/lea.s: New file.
* testsuite/gas/s12z/mac.d: New file.
* testsuite/gas/s12z/mac.s: New file.
* testsuite/gas/s12z/min-max.d: New file.
* testsuite/gas/s12z/min-max.s: New file.
* testsuite/gas/s12z/mod.d: New file.
* testsuite/gas/s12z/mod.s: New file.
* testsuite/gas/s12z/mov.d: New file.
* testsuite/gas/s12z/mov.s: New file.
* testsuite/gas/s12z/mul-imm.d: New file.
* testsuite/gas/s12z/mul-imm.s: New file.
* testsuite/gas/s12z/mul-opr-opr.d: New file.
* testsuite/gas/s12z/mul-opr-opr.s: New file.
* testsuite/gas/s12z/mul-opr.d: New file.
* testsuite/gas/s12z/mul-opr.s: New file.
* testsuite/gas/s12z/mul-reg.d: New file.
* testsuite/gas/s12z/mul-reg.s: New file.
* testsuite/gas/s12z/mul.d: New file.
* testsuite/gas/s12z/mul.s: New file.
* testsuite/gas/s12z/neg-opr.d: New file.
* testsuite/gas/s12z/neg-opr.s: New file.
* testsuite/gas/s12z/not-so-simple-shifts.d: New file.
* testsuite/gas/s12z/not-so-simple-shifts.s: New file.
* testsuite/gas/s12z/opr-18u.d: New file.
* testsuite/gas/s12z/opr-18u.s: New file.
* testsuite/gas/s12z/opr-expr.d: New file.
* testsuite/gas/s12z/opr-expr.s: New file.
* testsuite/gas/s12z/opr-ext-18.d: New file.
* testsuite/gas/s12z/opr-ext-18.s: New file.
* testsuite/gas/s12z/opr-idx-24-reg.d: New file.
* testsuite/gas/s12z/opr-idx-24-reg.s: New file.
* testsuite/gas/s12z/opr-idx3-reg.d: New file.
* testsuite/gas/s12z/opr-idx3-reg.s: New file.
* testsuite/gas/s12z/opr-idx3-xysp-24.d: New file.
* testsuite/gas/s12z/opr-idx3-xysp-24.s: New file.
* testsuite/gas/s12z/opr-indirect-expr.d: New file.
* testsuite/gas/s12z/opr-indirect-expr.s: New file.
* testsuite/gas/s12z/opr-symbol.d: New file.
* testsuite/gas/s12z/opr-symbol.s: New file.
* testsuite/gas/s12z/or-imm.d: New file.
* testsuite/gas/s12z/or-imm.s: New file.
* testsuite/gas/s12z/or-opr.d: New file.
* testsuite/gas/s12z/or-opr.s: New file.
* testsuite/gas/s12z/p2-mul.d: New file.
* testsuite/gas/s12z/p2-mul.s: New file.
* testsuite/gas/s12z/page2-inh.d: New file.
* testsuite/gas/s12z/page2-inh.s: New file.
* testsuite/gas/s12z/psh-pul.d: New file.
* testsuite/gas/s12z/psh-pul.s: New file.
* testsuite/gas/s12z/qmul.d: New file.
* testsuite/gas/s12z/qmul.s: New file.
* testsuite/gas/s12z/rotate.d: New file.
* testsuite/gas/s12z/rotate.s: New file.
* testsuite/gas/s12z/s12z.exp: New file.
* testsuite/gas/s12z/sat.d: New file.
* testsuite/gas/s12z/sat.s: New file.
* testsuite/gas/s12z/sbc-imm.d: New file.
* testsuite/gas/s12z/sbc-imm.s: New file.
* testsuite/gas/s12z/sbc-opr.d: New file.
* testsuite/gas/s12z/sbc-opr.s: New file.
* testsuite/gas/s12z/shift.d: New file.
* testsuite/gas/s12z/shift.s: New file.
* testsuite/gas/s12z/simple-shift.d: New file.
* testsuite/gas/s12z/simple-shift.s: New file.
* testsuite/gas/s12z/single-ops.d: New file.
* testsuite/gas/s12z/single-ops.s: New file.
* testsuite/gas/s12z/specd6.d: New file.
* testsuite/gas/s12z/specd6.s: New file.
* testsuite/gas/s12z/st-large-direct.d: New file.
* testsuite/gas/s12z/st-large-direct.s: New file.
* testsuite/gas/s12z/st-opr.d: New file.
* testsuite/gas/s12z/st-opr.s: New file.
* testsuite/gas/s12z/st-s-opr.d: New file.
* testsuite/gas/s12z/st-s-opr.s: New file.
* testsuite/gas/s12z/st-small-direct.d: New file.
* testsuite/gas/s12z/st-small-direct.s: New file.
* testsuite/gas/s12z/st-xy.d: New file.
* testsuite/gas/s12z/st-xy.s: New file.
* testsuite/gas/s12z/sub-imm.d: New file.
* testsuite/gas/s12z/sub-imm.s: New file.
* testsuite/gas/s12z/sub-opr.d: New file.
* testsuite/gas/s12z/sub-opr.s: New file.
* testsuite/gas/s12z/tfr.d: New file.
* testsuite/gas/s12z/tfr.s: New file.
* testsuite/gas/s12z/trap.d: New file.
* testsuite/gas/s12z/trap.s: New file.

binutils* readelf.c: Add support for s12z architecture.
* testsuite/lib/binutils-common.exp (is_elf_format): Excluse s12z
targets.

6 years agox86: Don't set eh->local_ref to 1 for linker defined symbols
H.J. Lu [Fri, 18 May 2018 13:43:19 +0000 (06:43 -0700)]
x86: Don't set eh->local_ref to 1 for linker defined symbols

Since symbols created by HIDDEN and PROVIDE_HIDDEN assignments in
linker script may be marked as defined, but not hidden, we can't
set eh->local_ref to 1 in _bfd_x86_elf_link_symbol_references_local.

Also R_386_GOT32X should be handled as just like R_386_GOT32 when
relocating a section.  The input R_386_GOT32X relocations, which
can be relaxed, should have been converted to R_386_PC32, R_386_32
or R_386_GOTOFF.

bfd/

PR ld/23189
* elf32-i386.c (elf_i386_relocate_section): Handle R_386_GOT32X
like R_386_GOT32.
* elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
set eh->local_ref to 1 for linker defined symbols.

ld/

PR ld/23189
* testsuite/ld-i386/i386.exp: Run pr23189.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr23189.d: New file.
* testsuite/ld-i386/pr23189.s: Likewise.
* testsuite/ld-i386/pr23189.t: Likewise.
* testsuite/ld-x86-64/pr23189.d: Likewise.
* testsuite/ld-x86-64/pr23189.s: Likewise.
* testsuite/ld-x86-64/pr23189.t: Likewise.

6 years agoPR23199, Invalid SHT_GROUP entry leads to group confusion
Alan Modra [Fri, 18 May 2018 07:39:45 +0000 (17:09 +0930)]
PR23199, Invalid SHT_GROUP entry leads to group confusion

This patch prevents elf_next_in_group list pointer confusion when
SHT_GROUP sections specify other SHT_GROUP sections in their list of
group sections.

PR 23199
* elf.c (setup_group): Formatting.  Check that SHT_GROUP entries
don't point at other SHT_GROUP sections.  Set shdr corresponding
to invalid entry, to NULL rather than section 0.  Identify
SHT_GROUP section index when reporting an error.  Cope with NULL
shdr pointer.

6 years agoATTRIBUTE_HIDDEN for libbfd.h
Alan Modra [Fri, 18 May 2018 02:05:18 +0000 (11:35 +0930)]
ATTRIBUTE_HIDDEN for libbfd.h

* libbfd-in.h (ATTRIBUTE_HIDDEN): Define and use throughout.
* configure.ac (HAVE_HIDDEN): Check compiler support for hidden
visibility.
* libbfd.h: Regenerate.
* configure: Regenerate.
* config.in: Regenerate.

6 years agolibbfd.h and libcoff.h include guards
Alan Modra [Thu, 17 May 2018 23:00:50 +0000 (08:30 +0930)]
libbfd.h and libcoff.h include guards

* libbfd-in.h: Add include guard.
* libcoff-in.h: Likewise.
* doc/Makefile.am (libbfd.h, libcoff.h): Append another #endif.
* doc/Makefile.in: Regenerate.
* libbfd.h: Regenerate.
* libcoff.h: Regenerate.

6 years agoopcodes sources should not include libbfd.h
Alan Modra [Thu, 17 May 2018 23:01:13 +0000 (08:31 +0930)]
opcodes sources should not include libbfd.h

* nfp-dis.c: Don't #include libbfd.h.
(init_nfp3200_priv): Use bfd_get_section_contents.
(nit_nfp6000_mecsr_sec): Likewise.