binutils-gdb.git
7 years agoFix excessive memory allocation attempts and possible integer overfloaws when attempt...
Nick Clifton [Fri, 3 Nov 2017 11:55:21 +0000 (11:55 +0000)]
Fix excessive memory allocation attempts and possible integer overfloaws when attempting to read a COFF binary with a corrupt symbol count.

PR 22385
* coffgen.c (_bfd_coff_get_external_symbols): Check for an
overlarge raw syment count.
(coff_get_normalized_symtab): Likewise.

7 years agoSkip gdb.python/py-thrhandle.exp if python is not enabled.
Yao Qi [Fri, 3 Nov 2017 10:36:42 +0000 (10:36 +0000)]
Skip gdb.python/py-thrhandle.exp if python is not enabled.

gdb/testsuite:

2017-11-03  Yao Qi  <yao.qi@linaro.org>

* gdb.python/py-thrhandle.exp: Skip it if python is not
enabled.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 3 Nov 2017 00:00:26 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoaarch64: Remove AARCH64_FEATURE_F16 from AARCH64_ARCH_V8_2
Siddhesh Poyarekar [Thu, 2 Nov 2017 17:19:32 +0000 (22:49 +0530)]
aarch64: Remove AARCH64_FEATURE_F16 from AARCH64_ARCH_V8_2

The FP16 feature is optional in ARMv8.2, so it is wrong to add it to
the default AARCH64_ARCH_V8_2 feature flags.  This patch makes the
behaviour consistent with that of gcc, which also does not assume FP16
for ARMv8.2.

include/

* opcode/aarch64.h (AARCH64_ARCH_V8_2): Drop
AARCH64_FEATURE_F16.

7 years agoWork around integer overflows when readelf is checking for corrupt ELF notes when...
Mingi Cho [Thu, 2 Nov 2017 17:01:08 +0000 (17:01 +0000)]
Work around integer overflows when readelf is checking for corrupt ELF notes when run on a 32-bit host.

PR 22384
* readelf.c (print_gnu_property_note): Improve overflow checks so
that they will work on a 32-bit host.

7 years agoConstruct readonly regcache without address space
Yao Qi [Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)]
Construct readonly regcache without address space

The address space is useless to readonly regcache, so this patch removes
the parameter to construct readonly regcache.

address_space was added in regcache by 6c95b8d, but for read-write
regcache.  regcache::aspace is used for various breakpoint/watchpoint
checking, and these regcache are not read-only regcache.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* frame.c (do_frame_register_read): Remove aspace.
* jit.c (jit_frame_sniffer): Likwise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Likewise.
* regcache.c (regcache::regcache): Pass nullptr.
(regcache_print): Caller updated.
* regcache.h (regcache::regcache): Remove one constructor
parameter aspace.

7 years agoconst-fy regcache::m_readonly_p
Yao Qi [Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)]
const-fy regcache::m_readonly_p

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* regcache.h (regcache) <m_readonly_p>: Change it to const bool.

7 years agoconst-fy regcache::m_aspace
Yao Qi [Thu, 2 Nov 2017 15:15:42 +0000 (15:15 +0000)]
const-fy regcache::m_aspace

regcache::m_aspace is a const, never changed during the lifetime of
regcache object.  The address_space object is a const object too.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* breakpoint.c (insert_single_step_breakpoints): Update.
* frame.c (struct frame_info) <aspace>: Add const.
(frame_save_as_regcache): Add const.
(get_frame_address_space): Return const address_space *.
* frame.h (get_frame_address_space): Update declaration.
* infrun.c (struct step_over_info) <aspace>: Add const.
(set_step_over_info): Make aspace const.
(displaced_step_prepare_throw): Change variable const.
(resume): Likewise.
(proceed): Likewise.
(adjust_pc_after_break): Likewise.
(save_waitstatus): Likewise.
(handle_signal_stop): Likewise.
(keep_going_pass_signal): Likewise.
* jit.c (jit_frame_sniffer): Add const.
* mips-tdep.c (mips_single_step_through_delay): Likewise.
* ppc-linux-tdep.c (ppu2spu_sniffer): Likewise.
* record-full.c (record_full_wait_1): Likewise.
* regcache.c (regcache::regcache): Change parameter to const.
* regcache.h (regcache::regcache): Likewise.
(regcache::aspace): Return const address_space *.
(regcache) <m_aspace>: Add const.

7 years agos/get_regcache_aspace (regcache)/regcache->aspace ()/g
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
s/get_regcache_aspace (regcache)/regcache->aspace ()/g

and remove get_regcache_aspace.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* darwin-nat.c (cancel_breakpoint): Use regcache->aspace ().
* frame.c (create_sentinel_frame): Likewise.
* infrun.c (displaced_step_prepare_throw): Likewise.
(resume): Likewise.
(thread_still_needs_step_over_bp): Likewise.
(proceed): Likewise.
(do_target_wait): Likewise.
(adjust_pc_after_break): Likewise.
(handle_syscall_event): Likewise.
(save_waitstatus): Likewise.
(handle_inferior_event_1): Likewise.
(handle_signal_stop): Likewise.
(keep_going_pass_signal): Likewise.
* linux-nat.c (status_callback): Likewise.
(save_stop_reason): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* record-full.c (record_full_exec_insn): Likewise.
(record_full_wait_1): Likewise.
* regcache.c (get_regcache_aspace): Remove.
* regcache.h (get_regcache_aspace): Remove.

7 years agoRemove regcache_descr::nr_raw_registers
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
Remove regcache_descr::nr_raw_registers

struct regcache_descr has fields nr_raw_registers and gdbarch, and
nr_raw_registers can be got via gdbarch_num_regs (gdbarch), so it looks
nr_raw_registers is redundant.  This patch removes it and adds a protected
method num_raw_registers.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* regcache.c (struct regcache_descr) <nr_raw_registers>: Remove.
(init_regcache_descr): Use gdbarch_num_regs.
(regcache::regcache): Likewise.
(regcache::get_register_status): Likewise.
(regcache::assert_raw_regnum): Likewise.
(regcache::cooked_read): Likewise.
(regcache::cooked_read_value): Likewise.
(regcache::cooked_write): Likewise.
(regcache::dump): Likewise.
(regcache::num_raw_registers): New method.
* regcache.h (class regcache) <num_raw_registers>: New.

7 years agoNew method regcache::assert_regnum
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
New method regcache::assert_regnum

class regcache has some methods checking the range of register number,
this patch is to move it in a new method assert_regnum.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache::assert_regnum): New method.
(regcache::invalidate): Call assert_regnum.
(regcache::raw_update): Likewise.
(regcache::raw_write): Likewise.
(regcache::raw_read_part): Likewise.
(regcache::raw_write_part): Likewise.
(regcache::raw_supply): Likewise.
(regcache::raw_supply_integer): Likewise.
(regcache::raw_supply_zeroed): Likewise.
(regcache::raw_collect): Likewise.
(regcache::raw_collect_integer): Likewise.
* regcache.h (regcache::assert_regnum): Declare.

7 years agoRemove code wrapped by "#if 0"
Yao Qi [Thu, 2 Nov 2017 15:15:41 +0000 (15:15 +0000)]
Remove code wrapped by "#if 0"

These code wrapped by "#if 0" was added by af030b9a, which added the new
command to dump registers in 2002.  The email didn't mention this either
https://sourceware.org/ml/gdb-patches/2002-08/msg00227.html  It was there
for 15 years, and nobody needs it, so we can remove it.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache::dump): Remove code.

7 years agoRemove regcache_descr fields sizeof_raw_register_status and sizeof_cooked_register_status
Yao Qi [Thu, 2 Nov 2017 15:05:12 +0000 (15:05 +0000)]
Remove regcache_descr fields sizeof_raw_register_status and sizeof_cooked_register_status

struct regcache_descr has two fields sizeof_raw_register_status
and sizeof_cooked_register_status, but they equal to nr_cooked_registers
and nr_raw_registers respectively, so this patch removes them.

gdb:

2017-11-02  Yao Qi  <yao.qi@linaro.org>

* regcache.c (struct regcache_descr) <sizeof_raw_register_status>:
Remove.
<sizeof_cooked_register_status>: Remove.
(init_regcache_descr): Update.
(regcache::regcache): Use nr_cooked_registers and nr_raw_registers.
(regcache::save): Likewise.
(regcache::dump): Likewise.

7 years ago[ARM] Help wince objdump on coproc tests
Thomas Preud'homme [Thu, 2 Nov 2017 14:16:22 +0000 (14:16 +0000)]
[ARM] Help wince objdump on coproc tests

Object files other than ELF do not have mapping symbols to indicate the
type of data for objdump to work reliably. This is why the following
tests FAIL on arm-wince-pe targets:
ARMv6T2 Thumb CoProcessor Instructions (1)
ARMv6T2 Thumb CoProcessor Instructions (2)

This patch adds the force-thumb disassembler option to objdump for this
test to PASS on these targets as well.

2017-11-02  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-1.d: Add
--disassembler-options=force-thumb to objdump options.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-2.d: Likewise.

7 years agoFT32: support for FT32B processor - part 2/2
James Bowman [Thu, 2 Nov 2017 01:34:25 +0000 (18:34 -0700)]
FT32: support for FT32B processor - part 2/2

FT32B is a new FT32 family member.
This patch adds support for the compressed instructions to gdb and sim.

gdb/ChangeLog:
        * ft32-tdep.c (ft32_fetch_instruction): New function.
        (ft32_analyze_prologue): Use ft32_fetch_instruction().

sim/ChangeLog:
        * ft32/interp.c (step_once): Add ft32 shortcode decoder.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 2 Nov 2017 00:00:15 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoFT32B is a new FT32 family member. It has a code compression scheme, which requires...
James Bowman [Wed, 1 Nov 2017 15:33:24 +0000 (15:33 +0000)]
FT32B is a new FT32 family member. It has a code compression scheme, which requires the use of linker relaxations. The change is quite large, so submission is in several parts.

Part 2 adds a relaxation pass, which actually implements the code compression scheme.

bfd * archures.c: Add bfd_mach_ft32b.
* cpu-ft32.c: Add arch_info_struct.
* elf32-ft32.c: Add R_FT32_RELAX, SC0, SC1,
DIFF32. (ft32_elf_relocate_section): Add clauses
for R_FT32_SC0, SC1, DIFF32.  (ft32_reloc_shortable,
elf32_ft32_is_diff_reloc, elf32_ft32_adjust_diff_reloc_value,
elf32_ft32_adjust_reloc_if_spans_insn,
elf32_ft32_relax_delete_bytes, elf32_ft32_relax_is_branch_target,
ft32_elf_relax_section): New function.
* reloc.c: Add BFD_RELOC_FT32_RELAX, SC0, SC1, DIFF32.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.

gas * config/tc-ft32.c (md_assemble): add relaxation reloc
BFD_RELOC_FT32_RELAX.  (md_longopts): Add "norelax" and
"no-relax". (md_apply_fix): Add reloc BFD_RELOC_FT32_DIFF32.
(relaxable_section, ft32_validate_fix_sub, ft32_force_relocation,
ft32_allow_local_subtract): New function.
* config/tc-ft32.h: remove unused MD_PCREL_FROM_SECTION.
* testsuite/gas/ft32/insnsc.s: New test exercising all FT32B
shortcodes.

include * elf/ft32.h: Add R_FT32_RELAX, SC0, SC1, DIFF32.

7 years agoPrevent illegal memory accesses when attempting to read excessively large COFF line...
Nick Clifton [Wed, 1 Nov 2017 15:21:46 +0000 (15:21 +0000)]
Prevent illegal memory accesses when attempting to read excessively large COFF line number tables.

PR 22376
* coffcode.h (coff_slurp_line_table): Check for an excessively
large line number count.

7 years agoUpdate check for invalid values in pe_bfd_read_buildid function.
Nick Clifton [Wed, 1 Nov 2017 12:37:33 +0000 (12:37 +0000)]
Update check for invalid values in pe_bfd_read_buildid function.

PR 22373
* peicode.h (pe_bfd_read_buildid): Revise check for invalid size
and offset in light of further possible bogus values.

7 years agoFix an invalid free called when attempting to link a COFF object against an ELF archi...
Nick Clifton [Wed, 1 Nov 2017 11:35:42 +0000 (11:35 +0000)]
Fix an invalid free called when attempting to link a COFF object against an ELF archive with --no-keep-memory enabled.

PR 22369
* coffgen.c (_bfd_coff_free_symbols): Fail if called on a non-COFF
file.
* cofflink.c (coff_link_check_archive_element): Skip non-COFF
members of an archive.

7 years ago[ARM] Fix Coprocessor instructions availability
Thomas Preud'homme [Wed, 1 Nov 2017 09:49:13 +0000 (09:49 +0000)]
[ARM] Fix Coprocessor instructions availability

A few coprocessor instructions introduced in ARMv2 are currently
accepted by GAS when targeting ARMv1 due to a typo in the code. This
patch fixes the issue and introduce a more fine grained testing for
coprocessor instructions availability. Coprocessor instructions are
grouped as follows:

* ARM coprocessor instructions introduced in ARMv2
  Includes: ldc, stc, mcr, mrc, cdp, ldcl, stcl
  Guarded by: ARM_EXT_V2
  Tests: copro-arm_v2plus-arm_v*.d

* ARM coprocessor instructions introduced in ARMv5
  Includes: ldc2, ldc2l, stc2, stc2l, cdp2, mcr2, mrc2
  Guarded by: ARM_EXT_V5
  Tests: copro-arm_v5plus-arm_v*.d

* ARM coprocessor instructions introduced in ARMv5TE
  Includes: mcrr, mrrc
  Guarded by: ARM_EXT_V5E
  Tests: copro-arm_v5teplus-arm_v*.d

* ARM coprocessor instructions introduced in ARMv6
  Includes: mcrr2, mrrc2
  Guarded by: ARM_EXT_V6
  Tests: copro-arm_v6plus-arm_v*.d

* Thumb coprocessor instructions introduced in ARMv6T2
  Includes: ldc, ldcl, stc, stcl, mcr, mrc, mcrr, mrrc, cdp, ldc2,
  ldc2l, stc2, stc2l, cdp2, mcr2, mrc2, mcrr2, mrrc2
  Guarded by: ARM_EXT_V6T2
  Tests: copro-thumb_v6t2plus-thumb_v*.d

For each of these groups, at least 2 tests are performed:
* instructions are not available in earlier architecture
* instructions are available in architecture where they were introduced
More tests need to be performed when instructions in a group span
several assembly files.

Note that an instruction in the original coprocessor testcase is
changed to unified syntax to allow the testcase to be assembled for ARM
and Thumb state. Correct processing of legacy syntax is covered in other
testcases.

2017-11-01  Thomas Preud'homme  <thomas.preudhomme@arm.com>

gas/
* config/tc-arm.c (arm_ext_v2): Define to ARM_EXT_V2 feature bit.
* testsuite/gas/arm/copro.s: Split into ...
* testsuite/gas/arm/copro-arm_v2plus-thumb_v6t2plus.s: This while
changing it to unified syntax and ...
* testsuite/gas/arm/copro-arm_v5plus-thumb_v6t2plus.s: this and ...
* testsuite/gas/arm/copro-arm_v5teplus-thumb_v6t2plus.s: This and ...
* testsuite/gas/arm/copro-arm_v6plus-thumb_v6t2plus.s: This.
* testsuite/gas/arm/copro.d: Split into ...
* testsuite/gas/arm/copro-arm_v2plus-arm_v2.d: This but target ARMv2
and ...
* testsuite/gas/arm/copro-arm_v5plus-arm_v5.d: this but target ARMv5
and ...
* testsuite/gas/arm/copro-arm_v5teplus-arm_v5te.d: This but target
ARMv5TE and ...
* testsuite/gas/arm/copro-arm_v6plus-arm_v6.d: This but target ARMv6.
* testsuite/gas/arm/copro-arm_v2plus-arm_v1.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-1.d: New testcase.
* testsuite/gas/arm/copro-arm_v2plus-thumb_v6t2plus-unavail.l: Expected
errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-1.d: New testcase.
* testsuite/gas/arm/copro-arm_v5plus-arm_v4.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-2.d: New testcase.
* testsuite/gas/arm/copro-arm_v5plus-thumb_v6t2plus-unavail.l:
Expected errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-2.d: New testcase.
* testsuite/gas/arm/copro-arm_v5teplus-arm_v5.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-3.d: New testcase.
* testsuite/gas/arm/copro-arm_v5teplus-thumb_v6t2plus-unavail.l:
Expected errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-3.d: New testcase.
* testsuite/gas/arm/copro-arm_v6plus-arm_v5te.d: New testcase.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v4t-4.d: New testcase.
* testsuite/gas/arm/copro-arm_v6plus-thumb_v6t2plus-unavail.l:
Expected errors for the above two testcases.
* testsuite/gas/arm/copro-thumb_v6t2plus-thumb_v6t2-4.d: New testcase.

7 years agoPR22374, PowerPC unnecessary PLT entries
Alan Modra [Tue, 31 Oct 2017 11:43:21 +0000 (22:13 +1030)]
PR22374, PowerPC unnecessary PLT entries

We don't need a PLT entry when function pointer initialization in a
read/write section is the only reference to a given function symbol.
This patch prevents the unnecessary PLT entry, and ensures no dynamic
relocs are emitted when UNDEFWEAK_NO_DYNAMIC_RELOC says so.

bfd/
PR 22374
* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Don't create a plt
entry when just a dynamic reloc can serve.  Ensure no dynamic
relocations when UNDEFWEAK_NO_DYNAMIC_RELOC by setting non_got_ref.
Expand and move the non_got_ref comment.
* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
ld/
* testsuite/ld-powerpc/ambiguousv2.d: Remove FIXME.

7 years agoPR22374 testcase, function pointer references in .data
Alan Modra [Tue, 31 Oct 2017 00:43:30 +0000 (11:13 +1030)]
PR22374 testcase, function pointer references in .data

Function pointer references in .data ought to use a dynamic reloc.
There shouldn't be any need for a PLT entry and definitely no copy
reloc.

This test fails on quite a few targets, but isn't something that
anyone should worry about too much.  It's really just a missed
optimization.

PR 22374
* testsuite/ld-elf/pr22374a.s,
* testsuite/ld-elf/pr22374b.s,
* testsuite/ld-elf/pr22374-1.r,
* testsuite/ld-elf/pr22374-2.r: New test.
* testsuite/ld-elf/elf.exp: Run it.

7 years agoTidy elf.exp
Alan Modra [Tue, 31 Oct 2017 07:49:21 +0000 (18:19 +1030)]
Tidy elf.exp

* testsuite/ld-elf/elf.exp: Merge some conditionals, a better
name than "shared library for next test", and use xfail arg
of run_ld_link_tests in a few places.

7 years agoUse console uiout when executing breakpoint commands
Simon Marchi [Wed, 1 Nov 2017 01:30:24 +0000 (21:30 -0400)]
Use console uiout when executing breakpoint commands

As reported here

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

the output of certain commands, like backtrace, doesn't appear anywhere
when it is run as a breakpoint command and when using MI.

The reason is that the current_uiout is set to the mi_ui_out while these
commands run, whereas we want the output as CLI output.  Some commands
like "print" work, because they use printf_filtered (gdb_stdout, ...)
directly, bypassing the current ui_out.

The fix I did is to force setting the cli_uiout as the current_uiout
when calling execute_control_command.  I am not sure if this is the
right way to fix the problem, comments about the approach would be
appreciated.

I enhanced gdb.mi/mi-break.exp to test the backtrace command.

Regtested on the buildbot.

gdb/ChangeLog:

* cli/cli-script.c (execute_control_command): Rename to ...
(execute_control_command_1): ... this.
(execute_control_command): New function.

gdb/testsuite/ChangeLog:

* gdb.mi/mi-break.exp (test_breakpoint_commands): Test backtrace
as a breakpoint command.

7 years agoAutomatic date update in version.in
GDB Administrator [Wed, 1 Nov 2017 00:00:19 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agotracepoint: Remove unnecessary const_cast
Simon Marchi [Tue, 31 Oct 2017 18:29:25 +0000 (14:29 -0400)]
tracepoint: Remove unnecessary const_cast

We are passing a const char * to a const char * parameter, the
const_cast is not necessary.

gdb/ChangeLog:

* tracepoint.c (tfind_command): Remove const_cast.

7 years agoFix illegal memory access triggered when parsing a PE binary with a corrupt data...
Nick Clifton [Tue, 31 Oct 2017 14:29:40 +0000 (14:29 +0000)]
Fix illegal memory access triggered when parsing a PE binary with a corrupt data dictionary.

PR 22373
* peicode.h (pe_bfd_read_buildid): Check for invalid size and data
offset values.

7 years agoRemind users to use the --use-dynamic command line option to dump dynamic relocations.
Nick Clifton [Tue, 31 Oct 2017 13:48:03 +0000 (13:48 +0000)]
Remind users to use the --use-dynamic command line option to dump dynamic relocations.

* readelf.c (process_relocs): Tell users if no static relocs were
found, but if they had added --use-dynamic to the command line
then relocs would have been displayed.

7 years agogdb/Makefile.in: fix 'make tags' failure
Mike Gulick [Tue, 31 Oct 2017 00:11:52 +0000 (20:11 -0400)]
gdb/Makefile.in: fix 'make tags' failure

'make tags' fails with the following error:

  make[2]: Entering directory '/local-ssd/mgulick/gdb/git/binutils-gdb/gdb'
  make[2]: *** No rule to make target 'gdb.h', needed by 'TAGS'.  Stop.
  make[2]: Leaving directory '/local-ssd/mgulick/gdb/git/binutils-gdb/gdb'

The file gdb/gdb.h was removed in commit
65630365f7d073430e62b4fe65f34dcdc0a4b05e.

gdb/ChangeLog:

2017-10-30  Mike Gulick  <mgulick@mathworks.com>

* Makefile.in (HFILES_NO_SRCDIR): Remove reference to gdb.h.

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

7 years agoIntroduce in_inclusive_range, fix -Wtautological-compare warnings
Simon Marchi [Mon, 30 Oct 2017 18:27:30 +0000 (14:27 -0400)]
Introduce in_inclusive_range, fix -Wtautological-compare warnings

When compiling with clang or gcc 8, we see warnings like this:

/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:10013:13: error: comparison of 0 <= unsigned expression is always true [-Werror,-Wtautological-compare]
      if (0 <= insn_op1 && 3 >= insn_op1)
          ~ ^  ~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/arm-tdep.c:11722:20: error: comparison of unsigned expression >= 0 is always true [-Werror,-Wtautological-compare]
      else if (opB >= 0 && opB <= 2)
               ~~~ ^  ~

This is because an unsigned integer (opB in this case) will always be >=
0.  It is still useful to keep both bounds of the range in the
expression, even if one is at the edge of the data type range.  This
patch introduces a utility function in_inclusive_range that gets rid of
the warning while conveying that we are checking for a range.

Tested by rebuilding.

gdb/ChangeLog:

* common/common-utils.h (in_inclusive_range): New function.
* arm-tdep.c (arm_record_extension_space): Use
in_inclusive_range.
(thumb_record_ld_st_reg_offset): Use in_inclusive_range.
* cris-tdep.c (cris_spec_reg_applicable): Use
in_inclusive_range.

7 years agoremote.c, QCatchSyscalls: Build std::string instead of unique_xmalloc_ptr
Pedro Alves [Mon, 30 Oct 2017 11:41:34 +0000 (11:41 +0000)]
remote.c, QCatchSyscalls: Build std::string instead of unique_xmalloc_ptr

Simplify the code a little bit using std::string + string_appendf.

gdb/ChangeLog:
2017-10-30  Pedro Alves  <palves@redhat.com>
    Simon Marchi <simon.marchi@ericsson.com>

* remote.c (remote_set_syscall_catchpoint): Build a std::string
instead of a gdb::unique_xmalloc_ptr, using string_appendf.

7 years agoIntroduce string_appendf/string_vappendf
Pedro Alves [Mon, 30 Oct 2017 11:41:34 +0000 (11:41 +0000)]
Introduce string_appendf/string_vappendf

string_appendf is like string_printf, but instead of allocating a new
string, it appends to an existing string.  This allows reusing a
std::string's memory buffer across several calls, for example.

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

* common/common-utils.c (string_appendf, string_vappendf): New
functions.
* common/common-utils.h (string_appendf, string_vappendf): New
declarations.
* unittests/common-utils-selftests.c (string_appendf_func)
(test_appendf_func, string_vappendf_wrapper, string_appendf_tests)
(string_vappendf_tests): New functions.
(_initialize_common_utils_selftests): Register "string_appendf" and
"string_vappendf tests".

7 years agoMerge/shared string_printf and string_vprintf unit tests
Pedro Alves [Mon, 30 Oct 2017 11:41:34 +0000 (11:41 +0000)]
Merge/shared string_printf and string_vprintf unit tests

Merge the string_printf and string_vprintf tests, running them all
against both functions.

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

* unittests/common-utils-selftests.c (format_func): New typedef.
(string_printf_tests, string_vprintf_tests): Tests factored out
and merged to ...
(test_format_func): ... this new function.
(string_printf_tests, string_vprintf_tests): Reimplement on top of
test_format_func.

7 years agodarwin-nat: Remove gdb.h include
Simon Marchi [Mon, 30 Oct 2017 02:37:11 +0000 (22:37 -0400)]
darwin-nat: Remove gdb.h include

gdb.h has been removed in

  Eliminate catch_exceptions/catch_exceptions_with_msg
  65630365f7d073430e62b4fe65f34dcdc0a4b05e

Remove the include in darwin-nat.c.  Tested by rebuilding.

gdb/ChangeLog:

* darwin-nat.c: Remove include of gdb.h.

7 years agofrv-elf --gc-sections failures
Alan Modra [Mon, 30 Oct 2017 01:32:42 +0000 (12:02 +1030)]
frv-elf --gc-sections failures

git commit 81742b83e9 exposed an frv-elf bug, with the object id not
matching the hash table id.

* elf32-frv.c (ELF_TARGET_ID): Don't define for generic
elf target.

7 years agorelocs_compatible test for gc-sections
Alan Modra [Sun, 29 Oct 2017 23:50:29 +0000 (10:20 +1030)]
relocs_compatible test for gc-sections

I noticed when looking at pr22300 that before calling check_relocs we
have an elf_object_id test (added for pr11933) as well as the
relocs_compatible test.  I believe backend gc_mark_hook and
gc_sweep_hook ought to be protected similarly from being confused by
unexpected relocations (for example, both elf64-ppc.c and elf32-ppc.c
use _bfd_elf_relocs_compatible, so I think it would be possible for
the ppc64 gc_mark_hook to be presented with a ppc32 relocatable
object).

* elflink.c (elf_gc_sweep): Test elf_object_id in addition to
relocs_compatible.
(bfd_elf_gc_sections): Likewise.

7 years agoFix hppa-linux pr22269-1 fail
Alan Modra [Fri, 27 Oct 2017 04:34:25 +0000 (15:04 +1030)]
Fix hppa-linux pr22269-1 fail

Adds UNDEFWEAK_NO_DYNAMIC_RELOC in the rest of places needed in this
file, reduces dynamic relocations in a number of cases, and removes
some bogus code that was attempting to handle dynamic common symbols
specially.

PR 22269
* elf32-hppa.c (elf32_hppa_check_relocs): Move SEC_ALLOC test to
ensure non_got_ref is not set due to debug references.
(elf32_hppa_adjust_dynamic_symbol): Tidy plabel handling.  Use
SYMBOL_CALLS_LOCAL and UNDEFWEAK_NO_DYNAMIC_RELOC when determining
need for a plt entry.
(allocate_dynrelocs): Similarly for got entries.  Tidy code discarding
dynamic relocs when pic.  Remove bogus code attempting to handle
commons.
(elf32_hppa_relocate_section): Similarly.  Delete resolved_to_zero
and simplify.
(elf32_hppa_finish_dynamic_symbol): Use UNDEFWEAK_NO_DYNAMIC_RELOC
and SYMBOL_REFERENCES_LOCAL in GOT handling.

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

7 years agoxtensa-xtregs: Fix formatting issues
Simon Marchi [Sun, 29 Oct 2017 17:01:19 +0000 (13:01 -0400)]
xtensa-xtregs: Fix formatting issues

Fix a few formatting issues in that file.

gdb/ChangeLog:

* xtensa-xtregs.c: Fix formatting issues.

7 years agoxtensa-xtregs: Constify field
Simon Marchi [Sun, 29 Oct 2017 05:13:33 +0000 (01:13 -0400)]
xtensa-xtregs: Constify field

Fix:

In file included from /home/emaisin/src/binutils-gdb/gdb/xtensa-linux-nat.c:46:0:
/home/emaisin/src/binutils-gdb/gdb/xtensa-xtregs.c:37:1: error: ISO C++ forbids converting a string constant to 'char*' [-Werror=write-strings]
 };
 ^

