Commit Graph

87435 Commits

Author SHA1 Message Date
Maciej W. Rozycki ceab86af75 MIPS/BFD: Fix section symbol name fetching in relocation
Symbol table entries for section symbols are different between IRIX and
traditional MIPS ELF targets in that IRIX entries have their `st_name'
member pointing at the section's name in the string table section, while
traditional entries have 0 there and the section header string table has
to be referred via the relevant section header's `shn_name' member
instead.

This is chosen with the `elf_backend_name_local_section_symbols' backend
and can be observed with `readelf -s' output for an IRIX object:

Symbol table '.symtab' contains 12 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 SECTION LOCAL  DEFAULT    1 .text
     2: 00000000     0 SECTION LOCAL  DEFAULT    3 .data
     3: 00000000     0 SECTION LOCAL  DEFAULT    4 .bss
     4: 00000000     0 SECTION LOCAL  DEFAULT    5 .reginfo
     5: 00000000     0 SECTION LOCAL  DEFAULT    6 .MIPS.abiflags
     6: 00000000     0 SECTION LOCAL  DEFAULT    7 .pdr
     7: 00000000     0 SECTION LOCAL  DEFAULT    9 .gnu.attributes
     8: 00002000    16 FUNC    GLOBAL DEFAULT    1 foo
     9: 00004008     0 FUNC    LOCAL  DEFAULT    1 abar
    10: 00002008     0 FUNC    LOCAL  DEFAULT    1 afoo
    11: 00004000    16 FUNC    GLOBAL DEFAULT    1 bar

and a corresponding traditional object:

Symbol table '.symtab' contains 12 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000000     0 SECTION LOCAL  DEFAULT    1
     2: 00000000     0 SECTION LOCAL  DEFAULT    3
     3: 00000000     0 SECTION LOCAL  DEFAULT    4
     4: 00004008     0 FUNC    LOCAL  DEFAULT    1 abar
     5: 00002008     0 FUNC    LOCAL  DEFAULT    1 afoo
     6: 00000000     0 SECTION LOCAL  DEFAULT    5
     7: 00000000     0 SECTION LOCAL  DEFAULT    6
     8: 00000000     0 SECTION LOCAL  DEFAULT    7
     9: 00000000     0 SECTION LOCAL  DEFAULT    9
    10: 00002000    16 FUNC    GLOBAL DEFAULT    1 foo
    11: 00004000    16 FUNC    GLOBAL DEFAULT    1 bar

respectively.  Consequently the right way to retrieve a section symbol's
name has to be chosen in `mips_elf_calculate_relocation' for the purpose
of error reporting.

Originally we produced symbol tables in the traditional object format
only and we handled it correctly until it was lost in a rewrite with:

commit 7403cb6305
Author: Mark Mitchell <mark@codesourcery.com>
Date:   Wed Jun 30 20:13:43 1999 +0000

probably because of the extra pointer indirection added which made the
same expression have a different meaning.

With the addition of IRIX symbol table format with:

commit 174fd7f955
Author: Richard Sandiford <rdsandiford@googlemail.com>
Date:   Mon Feb 9 08:04:00 2004 +0000

the bug has been partially covered and now when a relocation error is
triggered with an IRIX object the offending section symbol is correctly
reported:

tmpdir/dump0.o: In function `foo':
(.text+0x2000): relocation truncated to fit: R_MIPS_26 against `.text'
tmpdir/dump0.o: In function `bar':
(.text+0x4000): relocation truncated to fit: R_MIPS_26 against `.text'

because `bfd_elf_string_from_elf_section' retrieves the name from the
string table section.  With a traditional object however the function
returns an empty string and consequently `no symbol' is printed instead:

tmpdir/dump0.o: In function `foo':
(.text+0x2000): relocation truncated to fit: R_MIPS_26 against `no symbol'
tmpdir/dump0.o: In function `bar':
(.text+0x4000): relocation truncated to fit: R_MIPS_26 against `no symbol'

Restore the original semantics so that the section name is always
correctly retrieved.

	bfd/
	* elfxx-mips.c (mips_elf_calculate_relocation): Also use the
	section name if `bfd_elf_string_from_elf_section' returns an
	empty string.

	ld/
	* testsuite/ld-mips-elf/reloc-local-overflow.d: New test.
	* testsuite/ld-mips-elf/reloc-local-overflow.s: Source for the
	new test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
2016-05-27 22:25:42 +01:00
H.J. Lu 1848e56734 Update x86 CPU_XXX_FLAGS handling
Support defining CPU_XXX_FLAGS with other CPU_XXX_FLAGS.  Update
CPU_XXX_FLAGS to enable more bits like x87 and SYSCALL.  Don't enable
MMX when enabling SSE, AVX or AVX512.  Don't disable AVX nor AVX512 when
disabling SSE.  Don't disable AVX512 when disabling AVX.  Disable F16C,
FMA, FMA4 and XOP when disabling AVX.  Add 87, no287, no387, no687,
nosse2, nosse3, nossse3, nosse4.1, nosse4.2, nosse4 and noavx2 directives
to x86 assembler.

TODO: Add more .noXXX, like .noavx512f, directives to x86 assembler.

gas/

	PR gas/20145
	* config/tc-i386.c (cpu_arch): Add 687.
	(cpu_noarch): Add no287, no387, no687, nosse2, nosse3, nossse3,
	nosse4.1, nosse4.2, nosse4 and noavx2.
	(parse_real_register): Check cpuregmmx instead of cpummx for MMX
	register.  Check cpuregxmm instead of cpusse for XMM register.
	Check cpuregymm instead of cpuavx for YMM register.  Check
	cpuregzmm/cpuregmask instead of cpuavx512f for ZMMM/mask register.
	* doc/c-i386.texi: Mention 687, no287, no387, no687, nosse2,
	nosse3, nossse3, nosse4.1, nosse4.2, nosse4 and noavx2.
	* testsuite/gas/i386/arch-10-prefetchw.d (as): Add mmx.
	* testsuite/gas/i386/arch-10.d (as): Likewise.
	* testsuite/gas/i386/arch-11.s: Add ".arch .mmx".
	* testsuite/gas/i386/i386.exp: Pass mmx to assembler for
	arch-10-3 and arch-10-4.  Run no87-3, nosse-4, nosse-5, noavx-3
	and noavx-4.
	* testsuite/gas/i386/no87-3.l: New file.
	* testsuite/gas/i386/no87-3.s: Likewise.
	* testsuite/gas/i386/noavx-3.l: Likewise.
	* testsuite/gas/i386/noavx-3.s: Likewise.
	* testsuite/gas/i386/noavx-4.d: Likewise.
	* testsuite/gas/i386/noavx-4.s: Likewise.
	* testsuite/gas/i386/nosse-4.l: Likewise.
	* testsuite/gas/i386/nosse-4.s: Likewise.
	* testsuite/gas/i386/nosse-5.d: Likewise.
	* testsuite/gas/i386/nosse-5.s: Likewise.

