binutils-gdb.git
7 years agoMake some improvements to how SORT_* specifiers and EXCLUDE_FILE specifiers are handl...
Andrew Burgess [Fri, 28 Jul 2017 12:01:10 +0000 (13:01 +0100)]
Make some improvements to how SORT_* specifiers and EXCLUDE_FILE specifiers are handled in the linker script grammar.

* ldgram.y (ldgram_had_keep): Make static.
(ldgram_vers_current_lang): Likewise.
(filename_spec): New rule.
(input_section_spec_no_keep): Use filename_spec.
(wildcard_maybe_exclude): New rule.
(wildcard_spec): Rename to...
(section_name_spec): ...this.
(section_NAME_list): Rename to...
(section_name_list): ...this.
(section_name_spec): Simplifiy and use wildcard_maybe_exclude.
* ldlang.c (placed_commons): Delete.
(lang_add_wild): No longer set placed_commons.
(print_wild_statement): Use full names for SORT specifiers.
* testsuite/ld-scripts/align.exp: Run new tests.
* testsuite/ld-scripts/align3.d: New file.
* testsuite/ld-scripts/align3.t: New file.
* testsuite/ld-scripts/align4.d: New file.
* testsuite/ld-scripts/align4.t: New file.
* testsuite/ld-scripts/align5.d: New file.
* testsuite/ld-scripts/align5.t: New file.
* testsuite/ld-scripts/exclude-file-5.d: New file.
* testsuite/ld-scripts/exclude-file-5.map: New file.
* testsuite/ld-scripts/exclude-file-5.t: New file.
* testsuite/ld-scripts/exclude-file-6.d: New file.
* testsuite/ld-scripts/exclude-file-6.map: New file.
* testsuite/ld-scripts/exclude-file-6.t: New file.
* NEWS: Mention the changes.

7 years agoFix problems parsing RISCV architecture extenstions in the assembler.
Andrew Waterman [Fri, 28 Jul 2017 09:02:57 +0000 (10:02 +0100)]
Fix problems parsing RISCV architecture extenstions in the assembler.

* config/tc-riscv.c (riscv_set_arch): Handle the Q subset like
all other subsets.
Obviate use-after-free.

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

7 years agoAdd myself as a write-after-approval GDB maintainer.
Xavier Roirand [Thu, 27 Jul 2017 13:53:02 +0000 (15:53 +0200)]
Add myself as a write-after-approval GDB maintainer.

gdb/Changelog:

2017-07-27  Xavier Roirand  <roirand@adacore.com>

        * MAINTAINERS (Write After Approval): Add Xavier Roirand.

Change-Id: Iee1dae7597da8f2c8c3098c14649ff400a81a388

7 years agoMove AVR .promemx.* sections into higher memory.
Georg-Johann Lay [Thu, 27 Jul 2017 13:17:14 +0000 (14:17 +0100)]
Move AVR .promemx.* sections into higher memory.

PR ld/21849
* scripttempl/avr.sc: Split .progmemx.* from .progmem.* and locate
former at a higher address.

7 years agoFix address violation issues encountered when parsing corrupt binaries.
Nick Clifton [Thu, 27 Jul 2017 11:04:50 +0000 (12:04 +0100)]
Fix address violation issues encountered when parsing corrupt binaries.

PR 21840
* mach-o.c (bfd_mach_o_read_symtab_strtab): Fail if the symtab
size is -1.
* nlmcode.h (nlm_swap_auxiliary_headers_in): Replace assertion
with error return.
* section.c (bfd_make_section_with_flags): Fail if the name or bfd
are NULL.
* vms-alpha.c (bfd_make_section_with_flags): Correct computation
of end pointer.
(evax_bfd_print_emh): Check for invalid string lengths.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 27 Jul 2017 00:00:47 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoGold: Fix mips.cc for GCC 4.2
H.J. Lu [Wed, 26 Jul 2017 17:39:20 +0000 (10:39 -0700)]
Gold: Fix mips.cc for GCC 4.2

GCC 4.2 fails to compile "(uint64_t) 0x800080008000" with

error: integer constant is too large for ‘long’ type

This patch adds "llu" suffix to 0x800080008000 for GCC 4.2.

* mips.cc (Mips_relocate_functions): Add "llu" suffix to
0x800080008000.

7 years agoAdd "maint check xml-descriptions" to test builtin xml target descriptions
Yao Qi [Wed, 26 Jul 2017 13:55:31 +0000 (14:55 +0100)]
Add "maint check xml-descriptions" to test builtin xml target descriptions

Now, GDB is able to dynamically create i386-linux target descriptions
from features, instead of using pre-generated target descriptions.  These
pre-generated target descriptions are no longer used by GDB (note that
they are still used by GDBserver).

This patch add a new maint command "maint check xml-descriptions" to test
dynamically generated tdesc are identical to these generated from xml files.

gdb:

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

* cli/cli-cmds.c (maintenancechecklist): New variable.
* gdbcmd.h (maintenancechecklist): Declare it.
* i386-linux-tdep.c (_initialize_i386_linux_tdep) [GDB_SELF_TEST]:
Call i386_linux_read_description with different masks.
* maint.c (maintenance_check_command): New function.
(_initialize_maint_cmds): Call add_prefix_cmd.
* target-descriptions.c (tdesc_reg): override operator != and ==.
(tdesc_type): Likewise.
(tdesc_feature): Likewise.
(target_desc): Likewise.
[GDB_SELF_TEST] (selftests::record_xml_tdesc): New function.
(maintenance_check_xml_descriptions): New function.
(_initialize_target_descriptions) Add command "xml-descriptions".
* target-descriptions.h (selftests::record_xml_tdesc): Declare.

gdb/testsuite:

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

* gdb.gdb/unittest.exp: Invoke command
"maintenance check xml-descriptions".

gdb/doc:

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

* gdb.texinfo (Maintenance Commands): Document command
"maint check xml-descriptions".

7 years agoLazily and dynamically create i386-linux target descriptions
Yao Qi [Wed, 26 Jul 2017 13:39:54 +0000 (14:39 +0100)]
Lazily and dynamically create i386-linux target descriptions

Instead of using pre-generated target descriptions, this patch
changes GDB to lazily and dynamically create target descriptions
according to the target hardware capability (xcr0 in i386).
This support any combination of target features.

Some reg in target description has "regnum" attribute, so its register
number is got from the attribute value instead from sequential allocation.

  <reg name="xmm0" bitsize="128" type="vec128" regnum="32"/>

when target description is created, it should match the regnum, so this
patch adds a new field m_next_regnum to track it, if attribute number is
greater than the m_next_regnum, print the code to set register number
explicitly.

gdb:

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

* i386-linux-tdep.c: Don't include features/i386/i386-*linux.c.
Include features/i386/32bit-*.c.
(i386_linux_read_description): Generate target description if it
doesn't exist.
(_initialize_i386_linux_tdep): Don't call _initialize_tdesc_i386
functions.
* features/i386/32bit-linux.c: Re-generated.
* features/i386/32bit-sse.c: Likewise.
* target-descriptions.c (print_c_feature::visit): Print code to
set register number if needed.
(print_c_feature) <m_next_regnum>: New field.

7 years agoGenerate c for feature instead of tdesc
Yao Qi [Wed, 26 Jul 2017 13:24:08 +0000 (14:24 +0100)]
Generate c for feature instead of tdesc

This patch changes Makefile and command "maint print c-files" so
that GDB can print c files for features instead target description.
Previously, we feed GDB a target description xml file, which generate
c files including multiple features.

With this patch, in Makefile, we wrap each feature xml file, and
create a temp target description which include only one feature.
Then, adjust the target description printer for them, and print
a c function for each given feature, so that we can use these
c functions later to create target description in a flexible way.

gdb:

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

* features/Makefile (CFILES): Rename with TDESC_CFILES.
(FEATURE_XMLFILES): New.
(FEATURE_CFILES): New.
New rules.
(clean-cfiles): Remove generated c files.
* features/i386/32bit-avx.c: Generated.
  * features/i386/32bit-avx512.c: Generated.
  * features/i386/32bit-core.c: Generated.
  * features/i386/32bit-linux.c: Generated.
  * features/i386/32bit-mpx.c: Generated.
  * features/i386/32bit-pkeys.c: Generated.
  * features/i386/32bit-sse.c: Generated.
  * target-descriptions.c: Include algorithm.
(tdesc_element_visitor): Add method visit_end.
(print_c_tdesc): Implement visit_end.
(print_c_tdesc:: m_filename_after_features): Move it to
protected.
(print_c_feature): New class.
(maint_print_c_tdesc_cmd): Use print_c_feature if XML file
name starts with "i386/32bit-".

7 years agoUse visitor pattern for "maint print c-tdesc"
Yao Qi [Wed, 26 Jul 2017 11:56:54 +0000 (12:56 +0100)]
Use visitor pattern for "maint print c-tdesc"

Target description can be modeled as a tree, the target description
is the root node, features are children nodes, registers and types are
grand-children nodes.  So command "maint print c-tdesc" in effect
traverse/visit each node, and print them in c.  This can be
implemented by visitor pattern, this is the first reason.  Secondly,
I want to this command prints c files in a different way for some
specific xml files, but still print c files the same way for the rest
of xml files.  Third, I even want to print xml files from target
descriptions, so that GDBserver can use it to reply GDB's query
qXfer:features:read:target.xml.

gdb:

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

* target-descriptions.c (tdesc_element_visitor): New class.
(tdesc_element): New class.
(tdesc_reg): Inherit from tdesc_element.
(tdesc_reg::accept): New function.
(tdesc_type): Inherit from tdesc_element.
(tdesc_type::accept): New function.
(tdesc_feature): Inherit from tdesc_element.
(tdesc_feature::accept): New function.
(target_desc): Inherit from tdesc_element.
(target_desc::target_desc): New.
(target_desc::~target_desc): New.
(target_desc::accept): New.
(allocate_target_description): Use new.
(free_target_description): Use delete.
(print_c_tdesc): New class.
(maint_print_c_tdesc_cmd): Adjust.

* features/aarch64.c: Re-generated.
* features/arc-arcompact.c: Re-generated.
* features/arc-v2.c: Re-generated.
* features/arm/arm-with-iwmmxt.c: Re-generated.
* features/arm/arm-with-m.c: Re-generated.
* features/arm/arm-with-m-fpa-layout.c: Re-generated.
* features/arm/arm-with-m-vfp-d16.c: Re-generated.
* features/arm/arm-with-neon.c: Re-generated.
* features/arm/arm-with-vfpv2.c: Re-generated.
* features/arm/arm-with-vfpv3.c: Re-generated.
* features/i386/amd64-avx-avx512.c: Re-generated.
* features/i386/amd64-avx-avx512-linux.c: Re-generated.
* features/i386/amd64-avx.c: Re-generated.
* features/i386/amd64-avx-linux.c: Re-generated.
* features/i386/amd64-avx-mpx-avx512-pku.c: Re-generated.
* features/i386/amd64-avx-mpx-avx512-pku-linux.c: Re-generated.
* features/i386/amd64-avx-mpx.c: Re-generated.
* features/i386/amd64-avx-mpx-linux.c: Re-generated.
* features/i386/amd64.c: Re-generated.
* features/i386/amd64-linux.c: Re-generated.
* features/i386/amd64-mpx.c: Re-generated.
* features/i386/amd64-mpx-linux.c: Re-generated.
* features/i386/i386-avx-avx512.c: Re-generated.
* features/i386/i386-avx-avx512-linux.c: Re-generated.
* features/i386/i386-avx.c: Re-generated.
* features/i386/i386-avx-linux.c: Re-generated.
* features/i386/i386-avx-mpx-avx512-pku.c: Re-generated.
* features/i386/i386-avx-mpx-avx512-pku-linux.c: Re-generated.
* features/i386/i386-avx-mpx.c: Re-generated.
* features/i386/i386-avx-mpx-linux.c: Re-generated.
* features/i386/i386.c: Re-generated.
* features/i386/i386-linux.c: Re-generated.
* features/i386/i386-mmx.c: Re-generated.
* features/i386/i386-mmx-linux.c: Re-generated.
* features/i386/i386-mpx.c: Re-generated.
* features/i386/i386-mpx-linux.c: Re-generated.
* features/i386/x32-avx-avx512.c: Re-generated.
* features/i386/x32-avx-avx512-linux.c: Re-generated.
* features/i386/x32-avx.c: Re-generated.
* features/i386/x32-avx-linux.c: Re-generated.
* features/i386/x32.c: Re-generated.
* features/i386/x32-linux.c: Re-generated.
* features/microblaze.c: Re-generated.
* features/microblaze-with-stack-protect.c: Re-generated.
* features/mips64-dsp-linux.c: Re-generated.
* features/mips64-linux.c: Re-generated.
* features/mips-dsp-linux.c: Re-generated.
* features/mips-linux.c: Re-generated.
* features/nds32.c: Re-generated.
* features/nios2.c: Re-generated.
* features/nios2-linux.c: Re-generated.
* features/rs6000/powerpc-32.c: Re-generated.
* features/rs6000/powerpc-32l.c: Re-generated.
* features/rs6000/powerpc-403.c: Re-generated.
* features/rs6000/powerpc-403gc.c : Re-generated.
* features/rs6000/powerpc-405.c: Re-generated.
* features/rs6000/powerpc-505.c: Re-generated.
* features/rs6000/powerpc-601.c: Re-generated.
* features/rs6000/powerpc-602.c: Re-generated.
* features/rs6000/powerpc-603.c: Re-generated.
* features/rs6000/powerpc-604.c: Re-generated.
* features/rs6000/powerpc-64.c: Re-generated.
* features/rs6000/powerpc-64l.c: Re-generated.
* features/rs6000/powerpc-7400.c: Re-generated.
* features/rs6000/powerpc-750.c: Re-generated.
* features/rs6000/powerpc-860.c: Re-generated.
* features/rs6000/powerpc-altivec32.c: Re-generated.
* features/rs6000/powerpc-altivec32l.c: Re-generated.
* features/rs6000/powerpc-altivec64.c: Re-generated.
* features/rs6000/powerpc-altivec64l.c: Re-generated.
* features/rs6000/powerpc-cell32l.c: Re-generated.
* features/rs6000/powerpc-cell64l.c: Re-generated.
* features/rs6000/powerpc-e500.c: Re-generated.
* features/rs6000/powerpc-e500l.c: Re-generated.
* features/rs6000/powerpc-isa205-32l.c: Re-generated.
* features/rs6000/powerpc-isa205-64l.c: Re-generated.
* features/rs6000/powerpc-isa205-altivec32l.c: Re-generated.
* features/rs6000/powerpc-isa205-altivec64l.c: Re-generated.
* features/rs6000/powerpc-isa205-vsx32l.c: Re-generated.
* features/rs6000/powerpc-isa205-vsx64l.c: Re-generated.
* features/rs6000/powerpc-vsx32.c: Re-generated.
* features/rs6000/powerpc-vsx32l.c: Re-generated.
* features/rs6000/powerpc-vsx64.c: Re-generated.
* features/rs6000/powerpc-vsx64l.c: Re-generated.
* features/rs6000/rs6000.c: Re-generated.
* features/s390-linux32.c: Re-generated.
* features/s390-linux32v1.c: Re-generated.
* features/s390-linux32v2.c: Re-generated.
* features/s390-linux64.c: Re-generated.
* features/s390-linux64v1.c: Re-generated.
* features/s390-linux64v2.c: Re-generated.
* features/s390-te-linux64.c: Re-generated.
* features/s390-tevx-linux64.c: Re-generated.
* features/s390-vx-linux64.c: Re-generated.
* features/s390x-linux64.c: Re-generated.
* features/s390x-linux64v1.c: Re-generated.
* features/s390x-linux64v2.c: Re-generated.
* features/s390x-te-linux64.c: Re-generated.
* features/s390x-tevx-linux64.c: Re-generated.
* features/s390x-vx-linux64.c: Re-generated.
* features/sparc/sparc32-solaris.c: Re-generated.
* features/sparc/sparc64-solaris.c: Re-generated.
* features/tic6x-c62x.c: Re-generated.
* features/tic6x-c62x-linux.c: Re-generated.
* features/tic6x-c64x.c: Re-generated.
* features/tic6x-c64x-linux.c: Re-generated.
* features/tic6x-c64xp.c: Re-generated.
* features/tic6x-c64xp-linux.c: Re-generated.

