Commit Graph

95116 Commits

Author SHA1 Message Date
Keith Seitz 18cdc6d8f8 Add a C++ wrapper for GCC C plug-in
This patch introduces a new class which wraps the GCC C compile plug-in.
It is a little unfortunate that this all happened in between the time that
GCC moved to C++ and GDB moved to C++, leaving us with an ABI promise to
support a C-like interface.  The hope is to isolate GDB from some of this
should it change in the future.

Broadly, what this does is replace calls like:

  C_CTX (context)->c_ops->operation (C_CTX (context), ...);

with calls that now look like:

  context->c_plugin->operation (...);

This API will be further refined in following patches when struct
compile_instance/compile_c_instance are changed into classes.

gdb/ChangeLog:
        * Makefile.in (HFILES_NO_SRCDIR): Add compile/gcc-c-plugin.h.
        * compile/compile-c-types.c: Define GCC_METHODN macros and include
        gcc-c-fe.def to define C plugin.
        (delete_instance): Delete `c_plugin'.
        (new_compile_instance): Initialize `c_plugin'.
        * compile/compile-c.h: Include gcc_c_plugin.h.
        (struct compile_c_instance) <c_plugin>: New member.
        * gcc-c-plugin.h: New file.
        Update all callers with API change.
2018-08-10 11:14:25 -07:00
Keith Seitz b7dc48b4a8 Move C-related declarations to compile-c.h
This patch simply moves a bunch of C language-related declarations from
the various compile header files into a new C-specific header, compile-c.h.

gdb/ChangeLog:
        * Makefile.in (SUBDIR_GCC_COMPILE_SRCS): Move header files ...
        (HFILES_NO_SRCDIR): ... to here.
        Add compile-internal.h and compile-c.h.
        * compile/compile-c-support.c: Include compile-c.h.
        * compile/compile-c-symbols.c: Include compile-c.h.
        (generate_c_for_variable_locations): Update comment.
        * compile/compile-c-types.c: Include compile-c.h.
        * compile/compile-c.h: New file -- moved C language declarations
        from other files here.
        * compile/compile-internal.h: Do not include hashtab.h or
        common/enum-flags.h.
        (gcc_qualifiers_flags, struct compile_c_instance, C_CTX)
        (gcc_convert_symbol, gcc_symbol_address)
        (generate_c_for_variable_locations, c_get_mode_for_size)
        (c_get_range_decl_name): Definitions moved to compile-c.h.
        * compile/compile-loc2c.c: Include compile-c.h.
2018-08-10 11:14:25 -07:00
Keith Seitz 6f36b6d29f Rename symbol_substitution_name
This patch simply adds a "c_" prefix to symbol_substitution_name to clarify
that this is a C language-related function.

gdb/ChangeLog:
        * compile/compile-c-symbols.c (symbol_substitution_name): Rename to ...
        (c_symbol_substitution_name): ... this.
        Update all callers.
2018-08-10 11:14:25 -07:00
Keith Seitz bd923e5108 Return unique_xmalloc_ptr for generate_c_for_variable_locations
This patch eliminates two cleanups in compile/ by changing
generate_c_for_variable_locations so that it returns a unique_ptr.

gdb/ChangeLog:
        * compile/compile-c-support.c (c_compute_program): Use
        unique_xmalloc_ptr to eliminate cleanup.
        * compile/compile-c-symbols.c (generate_c_for_variable_locations):
        Return a unique_xmalloc_ptr and eliminate cleanup.
        * compile/compile-internal.h (generate_c_for_variable_locations):
        Return unique_xmalloc_ptr and update description.
2018-08-10 11:14:25 -07:00
H.J. Lu d7f449c026 x86: Don't display --32/--64/--x32 without BFD64
For 32-bit x86 assembler, --64 and --x32 are unsupported if BFD64 is
undefined.  Even if BFD64 is defined, --64 and --x32 still may not be
supported if x86-64 support isn't compiled in:

[hjl@gnu-hsw-1 gas]$ ./as-new --64 -o x.o x.s
Assembler messages:
Fatal error: no compiled in support for x86_64
[hjl@gnu-hsw-1 gas]$ ./as-new --x32 -o x.o x.s
Assembler messages:
Fatal error: no compiled in support for 32bit x86_64
[hjl@gnu-hsw-1 gas]$

This patch removes --32/--64/--x32 from md_show_usage if BFD64 is
undefined and runs code64-inval only if BFD64 is undefined.

	* config/tc-i386.c (md_show_usage): Don't display --32/--64/--x32
	if BFD64 is undefined.
	* testsuite/gas/i386/i386.exp (gas_bfd64_check): New.
	Run code64-inval if gas_bfd64_check fails.
2018-08-10 11:03:50 -07:00
H.J. Lu 19449d7c67 x86: Replace evex-no-scale.s with evex-no-scale-[32|64].s
.if is_64bit
	vmovaps	-1024(%rip), %zmm0
	vmovaps	64(,%rax), %zmm0
	vmovaps	64(,%riz), %zmm0