opcodes/

	PR gas/20145
	* i386-gen.c (cpu_flag_init): Update CPU_XXX_FLAGS.  Remove
	CpuMMX from CPU_SSE_FLAGS.  Remove AVX and AVX512 bits from
	CPU_ANY_SSE_FLAGS.  Remove AVX512 bits from CPU_ANY_AVX_FLAGS.
	Add CPU_XSAVE_FLAGS to CPU_XSAVEOPT_FLAGS, CPU_XSAVE_FLAGS and
	CpuXSAVEC.  Add CPU_AVX_FLAGS to CpuF16C.  Remove CpuMMX from
	CPU_AVX512F_FLAGS, CPU_AVX512CD_FLAGS, CPU_AVX512ER_FLAGS,
	CPU_AVX512PF_FLAGS, CPU_AVX512DQ_FLAGS and CPU_AVX512BW_FLAGS.
	Add CPU_SSE2_FLAGS to CPU_SHA_FLAGS.   Add CPU_ANY_287_FLAGS,
	CPU_ANY_387_FLAGS, CPU_ANY_687_FLAGS, CPU_ANY_SSE2_FLAGS,
	CPU_ANY_SSE3_FLAGS, CPU_ANY_SSSE3_FLAGS, CPU_ANY_SSE4_1_FLAGS,
	CPU_ANY_SSE4_2_FLAGS and CPU_ANY_AVX2_FLAGS.  Enable CpuRegMMX
	for MMX.  Enable CpuRegXMM for SSE, AVX and AVX512.  Enable
	CpuRegYMM for AVX and AVX512VL,  Enable CpuRegZMM and
	CpuRegMask for AVX512.
	(cpu_flags): Add CpuRegMMX, CpuRegXMM, CpuRegYMM, CpuRegZMM
	and CpuRegMask.
	(set_bitfield_from_cpu_flag_init): New function.
	(set_bitfield): Remove const on f.  Call
	set_bitfield_from_cpu_flag_init to handle CPU_XXX_FLAGS.
	* i386-opc.h (CpuRegMMX): New.
	(CpuRegXMM): Likewise.
	(CpuRegYMM): Likewise.
	(CpuRegZMM): Likewise.
	(CpuRegMask): Likewise.
	(i386_cpu_flags): Add cpuregmmx, cpuregxmm, cpuregymm, cpuregzmm
	and cpuregmask.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
2016-05-27 10:05:57 -07:00
Pedro Alves 744608cc85 Skip attach-many-short-lived-threads.exp on known-broken DejaGnu versions
If the testsuite is run with a DejaGnu version that predates the fix
from last year:

  [PATCH] DejaGnu kills the wrong process due to PID-reuse races
  http://lists.gnu.org/archive/html/dejagnu/2015-07/msg00005.html

... gdb.threads/attach-many-short-lived-threads.exp fails randomly,
often.  Other tests randomly fail due to that issue too, but this one
is _much_ more exposed.

DejaGnu 1.6 was released meanwhile, which includes that DejaGnu fix,
and also some distros backported the fix too.

So skip the test when run with older/broken DejaGnus.

gdb/testsuite/ChangeLog:
2016-05-27  Pedro Alves  <palves@redhat.com>

	* gdb.threads/attach-many-short-lived-threads.exp (bad_dejagnu):
	New procedure.
	(top level): Call it, and bail out of DejaGnu is known to be bad.
2016-05-27 16:18:28 +01:00
H.J. Lu e92bae6260 Replace CpuAMD64/CpuIntel64 with AMD64/Intel64
AMD64 vs CpuIntel64 ISA should be handled similar as AT&T vs Intel
syntax.  Since cpu_flags isn't sorted by position, we need to check
the whole cpu_flags array for the maximum position when verifying
CpuMax.

gas/

	PR gas/20154
	* config/tc-i386.c (cpu_flags_match): Don't set cpuamd64 nor
	cpuintel64.
	(match_template): Check Intel64/AMD64 ISA.

opcodes/

	PR gas/20154
	* i386-gen.c (cpu_flags): Remove CpuAMD64 and CpuIntel64.
	(opcode_modifiers): Add AMD64 and Intel64.
	(main): Properly verify CpuMax.
	* i386-opc.h (CpuAMD64): Removed.
	(CpuIntel64): Likewise.
	(CpuMax): Set to CpuNo64.
	(i386_cpu_flags): Remove cpuamd64 and cpuintel64.
	(AMD64): New.
	(Intel64): Likewise.
	(i386_opcode_modifier): Add amd64 and intel64.
	(i386-opc.tbl): Replace CpuAMD64/CpuIntel64 with AMD64/Intel64
	on call and jmp.
	* i386-init.h: Regenerated.
	* i386-tbl.h: Likewise.
2016-05-27 08:03:17 -07:00
Eli Zaretskii c185ba27ca Improve documentation of general query packets
gdb/doc/ChangeLog:

	* gdb.texinfo (General Query Packets): Move the description of the
	response before the long list of the specific 'read' and 'write'
	requests.
2016-05-27 16:59:22 +03:00
H.J. Lu e89c5eaa72 Correct CpuMax in i386-opc.h
CpuMax should be CpuIntel64, not CpuNo64.  i386-gen.c is updated to
verify that CpuMax is correct.  X86 assembler is updated to properly
set cpuamd64 and cpuintel64.

gas/

	PR gas/20154
	* config/tc-i386.c (intel64): New.
	(cpu_flags_match): Set cpuamd64 and cpuintel64.
	(md_parse_option): Set intel64 instead of cpuamd64 and
	cpuintel64.

opcodes/

	PR gas/20154
	* i386-gen.c (main): Fail if CpuMax is incorrect.
	* i386-opc.h (CpuMax): Set to CpuIntel64.
	* i386-tbl.h: Regenerated.
2016-05-27 06:55:53 -07:00
Nick Clifton 1690f1db1a Fix typo introduced during the most recent synchronization update. 2016-05-27 14:34:06 +01:00
Nick Clifton 77d66e7b30 Improve the MSP430 disassembler's handling of memory read errors.
PR target/20150
	* msp430-dis.c (msp430dis_read_two_bytes): New function.
	(msp430dis_opcode_unsigned): New function.
	(msp430dis_opcode_signed): New function.
	(msp430_singleoperand): Use the new opcode reading functions.
	Only disassenmble bytes if they were successfully read.
	(msp430_doubleoperand): Likewise.
	(msp430_branchinstr): Likewise.
	(msp430x_callx_instr): Likewise.
	(print_insn_msp430): Check that it is safe to read bytes before
	attempting disassembly.  Use the new opcode reading functions.
2016-05-27 13:49:58 +01:00
Andrew Burgess 51415b9f30 gdb: Forward VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT
When evaluating an expression with EVAL_AVOID_SIDE_EFFECTS if the value
we return is forced to be of type not_lval then GDB will be unable to
take the address of the returned value.

Instead, we should properly initialise the LVAL of the returned value.

This commit builds on two previous commits 2520f728b7 (Forward
VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT) and
ac775bf4d3 (gdb: Forward VALUE_LVAL when avoiding side effects for
STRUCTOP_PTR), which in turn build on ac1ca910d7 (Fixes for PR
exp/15364).

This commit is currently untested due to my lack of access to an OpenCL
compiler, however, if follows the same pattern as the first two commits
mentioned above and so I believe that it is correct.

gdb/ChangeLog:

	* opencl-lang.c (evaluate_subexp_opencl): If
	EVAL_AVOID_SIDE_EFFECTS mode, forward the VALUE_LVAL attribute to
	the returned value in the STRUCTOP_STRUCT case.
