Commit Graph

93122 Commits

Author SHA1 Message Date
GDB Administrator c76ff6936b Automatic date update in version.in 2018-01-01 00:00:38 +00:00
Ruslan Kabatsayev 47fea87745 Avoid indexing std::vector past the end
The code here wants to find address of an element, and often this
element is one past the end of std::vector. Dereferencing that element
leads to undefined behavior, so it's better to simply use pointer
arithmetic instead of taking address of invalid dereference.

gdb/ChangeLog:

	* psymtab.c (recursively_search_psymtabs): Use pointer arithmetic
	instead of dereferencing std::vector past the end.
2017-12-31 11:55:19 +03:00
Simon Marchi cfa27c399e Only ignore -Wenum-compare-switch if it exists
My patch

  dwarf2read: Silence -Wenum-compare-switch warning
  132448f835

made some parts of dwarf2read.c ignore warnings about switch using enums
of different kinds.  What I did not realize was that older Clang
versions (prior to 6) did not have that warning, and therefore give this
error:

/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24187:7: error: unknown warning group '-Wenum-compare-switch', ignored [-Werror,-Wunknown-pragmas]
      DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES
      ^
/home/emaisin/src/binutils-gdb/gdb/common/diagnostics.h:42:3: note: expanded from macro 'DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES'
  DIAGNOSTIC_IGNORE ("-Wenum-compare-switch")
  ^
/home/emaisin/src/binutils-gdb/gdb/common/diagnostics.h:27:3: note: expanded from macro 'DIAGNOSTIC_IGNORE'
  _Pragma (STRINGIFY (GCC diagnostic ignored option))
  ^
<scratch space>:10:25: note: expanded from here
 GCC diagnostic ignored "-Wenum-compare-switch"
                        ^

Clang has a way to test if it knows about a particular warning.  This
patch uses that feature to only define
DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES to something if the
warning is recognized by the Clang version being used.  I tested
building dwarf2read.c with clang 4, 5, 6, as well as gcc.

gdb/ChangeLog:

	* common/diagnostics.h
	(DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): Only
	define if the compiler knows about -Wenum-compare-switch.
2017-12-30 23:33:26 -05:00
Simon Marchi 132448f835 dwarf2read: Silence -Wenum-compare-switch warning
Compiling with Clang 6 gives:

/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24385:14: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch]
        case DW_MACINFO_vendor_ext:
             ^~~~~~~~~~~~~~~~~~~~~
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24561:7: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch]
        case DW_MACINFO_vendor_ext:
             ^~~~~~~~~~~~~~~~~~~~~

This code uses the two enum types on purpose, because it handles both
.debug_macro and .debug_macinfo sections.  Add some pragmas to disable
the warning in these specific cases.

gdb/ChangeLog:

	* dwarf2read.c (dwarf_decode_macro_bytes): Ignore
	-Wenum-compare-switch warning.
	(dwarf_decode_macros): Likewise.
2017-12-30 21:24:42 -05:00
Tom Tromey e9d9f57e11 C++-ify parser_state
This mildly C++-ifies parser_state and stap_parse_info -- just enough
to remove some cleanups.

This version includes the changes implemented by Simon.

Regression tested by the buildbot.

gdb/ChangeLog
2017-12-30  Tom Tromey  <tom@tromey.com>
	    Simon Marchi  <simon.marchi@ericsson.com>

	* stap-probe.h (struct stap_parse_info): Add constructor,
	destructor.
	* stap-probe.c (stap_parse_argument): Update.
	* rust-exp.y (rust_lex_tests): Update.
	* parser-defs.h (struct parser_state): Add constructor,
	destructor, release method.
	<expout>: Change type to expression_up.
	(null_post_parser): Change type.
	(initialize_expout, reallocate_expout): Remove.
	* parse.c (parser_state::parser_state): Rename from
	initialize_expout.
	(parser_state::release): Rename from reallocate_expout.
	(write_exp_elt, parse_exp_in_context_1, increase_expout_size):
	Update.
	(null_post_parser): Change type of "exp".
	* dtrace-probe.c (dtrace_probe::build_arg_exprs): Update.
	* ada-lang.c (resolve, resolve_subexp)
	(replace_operator_with_call): Change type of "expp".
	* language.h (struct language_defn) <la_post_parser>: Change type
	of "expp".
2017-12-30 17:05:37 -07:00
GDB Administrator a594729cfb Automatic date update in version.in 2017-12-31 00:00:27 +00:00
Simon Marchi fc898b42e3 Make mapped_debug_names and mapped_index final
When compiling with Clang 6, I see these warnings:

/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25421:5: error: destructor called on non-final 'mapped_index' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
    data->index_table->~mapped_index ();
    ^