gdb/ChangeLog:

* xtensa-xtregs.c (xtensa_regtable_t) <name>: Constify.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 29 Oct 2017 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoMake gdb.selected_thread().inferior return a new reference
Maksim Dzabraev [Sat, 28 Oct 2017 18:14:34 +0000 (01:14 +0700)]
Make gdb.selected_thread().inferior return a new reference

thpy_get_inferior function should return a new reference to the
existing inferior object, and therefore should increment its refcount.

Fixed bug looks like this.
If multiple time call gdb.selected_thread ().inferior, gdb throws exception:

(gdb) pi gdb.selected_thread().inferior
<gdb.Inferior object at 0x7f1952bea698>
(gdb) pi gdb.selected_thread().inferior
Python Exception <type 'exceptions.AttributeError'> 'NoneType' object
has no attribute 'inferior':
Error while executing Python code.
(gdb) info threads
  Id   Target Id         Frame
* 1    Thread 0x7f54f0474740 (LWP 584) "mc" 0x00007f54ef055c33 in

7 years agoPR22361 readelf buffer overflow on fuzzed archive header
Alan Modra [Sat, 28 Oct 2017 11:01:16 +0000 (21:31 +1030)]
PR22361 readelf buffer overflow on fuzzed archive header

PR 22361
* readelf.c (process_archive_index_and_symbols): Ensure ar_size
field is zero terminated for strtoul.
(setup_archive, get_archive_member_name): Likewise.

7 years agoPR22300, Abort in elf32_hppa_relocate_section building polyml
Alan Modra [Sat, 28 Oct 2017 03:40:55 +0000 (14:10 +1030)]
PR22300, Abort in elf32_hppa_relocate_section building polyml

polyml produces object files with the wrong OS/ABI for hppa-linux.
This, along with the fact that elf32-hppa.c is using the strictest
backend relocs_compatible, results in wrong merging of ELF symbols.

So, remove the relocs_compatible check in _bfd_elf_merge_symbol.
_bfd_elf_merge_symbol is only called nowadays from within blocks
protected by is_elf_hash_table, so "we are doing an ELF link" as the
removed comment says, is true.

Also relax relocs_compatible for hppa and powerpc.  relocs_compatible
is used for more than just merging symbols, as the name suggests.
This allows objects that are in fact reasonably compatible to be
linked.

PR 22300
* elflink.c (_bfd_elf_merge_symbol): Remove relocs_compatible check.
* elf32-hppa.c (elf_backend_relocs_compatible): Define.
* elf32-ppc.c (elf_backend_relocs_compatible): Define.
* elf64-ppc.c (elf_backend_relocs_compatible): Define.

7 years agoRemove find_inferior usage for thread_search
Simon Marchi [Sat, 28 Oct 2017 03:44:12 +0000 (23:44 -0400)]
Remove find_inferior usage for thread_search

Replace it with for_each_thread.  While at it, we can inline the
callback code.  One little change is that I am using the
prev_general_thread variable instead of current_gen_ptid, since they
should have the same value.

gdb/gdbserver/ChangeLog:

* target.c (struct thread_search): Remove.
(thread_search_callback): Remove.
(prepare_to_access_memory): Use for_each_thread instead of
find_inferior.  Inline code from thread_search_callback.

7 years agoRemove usage of find_inferior in resume
Simon Marchi [Sat, 28 Oct 2017 03:43:11 +0000 (23:43 -0400)]
Remove usage of find_inferior in resume

Change find_inferior with find_thread.  Since we can now pass arguments
directly instead of through a void pointer, we don't need the
visit_actioned_threads_data structure anymore.

gdb/gdbserver/ChangeLog:

* server.c (struct visit_actioned_threads_data): Remove.
(visit_actioned_threads): Change prototype to take arguments
directly.
(resume): Use find_thread instead of find_inferior.

7 years agoRemove usages of find_inferior in handle_status
Simon Marchi [Sat, 28 Oct 2017 03:41:49 +0000 (23:41 -0400)]
Remove usages of find_inferior in handle_status

Replace one with find_thread, the other with for_each_thread.

gdb/gdbserver/ChangeLog:

* server.c (queue_stop_reply_callback): Change prototype, return
void.
(find_status_pending_thread_callback): Remove.
(handle_status): Replace find_inferior with find_thread and
for_each_thread.

7 years agocommon-utils-selftests.c: Add ATTRIBUTE_PRINTF
Simon Marchi [Sat, 28 Oct 2017 03:36:19 +0000 (23:36 -0400)]
common-utils-selftests.c: Add ATTRIBUTE_PRINTF

Fix this, when building with clang:

/home/emaisin/src/binutils-gdb/gdb/unittests/common-utils-selftests.c:50:40: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
  std::string result = string_vprintf (fmt, vp);
                                       ^~~
gdb/ChangeLog:

* unittests/common-utils-selftests.c (format): Add
ATTRIBUTE_PRINTF.

7 years agoC++ify xml-syscall.c
Simon Marchi [Sat, 28 Oct 2017 02:23:33 +0000 (22:23 -0400)]
C++ify xml-syscall.c

This patch C++ifies the structures in xml-syscall.c, by using
std::vector instead of VEC, and std::string instead of char*.
Using a unique_ptr in syscall_parse_xml allows to remove a cleanup.

Something that seems strange with the existing code, if you look at
syscalls_info_free_syscalls_desc and
syscalls_info_free_syscall_group_desc, they free the structure elements
(the strings and vectors), but they don't free the syscall_desc and
syscall_group_desc structure themselves.  I don't see anything freeing
those currently.  Any idea why?  According to the comment above
syscalls_info_free_syscall_group_desc, it kinda looks like it's on
purpose.  With this patch, those structures are deleted when the vector
that contains them gets deleted.

The only time I'm aware a syscalls_info structure gets deleted is in the
case the data directory changes during runtime, in init_syscalls_info.
If tried that use case (including under valgrind):

 (gdb) catch syscall
 (gdb) set data-directory another-data-directory
 (gdb) catch syscall

I confirmed that the syscalls_info structure got deleted and recreated,
and everything seemed fine.

Regtested on the buildbot.

gdb/ChangeLog:

* xml-syscall.c (struct syscall_desc): Add constructor.
<name>: Change type to std::string.
(syscall_desc_up): New typedef.
(syscall_desc_p): Remove typeder.
(DEF_VEC_P(syscall_desc_p)): Remove.
(struct syscall_group_desc): Add constructor.
<name>: Change type to std::string.
<syscalls>: Change type to std::vector.
(syscall_group_desc_up): New typedef.
(syscall_group_desc_p): Remove typedef.
(DEF_VEC_P(syscall_group_desc_p)): Remove.
(struct syscalls_info) <syscalls>: Change type to std::vector of
unique_ptr.
<groups>: Likewise.
<my_gdb_datadir>: Change type to std::string.
(syscalls_info_up): New typedef.
(allocate_syscalls_info): Remove.
(syscalls_info_free_syscalls_desc): Remove.
(syscalls_info_free_syscall_group_desc): Remove.
(free_syscalls_info): Remove.
(make_cleanup_free_syscalls_info): Remove.
(syscall_group_create_syscall_group_desc): Adjust.
(syscall_group_add_syscall): Adjust.
(syscall_create_syscall_desc): Adjust.
(syscall_parse_xml): Adjust, use unique_ptr instead of cleanup.
(init_syscalls_info): Adjust.
(syscall_group_get_group_by_name): Adjust.
(xml_get_syscall_number): Adjust.
(xml_get_syscall_name): Adjust.
(xml_list_of_syscalls): Adjust.
(xml_list_syscalls_by_group): Adjust.
(xml_list_of_groups): Adjust.

7 years agoGet rid of VEC(probe_p)
Simon Marchi [Sat, 28 Oct 2017 02:05:42 +0000 (22:05 -0400)]
Get rid of VEC(probe_p)

Replace the remaining usages of VEC(probe_p) with std::vector.

Regtested on the buildbot.

gdb/ChangeLog:

* probe.h: Don't include gdb_vecs.h.
(DEF_VEC_P (probe_p)): Remove.
(find_probes_in_objfile): Return an std::vector.
* probe.c (find_probes_in_objfile): Likewise.
* breakpoint.c (breakpoint_objfile_data)
<longjmp_probes>: Change type to std::vector.
<exception_probes>: Likewise.
(free_breakpoint_probes): Don't manually free vectors.
(create_longjmp_master_breakpoint): Adjust.
(create_exception_master_breakpoint): Adjust.
* solib-svr4.c (svr4_create_probe_breakpoints): Change
parameter type, adjust.
(svr4_create_solib_event_breakpoints): Adjust.

7 years agoAllocate breakpoint_objfile_data with new
Simon Marchi [Sat, 28 Oct 2017 02:01:21 +0000 (22:01 -0400)]
Allocate breakpoint_objfile_data with new

Allocate with new and free with delete.  This allows using an
std::vector in the following patch.

I renamed free_breakpoint_probes to free_breakpoint_objfile_data,
because it now doesn't only free the probes vector, but also the
breakpoint_objfile_data structure itself.

gdb/ChangeLog:

* breakpoint.c (breakpoint_objfile_data): Initialize fields.
(get_breakpoint_objfile_data): Allocate breakpoint_objfile_data
with new.
(free_breakpoint_probes): Rename to ...
(free_breakpoint_objfile_data): ... this, and call delete on
bp_objfile_data..

7 years agoGet rid of VEC(loaded_script_ptr)
Simon Marchi [Sat, 28 Oct 2017 01:55:42 +0000 (21:55 -0400)]
Get rid of VEC(loaded_script_ptr)

Direct replacement with std::vector.  This allows removing a cleanup as
well.

Regtested on the buildbot.

gdb/ChangeLog:

* auto-load.c: Don't include gdb_vecs.h, include algorithm.
(loaded_script_ptr): Remove typedef.
(DEF_VEC_P (loaded_script_ptr)): Remove.
(struct collect_matching_scripts_data): Add constructor.
<scripts_p>: Change type to (pointer to) std::vector.
(collect_matching_scripts_data): Adjust.
(sort_scripts_by_name): Make suitable for std::sort.
(print_scripts): Don't sort vector, adjust to std::vector.
(auto_load_info_scripts): Sort vectors, adjust to std::vector.