2016-05-27 13:07:15 +01:00
Andrew Burgess ac775bf4d3 gdb: Forward VALUE_LVAL when avoiding side effects for STRUCTOP_PTR
Assume that we have a C program like this:

  struct foo_type
  {
    int var;
  } foo;

  struct foo_type *foo_ptr = &foo;

  int
  main ()
  {
    return foo_ptr->var;
  }

Then GDB should be able to evaluate the following, however, it currently
does not:

  (gdb) start
  ...
  (gdb) whatis &(foo_ptr->var)
  Attempt to take address of value not located in memory.

The problem is that in EVAL_AVOID_SIDE_EFFECTS mode,
eval.c:evaluate_subexp_standard always returns a not_lval value as the
result for a STRUCTOP_PTR operation. As a consequence, the rest of
the code believes that one cannot take the address of the returned
value.

This patch fixes STRUCTOP_PTR handling so that the VALUE_LVAL
attribute for the returned value is properly initialized.  After this
change, the above session becomes:

  (gdb) start
  ...
  (gdb) whatis &(foo_ptr->var)
  type = int *

This commit is largely the same as commit 2520f728b7 (Forward
VALUE_LVAL when avoiding side effects for STRUCTOP_STRUCT) but applied
to STRUCTOP_PTR rather than STRUCTOP_STRUCT.  Both of these commits are
building on top of commit ac1ca910d7 (Fixes for PR exp/15364).

gdb/ChangeLog:

	* eval.c (evaluate_subexp_standard): If EVAL_AVOID_SIDE_EFFECTS
	mode, forward the VALUE_LVAL attribute to the returned value in
	the STRUCTOP_PTR case.

gdb/testsuite/ChangeLog:

	* gdb.base/whatis.c: Extend the test case.
	* gdb.base/whatis.exp: Add additional tests.
2016-05-27 13:06:25 +01:00
H.J. Lu 9d07ebe108 Don't clear cpu64 nor cpuno64
No need to clear cpu64 nor cpuno64 since they will be cleared by
cpu_flags_and.

	* config/tc-i386.c (cpu_flags_match): Don't clear cpu64 nor
	cpuno64.
2016-05-27 04:56:05 -07:00
Peter Bergner 19dfcc89e8 Add support for new POWER ISA 3.0 instructions.
opcodes/

	* ppc-opc.c (CY): New define.  Document it.
	(powerpc_opcodes) <addex[.], lwzmx, vmsumudm>: New mnemonics.

gas/
	* testsuite/gas/ppc/altivec3.d <vmsumudm>: Add test.
	* testsuite/gas/ppc/altivec3.s: Likewise.
	* testsuite/gas/ppc/power9.d <addex[.], lwzmx, vmsumudm>: Add tests.
	* testsuite/gas/ppc/power9.s: Likewise.
2016-05-26 19:06:51 -05:00
GDB Administrator 5e0bc41893 Automatic date update in version.in 2016-05-27 00:00:20 +00:00
H.J. Lu 8d5b9a5a30 Append ".p2align 4" to some x86 directive tests
Append ".p2align 4" to some x86 directive tests for explicit paddings
for section alignment to avoid implicit section alignment in assembler
listings.

	* testsuite/gas/i386/avx512vl-2.l: Append "#pass".
	* testsuite/gas/i386/noavx-1.l: Likewise.
	* testsuite/gas/i386/nommx-1.l: Likewise.
	* testsuite/gas/i386/nosse-1.l: Likewise.
	* testsuite/gas/i386/x86-64-avx512vl-2.l: Likewise.
	* testsuite/gas/i386/avx512vl-2.s: Append ".p2align 4".
	* testsuite/gas/i386/noavx-1.s: Likewise.
	* testsuite/gas/i386/nommx-1.s: Likewise.
	* testsuite/gas/i386/nosse-1.s: Likewise.
	* testsuite/gas/i386/x86-64-avx512vl-2.s: Likewise.
2016-05-26 07:55:38 -07:00
Trevor Saunders 81cead6f5e metag: make an array's type unsigned char[]
It contains values between 128 and 256 which fit in an unsigned char, but not a
signed char, so we should explicitly use unsigned char to not rely on how these
values are converted to signed char.

gas/ChangeLog:

2016-05-26  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* config/tc-metag.c (metag_handle_align): Make the type of noop
	unsigned char.
2016-05-26 08:46:01 -04:00
Trevor Saunders 79052aaec9 rx: make the type of a variable bfd_reloc_code_real_type
gas/ChangeLog:

2016-05-26  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* config/tc-rx.c (md_convert_frag): Make the type of reloc_type
	bfd_reloc_code_real_type.
2016-05-26 08:45:03 -04:00
Maciej W. Rozycki ed53407eec MIPS/BFD: Don't stop processing on `bfd_reloc_outofrange'
Upon a `bfd_reloc_outofrange' error continue processing so that any
further issues are also reported, similarly to how `bfd_reloc_overflow'
is handled.  Adjust message formatting accordingly, using `%X' to abort
processing at conclusion.

Reduce the number of test cases by grouping relocations the handling of
which can now be verified together with a single source and dump.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_relocate_section)
	<bfd_reloc_outofrange>: Use the `%X%H' rather than `%C' format
	for message.  Continue processing rather than returning failure.

	ld/
	* testsuite/ld-mips-elf/unaligned-jalx-0.d: Fold
	`unaligned-jalx-2' here.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: Fold
	`unaligned-jalx-mips16-2' here.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: Fold
	`unaligned-jalx-micromips-2' here.
	* testsuite/ld-mips-elf/unaligned-jalx-0.s: Update accordingly.
	* testsuite/ld-mips-elf/unaligned-jalx-1.d: Update error
	message.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: Likewise.
	* testsuite/ld-mips-elf/unaligned-jalx-2.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d: Remove
	test.
	* testsuite/ld-mips-elf/unaligned-jalx-2.s: Remove test source.
	* testsuite/ld-mips-elf/unaligned-lwpc-0.d: Fold
	`unaligned-lwpc-3' here.
	* testsuite/ld-mips-elf/unaligned-lwpc-0.s: Update accordingly.
	* testsuite/ld-mips-elf/unaligned-lwpc-1.d: Fold
	`unaligned-lwpc-2' here.
	* testsuite/ld-mips-elf/unaligned-lwpc-1.s: Update accordingly.
	* testsuite/ld-mips-elf/unaligned-lwpc-2.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-lwpc-2.s: Remove test source.
	* testsuite/ld-mips-elf/unaligned-lwpc-3.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-lwpc-3.s: Remove test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-0.d: Fold
	`unaligned-ldpc-4' here.
	* testsuite/ld-mips-elf/unaligned-ldpc-0.s: Update accordingly.
	* testsuite/ld-mips-elf/unaligned-ldpc-1.d: Update error
	message.  Fold `unaligned-ldpc-2' and `unaligned-ldpc-3' here.
	* testsuite/ld-mips-elf/unaligned-ldpc-1.s: Update accordingly.
	* testsuite/ld-mips-elf/unaligned-ldpc-2.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-ldpc-2.s: Remove test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-3.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-ldpc-3.s: Remove test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-4.d: Remove test.
	* testsuite/ld-mips-elf/unaligned-ldpc-4.s: Remove test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Delete removed tests.