In file included from /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:31:
In file included from /home/emaisin/src/binutils-gdb/gdb/defs.h:28:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/common-defs.h:92:
In file included from /home/emaisin/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:23:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/memory:81:
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:76:2: error: delete called on non-final 'mapped_debug_names' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
        delete __ptr;
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:236:4: note: in instantiation of member function 'std::default_delete<mapped_debug_names>::operator()' requested here
          get_deleter()(__ptr);
          ^
/home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:2374:21: note: in instantiation of member function 'std::unique_ptr<mapped_debug_names, std::default_delete<mapped_debug_names> >::~unique_ptr' requested here
dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_,
                    ^

This patch silences these warnings by making the classes final.

gdb/ChangeLog:

	* dwarf2read.c (struct mapped_debug_names): Make final.
	(struct mapped_index): Make final.
2017-12-30 00:10:17 -05:00
Simon Marchi 0436426c7f Ignore warning about using different types of enums in switch
When compiling with clang 6, I see a bunch of warnings like this:

/home/emaisin/src/binutils-gdb/gdb/amd64-linux-tdep.c:1427:8: error: comparison of two values with different enumeration types in switch statement ('enum amd64_syscall' and 'amd
64_x32_syscall') [-Werror,-Wenum-compare-switch]
  case amd64_x32_sys_move_pages:
       ^~~~~~~~~~~~~~~~~~~~~~~~

In this switch, we indeed use enumerators of both types
amd64_x32_syscall and amd64_syscall.  This is done on purpose, and the
enum values are chosen so that they are complementary.

I think it's still a useful warning, so I chose to ignore just that
particular case.

gdb/ChangeLog:

	* common/diagnostics.h
	(DIAGNOSTIC_IGNORE_SWITCH_DIFFERENT_ENUM_TYPES): New macro.
	* amd64-linux-tdep.c (amd64_canonicalize_syscall): Use it.
2017-12-29 23:32:29 -05:00
Simon Marchi 502a625ab0 Remove unnecessary call to get_thread_db_info
In thread_db_detach, we call get_thread_db_info to first check if there
exists a thread_db_info entry for the pid to detach.  If there is, then
we call delete_thread_db_info.  It's unnecessary to call
get_thread_db_info in the first place, since delete_thread_db_info
handles the case where no thread_db_info entry exist for the given pid.

gdb/ChangeLog:

	* linux-thread-db.c (thread_db_detach): Remove call to
	delete_thread_db_info.
2017-12-29 21:57:08 -05:00
GDB Administrator 4b2dfff9e7 Automatic date update in version.in 2017-12-30 00:00:30 +00:00
GDB Administrator ffd727ca6e Automatic date update in version.in 2017-12-29 00:00:34 +00:00
Jim Wilson d9be0c189a RISC-V: Add missing privileged spec registers.
gas/
	* testsuite/gas/riscv/priv-reg.d, testsuite/gas/riscv/priv-reg.s: New.

	include/
	* opcode/riscv-opc.h (DECLARE_CSR): Add missing privileged registers.
	Sort to match privileged spec documentation order.
	(DECLARE_CSR_ALIAS): Add ubadaddr, and comments.
2017-12-28 13:21:46 -08:00
Simon Marchi 4ee2b642dd Remove unused HP-UX TARGET_OBJECT_ enums
These two enumerators are unused, remove them.

gdb/ChangeLog:

	* target.h (enum target_object) <TARGET_OBJECT_HPUX_UREGS,
	TARGET_OBJECT_HPUX_SOLIB_GOT>: Remove.
2017-12-28 12:29:33 -05:00
GDB Administrator 0f833180d3 Automatic date update in version.in 2017-12-28 00:00:21 +00:00
Stafford Horne cef0f8684e tdesc: handle arbitrary strings in tdesc_register_in_reggroup_p
tdesc_register_in_reggroup_p in now able to handle arbitrary
groups. This is useful when groups are created while the
target descriptor file is received from the remote.

This can be the case of a soft core target processor where
registers/groups can change.

gdb/ChangeLog:

yyyy-mm-dd  Franck Jullien  <franck.jullien@gmail.com>
	    Stafford Horne  <shorne@gmail.com>

	* target-descriptions.c (tdesc_register_in_reggroup_p): Support
	arbitrary strings.
	(tdesc_use_registers): Add logic to register new reggroups.
	(tdesc_reg::group): Update comment to indicate we allow
	arbitrary strings.
	* NEWS (Changes since GDB 8.0): Announce that GDB supports
	arbitrary reggroups.

gdb/testsuite/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* gdb.xml/extra-regs.xml: Add example foo reggroup.
	* gdb.xml/tdesc-regs.exp: Add test to check for foo reggroup.

gdb/doc/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* gdb.texinfo (Target Description Format): Explain that arbitrary
	strings are now allowed for register groups.
2017-12-27 23:36:31 +09:00
Stafford Horne f7efd54948 reggroups: Add reggroup_gdbarch_new, reggroup_find for dynamic reggroups
Traditionally reggroups have been created via reggroup_new() during
initialization code and never freed.  Now, if we want to initialize
reggroups dynamically (i.e. in target description) we should be able to
free them.  Create this function reggroup_gdbarch_new() which will
allocate the reggroup memory onto the passed gdbarch obstack.

Also creating reggroup_find() as a utility to find a gdbarch registered
reggroup object by name.

gdb/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* reggroups.c (reggroup_gdbarch_new): New function.
	(reggroup_find): New function.
	* reggroups.h (reggroup_gdbarch_new): New function.
	(reggroup_find): New function.
2017-12-27 23:36:31 +09:00
Stafford Horne c1166ca9f3 reggroups: Convert reggroups from post_init to pre_init
Currently the reggroups gdbarch_data cannot be manipulated until after
the gdbarch is completely initialized.  This is usually done when the
object init depends on architecture specific fields.  In the case of
reggroups it only depends on the obstack being available.

Coverting this to pre_init allows using reggroups during gdbarch
initialization.  This is needed to allow registering arbitrary reggroups
during gdbarch initializations.

gdb/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* reggroups.c (reggroups_init): Change to depend only on
	obstack rather than gdbarch.
	(reggroup_add): Remove logic for forcing premature init.
	(_initialize_reggroup): Set `reggroups_data` with
	gdbarch_data_register_pre_init() rather than
	gdbarch_data_register_post_init().
2017-12-27 23:36:30 +09:00
Stafford Horne b67d92b06e reggroups: Add test and docs for `info reg $reggroup` feature
Until now this feature has existed but was not documented.  Adding docs
and tests.

gdb/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* infcmd.c (_initialize_infcmd): Add help for info reg $reggroup
	and info all-registers $reggroup feature.

gdb/doc/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* gdb.texinfo (Registers): Document info reg $reggroup feature.

gdb/testsuite/ChangeLog:

yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>

	* gdb.base/reggroups.c: New file.
	* gdb.base/reggroups.exp: New file.
2017-12-27 23:36:30 +09:00
GDB Administrator 76bce0d1d5 Automatic date update in version.in 2017-12-27 00:00:21 +00:00
GDB Administrator a811763d74 Automatic date update in version.in 2017-12-26 00:00:28 +00:00
GDB Administrator dc6af97a85 Automatic date update in version.in 2017-12-25 00:00:30 +00:00
GDB Administrator a6c42a6e74 Automatic date update in version.in 2017-12-24 00:00:39 +00:00
Simon Marchi 6e8c24fe27 Add ATTRIBUTE_PRINTF to printf_field_type_assignment
Get rid of:

/home/simark/src/binutils-gdb/gdb/target-descriptions.c:2026:25: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
    vprintf_unfiltered (fmt, args);

when building with clang.

gdb/ChangeLog:

	* target-descriptions.c (print_c_tdesc)
	<printf_field_type_assignment>: Add ATTRIBUTE_PRINTF.
2017-12-23 16:25:06 -05:00
GDB Administrator 5c8833d2fa Automatic date update in version.in 2017-12-23 00:00:31 +00:00
GDB Administrator 845756abe8 Automatic date update in version.in 2017-12-22 00:00:31 +00:00
Simon Marchi a8d2e5856f Do not emit "field_type" var if not needed on "maint print c-tdesc"
While fiddling a bit with -Wunused-variable, Sergio noticed that "maint
print c-tdesc" was always generating code for the "tdesc_type
*field_type" variable, even when it wasn't used.  This is caught by GCC
when using -Wunused-variable, of course.

This patch changes the print_c_tdesc class to only output the field
declaration when we actually need it.

It shouldn't be necessary to do the same with the other variable
declarations (type_with_fields and element_type), because they are
always if they are declared.

The C files in features/ are regenerated, some declarations of
field_type are removed, as expected, while some others move to where
they are used for the first time.

gdb/ChangeLog:

	* target-descriptions.c (print_c_tdesc) <visit>: Don't output
	field_type declaration, use printf_field_type_assignment
	instead.
	<printf_field_type_assignment>: New method.
	* features/aarch64-core.c, features/aarch64-fpu.c
	features/arc-arcompact.c, features/arc-v2.c,
	features/arm/arm-with-iwmmxt.c, features/i386/32bit-core.c,
	features/i386/32bit-mpx.c, features/i386/32bit-sse.c,
	features/i386/64bit-avx512.c, features/i386/64bit-core.c,
	features/i386/64bit-mpx.c, features/i386/64bit-sse.c,
	features/i386/x32-core.c, features/or1k.c,
	features/rs6000/powerpc-7400.c,
	features/rs6000/powerpc-altivec32.c,
	features/rs6000/powerpc-altivec32l.c,
	features/rs6000/powerpc-altivec64.c,
	features/rs6000/powerpc-altivec64l.c,
	features/rs6000/powerpc-cell32l.c,
	features/rs6000/powerpc-cell64l.c,
	features/rs6000/powerpc-isa205-altivec32l.c,
	features/rs6000/powerpc-isa205-altivec64l.c,
	features/rs6000/powerpc-isa205-vsx32l.c,
	features/rs6000/powerpc-isa205-vsx64l.c,
	features/rs6000/powerpc-vsx32.c,
	features/rs6000/powerpc-vsx32l.c,
	features/rs6000/powerpc-vsx64.c,
	features/rs6000/powerpc-vsx64l.c, features/s390-gs-linux64.c,
	features/s390-tevx-linux64.c, features/s390-vx-linux64.c,
	features/s390x-gs-linux64.c, features/s390x-tevx-linux64.c,
	features/s390x-vx-linux64.c: Re-generate.
2017-12-21 18:21:45 -05:00
Uros Bizjak 27e9ff87a6 Remove write-only assignment in rs6000-tdep.c
The result of this memory read is never used, so it can be removed.

gdb/ChangeLog:

	* rs6000-tdep.c (ppc_deal_with_atomic_sequence): Remove
	write-only assignment to "insn" variable.
2017-12-20 20:42:21 -05:00
GDB Administrator 6eab0eaa1b Automatic date update in version.in 2017-12-21 00:00:39 +00:00
Jim Wilson 21a186f280 RISC-V: Add compressed instruction hints, and a few misc cleanups.
gas/
	* config/tc-riscv.c (risc_ip) <o>: Add comment.
	* testsuite/gas/riscv/c-nonzero-imm.d,
	* testsuite/gas/riscv/c-nonzero-imm.l,
	* testsuite/gas/riscv/c-nonzero-imm.s,
	* testsuite/gas/riscv/c-nonzero-reg.d,
	* testsuite/gas/riscv/c-nonzero-reg.l,
	* testsuite/gas/riscv/c-nonzero-reg.s,
	* testsuite/gas/riscv/c-zero-imm-64.d,
	* testsuite/gas/riscv/c-zero-imm-64.s,
	* testsuite/gas/riscv/c-zero-imm.d, testsuite/gas/riscv/c-zero-imm.s,
	* testsuite/gas/riscv/c-zero-reg.d,
	* testsuite/gas/riscv/c-zero-reg.s: New.

	opcodes/
	* riscv-opc.c (match_c_add_with_hint, match_c_lui_with_hint): New.
	(riscv_opcodes) <li>: Delete "d,0" line.  Change Cj to Co.
	<andi, and, add, addiw, addw, c.addi>: Change Cj to Co.
	<add>: Add explanatory comment for 4-operand add instruction.
	<c.nop>: Add support for immediate operand.
	<c.mv, c.add>: Use match_c_add_with_hint instead of match_c_add.
	<c.lui>: Use match_c_lui_with_hint instead of match_c_lui.
	<c.li, c.slli>: Use match_opcode instead of match_rd_nonzero.
2017-12-20 13:37:44 -08:00
Ulrich Weigand 396d3980f5 [Cell/B.E.] Fix regression due to gdbarch_significant_addr_bit
On Cell/B.E. multi-architecture debugging we use a "merged" address space
that encodes both the main PowerPC address space and the local store address
spaces of all active SPUs.  This will always occupy 64 bits.

However, gdbarch_addr_bit is set to 32 on SPU, and may be set to 32 as well
on PowerPC.  Since the new gdbarch_significant_addr_bit defaults to the
value of gdbarch_addr_bit, this means addresses may be improperly truncated.

Work around this problem by explicitly setting gdbarch_significant_addr_bit
to 64 both for the SPU target and also for PowerPC target that support
Cell/B.E. execution.

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

	* spu-tdep.c (spu_gdbarch_init): Set set_gdbarch_significant_addr_bit
	to 64 bits.
	(ppc_linux_init_abi): Likewise, if Cell/B.E. is supported.
2017-12-20 13:59:14 +01:00
Simon Marchi 175654b9cd Fix ChangeLog formatting
Doing some unrelated grepping found that there were some missing
spaces, fix it.
2017-12-19 22:12:58 -05:00
GDB Administrator 0a16b291e0 Automatic date update in version.in 2017-12-20 00:00:21 +00:00
Tamar Christina 00c2093f69 Correct disassembly of dot product instructions.
Dot products deviate from the normal disassembly rules for lane indexed
instruction. Their canonical representation is in the form of:

v0.2s, v0.8b, v0.4b[0] instead of v0.2s, v0.8b, v0.b[0] to try to denote
that these instructions select 4x 1 byte elements instead of a single 1 byte
element.

Previously we were disassembling them following the normal rules, this patch
corrects the disassembly.

gas/

	PR gas/22559
	* config/tc-aarch64.c (vectype_to_qualifier): Support AARCH64_OPND_QLF_S_4B.
	* gas/testsuite/gas/aarch64/dotproduct.d: Update disassembly.

include/

	PR gas/22559
	* aarch64.h (aarch64_opnd_qualifier): Add AARCH64_OPND_QLF_S_4B.

opcodes/

	PR gas/22559
	* aarch64-asm.c (aarch64_ins_reglane): Change AARCH64_OPND_QLF_S_B to
	AARCH64_OPND_QLF_S_4B
	* aarch64-dis.c (aarch64_ext_reglane): Change AARCH64_OPND_QLF_S_B to
	AARCH64_OPND_QLF_S_4B
	* aarch64-opc.c (aarch64_opnd_qualifiers): Add 4b variant.
	* aarch64-tbl.h (QL_V2DOT): Change S_B to S_4B.
2017-12-19 12:21:12 +00:00
Tamar Christina a3b3345ae6 Add support for V_4B so we can properly reject it.
Previously parse_vector_type_for_operand was changed to allow the use of 4b
register size for indexed lane instructions. However this had the unintended
side effect of also allowing 4b for normal vector registers.

Because this support was only partial the rest of the tool silently treated
4b as 8b and continued. This patch adds full support for 4b so it can be
properly distinguished from 8b and the correct errors are generated.

With this patch you still can't encode any instruction which actually requires
v<num>.4b but such instructions don't exist so to prevent needing a workaround
in get_vreg_qualifier_from_value this was just omitted.

gas/

	PR gas/22529
	* config/tc-aarch64.c (vectype_to_qualifier): Support AARCH64_OPND_QLF_V_4B.
	* gas/testsuite/gas/aarch64/pr22529.s: New.
	* gas/testsuite/gas/aarch64/pr22529.d: New.
	* gas/testsuite/gas/aarch64/pr22529.l: New.

include/

	PR gas/22529
	* opcode/aarch64.h (aarch64_opnd_qualifier): Add AARCH64_OPND_QLF_V_4B.

opcodes/

	PR gas/22529
	* aarch64-opc.c (aarch64_opnd_qualifiers): Add 4b variant.
2017-12-19 12:19:15 +00:00
Nick Clifton bef7475fbd Stop readelf from complaining about relocation sections with an sh_info field of 0 in dynamic executables.
PR 22587
	* readelf.c (process_section_headers): Do not complain about an
	sh_info field of 0 in relocation sections of ET_EXEC or ET_DYN
	type executables.
2017-12-19 09:48:40 +00:00
GDB Administrator be62dcaa17 Automatic date update in version.in 2017-12-19 00:00:18 +00:00
Alan Modra 63f452a8bf PR22626, invalid dynindx used for dynamic relocs against section syms
_bfd_elf_link_renumber_dynsyms is called twice by the linker.  The
first call in bfd_elf_size_dynamic_sections is just to answer the
question as to whether there are there any dynamic symbols.  The
second call in bfd_elf_size_dynsym_hash_dynstr sets the st_shndx value
that dynamic symbols will have.  strip_excluded_output_sections is
called between these two calls.  So sections seen on the first
_bfd_elf_link_renumber_dynsyms pass might differ from those seen on
the second pass.  Unfortunately, that can result in a stripped
section's dynamic symbol being assigned a dynindx on the first pass
but not corrected to the final value (of zero, ie. not dynamic) on the
second pass.  PowerPC, x86, mips, and most other targets that emit
dynamic section symbols, just test that section symbol dynindx is
non-zero before using a given section symbol in dynamic relocations.

This patch prevents _bfd_elf_link_renumber_dynsyms from setting any
section symbol dynindx on the first pass.

	PR 22626
	* elflink.c (_bfd_elf_link_renumber_dynsyms): Don't set section
	dynindx when section_sym_count is NULL.
	(bfd_elf_size_dynamic_sections): Pass NULL section_sym_count to
	preliminary _bfd_elf_link_renumber_dynsyms call.
2017-12-19 06:53:22 +10:30
Alan Modra f795c49463 Test binutils_assemble return value
This is a followup to "binutils nm testsuite tidy".  Since the perror
in binutils_assemble has been removed, we need to take more care in
failure paths.

The patch also fixed a number of .exp files that have multiple tests,
where an assembly failure returns from the .exp file.  In most cases
it is nicer to attempt all tests.

	* testsuite/binutils-all/ar.exp (unique_symbol): Don't run AR
	if assembly fails.
	* testsuite/binutils-all/arc/objdump.exp (check_assembly): If
	objfile is empty, fail test.
	* testsuite/binutils-all/arm/objdump.exp: Don't return if assembly
	fails for a test, continue on to other tests.
	* testsuite/binutils-all/bfin/objdump.exp: Likewise.
	* testsuite/binutils-all/hppa/objdump.exp: Likewise.
	* testsuite/binutils-all/m68k/objdump.exp: Likewise.
	* testsuite/binutils-all/vax/objdump.exp: Likewise.
	* testsuite/binutils-all/size.exp: Likewise.
	* testsuite/binutils-all/nm.exp: Likewise.  Move PR12753 test.
	* testsuite/binutils-all/objcopy.exp: Don't perror on assembly fail.
	* testsuite/binutils-all/objdump.exp: Report assembly fails.
2017-12-19 06:51:33 +10:30
Nick Clifton c54207d326 Decode expression lists used with DW_AT_byte_size and other DWARF attributes.
PR 22532
	* dwarf.c (read_and_display_attr_value): Add attributes that might
	use the DW_FORM_exprloc form, and if so, display the decoded
	location expression list.
2017-12-18 17:57:18 +00:00
Nick Clifton 4f588891ac Resolve PR 22493 - the encoding to be used when pushing the stack pointer onto the stack.
PR 22493
	* config/tc-arm.c (encode_ldmstm): Do not use A2 encoding of the
	PUSH insn when pushing the stack pointer.
2017-12-18 09:37:57 +00:00
Jan Beulich 10c17abdd0 x86: fold certain AVX and AVX2 templates
Just like for instructions in GPRs, there's no need to have separate
templates for otherwise identical insns acting on XMM or YMM registers
(or memory of the same size).
2017-12-18 09:37:15 +01:00
Jan Beulich 1b54b8d7e4 x86: fold RegXMM/RegYMM/RegZMM into RegSIMD
... qualified by their respective sizes, allowing to drop FirstXmm0 at
the same time.
2017-12-18 09:36:14 +01:00
Jan Beulich ca0d63fe07 x86: drop FloatReg and FloatAcc
Express them as Reg|Tbyte and Acc|Tbyte respectively.
2017-12-18 09:35:01 +01:00
Jan Beulich dc821c5f9a x86: replace Reg8, Reg16, Reg32, and Reg64
Use a combination of a single new Reg bit and Byte, Word, Dword, or
Qword instead.

Besides shrinking the number of operand type bits this has the benefit
of making register handling more similar to accumulator handling (a
generic flag is being accompanied by a "size qualifier"). It requires,
however, to split a few insn templates, as it is no longer correct to
have combinations like Reg32|Reg64|Byte. This slight growth in size will
hopefully be outweighed by this change paving the road for folding a
presumably much larger number of templates later on.
2017-12-18 09:34:00 +01:00
Joel Brobecker eccab96d54 improved error message when getting an exception printing a variable
Consider the following Ada code defining a global variable whose
type is an array of static bounds (1 .. 2), but where its elements
are a variant record whose size is not statically known:

    type Ints is array (Natural range <>) of Integer;
    type Bounded_Ints (Max_Size : Natural) is record
       Length : Natural := 0;
       Objs   : Ints (1 .. Max_Size);
    end record;

    type Ints_Doubled is array (1 .. 2) of Bounded_Ints (Idem (0));

    Global : Ints_Doubled;

When compiling this program at -O2 using a GCC-6.4-based compiler
on x86_64-linux, trying to print the value of that global variable
yields:

    (gdb) p global
    $1 =

Let's look at the debugging info, which starts with the global
variable itself...

        .uleb128 0x19   # (DIE (0x25e) DW_TAG_variable)
        .long   .LASF32 # DW_AT_name: "fd__global"
        .long   0x273   # DW_AT_type

... its type is a reference to a typedef ...

        .uleb128 0x14   # (DIE (0x273) DW_TAG_reference_type)
        .byte   0x8     # DW_AT_byte_size
        .long   0x202   # DW_AT_type
        [...]
        .uleb128 0x15   # (DIE (0x202) DW_TAG_typedef)
        .long   .LASF19 # DW_AT_name: "fd__ints_doubled"
        .long   0x20d   # DW_AT_type

... of an array (1..2) ...

        .uleb128 0x2    # (DIE (0x20d) DW_TAG_array_type)
        .long   .LASF19 # DW_AT_name: "fd__ints_doubled"
        .long   0x15b   # DW_AT_type
        .long   0x221   # DW_AT_sibling
        .uleb128 0x16   # (DIE (0x21a) DW_TAG_subrange_type)
        .long   0x40    # DW_AT_type
        .sleb128 2      # DW_AT_upper_bound
        .byte   0       # end of children of DIE 0x20d

... of a struct whose name is fd__Tints_doubledC:

        .uleb128 0x10   # (DIE (0x15b) DW_TAG_structure_type)
        .long   .LASF11 # DW_AT_name: "fd__Tints_doubledC"
        .long   0x1e4   # DW_AT_GNAT_descriptive_type
                        # DW_AT_artificial
        .long   0x1e4   # DW_AT_sibling
        .uleb128 0x7    # (DIE (0x16a) DW_TAG_member)
        .long   .LASF4  # DW_AT_name: "max_size"
        [snip]

The error occurs while Ada evaluator is trying to "fix"
the element type inside the array, so as to determine its actual
size. For that, it searches for a parallel "XVZ" variable,
which, when found, contains the object's actual size.

Unfortunately in our case, the variable exists but has been
optimized out, as seen by the presence of a variable DIE in
the debugging info, but with no address attribute:

        .uleb128 0x18   # (DIE (0x24e) DW_TAG_variable)
        .long   .LASF31 # DW_AT_name: "fd__Tints_doubledC___XVZ"
        .long   0x257   # DW_AT_type
                        # DW_AT_artificial

Discussing this with some members of AdaCore's compiler team,
it is expected that the optimizer can get rid of this variable,
and we don't want to pessimize the code just to improve debuggability,
since -O2 is about performance. So, the idea of this patch is
not to make it work, but provide a bit more information to help
users understand what kind of error is preventing GDB from being
able to print the variable's value.

The first hurdle we had to clear was the fact that ada_val_print
traps all exceptions (including QUIT ones!), and does so completly
silently. So, the fix was to add a trace of the exception being
generated. While doing so, we fix an old XXX/FIXME by only catching
errors, letting QUIT exceptions go through.

Once this is done, we now get an error message, which gives a first
clue as to what was happening:

    (gdb) p fd.global
    $1 = <error reading variable: value has been optimized out>

However, it would be more useful to know which value it was
that was optimized out. For that purpose, we enhanced
ada-lang.c::ada_to_fixed_type_1 so as to re-throw the error
with a message which indicates which variable we failed to read.

With those changes, the new output is now:

    (gdb) p fd.global
    $1 = <error reading variable: unable to read value of fd__Tints_doubledC___XVZ (value has been optimized out)>

gdb/ChangeLog:

        * ada-lang.c (ada_to_fixed_type_1): Rethrow errors with
        a more detailed exception message when getting an exception
        while trying to read the value of an XVZ variable.
        * ada-valprint.c (ada_val_print): Only catch RETURN_MASK_ERROR
        exceptions.  Print an error message when an exception is caught.

gdb/testsuite/ChangeLog:

        * gdb.dwarf2/ada-valprint-error.c: New file.
        * gdb.dwarf2/ada-valprint-error.exp: New file.

Tested on x86_64-linux
2017-12-17 22:39:33 -05:00
Joel Brobecker 0e2da9f013 (Ada) crash assigning to record component which is an array
Consider the following code, which declares a variabled called "input"
of type "parameter", which is a record with one component called "u2",
where the type of that component is a simple 3-element array of
floating point values:

   type Float_Array_3 is array (1 .. 3) of Float;
   type parameters is record
      u2 : Float_Array_3;
   end record;
   input : parameters;

Trying to assign a value to input.u2 causes GDB to crash:

    (gdb) p input.u2 := (0.25,0.5,0.75)
    [1]    20228 segmentation fault (core dumped) [...]/gdb

The crash occurs because input.u2 is described in the debugging
info as a typedef of an array. Indeed, input's type is:

 <1><ae9>: Abbrev Number: 7 (DW_TAG_structure_type)
    <aea>   DW_AT_name        : (indirect string, offset: 0x1045): target_wrapper__parameters
    [...]
 <2><af5>: Abbrev Number: 8 (DW_TAG_member)
    <af6>   DW_AT_name        : u2
    [...]
    <afb>   DW_AT_type        : <0xaca>

and, looking at DIE 0xaca to get input.u2's type, we see:

 <1><aca>: Abbrev Number: 4 (DW_TAG_typedef)
    <acb>   DW_AT_name        : (indirect string, offset: 0x1060): target_wrapper__float_array_3
    [...]
    <ad1>   DW_AT_type        : <0xad5>

We can also confirm, following the DW_AT_type attribute (0xad5), that
it's a typedef of our array:

 <1><ad5>: Abbrev Number: 5 (DW_TAG_array_type)
    <ad6>   DW_AT_name        : (indirect string, offset: 0x1060): target_wrapper__float_array_3
    [...]

In fact, this scenario uncovered 2 areas where typedef handling
is missing, thus causing a crash. The first happens inside
assign_aggregate:

   if (ada_is_direct_array_type (lhs_type))
     {
       lhs = ada_coerce_to_simple_array (lhs);
       lhs_type = value_type (lhs);
       low_index = TYPE_ARRAY_LOWER_BOUND_VALUE (lhs_type);
       high_index = TYPE_ARRAY_UPPER_BOUND_VALUE (lhs_type);
     }

Here, lhs_type is a TYPE_CODE_TYPEDEF. ada_is_direct_array_type
knows how to handle it, but TYPE_ARRAY_LOWER_BOUND_VALUE assumes
that the given type is a TYPE_CODE_ARRAY. As such, it ends up
accessing some fields in lhs_type which it shouldn't, and kaboom.

We fixed this issue by making sure that the TYPE_CODE_TYPEDEF
layer gets stripped.

Once this is done, we hit a different kind of error, also leading to
a SEGV, this time in assign_component. The code looks like this:

  if (TYPE_CODE (value_type (lhs)) == TYPE_CODE_ARRAY)
    [...]
  else
    [...]

Because once again lhs is a TYPE_CODE_TYPEDEF, the check fail,
and we end up assuming that lhs is a struct, executing the "else"
block, which is:

  else
    {
      elt = ada_index_struct_field (index, lhs, 0, value_type (lhs));
      elt = ada_to_fixed_value (elt);
    }

Since lhs is not a struct, ada_index_struct_field returns NULL,
which ada_to_fixed_value does not handle well, hence another crash.

This patch fixes this other issue the same way, by stripping
TYPE_CODE_TYPEDEF layers.

gdb/ChangeLog:

        * ada-lang.c (assign_component): Strip any TYPE_CODE_TYPEDEF
        layer from lhs' type.
        (assign_aggregate): Likewise.

gdb/testsuite:

        * gdb.ada/assign_arr: New testcase.

Tested on x86_64-linux.
2017-12-17 22:11:40 -05:00
Xavier Roirand cb923fcc23 Ada: fix bad handling in ada_convert_actual
Using this small example:

procedure Foo is

   type Integer_Access is access all Integer;

   procedure P (A : Integer_Access) is
   begin
      null;
   end P;

begin
   P (null);
end Foo;

and doing this debug session:

(gdb) b p
Breakpoint 1 at 0x402d67: file foo.adb, line 7.
(gdb) print p(null)

Breakpoint 1, foo.p (a=0x641010) at foo.adb:10
...                  ^^^^^^^^^^

shows that something goes wrong between the initial null value and the
received parameter value in the 'f' function.
The value for the parameter 'a' we get is the address of the value we
would expect instead of the value itself. This can be checked by doing:

(gdb) p *a
$1 = 0

Before this fix, in ada_convert_value, this function was looking to the
actual value (the null value here) to determine if the formal (parameter
'a' in the procedure 'P' in this exemple) requires a pointer or not which
is a wrong assumption and leads to push the address of the value to the
inferior instead of the value itself.

This is fixed by this patch.

gdb/ChangeLog:

        * ada-lang.c (ada_convert_actual): Change the way actual value
        are passed to the inferior when the inferior expects a pointer type.

gdb/testsuite/ChangeLog:

        * gdb.ada/funcall_ptr: New testcase.

Tested on x86_64-linux.
2017-12-17 22:01:32 -05:00
GDB Administrator 7d47b066d0 Automatic date update in version.in 2017-12-18 00:00:20 +00:00
H.J. Lu 390c91cfcf x86: Check pseudo prefix without instruction
Pseudo prefixes must be used on an instruction.  Issue an error when
pseudo prefix is used without instruction.

	PR gas/22623
	* gas/config/tc-i386.c (output_insn): Check pseudo prefix
	without instruction.
	* testsuite/gas/i386/i386.exp: Run inval-pseudo.
	* testsuite/gas/i386/inval-pseudo.l: New file.
	* testsuite/gas/i386/inval-pseudo.s: Likewise.
2017-12-17 09:49:11 -08:00
GDB Administrator fd7055f4a7 Automatic date update in version.in 2017-12-17 00:00:31 +00:00