7 years agoGet rid of VEC(filename_language)
Simon Marchi [Sat, 28 Oct 2017 01:47:30 +0000 (21:47 -0400)]
Get rid of VEC(filename_language)

This patch removes VEC(filename_language), replacing its usage with
std::vector.  filename_language::ext is changed to an std::string at the
same time.

Regtested on the buildbot.

gdb/ChangeLog:

* symfile.c (filename_language): Make struct, not typedef.  Add
constructor.
<ext>: Change type to std::string.
(DEF_VEC_O (filename_language)): Remove.
(filename_language_table): Change type to std::vector.
(add_filename_language): Adjust.
(set_ext_lang_command): Adjust.
(info_ext_lang_command): Adjust.
(deduce_language_from_filename): Adjust.
(class scoped_restore_filename_language_table): Remove.
(test_filename_language): Use scoped_restore.
(test_set_ext_lang_command): Use scoped_restore, adjust to
std::vector change.

7 years agoAdd tests for filename_language
Simon Marchi [Sat, 28 Oct 2017 01:46:49 +0000 (21:46 -0400)]
Add tests for filename_language

The next patch touches the filename_language area, but I noticed there
is no test exercising that.  This patch adds some selftests for
add_filename_language, deduce_language_from_filename and
set_ext_lang_command.  Because these tests add entries to the global
filename_language_table vector, it is not possible to run them
successfully multiple times in a same GDB instance.  They can
potentially interfere with each other for the same reason.  I therefore
added the scoped_restore_filename_language_table class that is used to
make sure tests leave that global vector in the same state they found it
(it is replaced in the following patch by a simple scoped_restore).

gdb/ChangeLog:

* symfile.c: Include selftest.h.
(class scoped_restore_filename_language_table): New.
(test_filename_language): New test.
(test_set_ext_lang_command): New test.
(_initialize_symfile): Register tests.

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

7 years agoUse SaL symbol name when reporting breakpoint locations
Keith Seitz [Fri, 27 Oct 2017 17:57:23 +0000 (10:57 -0700)]
Use SaL symbol name when reporting breakpoint locations

Currently, "info break" can show some (perhaps) unexpected results when
setting a breakpoint on an inlined function:

(gdb) list
1 #include <stdio.h>
2
3 static inline void foo()
4 {
5         printf("Hello world\n");
6 }
7
8 int main()
9 {
10         foo();
11         return 0;
12 }
13
(gdb) b foo
Breakpoint 1 at 0x400434: file foo.c, line 5.
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000400434 in main at foo.c:5

GDB reported that we understood what "foo" was, but we then report that the
breakpoint is actually set in main. While that is literally true, we can
do a little better.

This is accomplished by copying the symbol for which the breakpoint was set
into the bp_location.  From there, print_breakpoint_location can use this
information to print out symbol information (if available) instead of calling
find_pc_sect_function.

With the patch installed,