2016-05-26 12:28:59 +01:00
Nick Clifton 0d832c8ea7 Provide the __bssstart and __bsssize symbols needed by the MSP430's crt0.o code.
PR target/20134
	* scripttempl/elf32msp430.sc (.bss): Provide __bssstart and
	__bsssize.
	* scripttempl/elf32msp430_3.sc (.bss): Likewise.
2016-05-26 11:43:38 +01:00
Trevor Saunders 94740f9c4b metag: add extern C to header
include/ChangeLog:

2016-05-26  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* opcode/metag.h: wrap declarations in extern "C".
2016-05-26 06:12:15 -04:00
GDB Administrator d7b61136f9 Automatic date update in version.in 2016-05-26 00:00:20 +00:00
H.J. Lu 73b090a922 Require another match for AVX512VL
The AVX512VL bit alone isn't sufficient to select a 128-bit or 256-bit
AVX512 instruction.  We must match another AVX512 bit.

	PR gas/20140
	* config/tc-i386.c (cpu_flags_match): Require another match
	for AVX512VL.
	* testsuite/gas/i386/i386.exp: Run avx512vl-1, avx512vl-2,
	x86-64-avx512vl-1 and x86-64-avx512vl-2.
	* testsuite/gas/i386/avx512vl-1.l: New file.
	* testsuite/gas/i386/avx512vl-1.s: Likewise.
	* testsuite/gas/i386/avx512vl-2.l: Likewise.
	* testsuite/gas/i386/avx512vl-2.s: Likewise.
	* testsuite/gas/i386/x86-64-avx512vl-1.l: Likewise.
	* testsuite/gas/i386/x86-64-avx512vl-1.s: Likewise.
	* testsuite/gas/i386/x86-64-avx512vl-2.l: Likewise.
	* testsuite/gas/i386/x86-64-avx512vl-2.s: Likewise.
2016-05-25 15:04:47 -07:00
Maciej W. Rozycki de341542a6 MIPS/BFD: Report `bfd_reloc_outofrange' errors as such
A `bfd_reloc_outofrange' condition from `mips_elf_calculate_relocation'
currently triggers the warning callback, which in the case of LD prints
messages like:

foo.o: In function `foo':
(.text+0x0): warning: JALX to a non-word-aligned address

or:

foo.o: In function `foo':
(.text+0x0): warning: PC-relative load from unaligned address

and nothing else, which suggests this is a benign condition and link has
otherwise successfully run to completion.  This is however not the case,
the link terminates right away with no further messages and no output
produced.