7 years agoCentralize i386 linux target descriptions
Yao Qi [Wed, 26 Jul 2017 11:36:42 +0000 (12:36 +0100)]
Centralize i386 linux target descriptions

This patch moves all the tdesc_i386*_linux target descriptions to a
function i386_linux_read_description, which returns the right target
description according to xcr0.  This also remove the duplication in
getting target descriptions in corefile and native target.

gdb:

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

* i386-linux-tdep.c (i386_linux_read_description): New function.
(i386_linux_core_read_description): Call
i386_linux_read_description.
* i386-linux-tdep.h (i386_linux_read_description): Declare.
(tdesc_i386_linux, tdesc_i386_mmx_linux): Remove declarations.
(tdesc_i386_avx_linux, tdesc_i386_mpx_linux): Likewise
(tdesc_i386_avx_mpx_linux, tdesc_i386_avx_avx512_linux): Likewise.
(tdesc_i386_avx_mpx_avx512_pku_linux): Likewise.
* x86-linux-nat.c (x86_linux_read_description): Call
i386_linux_read_description.

7 years agoAdd optional argument to command "maint prints c-tdesc"
Yao Qi [Wed, 26 Jul 2017 11:03:47 +0000 (12:03 +0100)]
Add optional argument to command "maint prints c-tdesc"

Nowadays, we need two steps to print c files for xml target description,
that is, 1) read xml target description in, update the current tdesc,
2) visit the current tdesc, print the c file.  It is unnecessary to
involve in current tdesc, and some validations in each gdbarch are
performed unnecessarily, which will reject some target descriptions if
they are missing some mandatory feature.

This patch adds an optional argument to "maint print c-tdesc", which
is an XML file target description, so that we can combine the two
steps above into one step, and don't have to involve in global current
tdesc.

gdb:

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

* NEWS: Mention it.
* features/Makefile (%.c: %.xml): Pass the xml file name to
command "maint print c-tdesc".
* target-descriptions.c (maint_print_c_tdesc_cmd): Get file
name from 'arg'.

gdb/doc:

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

* gdb.texinfo (Maintenance Commands): Document optional
argument of "maint print c-tdesc".

7 years agoClass-fy target_desc
Yao Qi [Wed, 26 Jul 2017 09:37:17 +0000 (10:37 +0100)]
Class-fy target_desc

This patch adds ctor and dtor in target_desc.

gdb:

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

* target-descriptions.c (target_desc): Add ctor and dtor.  Do
in-class initialization.
(tdesc_create_feature): Call new instead of XCNEW.
(free_target_description): Ue delete.

7 years agoAdd enum for result of fast_tracepoint_collecting
Simon Marchi [Wed, 26 Jul 2017 08:55:35 +0000 (10:55 +0200)]
Add enum for result of fast_tracepoint_collecting

I got confused by the result value of fast_tracepoint_collecting, while
it sounds like it would return true/false (whether the thread is
collecting or not), it actually returns:

  0: not collecting
  1: in the jump pad, before the relocated instruction
  2: in the jump pad, at or after the relocated instruction

To avoid confusion, I think it would be nice to make it return an enum.
If you can help find a shorter but still relavant name, it would be
awesome.  Otherwise, we'll go with that, fast_tpoint_collect_result,
which is at least consistent with the existing
fast_tpoint_collect_status.

gdb/gdbserver/ChangeLog:

* tracepoint.h (enum class fast_tpoint_collect_result): New
enumeration.
(fast_tracepoint_collecting): Change return type to
fast_tpoint_collect_result.
* tracepoint.c (fast_tracepoint_collecting): Likewise.
* linux-low.h: Include tracepoint.h.
(struct lwp_info) <collecting_fast_tracepoint>: Change type to
fast_tpoint_collect_result.
* linux-low.c (handle_tracepoints): Adjust.
(linux_fast_tracepoint_collecting): Change return type to
fast_tpoint_collect_result.
(maybe_move_out_of_jump_pad, linux_wait_for_event_filtered,
linux_wait_1, stuck_in_jump_pad_callback,
lwp_signal_can_be_delivered, linux_resume_one_lwp_throw,
proceed_one_lwp): Adjust to type change.

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

7 years agoFix two NetBSD-specific typos in the configure.nat conversion.
John Baldwin [Sat, 15 Jul 2017 15:30:40 +0000 (08:30 -0700)]
Fix two NetBSD-specific typos in the configure.nat conversion.

- Add the '-lkvm' library requirement for NetBSD/sparc64.
- Fix spelling of 'nbsdelf' host.

gdb/Changelog:

* configure.nat: Add "-lkvm" for NetBSD/sparc64 and fix typo.

7 years agoMake amd64_x32_init_abi and amd64_init_abi argument constant
Yao Qi [Tue, 25 Jul 2017 14:25:38 +0000 (15:25 +0100)]
Make amd64_x32_init_abi and amd64_init_abi argument constant

gdb:

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

* amd64-tdep.c (amd64_init_abi): Make argument default_tdesc
constant.
(amd64_x32_init_abi): Likewise.
* amd64-tdep.h (amd64_init_abi): Update declaration.
(amd64_x32_init_abi): Likewise.

7 years agoFix thinko in previous change to elf32-msp430.c
Nick Clifton [Tue, 25 Jul 2017 11:47:46 +0000 (12:47 +0100)]
Fix thinko in previous change to elf32-msp430.c

7 years agoFix typos in error and option messages in OPCODES library.
Nick Clifton [Tue, 25 Jul 2017 11:12:16 +0000 (12:12 +0100)]
Fix typos in error and option messages in OPCODES library.

