Commit Graph

95339 Commits

Author SHA1 Message Date
Jan Vrany 26fb3983d7 MI: Add -a option to the "-data-disassemble" command
The CLI "disassemble" command allows specifying a single address - in
that case the function surrounding that address is disassembled.

This commit adds this feature to the equivalent MI command
"-data-disassemble".

gdb/ChangeLog:
2018-08-14  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* mi/mi-cmd-disas.c (mi_cmd_disassemble): Add -a option.
	If used, use find_pc_partial_function to find address range
	to disassemble.
	* mi/mi-main.c (mi_cmd_list_features): Report
	"data-disassemble-a-option" feature.
	* NEWS: Mention new -data-disassemble option -a.

gdb/doc/ChangeLog:
2018-08-14  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.texinfo (GDB/MI Data Manipulation): Document
	"-data-disassemble -a addr".
	(GDB/MI Support Commands): Document "data-disassemble-a-option"
	feature.

gdb/testsuite/ChangeLog:
2018-08-14  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.mi/mi-disassemble.exp (test_disassembly_only): Add tests for
	-data-disassemble -a.
	(test_disassembly_bogus_args): Likewise.
2018-08-14 14:13:28 +01:00
Andrew Burgess 67943c005f gdb: Fix instability in thread groups test
In the test script gdb.mi/list-thread-groups-available.exp we ask GDB
to list all thread groups, and match the output against a
regexp. Occasionally, I would see this test fail.

The expected output is a list of entries, each entry looking roughly
like this:

  {id="<DECIMAL>",type="process",description="<STRING>",
   user="<STRING>",cores=["<DECIMAL>","<DECIMAL>",...]}

All the fields after 'id' and 'type' are optional, and the 'cores'
list can contain 1 or more "<DECIMAL>" entries.

On my machine (Running Fedora 27, kernel 4.17.3-100.fc27.x86_64)
usually the 'description' is a non-empty string, and the 'cores' list
has at least one entry in it.  But sometimes, very rarely, I'll see an
entry in the process group list where the 'description' is an empty
string, the 'user' is the string "?", and the 'cores' list is empty.
Such an entry looks like this:

   {id="19863",type="process",description="",user="?",cores=[]}

I believe that this is caused by the process exiting while GDB is
scanning /proc for process information.  The current code in
gdb/nat/linux-osdata.c is not (I think) resilient against exiting
processes.

This commit adjusts the regex that matches the 'cores' list so that an
empty list is acceptable, with this patch in place the test script
gdb.mi/list-thread-groups-available.exp never fails for me now.

I've only adjusted the cores regexp for the occasion when we have GDB
read information about all processes, its only in this case that we
might encounter an exiting process.  When we read information about
two known PIDs, that we know will not exit for the duration of the
test, we require that the core list be non-empty.

gdb/testsuite/ChangeLog:

	* gdb.mi/list-thread-groups-available.exp: Update test regexp.
2018-08-14 13:38:51 +01:00
Robert Yang 2a50366ded When the assembler reports that the input and output are the same, report the file names involved, in order to help debugging. Also do not equate two files are the same if the have the same inode value but reside on different file systems.
* as.c (main): Improve check for input file matching output file.
2018-08-14 12:22:35 +01:00
GDB Administrator 08887f4a64 Automatic date update in version.in 2018-08-14 00:00:28 +00:00
Tom Tromey a97b53dda9 Define _FORTIFY_SOURCE in common-defs.h
This defines _FORTIFY_SOURCE in common-defs.h.  This seems like a
sensible safety measure, and also it may help avoid build problems
with -Wunused-result on distros that already define _FORTIFY_SOURCE by
default.

Tested by the buildbot.

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

	* common/common-defs.h (_FORTIFY_SOURCE): Define.
2018-08-13 10:02:00 -06:00
H.J. Lu 98641896ad bfd: Move elf-properties.lo to BFD32_LIBS
commit 6404ab9937
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Aug 8 21:00:04 2018 -0700

    Convert .note.gnu.property section between ELF32 and ELF64