Use the general error or warning info callback then, preserving the
message format.  Also set a BFD error condition so that a failure is
unambiguously reported.  Complement the change with a set of suitable
test suite additions.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_relocate_section)
	<bfd_reloc_outofrange>: Call `->einfo' rather than `->warning'.
	Call `bfd_set_error'.

	ld/
	* testsuite/ld-mips-elf/unaligned-jalx-0.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-1.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-0.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-1.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-mips16-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-0.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-1.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-micromips-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-lwpc-0.d: New test.
	* testsuite/ld-mips-elf/unaligned-lwpc-1.d: New test.
	* testsuite/ld-mips-elf/unaligned-lwpc-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-lwpc-3.d: New test.
	* testsuite/ld-mips-elf/unaligned-ldpc-0.d: New test.
	* testsuite/ld-mips-elf/unaligned-ldpc-1.d: New test.
	* testsuite/ld-mips-elf/unaligned-ldpc-2.d: New test.
	* testsuite/ld-mips-elf/unaligned-ldpc-3.d: New test.
	* testsuite/ld-mips-elf/unaligned-ldpc-4.d: New test.
	* testsuite/ld-mips-elf/unaligned-jalx-0.s: New test source.
	* testsuite/ld-mips-elf/unaligned-jalx-1.s: New test source.
	* testsuite/ld-mips-elf/unaligned-jalx-2.s: New test source.
	* testsuite/ld-mips-elf/unaligned-insn.s: New test source.
	* testsuite/ld-mips-elf/unaligned-lwpc-0.s: New test source.
	* testsuite/ld-mips-elf/unaligned-lwpc-1.s: New test source.
	* testsuite/ld-mips-elf/unaligned-lwpc-2.s: New test source.
	* testsuite/ld-mips-elf/unaligned-lwpc-3.s: New test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-0.s: New test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-1.s: New test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-2.s: New test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-3.s: New test source.
	* testsuite/ld-mips-elf/unaligned-ldpc-4.s: New test source.
	* testsuite/ld-mips-elf/unaligned-syms.s: New test source.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-05-25 21:03:22 +01:00
H.J. Lu f3ad76370f Enable VREX for all AVX512 directives
Add all AVX512 bits to CPU_ANY_AVX_FLAGS.

	* i386-gen.c (cpu_flag_init): Add CpuVREX to CPU_AVX512DQ_FLAGS,
	CPU_AVX512BW_FLAGS, CPU_AVX512VL_FLAGS, CPU_AVX512IFMA_FLAGS
	and CPU_AVX512VBMI_FLAGS.  Add CpuAVX512DQ, CpuAVX512BW,
	CpuAVX512VL, CpuAVX512IFMA and CpuAVX512VBMI to
	CPU_ANY_AVX_FLAGS.
	* i386-init.h: Regenerated.
2016-05-25 11:23:40 -07:00
H.J. Lu f1360d5830 Enable VREX for AVX512 directives
Enable VREX for AVX512 instructions with upper 16 vector registers.

gas/

	PR gas/20141
	* testsuite/gas/i386/i386.exp: Run x86-64-pr20141.
	* testsuite/gas/i386/x86-64-pr20141.d: New file.
	* testsuite/gas/i386/x86-64-pr20141.s: Likewise.

opcodes/

	PR gas/20141
	* i386-gen.c (cpu_flag_init): Add CpuVREX to CPU_AVX512F_FLAGS,
	CPU_AVX512CD_FLAGS, CPU_AVX512ER_FLAGS and CPU_AVX512PF_FLAGS.
	* i386-init.h: Regenerated.
2016-05-25 10:49:25 -07:00
H.J. Lu 293f5f6543 Reimplement .no87/.nommx/.nosse/.noavx directives
Move all .noXXX directives to cpu_noarch.

gas/

	* config/tc-i386.c (arch_entry): Remove negated.
	(noarch_entry): New struct.
	(cpu_arch): Updated.  Remove .no87, .nommx, .nosse and .noavx.
	(cpu_noarch): New.
	(set_cpu_arch): Check cpu_noarch after cpu_arch.
	(md_parse_option): Allow -march=+nosse.  Check cpu_noarch after
	cpu_arch.
	(output_message): New function.
	(show_arch): Use it.  Handle cpu_noarch.
	* testsuite/gas/i386/i386.exp: Run nommx-1, nommx-2, nommx-3,
	nosse-1, nosse-2, nosse-3, noavx-1 and noavx-2.
	* testsuite/gas/i386/noavx-1.l: New file.
	* testsuite/gas/i386/noavx-1.s: Likewise.
	* testsuite/gas/i386/noavx-2.s: Likewise.
	* testsuite/gas/i386/noavx-2.l: Likewise.
	* testsuite/gas/i386/nommx-1.s: Likewise.
	* testsuite/gas/i386/nommx-1.l: Likewise.
	* testsuite/gas/i386/nommx-2.s: Likewise.
	* testsuite/gas/i386/nommx-2.l: Likewise.
	* testsuite/gas/i386/nommx-3.s: Likewise.
	* testsuite/gas/i386/nommx-3.l: Likewise.
	* testsuite/gas/i386/nosse-1.s: Likewise.
	* testsuite/gas/i386/nosse-1.l: Likewise.
	* testsuite/gas/i386/nosse-2.s: Likewise.
	* testsuite/gas/i386/nosse-2.l: Likewise.
	* testsuite/gas/i386/nosse-3.s: Likewise.
	* testsuite/gas/i386/nosse-3.l: Likewise.

opcodes/

	* i386-gen.c (cpu_flag_init): Rename CPU_ANY87_FLAGS to
	CPU_ANY_X87_FLAGS.  Add CPU_ANY_MMX_FLAGS.
	* i386-init.h: Regenerated.
2016-05-25 10:26:13 -07:00
H.J. Lu e6cc316af9 Enable 64-bit archives in ar and ranlib
Since existing ld and gold support the 64-bit (MIPS) ELF archives, we
can use the 64-bit (MIPS) ELF archives as 64-bit archives.  Since the
plugin target is used to create archive in plugin-enabled ar, we need
a way to enable 64-bit archives in the plugin target.  This patch adds
--enable-64-bit-archive to bfd to force 64-bit archives in ar and
ranlib.  Since both 64-bit MIPS and s390 ELF targets currently use
64-bit archives, 64-bit archives are enabled by default for them.
64-bit archive is generated automatically if the archive is too big.

Tested on Linux/x86 and Linux/x86-64 with existing ld and gold.

bfd/

	PR binutils/14625
	* archive.c (bfd_slurp_armap): Replace
	bfd_elf64_archive_slurp_armap with
	_bfd_archive_64_bit_slurp_armap.
	(bsd_write_armap): Call _bfd_archive_64_bit_write_armap if
	BFD64 is defined and the archive is too big.
	(coff_write_armap): Likewise.
	* archive64.c (bfd_elf64_archive_slurp_armap): Renamed to ...
	(_bfd_archive_64_bit_slurp_armap): This.
	(bfd_elf64_archive_write_armap): Renamed to ...
	(_bfd_archive_64_bit_write_armap): This.
	* configure.ac: Add --enable-64-bit-archive.
	(want_64_bit_archive): New.  Set to true by default for 64-bit
	MIPS and s390 ELF targets.
	(USE_64_BIT_ARCHIVE): New AC_DEFINE.
	* config.in: Regenerated.
	* configure: Likewise.
	* elf64-mips.c (bfd_elf64_archive_functions): Removed.
	(bfd_elf64_archive_slurp_armap): Likewise.
	(bfd_elf64_archive_write_armap): Likewise.
	(bfd_elf64_archive_slurp_extended_name_table): Likewise.
	(bfd_elf64_archive_construct_extended_name_table): Likewise.
	(bfd_elf64_archive_truncate_arname): Likewise.
	(bfd_elf64_archive_read_ar_hdr): Likewise.
	(bfd_elf64_archive_write_ar_hdr): Likewise.
	(bfd_elf64_archive_openr_next_archived_file): Likewise.
	(bfd_elf64_archive_get_elt_at_index): Likewise.
	(bfd_elf64_archive_generic_stat_arch_elt): Likewise.
	(bfd_elf64_archive_update_armap_timestamp): Likewise.
	* elf64-s390.c (bfd_elf64_archive_functions): Removed.
	(bfd_elf64_archive_slurp_armap): Likewise.
	(bfd_elf64_archive_write_armap): Likewise.
	(bfd_elf64_archive_slurp_extended_name_table): Likewise.
	(bfd_elf64_archive_construct_extended_name_table): Likewise.
	(bfd_elf64_archive_truncate_arname): Likewise.
	(bfd_elf64_archive_read_ar_hdr): Likewise.
	(bfd_elf64_archive_write_ar_hdr): Likewise.
	(bfd_elf64_archive_openr_next_archived_file): Likewise.
	(bfd_elf64_archive_get_elt_at_index): Likewise.
	(bfd_elf64_archive_generic_stat_arch_elt): Likewise.
	(bfd_elf64_archive_update_armap_timestamp): Likewise.
	* elfxx-target.h (TARGET_BIG_SYM): Use _bfd_archive_64_bit on
	BFD_JUMP_TABLE_ARCHIVE if USE_64_BIT_ARCHIVE is defined and
	bfd_elfNN_archive_functions isn't defined.
	(TARGET_LITTLE_SYM): Likewise.
	* libbfd-in.h (_bfd_archive_64_bit_slurp_armap): New prototype.
	(_bfd_archive_64_bit_write_armap): Likewise.
	(_bfd_archive_64_bit_slurp_extended_name_table): New macro.
	(_bfd_archive_64_bit_construct_extended_name_table): Likewise.
	(_bfd_archive_64_bit_truncate_arname): Likewise.
	(_bfd_archive_64_bit_read_ar_hdr): Likewise.
	(_bfd_archive_64_bit_write_ar_hdr): Likewise.
	(_bfd_archive_64_bit_openr_next_archived_file): Likewise.
	(_bfd_archive_64_bit_get_elt_at_index): Likewise.
	(_bfd_archive_64_bit_generic_stat_arch_elt): Likewise.
	(_bfd_archive_64_bit_update_armap_timestamp): Likewise.
	* libbfd.h: Regenerated.
	* plugin.c (plugin_vec): Use _bfd_archive_64_bit on
	BFD_JUMP_TABLE_ARCHIVE if USE_64_BIT_ARCHIVE is defined.

binutils/

	PR binutils/14625
	* NEWS: Mention --enable-64-bit-archive.
2016-05-25 09:47:03 -07:00
H.J. Lu b95a0a3177 Skip an archive element if not added by linker
During archive rescan to resolve symbol references for files added by
LTO, linker add_archive_element callback is called to check if an
archive element should added.  After all IR symbols have been claimed,
linker won't claim new IR symbols and shouldn't add the LTO archive
element.  This patch updates linker add_archive_element callback to
return FALSE when seeing an LTO archive element during rescan and
changes ELF linker to skip such archive element.

bfd/

	PR ld/20103
	* cofflink.c (coff_link_check_archive_element): Return TRUE if
	linker add_archive_element callback returns FALSE.
	* ecoff.c (ecoff_link_check_archive_element): Likewise.
	* elf64-ia64-vms.c (elf64_vms_link_add_archive_symbols): Skip
	archive element if linker add_archive_element callback returns
	FALSE.
	* elflink.c (elf_link_add_archive_symbols): Likewise.
	* pdp11.c (aout_link_check_ar_symbols): Likewise.
	* vms-alpha.c (alpha_vms_link_add_archive_symbols): Likewise.
	* xcofflink.c (xcoff_link_check_dynamic_ar_symbols): Likewise.
	(xcoff_link_check_ar_symbols): Likewise.

ld/

	PR ld/20103
	* ldmain.c (add_archive_element): Don't claim new IR symbols
	after all IR symbols have been claimed.
	* plugin.c (plugin_call_claim_file): Remove no_more_claiming
	check.
	* testsuite/ld-plugin/lto.exp (pr20103): New proc.
	Run PR ld/20103 tests.
	* testsuite/ld-plugin/pr20103a.c: New file.
	* testsuite/ld-plugin/pr20103b.c: Likewise.
	* testsuite/ld-plugin/pr20103c.c: Likewise.
2016-05-25 08:41:05 -07:00
Tom Tromey 7bd787e877 fix spelling of HAVE_LIBPYTHON2_4 in py-value.c
Ulrich pointed out that an earlier patch had misspelled
HAVE_LIBPYTHON2_4, adding an extra "_".  This caused a build failure.
This patch fixes the bug.

2016-05-25  Tom Tromey  <tom@tromey.com>

	* python/py-value.c (value_object_as_number): Use correct spelling
	of HAVE_LIBPYTHON2_4.
2016-05-25 07:54:44 -06:00
Nick Clifton ee4d7613b9 Fix typo in changelog entry 2016-05-25 13:12:14 +01:00
Chua Zheng Leong 934c263269 Only generate VMOV.I64 instructions for loading constant floating point values if this instruction is supported by the currently selected fpu.
PR target/2006764
	* config/tc-arm.c (move_or_literal_pool): Only generate a VMOV.I64
	instruction if supported by the currently selected fpu variant.
	* testsuite/gas/arm/vfpv3-ldr_immediate.s: Add test of this PR.
	* testsuite/gas/arm/vfpv3-ldr_immediate.d: Update expected disassembly.
2016-05-25 13:09:51 +01:00
Bernhard Heckel 2bbad2ea11 Fortran, typeprint: Forward level of details to be printed for pointers.
Variable "show" was hardcoded to zero for pointer and reference types.
This implementation didn't allow a correct "whatis" print
for those types and results in same output for "ptype" and "whatis".

Before:
(gdb) whatis t3p
type = PTR TO -> ( Type t3
    integer(kind=4) :: t3_i
    Type t2 :: t2_n
End Type t3 )

After:
(gdb) whatis t3p
type = PTR TO -> ( Type t3 )

2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* f-typeprint.c (f_type_print_base): Replace 0 by show.

gdb/testsuite/Changelog:
	* gdb.fortran/type.f90: Add pointer variable.
	* gdb.fortran/whatis_type.exp: Add whatis/ptype of pointers.
2016-05-25 08:47:18 +02:00
Bernhard Heckel 8b70175dfa Fortran, testsuite: Fix duplicate testcase name.
2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/testsuite/Changelog:
	* gdb.fortran/vla-type.exp: Fix testcase name.
2016-05-25 08:47:18 +02:00
Bernhard Heckel 86d8a84882 Fortran, testsuite: Add testcases for nested structures.
As as result of printing only the outer elements of nested structures,
some testcases have to be added to check for corner cases with VLA's.

2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/testsuite/Changelog:
	* gdb.fortran/vla-type.exp: Access elements in nested structs.
2016-05-25 08:47:18 +02:00
Bernhard Heckel e188eb3621 Fortran, typeprint: Decrease level of details when printing elements of a structure.
According to the typeprint's description, the level of details is
decreased by one for the typeprint of elements of a structure.

Before:
(gdb) ptype t3v
type = Type t3
    integer(kind=4) :: t3_i
    Type t2
        integer(kind=4) :: t2_i
        Type t1
            integer(kind=4) :: t1_i
            real(kind=4) :: t1_r
        End Type t1 :: t1_n
    End Type t2 :: t2_n
End Type t3

After:
(gdb) ptype t3v
type = Type t3
    integer(kind=4) :: t3_i
    Type t2 :: t2_n
End Type t3

2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* f-typeprint.c (f_type_print_base): Decrease show by one.

gdb/testsuite/Changelog:
	* gdb.fortran/type.f90: Add nested structures.
	* gdb.fortran/whatis-type.exp: Whatis/ptype nested structures.
	* gdb.fortran/derived-type.exp: Adapt expected output.
	* gdb.fortran/vla-type.exp: Adapt expected output.
2016-05-25 08:47:17 +02:00
Bernhard Heckel 9b2db1fd27 Fortran, typeprint: Take level of details into account when printing elements of a structure.
According to the typeprint's description, elements of a structure
should not be printed when show is < 1.
This variable is also used to distinguish the level of details
between "ptype" and "whatis" expressions.

Before:
(gdb) whatis t1v
type = Type t1
    integer(kind=4) :: t1_i
    real(kind=4) :: t1_r
End Type t1

After:
(gdb) whatis t1v
type = Type t1

2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* f-typeprint.c (f_type_print_base): Don't print fields when show < 0.

gdb/testsuite/Changelog:
	* gdb.fortran/whatis_type.exp: Adapt expected output.
2016-05-25 08:47:17 +02:00
Bernhard Heckel 72b1705502 Fortran, typeprint: Fix wrong indentation when ptype nested structures.
Level of indentation was not proper handled when printing
the elements type's name.

Before:
type = Type t1
integer(kind=4) :: var_1
integer(kind=4) :: var_2
End Type t1

After:
type = Type t1
    integer(kind=4) :: var_1
    integer(kind=4) :: var_2
End Type t1

2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/Changelog:
	* f-typeprint.c (f_type_print_base): Take print level into account.

gdb/testsuite/Changelog:
	* gdb.fortran/print_type.exp: Fix expected output.
	* gdb.fortran/whatis_type.exp: Fix expected output.
2016-05-25 08:47:16 +02:00
Bernhard Heckel 3cd81d8df7 Fortran, testsuite: Use multi_line in whatis_type testcase.
2016-05-25  Bernhard Heckel  <bernhard.heckel@intel.com>

gdb/testsuite/Changelog:
	* gdb.fortran/whatis_type.exp: Use multi_line.
2016-05-25 08:47:16 +02:00
GDB Administrator e4c1704d7a Automatic date update in version.in 2016-05-25 00:00:17 +00:00
Maciej W. Rozycki 7db9a74e9f MIPS/BFD: Unify `bfd_reloc_outofrange' error reporting code
bfd/
	* elfxx-mips.c (_bfd_mips_elf_relocate_section)
	<bfd_reloc_outofrange>: Unify error reporting code.