(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000400434 in foo at foo.c:5

gdb/ChangeLog:

* breakpoint.c (print_breakpoint_location): Use the symbol saved
in the bp_location, falling back to find_pc_sect_function when
needed.
(add_location_to_breakpoint): Save sal->symbol.
* breakpoint.h (struct bp_location) <symbol>: New field.
* symtab.c (find_function_start_sal): Save the symbol into the SaL.
* symtab.h (struct symtab_and_line) <symbol>: New field.

gdb/testsuite/ChangeLog:

* gdb.opt/inline-break.exp (break_info_1): New procedure.
Test "info break" for every inlined function breakpoint.

7 years ago[AArch64] Mark LR clobbered by BL in inline asm
Yao Qi [Fri, 27 Oct 2017 14:29:24 +0000 (15:29 +0100)]
[AArch64] Mark LR clobbered by BL in inline asm

LR is a caller-save register, so, if inline asm does BL (which touches
LR), we should mark LR clobbered.

gdb/testsuite:

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

* gdb.arch/insn-reloc.c (can_relocate_bl): Mark "x30" clobbered.

7 years agodwarf: Read register number as unsigned in DW_CFA_def_cfa*
Simon Marchi [Fri, 27 Oct 2017 13:01:36 +0000 (09:01 -0400)]
dwarf: Read register number as unsigned in DW_CFA_def_cfa*

When displaying the .debug_frame section, the register numbers in the
DW_CFA_def_cfa* statements are read as signed numbers.  I have come
across a target that has register 121, encoded as 0x79 in unsigned LEB128.
Interpreting this as signed results in -7, which makes readelf display
"r-7".

The DWARF5 standard (6.4.2.2) states that the register numbers should be
treated as unsigned LEB128.

Simply replacing READ_SLEB with READ_ULEB resulted in warnings like
these:

/home/emaisin/src/binutils-gdb/binutils/dwarf.c: In function â€˜display_debug_frames’:
/home/emaisin/src/binutils-gdb/binutils/dwarf.c:355:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if ((var) != _val)     \
                 ^
/home/emaisin/src/binutils-gdb/binutils/dwarf.c:7866:8: note: in expansion of macro â€˜READ_ULEB’
        READ_ULEB (fc->cfa_reg);
        ^
... so I also changed Frame_Chunk::cfa_reg to an unsigned int.

binutils/ChangeLog:

* dwarf.c (struct Frame_Chunk) <cfa_reg>: Change type to
unsigned int.
(display_debug_frames): Read CFA reg as an unsigned number.

7 years agoAdd PR mention to previous commit
Simon Marchi [Fri, 27 Oct 2017 12:57:10 +0000 (08:57 -0400)]
Add PR mention to previous commit

7 years agoFix broken recursion detection when printing static members
Patrick Frants [Fri, 27 Oct 2017 02:26:08 +0000 (22:26 -0400)]
Fix broken recursion detection when printing static members

Recursion detection for static members was broken.  The implementation
uses a growing (and shrinking) obstack object to simulate a stack of
addresses (CORE_ADDR).  Pushing addresses is implemented by calling
obstack_grow(), while popping is implemented by calling obstack_free().
The latter is problematic because obstack_free() expects a pointer to
the base of an object.  When popping elements of the stack however,
obstack_free() was called with the new top, which potentially is not the
same as the base of the stack.  This is unintended use and the effect is
that obstack->next_free and obstack->object_base members are assigned
the value of the new top, which equals an empty stack.  Summary: popping
elements would always result in an empty stack, which breaks the
recursion detection.

The fix shrinks the stack using obstack_blank_fast() with a negative
value as described at the bottom of this page:
https://gcc.gnu.org/onlinedocs/libiberty/Extra-Fast-Growing.html "You
can use obstack_blank_fast with a “negative” size argument to make the
current object smaller.  Just don’t try to shrink it beyond zero
length—there’s no telling what will happen if you do that. Earlier
versions of obstacks allowed you to use obstack_blank to shrink objects.
This will no longer work."

The reproducer is added to gdb.cp/classes.exp, which fails without this
patch.

gdb/ChangeLog:

* cp-valprint.c (cp_print_value_fields): Use obstack_blank_fast
to rewind obstack.

gdb/testsuite/ChangeLog:

* gdb.cp/classes.exp (test_static_members): Test printing
Outer::instance.
* gdb.cp/classes.c (struct Inner, struct Outer): New.
(Inner::instance, Outer::instance): New.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 27 Oct 2017 00:00:28 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoGarbage collect remote.c:remote_async_terminal_ours_p
Pedro Alves [Thu, 26 Oct 2017 18:53:03 +0000 (19:53 +0100)]
Garbage collect remote.c:remote_async_terminal_ours_p

remote.c:remote_async_terminal_ours_p stopped being useful after
048094accce2 ("target remote: Don't rely on immediate_quit (introduce
quit handlers)") and commit 41fd2b0f5d95 ("Make input_fd be per UI"),
which turned remote's terminal_inferior/ours methods into nops.

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

* remote.c (remote_async_terminal_ours_p): Delete.
(remote_open_1, remote_terminal_inferior, remote_terminal_ours):
Remove references to 'remote_async_terminal_ours_p'.

7 years agox86: Check invalid XMM register in AVX512 gathers
H.J. Lu [Thu, 26 Oct 2017 18:16:41 +0000 (11:16 -0700)]
x86: Check invalid XMM register in AVX512 gathers

Extend invalid register check for AVX512 gathers to XMM register.

PR gas/22352
* config/tc-i386.c (check_VecOperands): Also check XMM register
for invalid register in AVX512 gathers.
* testsuite/gas/i386/vgather-check.s: Add tests for AVX512
gathers with XMM register.
* testsuite/gas/i386/x86-64-vgather-check.s: Likewise.
* testsuite/gas/i386/vgather-check-error.l: Updated.
* testsuite/gas/i386/vgather-check-none.d: Likewise.
* testsuite/gas/i386/vgather-check-warn.d: Likewise.
* testsuite/gas/i386/vgather-check-warn.e: Likewise.
* testsuite/gas/i386/vgather-check.d: Likewise.
* testsuite/gas/i386/x86-64-vgather-check-error.l: Likewise.
* testsuite/gas/i386/x86-64-vgather-check-none.d: Likewise.
* testsuite/gas/i386/x86-64-vgather-check-warn.d: Likewise.
* testsuite/gas/i386/x86-64-vgather-check-warn.e: Likewise.
* testsuite/gas/i386/x86-64-vgather-check.d: Likewise.

7 years ago[PR21703]Adjust pr21703 tests on various targets.
Renlin Li [Thu, 26 Oct 2017 14:40:45 +0000 (15:40 +0100)]
[PR21703]Adjust pr21703 tests on various targets.

xfail tests for certain targets.
Check shared library support for shared test.
Relax pr21703-r.sd and pr21703-shared.sd with additional "#..." pattern lines.

ld/

* testsuite/ld-elf/elf.exp: xfail pr21703 tests on specific targets.
Only run shared lib test for targets which support it.
* testsuite/ld-elf/pr21703-r.sd: Adjust the expected output.
* testsuite/ld-elf/pr21703-shared.sd: Likewise.

7 years agoAs Alan predicted at https://sourceware.org/ml/binutils/2017-10/msg00137.html the...
James Greenhalgh [Thu, 26 Oct 2017 10:30:40 +0000 (11:30 +0100)]
As Alan predicted at https://sourceware.org/ml/binutils/2017-10/msg00137.html the values in some Arm tests need updating after recent changes. These looked a bit spooky at first, but they are just a difference in the order we emit veneers and far jumps, so are not so scary after all.

Checked with an arm-none-eabi tester and an arm-none-linux-gnueabi tester with no issues.

* testsuite/ld-arm/cortex-a8-far.d: Update expected disassembly.
* testsuite/ld-arm/farcall-group-size2: Likewise.
* testsuite/ld-arm/farcall-group.d: Likewise.

7 years agoRemove regular_breakpoint_inserted_here_p declaration
Yao Qi [Thu, 26 Oct 2017 08:53:38 +0000 (09:53 +0100)]
Remove regular_breakpoint_inserted_here_p declaration

There is no regular_breakpoint_inserted_here_p definition at all, so
this patch removes the declaration.

gdb:

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

* breakpoint.h (regular_breakpoint_inserted_here_p): Remove.

7 years agoconst-fy breakpoint_ops->breakpoint_hit parameter aspace
Yao Qi [Thu, 26 Oct 2017 08:46:16 +0000 (09:46 +0100)]
const-fy breakpoint_ops->breakpoint_hit parameter aspace

gdb:

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

* break-catch-sig.c (signal_catchpoint_breakpoint_hit): Make
aspace const.
* break-catch-syscall.c (breakpoint_hit_catch_syscall):
Likewise.
* breakpoint.c (bpstat_check_location): Remove cast.
(breakpoint_hit_catch_fork): Make aspce const.
(breakpoint_hit_catch_solib): Likewise.
(breakpoint_hit_catch_exec): Likewise.
(breakpoint_hit_ranged_breakpoint): Likewise.
(breakpoint_hit_watchpoint): Likewise.
(base_breakpoint_breakpoint_hit): Likewise.
(bkpt_breakpoint_hit): Likewise.
(dprintf_breakpoint_hit): Likewise.
(tracepoint_breakpoint_hit): Likewise.
* breakpoint.h (breakpoint_ops) <breakpoint_hit>: Likewise.

7 years agoconst-fy function parameter struct address_space *aspace
Yao Qi [Thu, 26 Oct 2017 08:46:16 +0000 (09:46 +0100)]
const-fy function parameter struct address_space *aspace

This patch changes the parameter "struct address_space *aspace" to "const
address_space *aspace" in many functions.

gdb:

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

* breakpoint.c (breakpoint_location_address_match): Change
"struct address_space *" to "const address_space".
(breakpoint_location_address_range_overlap): Likewise.
(breakpoint_here_p): Likewise.
(breakpoint_in_range_p): Likewise.
(moribund_breakpoint_here_p): Likewise.
(bp_location_inserted_here_p): Likewise.
(software_breakpoint_inserted_here_p): Likewise.
(hardware_breakpoint_inserted_here_p): Likewise.
(hardware_watchpoint_inserted_in_range): Likewise.
(bpstat_check_location): Likewise.
(bpstat_stop_status): Likewise.
(breakpoint_address_match): Likewise.
(breakpoint_address_match_range): Likewise.
(breakpoint_location_address_match): Likewise.
(breakpoint_location_address_range_overlap): Likewise.
(insert_single_step_breakpoint): Likewise.
(breakpoint_has_location_inserted_here): Likewise.
(single_step_breakpoint_inserted_here_p): Likewise.
(pc_at_non_inline_function): Likewise.
* breakpoint.h (bpstat_stop_status): Update declaration.
(breakpoint_here_p): Likewise.
(breakpoint_in_range_p): Likewise.
(moribund_breakpoint_here_p): Likewise.
(breakpoint_inserted_here_p): Likewise.
(software_breakpoint_inserted_here_p): Likewise.
(hardware_breakpoint_inserted_here_p): Likewise.
(breakpoint_has_location_inserted_here): Likewise.
(single_step_breakpoint_inserted_here_p): Likewise.
(hardware_watchpoint_inserted_in_range): Likewise.
(breakpoint_address_match): Likewise.
(insert_single_step_breakpoint): Likewise.
(pc_at_non_inline_function): Likewise.
* gdbthread.h (thread_has_single_step_breakpoint_here): Likewise.
* record.c (record_check_stopped_by_breakpoint): Likewise.
* record.h (record_check_stopped_by_breakpoint): Likewise.
* thread.c (thread_has_single_step_breakpoint_here): Likewise.

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

7 years agotestsuite/gas/all/fill-1.s: Use L2 rather than .L2.
Hans-Peter Nilsson [Wed, 25 Oct 2017 23:11:06 +0000 (01:11 +0200)]
testsuite/gas/all/fill-1.s: Use L2 rather than .L2.

For some targets, like mmix-knuth-mmixware, .L2 (and .L1) are invalid
symbols.

7 years agold: Correct -z ibt documentation
H.J. Lu [Wed, 25 Oct 2017 15:44:54 +0000 (08:44 -0700)]
ld: Correct -z ibt documentation

* ld.texinfo: Correct -z ibt.

7 years agos/get_regcache_arch (regcache)/regcache->arch ()/g
Yao Qi [Wed, 25 Oct 2017 15:37:03 +0000 (16:37 +0100)]
s/get_regcache_arch (regcache)/regcache->arch ()/g

This patches removes get_regcache_arch, and use regache->arch () instead.
The motivation of this change is that I am going to move some basic stuff
into a base class of regcache.  I don't need to update "client" code
regcache->arch ().  On the other hand, this patch shortens the code a
little bit.

gdb:

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

* aarch32-linux-nat.c (aarch32_gp_regcache_supply): Use
regcache->arch () instead get_regcache_arch.
* aarch64-fbsd-nat.c (aarch64_fbsd_fetch_inferior_registers):
Likewise.
(aarch64_fbsd_store_inferior_registers): Likewise.
* aarch64-linux-nat.c (fetch_gregs_from_thread): Likewise.
(store_gregs_to_thread): Likewise.
(fetch_fpregs_from_thread): Likewise.
(store_fpregs_to_thread): Likewise.
* aarch64-tdep.c (aarch64_extract_return_value): Likewise.
(aarch64_store_return_value): Likewise.
(aarch64_software_single_step): Likewise.
* aix-thread.c (aix_thread_wait): Likewise.
(supply_reg32): Likewise.
(supply_sprs64): Likewise.
(supply_sprs32): Likewise.
(fill_gprs64): Likewise.
(fill_gprs32): Likewise.
(fill_sprs64): Likewise.
(fill_sprs32): Likewise.
(store_regs_user_thread): Likewise.
(store_regs_kernel_thread): Likewise.
* alpha-bsd-nat.c (alphabsd_fetch_inferior_registers): Likewise.
(alphabsd_store_inferior_registers): Likewise.
* alpha-tdep.c (alpha_extract_return_value): Likewise.
(alpha_store_return_value): Likewise.
(alpha_deal_with_atomic_sequence): Likewise.
(alpha_next_pc): Likewise.
(alpha_software_single_step): Likewise.
* amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers): Likewise.
(amd64bsd_store_inferior_registers): Likewise.
* amd64-linux-nat.c (amd64_linux_fetch_inferior_registers):
Likewise.
(amd64_linux_store_inferior_registers): Likewise.
* amd64-nat.c (amd64_supply_native_gregset): Likewise.
(amd64_collect_native_gregset): Likewise.
* amd64-obsd-tdep.c (amd64obsd_supply_uthread): Likewise.
(amd64obsd_collect_uthread): Likewise.
* amd64-tdep.c (amd64_supply_fpregset): Likewise.
(amd64_collect_fpregset): Likewise.
(amd64_supply_fxsave): Likewise.
(amd64_supply_xsave): Likewise.
(amd64_collect_fxsave): Likewise.
(amd64_collect_xsave): Likewise.
* arc-tdep.c (arc_write_pc): Likewise.
* arch-utils.c (default_skip_permanent_breakpoint): Likewise.
* arm-fbsd-nat.c (arm_fbsd_fetch_inferior_registers): Likewise.
(arm_fbsd_store_inferior_registers): Likewise.
* arm-linux-nat.c (fetch_vfp_regs): Likewise.
(store_vfp_regs): Likewise.
(arm_linux_fetch_inferior_registers): Likewise.
(arm_linux_store_inferior_registers): Likewise.
* arm-linux-tdep.c (arm_linux_supply_gregset): Likewise.
(arm_linux_sigreturn_next_pc): Likewise.
(arm_linux_get_next_pcs_syscall_next_pc): Likewise.
* arm-nbsd-nat.c (arm_supply_gregset): Likewise.
(fetch_register): Likewise.
(store_register): Likewise.
* arm-tdep.c (arm_is_thumb): Likewise.
(displaced_in_arm_mode): Likewise.
(bx_write_pc): Likewise.
(arm_get_next_pcs_addr_bits_remove): Likewise.
(arm_software_single_step): Likewise.
(arm_extract_return_value): Likewise.
(arm_store_return_value): Likewise.
(arm_write_pc): Likewise.
* bfin-tdep.c (bfin_extract_return_value): Likewise.
* bsd-uthread.c (bsd_uthread_fetch_registers): Likewise.
(bsd_uthread_store_registers): Likewise.
* core-regset.c (fetch_core_registers): Likewise.
* corelow.c (get_core_registers): Likewise.
* cris-tdep.c (cris_store_return_value): Likewise.
(cris_extract_return_value): Likewise.
(find_step_target): Likewise.
(find_step_target): Likewise.
(cris_software_single_step): Likewise.
* ctf.c (ctf_fetch_registers): Likewise.
* darwin-nat.c (cancel_breakpoint): Likewise.
* fbsd-tdep.c (fbsd_collect_thread_registers): Likewise.
* frv-tdep.c (frv_extract_return_value): Likewise.
* ft32-tdep.c (ft32_store_return_value): Likewise.
(ft32_extract_return_value): Likewise.
* go32-nat.c (fetch_register): Likewise.
(go32_fetch_registers): Likewise.
(go32_store_registers): Likewise.
(store_register): Likewise.
* h8300-tdep.c (h8300_extract_return_value): Likewise.
(h8300_store_return_value): Likewise.
* hppa-linux-nat.c (fetch_register): Likewise.
(store_register): Likewise.
(hppa_linux_fetch_inferior_registers): Likewise.
(hppa_linux_store_inferior_registers): Likewise.
* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers): Likewise.
(i386_darwin_store_inferior_registers): Likewise.
* i386-gnu-nat.c (gnu_fetch_registers): Likewise.
(gnu_store_registers): Likewise.
* i386-linux-nat.c (fetch_register): Likewise.
(store_register): Likewise.
(supply_gregset): Likewise.
(fill_gregset): Likewise.
(i386_linux_fetch_inferior_registers): Likewise.
(i386_linux_store_inferior_registers): Likewise.
(i386_linux_resume): Likewise.
* i386-linux-tdep.c (i386_linux_get_syscall_number_from_regcache):
Likewise.
* i386-nto-tdep.c (i386nto_supply_gregset): Likewise.
* i386-obsd-nat.c (i386obsd_supply_pcb): Likewise.
* i386-obsd-tdep.c (i386obsd_supply_uthread): Likewise.
(i386obsd_collect_uthread): Likewise.
* i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise.
(i386_supply_gregset): Likewise.
(i386_collect_gregset): Likewise.
(i386_supply_fpregset): Likewise.
(i386_collect_fpregset): Likewise.
(i386_mpx_bd_base): Likewise.
* i386-v4-nat.c (supply_fpregset): Likewise.
(fill_fpregset): Likewise.
* i387-tdep.c (i387_supply_fsave): Likewise.
(i387_collect_fsave): Likewise.
(i387_supply_fxsave): Likewise.
(i387_collect_fxsave): Likewise.
(i387_supply_xsave): Likewise.
(i387_collect_xsave): Likewise.
* ia64-linux-nat.c (ia64_linux_fetch_registers): Likewise.
(ia64_linux_store_registers): Likewise.
* ia64-tdep.c (ia64_access_rse_reg): Likewise.
(ia64_extract_return_value): Likewise.
(ia64_store_return_value): Likewise.
(find_func_descr): Likewise.
* inf-child.c (inf_child_fetch_inferior_registers): Likewise.
* inf-ptrace.c (inf_ptrace_fetch_registers): Likewise.
(inf_ptrace_store_registers): Likewise.
* infrun.c (use_displaced_stepping): Likewise.
(displaced_step_prepare_throw): Likewise.
(resume): Likewise.
(proceed): Likewise.
(do_target_wait): Likewise.
(adjust_pc_after_break): Likewise.
(handle_inferior_event_1): Likewise.
(handle_signal_stop): Likewise.
(save_infcall_suspend_state): Likewise.
(restore_infcall_suspend_state): Likewise.
* iq2000-tdep.c (iq2000_extract_return_value): Likewise.
* jit.c (jit_frame_prev_register): Likewise.
* linux-nat.c (save_stop_reason): Likewise.
(linux_nat_wait_1): Likewise.
(resume_stopped_resumed_lwps): Likewise.
* linux-record.c (record_linux_sockaddr): Likewise.
(record_linux_msghdr): Likewise.
(record_linux_system_call): Likewise.
* linux-tdep.c (linux_collect_thread_registers): Likewise.
* lm32-tdep.c (lm32_extract_return_value): Likewise.
(lm32_store_return_value): Likewise.
* m32c-tdep.c (m32c_read_flg): Likewise.
(m32c_pseudo_register_read): Likewise.
(m32c_pseudo_register_write): Likewise.
* m32r-linux-tdep.c (m32r_linux_supply_gregset): Likewise.
(m32r_linux_collect_gregset): Likewise.
* m32r-tdep.c (m32r_store_return_value): Likewise.
(m32r_extract_return_value): Likewise.
* m68k-bsd-nat.c (m68kbsd_supply_fpregset): Likewise.
(m68kbsd_collect_fpregset): Likewise.
* m68k-bsd-tdep.c (m68kbsd_supply_fpregset): Likewise.
* m68k-linux-nat.c (fetch_register): Likewise.
(old_fetch_inferior_registers): Likewise.
(old_store_inferior_registers): Likewise.
(store_regs): Likewise.
* m68k-tdep.c (m68k_svr4_extract_return_value): Likewise.
(m68k_svr4_store_return_value): Likewise.
* m88k-tdep.c (m88k_store_arguments): Likewise.
* mi/mi-main.c (mi_cmd_data_list_changed_registers): Likewise.
(mi_cmd_data_write_register_values): Likewise.
* mips-fbsd-nat.c (mips_fbsd_fetch_inferior_registers): Likewise.
(mips_fbsd_store_inferior_registers): Likewise.
* mips-fbsd-tdep.c (mips_fbsd_supply_fpregs): Likewise.
(mips_fbsd_supply_gregs): Likewise.
(mips_fbsd_collect_fpregs): Likewise.
(mips_fbsd_collect_gregs): Likewise.
(mips_fbsd_supply_fpregset): Likewise.
(mips_fbsd_collect_fpregset): Likewise.
(mips_fbsd_supply_gregset): Likewise.
(mips_fbsd_collect_gregset): Likewise.
* mips-linux-nat.c (supply_gregset): Likewise.
(fill_gregset): Likewise.
(supply_fpregset): Likewise.
(fill_fpregset): Likewise.
* mips-linux-tdep.c (mips_supply_gregset): Likewise.
(mips_fill_gregset): Likewise.
(mips_supply_fpregset): Likewise.
(mips_fill_fpregset): Likewise.
(mips64_supply_gregset): Likewise.
(micromips_linux_sigframe_validate): Likewise.
* mips-nbsd-nat.c (mipsnbsd_fetch_inferior_registers): Likewise.
(mipsnbsd_fetch_inferior_registers): Likewise.
(mipsnbsd_store_inferior_registers): Likewise.
* mips-nbsd-tdep.c (mipsnbsd_supply_fpregset): Likewise.
(mipsnbsd_supply_gregset): Likewise.
(mipsnbsd_iterate_over_regset_sections): Likewise.
(mipsnbsd_supply_reg): Likewise.
(mipsnbsd_supply_fpreg): Likewise.
* mips-tdep.c (mips_in_frame_stub): Likewise.
(mips_dummy_id): Likewise.
(is_octeon_bbit_op): Likewise.
(micromips_bc1_pc): Likewise.
(extended_mips16_next_pc): Likewise.
(mips16_next_pc): Likewise.
(deal_with_atomic_sequence): Likewise.
* moxie-tdep.c (moxie_process_readu): Likewise.
* nios2-tdep.c (nios2_get_next_pc): Likewise.
* nto-procfs.c (procfs_store_registers): Likewise.
* ppc-fbsd-nat.c (ppcfbsd_fetch_inferior_registers): Likewise.
(ppcfbsd_store_inferior_registers): Likewise.
* ppc-linux-nat.c (fetch_vsx_register): Likewise.
(fetch_altivec_register): Likewise.
(get_spe_registers): Likewise.
(fetch_spe_register): Likewise.
(fetch_altivec_registers): Likewise.
(fetch_all_gp_regs): Likewise.
(fetch_all_fp_regs): Likewise.
(store_vsx_register): Likewise.
(store_altivec_register): Likewise.
(set_spe_registers): Likewise.
(store_spe_register): Likewise.
(store_altivec_registers): Likewise.
(store_all_gp_regs): Likewise.
(store_all_fp_regs): Likewise.
* ppc-linux-tdep.c (ppc_linux_supply_gregset): Likewise.
(ppc_linux_collect_gregset): Likewise.
(ppc_canonicalize_syscall): Likewise.
(ppc_linux_record_signal): Likewise.
(ppu2spu_prev_register): Likewise.
* ppc-nbsd-nat.c (ppcnbsd_supply_pcb): Likewise.
* ppc-obsd-nat.c (ppcobsd_fetch_registers): Likewise.
(ppcobsd_store_registers): Likewise.
* ppc-ravenscar-thread.c (ppc_ravenscar_generic_fetch_registers):
Likewise.
(ppc_ravenscar_generic_store_registers): Likewise.
* procfs.c (procfs_fetch_registers): Likewise.
(procfs_store_registers): Likewise.
* ravenscar-thread.c (ravenscar_fetch_registers): Likewise.
(ravenscar_store_registers): Likewise.
(ravenscar_prepare_to_store): Likewise.
* record-btrace.c (record_btrace_fetch_registers): Likewise.
* record-full.c (record_full_wait_1): Likewise.
(record_full_registers_change): Likewise.
(record_full_store_registers): Likewise.
(record_full_core_fetch_registers): Likewise.
(record_full_save): Likewise.
(record_full_goto_insn): Likewise.
* regcache.c (regcache_register_size): Likewise.
(get_regcache_arch): Remove.
(regcache_read_pc): Likewise.
* regcache.h (get_regcache_arch): Remove.
* remote-sim.c (gdbsim_fetch_register): Likewise.
(gdbsim_store_register): Likewise.
* remote.c (fetch_register_using_p): Likewise.
(send_g_packet): Likewise.
(remote_prepare_to_store): Likewise.
(store_registers_using_G): Likewise.
* reverse.c (save_bookmark_command): Likewise.
(goto_bookmark_command): Likewise.
* rs6000-aix-tdep.c (branch_dest): Likewise.
* rs6000-nat.c (rs6000_ptrace64): Likewise.
(fetch_register): Likewise.
* rs6000-tdep.c (ppc_supply_reg): Likewise.
(ppc_collect_reg): Likewise.
(ppc_collect_gregset): Likewise.
(ppc_collect_fpregset): Likewise.
(ppc_collect_vsxregset): Likewise.
(ppc_collect_vrregset): Likewise.
(ppc_displaced_step_hw_singlestep): Likewise.
(rs6000_pseudo_register_read): Likewise.
(rs6000_pseudo_register_write): Likewise.
* s390-linux-nat.c (supply_gregset): Likewise.
(fill_gregset): Likewise.
(s390_linux_fetch_inferior_registers): Likewise.
* s390-linux-tdep.c (s390_write_pc): Likewise.
(s390_software_single_step): Likewise.
(s390_all_but_pc_registers_record): Likewise.
(s390_linux_syscall_record): Likewise.
* sentinel-frame.c (sentinel_frame_prev_arch): Likewise.
* sh-nbsd-nat.c (shnbsd_fetch_inferior_registers): Likewise.
(shnbsd_store_inferior_registers): Likewise.
* sh-tdep.c (sh_extract_return_value_nofpu): Likewise.
(sh_extract_return_value_fpu): Likewise.
(sh_store_return_value_nofpu): Likewise.
(sh_corefile_supply_regset): Likewise.
(sh_corefile_collect_regset): Likewise.
* sh64-tdep.c (sh64_extract_return_value): Likewise.
(sh64_store_return_value): Likewise.
* sparc-linux-tdep.c (sparc32_linux_collect_core_fpregset): Likewise.
* sparc-nat.c (sparc_fetch_inferior_registers): Likewise.
(sparc_store_inferior_registers): Likewise.
* sparc-ravenscar-thread.c (register_in_thread_descriptor_p): Likewise.
(sparc_ravenscar_prepare_to_store): Likewise.
* sparc-tdep.c (sparc32_store_arguments): Likewise.
(sparc_analyze_control_transfer): Likewise.
(sparc_step_trap): Likewise.
(sparc_software_single_step): Likewise.
(sparc32_gdbarch_init): Likewise.
(sparc_supply_rwindow): Likewise.
(sparc_collect_rwindow): Likewise.
* sparc64-linux-tdep.c (sparc64_linux_collect_core_fpregset): Likewise.
* sparc64-nbsd-nat.c (sparc64nbsd_supply_gregset): Likewise.
(sparc64nbsd_collect_gregset): Likewise.
(sparc64nbsd_supply_fpregset): Likewise.
(sparc64nbsd_collect_fpregset): Likewise.
* sparc64-tdep.c (sparc64_store_arguments): Likewise.
(sparc64_supply_gregset): Likewise.
(sparc64_collect_gregset): Likewise.
(sparc64_supply_fpregset): Likewise.
(sparc64_collect_fpregset): Likewise.
* spu-linux-nat.c (spu_fetch_inferior_registers): Likewise.
* spu-tdep.c (spu_unwind_sp): Likewise.
(spu2ppu_prev_register): Likewise.
(spu_memory_remove_breakpoint): Likewise.
* stack.c (return_command): Likewise.
* tic6x-tdep.c (tic6x_extract_signed_field): Likewise.
* tracefile-tfile.c (tfile_fetch_registers): Likewise.
* tracefile.c (trace_save_ctf): Likewise.
* windows-nat.c (do_windows_fetch_inferior_registers): Likewise.
(do_windows_store_inferior_registers): Likewise.
(windows_resume): Likewise.
* xtensa-linux-nat.c (fill_gregset): Likewise.
(supply_gregset_reg): Likewise.
* xtensa-tdep.c (xtensa_register_write_masked): Likewise.
(xtensa_register_read_masked): Likewise.
(xtensa_supply_gregset): Likewise.
(xtensa_extract_return_value): Likewise.
(xtensa_store_return_value): Likewise.