PR 21739
opcodes * arc-opc.c (insert_rhv2): Use lower case first letter in error
message.
(insert_r0): Likewise.
(insert_r1): Likewise.
(insert_r2): Likewise.
(insert_r3): Likewise.
(insert_sp): Likewise.
(insert_gp): Likewise.
(insert_pcl): Likewise.
(insert_blink): Likewise.
(insert_ilink1): Likewise.
(insert_ilink2): Likewise.
(insert_ras): Likewise.
(insert_rbs): Likewise.
(insert_rcs): Likewise.
(insert_simm3s): Likewise.
(insert_rrange): Likewise.
(insert_r13el): Likewise.
(insert_fpel): Likewise.
(insert_blinkel): Likewise.
(insert_pclel): Likewise.
(insert_nps_bitop_size_2b): Likewise.
(insert_nps_imm_offset): Likewise.
(insert_nps_imm_entry): Likewise.
(insert_nps_size_16bit): Likewise.
(insert_nps_##NAME##_pos): Likewise.
(insert_nps_##NAME): Likewise.
(insert_nps_bitop_ins_ext): Likewise.
(insert_nps_##NAME): Likewise.
(insert_nps_min_hofs): Likewise.
(insert_nps_##NAME): Likewise.
(insert_nps_rbdouble_64): Likewise.
(insert_nps_misc_imm_offset): Likewise.
* riscv-dis.c (print_riscv_disassembler_options): Fix typo in
option description.

gas * testsuite/gas/arc/add_s-err.s: Update expected error message.

7 years agoCatch exceptions thrown from gdbarch_skip_prologue
Yao Qi [Tue, 25 Jul 2017 10:38:50 +0000 (11:38 +0100)]
Catch exceptions thrown from gdbarch_skip_prologue

PR 21555 is caused by the exception during the prologue analysis when re-set
a breakpoint.

(gdb) bt
 #0  memory_error_message (err=TARGET_XFER_E_IO, gdbarch=0x153db50, memaddr=93824992233232) at ../../binutils-gdb/gdb/corefile.c:192
 #1  0x00000000005718ed in memory_error (err=TARGET_XFER_E_IO, memaddr=memaddr@entry=93824992233232) at ../../binutils-gdb/gdb/corefile.c:220
 #2  0x00000000005719d6 in read_memory_object (object=object@entry=TARGET_OBJECT_CODE_MEMORY, memaddr=93824992233232, memaddr@entry=1, myaddr=myaddr@entry=0x7fffffffd0a0 "P\333S\001", len=len@entry=1) at ../../binutils-gdb/gdb/corefile.c:259
 #3  0x0000000000571c6e in read_code (len=1, myaddr=0x7fffffffd0a0 "P\333S\001", memaddr=<optimized out>) at ../../binutils-gdb/gdb/corefile.c:287
 #4  read_code_unsigned_integer (memaddr=memaddr@entry=93824992233232, len=len@entry=1, byte_order=byte_order@entry=BFD_ENDIAN_LITTLE)                          at ../../binutils-gdb/gdb/corefile.c:362
 #5  0x000000000041d4a0 in amd64_analyze_prologue (gdbarch=gdbarch@entry=0x153db50, pc=pc@entry=93824992233232, current_pc=current_pc@entry=18446744073709551615, cache=cache@entry=0x7fffffffd1e0) at ../../binutils-gdb/gdb/amd64-tdep.c:2310
 #6  0x000000000041e404 in amd64_skip_prologue (gdbarch=0x153db50, start_pc=93824992233232) at ../../binutils-gdb/gdb/amd64-tdep.c:2459
 #7  0x000000000067bfb0 in skip_prologue_sal (sal=sal@entry=0x7fffffffd4e0) at ../../binutils-gdb/gdb/symtab.c:3628
 #8  0x000000000067c4d8 in find_function_start_sal (sym=sym@entry=0x1549960, funfirstline=1) at ../../binutils-gdb/gdb/symtab.c:3501
 #9  0x000000000060999d in symbol_to_sal (result=result@entry=0x7fffffffd5f0, funfirstline=<optimized out>, sym=sym@entry=0x1549960) at ../../binutils-gdb/gdb/linespec.c:3860
....
 #16 0x000000000054b733 in location_to_sals (b=b@entry=0x15792d0, location=0x157c230, search_pspace=search_pspace@entry=0x1148120, found=found@entry=0x7fffffffdc64) at ../../binutils-gdb/gdb/breakpoint.c:14211
 #17 0x000000000054c1f5 in breakpoint_re_set_default (b=0x15792d0) at ../../binutils-gdb/gdb/breakpoint.c:14301
 #18 0x00000000005412a9 in breakpoint_re_set_one (bint=bint@entry=0x15792d0) at ../../binutils-gdb/gdb/breakpoint.c:14412

This problem can be fixed by

 - either each prologue analyzer doesn't throw exception,
 - or catch the exception thrown from gdbarch_skip_prologue,

I choose the latter because the former needs to fix *every* prologue
analyzer to not throw exception.

This error can be reproduced by changing reread.exp.  The test reread.exp
has already test that breakpoint can be reset correctly after the
executable is re-read.  This patch extends this test by compiling test c
file with and without -fPIE.

(gdb) run ^M
The program being debugged has been started already.^M
Start it from the beginning? (y or n) y^M
x86_64/gdb/testsuite/outputs/gdb.base/reread/reread' has changed; re-reading symbols.
Error in re-setting breakpoint 1: Cannot access memory at address 0x555555554790^M
Error in re-setting breakpoint 2: Cannot access memory at address 0x555555554790^M
Starting program: /scratch/yao/gdb/build-git/x86_64/gdb/testsuite/outputs/gdb.base/reread/reread ^M
This is foo^M
[Inferior 1 (process 27720) exited normally]^M
(gdb) FAIL: gdb.base/reread.exp: opts= "-fPIE" "ldflags=-pie" : run to foo() second time (the program exited)

This patch doesn't re-indent the code, to keep the patch simple.

gdb:

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

PR gdb/21555
* arch-utils.c (gdbarch_skip_prologue_noexcept): New function.
* arch-utils.h (gdbarch_skip_prologue_noexcept): Declare.
* infrun.c: Include arch-utils.h
(handle_step_into_function): Call gdbarch_skip_prologue_noexcept.
(handle_step_into_function_backward): Likewise.
* symtab.c (skip_prologue_sal): Likewise.

gdb/testsuite:

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

PR gdb/21555
* gdb.base/reread.exp: Wrap the whole test with two kinds of
compilation flags, with -fPIE and without -fPIE.

7 years ago[ARM] Access FPSCR on vfpv2
Yao Qi [Fri, 21 Jul 2017 15:35:23 +0000 (16:35 +0100)]
[ARM] Access FPSCR on vfpv2

GDB can fetch or store FPSCR on vfpv3, which has 32 VFP registers, but
fail to do so on vfpv2, which has 16 VFP registers.  GDB code is incorrect
for vfpv2,

       else if (tdep->vfp_register_count > 0
         && regno >= ARM_D0_REGNUM
       && regno <= ARM_D0_REGNUM + tdep->vfp_register_count)

while FPSCR register number is defined as ARM_D0_REGNUM + 32.

  ARM_D0_REGNUM, /* VFP double-precision registers.  */
  ARM_D31_REGNUM = ARM_D0_REGNUM + 31,
  ARM_FPSCR_REGNUM,

The code above uses "<=" rather than "<", in order to put FPSCR in the
range, but it is only correct when tdep->vfp_register_count is 32.  On
vpfv2, it is 16, and FPSCR is out of the range, so fetch_vfp_regs or
store_vfp_regs are not called.

gdb:

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

PR tdep/21717
* arm-linux-nat.c (arm_linux_fetch_inferior_registers): Update
condition for FPSCR.
(arm_linux_store_inferior_registers): Likewise.

7 years agoUpdated French translation for the BFD library.
Nick Clifton [Tue, 25 Jul 2017 08:46:14 +0000 (09:46 +0100)]
Updated French translation for the BFD library.

7 years agoAdd a linker branch optimization for the MSP430.
Benjamin Green [Tue, 25 Jul 2017 08:41:23 +0000 (09:41 +0100)]
Add a linker branch optimization for the MSP430.

PR 21824
* elf32-msp430.c (msp430_elf_relax_section): Allow conversion of
16-bit absolute branches into 10-bit pc-relative branches on the
MSP430 as well as the MSP430X.

7 years agooops - add changelog entry accidentally omitted from previous delta.
Nick Clifton [Tue, 25 Jul 2017 08:39:13 +0000 (09:39 +0100)]
oops - add changelog entry accidentally omitted from previous delta.

7 years agoStop readelf from returning an error status if asked to dump an emoty section.
Nick Clifton [Tue, 25 Jul 2017 08:35:36 +0000 (09:35 +0100)]
Stop readelf from returning an error status if asked to dump an emoty section.

PR 21820
* readelf.c (dump_section_as_strings): Do not fail if the section
was empty.
(dump_section_as_bytes): Likewise.

7 years ago__tls_get_addr_opt stub eh_frame info
Alan Modra [Tue, 25 Jul 2017 04:22:32 +0000 (13:52 +0930)]
__tls_get_addr_opt stub eh_frame info

Since the __tls_get_addr_opt stub saves LR and makes a call, eh_frame
info should be generated to describe how to unwind through the stub.

The patch also changes the way the backend iterates over stubs, from
looking at all sections in stub_bfd to which all dynamic sections are
attached as well, to iterating over the group list, which gets just
the stub sections.  Most binaries will have just one or two stub
groups, so this is a little faster.

bfd/
* elf64-ppc.c (struct map_stub): Add tls_get_addr_opt_bctrl.
(stub_eh_frame_size): New function.
(ppc_size_one_stub): Set group tls_get_addr_opt_bctrl.
(group_sections): Init group tls_get_addr_opt_bctrl.
(ppc64_elf_size_stubs): Update sizing and initialization of
.eh_frame.  Iteration over stubs via group list.
(ppc64_elf_build_stubs): Iterate over stubs via group list.
(ppc64_elf_finish_dynamic_sections): Update finalization of
.eh_frame.
ld/
* testsuite/ld-powerpc/tlsopt5.s: Add cfi.
* testsuite/ld-powerpc/tlsopt5.d: Update.
* testsuite/ld-powerpc/tlsopt5.wf: New file.
* testsuite/ld-powerpc/powerpc.exp: Perform new tlsopt5 test.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 25 Jul 2017 00:01:08 +0000 (00:01 +0000)]
Automatic date update in version.in

7 years agos390-vregs.exp: Fix Tcl error after non-zero-pad patch
Andreas Arnez [Mon, 24 Jul 2017 16:35:30 +0000 (18:35 +0200)]
s390-vregs.exp: Fix Tcl error after non-zero-pad patch

s390-vregs.exp yields a Tcl error:

  ERROR: can't read "i": no such variable
      while executing
  "expr $a_high * ($i + 1) * $a_high "
      (procedure "hex128" line 2)
      invoked from within
  "hex128 $a_high $a_low $b_high $b_low"
  ...

This is a regression, caused by commit 30a254669b16b8 -- "Don't always
zero pad in print_*_chars".  That patch introduced a new procedure
"hex128" for formatting a 128-bit value as hex, but it accidentally moved
the calculation of the 128-bit value into that new procedure as well
instead of leaving it in the original context.  This is fixed.

gdb/testsuite/ChangeLog:

* gdb.arch/s390-vregs.exp: Calculate parameters to hex128 in the
calling context.
(hex128): Drop erroneous calculation of parameters.

7 years ago[AArch64] Fix the bit pattern order in the comments in auto-generated file
Jiong Wang [Mon, 24 Jul 2017 10:26:58 +0000 (11:26 +0100)]
[AArch64] Fix the bit pattern order in the comments in auto-generated file

The bit pattern comment in "aarch64_opcode_lookup_1" is reversed.

This patch fixed this.

opcode/
* aarch64-gen.c (print_decision_tree_1): Reverse the index of PATTERN to
correct the print.
* aarch64-dis-2.c: Regenerated.

7 years agoFix another memory access error triggered by attempting to parse a corrupt binary.
Nick Clifton [Mon, 24 Jul 2017 13:04:04 +0000 (14:04 +0100)]
Fix another memory access error triggered by attempting to parse a corrupt binary.

PR 21813
(alpha_vms_object_p): Check for a truncated record.

7 years agoFix address violation errors parsing corrupt binary files.
Nick Clifton [Mon, 24 Jul 2017 12:49:22 +0000 (13:49 +0100)]
Fix address violation errors parsing corrupt binary files.

PR 21813
binutils* rddbg.c (read_symbol_stabs_debugging_info): Check for an empty
string whilst concatenating symbol names.

bfd * mach-o.c (bfd_mach_o_canonicalize_relocs): Pass the base address
of the relocs to the canonicalize_one_reloc routine.
* mach-o.h (struct bfd_mach_o_backend_data): Update the prototype
for the _bfd_mach_o_canonicalize_one_reloc field.
* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add
res_base parameter.  Use to check for corrupt pair relocs.
* mach-o-aarch64.c (bfd_mach_o_arm64_canonicalize_one_reloc):
Likewise.
* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc):
Likewise.
* mach-o-x86-64.c (bfd_mach_o_x86_64_canonicalize_one_reloc):
Likewise.

* vms-alpha.c (_bfd_vms_slurp_eihd): Make sure that there is
enough data in the record before attempting to parse it.
(_bfd_vms_slurp_eeom): Likewise.

(_bfd_vms_slurp_egsd): Check for an invalid section index.
(image_set_ptr): Likewise.
(alpha_vms_slurp_relocs): Likewise.

7 years agoStop the generation of mapping symbols in the debug sections of ARM and AArch64 binaries.
Nick Clifton [Mon, 24 Jul 2017 10:32:57 +0000 (11:32 +0100)]
Stop the generation of mapping symbols in the debug sections of ARM and AArch64 binaries.

PR 21809
* config/tc-aarch64.c (aarch64_init_frag): Do not set a mapping
state for frags in debug sections.
* config/tc-arm.c (arm_init_frag): Likewise.

7 years agoImprove "unrecognized relocation" error messages to add the suggestion that the linke...
Nick Clifton [Mon, 24 Jul 2017 10:27:33 +0000 (11:27 +0100)]
Improve "unrecognized relocation" error messages to add the suggestion that the linker might be out of date.

PR 21803
* reloc.c (_bfd_unrecognized_reloc): New function.  Reports
an unrecognized reloc and sets the bfd_error value.
* libbfd.h: Regenerate.
* elf32-arm.c (elf32_arm_final_link_relocate): Use the new
function.
* elf32-i386.c (elf_i386_relocate_section): Likewise.
* elf32-tilepro.c (tilepro_elf_relocate_section): Likewise.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_relocate_section): Likewise.
* elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise.

7 years ago[ARC] Fix big-endian ld tests errors.
claziss [Mon, 24 Jul 2017 08:10:21 +0000 (10:10 +0200)]
[ARC] Fix big-endian ld tests errors.

A set of small patches that are fixing big-endian observed errors.

ld/
2017-07-24  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/ld-arc/jli-overflow.d: Force testing for little
endian.
* testsuite/ld-arc/tls_gd-01.d: Fix string to match bigendian
systems.
* testsuite/ld-arc/tls_ie-01.d: Fix test for bigendian systems.

7 years agoAutomatic date update in version.in
GDB Administrator [Mon, 24 Jul 2017 00:00:58 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years ago* dwarf2dbg.c (dwarf2dbg_final_check): Rename local variable exp from expr.
Hans-Peter Nilsson [Sun, 23 Jul 2017 22:53:34 +0000 (00:53 +0200)]
* dwarf2dbg.c (dwarf2dbg_final_check): Rename local variable exp from expr.

Trying to build (for mmix-knuth-mmixware but I don't think that
matters) yields the following (repeatable on e.g. CompileFarm gcc20
sporting gcc-4.7.2 as default):

gcc -DHAVE_CONFIG_H -I. -I/home/hp/binutils/src/gas  -I. -I/home/hp/binutils/src/gas -I../bfd -I/home/hp/binutils/src/gas/config -I/home/hp/binutils/src/gas/../include -I/home/hp/binutils/src/gas/.. -I/home/hp/binutils/src/gas/../bfd -DLOCALEDIR="\"/usr/local/share/locale\""  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -Wwrite-strings -I/home/hp/binutils/src/gas/../zlib -g -O2 -MT dwarf2dbg.o -MD -MP -MF .deps/dwarf2dbg.Tpo -c -o dwarf2dbg.o /home/hp/binutils/src/gas/dwarf2dbg.c
cc1: warnings being treated as errors
/home/hp/binutils/src/gas/dwarf2dbg.c: In function 'dwarf2dbg_final_check':
/home/hp/binutils/src/gas/dwarf2dbg.c:2246: error: declaration of 'expr' shadows a global declaration
/home/hp/binutils/src/gas/expr.h:180: error: shadowed declaration is here
make[4]: *** [dwarf2dbg.o] Error 1

IIRC this is a false namespace clash and the warning is not observable
with a new-enough gcc.  Committed as obvious.

brgds, H-P
PS. Idea: -Wcompiler; warn about constructs problematic with e.g. old gcc. 1/2 ;-)

7 years agoCorrect eh_frame info for __glink_PLTresolve
Alan Modra [Sun, 23 Jul 2017 10:33:40 +0000 (20:03 +0930)]
Correct eh_frame info for __glink_PLTresolve

My PPC64_OPT_LOCALENTRY patch of June 1, git commit f378ab099d, and
the later gold change, git commit 7ee7ff7015, added an insn in
__glink_PLTresolve which needs a corresponding adjustment in the
eh_frame info for asynchronous exceptions to unwind correctly.

It would have been OK for both ABIs to use +5 for the advance before
restore of LR, since we can put the DW_CFA_restore_extended on any
insn after the actual restore and before the r12/r0 copy is clobbered,
but it's slightly better to delay as much as possible.  There are
then more addresses where fewer CFA program insns are executed.

bfd/
* elf64-ppc.c (ppc64_elf_size_stubs): Correct advance to
restore of LR.
gold/
* powerpc.cc (glink_eh_frame_fde_64v2): Correct advance to
restore of LR.
(glink_eh_frame_fde_64v1): Advance to restore of LR at latest
possible insn.

7 years agoAutomatic date update in version.in
GDB Administrator [Sun, 23 Jul 2017 00:00:36 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoUse std::vector in struct catch_syscall_inferior_data
Tom Tromey [Wed, 19 Jul 2017 00:23:32 +0000 (18:23 -0600)]
Use std::vector in struct catch_syscall_inferior_data

This changes struct catch_syscall_inferior_data to use a std::vector
rather than a VEC.  It also changes it to be allocated with new and
destroyed with delete.

ChangeLog
2017-07-22  Tom Tromey  <tom@tromey.com>

* break-catch-syscall.c (struct catch_syscall_inferior_data)
<syscalls_counts>: Now a std::vector.
(get_catch_syscall_inferior_data): Use "new".
(catch_syscall_inferior_data_cleanup): Use "delete".
(insert_catch_syscall, remove_catch_syscall)
(clear_syscall_counts): Update.

7 years agoUse std::vector in syscall_catchpoint
Tom Tromey [Mon, 17 Jul 2017 22:58:22 +0000 (16:58 -0600)]
Use std::vector in syscall_catchpoint

This changes syscall_catchpoint to use a std::vector rather than a VEC
for "syscalls_to_be_caught".  This simplifies the code a bit.

ChangeLog
2017-07-22  Tom Tromey  <tom@tromey.com>

* break-catch-syscall.c (syscall_catchpoint)
<syscalls_to_be_caught>: Now a std::vector<int>
(~syscall_catchpoint): Remove.
(insert_catch_syscall, remove_catch_syscall)
(breakpoint_hit_catch_syscall, print_one_catch_syscall)
(print_mention_catch_syscall, print_recreate_catch_syscall):
Update.
(create_syscall_event_catchpoint): Change type of "filter"
parameter.
(catch_syscall_split_args): Return a std::vector.
(catch_syscall_command_1, catching_syscall_number_1): Update.

7 years agoC++-ify break-catch-throw
Tom Tromey [Sat, 3 Jun 2017 14:06:36 +0000 (08:06 -0600)]
C++-ify break-catch-throw

This changes exception_catchpoint's "exception_rx' member to be a
std::string, and updating the users.

ChangeLog
2017-07-22  Tom Tromey  <tom@tromey.com>

* break-catch-throw.c (struct exception_catchpoint)
<exception_rx>: Now a std::string.
(~exception_catchpoint): Remove.
(print_one_detail_exception_catchpoint): Update.
(handle_gnu_v3_exceptions): Change type of except_rx.
(extract_exception_regexp): Return a std::string.
(catch_exception_command_1): Update.

7 years agoC++-ify break-catch-sig
Tom Tromey [Sat, 3 Jun 2017 13:53:26 +0000 (07:53 -0600)]
C++-ify break-catch-sig

This changes signal_catchpoint to be more of a C++ class, using
std::vector and updating the users.

ChangeLog
2017-07-22  Tom Tromey  <tom@tromey.com>

* break-catch-sig.c (gdb_signal_type): Remove typedef.
(struct signal_catchpoint) <signals_to_be_caught>: Now a
std::vector.
<catch_all>: Now a bool.
(~signal_catchpoint): Remove.
(signal_catchpoint_insert_location)
(signal_catchpoint_remove_location)
(signal_catchpoint_breakpoint_hit, signal_catchpoint_print_one)
(signal_catchpoint_print_mention)
(signal_catchpoint_print_recreate)
(signal_catchpoint_explains_signal): Update.
(create_signal_catchpoint): Change type of "filter" and
"catch_all".
(catch_signal_split_args): Return a std::vector.  Change type of
"catch_all".
(catch_signal_command): Update.

7 years agoAutomatic date update in version.in
GDB Administrator [Sat, 22 Jul 2017 00:00:45 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agogdb.python/py-unwind: Disable stack protection
Simon Marchi [Fri, 21 Jul 2017 22:01:03 +0000 (00:01 +0200)]
gdb.python/py-unwind: Disable stack protection

[I made some typo fixes but forgot to amend my commit before sending the patch,
 hence this v2.]

I see the following failure on Ubuntu 16.04's gcc 5.4.0:

Running /home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.python/py-unwind.exp ...
FAIL: gdb.python/py-unwind.exp: continue to breakpoint: break backtrace-broken
FAIL: gdb.python/py-unwind.exp: Backtrace restored by unwinder (pattern 1)

The problem is that the test expects a very particular stack layout.
When stack protection is enabled, it adds a canary value which looks
like an additional local variable.  This makes the test complain about
a bad stack layout and fail.

The simple solution is to disable stack protection for that test using
-fno-stack-protector.  I checked older compilers (gcc 4.4, clang 3.5)
and they support that flag, so I don't think it's necessary to probe for
whether the compiler supports it.

Maybe a better solution would be to change the test to make it cope with
different stack layouts (perhaps it could save addresses of stuff in
some global variables which GDB/the unwinder would read).  I'll go with
the simple solution for now though.

gdb/testsuite/ChangeLog:

* gdb.python/py-unwind.exp: Disable stack protection when
building test file.

7 years agoUpdated French translation for the binutils subdirectory.
Nick Clifton [Fri, 21 Jul 2017 15:01:34 +0000 (16:01 +0100)]
Updated French translation for the binutils subdirectory.

* po/fr.po: Updated French translation.

7 years agoFix typo in warning message.
Nick Clifton [Fri, 21 Jul 2017 14:56:54 +0000 (15:56 +0100)]
Fix typo in warning message.

PR 21810
* dwarf.c (display_gdb_index): Fix typo in warning message.

7 years agoRemove unused variables in dwarf parser.
Simon Marchi [Fri, 21 Jul 2017 10:42:21 +0000 (11:42 +0100)]
Remove unused variables in dwarf parser.

* dwarf.c (last_pointer_size, warned_about_missing_comp_units):
Remove.
(load_debug_info): Remove assignments to those two variables.

7 years agoThis patch introduces support for specifing views in .loc directives, so that the...
Alexandre Oliva [Fri, 21 Jul 2017 09:09:06 +0000 (10:09 +0100)]
This patch introduces support for specifing views in .loc directives, so that the compiler can use the assembler to generate line number information and have the assembler determine view numbers to multiple views at the same program counter.

binutils* dwarf.c (struct State_Machine_Registers): Add view field.
(reset_state_machine): Reset view.
(process_extended_line_op): Reset view when appropriate.
(display_debug_lines_raw): Increment or reset view when appropriate.
Print nonzero views.  Support print view resets, disabled by default.
(display_debug_lines_decoded): Likewise.  Disambiguate op_code tests,
enabling printing of end_sequence.
* testsuite/binutils-all/dw2-1.W: Add nonzero views.
* testsuite/binutils-all/dw2-3.W: Likewise.
* testsuite/binutils-all/dw2-3gabi.W: Likewise.
* testsuite/binutils-all/dw5.W: Add end sequence lines.
* testsuite/binutils-all/i386/compressed-1a.d: Add nonzero views.
* testsuite/binutils-all/libdw2-compressedgabi.out: Likewise.
* testsuite/binutils-all/objdump.W: Likewise.
* testsuite/binutils-all/objdump.WL: Add end sequence lines.
* testsuite/binutils-all/x86-64/compressed-1a.d: Add nonzero views.

gas * doc/as.texinfo (.loc): Document view support.
* dwarf2dbg.c (unused): Check offset of next in struct line_entry.
(current): Initialize view.
(force_reset_view, view_assert_failed): New variables.
(reverse_line_entry_list): New function.
(set_or_check_view): Likewise.
(dwarf2_gen_line_info_1): Call it.
(dwarf2_where): Set view to NULL.
(dwarf2_emit_insn): Return early when called before first file.
(dwarf2_directive_loc): Add view support.  Emit insn
immediately when view option is given.
(process_entries): Avoid set_address to reset view when a known
address change already implies the view reset.
(dwarf2dbg_final_check): New function.
* dwarf2dbg.h (struct dwarf2_line_info): Add view.
(dwarf2dbg_final_check): Declare.
* read.c (s_leb128): Parse expression as deferred.
* testsuite/gas/all/gas.exp: Run sleb128-9.
* testsuite/gas/all/sleb128-9.d: New.
* testsuite/gas/all/sleb128-9.l: New.
* testsuite/gas/all/sleb128-9.s: New.
* testsuite/gas/elf/dwarf2-1.d: Add nonzero views.
* testsuite/gas/elf/dwarf2-2.d: Likewise.
* testsuite/gas/elf/dwarf2-5.d: New.
* testsuite/gas/elf/dwarf2-5.s: New.
* testsuite/gas/elf/dwarf2-6.d: New.
* testsuite/gas/elf/dwarf2-6.s: New.
* testsuite/gas/elf/dwarf2-7.d: New.
* testsuite/gas/elf/dwarf2-7.s: New.
* testsuite/gas/elf/dwarf2-8.d: New.
* testsuite/gas/elf/dwarf2-8.l: New.
* testsuite/gas/elf/dwarf2-8.s: New.
* testsuite/gas/elf/dwarf2-9.d: New.
* testsuite/gas/elf/dwarf2-9.l: New.
* testsuite/gas/elf/dwarf2-9.s: New.
* testsuite/gas/elf/dwarf2-10.d: New.
* testsuite/gas/elf/dwarf2-10.l: New.
* testsuite/gas/elf/dwarf2-10.s: New.
* testsuite/gas/elf/dwarf2-11.d: New.
* testsuite/gas/elf/dwarf2-11.s: New.
* testsuite/gas/elf/dwarf2-12.d: New.
* testsuite/gas/elf/dwarf2-12.s: New.
* testsuite/gas/elf/dwarf2-13.d: New.
* testsuite/gas/elf/dwarf2-13.s: New.
* testsuite/gas/elf/dwarf2-14.d: New.
* testsuite/gas/elf/dwarf2-14.s: New.
* testsuite/gas/elf/dwarf2-15.d: New.
* testsuite/gas/elf/dwarf2-15.s: New.
* testsuite/gas/elf/dwarf2-16.d: New.
* testsuite/gas/elf/dwarf2-16.s: New.
* testsuite/gas/elf/dwarf2-17.d: New.
* testsuite/gas/elf/dwarf2-17.s: New.
* testsuite/gas/elf/dwarf2-18.d: New.
* testsuite/gas/elf/dwarf2-18.s: New.
* testsuite/gas/elf/elf.exp: Run dwarf2-5..18 tests.
* testsuite/gas/i386/dw2-compress-1.d: Add nonzero views.
* testsuite/gas/i386/dw2-compressed-1.d: Likewise.
* testsuite/gas/i386/ilp32/lns/lns-duplicate.d: Likewise.
* testsuite/gas/lns/lns-big-delta.d: Likewise.
* testsuite/gas/lns/lns-duplicate.d: Likewise.
* testsuite/gas/mips/loc-swap-2.d: Likewise.
* testsuite/gas/mips/loc-swap-3.d: Likewise.
* testsuite/gas/mips/loc-swap.d: Likewise.
* testsuite/gas/mips/micromips@loc-swap-2.d: Likewise.
* testsuite/gas/mips/micromips@loc-swap.d: Likewise.
* testsuite/gas/mips/mips16@loc-swap-2.d: Likewise.
* testsuite/gas/mips/mips16@loc-swap.d: Likewise.
* testsuite/gas/mips/mips16e@loc-swap.d: Likewise.
* write.c (write_object_file): Check pending view asserts.
(cvt_frag_to_fill): Complain about undefined leb128 operand.

7 years agoS/390: Support z14 as CPU name.
Andreas Krebbel [Fri, 21 Jul 2017 08:54:06 +0000 (10:54 +0200)]
S/390: Support z14 as CPU name.

With IBM z14 officially announced I can add z14 as CPU name.

No regressions with that patch on s390x.

gas/ChangeLog:

2017-07-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* config/tc-s390.c (s390_parse_cpu): Add z14 as alternate CPU
name.
* doc/as.texinfo: Add z14 to CPU string list.
* doc/c-s390.texi: Likewise.

opcodes/ChangeLog:

2017-07-21  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

* s390-mkopc.c (main): Enable z14 as CPU string in the opcode
table.

7 years agoAutomatic date update in version.in
GDB Administrator [Fri, 21 Jul 2017 00:00:33 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoMake language_def O(1)
Pedro Alves [Thu, 20 Jul 2017 17:28:01 +0000 (18:28 +0100)]
Make language_def O(1)

Profiling GDB with the rest of series applied, I saw calls to
language_def showing up high in some runs.  The problem is that
language_def is O(N) currently, since walk the languages vector each
time to find the matching language_defn.

IMO, the add_language mechanism is pointless, because "enum language"
implies the core of GDB needs to know about all languages anyway.  So
simply make the languages vector array be an array where each
element's index is the corresponding enum language enumerator.  Note
that "local_language_defn" is gone along the way.  It's just a copy of
"auto", so the new code simply maps one to the other.  One fewer place
to update when we need to change the language vector...

Also, a while ago the output of "set language" was made out of order
as side effect of some other change.  While I was at it, I made them
sorted again.

gdb/ChangeLog:
2017-07-20  Pedro Alves  <palves@redhat.com>

* ada-lang.c (ada_language_defn): Make extern.
(_initialize_ada_language): Remove add_language call.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Make extern.
(_initialize_c_language): Delete.
* completer.c (compare_cstrings): Delete, moved to utils.h.
* d-lang.c (d_language_defn): Make extern.
(_initialize_d_language): Remove add_language calls.
* defs.h (enum language): Add comment.
* f-lang.c (f_language_defn): Make extern.
(_initialize_f_language): Remove add_language call.
* go-lang.c (go_language_defn): Make extern.
(_initialize_go_language): Remove add_language call.
* language.c: Include <algorithm>.
(languages): Redefine as const array.
(languages_size, languages_allocsize, DEFAULT_ALLOCSIZE): Delete.
(set_language_command): Handle "local".  Use for-range loop.
(set_language): Remove loop.
(language_enum): Rewrite.
(language_def, language_str): Remove loops.
(add_language): Delete.
(add_set_language_command): New, based on add_languages.
(skip_language_trampoline): Adjust.
(local_language_defn): Delete.
(language_gdbarch_post_init): Adjust.
(_initialize_language): Remove add_language calls.  Call
add_set_language_command.
* language.h (add_language): Delete.
(auto_language_defn)
(unknown_language_defn, minimal_language_defn, ada_language_defn)
(asm_language_defn, c_language_defn, cplus_language_defn)
(d_language_defn, f_language_defn, go_language_defn)
(m2_language_defn, objc_language_defn, opencl_language_defn)
(pascal_language_defn, rust_language_defn): Declare.
* m2-lang.c (m2_language_defn): Make extern.
(_initialize_m2_language): Remove add_language call.
* objc-lang.c (objc_language_defn): Make extern.
(_initialize_objc_language): Remove add_language call.
* opencl-lang.c (opencl_language_defn): Make extern.
(_initialize_opencl_language): Remove add_language call.
* p-lang.c (pascal_language_defn): Make extern.
(_initialize_pascal_language): Delete.
* rust-lang.c (rust_language_defn): Make extern.
(_initialize_rust_language): Delete.
* utils.h (compare_cstrings): New static inline function.

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

* gdb.base/default.exp (set language): Adjust expected output.

7 years agoget_int_var_value
Pedro Alves [Thu, 20 Jul 2017 17:12:19 +0000 (18:12 +0100)]
get_int_var_value

I noticed that get_int_var_value's parameters could use some
constification.  And then realized that client code would become
simpler by changing the interface to return the success/failure
indication as actual return value, as it allows getting rid of the
local "boolean" variable.

gdb/ChangeLog:
2017-07-20  Pedro Alves  <palves@redhat.com>

* ada-lang.c (ada_to_fixed_type_1): Adjust.
(get_var_value): Constify parameters.
(get_int_var_value): Change prototype.
(to_fixed_range_type): Adjust.
* ada-lang.h (get_int_var_value): Change prototype.

7 years agoUse SYMBOL_MATCHES_SEARCH_NAME some more
Pedro Alves [Thu, 20 Jul 2017 17:06:13 +0000 (18:06 +0100)]
Use SYMBOL_MATCHES_SEARCH_NAME some more

gdb/ChangeLog:
2017-07-20  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (dw2_lookup_symbol): Use
SYMBOL_MATCHES_SEARCH_NAME.
* psymtab.c (psym_lookup_symbol): Use SYMBOL_MATCHES_SEARCH_NAME.

7 years agoEliminate block_iter_name_*
Pedro Alves [Thu, 20 Jul 2017 17:04:46 +0000 (18:04 +0100)]
Eliminate block_iter_name_*

This patch gets rid of block_iter_name_* as being unnecessary.  It's
the same as calling block_iter_match_*, and passing strcmp_iw as
comparison routine.

(A later patch will get rid of those new explicit strcmp_iw calls.)

gdb/ChangeLog:
2017-07-20  Pedro Alves  <palves@redhat.com>

* block.c (block_iter_name_step, block_iter_name_first)
(block_iter_name_next): Delete.
(block_lookup_symbol_primary): Adjust to use
dict_iter_match_first/dict_iter_match_next.
* block.h (block_iter_name_first, block_iter_name_next): Delete
declarations.
(ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use
dict_iter_match_first/dict_iter_match_next.

7 years agoFix cp_find_first_component_aux bug
Pedro Alves [Thu, 20 Jul 2017 16:58:17 +0000 (17:58 +0100)]
Fix cp_find_first_component_aux bug

Valgrind catches an out-of-bounds read here:

 $ gdb ./testsuite/outputs/gdb.cp/method2/method2
 (gdb) start
 [...]
 Temporary breakpoint 1, main (argc=1, argv=0x7fffffffd958) at src/gdb/testsuite/gdb.cp/method2.cc:26
 26        return 0;
 (gdb) b A::operator
 ==26907== Invalid read of size 1
 ==26907==    at 0x75C0AE: cp_find_first_component_aux(char const*, int) (cp-support.c:951)
 ==26907==    by 0x75C084: cp_find_first_component(char const*) (cp-support.c:925)
 ==26907==    by 0x75C3DA: cp_entire_prefix_len(char const*) (cp-support.c:1089)
 ==26907==    by 0x758B16: cp_lookup_symbol_in_namespace(char const*, char const*, block const*, domain_enum_tag, int) (cp-namespace.c:314)
 ==26907==    by 0x75972A: lookup_namespace_scope(language_defn const*, char const*, block const*, domain_enum_tag, char const*, int) (cp-namespace.c:739)
 ==26907==    by 0x7597CB: cp_lookup_symbol_nonlocal(language_defn const*, char const*, block const*, domain_enum_tag) (cp-namespace.c:768)
 ==26907==    by 0x8C1137: lookup_symbol_aux(char const*, block const*, domain_enum_tag, language, field_of_this_result*) (symtab.c:2016)
 ==26907==    by 0x8C098A: lookup_symbol_in_language(char const*, block const*, domain_enum_tag, language, field_of_this_result*) (symtab.c:1824)
 ==26907==    by 0x8C0A04: lookup_symbol(char const*, block const*, domain_enum_tag, field_of_this_result*) (symtab.c:1836)
 ==26907==    by 0x82CBE1: find_label_symbols(linespec_state*, VEC_symbolp*, VEC_symbolp**, char const*) (linespec.c:3390)
 ==26907==    by 0x828FB5: linespec_parse_basic(ls_parser*) (linespec.c:1620)
 ==26907==    by 0x82A78F: parse_linespec(ls_parser*, char const*) (linespec.c:2307)
 ==26907==  Address 0x910f97c is 0 bytes after a block of size 12 alloc'd
 ==26907==    at 0x4C28BF6: malloc (vg_replace_malloc.c:299)
 ==26907==    by 0x74E737: xmalloc (common-utils.c:43)
 ==26907==    by 0x74EAF4: savestring(char const*, unsigned long) (common-utils.c:179)
 ==26907==    by 0x826CEF: copy_token_string(ls_token) (linespec.c:488)
 ==26907==    by 0x828EF6: linespec_parse_basic(ls_parser*) (linespec.c:1599)
 ==26907==    by 0x82A78F: parse_linespec(ls_parser*, char const*) (linespec.c:2307)
 ==26907==    by 0x82AE27: event_location_to_sals(ls_parser*, event_location const*) (linespec.c:2469)
 ==26907==    by 0x82B1CE: decode_line_full(event_location const*, int, program_space*, symtab*, int, linespec_result*, char const*, char const*) (linespec.c:2557)
 ==26907==    by 0x720C8A: parse_breakpoint_sals(event_location const*, linespec_result*) (breakpoint.c:9550)
 ==26907==    by 0x72A2F7: create_sals_from_location_default(event_location const*, linespec_result*, bptype) (breakpoint.c:14484)
 ==26907==    by 0x727F86: bkpt_create_sals_from_location(event_location const*, linespec_result*, bptype) (breakpoint.c:13219)
 ==26907==    by 0x72146D: create_breakpoint(gdbarch*, event_location const*, char*, int, char*, int, int, bptype, int, auto_boolean, breakpoint_ops const*, int, int, int, unsigned int) (breakpoint.c:9759)

Tests exercising this will be added further down the series.

gdb/ChangeLog:
2017-07-20  Pedro Alves  <palves@redhat.com>

* cp-support.c (cp_find_first_component_aux): Add missing case for
end of string.

7 years agoMake gdb.base/dmsym.exp independent of "set language ada"
Pedro Alves [Thu, 20 Jul 2017 16:52:03 +0000 (17:52 +0100)]
Make gdb.base/dmsym.exp independent of "set language ada"

This test is using "set language ada" expecting that to cause GDB to
do Ada symbol name matching.  That won't work when GDB uses the
symbol's language to decide which symbol matching algorithm to use,
because the test's symbols are C symbols.

So generalize the test a bit to not rely on Ada name matching rules.

Confirmed that by undoing the original fix the test was written for,
the test still fails.

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

* gdb.base/dmsym.c (pck__foo__bar__minsym): Rename to ...
(test_minsym): ... this, and make static.
(get_pck__foo__bar__minsym): Rename to ...
(get_test_minsym): ... this.
* gdb.base/dmsym.exp (): Remove "set language ada" call.  Adjust
symbol names and comments.
* gdb.base/dmsym_main.c (get_pck__foo__bar__minsym): Rename to ...
(get_test_minsym): ... this.
(pck__foo__bar__minsym__2): Rename to ...
(test_minsym): ... this.
(main): Adjust.

7 years agoUpdate the German translation for the opcodes library.
Nick Clifton [Thu, 20 Jul 2017 10:47:16 +0000 (11:47 +0100)]
Update the German translation for the opcodes library.

* po/de.po: Updated German translation.

7 years agoAutomatic date update in version.in
GDB Administrator [Thu, 20 Jul 2017 00:00:34 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoPR ld/16656: Add missing annotation to the relevant ChangeLog entries
Maciej W. Rozycki [Wed, 19 Jul 2017 23:39:57 +0000 (00:39 +0100)]
PR ld/16656: Add missing annotation to the relevant ChangeLog entries

Add PR ld/16656 annotation to ChangeLog entries for commit 9a0f1d5099fa
("LD/testsuite: Conditionalize the placement of `.dynamic' in
GNU_RELRO") and commit ("LD/testsuite: Conditionalize the placement of
`.got' in GNU_RELRO").

7 years ago[AArch64] Fix PR18841 ifunc relocation ordering
Szabolcs Nagy [Tue, 4 Jul 2017 14:43:59 +0000 (15:43 +0100)]
[AArch64] Fix PR18841 ifunc relocation ordering

In order to get the ifunc relocs properly sorted the correct class
needs to be returned.  The code mimics what has been done for x86.

Fixes
FAIL: Run pr18841 with libpr18841c.so

bfd/
PR ld/18841
* elfnn-aarch64.c (elfNN_aarch64_reloc_type_class): Return
reloc_class_ifunc for ifunc symbols.

7 years agoExtend previous fix to coff-rs6000.c to coff64-rs6000.c
Nick Clifton [Wed, 19 Jul 2017 15:14:02 +0000 (16:14 +0100)]
Extend previous fix to coff-rs6000.c to coff64-rs6000.c

PR 21786
* coff64-rs6000.c (_bfd_strntol): New function.
(_bfd_strntoll): New function.
(GET_VALUE_IN_FIELD): New macro.
(xcoff64_slurp_armap): Use new macros.

7 years agoFix use-after-free error when parsing a corrupt nested archive.
Nick Clifton [Wed, 19 Jul 2017 13:49:12 +0000 (14:49 +0100)]
Fix use-after-free error when parsing a corrupt nested archive.

PR 21787
* archive.c (bfd_generic_archive_p): If the bfd does not have the
correct magic bytes at the start, set the error to wrong format
and clear the format selector before returning NULL.

7 years agoLD/testsuite: Add 2**4 section alignment FILL script statement test
Maciej W. Rozycki [Wed, 19 Jul 2017 12:11:59 +0000 (13:11 +0100)]
LD/testsuite: Add 2**4 section alignment FILL script statement test

Complement commit ffe54b3798db ("Pad sections according to current
script FILL.") and add a FILL script statement test for targets that
impose the minimum alignment of more than 2**2 for the `.text' section.
These targets include IA-64 targets, MIPS targets other than bare-metal
ELF and VxWorks, TILE-Gx targets, TILEPro targets and X86-64 PE targets.

Use the `notarget' tag for configuration triplets that are incompatible
with the new test, but are supported by the existing FILL test, and
`xfail' for ones that have issues due to section alignment or padding
with both tests.  Make a complementary change to the existing FILL test,
removing the following test issues:

arm-epoc-pe  -FAIL: ld-scripts/fill
mips-elf  -XPASS: ld-scripts/fill
mips-img-elf  -XPASS: ld-scripts/fill
mips-mti-elf  -XPASS: ld-scripts/fill
mips-sde-elf  -XPASS: ld-scripts/fill
mips-vxworks  -XPASS: ld-scripts/fill
mipsel-elf  -XPASS: ld-scripts/fill
mipsel-img-elf  -XPASS: ld-scripts/fill
mipsel-mti-elf  -XPASS: ld-scripts/fill
mipsel-vxworks  -XPASS: ld-scripts/fill
mipsisa32-elf  -XPASS: ld-scripts/fill
mipsisa32el-elf  -XPASS: ld-scripts/fill
mipsisa64-elf  -XPASS: ld-scripts/fill
mipsisa64el-elf  -XPASS: ld-scripts/fill
tilegx-linux  -FAIL: ld-scripts/fill
tilepro-elf  -FAIL: ld-scripts/fill
tx39-elf  -XPASS: ld-scripts/fill

ld/
* testsuite/ld-scripts/fill.d: Adjust `xfail' entries.  Add
`notarget' entries.  Update comments.
* testsuite/ld-scripts/fill16.d: New test.
* testsuite/ld-scripts/fill16_0.s: New test source.
* testsuite/ld-scripts/fill16_1.s: New test source.
* testsuite/ld-scripts/fill16_2.s: New test source.
* testsuite/ld-scripts/data.exp: Run the new test.

7 years agoFix address violation when attempting to read a corrupt field in a COFF archive heade...
Nick Clifton [Wed, 19 Jul 2017 10:07:43 +0000 (11:07 +0100)]
Fix address violation when attempting to read a corrupt field in a COFF archive header structure.

PR 21786
* coff-rs6000.c (_bfd_strntol): New function.
(_bfd_strntoll): New function.
(GET_VALUE_IN_FIELD): New macro.
(EQ_VALUE_IN_FIELD): new macro.
(_bfd_xcoff_slurp_armap): Use new macros.
(_bfd_xcoff_archive_p): Likewise.
(_bfd_xcoff_read_ar_hdr): Likewise.
(_bfd_xcoff_openr_next_archived_file): Likewise.
(_bfd_xcoff_stat_arch_elt): Likewise.

7 years ago[ARC] Add SecureShield AUX registers
claziss [Wed, 19 Jul 2017 07:56:55 +0000 (09:56 +0200)]
[ARC] Add SecureShield AUX registers

Update auxiliary registers with SecureShield ones.

opcodes/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>

* arc-regs.h (sec_stat): New aux register.
(aux_kernel_sp): Likewise.
(aux_sec_u_sp): Likewise.
(aux_sec_k_sp): Likewise.
(sec_vecbase_build): Likewise.
(nsc_table_top): Likewise.
(nsc_table_base): Likewise.
(ersec_stat): Likewise.
(aux_sec_except): Likewise.

7 years ago[ARC] Add SJLI instruction.
Claudiu Zissulescu [Wed, 19 Jul 2017 07:56:55 +0000 (09:56 +0200)]
[ARC] Add SJLI instruction.

include/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>

* opcode/arc.h (SJLI): Add.

opcode/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>

* arc-opc.c (extract_uimm12_20): New function.
(UIMM12_20): New operand.
(SIMM3_5_S): Adjust.
* arc-tbl.h (sjli): Add new instruction.

7 years ago[ARC] Add JLI support.
John Eric Martin [Wed, 19 Jul 2017 07:56:55 +0000 (09:56 +0200)]
[ARC] Add JLI support.

The following relocation types were added to GCC/binutils:

ARC_JLI_SECTOFF is a relocation type in Metaware that is now used by
GCC as well to adjust the index of function calls to functions with
attribute jli_call_always.

bfd/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
    John Eric Martin  <John.Martin@emmicro-us.com>

* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-arc.c (JLI): Define.
* reloc.c: Add JLI relocations.

gas/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/gas/arc/jli-1.d: New file.
* testsuite/gas/arc/jli-1.s: Likewise.
* testsuite/gas/arc/taux.d: Update for jli_base.

include/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
    John Eric Martin  <John.Martin@emmicro-us.com>

* elf/arc-reloc.def: Add JLI relocs howto.
* opcode/arc-func.h (replace_jli): New function.

ld/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
    John Eric Martin  <John.Martin@emmicro-us.com>

* emulparams/arcelf.sh (JLI_START_TABLE): Define.
* scripttempl/elfarc.sc: Handle jlitab section.
* scripttempl/elfarcv2.sc: Likewise.
* testsuite/ld-arc/arc.exp: Add JLI test.
* testsuite/ld-arc/jli-script.ld: New file.
* testsuite/ld-arc/jli-simple.dd: Likewise.
* testsuite/ld-arc/jli-simple.rd: Likewise.
* testsuite/ld-arc/jli-simple.s: Likewise.
* testsuite/ld/testsuite/ld-arc/jli-overflow.s: Likewise.
* testsuite/ld/testsuite/ld-arc/jli-overflow.d: Likewise.
* testsuite/ld/testsuite/ld-arc/jli-overflow.err: Likewise.

opcode/
2017-07-19  Claudiu Zissulescu  <claziss@synopsys.com>
    John Eric Martin  <John.Martin@emmicro-us.com>

* arc-opc.c (UIMM10_6_S_JLIOFF): Define.
(UIMM3_23): Adjust accordingly.
* arc-regs.h: Add/correct jli_base register.
* arc-tbl.h (jli_s): Likewise.

7 years agoRemove datasize measurements based on sbrk()
Tristan Gingold [Wed, 19 Jul 2017 07:55:12 +0000 (09:55 +0200)]
Remove datasize measurements based on sbrk()

binutils/
* nm.c (show_stats): Remove variable.
(long_options): Remove --stats option.
(main): Remove handling of --stats.

ld/
* ldmain.c (main): Remove display of data size.

gas/
* as.c (start_sbrk): Remove.
(main): Remove assignment.
(dump_statistics): Remove display of data size.

7 years agoFix gas crash on missing seh_endproc.
Tristan Gingold [Wed, 19 Jul 2017 06:05:30 +0000 (08:05 +0200)]
Fix gas crash on missing seh_endproc.

gas/
* testsuite/gas/pe/seh-x64-err-2.s: New test.
* testsuite/gas/pe/seh-x64-err-2.l: New stderr output.
* testsuite/gas/pe/pe.exp: Add test.
* config/obj-coff-seh.c (obj_coff_seh_do_final): Don't try to end
seh part.

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

7 years agoLD/testsuite: Conditionalize the placement of `.got' in GNU_RELRO
Maciej W. Rozycki [Tue, 18 Jul 2017 16:20:30 +0000 (17:20 +0100)]
LD/testsuite: Conditionalize the placement of `.got' in GNU_RELRO

Complement commit d345186d0535 ("Check if GNU_RELRO segment is is
generated") and exclude the presence of a `.got' section from implying
the creation of a GNU_RELRO segment for targets which place the section
along with small data, and therefore as it stands cannot have the
section assigned to GNU_RELRO.  This is because we currently only
support a single GNU_RELRO segment and we place it at the beginning of
regular data which is then separated from small data by read-write data.

Currently the list of such targets consists of Alpha, Linux HPPA, NetBSD
HPPA, OpenBSD HPPA, Meta, MIPS, Nios II, OpenRISC 1000, RISC-V, SH and
X86-64, as determined by examining default linker scripts produced in a
`--enable-targets=all' build for those that have DATA_SEGMENT_RELRO_END
set and `.got' placed beyond.  These targets do not set NO_SMALL_DATA or
DATA_GOT in their respective files in ld/emulparams/*, hovever checking
for the absence of these settings on its own is not very feasible due to
the structure of these files and the lack of support for GNU_RELRO by
some targets in the first place.

Add a separate control for `.got.plt' which does get placed in GNU_RELRO
on MIPS targets even though `.got' does not.

ld/
* testsuite/ld-elf/binutils.exp (binutils_test): Make the
expectation for `.got' in GNU_RELRO segment target-specific.
Handle `.got.plt' separately.

7 years agoLD/testsuite: Conditionalize the placement of `.dynamic' in GNU_RELRO
Maciej W. Rozycki [Tue, 18 Jul 2017 16:20:30 +0000 (17:20 +0100)]
LD/testsuite: Conditionalize the placement of `.dynamic' in GNU_RELRO

Complement commit d345186d0535 ("Check if GNU_RELRO segment is is
generated") and exclude the presence of a `.dynamic' section from
implying the creation of a GNU_RELRO segment for targets which place the
section in the (read-only) text segment, and therefore cannot have the
section assigned to GNU_RELRO and neither it would make sense.

Currently the list of such targets consists of 64-bit HPPA and
non-VxWorks MIPS targets, as determined by looking for TEXT_DYNAMIC
being set across ld/emulparams/* and then verified by examining default
linker scripts produced in a `--enable-targets=all' build.

ld/
* testsuite/ld-elf/binutils.exp (binutils_test): Make the
expectation for `.dynamic' in GNU_RELRO segment target-specific.

7 years agoFix spelling typos.
Yuri Chornovian [Tue, 18 Jul 2017 15:58:14 +0000 (16:58 +0100)]
Fix spelling typos.

7 years agoFix Fission (broken by my previous patch)
David Blaikie [Tue, 18 Jul 2017 15:06:17 +0000 (16:06 +0100)]
Fix Fission (broken by my previous patch)

Turns out somewhere along the refactoring of the multiple-CU support
for Fission I broke the patch before submitting it (& seems to have
broken Fission support generally).

Syncing back to the point at which the patch was committed, the
previous test results on my machine are:

 expected passes: 36137
 unexpected failures: 416

with the previous (broken) patch committed:

 expected passes: 36131
 unexpected failures: 429

With this one line patch applied on top of the broken commit:

 expected passes: 36144
 unexpected failures: 416

(& all other result counts remained the same in all 3 cases)

gdb/ChangeLog:
2017-07-18  David Blaikie  <dblaikie@gmail.com>

* dwarf2read.c (create_cus_hash_table): Re-add lost initialization
of dwo_cu's dwo_file.

7 years agoFix runtime failure triggered by a corrupt ecoff input file.
Nick Clifton [Tue, 18 Jul 2017 14:46:13 +0000 (15:46 +0100)]
Fix runtime failure triggered by a corrupt ecoff input file.

PR binutils/21781
* coffcode.h (handle_COMDAT): Replace abort with an error message
and return.

7 years agoRemove one line comment
Yao Qi [Tue, 18 Jul 2017 11:57:19 +0000 (12:57 +0100)]
Remove one line comment

This patch is going to remove a line comment, which was added in this
commit,

commit 55fea07
Author: Jim Kingdon <jkingdon@engr.sgi.com>
Date:   Tue Sep 14 01:08:22 1993 +0000

        * remote.c: Define remote_debug to 0 and #if 0 baud_rate.  Temporary
        hack so this file compiles again.

        * remote-utils.c (gr_multi_scan): Cast return value from alloca.
        (gr_multi_scan): #if 0 never-reached return(-1).

and at that moment, remote_prepare_to_store does updates some global
state,

static void
remote_prepare_to_store ()
{
  /* Make sure the entire registers array is valid.  */
  read_register_bytes (0, (char *)NULL, REGISTER_BYTES);
}

However, now, remote_prepare_to_store doesn't do that at all, and
rsa->sizeof_g_packet is updated in init_remote_state, so the line of
comment is out of date, and this patch removes it.

gdb:

2017-07-18  Yao Qi  <yao.qi@linaro.org>

* remote.c (store_registers_using_G): Remove one line comment.

7 years agoSimplify regcache_cpy and remove regcache::cpy_no_passthrough
Yao Qi [Tue, 18 Jul 2017 11:46:14 +0000 (12:46 +0100)]
Simplify regcache_cpy and remove regcache::cpy_no_passthrough

Nowadays, regcache_cpy is used where src is read-only and dst is not
read-only, so the regcache_cpy can be simplified to handle this case only.
As a result, regcache::cpy_no_passthrough, which is about two read-only
regcache copy, is no longer used, remove it as well.

gdb:

2017-07-18  Yao Qi  <yao.qi@linaro.org>

* regcache.c (regcache_cpy): Simplify it.
(regcache::cpy_no_passthrough): Remove it.
* regcache.h (cpy_no_passthrough): Remove it.
(regcache_dup, regcache_cpy): Update comments.

7 years agoImprove doc about "maint print c-tdesc"
Yao Qi [Tue, 18 Jul 2017 11:39:22 +0000 (12:39 +0100)]
Improve doc about "maint print c-tdesc"

In my patch extending command "maint print c-tdesc"
(https://sourceware.org/ml/gdb-patches/2017-06/msg00286.html), Eli
raised some questions on the existing doc to this command.  It is not
very clear, so this patch improves it.  Eli approved it.

gdb/doc:

2017-07-18  Yao Qi  <yao.qi@linaro.org>

* gdb.texinfo (Maintenance Commands): Improve the doc to
command "maint print c-tdesc".

7 years agoImport updated Ukranian and Swedish translations.
Nick Clifton [Tue, 18 Jul 2017 11:18:01 +0000 (12:18 +0100)]
Import updated Ukranian and Swedish translations.

gas * po/uk.po: Updated Ukranian translation.

binutils* po/sv.po: Updated Swedish translation.

7 years agoFix GDB builds that include the simulator
Pedro Alves [Tue, 18 Jul 2017 10:38:17 +0000 (11:38 +0100)]
Fix GDB builds that include the simulator

The completer rewrite series missed adjusting target sim to the new
completion_tracker interface.

src/gdb/remote-sim.c: In function ‘void _initialize_remote_sim()’:
src/gdb/remote-sim.c:1350:46: error: invalid conversion from ‘VEC_char_ptr* (*)(cmd_list_element*, const char*, const char*)’ to ‘void (*)(cmd_list_element*, completion_tracker&, const char*, const char*)’ [-fpermissive]
   set_cmd_completer (c, sim_command_completer);
                                              ^

This commit fixes it, and also takes care to be exception safe (the
previous code would leak if growing the VEC throws).

Tested manually with a --target=arm-none-eabi build.

gdb/ChangeLog:
2017-07-18  Pedro Alves  <palves@redhat.com>

* remote-sim.c (sim_command_completer): Adjust to work with a
completion_tracker instead of a VEC.

7 years ago* dwarf.c (display_debug_names): Initialize hash_prev.
Hans-Peter Nilsson [Tue, 18 Jul 2017 10:14:38 +0000 (12:14 +0200)]
* dwarf.c (display_debug_names): Initialize hash_prev.

gcc-4.3.0 warns that it may be used uninitialized.  It takes a look
and a half at the code to understand that it's false.

7 years agoAutomatic date update in version.in
GDB Administrator [Tue, 18 Jul 2017 00:00:50 +0000 (00:00 +0000)]
Automatic date update in version.in

7 years agoi386: Add tests for PIE with undefined weak symbol
H.J. Lu [Mon, 17 Jul 2017 19:42:32 +0000 (12:42 -0700)]
i386: Add tests for PIE with undefined weak symbol

* testsuite/ld-i386/i386.exp: Run pie1 and pie1-nacl.
* testsuite/ld-i386/pie1-nacl.d: New file.
* testsuite/ld-i386/pie1.d: Likewise.
* testsuite/ld-i386/pie1.s: Likewise.

7 years agoAdd missing ChangeLog entries for PR ld/21782 fix
H.J. Lu [Mon, 17 Jul 2017 19:40:57 +0000 (12:40 -0700)]
Add missing ChangeLog entries for PR ld/21782 fix

7 years agoA smarter linespec completer
Pedro Alves [Mon, 17 Jul 2017 19:08:02 +0000 (20:08 +0100)]
A smarter linespec completer

Continuing the theme of the explicit locations patch, this patch gets
rid of the need for quoting function names in linespec TAB completion.
To recap, when you have overloads in your program, and you want to set
a breakpoint in one of them:

 void function(int);  // set breakpoint here.
 void function(long);

 (gdb) b function(i[TAB]
 <all the symbols in the program that start with "i" are uselessly shown...>

This patch gets rid of the need for quoting by switching the linespec
completer to use the custom completion word point mechanism added in
the previous explicit location patch (extending it as needed), to
correctly determine the right completion word point.  In the case
above, we want the completer to figure out that it's completing a
function name that starts with "function(i", and it now does.

We also want the completer to know when it's potentially completing a
source file name, for:

(gdb) break source.[TAB] -> source.c:
(gdb) break source.c:  # Type line number or function name now

And we want it to know to complete label names, which it doesn't today:

(gdb) break function:lab[TAB]

etc., etc.

So what we want is for completion to grok the input string as closely
to how the linespec parser groks it.

With that in mind, the solution suggests itself - make the linespec
completer use the same parsing code as normal linespec parsing.

That's what the patch does.  The old completer is replaced by one that
reuses the actual linespec parser as much as possible.  This (ideally)
eliminate differences between what completion understands and actually
setting breakpoints understands by design.

The completer now offers sensible completion candidates depending on
which component of the linespec is being completed, source filename,
function, line number, expression, and (a new addition), labels.  For
example, when completing the function part, we now show the full name
of the method as completion candidates, instead of showing whatever
comes after what readline considered the word break character:

 (gdb) break klass::method[TAB]
 klass:method1(int)
 klass:method2()

If input is past the function, then we now offer keyword condidates:

  (gdb) b function(int) [TAB]
  if      task    thread

If input is past a keyword, we offer expression completion, which is
different from linespec completion:

  (gdb) b main if 1 + glo[TAB]
  global

(e.g., completes on types, struct data fields, etc.)

As mentioned, this teaches the linespec completer about completing
label symbols too:

  (gdb) b source.c:function:lab[TAB]

A nice convenience is that when completion uniquely matches a source
name, gdb adds the ":" automatically for you:

  (gdb) b filenam[TAB]
  (gdb) b filename.c:  # ':' auto-added, cursor right after it.

It's the little details.  :-)

I worked on this patch in parallel with writing the (big) testcase
added closer to the end of the series, which exercises many many
tricky cases around quoting and whitespace insertion placement.  In
general, I think it now all Just Works.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* completer.c (complete_source_filenames): New function.
(complete_address_and_linespec_locations): New function.
(location_completer): Use complete_address_and_linespec_locations.
(completion_tracker::build_completion_result): Honor the tracker's
request to suppress append.
* completer.h (completion_tracker::suppress_append_ws)
(completion_tracker::set_suppress_append_ws): New methods.
(completion_tracker::m_suppress_append_ws): New field.
(complete_source_filenames): New declaration.
* linespec.c (linespec_complete_what): New.
(struct ls_parser) <complete_what, completion_word,
completion_quote_char, completion_quote_end, completion_tracker>:
New fields.
(string_find_incomplete_keyword_at_end): New.
(linespec_lexer_lex_string): Record quote char.  If in completion
mode, don't throw.
(linespec_lexer_consume_token): Advance the completion word point.
(linespec_lexer_peek_token): Save/restore completion info.
(save_stream_and_consume_token): New.
(set_completion_after_number): New.
(linespec_parse_basic): Set what to complete next depending on
token.  Handle function and label completions specially.
(parse_linespec): Disable objc shortcut in completion mode.  Set
what to complete next depending on token type.  Skip keyword if in
completion mode.
(complete_linespec_component, linespec_complete): New.
* linespec.h (linespec_complete): Declare.

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

* gdb.base/completion.exp: Adjust expected output.
* gdb.linespec/ls-errs.exp: Don't send tab characters, now that
the completer works.

7 years agoLinespec lexing and C++ operators
Pedro Alves [Mon, 17 Jul 2017 19:28:12 +0000 (20:28 +0100)]
Linespec lexing and C++ operators

There's some lexing code in linespec that isn't handling C++ operators
correctly.  It's the usual confusion with operator< / operator<<, in
code that wants to skip past template parameters.

The linespec_lexer_lex_string change is necessary otherwise we get
this (with current master):

 (gdb) break 'operator<'
 unmatched quote

The need for the find_toplevel_char change was exposed by the use of
that function in the explicit location completer.  Without the fix,
that completer is not able to "see" past operator< symbols, without
quoting, like:

 (gdb) b -function operator<(int, int) -labe[TAB]    # nothing happens

gdb incorrectly thinks "-labe" is part of the "unclosed" template
parameter list started with "<".

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* linespec.c (linespec_lexer_lex_string, find_toplevel_char):
Handle 'operator<' / 'operator<<'.

7 years agoExplicit locations -label completer
Pedro Alves [Mon, 17 Jul 2017 19:24:41 +0000 (20:24 +0100)]
Explicit locations -label completer

We're missing a completer for

  (gdb) break -function func -label [TAB]

This patch adds one.  Tests will be added later in the series.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* completer.c (collect_explicit_location_matches): Handle
MATCH_LABEL.
(convert_explicit_location_to_linespec): New, factored out from
...
(convert_explicit_location_to_sals): ... this.
(complete_label): New.
(linespec_complete_label, find_label_symbols_in_block): New.
(find_label_symbols): Add completion_mode parameter and adjust to
call find_label_symbols_in_block.
* linespec.h (linespec_complete_label): Declare.

7 years agoRewrite/enhance explicit locations completer, parse left->right
Pedro Alves [Mon, 17 Jul 2017 19:21:33 +0000 (20:21 +0100)]
Rewrite/enhance explicit locations completer, parse left->right

One of the most annoying (to me) things about GDB's completion is when
you have overloads in your program, and you want to set a breakpoint
in one of them:

 void function(int);  // set breakpoint here.
 void function(long);

 (gdb) b -f func[TAB]
 (gdb) b -f function(       # ok, gdb completed as much as possible.
 (gdb) b -f function([TAB]  # show me the overloads, please.
 <_all_ symbols in the program are shown...>

E.g., when debugging GDB, that'd be:

 (gdb) b -f function([TAB]
 (anonymous namespace)::get_global()::global  pt_insn_get_offset@plt                       scm_new_port_table_entry
 asprintf                                     pt_pkt_alloc_decoder                         scm_new_port_table_entry@plt
 asprintf@plt                                 pt_pkt_alloc_decoder@plt                     scm_out_of_range
 bt_ctf_get_char_array                        pt_pkt_sync_forward                          scm_out_of_range@plt
 bt_ctf_get_char_array@plt                    pt_pkt_sync_forward@plt                      scm_putc
 bt_ctf_get_uint64                            pwrite                                       scm_putc@plt
 bt_ctf_get_uint64@plt                        pwrite@plt                                   scm_reverse_x
 bt_ctf_iter_read_event                       PyErr_Restore                                scm_reverse_x@plt
 bt_ctf_iter_read_event@plt                   PyErr_Restore@plt                            scm_set_port_filename_x
 <snip...>

Now that's a load of completely useless completions.

The reason GDB offers those is that the completer relies on readline
figuring out the completion word point in the input line based on the
language's word break characters, which include "(".  So readline
tells the completer to complete on "", the string that is after '('.
Likewise, if you type "function(i[TAB]" to try to complete to "int",
you're out of luck.  GDB shows you all the symbols in the program that
start with "i"...  This makes sense for the expression completer, as
what you'd want to type is e.g., a global variable, say:

(gdb) print function(i[TAB]

but, it makes no sense when specifying a function name for a
breakpoint location.

To get around that limitation, users need to quote the function name,
like:

 (gdb) b -f 'function([TAB]
 function(int)      function(long)
 (gdb) b 'function(i[TAB]
 (gdb) b 'function(int)' # now completes correctly!

Note that the quoting is only necessary for completion.  Creating the
breakpoint does not require the quoting:

 (gdb) b -f function(int) [RET]
 Breakpoint 1 at ....

This patch removes this limitation.

(
Actually, it's a necessary patch, though not sufficient.  That'll
start working correctly by the end of the series.  With this patch, if try it,
you'll see:

 (gdb) b -f function(i[TAB]
 (gdb) b -f function

i.e., gdb strips everything after the "(".  That's caused by some code
in symtab.c that'll be eliminated further down the series.  These
patches are all unfortunately interrelated, which is also the reason
new tests only appear much later in the series.
But let's ignore that reality for the remainder of the description.
)

So... this patch gets rid of the need for quoting.

It does that by adding a way for a completer to control the exact
completion word point that readline should start the completion
request for, instead of letting readline try to figure it out using
the current language's word break chars array, and often failing.

In the case above, we want the completer to figure out that it's
completing a function name that starts with "function(i".  It now
does.

It took me a while to figure out a way to ask readline to "use this
exact word point", and for a while I feared that it'd be impossible
with current readline (and having to rely on master readline for core
functionality is something I'd like to avoid very much).  Eventually,
after several different attempts, I came up with what is described in
the comment above gdb_custom_word_point_brkchars in the patch.

With this patch, the handle_brkchars phase of the explicit location
completer advances the expected word point as it parses the input line
left to right, until it figures out exactly what we're completing,
instead of expecting readline to break the string using the word break
characters, and then having the completer heuristically fix up a bad
decision by parsing the input string backwards.  This allows correctly
knowning that we're completing a symbol name after -function, complete
functions without quoting, etc.

Later, we'll make use of this same mechanims to implement a proper
linespec completer that avoids need for quoting too.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* ada-lang.c (ada_collect_symbol_completion_matches): Add
complete_symbol_mode parameter.
* cli/cli-cmds.c (complete_command): Get the completion result out
of the handle_brkchars tracker if used a custom word point.
* completer.c: Include "linespec.h".
(enum explicit_location_match_type) <MATCH_LINE>: New enumerator.
(advance_to_expression_complete_word_point): New.
(completion_tracker::completes_to_completion_word): New.
(complete_files_symbols): Pass down
complete_symbol_mode::EXPRESSION.
(explicit_options, probe_options): New.
(collect_explicit_location_matches): Complete on the
explictit_loc->foo instead of word.  Use
linespec_complete_function.  Handle MATCH_LINE.  Handle offering
keyword and options completions.
(backup_text_ptr): Delete.
(skip_keyword): New.
(complete_explicit_location): Remove 'word' parameter.  Add
language, quoted_arg_start and quoted_arg_end parameters.
Rewrite, parsing left to right.
(location_completer): Rewrite.
(location_completer_handle_brkchars): New function.
(symbol_completer): Pass down complete_symbol_mode::EXPRESSION.
(enum complete_line_internal_reason): Adjust comments.
(completion_tracker::discard_completions): New.
(completer_handle_brkchars_func_for_completer): Handle
location_completer.
(gdb_custom_word_point_brkchars)
(gdb_org_rl_basic_quote_characters): New.
(gdb_completion_word_break_characters_throw)
(completion_find_completion_word): Handle trackers that use a
custom word point.
(completion_tracker::advance_custom_word_point_by): New.
(completion_tracker::build_completion_result): Don't rely on
readline appending the quote char.
(gdb_rl_attempted_completion_function_throw): Handle trackers that
use a custom word point.
(gdb_rl_attempted_completion_function): Restore
rl_basic_quote_characters.
* completer.h (class completion_tracker): Extend intro comment.
(completion_tracker::set_quote_char)
(completion_tracker::quote_char)
(completion_tracker::set_use_custom_word_point)
(completion_tracker::use_custom_word_point)
(completion_tracker::custom_word_point)
(completion_tracker::set_custom_word_point)
(completion_tracker::advance_custom_word_point_by)
(completion_tracker::completes_to_completion_word)
(completion_tracker::discard_completions): New methods.
(completion_tracker::m_quote_char)
(completion_tracker::m_use_custom_word_point)
(completion_tracker::m_custom_word_point): New fields.
(advance_to_expression_complete_word_point): Declare.
* f-lang.c (f_collect_symbol_completion_matches): Add
complete_symbol_mode parameter.
* language.h (struct language_defn)
<la_collect_symbol_completion_matches>: Add complete_symbol_mode
parameter.
* linespec.c (linespec_keywords): Add NULL terminator.  Make extern.
(linespec_complete_function): New function.
(linespec_lexer_lex_keyword): Adjust.
* linespec.h (linespec_keywords, linespec_complete_function): New
declarations.
* location.c (find_end_quote): New function.
(explicit_location_lex_one): Add explicit_completion_info
parameter.  Save quoting info.  Don't throw if being called for
completion.  Don't handle Ada operators here.
(is_cp_operator, skip_op_false_positives, first_of)
(explicit_location_lex_one_function): New function.
(string_to_explicit_location): Replace 'dont_throw' parameter with
an explicit_completion_info pointer parameter.  Handle it.  Don't
use explicit_location_lex_one to lex function names.  Use
explicit_location_lex_one_function instead.
* location.h (struct explicit_completion_info): New.
(string_to_explicit_location): Replace 'dont_throw' parameter with
an explicit_completion_info pointer parameter.
* symtab.c (default_collect_symbol_completion_matches_break_on):
Add complete_symbol_mode parameter.  Handle LINESPEC mode.
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches): Add complete_symbol_mode
parameter.
(collect_symbol_completion_matches_type): Pass down
complete_symbol_mode::EXPRESSION.
(collect_file_symbol_completion_matches): Add complete_symbol_mode
parameter.  Handle LINESPEC mode.
* symtab.h (complete_symbol_mode): New.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_file_symbol_completion_matches): Add complete_symbol_mode
parameter.

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

* gdb.linespec/ls-errs.exp (do_test): Adjust expected output.

7 years agox86-64: Limit PIC check to shared library build
H.J. Lu [Mon, 17 Jul 2017 19:17:59 +0000 (12:17 -0700)]
x86-64: Limit PIC check to shared library build

When building an executable, undefined symbols are error and undefined
weak symbols are resolved to zero.  We only need to check PIC for
building a shared library.

bfd/

PR ld/21782
* elf64-x86-64.c (elf_x86_64_relocate_section): Limit PIC check
to shared library.

ld/

PR ld/21782
* testsuite/ld-x86-64/pie3-nacl.d: New file.
* testsuite/ld-x86-64/pie3.d: Likewise.
* testsuite/ld-x86-64/pie3.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pie3 and pie3-nacl.

7 years agoIntroduce strncmp_iw
Pedro Alves [Mon, 17 Jul 2017 19:08:48 +0000 (20:08 +0100)]
Introduce strncmp_iw

The explicit locations completer patch will need a strncmp_iw
function, that to strcmp_iw like strncmp is to strcmp.  This patch
implements it.

(Unit tests added a bit further down in this series will exercise
this.)

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* utils.c (enum class strncmp_iw_mode): New.
(strcmp_iw): Rename to ...
(strncmp_iw_with_mode): ... this.  Add string2_len and mode
parameters.  Handle them.
(strncmp_iw): New.
(strcmp_iw): Reimplement as wrapper around strncmp_iw_with_mode.
* utils.h (strncmp_iw): Declare.
(strcmp_iw): Move describing comments here.

7 years agoRe-indent elf_x86_64_relocate_section
H.J. Lu [Mon, 17 Jul 2017 17:40:18 +0000 (10:40 -0700)]
Re-indent elf_x86_64_relocate_section

* elf64-x86-64.c (elf_x86_64_relocate_section): Re-indent.

7 years agoIntroduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout
Pedro Alves [Mon, 17 Jul 2017 14:51:55 +0000 (15:51 +0100)]
Introduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout

Move LENGTH_OF_OPERATOR from cp-support.c to cp-support.h so we can
use it elsewhere.  Since there's already
CP_ANONYMOUS_NAMESPACE_STR/CP_ANONYMOUS_NAMESPACE_LEN there, follow
the same naming pattern for the new symbols.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* c-exp.y (operator_stoken): Use CP_OPERATOR_LEN and
CP_OPERATOR_STR.
* c-typeprint.c (is_type_conversion_operator): Use
CP_OPERATOR_STR.
* cp-support.c (LENGTH_OF_OPERATOR): Delete.
(cp_find_first_component_aux): Use CP_OPERATOR_STR and
CP_OPERATOR_LEN.
* cp-support.h (CP_OPERATOR_STR, CP_OPERATOR_LEN): New.
* gnu-v2-abi.c (gnuv2_is_operator_name): Use CP_OPERATOR_STR.
* gnu-v3-abi.c (gnuv3_is_operator_name): Use CP_OPERATOR_STR.
* linespec.c (linespec_lexer_lex_string): Use CP_OPERATOR_LEN and
CP_OPERATOR_STR.
* location.c: Include "cp-support.h".
(explicit_location_lex_one): Use CP_OPERATOR_LEN and
CP_OPERATOR_STR.
* symtab.c (operator_chars): Use CP_OPERATOR_STR and
CP_OPERATOR_LEN.

7 years ago"complete" command and completion word break characters
Pedro Alves [Mon, 17 Jul 2017 14:30:59 +0000 (15:30 +0100)]
"complete" command and completion word break characters

The linespec/locations/completer testcase added later in the series
tests every completion with both TAB completion and the "complete"
command.  This exposed problems in the "complete" command, around
determining the completion word point.

First, the complete command has a too-simple approximation of what
readline's TAB-completion code does to find the completion word point.
Unfortunately, readline doesn't expose the functionality it uses
internally, so to fix this this patch copies over the relevant code,
and adjusts it a bit to better fit the use cases we need it for.
(Specifically, our version avoids relying on the
rl_word_break_characters, etc. globals, and instead takes those as
arguments.)

A following patch will want to use this function for TAB-completion
too, but the "complete" command was a good excuse to split this to a
separate patch.

Then, notice how the complete_command does not call into the completer
for the command being completed to determine the right set of word
break characters.  It always uses the default set.  That is fixed by
having the "complete" command call into complete_line_internal for a
full handle_brkchars phase, just TAB-completion.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* cli/cli-cmds.c (complete_command): Use a completion tracker
along with completion_find_completion_word for handle_brkchars
phase.
* completer.c (RL_QF_SINGLE_QUOTE, RL_QF_DOUBLE_QUOTE)
(RL_QF_BACKSLASH, RL_QF_OTHER_QUOTE): New.
(struct gdb_rl_completion_word_info): New.
(gdb_rl_find_completion_word): New.
(completion_find_completion_word): New.
* completer.h (completion_find_completion_word): Declare.

7 years agoIntroduce class completion_tracker & rewrite completion<->readline interaction
Pedro Alves [Mon, 17 Jul 2017 13:45:59 +0000 (14:45 +0100)]
Introduce class completion_tracker & rewrite completion<->readline interaction

This patch reworks the whole completion machinery, and prepares it
for later enhancements.

Adds a new "completion_tracker" class that is meant to hold everything
about the state of the current completion operation.

This class now has the responsibility of tracking the list of
completion matches, and checking whether the max completions limit has
been reached.  You can look at this as this patch starting out by
C++fying the existing "completion_tracker" in symtab.c (it's just an
htab_t typedef currently), moving it to completer.h/c, and then making
it a class/generalizing/enhancing it.

Unlike with the current tracking, completion_tracker now checks
whether the limit has been reached on each completion match list
insertion.  This both simplifies the max-completions handling code
(maybe_add_completion_enum is gone, for example), and is a
prerequisite for follow up patches.

The current completion_tracker is only used for symbol completions,
and the symbol code gets at the current instance via globals.  This
patch cleans that up by adding a completion_tracker reference to the
signature of the completion functions, and passing the tracker around
everywhere necessary.

Then, the patch changes how the completion match list is handed over
to readline.  Currently, we're using the rl_completion_entry_function
readline entry point, and the patch switches to
rl_attempted_completion_function.  A following patch will want to let
GDB itself decide the common completion prefix between all matches
(what readline calls the "lowest common denominator"), instead of
having readline compute it, and that's not possible with the
rl_completion_entry_function entry point.  Also,
rl_attempted_completion_function lets GDB hand over the match list to
readline as an array in one go instead of passing down matches one by
one, so from that angle it's a nicer entry point anyway.

Lastly, the patch catches exceptions around the readline entry points,
because we can't let C++ exceptions cross readline.  We handle that in
the readline input entry point, but the completion entry point isn't
guarded, so GDB can abort if completion throws.  E.g., in current
master:

 (gdb) b -function "fun<tab>
 terminate called after throwing an instance of 'gdb_exception_RETURN_MASK_ERROR'
 Aborted (core dumped)

This patch fixes that.  This will be exercised in the new tests added
later on in the series.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* ada-lang.c (symbol_completion_match): Adjust comments.
(symbol_completion_add): Replace vector parameter with
completion_tracker parameter.  Use it.
(ada_make_symbol_completion_list): Rename to...
(ada_collect_symbol_completion_matches): ... this.  Add
completion_tracker parameter and use it.
(ada_language_defn): Adjust.
* break-catch-syscall.c (catch_syscall_completer): Adjust
prototype and work with completion_tracker instead of VEC.
* breakpoint.c (condition_completer): Adjust prototype and work
with completion_tracker instead of VEC.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Adjust to renames.
* cli/cli-cmds.c (complete_command): Rework using
completion_tracker.  Catch exceptions when completing.
* cli/cli-decode.c (integer_unlimited_completer)
(complete_on_cmdlist, complete_on_enum): Adjust prototype and work
with completion_tracker instead of VEC.
* command.h (struct completion_tracker): Forward declare.
(completer_ftype, completer_handle_brkchars_ftype): Change
types.
(complete_on_cmdlist, complete_on_enum): Adjust.
* completer.c: Include <algorithm>.
(struct gdb_completer_state): New.
(current_completion): New global.
(readline_line_completion_function): Delete.
(noop_completer, filename_completer)
(filename_completer_handle_brkchars, complete_files_symbols)
(linespec_location_completer): Adjust to work with a
completion_tracker instead of a VEC.
(string_or_empty): New.
(collect_explicit_location_matches): Adjust to work with a
completion_tracker instead of a VEC.
(explicit_location_completer): Rename to ...
(complete_explicit_location): ... this and adjust to work with a
completion_tracker instead of a VEC.
(location_completer): Adjust to work with a completion_tracker
instead of a VEC.
(add_struct_fields): Adjust to work with a completion_list instead
of VEC.
(expression_completer): Rename to ...
(complete_expression): ... this and adjust to work with a
completion_tracker instead of a VEC.  Use complete_files_symbols.
(expression_completer): Reimplement on top of complete_expression.
(symbol_completer): Adjust to work with a completion_tracker
instead of a VEC.
(enum complete_line_internal_reason): Add describing comments.
(complete_line_internal_normal_command): Adjust to work with a
completion_tracker instead of a VEC.
(complete_line_internal): Rename to ...
(complete_line_internal_1): ... this and adjust to work with a
completion_tracker instead of a VEC.  Assert TEXT is NULL in the
handle_brkchars phase.
(new_completion_tracker): Delete.
(complete_line_internal): Reimplement as TRY/CATCH wrapper around
complete_line_internal_1.
(free_completion_tracker): Delete.
(INITIAL_COMPLETION_HTAB_SIZE): New.
(completion_tracker::completion_tracker)
(completion_tracker::~completion_tracker): New.
(maybe_add_completion): Delete.
(completion_tracker::maybe_add_completion)
(completion_tracker::add_completion)
(completion_tracker::add_completions): New.
(throw_max_completions_reached_error): Delete.
(complete_line): Adjust to work with a completion_tracker instead
of a VEC.  Don't create a completion_tracker_t or check for max
completions here.
(command_completer, command_completer_handle_brkchars)
(signal_completer, reg_or_group_completer_1)
(reg_or_group_completer, default_completer_handle_brkchars):
Adjust to work with a completion_tracker.
(gdb_completion_word_break_characters_throw): New.
(gdb_completion_word_break_characters): Reimplement.
(line_completion_function): Delete.
(completion_tracker::recompute_lowest_common_denominator)
(expand_preserving_ws)
(completion_tracker::build_completion_result)
(completion_result::completion_result)
(completion_result::completion_result)
(completion_result::~completion_result)
(completion_result::completion_result)
(completion_result::release_match_list, compare_cstrings)
(completion_result::sort_match_list)
(completion_result::reset_match_list)
(gdb_rl_attempted_completion_function_throw)
(gdb_rl_attempted_completion_function): New.
* completer.h (completion_list, struct completion_result)
(class completion_tracker): New.
(complete_line): Add completion_tracker parameter.
(readline_line_completion_function): Delete.
(gdb_rl_attempted_completion_function): New.
(noop_completer, filename_completer, expression_completer)
(location_completer, symbol_completer, command_completer)
(signal_completer, reg_or_group_completer): Update prototypes.
(completion_tracker_t, new_completion_tracker)
(make_cleanup_free_completion_tracker): Delete.
(enum maybe_add_completion_enum): Delete.
(maybe_add_completion): Delete.
(throw_max_completions_reached_error): Delete.
* corefile.c (complete_set_gnutarget): Adjust to work with a
completion_tracker instead of a VEC.
* cp-abi.c (cp_abi_completer): Adjust to work with a
completion_tracker instead of a VEC.
* d-lang.c (d_language_defn): Adjust.
* disasm.c (disassembler_options_completer): Adjust to work with a
completion_tracker instead of a VEC.
* f-lang.c (f_make_symbol_completion_list): Rename to ...
(f_collect_symbol_completion_matches): ... this.  Adjust to work
with a completion_tracker instead of a VEC.
(f_language_defn): Adjust.
* go-lang.c (go_language_defn): Adjust.
* guile/scm-cmd.c (cmdscm_add_completion, cmdscm_completer):
Adjust to work with a completion_tracker instead of a VEC.
* infrun.c (handle_completer): Likewise.
* interps.c (interpreter_completer): Likewise.
* interps.h (interpreter_completer): Likewise.
* language.c (unknown_language_defn, auto_language_defn)
(local_language_defn): Adjust.
* language.h (language_defn::la_make_symbol_completion_list):
Rename to ...
(language_defn::la_collect_symbol_completion_matches): ... this
and adjust to work with a completion_tracker instead of a VEC.
* m2-lang.c (m2_language_defn): Adjust.
* objc-lang.c (objc_language_defn): Adjust.
* opencl-lang.c (opencl_language_defn): Adjust.
* p-lang.c (pascal_language_defn): Adjust.
* python/py-cmd.c (cmdpy_completer_helper): Handle NULL word.
(cmdpy_completer_handle_brkchars, cmdpy_completer): Adjust to work
with a completion_tracker.
* rust-lang.c (rust_language_defn): Adjust.
* symtab.c (free_completion_list, do_free_completion_list)
(return_val, completion_tracker): Delete.
(completion_list_add_name, completion_list_add_symbol)
(completion_list_add_msymbol, completion_list_objc_symbol)
(completion_list_add_fields, add_symtab_completions): Add
completion_tracker parameter and use it.
(default_make_symbol_completion_list_break_on_1): Rename to...
(default_collect_symbol_completion_matches_break_on): ... this.
Add completion_tracker parameter and use it instead of allocating
a completion tracker here.
(default_make_symbol_completion_list_break_on): Delete old
implementation.
(default_make_symbol_completion_list): Delete.
(default_collect_symbol_completion_matches): New.
(make_symbol_completion_list): Delete.
(collect_symbol_completion_matches): New.
(make_symbol_completion_type): Rename to ...
(collect_symbol_completion_matches_type): ... this.  Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list_1): Rename to...
(collect_file_symbol_completion_matches): ... this.  Add
completion_tracker parameter and use it instead of VEC.
(make_file_symbol_completion_list): Delete.
(add_filename_to_list): Use completion_list instead of a VEC.
(add_partial_filename_data::list): Now a completion_list.
(make_source_files_completion_list): Work with a completion_list
instead of a VEC.
* symtab.h: Include "completer.h".
(default_make_symbol_completion_list_break_on)
(default_make_symbol_completion_list, make_symbol_completion_list)
(make_symbol_completion_type, make_file_symbol_completion_list)
(make_source_files_completion_list): Delete.
(default_collect_symbol_completion_matches_break_on)
(default_collect_symbol_completion_matches)
(collect_symbol_completion_matches)
(collect_symbol_completion_matches_type)
(collect_file_symbol_completion_matches)
(make_source_files_completion_list): New.
* top.c (init_main): Don't install a rl_completion_entry_function
hook.  Install a rl_attempted_completion_function hook instead.
* tui/tui-layout.c (layout_completer): Adjust to work with a
completion_tracker.
* tui/tui-regs.c (tui_reggroup_completer):
* tui/tui-win.c (window_name_completer, focus_completer)
(winheight_completer): Adjust to work with a completion_tracker.
* value.c: Include "completer.h".
(complete_internalvar): Adjust to work with a completion_tracker.
* value.h (complete_internalvar): Likewise.

7 years agoClean up "completer_handle_brkchars" callback handling
Pedro Alves [Mon, 17 Jul 2017 11:05:03 +0000 (12:05 +0100)]
Clean up "completer_handle_brkchars" callback handling

This patch cleans up "completer_handle_brkchars" callback handling:

- Renames the function typedef to better match its intent:
  completer_ftype_void ->  completer_handle_brkchars_ftype

- Factors out common code in complete_line_internal handling the
  "handle_brkchars" callback to a separate function.

- Centralizes all the "completer method" to "handle_brkchars method"
  mapping in a single function.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* cli/cli-decode.c (set_cmd_completer_handle_brkchars): Adjust to
renames.
* cli/cli-decode.h (struct cmd_list_element) <completer>: Move
comments to completer_ftype's declaration.
<completer_handle_brkchars>: Change type to
completer_handle_brkchars_ftype.
* command.h (completer_ftype): Add describing comment and give
names to parameters.
(completer_ftype_void): Rename to ...
(completer_handle_brkchars_ftype) ... this.  Add describing comment.
(set_cmd_completer_handle_brkchars): Adjust.
* completer.c (filename_completer_handle_brkchars): New function.
(complete_line_internal_normal_command): New function, factored
out from ...
(complete_line_internal): ... here.
(command_completer_handle_brkchars)
(default_completer_handle_brkchars)
(completer_handle_brkchars_func_for_completer): New functions.
* completer.h (set_gdb_completion_word_break_characters): Delete
declaration.
(completer_handle_brkchars_func_for_completer): New declaration.
* python/py-cmd.c (cmdpy_completer_handle_brkchars): Adjust to use
completer_handle_brkchars_func_for_completer.

7 years agoRename make_symbol_completion_list_fn -> symbol_completer
Pedro Alves [Mon, 17 Jul 2017 10:55:42 +0000 (11:55 +0100)]
Rename make_symbol_completion_list_fn -> symbol_completer

"make_symbol_completion_list_fn" is odly named when you look at a list
of "standard" completers, like the Python/Guile completer lists
adjusted by this patch.  Rename / move it to completers.h/c, for
consistency.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* completer.c (symbol_completer): New function, based on
make_symbol_completion_list_fn.
* completer.h (symbol_completer): New declaration.
* guile/scm-cmd.c (cmdscm_completers): Adjust.
* python/py-cmd.c (completers): Adjust.
* symtab.c (make_symbol_completion_list_fn): Delete.
* symtab.h (make_symbol_completion_list_fn): Delete.
* cli/cli-decode.c (add_cmd): Adjust.

7 years agoFix TAB-completion + .gdb_index slowness (generalize filename_seen_cache)
Pedro Alves [Mon, 17 Jul 2017 10:28:33 +0000 (11:28 +0100)]
Fix TAB-completion + .gdb_index slowness (generalize filename_seen_cache)

Tab completion when debugging a program binary that uses GDB index is
surprisingly much slower than when GDB uses psymtabs instead.  Around
1.5x/3x slower.  That's surprising, because the whole point of GDB
index is to speed things up...

For example, with:

 set pagination off
 set $count = 0
 while $count < 400
   complete b string_prin         # matches gdb's string_printf
   printf "count = %d\n", $count
   set $count = $count + 1
 end

 $ time ./gdb --batch -q  ./gdb-with-index -ex "source script.cmd"
 real    0m11.042s
 user    0m10.920s
 sys     0m0.042s

 $ time ./gdb --batch -q  ./gdb-without-index -ex "source script.cmd"
 real    0m4.635s
 user    0m4.590s
 sys     0m0.037s

Same but with:
 -   complete b string_prin
 +   complete b zzzzzz
to exercise the no-matches worst case, master currently gets you
something like:

 with index           without index
 real    0m11.971s    0m8.413s
 user    0m11.912s    0m8.355s
 sys     0m0.035s     0m0.035s

Running gdb under perf shows 80% spent inside
maybe_add_partial_symtab_filename, and 20% spent in the lbasename
inside that.

The problem that tab completion walks over all compunit symtabs, and
for each, walks the contained file symtabs.  And there a huge number
of file symtabs (each included system header, etc.) that appear in
each compunit symtab's file symtab list.  As in, when debugging GDB, I
have 367381 symtabs iterated, when of those only 5371 filenames are
unique...

This was a regression from the earlier (nice) split of symtabs in
compunit symtabs + file symtabs.

The fix here is to add a cache of unique filenames per objfile so that
the walk / uniquing is only done once.  There's already a abstraction
for this in symtab.c; this patch moves that code out to a separate
file and C++ifies it bit.

This makes the worst-case scenario above consistently drop to ~2.5s
(1.5s for the "string_prin" hit case), making it over 3.3x times
faster than psymtabs in this use case (7x in the "string_prin" hit
case).

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* Makefile.in (COMMON_OBS): Add filename-seen-cache.o.
* dwarf2read.c: Include "filename-seen-cache.h".
* dwarf2read.c (dwarf2_per_objfile) <filenames_cache>: New field.
(dw2_map_symbol_filenames): Build and use a filenames_seen_cache.
* filename-seen-cache.c: New file.
* filename-seen-cache.h: New file.
* symtab.c: Include "filename-seen-cache.h".
(struct filename_seen_cache, INITIAL_FILENAME_SEEN_CACHE_SIZE)
(create_filename_seen_cache, clear_filename_seen_cache)
(delete_filename_seen_cache, filename_seen): Delete, parts moved
to filename-seen-cache.h/filename-seen-cache.c.
(output_source_filename, sources_info)
(maybe_add_partial_symtab_filename)
(make_source_files_completion_list): Adjust to use
filename_seen_cache.

7 years agoC++ify dwarf2_per_objfile
Pedro Alves [Mon, 17 Jul 2017 10:31:20 +0000 (11:31 +0100)]
C++ify dwarf2_per_objfile

This makes dwarf2_per_objfile a class with cdtors.

A following patch will add a non-trivial field to struct
dwarf2_per_objfile, making dwarf2_per_objfile itself non-trivial.
Since dwarf2_per_objfile is allocated in an obstack, we need to run
its cdtors manually.

Tested on x86-64 GNU/Linux.

gdb/ChangeLog:
2017-07-17  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (dwarf2_per_objfile): In-class initialize all
fields.
(dwarf2_per_objfile::dwarf2_per_objfile(objfile*, const
dwarf2_debug_sections*)): New.
(dwarf2_per_objfile::dwarf2_per_objfile(const
dwarf2_per_objfile&)): Declare as deleted.
(dwarf2_per_objfile::operator=): Declare as deleted.
(dwarf2_per_objfile::dwarf2_per_objfile)
(dwarf2_per_objfile::~dwarf2_per_objfile)
(dwarf2_per_objfile::free_cached_comp_units): New.
(dwarf2_has_info): dwarf2_per_objfile initialization code moved to
ctor.  Call dwarf2_per_objfile's ctor manually.
(dwarf2_locate_sections): Deleted/refactored as ...
(dwarf2_per_objfile::locate_sections): ... this new method.
(free_cached_comp_units): Defer to
dwarf2_per_objfile::free_cached_comp_units.
(dwarf2_free_objfile): Call dwarf2_per_objfile's dtor manually.