updated bfd_convert_section_size and bfd_convert_section_contents
in bfd.c to call _bfd_elf_convert_gnu_property_size and
_bfd_elf_convert_gnu_properties, which are defined in elf-properties.c.
It led to

bfd.c:2484: undefined reference to `_bfd_elf_convert_gnu_property_size'

for non-ELF targets.  Since elf-properties.c is a generic implementation
and doesn't reference any ELF specific functions directly, this patch
moves elf-properties.lo BFD32_LIBS.

Tested for many ELF and non-ELF targets.

	PR binutils/23494
	* Makefile.am (BFD32_LIBS): Add elf-properties.lo.
	(BFD32_LIBS_CFILES): Add elf-properties.c.
	(BFD32_BACKENDS): Remove elf-properties.lo.
	(BFD32_BACKENDS_CFILES): Remove elf-properties.c.
	* configure.ac (elf): Remove elf-properties.lo.
	* Makefile.in: Regenerated.
	* configure: Likewise.
2018-08-13 07:24:44 -07:00
Alan Hayward 0c76e06d5c Parse SVE registers in aarch64 core file reading/writing
sve_regmap cannot be global static as the size is dependant on the current
vector length.

gdb/
	* aarch64-linux-tdep.c (aarch64_linux_supply_sve_regset): New function.
	(aarch64_linux_collect_sve_regset): Likewise.
	(aarch64_linux_iterate_over_regset_sections): Check for SVE.
	* regcache.h (regcache_map_entry_size): New function.
2018-08-13 11:02:22 +01:00
Alan Hayward b7fd65b9dc Detect SVE when reading aarch64 core files
The SVE section in a core file contains a header followed by the registers.
Add defines to easily access the header fields within a buffer.

gdb/
	* aarch64-linux-tdep.c (SVE_HEADER_SIZE_LENGTH): Add define.
	(SVE_HEADER_MAX_SIZE_LENGTH): Likewise.
	(SVE_HEADER_VL_LENGTH): Likewise.
	(SVE_HEADER_MAX_VL_LENGTH): Likewise.
	(SVE_HEADER_FLAGS_LENGTH): Likewise.
	(SVE_HEADER_RESERVED_LENGTH): Likewise.
	(SVE_HEADER_SIZE_OFFSET): Likewise.
	(SVE_HEADER_MAX_SIZE_OFFSET): Likewise.
	(SVE_HEADER_VL_OFFSET): Likewise.
	(SVE_HEADER_MAX_VL_OFFSET): Likewise.
	(SVE_HEADER_FLAGS_OFFSET): Likewise.
	(SVE_HEADER_RESERVED_OFFSET): Likewise.
	(SVE_HEADER_SIZE): Likewise.
	(aarch64_linux_core_read_vq): Add function.
	(aarch64_linux_core_read_description): Check for SVE section.
2018-08-13 10:51:45 +01:00
Alan Hayward a616bb9450 Split size in regset section iterators
In the existing code, when using the regset section iteration functions, the
size parameter is used in different ways.

With collect, size is used to create the buffer in which to write the regset.
(see linux-tdep.c::linux_collect_regset_section_cb).

With supply, size is used to confirm the existing regset is the correct size.
If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size.
Effectively, size is the minimum possible size of the regset.
(see corelow.c::get_core_register_section).

There are currently no targets with both REGSET_VARIABLE_SIZE and a collect
function.
In SVE, a corefile can contain one of two formats after the header, both of
which are different sizes. However, when writing a core file, we always want
to write out the full bigger size.

To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes.
This is done by adding supply_size and collect_size.

gdb/

	* aarch64-fbsd-tdep.c
	(aarch64_fbsd_iterate_over_regset_sections): Add supply_size and
	collect_size.
	* aarch64-linux-tdep.c
	(aarch64_linux_iterate_over_regset_sections): Likewise.
	* alpha-linux-tdep.c
	(alpha_linux_iterate_over_regset_sections):
	* alpha-nbsd-tdep.c
	(alphanbsd_iterate_over_regset_sections): Likewise.
	* amd64-fbsd-tdep.c
	(amd64fbsd_iterate_over_regset_sections): Likewise.
	* amd64-linux-tdep.c
	(amd64_linux_iterate_over_regset_sections): Likewise.
	* arm-bsd-tdep.c
	(armbsd_iterate_over_regset_sections): Likewise.
	* arm-fbsd-tdep.c
	(arm_fbsd_iterate_over_regset_sections): Likewise.
	* arm-linux-tdep.c
	(arm_linux_iterate_over_regset_sections): Likewise.
	* corelow.c (get_core_registers_cb): Likewise.
	(core_target::fetch_registers): Likewise.
	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
	* frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise.
	* gdbarch.h (void): Regenerate.
	* gdbarch.sh: Add supply_size and collect_size.
	* hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise.
	* hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise.
	* hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise.
	* i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise.
	* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise.
	* i386-tdep.c (i386_iterate_over_regset_sections): Likewise.
	* ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise.
	* linux-tdep.c (linux_collect_regset_section_cb): Likewise.
	* m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise.
	* m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise.
	* m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise.
	* mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise.
	* mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise.
	* mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise.
	* mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise.
	* mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise.
	* nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise.
	* ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise.
	* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise.
	* ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise.
	* ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise.
	* riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise.
	* s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise.
	* score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise.
	* sh-tdep.c (sh_iterate_over_regset_sections): Likewise.
	* sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise.
	* tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise.
	* vax-tdep.c (vax_iterate_over_regset_sections): Likewise.
	* xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
2018-08-13 10:16:41 +01:00
GDB Administrator facbd8bd3d Automatic date update in version.in 2018-08-13 00:00:51 +00:00
H.J. Lu 988daa317c ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s
Swap pr23486a.s and pr23486a.s so that pr23486b.d differs from pr23486a.d.

	* testsuite/ld-x86-64/pr23486b.d: Swap pr23486a.s and pr23486a.s.
2018-08-12 05:39:00 -07:00
GDB Administrator 8e92e6d4b2 Automatic date update in version.in 2018-08-12 00:01:17 +00:00
H.J. Lu d871f3f483 x86: Add CpuCMOV and CpuFXSR
There are separate CPUID feature bits for fxsave/fxrstor and cmovCC
instructions.  This patch adds CpuCMOV and CpuFXSR to replace Cpu686
on corresponding instructions.

gas/

	* config/tc-i386.c (cpu_arch): Add .cmov and .fxsr.
	(cpu_noarch): Add nocmov and nofxsr.
	* doc/c-i386.texi: Document cmov and fxsr.

opcodes/

	* i386-gen.c (cpu_flag_init): Add CpuCMOV and CpuFXSR to
	CPU_I686_FLAGS.  Add CPU_CMOV_FLAGS, CPU_FXSR_FLAGS,
	CPU_ANY_CMOV_FLAGS and CPU_ANY_FXSR_FLAGS.
	(cpu_flags): Add CpuCMOV and CpuFXSR.
	* i386-opc.tbl: Replace Cpu686 with CpuFXSR on fxsave, fxsave64,
	fxrstor and fxrstor64.  Replace Cpu686 with CpuCMOV on cmovCC.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
2018-08-11 14:37:32 -07:00
H.J. Lu ab9e342807 x86: Properly add X86_ISA_1_NEEDED property
Existing properties may be removed during property merging.  We avoid
adding X86_ISA_1_NEEDED property only if existing properties won't be
removed.

bfd/

	PR ld/23428
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Don't
	add X86_ISA_1_NEEDED property only if existing properties won't
	be removed.

ld/

	PR ld/23428
	* testsuite/ld-elf/dummy.s: New file.
	* testsuite/ld-elf/linux-x86.S: Add X86_FEATURE_1_AND property.
	* testsuite/ld-elf/linux-x86.exp: Add dummy.s to pr23428.
2018-08-11 06:41:33 -07:00
Alan Modra 1dc9e2d63e Factor out common relocation processing
This patch factors out some code common to both bfd_perform_relocation
and bfd_install_relocation, in the process fixing the omission of
"case -1" in bfd_install_relocation.

	* reloc.c (bfd_get_reloc_size): Sort switch.
	(read_reloc, write_reloc, apply_reloc): New functions.
	(bfd_perform_relocation, bfd_install_relocation): Use apply_reloc.
	(_bfd_relocate_contents): Use read_reloc and write_reloc.
	(_bfd_clear_contents): Likewise.
2018-08-11 13:39:16 +09:30
John Darrington 7cf9ebc695 Deal with relocations which are 3 bytes in size
* reloc.c (_bfd_relocate_contents): Handle 3 byte relocs.
	(_bfd_clear_contents): Likewise.
	(bfd_perform_relocation): Likewise.
	(bfd_install_relocation): Likewise.
2018-08-11 11:11:39 +09:30
GDB Administrator ae1f3b64e5 Automatic date update in version.in 2018-08-11 00:00:27 +00:00
Simon Marchi a9925d4f99 Fix forgotten xstrprintf -> string_printf change
The patch

  528e157 ("Replace some uses of xstrprintf with string_printf")

forgot to actually change an xstrprintf call to string_printf, this one
fixes it.

gdb/ChangeLog:

	* nat/linux-osdata.c (commandline_from_pid): Replace xstrprintf
	with string_printf.
2018-08-10 18:01:11 -04:00
H.J. Lu 48e30f5238 Always clear h->verinfo.verdef when overriding a dynamic definition
When linker defines a symbol to override a dynamic definition, it should
always clear h->verinfo.verdef so that the symbol won't be associated
with the version information from the dynamic object.  This happened to
the symbol "_edata" when creating an unversioned dynamic object linking
against:

1. libKF5ConfigCore.so.5.49.0
2. libKF5CoreAddons.so.5.49.0
3. libKF5I18n.so.5.49.0
4. libKF5DBusAddons.so.5.49.0
5. libQt5Xml.so.5.11.1
6. libQt5DBus.so.5.11.1
7. libQt5Core.so.5.11.1

Among them

libQt5Xml.so.5.11.1
   299: 000000000003e000     0 NOTYPE  GLOBAL DEFAULT   18 _edata@@Qt_5
libQt5DBus.so.5.11.1
   597: 0000000000092018     0 NOTYPE  GLOBAL DEFAULT   18 _edata@@Qt_5
libQt5Core.so.5.11.1
  2292: 00000000004df640     0 NOTYPE  GLOBAL DEFAULT   21 _edata@Qt_5
  2293: 00000000004df640     0 NOTYPE  GLOBAL DEFAULT   21 _edata@Qt_5

The problem is triggered by 2 duplicated entries of _edata@Qt_5 in
libQt5Core.so.5.11.1 which was created by gold.  Before this commit,
ld created the dynamic object with "_edata" in its dynamic symbol table
which was linker defined and associated with the version information
from libQt5Core.so.5.11.1.  The code in question was there when the
binutils source was imported to sourceware.org.  When such a dynamic
object was used later, we got:

/usr/bin/ld: bin/libKF5Service.so.5.49.0: _edata: invalid version 21 (max 0)
/usr/bin/ld: bin/libKF5Service.so.5.49.0: error adding symbols: bad value

Tested with many ELF targets.

	PR ld/23499
	* elflink.c (bfd_elf_record_link_assignment): Always clear
	h->verinfo.verdef when overriding a dynamic definition.
2018-08-10 12:22:09 -07:00
Keith Seitz ad3a68e9b9 Use policies for code generation
This patch changes code generation procedures add_code_header,
add_code_footer, and several other language-specific code generation
functions into policies.

gdb/ChangeLog:
        * compile/compile-c-support.c (add_code_header, add_code_footer):
        Move into policy class.
        (c_push_user_expression, pop_user_expression_nop)
        (c_add_code_header, c_add_code_footer, c_add_input): New policy class.
        (compile_program): New host class.
        (c_compile_program): New typedef.
        (c_compute_porgram): Use c_compile_program.
2018-08-10 11:14:25 -07:00
Keith Seitz 0cfbf43085 Use unique_ptr for htabs
This patch updates the type-conversion caching in C compile to use
unique pointers.  This patch also removes the on-demand allocation of the
symbol error map in favor of initialization, simplifying the code.

gdb/ChangeLog
        * compile/compile-internal.h (compile_instance::~compile_instance):
        Remove calls to htab_delete.
        <m_type_map, m_symbol_err_map>: Switch type to htab_up.
        * compile.c (compile_instance::compile_instance): Initialize
        htab unique pointers.
        (compile_instance::get_cached_type, compile_instance::insert_type)
        (compile_instance::error_symbol_once): Update for unique_ptr.
2018-08-10 11:14:25 -07:00
Keith Seitz 946d3d10e7 Move compile_instance to compile.c
This simple patch moves any code related to compile_instance into
compile.c, reserving compile-c-* files strictly for C language support.

gdb/ChangeLog:
        * compile/compile-c-symbols.c (struct symbol_error)
        (hash_symbol_error, eq_symbol_error, del_symbol_error)
        (compile_instance::insert_symbol_error)
        (compile_instance::error_symbol_once): Move to ...
        * compile/compile.c: ... here.
2018-08-10 11:14:25 -07:00
Keith Seitz 9cdfd9a26e Change compile_instance/compile_c_instance into classes
This patch changes structs compile_instance and compile_c_instance into
classes.

Because of the nature of the change, there are a number of unavoidably
mechanical changes buried in here, such as turning variable access of the
POD struct into method calls, removing the struct keyword, and changing
access of the plugin from "c_plugin->operation()" to
"plugin ().operation ()".

There is one "non-trivial" change associated with this patch, though.
The type cache and symbol error maps have been moved into the base class,
believing these facilities would be used other language implementations.
[They are indeed re-used by C++.]

gdb/ChangeLog:

        * compile/compile-c-support.c (c_get_compile_context): Use `new'
        instead of `new_compile_instance'.
        * compile/compile-c-symbols.c (compile_instance::insert_symbol_error):
        Update description.
        If the symbol error map is not initialized, create it.
        (generate_c_for_for_one_symbol): Do not check/initialize
        the symbol error map.
        * compile/compile-c-types.c (compile_c_instance): Make a class.
        Update all callers.
        (compile_instance::compile_instance): Initialize the type cache.
        (get_cached_type): New function.
        (insert_type): Update description.
        (compile_c_instance::m_default_cflags): Define.
        (convert_type): Update description.  Use get_cached_type.
        (delete_instance): Moved to destructor.
        (new_compile_instance): Moved to constructor.
        * compile/compile-c.h (compile_c_instance): Make class inheriting
        from compile_instance.
        <base>: Remove field.
        <type_map, symbol_err_map>: Move to base class.
        <c_plugin>: Rename to `m_plugin' and remove pointer type.
        * compile/compile-internal.h (compile_instance): Make class.
        <type_map_t, symbol_err_map_t>: Define.
        <fe>: Rename to `m_gcc_fe'.
        <scope, block, gcc_target_options>: Add `m_' prefix.
        <m_type_map, m_symbol_err_map>: New fields, moved from
        compile_c_instance.
        <destroy>: Remove.
        (convert_type, new_compile_instance): Remove.
        * compile/compile.c (cleanup_compile_instance): Remove.
        (compile_to_object): Use unique_ptr to eliminate cleanups.
        (compile_instance::set_print_callback, compile_instance::version)
        (compile_instance::set_verbose)
        (compile_instance::set_driver_filename)
        (compile_instance::set_triplet_regexp)
        (compile_instance::set_arguments)
        (compile_instance::set_source_file)
        (compile_instance::compile): Define.
2018-08-10 11:14:25 -07:00
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