2016-05-24 20:48:14 +01:00
Tom Tromey ddae946278 Fix PR python/17386 - add __index__ method to gdb.Value
This patch fixes PR python/17386.

The bug is that gdb.Value does not implement the Python __index__
method.  This method is needed to convert a Python object to an index
and is used by various operations in Python, such as indexing an
array.

The fix is to implement the nb_index method for gdb.Value.

nb_index was added in Python 2.5.  I don't have a good way to test
Python 2.4, but I made an attempt to accomodate it.

I chose to use valpy_long in all cases because this simplifies porting
to Python 3, and because there didn't seem to be any harm.

Built and regtested on x86-64 Fedora 23.

2016-05-24  Tom Tromey  <tom@tromey.com>

	PR python/17386:
	* python/py-value.c (value_object_as_number): Add
	nb_inplace_floor_divide, nb_inplace_true_divide, nb_index.

2016-05-24  Tom Tromey  <tom@tromey.com>

	PR python/17386:
	* gdb.python/py-value.exp (test_value_numeric_ops): Add tests that
	use value as an index.
2016-05-24 10:05:59 -06:00
Tom Tromey e2b7f516fc add nb_inplace_divide for python 2
Python 2's PyNumberMethods has nb_inplace_divide, but Python 3 does
not.  This patch adds it for Python 2.