7 years agoTarget FP: Use target format throughout expression parsing
Ulrich Weigand [Wed, 25 Oct 2017 13:32:23 +0000 (15:32 +0200)]
Target FP: Use target format throughout expression parsing

When parsing floating-point literals, the language parsers currently
use parse_float or some equivalent routine to parse the input string
into a DOUBLEST, which is then stored within a OP_DOUBLE expression
node.  When evaluating the expression, the OP_DOUBLE is finally
converted into a value in target format.

On the other hand, *decimal* floating-point literals are parsed
directly into target format and stored that way in a OP_DECFLOAT
expression node.  In order to eliminate the DOUBLEST, this patch
therefore unifies the handling of binary and decimal floating-
point literals and stores them both in target format within a
new OP_FLOAT expression node, replacing both OP_DOUBLE and
OP_DECFLOAT.

In order to store literals in target format, the parse_float
routine needs to know the type of the literal.  All parsers
therefore need to be changed to determine the appropriate type
(e.g. by detecting suffixes) *before* calling parse_float,
instead of after it as today.  However, this change is mostly
straightforward -- again, this is already done for decimal FP
today.

The core of the literal parsing is moved into a new routine
floatformat_from_string, mirroring floatformat_to_string.
The parse_float routine now calls either floatformat_from_string
or decimal_from_sting, allowing it to handle any type of FP
literal.

All language parsers need to be updated.  Some notes on
specific changes to the various languages:

- C: Decimal FP is now handled in parse_float, and no longer
  needs to be handled specially.

- D: Straightforward.

- Fortran: Still used a hard-coded "atof", also replaced by
  parse_float now.  Continues to always use builtin_real_s8
  as the type of literal, even though this is probably wrong.

- Go: This used to handle "f" and "l" suffixes, even though
  the Go language actually doesn't support those.  I kept this
  support for now -- maybe revisit later.  Note the the GDB
  test suite for some reason actually *verifies* that GDB supports
  those unsupported suffixes ...

- Pascal: Likewise -- this handles suffixes that are not
  supported in the language standard.

- Modula-2: Like Fortran, used to use "atof".

- Rust: Mostly straightforward, except for a unit-testing hitch.
  The code use to set a special "unit_testing" flag which would
  cause "rust_type" to always return NULL.  This makes it not
  possible to encode a literal into target format (which type?).
  The reason for this flag appears to have been that during
  unit testing, there is no "rust_parser" context set up, which
  means no "gdbarch" is available to use its types.  To fix this,
  I removed the unit_testing flag, and instead simply just set up
  a dummy rust_parser context during unit testing.

- Ada: This used to check sizeof (DOUBLEST) to determine which
  type to use for floating-point literal.  This seems questionable
  to begin with (since DOUBLEST is quite unrelated to target formats),
  and in any case we need to get rid of DOUBLEST.  I'm now simply
  always using the largest type (builtin_long_double).

gdb/ChangeLog:
2017-10-25  Ulrich Weigand  <uweigand@de.ibm.com>

* doublest.c (floatformat_from_string): New function.
* doublest.h (floatformat_from_string): Add prototype.

* std-operator.def (OP_DOUBLE, OP_DECFLOAT): Remove, replace by ...
(OP_FLOAT): ... this.
* expression.h: Do not include "doublest.h".
(union exp_element): Replace doubleconst and decfloatconst by
new element floatconst.
* ada-lang.c (resolve_subexp): Handle OP_FLOAT instead of OP_DOUBLE.
(ada_evaluate_subexp): Likewise.
* eval.c (evaluate_subexp_standard): Handle OP_FLOAT instead of
OP_DOUBLE and OP_DECFLOAT.
* expprint.c (print_subexp_standard): Likewise.
(dump_subexp_body_standard): Likewise.
* breakpoint.c (watchpoint_exp_is_const): Likewise.

* parse.c: Include "dfp.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): New function.
(operator_length_standard): Handle OP_FLOAT instead of OP_DOUBLE
and OP_DECFLOAT.
(operator_check_standard): Likewise.
(parse_float): Do not accept suffix.  Take type as input.  Return bool.
Return target format buffer instead of host DOUBLEST.
Use floatformat_from_string and decimal_from_string to parse
either binary or decimal floating-point types.
(parse_c_float): Remove.
* parser-defs.h: Do not include "doublest.h".
(write_exp_elt_dblcst, write_exp_elt_decfloatcst): Remove.
(write_exp_elt_floatcst): Add prototype.
(parse_float): Update prototype.
(parse_c_float): Remove.

* c-exp.y: Do not include "dfp.h".
(typed_val_float): Use byte buffer instead of DOUBLEST.
(typed_val_decfloat): Remove.
(DECFLOAT): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.
Handle decimal and binary FP types the same way.

* d-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT_LITERAL): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.

* f-exp.y: Replace dval by typed_val_float.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Use parse_float instead of atof.

* go-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(parse_go_float): Remove.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of parse_go_float.
Parse suffixes and determine type before calling parse_float.

* p-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Update to new parse_float interface.
Parse suffixes and determine type before calling parse_float.

* m2-exp.y: Replace dval by byte buffer val.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
(parse_number): Call parse_float instead of atof.

* rust-exp.y (typed_val_float): Use byte buffer instead of DOUBLEST.
(lex_number): Call parse_float instead of strtod.
(ast_dliteral): Use OP_FLOAT instead of OP_DOUBLE.
(convert_ast_to_expression): Handle OP_FLOAT instead of OP_DOUBLE.
Use write_exp_elt_floatcst.
(unit_testing): Remove static variable.
(rust_type): Do not check unit_testing.
(rust_lex_tests): Do not set uint_testing.  Set up dummy rust_parser.

* ada-exp.y (type_float, type_double): Remove.
(typed_val_float): Use byte buffer instead of DOUBLEST.
(FLOAT): Use OP_FLOAT and write_exp_elt_floatcst.
* ada-lex.l (processReal): Use parse_float instead of sscanf.

7 years agoPR22348, conflicting global vars in crx and cr16
Alan Modra [Wed, 25 Oct 2017 11:29:14 +0000 (21:59 +1030)]
PR22348, conflicting global vars in crx and cr16