.endif

doesn't with i686-elf cross binutils on 64-bit hosts:

evex-no-scale.s: Assembler messages:
evex-no-scale.s:10: Error: bad register name `%rip)'
evex-no-scale.s:11: Error: bad register name `%rax)'
evex-no-scale.s:12: Error: bad register name `%riz)'

This patch replaces evex-no-scale.s with evex-no-scale-32.s and
evex-no-scale-64.s.

	* testsuite/gas/i386/evex-no-scale-32.d: Don't use
	evex-no-scale.s.
	* testsuite/gas/i386/evex-no-scale-64.d: Likewise.
	* testsuite/gas/i386/evex-no-scale-32.s: New file.
	* testsuite/gas/i386/evex-no-scale-64.s: Likewise.
	* testsuite/gas/i386/evex-no-scale.s: Removed.
2018-08-10 10:23:11 -07:00
H.J. Lu 9c973a29df Always use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE
For GNU_PROPERTY_STACK_SIZE, pr_datasz is the same as align_size, which
is 8 bytes for 64-bit ELF binaries and 4 bytes for 32-bit ELF binaries,
Use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE to convert
.note.gnu.property section.

bfd/

	PR binutils/23494
	* elf-properties.c (elf_get_gnu_property_section_size): Always
	use align_size as pr_datasz for GNU_PROPERTY_STACK_SIZE.
	(elf_write_gnu_properties): Likewise.

binutils/

	PR binutils/23494
	* testsuite/binutils-all/x86-64/pr23494c.s: New file.
	* testsuite/binutils-all/x86-64/pr23494e-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494e.d: Likewise.
2018-08-10 08:14:24 -07:00
H.J. Lu 11459a79d9 Skip PR binutils/23494 tests for nacl targets
PR binutils/23494 tests pass "-O elf64-x86-64" and "-O elf32-x86-64"
to objcopy which may not supported for nacl targets.  This patch skips
these tests for nacl targets.

	* testsuite/binutils-all/x86-64/pr23494a-x32.d: Skip nacl
	targets.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
2018-08-10 07:53:50 -07:00
Alan Hayward dbd534fee4 Rename size in get_core_register_section
Make it clearer that the size field indicates the size of the section.

gdb/

	* corelow.c (core_target::get_core_register_section): Rename
	min_size to section_min_size.
2018-08-10 10:24:47 +01:00
GDB Administrator db850b6865 Automatic date update in version.in 2018-08-10 00:00:26 +00:00
Jim Wilson 52a187f8e7 RISC-V: Add configure support for riscv*-linux*.
This adds the target and native configure support, and the NEWS entries for
the new target and native configurations.

	gdb/
	* Makefile.in (ALL_TARGET_OBS): Add riscv-linux-tdep.c.
	(ALLDEPFILES): Add riscv-linux-nat.c, and riscv-linux-tdep.c.
	* NEWS: Mention new GNU/Linux RISC-V target.
	* configure.host: Add riscv*-*-linux*.
	* configure.nat: Add riscv*.
	* configure.tgt: Add riscv*-*-linux*.
2018-08-09 13:37:45 -07:00
Jim Wilson 3c77f97eb0 RISC-V: Add native linux support.
Add initial native support for riscv*-linux*.

	gdb/
	* riscv-linux-nat.c: New file.
2018-08-09 13:35:24 -07:00
Jim Wilson 90ad36544c RISC-V: Add linux target support.
Add initial target support for riscv*-linux*.

	gdb/
	* riscv-linux-tdep.c: New file.
2018-08-09 13:33:36 -07:00
Andrew Burgess aff4e1751f gdb: Make infrun.c:resume function static
Make the infrun.c:resume function static, and update the header
comment on the infrun.c:proceed function.  There should be no user
visible change after this commit.

gdb/ChangeLog:

	* infrun.c (resume): Make static, add forward declaration.
	(proceed): Update header comment.
	* infrun.h (resume): Delete declaration.
2018-08-09 19:23:43 +01:00
Tom Tromey 06ab921988 Minor formatting fixes in riscv-tdep.h
This fixes some minor formatting issues in riscv-tdep.h, including one
pointed out by ARI.

ChangeLog
2018-08-09  Tom Tromey  <tom@tromey.com>

	* riscv-tdep.h: Minor formatting fixes.
2018-08-09 11:42:57 -06:00
Simon Marchi 83c8d318d1 Fix some gettext ARI warnings
ARI produces this warning for the lines touched in this patch:

  warning: gettext: All messages should be marked up with _.

However, in these cases, the message is not translatable (they are
syscall names).  Adding an extra set of parentheses silences the
warning.

gdb/ChangeLog:

	* common/scoped_mmap.c (mmap_file): Silence ARI warning.
	* dwarf-index-cache.c (create_dir_and_check): Likewise.
	(test_mkdir_recursive): Likewise.
	* dwarf-index-write.c (write_psymtabs_to_index): Likewise.
2018-08-09 13:17:56 -04:00
H.J. Lu 3a53fb12c8 as --help: Display default option for --elf-stt-common=
* as.c (show_usage): Display default option for --elf-stt-common=.
2018-08-09 09:57:11 -07:00
H.J. Lu 7c5c05effd x86: Display default x86-specific options for "as --help"
* config/tc-i386.c (md_show_usage): Display default options.
2018-08-09 09:52:43 -07:00
Andrew Burgess 5ff2bbae19 gdb: Check element of optimised out vla exists
If a vla is not in memory, and the upper bound is not defined, then we
can't know that an array element exists or not, and we should not try
to access the array element.  One case where this happens is for
arrays that have been optimised out, the array will then have
VALUE_LVAL of not_lval, and an undefined upper bound, if we then try
to access an element of this array we will index into random GDB
memory.

An argument could be made that even for arrays that are in inferior
memory, if the upper bound is not defined then we should not try to
access the array element, however, in some of the Fortran tests, it
seems as though we do rely indexing from a base address into an array
which has no bounds defined.  In this case GDBs standard protection
for detecting unreadable target memory prevents bad thing happening.

gdb/ChangeLog:

	* valarith.c (value_subscripted_rvalue): If an array is not in
	memory, and we don't know the upper bound, then we can't know that
	the requested element exists or not.

gdb/testsuite/ChangeLog:

	* gdb.base/vla-optimized-out.exp: Add new test.
2018-08-09 17:17:35 +01:00
Andrew Burgess e5bbcd0f04 gdb: Merge similar tests into a single test script
The three test scripts:

  gdb/testsuite/gdb.base/vla-optimized-out.exp
  gdb/testsuite/gdb.base/vla-optimized-out-o3.exp
  gdb/testsuite/gdb.base/vla-optimized-out-o3-strict.exp

are all pretty similar, with differences in the compile flags used,
and some of the expected results.

Instead of maintaining 3 files, merge them into a single test script,
and use parameters to control the test behaviour.

gdb/testsuite/ChangeLog:

	* gdb.base/vla-optimized-out-o3.exp: Delete.
	* gdb.base/vla-optimized-out-o3-strict.exp: Delete.
	* gdb.base/vla-optimized-out.exp: Extend to cover all of the
	deleted tests.
2018-08-09 17:17:34 +01:00
Richard Earnshaw 57285adece arm - Add some comments about the versions of ARM ELF that define various e_flags values
This patch adds a few comments to include/elf/arm.h to clarify which
versions of the ARM ELF specification defined which headers.  Given
that the EABI is pretty ubiquitous these days, I've marked anything
not based on that as deprecated.

There are no plans to remove any deprecated definitions at this time,
but any new development shouldn't be building upon support for
deprecated definitions remaining in the long term.

	* elf/arm.h: Updated comments for e_flags definitions.
2018-08-09 16:51:09 +01:00
H.J. Lu 6404ab9937 Convert .note.gnu.property section between ELF32 and ELF64
.note.gnu.property section has different alignments and section
sizes for 32-bit and 64-bit ELF binaries.  This patch updated
bfd_convert_section_size and bfd_convert_section_contents to
properly convert .note.gnu.property section between 32-bit and
64-bit ELF binaries.

bfd/

	PR binutils/23494
	* bfd.c (bfd_convert_section_size): Check BFD_DECOMPRESS after
	calling _bfd_elf_convert_gnu_property_size to convert
	.note.gnu.property section size.
	(bfd_convert_section_contents): Check BFD_DECOMPRESS after
	calling _bfd_elf_convert_gnu_properties to convert
	.note.gnu.property section.
	* elf-bfd.h (_bfd_elf_convert_gnu_property_size): New prototype.
	(_bfd_elf_convert_gnu_properties): Likewise.
	* elf-properties.c (elf_get_gnu_property_section_size): New
	function.
	(elf_write_gnu_properties): Likewise.
	(_bfd_elf_convert_gnu_property_size): Likewise.
	(_bfd_elf_convert_gnu_properties): Likewise.
	(_bfd_elf_link_setup_gnu_properties): Use
	elf_get_gnu_property_section_size and elf_write_gnu_properties.

binutils/

	PR binutils/23494
	* testsuite/binutils-all/x86-64/pr23494a-x32.d: New file.
	* testsuite/binutils-all/x86-64/pr23494a.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494a.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494b.s: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494c.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d-x32.d: Likewise.
	* testsuite/binutils-all/x86-64/pr23494d.d: Likewise.
2018-08-08 21:00:18 -07:00
GDB Administrator f40f4a11d1 Automatic date update in version.in 2018-08-09 00:00:26 +00:00
Simon Marchi fdbac7d8d1 Fix some comments in target.c
Fix a typo and add a missing one.

gdb/ChangeLog:

	* target.c (str_comma_list_concat_elem): Fix typo in comment.
	(target_options_to_string): Add comment.
2018-08-08 18:13:18 -04:00
Tom Tromey 83202f7ae8 Check result of "write"
Some distros enable _FORTIFY_SOURCE by default, which caught a failure
to check the result of "write" in scoped_mmap-selftests.c.  This patch
fixes the problem.

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

	* unittests/scoped_mmap-selftests.c: Check result of "write".
2018-08-08 11:59:44 -06:00
Jim Wilson 5c720ed886 RISC-V: Add software single step support.
This adds software single step support that is needed by the linux native port.
This is modeled after equivalent code in the MIPS port.

This also fixes a few bugs in the compressed instruction decode support.  Some
instructions are RV32/RV64 specific, and this wasn't being checked.  Also, a
few instructions were accidentally using the non-compressed is_* function.

This has been tested on a HiFive Unleashed running Fedora, by putting a
breakpoint on start, typing stepi, and then holding down the return key until
it finishes, and observing that I see everything I expect to see along the way.
There is a problem in _dl_addr where I get into an infinite loop, but it seems
to be some synchronization code that doesn't agree with single step, so I have
to find the end of the loop, put a breakpoint there, continue, and then single
step again until the end.

	gdb/
	* riscv-tdep.c (enum opcode): Add jump, branch, lr, and sc opcodes.
	(decode_register_index_short): New.
	(decode_j_type_insn, decode_cj_type_insn): New.
	(decode_b_type_insn, decode_cb_type_insn): New.
	(riscv_insn::decode): Add support for jumps, branches, lr, and sc.  New
	local xlen.  Check xlen when decoding ambiguous compressed insns.  In
	compressed decode, use is_c_lui_insn instead of is_lui_insn, and
	is_c_sw_insn instead of is_sw_insn.
	(riscv_next_pc, riscv_next_pc_atomic_sequence): New.
	(riscv_software_single_step): New.
	* riscv-tdep.h (riscv_software_single_step): Declare.
2018-08-08 10:53:12 -07:00
Jim Wilson 411baa470e RISC-V: Make riscv_isa_xlen a global function.
This allows the function to be used from riscv OS files, which also need to
depend on XLEN size.

	gdb/
	* riscv-tdep.c (riscv_isa_xlen): Drop static.
	* riscv-tdep.h (riscv_isa_xlen): Add extern declaration.
2018-08-08 10:51:40 -07:00
Kevin Buettner f384a1f025 Add support for DW_OP_GNU_variable_value to readelf
As indicated by the subject, this patch adds support for the DWARF
expression opcode DW_OP_GNU_variable_value to readelf.

It's pretty much a copy/paste of DW_OP_call_ref with the obvious name
changes for the printf statements.  The FIXME comment comes from that
copy/paste.

binutils/ChangeLog:

	* dwarf.c (decode_location_expresion): Add case for
	DW_OP_GNU_variable_value.
2018-08-08 08:10:36 -07:00
H.J. Lu f7309df20c x86: Properly merge GNU_PROPERTY_X86_ISA_1_USED
Without the GNU_PROPERTY_X86_ISA_1_USED property, all ISAs may be used.
If a bit in the GNU_PROPERTY_X86_ISA_1_USED property is unset, the
corresponding x86 instruction set isn’t used.  When merging properties
from 2 input files and one input file doesn't have the
GNU_PROPERTY_X86_ISA_1_USED property, the output file shouldn't have
it neither.  This patch removes the GNU_PROPERTY_X86_ISA_1_USED
property if an input file doesn't have it.

This patch replaces the GNU_PROPERTY_X86_ISA_1_USED property with the
GNU_PROPERTY_X86_ISA_1_NEEDED property which is the minimum ISA
requirement.

bfd/

	PR ld/23486
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Remove
	GNU_PROPERTY_X86_ISA_1_USED if an input file doesn't have it.
	(_bfd_x86_elf_link_setup_gnu_properties): Adding the
	GNU_PROPERTY_X86_ISA_1_NEEDED, instead of
	GNU_PROPERTY_X86_ISA_1_USED, property.

ld/

	PR ld/23486
	* testsuite/ld-i386/i386.exp: Run PR ld/23486 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr23486a.d: New file.
	* testsuite/ld-i386/pr23486b.d: Likewise.
	* testsuite/ld-x86-64/pr23486a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486a.d: Likewise.
	* testsuite/ld-x86-64/pr23486a.s: Likewise.
	* testsuite/ld-x86-64/pr23486b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr23486b.d: Likewise.
	* testsuite/ld-x86-64/pr23486b.s: Likewise.
	* testsuite/ld-i386/property-3.r: Remove "x86 ISA used".
	* testsuite/ld-i386/property-4.r: Likewise.
	* testsuite/ld-i386/property-5.r: Likewise.
	* testsuite/ld-i386/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-i386/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-i386/property-x86-shstk3b.d: Likewise.
	* testsuite/ld-x86-64/property-3.r: Likewise.
	* testsuite/ld-x86-64/property-4.r: Likewise.
	* testsuite/ld-x86-64/property-5.r: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-ibt3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b-x32.d: Likewise.
	* testsuite/ld-x86-64/property-x86-shstk3b.d: Likewise.
2018-08-08 06:09:28 -07:00
Andrew Burgess 9d4a934ce6 gdb: Fix assert for extended-remote target (PR gdb/18050)
Consider the following GDB session:

   (gdb) target extended-remote :2347
   (gdb) file /path/to/exe
   (gdb) set remote exec-file /path/to/exe
   (gdb) set detach-on-fork off
   (gdb) break breakpt
   (gdb) run
   # ... hits breakpoint
   (gdb) info inferiors
     Num  Description       Executable
   * 1    process 17001     /path/to/exe
     2    process 17002     /path/to/exe
   (gdb) kill
   (gdb) info inferiors
     Num  Description       Executable
   * 1    <null>            /path/to/exe
     2    process 17002     /path/to/exe
   (gdb) target extended-remote :2348
   ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
   A problem internal to GDB has been detected,
   further debugging may prove unreliable.

Or, from bug PR gdb/18050:

   (gdb) start
   (gdb) add-inferior -exec /path/to/exe
   (gdb) target extended-remote :2347
   ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed.
   A problem internal to GDB has been detected,
   further debugging may prove unreliable.

The issue is calling target.c:dispose_inferior with a killed inferior in
the inferior list.  This assertion is fixed in this commit.

The new test for this issue only runs on platforms that support
'detach-on-fork', and when using
'--target_board=native-extended-gdbserver'.

gdb/ChangeLog:

	PR gdb/18050:
	* target.c (dispose_inferior): Don't dispose of inferiors that are
	already killed.

gdb/testsuite/ChangeLog:

	PR gdb/18050:
	* gdb.server/extended-remote-restart.c: New file.
	* gdb.server/extended-remote-restart.exp: New file.
2018-08-08 13:14:45 +01:00
Szabolcs Nagy ff36536c92 Fix gdb/remote.c build failure
Add const qualifier to fix

/S/gdb/common/gdb_locale.h:35:27: error: deprecated conversion from string constant to 'char*' [-Werror=write-strings]
 # define _(String) (String)
                           ^
/S/gdb/remote.c:12844:19: note: in expansion of macro '_'
   char *err_msg = _("Tracepoint packet too large for target.");
                   ^
gdb/ChangeLog:

	* remote.c (remote_target::download_tracepoint): Change char* to
	const char*.
2018-08-08 11:31:11 +01:00
Tulio Magno Quites Machado Filho f6f9ed015e Fix "may be used uninitialized" warning.
* object.cc (Sized_relobj_file::map_to_kept_section): Initialize
	kept_file.
2018-08-07 22:40:33 -07:00
Cary Coutant a9fc784bac Properly merge GNU_PROPERTY_X86_ISA_1_USED (x86_64).
gold/
	PR ld/23486
	* x86_64.cc (Target_x86_64::Target_x86_64): Initialize
	object_isa_1_used_.
	(Target_x86_64::object_isa_1_used_): New data member.
	(Target_x86_64::record_gnu_property): Save ISA_1_USED bits for object.
	(Target_x86_64::merge_gnu_properties): Merge ISA_1_USED bits.
2018-08-07 21:35:41 -07:00
Simon Marchi 045cf01286 Fix gdb.fortran/nested-funcs.exp failure
Commit 87d6a7aa93 ("Add DWARF index cache") broke
gdb.fortran/nested-funcs.exp.  Because of the new "set index-cache"
command, the expression "set index = 42" now fails:

  set index = 42
  Undefined set index-cache command: "= 42".  Try "help set index-cache".
  (gdb) PASS: gdb.fortran/nested-funcs.exp: set index = 42

Fix it by changing it to "set variable index = 42".  Also, use
gdb_test_no_output to confirm that it worked (since that particular test
wrongfully passed).

gdb/testsuite/ChangeLog:

	* gdb.fortran/nested-funcs.exp: Replace "set index = 42" with
	"set variable index = 42".
2018-08-07 22:46:37 -04:00
Simon Marchi 09ce46f230 Make target_options_to_string return an std::string
Return an std::string instead of a char *, saving some manual freeing.

I only manually tested with "set debug target 1" and "set debug lin-lwp
1", since this only deals with debug output.

gdb/ChangeLog:

	* target.h (target_options_to_string): Return an std::string.
	* target.c (str_comma_list_concat_elem): Return void, use
	std::string.
	(do_option): Likewise.
	(target_options_to_string): Return an std::string.
	* linux-nat.c (linux_nat_target::wait): Adjust.
	* target-debug.h (target_debug_print_options): Adjust.
2018-08-07 21:38:27 -04:00
GDB Administrator b825f3a90e Automatic date update in version.in 2018-08-08 00:00:29 +00:00
Tom Tromey 9c61296405 Allow CPPFLAGS to be set on the make command line
While looking into PR build/8751 (which seems to be fixed), I noticed
that it's not possible to change CPPFLAGS for gdb on the "make"
command line.  It's reasonable to want to do this sometimes, and I
think this patch should suffice.

gdb/ChangeLog
2018-08-07  Tom Tromey  <tom@tromey.com>

	* Makefile.in (CPPFLAGS): New variable.
	(INTERNAL_CPPFLAGS): Use it.
2018-08-07 16:39:13 -06:00
Simon Marchi 7d11235d04 Add doc and news for DWARF index cache
New in v3:

- Address Eli's comments.

This patch adds doc and news for the feature introduced by the previous
patch.

gdb/ChangeLog:

	* NEWS: Mention the index cache.

gdb/doc/ChangeLog:

	* gdb.texinfo (Index Files Speed Up GDB): Add section about
	symbol index cache.
2018-08-07 18:15:28 -04:00
Simon Marchi 87d6a7aa93 Add DWARF index cache
New in v3:

- Remove things related to the dwarf-5 format.
- Fix compilation on mingw (scoped_mmap.c).

GDB can generate indexes for DWARF debug information, which, when
integrated in the original binary, can speed up loading object files.
This can be done using the gdb-add-index script or directly by the
linker itself.  However, not many people know about this.  And even
among those who do, because it requires additional steps, I don't know a
lot of people who actually go through that trouble.

To help make using the DWARF index more transparent, this patch
introduces a DWARF index cache.  When enabled, loading an index-less
binary in GDB will automatically save an index file in ~/.cache/gdb.
When loading that same object file again, the index file will be looked
up and used to load the DWARF index.  You therefore get the benefit of
the DWARF index without having to do additional manual steps or
modifying your build system.  When an index section is already present
in the file, GDB will prefer that one over looking up the cache.

When doing my edit-compile-debug cycle, I often debug multiple times the
same build, so the cache helps reducing the load time of the debug
sessions after the first one.

- The saved index file is exactly the same as the output of the "save
  gdb-index" command.  It is therefore the exact same content that would
  be found in the .gdb_index or .debug_names section.  We just leave it
  as a standalone file instead of merging it in the binary.

- The cache is just a directory with files named after the object
  file's build-id.  It is not possible to save/load the index for an
  object file without build-id in the cache.

- The cache uses the gdb index format.  The problem with the dwarf-5
  format is that we can generate an addendum to the .debug_str section
  that you're supposed to integrate to the original binary.  This
  complicates a little bit loading the data from the cached index files,
  so I would leave this for later.

- The size taken up by ~/.cache/gdb is not limited.  I was thinking we
  could add configurable limit (like ccache does), but that would come
  after.  Also, maybe a command to flush the cache.

- The cache is disabled by default.  I think once it's been out there
  and tested for a while, it could be turned on by default, so that
  everybody can enjoy it.

- The code was made to follow the XDG specification: if the
  XDG_CACHE_HOME environment variable, it is used, otherwise it falls
  back to ~/.cache/gdb.  It is possible to change it using "set
  index-cache directory".  On other OSes than GNU/Linux, ~/.cache may
  not be the best place to put such data.  On macOS it should probably
  default to ~/Library/Caches/...  On Windows, %LocalAppData%/...  I
  don't intend to do this part, but further patches are welcome.

- I think that we need to be careful that multiple instances of GDB
  don't interfere with each other (not far fetched at all if you run GDB
  in some automated script) and the cache is always coherent (either the
  file is not found, or it is found and entirely valid).  Writing the
  file directly to its final location seems like a recipe for failure.
  One GDB could read a file in the index while it is being written by
  another GDB.  To mitigate this, I made write_psymtabs_to_index write
  to temporary files and rename them once it's done.  Two GDB instances
  writing the index for the same file should not step on each other's
  toes (the last file to be renamed will stay).  A GDB looking up a file
  will only see a complete file or no file.  Also, if GDB crashes while
  generating the index file, it will leave a work-in-progress file, but
  it won't be picked up by other instances looking up in the cache.

gdb/ChangeLog:

	* common/pathstuff.h (get_standard_cache_dir): New.
	* common/pathstuff.c (get_standard_cache_dir): New.
	* build-id.h (build_id_to_string): New.
	* dwarf-index-common.h (INDEX4_SUFFIX, INDEX5_SUFFIX,
	DEBUG_STR_SUFFIX): Move to here.
	* dwarf-index-write.c (INDEX4_SUFFIX, INDEX5_SUFFIX,
	DEBUG_STR_SUFFIX): Move from there.
	(write_psymtabs_to_index): Make non-static, add basename
	parameter.  Write to temporary files, rename when done.
	(save_gdb_index_command): Adjust call to
	write_psymtabs_to_index.
	* dwarf2read.h (dwarf2_per_objfile) <index_cache_res>: New
	field.
	* dwarf2read.c (dwz_file) <index_cache_res>: New field.
	(get_gdb_index_contents_from_cache): New.
	(get_gdb_index_contents_from_cache_dwz): New.
	(dwarf2_initialize_objfile): Read index from cache.
	(dwarf2_build_psymtabs): Save to index.
	* dwarf-index-cache.h: New file.
	* dwarf-index-cache.c: New file.
	* dwarf-index-write.h: New file.

gdb/testsuite/ChangeLog:

	* boards/index-cache-gdb.exp: New file.
	* gdb.dwarf2/index-cache.exp: New file.
	* gdb.dwarf2/index-cache.c: New file.
	* gdb.base/maint.exp: Check if we are using the index cache.
2018-08-07 18:14:20 -04:00
Simon Marchi 8a99096f31 Import gnulib's mkdir module
The following patch makes use of the mkdir function.  Import the mkdir
gnulib module to ensure proper operation on all platforms.

gdb/ChangeLog:

	* gnulib/aclocal.m4: Re-generate.
	* gnulib/config.in: Re-generate.
	* gnulib/configure: Re-generate.
	* gnulib/import/Makefile.am: Re-generate.
	* gnulib/import/Makefile.in: Re-generate.
	* gnulib/import/m4/gnulib-cache.m4: Re-generate.
	* gnulib/import/m4/gnulib-comp.m4: Re-generate.
	* gnulib/import/m4/mkdir.m4: New file.
	* gnulib/import/mkdir.c: New file.
	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add mkdir
	module.
2018-08-07 18:13:52 -04:00
Simon Marchi 5c831bb1eb Introduce mmap_file function
New in v2:

- As Tom pointed out, we don't need to keep the fd around after
  mmapping.  This simplifies things quite a bit, since we don't need a
  new class.  It's now just a function that returns a scoped_mmap.

We already have scoped_mmap, which is a thin RAII layer over mmap.  If
one simply wants to mmap an entire file for reading, it takes a bit of
boilerplate.  This patch introduces the mmap_file function to make this
easier.

gdb/ChangeLog:

	* Makefile.in (COMMON_SFILES): Add common/scoped_mmap.c.
	* common/scoped_mmap.c: New file.
	* common/scoped_mmap.h (destroy): New method.
	(~scoped_mmap, reset): Use destroy.
	(scoped_mmap): New move constructor.
	(mmap_file): New declaration.
	* unittests/scoped_mmap-selftests.c (test_normal,
	test_invalid_filename, run_tests): New functions.
	(_initialize_scoped_mmap_selftests): Register selftest.
2018-08-07 18:10:29 -04:00
Simon Marchi 4485a1c1d8 Make index reading functions more modular
New in v3:

- Remove changed to dwarf-5 functions.

The read_gdb_index_from_section and read_debug_names_from_section
functions read the index content, as their names state, from sections of
object files.  A following patch will make it possible to read index
content from standalone files.

This patch therefore decouples the code that reads the index content
from the code that processes that content.  Functions
dwarf2_read_gdb_index and dwarf2_read_debug_names receive callbacks that
are responsible for providing the index contents (for both the main file
and the potential dwz file).

gdb/ChangeLog:

	* dwarf2read.c (read_gdb_index_from_section): Rename to...
	(read_gdb_index_from_buffer): ... this.  Remove section
	parameter, add buffer parameter.
	(get_gdb_index_contents_ftype,
	get_gdb_index_contents_dwz_ftype): New typedefs.
	(dwarf2_read_gdb_index): Add callback parameters to get the
	index contents.
	(get_gdb_index_contents_from_section): New.
	(dwarf2_initialize_objfile): Update call to
	dwarf2_read_gdb_index.
2018-08-07 18:08:58 -04:00
Simon Marchi 528e15722b Replace some uses of xstrprintf with string_printf
This patch replaces some simple uses of xstrprintf with with
string_printf, removing the need to do manual memory freeing.

The change in ada-lang.c fixes an apparent memory leak.

Regtested on the buildbot.

gdb/ChangeLog:

	* common/filestuff.h (gdb_fopen_cloexec): New overload.
	(gdb_open_cloexec): Likewise.
	* nat/linux-osdata.c (command_from_pid): Use string_printf.
	(commandline_from_pid): Likewise.
	(linux_xfer_osdata_threads): Likewise.
	(linux_xfer_osdata_fds): Likewise.
	* ada-lang.c (is_package_name): Likewise.
	* auxv.c (procfs_xfer_auxv): Likewise.
	* breakpoint.c (print_one_breakpoint_location): Use
	uiout::field_fmt.
	(print_one_catch_solib): Use string_printf.
	* coff-pe-read.c (add_pe_exported_sym): Likewise.
	(add_pe_forwarded_sym): Likewise.
	* dwarf2read.c (create_type_unit_group): Likewise.
	(build_error_marker_type): Likewise.
	* infcall.c (get_function_name): Likewise.
	* valprint.c (print_converted_chars_to_obstack): Likewise.
	* xtensa-tdep.c (xtensa_register_type): Likewise.
2018-08-07 17:43:08 -04:00
Rainer Orth 96d68bd48c Support parallel make check with GNU make 4.2+
I noticed that make -jN check would run make check-single when using GNU
make 4.2.1.

In the end, it turned out that this is due to this change from the make
4.2 NEWS file:

* The amount of parallelism can be determined by querying MAKEFLAGS, even when
  the job server is enabled (previously MAKEFLAGS would always contain only
  "-j", with no number, when job server was enabled).

The fix is trivial: just accept an optional arg to -j in Makefile.in
(saw_dash_j).  Tested on i386-pc-solaris2.11 with just make and make
-j/-jN with both make 3.82 and 4.2.1.

	* Makefile.in (saw_dash_j): Allow for GNU make 4.2+ passing -jN in
	MAKEFLAGS.
2018-08-07 13:20:40 +02:00
Alan Modra df136d64fa PowerPC64 EH info for _notoc linkage stubs
This patch generates EH info for the new _notoc linkage stubs, to
support unwinding from asynchronous signal handlers.  Unwinding
through the __tls_get_addr_opt stub was already supported, but that
was just a single stub.  With multiple stubs the EH opcodes need to be
emitted and sized when iterating over stubs, so this is done when
emitting and sizing the stub code.  Emitting the CIEs and FDEs is done
when sizing the stubs, as we did before in order to have the linker
generated FDEs indexed in .eh_frame_hdr.  I moved the final tweaks to
FDEs from ppc64_elf_finish_dynamic_sections to ppc64_elf_build_stubs
simply because it's tidier to be done with them at that point.

bfd/
	* elf64-ppc.c (struct map_stub): Delete tls_get_addr_opt_bctrl.
	Add lr_restore, eh_size and eh_base.
	(eh_advance, eh_advance_size): New functions.
	(build_tls_get_addr_stub): Emit EH info for stub.
	(ppc_build_one_stub): Likewise for _notoc stubs.
	(ppc_size_one_stub): Size EH info for stub.
	(group_sections): Init new map_stub fields.
	(stub_eh_frame_size): Delete.
	(ppc64_elf_size_stubs): Size EH info for stubs.  Set up dummy EH
	program for stubs.
	(ppc64_elf_build_stubs): Reinit new map_stub fields.  Set FDE
	offset to stub section here..
	(ppc64_elf_finish_dynamic_sections): ..rather than here.
ld/
	* testsuite/ld-powerpc/notoc.s: Generate some cfi.
	* testsuite/ld-powerpc/notoc.d: Adjust.
	* testsuite/ld-powerpc/notoc.wf: New file.
	* testsuite/ld-powerpc/powerpc.exp: Run "ext" and "notoc" tests
	as run_ld_link_tests rather than run_dump_test.
2018-08-07 18:43:55 +09:30
Alan Modra e81b4c933c __tls_get_addr_opt stubs and tocsave optimization
This patch fixes a bug in the handling of the __tls_get_addr_opt
stub.  Calls via this stub don't have a toc restoring instruction
following the "bl", and the stub itself doesn't have an initial toc
save instruction.  Thus it is incorrect to skip over the first
instruction when a __tls_get_addr call is marked with a tocsave
reloc.

	* elf64-ppc.c (ppc64_elf_relocate_section): Don't skip first
	instruction of __tls_get_addr_opt stub.
	(plt_stub_size): Omit ALWAYS_EMIT_R2SAVE condition when
	dealing with __tls_get_addr_opt stub.
	(build_tls_get_addr_stub, ppc_size_one_stub): Likewise.
2018-08-07 18:43:54 +09:30
Martin Storsjo 99f8774cca Explain what happens for PE targeted linkers in the case where the user actually tries to provide __CTOR_LIST__ and/or __DTOR_LIST__ symbols.
* scripttempl/pe.sc: Improve the comment about overriding
	__CTOR_LIST__ and __DTOR_LIST__ symbols.
	* scripttemp/pep.sc: Likewise.
2018-08-07 08:45:14 +01:00
James Patrick Conlon 8f9ea98beb Correct the parsing of derferred register addressing in the PDP11 assembler.
PR 23481
	* config/tc-pdp11.c (parse_op_noreg): Check for deferred register
	addressing before assuming non-deferred addressing.
	* testsuite/gas/pdp11/pr23481.s: New test source file.
	* testsuite/gas/pdp11/pr23481.d: New test driver file.
	* testsuite/gas/pdp11/pdp11.exp: Run the new test.
2018-08-07 08:34:08 +01:00
Nick Clifton 71f6efc44e Updated Bulgarian translation for the ld/ directory 2018-08-07 08:16:03 +01:00
GDB Administrator 877877f5d5 Automatic date update in version.in 2018-08-07 00:00:59 +00:00