This buglet didn't cause much fallout because the only non-NULL entry
in value_object_as_number after this is for valpy_divide; and the
missing slot caused it to slide up to nb_floor_divide (where
nb_true_divide was intended).

2016-05-24  Tom Tromey  <tom@tromey.com>

	* python/py-value.c (value_object_as_number): Add
	nb_inplace_divide for Python 2.
2016-05-24 10:05:58 -06:00
Tom Tromey 1957f6b89f Fix PR python/17981
PR python/17981 notes that gdb.breakpoints() returns None when there
are no breakpoints; whereas an empty list or tuple would be more in
keeping with Python and the documentation.

This patch fixes the bug by changing the no-breakpoint return to make
an empty tuple.

Built and regtested on x86-64 Fedora 23.

2016-05-23  Tom Tromey  <tom@tromey.com>

	PR python/17981:
	* python/py-breakpoint.c (gdbpy_breakpoints): Return a new tuple
	when there are no breakpoints.

2016-05-23  Tom Tromey  <tom@tromey.com>

	* python.texi (Basic Python): Document gdb.breakpoints return.

2016-05-23  Tom Tromey  <tom@tromey.com>

	PR python/17981:
	* gdb.python/py-breakpoint.exp (test_bkpt_basic): Add test for
	no-breakpoint case.
2016-05-24 09:55:01 -06:00
Tom Tromey 224f10c1ae PR gdb/19194 - fix typo in the manual
PR gdb/19194 points out a typo in the documentation.  I'm checking
this in as obvious.

2016-05-24  Tom Tromey  <tom@tromey.com>

	PR gdb/19194:
	* gdb.texinfo (gdb man): Fix typo.
2016-05-24 09:41:39 -06:00
Pedro Alves 026a917475 Fix PR gdb/19828: gdb -p <process from a container>: internal error
When GDB attaches to a process, it looks at the /proc/PID/task/ dir
for all clone threads of that process, and attaches to each of them.

Usually, if there is more than one clone thread, it means the program
is multi threaded and linked with pthreads.  Thus when GDB soon after
attaching finds and loads a libthread_db matching the process, it'll
add a thread to the thread list for each of the initially found
lower-level LWPs.

If, however, GDB fails to find/load a matching libthread_db, nothing
is adding the LWPs to the thread list.  And because of that, "detach"
hits an internal error:

  (gdb) PASS: gdb.threads/clone-attach-detach.exp: fg attach 1: attach
  info threads
    Id   Target Id         Frame
  * 1    LWP 6891 "clone-attach-de" 0x00007f87e5fd0790 in __nanosleep_nocancel () at ../sysdeps/unix/syscall-template.S:84
  (gdb) FAIL: gdb.threads/clone-attach-detach.exp: fg attach 1: info threads shows two LWPs
  detach
  .../src/gdb/thread.c:1010: internal-error: is_executing: Assertion `tp' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n)
  FAIL: gdb.threads/clone-attach-detach.exp: fg attach 1: detach (GDB internal error)

From here:

  ...
  #8  0x00000000007ba7cc in internal_error (file=0x98ea68 ".../src/gdb/thread.c", line=1010, fmt=0x98ea30 "%s: Assertion `%s' failed.")
      at .../src/gdb/common/errors.c:55
  #9  0x000000000064bb83 in is_executing (ptid=...) at .../src/gdb/thread.c:1010
  #10 0x00000000004c23bb in get_pending_status (lp=0x12c5cc0, status=0x7fffffffdc0c) at .../src/gdb/linux-nat.c:1235
  #11 0x00000000004c2738 in detach_callback (lp=0x12c5cc0, data=0x0) at .../src/gdb/linux-nat.c:1317
  #12 0x00000000004c1a2a in iterate_over_lwps (filter=..., callback=0x4c2599 <detach_callback>, data=0x0) at .../src/gdb/linux-nat.c:899
  #13 0x00000000004c295c in linux_nat_detach (ops=0xe7bd30, args=0x0, from_tty=1) at .../src/gdb/linux-nat.c:1358
  #14 0x000000000068284d in delegate_detach (self=0xe7bd30, arg1=0x0, arg2=1) at .../src/gdb/target-delegates.c:34
  #15 0x0000000000694141 in target_detach (args=0x0, from_tty=1) at .../src/gdb/target.c:2241
  #16 0x0000000000630582 in detach_command (args=0x0, from_tty=1) at .../src/gdb/infcmd.c:2975
  ...

Tested on x86-64 Fedora 23.  Also confirmed the test passes against
gdbserver with "maint set target-non-stop".

gdb/ChangeLog:
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* linux-nat.c (attach_proc_task_lwp_callback): Mark the lwp
	resumed, and add the thread to GDB's thread list.

testsuite/ChangeLog:
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* gdb.threads/clone-attach-detach.c: New file.
	* gdb.threads/clone-attach-detach.exp: New file.
2016-05-24 14:51:32 +01:00
Pedro Alves 72b049d38c Make gdb/linux-nat.c consider a waitstatus pending on the infrun side
Working on the fix for gdb/19828, I saw
gdb.threads/attach-many-short-lived-threads.exp fail once in an
unusual way.  Unfortunately I didn't keep debug logs, but it's an
issue similar to what's been fixed in remote.c a while ago --
linux-nat.c was not fetching the pending status from the right place.

gdb/ChangeLog:
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* linux-nat.c (get_pending_status): If the thread reported the
	event to the core and it's pending, use the pending status signal
	number.
2016-05-24 14:51:03 +01:00
Pedro Alves 774113b02f [Linux] Optimize PID -> struct lwp_info lookup
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, and running gdb under
perf, I saw that GDB was spending most of the time in find_lwp_pid:

   - captured_main
      - 93.61% catch_command_errors
         - 87.41% attach_command
            - 87.40% linux_nat_attach
               - 87.40% linux_proc_attach_tgid_threads
                  - 82.38% attach_proc_task_lwp_callback
                     - 81.01% find_lwp_pid
                          5.30% ptid_get_lwp
                        + 0.10% ptid_lwp_p
                     + 0.64% add_thread
                     + 0.26% set_running
                     + 0.24% set_executing
                       0.12% ptid_get_lwp
                     + 0.01% ptrace
                     + 0.01% add_lwp

attach_proc_task_lwp_callback is called once for each LWP that we
attach to, found by listing the /proc/PID/task/ directory.  In turn,
attach_proc_task_lwp_callback calls find_lwp_pid to check whether the
LWP we're about to try to attach to is already known.  Since
find_lwp_pid does a linear walk over the whole LWP list, this becomes
quadratic.  We do the /proc/PID/task/ listing until we get two
iterations in a row where we found no new threads.  So the second and
following times we walk the /proc/PID/task/ dir, we're going to take
an even worse find_lwp_pid hit.

Fix this by adding a hash table keyed by LWP PID, for fast lookup.

The linked list embedded in the LWP structure itself is kept, and made
a double-linked list, so that removals from that list are O(1).  An
earlier version of this patch got rid of this list altogether, but
that revealed hidden dependencies / assumptions on how the list is
sorted.  For example, killing a process and then waiting for all the
LWPs status using iterate_over_lwps only works as is because the
leader LWP is always last in the list.  So I thought it better to take
an incremental approach and make this patch concern itself _only_ with
the PID lookup optimization.