include/
PR 22348
* opcode/cr16.h (instruction): Delete.
(cr16_words, cr16_allWords, cr16_currInsn): Delete.
* opcode/crx.h (crx_cst4_map): Rename from cst4_map.
(crx_cst4_maps): Rename from cst4_maps.
(crx_no_op_insn): Rename from no_op_insn.
(instruction): Delete.
opcodes/
PR 22348
* cr16-dis.c (cr16_cinvs, instruction, cr16_currInsn): Make static.
(cr16_words, cr16_allWords, processing_argument_number): Likewise.
(imm4flag, size_changed): Likewise.
* crx-dis.c (crx_cinvs, NUMCINVS, instruction, currInsn): Likewise.
(words, allWords, processing_argument_number): Likewise.
(cst4flag, size_changed): Likewise.
* crx-opc.c (crx_cst4_map): Rename from cst4_map.
(crx_cst4_maps): Rename from cst4_maps.
(crx_no_op_insn): Rename from no_op_insn.
gas/
PR 22348
* config/tc-crx.c (instruction, output_opcode): Make static.
(relocatable, ins_parse, cur_arg_num): Likewise.
(parse_insn): Adjust for renamed opcodes globals.
(check_range): Likewise

7 years agoAdd common AARCH64 REGNUM defines
Alan Hayward [Wed, 25 Oct 2017 08:06:41 +0000 (09:06 +0100)]
Add common AARCH64 REGNUM defines

gdb/
* aarch64-tdep.h (enum aarch64_regnum): Remove.
* arch/aarch64.h: New file.

gdbserver/
* linux-aarch64-low.c (aarch64_fill_gregset): Replace defines
with REGNO.
(aarch64_store_gregset): Likewise.
(aarch64_fill_fpregset): Likewise.
(aarch64_store_fpregset): Likewise.

7 years agoAllow for __gnu_lto_slim prefixed with extra "_"
Alan Modra [Wed, 25 Oct 2017 05:02:52 +0000 (15:32 +1030)]
Allow for __gnu_lto_slim prefixed with extra "_"

Some targets prefix global symbols with "_".

bfd/
* archive.c (_bfd_compute_and_write_armap): Match "__gnu_lto_slim"
optionally prefixed with "_".
* linker.c (_bfd_generic_link_add_one_symbol): Likewise.
binutils/
* nm.c (filter_symbols): Match "__gnu_lto_slim" optionally prefixed
with "_".
gold/
* symtab.cc (Symbol_table::add_from_relobj): Match "__gnu_lto_slim"
optionally prefixed with "_".
ld/
* testsuite/ld-plugin/lto-3r.d: Match "__gnu_lto_v" optionally
prefixed with "_".
* testsuite/ld-plugin/lto-5r.d: Likewise.

7 years agoYet another fill-1 test fix
Alan Modra [Wed, 25 Oct 2017 05:01:58 +0000 (15:31 +1030)]
Yet another fill-1 test fix

tic4x fails due to being a 4 octets per byte target, while tic54x is 2
octets per byte.

mmix still fails with
fill-1.s:4: Error: unknown pseudo-op: `.l1:'
fill-1.s:6: Error: unknown pseudo-op: `.l2:'
fill-1.s:3: Error: .space specifies non-absolute value

and if the labels are changed to L1 and L2 then mep-elf fails with
fill-1.s:3: Error: .space specifies non-absolute value

Since both of those look like they ought to be investigated by the
target maintainers, I'm tweaking the test to fail on both targets.

* testsuite/gas/all/fill-1.d: Exclude tic4x and tic54x.
* testsuite/gas/all/fill-1.s: Use L1 rather than .L1.

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

7 years agoFix format typos in previous previous ld/ChangeLog entry
Hans-Peter Nilsson [Tue, 24 Oct 2017 22:46:24 +0000 (00:46 +0200)]
Fix format typos in previous previous ld/ChangeLog entry

7 years agotestsuite/ld-riscv-elf/ld-riscv-elf.exp: Fix typo for istarget.
Hans-Peter Nilsson [Tue, 24 Oct 2017 22:45:05 +0000 (00:45 +0200)]
testsuite/ld-riscv-elf/ld-riscv-elf.exp: Fix typo for istarget.

7 years agoFix racy test in gdb.base/new-ui.exp
Pedro Alves [Tue, 24 Oct 2017 22:22:56 +0000 (23:22 +0100)]
Fix racy test in gdb.base/new-ui.exp

I noticed gdb.base/new-ui.exp failing once here with:

 FAIL: gdb.base/new-ui.exp: do_test: delete all breakpoints on extra console (got interactive prompt)
 FAIL: gdb.base/new-ui.exp: do_test: main console: next causes no spurious output on other console
 FAIL: gdb.base/new-ui.exp: do_test: main console: breakpoint hit reported on other console

The problem is 100% reproducible with check-read1:
  $ make check-read1 TESTS="gdb.*/new-ui.exp"

testsuite/gdb.log shows:
  delete
  Delete all breakpoints? (y or n) [answered Y; input not from terminal]
  (gdb) FAIL: gdb.base/new-ui.exp: do_test: delete all breakpoints on extra console (got interactive prompt)

This commit fixes the problem.

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

* gdb.base/new-ui.exp (do_test): Split "delete all breakpoints on
extra console" test in two stages.

7 years agoRISC-V: Fix disassembly of c.addi4spn, c.addi16sp, c.lui when imm=0
Andrew Waterman [Thu, 19 Oct 2017 18:21:44 +0000 (11:21 -0700)]
RISC-V: Fix disassembly of c.addi4spn, c.addi16sp, c.lui when imm=0

These are all invalid instructions, so they should not disassemble.

opcodes/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * riscv-opc.c (match_c_addi16sp) : New function.
        (match_c_addi4spn): New function.
        (match_c_lui): Don't allow 0-immediate encodings.
        (riscv_opcodes) <addi>: Use the above functions.
        <add>: Likewise.
        <c.addi4spn>: Likewise.
        <c.addi16sp>: Likewise.

gas/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * testsuite/gas/riscv/c-addi16sp-fail.d: New test.
        testsuite/gas/riscv/c-addi16sp-fail.l: Likewise.
        testsuite/gas/riscv/c-addi16sp-fail.s: Likewise.
        testsuite/gas/riscv/c-addi4spn-fail.d: Likewise.
        testsuite/gas/riscv/c-addi4spn-fail.l: Likewise.
        testsuite/gas/riscv/c-addi4spn-fail.s: Likewise.
        testsuite/gas/riscv/riscv.exp: Add new tests.

7 years agoUse const reference for decimal_from_string argument
Ulrich Weigand [Tue, 24 Oct 2017 16:34:41 +0000 (18:34 +0200)]
Use const reference for decimal_from_string argument

No functional change.

gdb/ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

* dfp.h (decimal_from_string): Use const reference for argument.
* dfp.c (decimal_from_string): Likewise.

7 years agoTarget FP printing: Use floatformat_to_string in tdep code
Ulrich Weigand [Tue, 24 Oct 2017 16:01:39 +0000 (18:01 +0200)]
Target FP printing: Use floatformat_to_string in tdep code

A few tdep files use target-specific printing routines to output values in
the floating-point registers.  To get rid of host floating-point code,
this patch changes them to use floatformat_to_string instead.

No functional change intended, the resulting output should look the same.

ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

* i387-tdep.c (print_i387_value): Use floatformat_to_string.
* sh64-tdep.c (sh64_do_fp_register): Likewise.
* mips-tdep.c (mips_print_fp_register): Likewise.

7 years agoTarget FP printing: Simplify and fix ui_printf
Ulrich Weigand [Tue, 24 Oct 2017 16:00:50 +0000 (18:00 +0200)]
Target FP printing: Simplify and fix ui_printf

This patch adds support for handling format strings to both
floatformat_to_string and decimal_to_string, and then uses
those routines to implement ui_printf formatted printing.

There is already a subroutine printf_decfloat that ui_printf uses to
handle decimal FP.  This is renamed to printf_floating and updated
to handle both binary and decimal FP.  This includes the following
set of changes:

- printf_decfloat currently parses the format string again to determine
  the intended target format.  This seems superfluous since the common
  parsing code in parse_format_string already did this, but then did
  not pass the result on to its users.  Fixed by splitting the decfloat_arg
  argument class into three distinct classes, and passing them through.

- Now we can rename printf_decfloat to printf_floating and also call it
  for the argument classes representing binary FP types.

- The code will now use the argclass to detect the type the value should
  be printed at, and converts the input value to this type if necessary.
  To remain compatible with current behavior, for binary FP the code
  instead tries to re-interpret the input value as a FP type of the
  same size if that exists.  (Maybe this behavior is more confusing
  than useful -- but this can be changed later if we want to ...)

- Finally, we can use floatformat_to_string / decimal_to_string passing
  the format string to perform the formatted output using the desired
  target FP type.

Note that we no longer generate different code depending on whether or not
the host supports "long double" -- this check is obsolete anyway since C++11
mandates "long double", and in any case a %lg format string is intended to
refer to the *target* long double type, not the host version.

Note also that formatted printing of DFP numbers may not work correctly,
since it attempts to use the host printf to do so (and makes unwarranted
assumptions about the host ABI while doing so!).  This is no change to
the current behavior -- I simply moved the code from printf_decfloat to
the decimal_to_string routine in dfp.c.  If we want to fix it in the
future, that is a more appropriate place anyway.

ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

* common/format.h (enum argclass): Replace decfloat_arg by
dec32float_arg, dec64float_arg, and dec128float_arg.
* common/format.c (parse_format_string): Update to return
new decimal float argument classes.

* printcmd.c (printf_decfloat): Rename to ...
(printf_floating): ... this.  Add argclass argument, and use it
instead of parsing the format string again.  Add support for
binary floating-point values, using floatformat_to_string.
Convert value to the target format if it doesn't already match.
(ui_printf): Call printf_floating instead of printf_decfloat,
also for double_arg / long_double_arg.  Pass argclass.

* dfp.c (decimal_to_string): Add format string argument.
* dfp.h (decimal_to_string): Likewise.

* doublest.c (floatformat_to_string): Add format string argument.
* doublest.h (floatformat_to_string): Likewise.

7 years agoTarget FP printing: Simplify and fix print_floating
Ulrich Weigand [Tue, 24 Oct 2017 15:59:22 +0000 (17:59 +0200)]
Target FP printing: Simplify and fix print_floating

The print_floating routine currently makes a lot of assumptions about host
and target floating point formats.  This patch cleans up many of those.

One problem is that print_floating may currently be called with types
that are not actually floating-point types, and it tries hard to output
those as floating-point values anyway.  However, there is only one single
caller of print_floating where this can ever happen: print_scalar_formatted.
And in fact, it is much simpler to handle the case where the value to be
printed is not already of floating-point type right there.

So this patch changes print_scalar_formatted to handle the 'f' format
as follows:

- If the value to be printed is already of floating-point type, just
  call print_floating on it.

- Otherwise, if there is a standard target floating-point type of
  the same size as the value, call print_floating using that type.

- Otherwise, just print the value as if the 'f' format had not been
  specified at all.

This has the overall effect to printing everything the same way as
the old code did, but is overall a lot simpler.  (Also, it would
allow us to change the above strategy more easily, if that might
be a more intuitive user interface.  For example, in the third
case above, maybe an error would be more appropriate?)

Given that change, print_floating can become much simpler.  In particular,
we now always have a floating-point format that we can consult.  This
means we can use the floating-point format to programmatically determine
the number of digits necessary to print the value.

The current code uses a hard-coded value of 9, 17, or 35 digits.  Note
that this matches the DECIMAL_DIG values for IEEE-32, IEEE-64, and
IEEE-128.  (Actually, for IEEE-128 the correct value is 36 -- the 35
seems to be an oversight.)  The DECIMAL_DIG value is defined to be
the smallest number so that any number in the target format, when
printed to this number of digits and then scanned back into a binary
floating-point number, will result in the original value.

Now that we always have a FP format, we can just compute the DECIMAL_DIG
value using the formula from the C standard.  This will be correct for
*all* FP formats, not just the above list, and it will be correct (as
opposed to current code) if the target formats differ from the host ones.

The patch moves the new logic to a new floatformat_to_string routine
(analogous to the existing decimal_to_string).  The print_floating
routine now calls floatformat_to_string or decimal_to_string, making
the separate print_decimal_floating and generic_val_print_decfloat routines
unnecessary.

gdb/ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

* doublest.c (floatformat_precision): New routine.
(floatformat_to_string): Likewise.
* doublest.c (floatformat_to_string): Add prototype.

* printcmd.c (print_scalar_formatted): Only call print_floating
on floating-point types.
* valprint.c: Do not include "floatformat.h".
(generic_val_print_decfloat): Remove.
(generic_val_print): Call generic_val_print_float for both
TYPE_CODE_FLT and TYPE_CODE_DECFLOAT.
(print_floating): Use floatformat_to_string.  Handle decimal float.
(print_decimal_floating): Remove, merge into floatformat_to_string.
* value.h (print_decimal_floating): Remove.

* Makefile.in: Do not build doublest.c with -Wformat-nonliteral.

7 years agoRISC-V: Only relax to C.LUI when imm != 0 and rd != 0/2
Andrew Waterman [Sun, 24 Sep 2017 01:04:16 +0000 (18:04 -0700)]
RISC-V: Only relax to C.LUI when imm != 0 and rd != 0/2