gdb/ChangeLog:
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* linux-nat.c (lwp_lwpid_htab): New htab.
	(lwp_info_hash, lwp_lwpid_htab_eq, lwp_lwpid_htab_create)
	(lwp_lwpid_htab_add_lwp): New functions.
	(lwp_list): Tweak comment.
	(lwp_list_add, lwp_list_remove, lwp_lwpid_htab_remove_pid): New
	functions.
	(purge_lwp_list): Rewrite, using htab_traverse_noresize.
	(add_initial_lwp): Add lwp to htab too.  Use lwp_list_add.
	(delete_lwp): Use lwp_list_remove.  Remove htab too.
	(find_lwp_pid): Search in htab.
	(_initialize_linux_nat): Call lwp_lwpid_htab_create.
	* linux-nat.h (struct lwp_info) <prev>: New field.
2016-05-24 14:50:37 +01:00
Pedro Alves 1ad3de988d [Linux] Avoid refetching core-of-thread if thread hasn't run
Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens, I saw GDB having trouble
keeping up with threads being spawned too fast, when it tried to stop
them all.  This was because while gdb is doing that, it updates the
thread list to make sure no new thread has sneaked in that might need
to be paused.  It does this a few times until it sees no-new-threads
twice in a row.  The thread listing update itself is not that
expensive, however, in the Linux backend, updating the threads list
calls linux_common_core_of_thread for each LWP to record on which core
each LWP was last seen running, which opens/reads/closes a /proc file
for each LWP which becomes expensive when you need to do it for
thousands of LWPs.

perf shows gdb in linux_common_core_of_thread 44% of the time, in the
stop_all_threads -> update_thread_list path in this use case.

This patch simply makes linux_common_core_of_thread avoid updating the
core the thread is bound to if the thread hasn't run since the last
time we updated that info.  This makes linux_common_core_of_thread
disappear into the noise in the perf report.

gdb/ChangeLog:
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* linux-nat.c (linux_resume_one_lwp_throw): Clear the LWP's core
	field.
	(linux_nat_update_thread_list): Don't fetch the core if already
	known.
2016-05-24 14:48:57 +01:00
Pedro Alves 95e94c3f18 [Linux] Read vDSO range from /proc/PID/task/PID/maps instead of /proc/PID/maps
... as it's _much_ faster.

Hacking the gdb.threads/attach-many-short-lived-threads.exp test to
spawn thousands of threads instead of dozens to stress and debug
timeout problems with gdb.threads/attach-many-short-lived-threads.exp,
I saw that GDB would spend several seconds just reading the
/proc/PID/smaps file, to determine the vDSO mapping range.  GDB opens
and reads the whole file just once, and caches the result, but even
that is too slow.  For example, with almost 8000 threads:

 $ ls /proc/3518/task/ | wc -l
 7906

reading the /proc/PID/smaps file grepping for "vdso" takes over 15
seconds :

 $ time cat /proc/3518/smaps | grep vdso
 7ffdbafee000-7ffdbaff0000 r-xp 00000000 00:00 0                          [vdso]

 real    0m15.371s
 user    0m0.008s
 sys     0m15.017s

Looking around the web for hints, I found a nice description of the
issue here:

 http://backtrace.io/blog/blog/2014/11/12/large-thread-counts-and-slow-process-maps/

The problem is that /proc/PID/smaps wants to show the mappings as
being thread stack, and that has the kernel iterating over all threads
in the thread group, for each mapping.

The fix is to use the "map" file under /proc/PID/task/PID/ instead of
the /proc/PID/ one, as the former doesn't mark thread stacks for all
threads.

That alone drops the timing to the millisecond range on my machine:

 $ time cat /proc/3518/task/3518/smaps | grep vdso
 7ffdbafee000-7ffdbaff0000 r-xp 00000000 00:00 0                          [vdso]

 real    0m0.150s
 user    0m0.009s
 sys     0m0.084s

And since we only need the vdso mapping's address range, we can use
"maps" file instead of "smaps", and it's even cheaper:

/proc/PID/task/PID/maps :

 $ time cat /proc/3518/task/3518/maps | grep vdso
 7ffdbafee000-7ffdbaff0000 r-xp 00000000 00:00 0                          [vdso]

 real    0m0.027s
 user    0m0.000s
 sys     0m0.017s

gdb/ChangeLog:
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* linux-tdep.c (find_mapping_size): Delete.
	(linux_vsyscall_range_raw): Rewrite reading from
	/proc/PID/task/PID/maps directly instead of using
	gdbarch_find_memory_regions.
2016-05-24 14:48:34 +01:00
Pedro Alves aa01bd3689 Linux native thread create/exit events support
A following patch (fix for gdb/19828) makes linux-nat.c add threads to
GDB's thread list earlier in the "attach" sequence, and that causes a
surprising regression on
gdb.threads/attach-many-short-lived-threads.exp on my machine.  The
extra "thread x exited" handling and traffic slows down that test
enough that GDB core has trouble keeping up with new threads that are
spawned while trying to stop existing ones.

I saw the exact same issue with remote/gdbserver a while ago and fixed
it in 65706a29ba (Remote thread create/exit events) so part of the
fix here is the exact same -- add support for thread created events to
gdb/linux-nat.c.  infrun.c:stop_all_threads enables those events when
it tries to stop threads, which ensures that new threads never get a
chance to themselves start new threads, thus fixing the race.

gdb/
2016-05-24  Pedro Alves  <palves@redhat.com>

	PR gdb/19828
	* linux-nat.c (report_thread_events): New global.
	(linux_handle_extended_wait): Report
	TARGET_WAITKIND_THREAD_CREATED if thread event reporting is
	enabled.
	(wait_lwp, linux_nat_filter_event): Report all thread exits if
	thread event reporting is enabled.  Remove comment.
	(filter_exit_event): New function.
	(linux_nat_wait_1): Use it.
	(linux_nat_thread_events): New function.
	(linux_nat_add_target): Install it as target_thread_events method.
2016-05-24 14:47:56 +01:00
Maciej W. Rozycki 44d3da2338 MIPS/GAS: Treat local jump relocs the same no matter if REL or RELA
Do not convert jump relocs against local MIPS16 or microMIPS symbols to
refer to a section symbol instead even on RELA targets, as it makes it
impossible for the linker to make a JAL to JALX conversion based on ISA
symbol annotation, breaking regular and compressed MIPS interlinking.

	gas/
	* config/tc-mips.c (mips_fix_adjustable): Also return 0 for
	jump relocations against MIPS16 or microMIPS symbols on RELA
	targets.
	* testsuite/gas/mips/jalx-local.d: New test.
	* testsuite/gas/mips/jalx-local-n32.d: New test.
	* testsuite/gas/mips/jalx-local-n64.d: New test.
	* testsuite/gas/mips/jalx-local.s: New test source.
	* testsuite/gas/mips/mips.exp: Run the new tests.

	ld/
	* testsuite/ld-mips-elf/jalx-local.d: New test.
	* testsuite/ld-mips-elf/jalx-local-n32.d: New test.
	* testsuite/ld-mips-elf/jalx-local-n64.d: New test.
	* testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2016-05-24 14:11:50 +01:00