This matches the ISA specification.  This also adds two tests: one to
make sure the assembler rejects invalid 'c.lui's, and one to make sure
we only relax valid 'c.lui's.

bfd/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * elfnn-riscv.c (_bfd_riscv_relax_lui): Don't relax to c.lui
        when rd is x0.

include/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * opcode/riscv.h (VALID_RVC_LUI_IMM): c.lui can't load the
        immediate 0.

gas/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * testsuite/gas/riscv/c-lui-fail.d: New testcase.
        gas/testsuite/gas/riscv/c-lui-fail.l: Likewise.
        gas/testsuite/gas/riscv/c-lui-fail.s: Likewise.
        gas/testsuite/gas/riscv/riscv.exp: Likewise.

ld/ChangeLog

2017-10-24  Andrew Waterman  <andrew@sifive.com>

        * ld/testsuite/ld-riscv-elf/c-lui.d: New testcase.
        ld/testsuite/ld-riscv-elf/c-lui.s: Likewise.
        ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp: New test suite.

7 years agoFix my previous gas/ChangeLog entry
Palmer Dabbelt [Tue, 24 Oct 2017 13:58:48 +0000 (06:58 -0700)]
Fix my previous gas/ChangeLog entry

7 years agoi386: Support .code64 directive only with 64-bit bfd
H.J. Lu [Tue, 24 Oct 2017 14:47:32 +0000 (07:47 -0700)]
i386: Support .code64 directive only with 64-bit bfd

Without 64-bit bfd, we can't properly support .code64 directive in
32-bit mode.

* config/tc-i386.c (md_pseudo_table): Add .code64 directive
only if BFD64 is defined.
* testsuite/gas/i386/code64-inval.l: New file.
* gas/testsuite/gas/i386/code64-inval.s: Likewise.
* gas/testsuite/gas/i386/code64.d: Likewise.
* gas/testsuite/gas/i386/code64.s: Likewise.
* testsuite/gas/i386/i386.exp: Run mixed-mode-reloc32,
att-regs, intel-regs, intel-expr and string-ok tests only if
assembler supports x86-64.  Run code64 and code64-inval.

7 years agoFix gdb.opt/inline-cmds.exp regressions
Ulrich Weigand [Tue, 24 Oct 2017 14:33:53 +0000 (16:33 +0200)]
Fix gdb.opt/inline-cmds.exp regressions

When sorting pending blocks in end_symtab_get_static_block, blocks
with the same starting address must remain in the original order
to preserve inline function caller/callee relationships.

The original code seems to have implicitly relied on the fact that the
glibc qsort implemention actually (in the common case) provides a stable
sort, although this is not guaranteed by the standard.  But the GNU
libstdc++ std::sort implementation is *not* stable.

gdb/ChangeLog:
2017-10-24  Ulrich Weigand  <uweigand@de.ibm.com>

* buildsym.c (end_symtab_get_static_block): Use std::stable_sort.

7 years ago[BFD][PR21703]Override the new defined symbol with the old normal symbol when --allow...
Renlin Li [Tue, 24 Oct 2017 11:42:30 +0000 (12:42 +0100)]
[BFD][PR21703]Override the new defined symbol with the old normal symbol when --allow-multiple-definition is provided.

The behavior of _bfd_elf_merge_symbol and _bfd_generic_link_add_one_symbol is
inconsistent.

In multiple definition case, _bfd_elf_merge_symbol decided to override the old
symbol definition with the new defintion, (size, type, target data)
In _bfd_generic_link_add_one_symbol, it simply return without doing anything
because of allow-multiple-definition is provided.
This leaves the symbol in a wrong state.

Here, following the documentation, I made this patch to force the old definition
override the new definition if the old symbol is not dynamic or weak.
Because, in those two cases, it's expected to do some merge. I have checked
that, those two cases are properly handled.

bfd/
PR ld/21703
* elflink.c (_bfd_elf_merge_symbol): Handle multiple definition case.

ld/

PR ld/21703
* testsuite/ld-elf/elf.exp: Run new tests.
* testsuite/ld-elf/pr21703-1.s: New.
* testsuite/ld-elf/pr21703-2.s: New.
* testsuite/ld-elf/pr21703-3.s: New.
* testsuite/ld-elf/pr21703-4.s: New.
* testsuite/ld-elf/pr21703-r.sd: New.
* testsuite/ld-elf/pr21703-shared.sd: New.
* testsuite/ld-elf/pr21703.sd: New.
* testsuite/ld-elf/pr21703.ver: New.

7 years agoReindent gdb.threads/attach-into-signal.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:45 +0000 (10:43 +0100)]
Reindent gdb.threads/attach-into-signal.exp

A previous patch removed one nesting level.

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

* gdb.threads/attach-into-signal.exp (corefunc): Reindent.

7 years agoDrop /proc/PID/status polling from gdb.threads/attach-into-signal.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:35 +0000 (10:43 +0100)]
Drop /proc/PID/status polling from gdb.threads/attach-into-signal.exp

I noticed that the 'with_test_prefix "stoppedtry $stoppedtry"' prefix
in this testcase is unnecessary, because inside that block there are
no pass/fail calls.  In fact the block includes a comment saying:

  # No PASS message as we may be looping in multiple
  # attempts.

but looking deeper at this I noticed a few odd things with this code
block:

1. This code is assuming that the second line in the /proc/PID/status
   files is the "State:" line, which may have been true when this was
   originally written, but is not true on my machine at least (Linux
   4.8.13).

     $ cat /proc/self/status
     Name:   cat
     Umask:  0002
     State:  R (running)

   So nowadays, that 'string match "*(stopped)*"' is running against
   the "Umask:" line and thus always returns false, meaning the loop
   always breaks on $stoppedtry == 0.

2. The loop seems to be waiting for the process to become "(stopped)",
   but if so then that 'if {![string match]}' check is reversed, it
   should be checking 'if {[string match]}' instead, because "string
   match" returns true if the string matches, not 0.

3. But if we fixed all that, we'd still run into the simple fact that
   nothing is actually stopping the test's inferior process before GDB
   attaches...  The top of the testcase says:

    # This test was created by modifying attach-stopped.exp.

   ... and attach-stopped.exp does have:

       # Stop the program
       remote_exec build "kill -s STOP ${testpid}"

   but then attach-stopped.exp doesn't have an equivalent
   /proc/PID/status poll loop...  (Maybe it could.)

So remove this whole loop as useless.

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

* gdb.threads/attach-into-signal.exp: Remove whole "stoppedtry"
loop.

7 years agoFix unstable test names in gdb.threads/attach-into-signal.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:35 +0000 (10:43 +0100)]
Fix unstable test names in gdb.threads/attach-into-signal.exp

Currently, if you diff testsuite/gdb.sum of two testsuite runs you'll
often see spurious hunks like these:

  -PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attempt 2: attach (pass 2), pending signal catch
  +PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attempt 1: attach (pass 2), pending signal catch
   PASS: gdb.threads/attach-into-signal.exp: successfully compiled posix threads test case
   PASS: gdb.threads/attach-into-signal.exp: threaded: handle SIGALRM stop print pass
  -PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 1: attach (pass 1), pending signal catch
  -PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 1: attach (pass 2), pending signal catch
  +PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 2: attach (pass 1), pending signal catch
  +PASS: gdb.threads/attach-into-signal.exp: threaded: attempt 4: attach (pass 2), pending signal catch

Fix this by removing the "attempt $attempt" test prefix.  The attempt
number can be retrieved from gdb.log instead, since the testcase is
already using "verbose -log" to that effect.

(The 'with_test_prefix "stoppedtry $stoppedtry"' prefix is unnecessary
too, because inside that block there are no pass/fail calls.  In fact
the block includes a comment saying:

  # No PASS message as we may be looping in multiple
  # attempts.

but I'll drop that whole loop in the next patch instead.)

After this commit we'll show:

  PASS: gdb.threads/attach-into-signal.exp: nonthreaded: handle SIGALRM stop print pass
  PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attach (pass 1), pending signal catch
  PASS: gdb.threads/attach-into-signal.exp: nonthreaded: attach (pass 2), pending signal catch
  PASS: gdb.threads/attach-into-signal.exp: successfully compiled posix threads test case
  PASS: gdb.threads/attach-into-signal.exp: threaded: handle SIGALRM stop print pass
  PASS: gdb.threads/attach-into-signal.exp: threaded: attach (pass 1), pending signal catch
  PASS: gdb.threads/attach-into-signal.exp: threaded: attach (pass 2), pending signal catch

(I've avoided reindenting to make the patch easier to maintain/read.
I'll reindent the blocks after this is in.)

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

* gdb.threads/attach-into-signal.exp (corefunc): Remove "attach
$attempt" test prefix.

7 years agoFix unstable test names in gdb.python/py-objfile.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:34 +0000 (10:43 +0100)]
Fix unstable test names in gdb.python/py-objfile.exp

Currently, if you diff testsuite/gdb.sum of different builds you see
this spurious hunk:

  -PASS: gdb.python/py-objfile.exp: get python valueof "sep_objfile.build_id" (6a0bfcab663f9810ccff33c756afdebb940037d4)
  +PASS: gdb.python/py-objfile.exp: get python valueof "sep_objfile.build_id" (1f5531c657c57777b05fc95baa0025fd1d115c3b)

Fix this by syncing get_python_valueof with get_integer_valueof, which
stopped outputting the value in commit 2f20e312aad6
("get_integer_valueof: Don't output value in test name").

After this commit we'll show:

  PASS: gdb.python/py-objfile.exp: get python valueof "sep_objfile.build_id"

As the comment explicitly says get_python_valueof is modeled on
get_integer_valueof, I went ahead and also added the optional 'test'
parameter while at it.

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

* lib/gdb-python.exp (get_python_valueof): Add 'test' optional
parameter and handle it.  Don't output read value in test name.

7 years agoFix unstable test names in gdb.gdb/unittest.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:34 +0000 (10:43 +0100)]
Fix unstable test names in gdb.gdb/unittest.exp

Currently, if you diff testsuite/gdb.sum of two builds built from different
source directories you see this spurious hunk:

  -PASS: gdb.gdb/unittest.exp: maintenance check xml-descriptions /home/pedro/gdb1/src/gdb/testsuite/../features
  +PASS: gdb.gdb/unittest.exp: maintenance check xml-descriptions /home/pedro/gdb2/src/gdb/testsuite/../features

After this commit we'll show instead:

  PASS: gdb.gdb/unittest.exp: maintenance check xml-descriptions ${srcdir}/../features

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

* gdb.gdb/unittest.exp ('maintenance check xml-descriptions'): Use
custom test name.

7 years agoFix unstable test names in gdb.base/startup-with-shell.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:33 +0000 (10:43 +0100)]
Fix unstable test names in gdb.base/startup-with-shell.exp

Currently, if you diff testsuite/gdb.sum of two builds in different
directories you see these spurious hunks:

  -PASS: gdb.base/startup-with-shell.exp: touch /home/pedro/gdb1/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/unique-file.unique-extension
  +PASS: gdb.base/startup-with-shell.exp: touch /home/pedro/gdb2/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/unique-file.unique-extension

  -PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: set args /home/pedro/gdb1/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension
  +PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: set args /home/pedro/gdb2/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension

  -PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = *.unique-extension: set args /home/pedro/gdb1/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension
  +PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = *.unique-extension: set args /home/pedro/gdb2/build/gdb/testsuite/outputs/gdb.base/startup-with-shell/*.unique-extension

Since the run_args arguments are already shown in the test prefix, we
can change the "set args" test name to literally "set args $run_args".
I.e., after this commit we'll show:

  PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = *.unique-extension: set args $run_args
  PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = *.unique-extension: set args $run_args
  PASS: gdb.base/startup-with-shell.exp: startup_with_shell = on; run_args = $TEST: set args $run_args
  PASS: gdb.base/startup-with-shell.exp: startup_with_shell = off; run_args = $TEST: set args $run_args

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

* gdb.base/startup-with-shell.exp ('touch $unique_file'): Don't
include the unstable output directory name in the test's name.
(initial_setup_simple) <'set args'>: Use custom test name.

7 years agoFix unstable test names in gdb.arch/arc-tdesc-cpu.exp
Pedro Alves [Tue, 24 Oct 2017 09:43:33 +0000 (10:43 +0100)]
Fix unstable test names in gdb.arch/arc-tdesc-cpu.exp

Currently if you diff testsuite/gdb.sum of two builds built from
different source trees you see this spurious hunk:

  -PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename /home/pedro/gdb1/src/gdb/testsuite/gdb.arch/arc-tdesc-cpu.xml
  +PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename /home/pedro/gdb2/src/gdb/testsuite/gdb.arch/arc-tdesc-cpu.xml

After this commit we'll show this instead in gdb.sum:
  PASS: gdb.arch/arc-tdesc-cpu.exp: set tdesc filename $srcdir/gdb.arch/arc-tdesc-cpu.xml

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

* gdb.arch/arc-tdesc-cpu.exp ('set tdesc filename'): Use gdb_test
with explicit test name.