platform/upstream/binutils.git
8 years agoRegenerate Makefile.in/aclocal.m4 automake 1.11.6
H.J. Lu [Fri, 15 Apr 2016 23:20:02 +0000 (16:20 -0700)]
Regenerate Makefile.in/aclocal.m4 automake 1.11.6

bfd/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.
* doc/Makefile.in: Likewise.

binutils/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.
* doc/Makefile.in: Likewise.

gas/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.
* doc/Makefile.in: Likewise.

gold/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.
* testsuite/Makefile.in: Likewise.

gprof/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.

ld/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.

opcodes/

* Makefile.in: Regenerated with automake 1.11.6.
* aclocal.m4: Likewise.

8 years agoMIPS/Linux: Also recognize TRAP_BRKPT and TRAP_HWBKPT
Pedro Alves [Fri, 15 Apr 2016 22:52:00 +0000 (23:52 +0100)]
MIPS/Linux: Also recognize TRAP_BRKPT and TRAP_HWBKPT

This makes the MIPS Linux backends recognize TRAP_BRKPT and
TRAP_HWBKPT in siginfo.si_code in addition to SI_KERNEL, since Linux
4.6 now reports the finer-grained si_code values too.

Refs:
 https://sourceware.org/ml/gdb-patches/2016-02/msg00756.html
 https://sourceware.org/ml/gdb-patches/2016-04/msg00090.html

On kernels that report SI_KERNEL (<= 4.5), we'll enter the "ambiguous"
path of save_stop_reason:

  if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code)
      && GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
    {
      /* The si_code is ambiguous on this arch -- check debug
 registers.  */
      if (!check_stopped_by_watchpoint (lp))
lp->stop_reason = TARGET_STOPPED_BY_SW_BREAKPOINT;
    }

while on kernels that report the finer-grained si_code values (>= 4.6),
we'll enter the corresponding branches:

  else if (GDB_ARCH_IS_TRAP_BRKPT (siginfo.si_code))
    {
    }
  else if (GDB_ARCH_IS_TRAP_HWBKPT (siginfo.si_code))
    {
      ...

gdb/ChangeLog:
2016-04-15  Pedro Alves  <palves@redhat.com>

* nat/linux-ptrace.h [__mips__] (GDB_ARCH_IS_TRAP_BRKPT): Also
accept TRAP_BRKPT.
 [__mips__] (GDB_ARCH_IS_TRAP_HWBKPT): Also accept TRAP_HWBKPT.

8 years ago[ARM] minor opt in thumb_stack_frame_destroyed_p
Yao Qi [Fri, 15 Apr 2016 14:30:01 +0000 (15:30 +0100)]
[ARM] minor opt in thumb_stack_frame_destroyed_p

thumb_stack_frame_destroyed_p scans the instructions from PC to the
end of the function, but if PC is far from the end of pc, we don't
have to scan, because PC should be in epilogue if it is still
far from the end of the function.  The criterion I use here is 16
bytes, which is more than 4 instructions.

Regression tested on aarch64-linux with mutli-arch debug.

gdb:

2016-04-15  Yao Qi  <yao.qi@linaro.org>

* arm-tdep.c (thumb_stack_frame_destroyed_p): Return zero if
PC is far from the end of function.

8 years agoFix non-ELF powerpc build breakage
Alan Modra [Fri, 15 Apr 2016 14:07:30 +0000 (23:37 +0930)]
Fix non-ELF powerpc build breakage

* config/tc-ppc.c (toc_reloc_types): Wrap in #ifdef OBJ_ELF

8 years agoAdd missing ChangeLog entry for PR gas/19909 fix
H.J. Lu [Fri, 15 Apr 2016 12:59:16 +0000 (05:59 -0700)]
Add missing ChangeLog entry for PR gas/19909 fix

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 15 Apr 2016 00:00:20 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agomake a few variables static
Trevor Saunders [Wed, 13 Apr 2016 08:15:10 +0000 (04:15 -0400)]
make a few variables static

They are only used in one file, so we might as well restrict there scope to
that file, and theoretically this might slightly improve compilers ability to
optimize usage of these variables.

gas/ChangeLog:

2016-04-14  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-nios2.c (nios2_as_options): Make file static.
* config/tc-ppc.c (toc_reloc_ypes): Likewise.
* config/tc-sparc.c (native_op_table): Likewise.

8 years agoremove some unused globals
Trevor Saunders [Tue, 12 Apr 2016 14:02:58 +0000 (10:02 -0400)]
remove some unused globals

gas/ChangeLog:

2016-04-14  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

* config/tc-m32c.c (M32C_Macros): Remove.
* config/tc-msp430.c (option_numbers): Likewise.

8 years agoarc/nps400 : New cmem instructions and associated relocation
Andrew Burgess [Tue, 29 Mar 2016 23:02:19 +0000 (00:02 +0100)]
arc/nps400 : New cmem instructions and associated relocation

Add support for arc/nps400 cmem instructions, these load and store
instructions are hard-wired to access "0x57f00000 + 16-bit-offset".

Supporting this relocation required some additions to the arc relocation
handling in the bfd library, as well as the standard changes required to
add a new relocation type.

There's a test of the new instructions in the assembler, and a test of
the relocation in the linker.

bfd/ChangeLog:

* reloc.c: Add BFD_RELOC_ARC_NPS_CMEM16 entry.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* elf32-arc.c: Add 'opcode/arc.h' include.
(struct arc_relocation_data): Add symbol_name.
(arc_special_overflow_checks): New function.
(arc_do_relocation): Use arc_special_overflow_checks, reindent as
required, add an extra comment.
(elf_arc_relocate_section): Setup symbol_name in reloc_data.

gas/ChangeLog:

* testsuite/gas/arc/nps400-3.d: New file.
* testsuite/gas/arc/nps400-3.s: New file.

include/ChangeLog:

* elf/arc-reloc.def: Add ARC_NPS_CMEM16 reloc.
* opcode/arc.h (NPS_CMEM_HIGH_VALUE): Define.

ld/ChangeLog:

* testsuite/ld-arc/arc.exp: New file.
* testsuite/ld-arc/nps-1.s: New file.
* testsuite/ld-arc/nps-1a.d: New file.
* testsuite/ld-arc/nps-1b.d: New file.
* testsuite/ld-arc/nps-1b.err: New file.

opcodes/ChangeLog:

* arc-nps400-tbl.h: Add xldb, xldw, xld, xstb, xstw, and xst
instructions.
* arc-opc.c (insert_nps_cmem_uimm16): New function.
(extract_nps_cmem_uimm16): New function.
(arc_operands): Add NPS_XLDST_UIMM16 operand.

8 years agobfd/arc: Rename enum entries to avoid conflicts
Andrew Burgess [Wed, 6 Apr 2016 17:55:23 +0000 (18:55 +0100)]
bfd/arc: Rename enum entries to avoid conflicts

In bfd/elf32-arc.c an enum is created that contains entries with generic
names like 'NONE' and 'OFF'.  This has been fine for now, but I had a
need to include opcode/arc.h into bfd/elf32-arc.c.  Unfortunately
opcode/arc.h includes a different enum with identical generic names.

Given that changing the enum in the header file could mean wide-ranging
changes, while changing the enum in the .c file is limited to only
changing the one file, I've added a prefix to the enum in the .c file.

This commit does not add the new include, that will come later.  There
should be no functional change with this commit.

bfd/ChangeLog:

* elf32-arc.c (tls_got_entries): Add 'TLS_GOT_' prefix to all
entries.
(elf_arc_relocate_section): Update enum uses.
(elf_arc_check_relocs): Likewise.
(elf_arc_finish_dynamic_symbol): Likewise.

8 years agoopcodes/arc: Move instruction length logic to new function
Andrew Burgess [Thu, 24 Mar 2016 16:54:37 +0000 (16:54 +0000)]
opcodes/arc: Move instruction length logic to new function

Move the logic that calculates the instruction length out to a new
function.  Restructure the code to make it simpler.

opcodes/ChangeLog:

* arc-dis.c (arc_insn_length): New function.
(print_insn_arc): Use arc_insn_length, change insnLen to unsigned.
(find_format): Change insnLen parameter to unsigned.

8 years agoReplace "link" with "sh_link"
H.J. Lu [Thu, 14 Apr 2016 15:36:32 +0000 (08:36 -0700)]
Replace "link" with "sh_link"

On Linux/x86, GCC 4.2 issues a warning:

bfd/elf.c: In function ‘_bfd_elf_copy_private_bfd_data’:
bfd/elf.c:1334: warning: declaration of ‘link’ shadows a global declaration
/usr/include/unistd.h:757: warning: shadowed declaration is here
make[6]: *** [elf.lo] Error 1

Replace "link" with "sh_link" fixes it.

* elf.c (_bfd_elf_copy_private_bfd_data): Replace "link" with
"sh_link".

8 years agogas/arc: Unify tests run on big/little endian arc assembler
Andrew Burgess [Thu, 7 Apr 2016 21:56:44 +0000 (22:56 +0100)]
gas/arc: Unify tests run on big/little endian arc assembler

We were running a slightly different set of assembler tests on big and
little endian arc targets.  This commit unifies the set of tests run.

gas/ChangeLog:

* testsuite/gas/arc/add_s-err.s: Update target pattern.
* testsuite/gas/arc/warn.s: Likewise.
* testsuite/gas/elf/elf.exp: Run test for arc.

8 years agoAvoid "format not a string literal" warnings
Pedro Alves [Thu, 14 Apr 2016 11:58:03 +0000 (12:58 +0100)]
Avoid "format not a string literal" warnings

On:

 $ uname -a
 NetBSD gcc70.fsffrance.org 5.1 NetBSD 5.1 (GENERIC) #0: Sat Nov  6 13:19:33 UTC 2010  builds@b6.netbsd.org:/home/builds/ab/netbsd-5-1-RELEASE/amd64/201011061943Z-obj/home/builds/ab/netbsd-5-1-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64

With:

 $ g++ -v
 Using built-in specs.
 Target: x86_64--netbsd
 Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --build=x86_64-unknown-netbsd4.99.72 --host=x86_64--netbsd --target=x86_64--netbsd --enable-__cxa_atexit
 Thread model: posix
 gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)

I saw:

 cc1plus: warnings being treated as errors
 ../../src/gdb/ctf.c: In function 'void ctf_save_metadata_header(trace_write_handler*)':
 ../../src/gdb/ctf.c:267: warning: format not a string literal, argument types not checked
 cc1plus: warnings being treated as errors
 ../../src/gdb/cli/cli-cmds.c: In function 'void alias_command(char*, int)':
 ../../src/gdb/cli/cli-cmds.c:1428: warning: format not a string literal and no format arguments
 ../../src/gdb/cli/cli-cmds.c:1457: warning: format not a string literal and no format arguments

gdb/ChangeLog:
2016-04-14  Pedro Alves  <palves@redhat.com>

* cli/cli-cmds.c (alias_usage_error): New function.
(alias_command): Use it.
* ctf.c (ctf_save_metadata_header): Inline metadata_fmt local in
ctf_save_write_metadata call.

8 years agoAvoid implicit float <-> integer conversion warnings
Pedro Alves [Thu, 14 Apr 2016 11:58:03 +0000 (12:58 +0100)]
Avoid implicit float <-> integer conversion warnings

On:

 $ uname -a
 NetBSD gcc70.fsffrance.org 5.1 NetBSD 5.1 (GENERIC) #0: Sat Nov  6 13:19:33 UTC 2010  builds@b6.netbsd.org:/home/builds/ab/netbsd-5-1-RELEASE/amd64/201011061943Z-obj/home/builds/ab/netbsd-5-1-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64

With:

 $ g++ -v
 Using built-in specs.
 Target: x86_64--netbsd
 Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --build=x86_64-unknown-netbsd4.99.72 --host=x86_64--netbsd --target=x86_64--netbsd --enable-__cxa_atexit
 Thread model: posix
 gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)

I saw:

 ../../src/gdb/ada-typeprint.c: In function 'void print_fixed_point_type(type*, ui_file*)':
 ../../src/gdb/ada-typeprint.c:366: warning: passing 'float' for argument 2 to 'DOUBLEST ada_fixed_to_float(type*, LONGEST)'

 ../../src/gdb/value.c: In function 'LONGEST unpack_long(type*, const gdb_byte*)':
 ../../src/gdb/value.c:2833: warning: converting to 'LONGEST' from 'DOUBLEST'
 ../../src/gdb/value.c:2838: warning: converting to 'LONGEST' from 'DOUBLEST'

gdb/ChangeLog:
2016-04-14  Pedro Alves  <palves@redhat.com>

* ada-typeprint.c (print_fixed_point_type): Don't pass float as
argument to function expecting LONGEST.
* value.c (unpack_long): Add casts to LONGEST.

8 years agoFix copying Solaris binaries with objcopy.
Nick Clifton [Thu, 14 Apr 2016 11:04:09 +0000 (12:04 +0100)]
Fix copying Solaris binaries with objcopy.

PR target/19938
bfd * elf-bbfd.h (struct elf_backend_data): New field:
elf_strtab_flags.
New field: elf_backend_set_special_section_info_and_link
* elfxx-target.h (elf_backend_strtab_flags): Define if not already
defined.
(elf_backend_set_special_section_info_and_link): Define if not
already defined.
(elfNN_bed): Use elf_backend_set_special_section_info_and_link and
elf_backend_strtab_flags macros to initialise fields in structure.
* elf.c (_bfd_elf_make_section_from_shdr): Check for SHF_STRINGS
being set even if SHF_MERGE is not set.
(elf_fake_sections): Likewise.
(section_match): New function.  Matches two ELF sections based
upon fixed characteristics.
(find_link): New function.  Locates a section in a BFD that
matches a section in a different BFD.
(_bfd_elf_copy_private_bfd_data): Copy the sh_info and sh_link
fields of reserved sections.
(bfd_elf_compute_section_file_positions): Set the flags for the
.shstrtab section based upon the elf_strtab_flags field in the
elf_backend_data structure.
(swap_out_syms): Likewise for the .strtab section.
* elflink.c (bfd_elf_final_link): Set the flags for the
.strtab section based upon the elf_strtab_flags field in the
elf_backend_data structure.
* elf32-i386.c (elf32_i386_set_special_info_link): New function.
(elf_backend_strtab_flags): Set to SHF_STRINGS for Solaris
targets.
(elf_backend_set_special_section_info_and_link): Define for
Solaris targets.
* elf32-sparc.c: Likewise.
* elf64-x86-64.c: Likewise.

binutils* testsuite/binutils-all/i386/compressed-1b.d: Allow for the
string sections possibly having the SHF_STRINGS flag bit set.
* testsuite/binutils-all/i386/compressed-1c.d: Likewise.
* testsuite/binutils-all/readelf.s: Likewise.
* testsuite/binutils-all/readelf.s-64: Likewise.
* testsuite/binutils-all/x86-64/compressed-1b.d: Likewise.
* testsuite/binutils-all/x86-64/compressed-1c.d: Likewise.

gas * testsuite/gas/i386/ilp32/x86-64-unwind.d: Allow for the string
sections possibly having the SHF_STRINGS flag bit set.
* testsuite/gas/i386/x86-64-unwind.d: Likewise.

8 years agoExtend PE matching regexp in PR 19457 test to match cygwin and mingw targets.
Nick Clifton [Thu, 14 Apr 2016 09:38:05 +0000 (10:38 +0100)]
Extend PE matching regexp in PR 19457 test to match cygwin and mingw targets.

PR 19457
* testsuite/ld-scripts/script.exp (extract_symbol_test): Add
exceptions for Mingw and Cygwin.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 14 Apr 2016 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoTest GDB connection to GDBserver with no symbol files
Luis Machado [Wed, 13 Apr 2016 20:22:14 +0000 (15:22 -0500)]
Test GDB connection to GDBserver with no symbol files

This test exercises the scenarios where we attempt to connect GDB to GDBserver
in standard remote mode, query the symbol file path, attempt to open said
symbol file on GDB's end and fail, causing the connection to drop abruptly.

Regression-tested on x86-64/Ubuntu.

With an unpatched GDB we should see this:

FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=permission: connection to GDBserver succeeded (the program is no longer running)
FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded (the program is no longer running)
FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=target:: action=permission: connection to GDBserver succeeded (the program is no longer running)
FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=target:: action=delete: connection to GDBserver succeeded (the program is no longer running)

A patched GDB should have full passes.

gdb/testsuite/ChangeLog:

2016-04-13  Luis Machado  <lgustavo@codesourcery.com>

* gdb.server/connect-with-no-symbol-file.c: New file.
* gdb.server/connect-with-no-symbol-file.exp: New file.

8 years agoDebugging without a binary (regression)
Luis Machado [Wed, 13 Apr 2016 20:17:22 +0000 (15:17 -0500)]
Debugging without a binary (regression)

When we attempt to debug a process using GDBserver in standard remote mode
without a symbol file on GDB's end, we may run into an issue where GDB cuts
the connection attempt short due to an error. The error is caused by not
being able to open a symbol file, like so:

--

(gdb) set sysroot
(gdb) tar rem :2345
Remote debugging using :2345
/proc/23769/exe: Permission denied.
(gdb) i r
The program has no registers now.
(gdb)

It should've been like this:

(gdb) set sysroot
(gdb) tar rem :2345
Remote debugging using :2345
warning: /tmp/symbol-file: Permission denied.
0xf7ddb2d0 in ?? ()
(gdb) i r
eax            0x0  0
ecx            0x0  0
edx            0x0  0
ebx            0x0  0
esp            0xffffdfa0 0xffffdfa0
ebp            0x0  0x0
esi            0x0  0
edi            0x0  0
eip            0xf7ddb2d0 0xf7ddb2d0
eflags         0x200  [ IF ]
cs             0x33 51
ss             0x2b 43
ds             0x0  0
es             0x0  0
fs             0x0  0
gs             0x0  0
(gdb)

This is caused by a couple of function calls within exec_file_locate_attach
that can potentially throw errors.

The following patch guards both exec_file_attach and symbol_file_add_main to
prevent the errors from disrupting the connection process.

There was also a case where native GDB tripped on this problem, but it was
mostly fixed by bf74e428bca61022bd5cdf6bf28789a184748b4d.

Regression-tested on x86-64/Ubuntu.

gdb/ChangeLog:

2016-04-13  Luis Machado  <lgustavo@codesourcery.com>

* exec.c (exec_file_locate_attach): Guard a couple functions
that can throw errors.
(exception_print_same): New helper function.

8 years agoFix zero_ext documentation
Antoine Tremblay [Wed, 13 Apr 2016 16:36:24 +0000 (12:36 -0400)]
Fix zero_ext documentation

This patch fixes the documentation for the zero_ext bytecode description.

It removes parts that seemed like a copy/paste from ext, since zero_ext
zeros the bits to the left.

gdb/doc/ChangeLog:

* agentexpr.texi (zero_ext): Fix zero_ext description.

8 years ago[ARC] Fix setting private elf flags when parsing .cpu.
Claudiu Zissulescu [Tue, 12 Apr 2016 12:51:57 +0000 (14:51 +0200)]
[ARC] Fix setting private elf flags when parsing .cpu.

gas/
2016-04-12  Claudiu Zissulescu  <claziss@synopsys.com>

* config/tc-arc.c (mach_type_specified_p): Change type to
bfd_boolean.
(arc_option): Set private flags when parsing cpu pseudo-op.
(md_parse_option): Set mach_type_specified_p to TRUE.

8 years agoFix and improve comment in gdb_remote_download
Simon Marchi [Wed, 13 Apr 2016 14:47:29 +0000 (10:47 -0400)]
Fix and improve comment in gdb_remote_download

This patch fixes the current comment in gdb_remote_download, which is
false (the "except if that's already where it is" part).  It also
improves it, by explaining why pass TOFILE through standard_output_file,
even it is an absolute path.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_remote_download): Fix and extend comment.

8 years agoAdd support to readelf for detecting and reporting Solaris specific section types...
Nick Clifton [Wed, 13 Apr 2016 14:37:55 +0000 (15:37 +0100)]
Add support to readelf for detecting and reporting Solaris specific section types and symbol visibility.

PR target/19983
* readelf.c (get_solaris_section_type): New function: Returns the
name of Solaris specific section types.
(get_solaris_dynamic_type): New function: Return the name of
Solaris specific dynamic types.
(get_dynamic_type): Use get_solaris_dynamic_type.
(get_section_type_name): Use get_solaris_section_type.
(get_solaris_symbol_visibility): New function: Returns Solaris
specific symbol visibilities.
(print_dynamic_symbol): Use get_solaris_symbol_visibility.
(process_symbol_table): Likewise.

8 years agold/testsuite: Initialise a variable to prevent tcl errors
Andrew Burgess [Tue, 12 Apr 2016 10:04:19 +0000 (11:04 +0100)]
ld/testsuite: Initialise a variable to prevent tcl errors

In some cases a variable could be left uninitialised and then an attempt
made to read this variable, resulting in a tcl error.  This commit
initialises the variable in all cases.

ld/ChangeLog:

* testsuite/lib/ld-lib.exp (run_dump_test): Initialise
check_ld(terminal).

8 years agogdbserver-base.exp: Copy file to standard output directory in ${board}_download
Simon Marchi [Wed, 13 Apr 2016 14:15:40 +0000 (10:15 -0400)]
gdbserver-base.exp: Copy file to standard output directory in ${board}_download

gdbserver-base.exp is used as the base for both native-gdbserver.exp and
native-extended-gdbserver.exp.  (Despite its name, it should really be
considered as a "local-gdbserver-base", as it's not really appropriate to
implement a remote gdbserver board.)

Currently, the _download procedure is implemented as a no-op (it returns
the source file path).  Because of the SONAME change, The fast
tracepoint tests now require the executable and the IPA
(libinproctrace.so) to be located in the same directory (see [1]).  When
using the native-gdbserver board, because _download returns the original
file path, the executable does not end up in the same directory as the
library, and it fails to execute.

In more general terms, with the recent changes, the testsuite now
assumes that when it does

  ${board}_download <source path 1> <destination path 1>
  ${board}_download <source path 2> <destination path 2>

where the destination paths are relative (generally just the file name),
both files will end up in the same base directory.  That assumption does
not hold for the current implementation in gdbserver-base.exp.

The proper fix would be to make native-gdbserver non-remote, so that
gdb_remote_download would not call DejaGnu's remote_download (see [2]).
We could then get rid of ${board}_download in gdbserver-base.exp.
However, that will likely take some time to complete.  In the mean time,
in order to make the fast tracepoint tests pass, we can simply copy the
file to the standard output directory.  Basically, it just mimics what
gdb_remote_download would do if the board wasn't flagged as remote.

Note that I missed these failures originally because I had a
libinproctrace.so in /usr/local/lib.  So, even though libinproctrace.so
wasn't copied to the test output directory, it did find the one in
/usr/local/lib.  It would be nice to find a way to protect against this,
as it could easily happen again...

Regtested with unix, native-gdbserver and native-extended-gdbserver, and
didn't see anything notable, except the ftrace tests now passing for
native-gdbserver.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=6e774b13c3b81ac2599812adf058796948ce7e95
[2] https://sourceware.org/ml/gdb-patches/2016-04/msg00112.html

gdb/testsuite/ChangeLog:

* boards/gdbserver-base.exp (${board}_download): Copy source file to
standard output directory.

8 years agooops - omitted from previous delta.
Nick Clifton [Wed, 13 Apr 2016 14:10:48 +0000 (15:10 +0100)]
oops - omitted from previous delta.

8 years agoFix disassembly of the V850's LD.BU instruction.
Nick Clifton [Wed, 13 Apr 2016 14:09:25 +0000 (15:09 +0100)]
Fix disassembly of the V850's LD.BU instruction.

PR target/19937
opcode * v850-opc.c (v850_opcodes): Correct masks for long versions of
the LD.B and LD.BU instructions.

gas * testsuite/gas/v850/pr19937.s: New test.
* testsuite/gas/v850/pr19937.d: New test control file.
* testsuite/gas/v850/basic.exp: Run the new test.

8 years agoFix aarch64 ftrace JIT condition testcase
Antoine Tremblay [Wed, 13 Apr 2016 13:40:00 +0000 (09:40 -0400)]
Fix aarch64 ftrace JIT condition testcase

This patch fixes the following failure:
FAIL: gdb.trace/trace-condition.exp: ftrace: -(21 << 1) == -42: check 10
frames were collected.

This was due to aarch64_emit_sub using the wrong order in its operands, so the
operation would end up being 42 - 0 rather than 0 - 42.

This patch also fixes the order of aarch64_emit_add for clarity.

The test case for emit_sub is fixed so that the proper order of
the operands is needed for the test to pass.

Tested on aarch64-native-extended-gdbserver.

Note: trace-condition.exp was broken a bit so I had to modify it to run
the test. A fix is coming for that in another patch.

gdb/gdbserver/ChangeLog:

* linux-aarch64-low.c (aarch64_emit_add): Switch x1 and x0.
(aarch64_emit_sub): Likewise.

gdb/testsuite/ChangeLog:

* gdb.trace/trace-condition.exp (foreach): Fix emit_sub testcase.

8 years agoFix PR remote/19840: gdb crashes on reverse-stepi
Pedro Alves [Wed, 13 Apr 2016 13:34:00 +0000 (14:34 +0100)]
Fix PR remote/19840: gdb crashes on reverse-stepi

Reverse debugging against a remote target that does reverse debugging
itself (with the bs/bc packets) always trips on:

 (gdb) target remote localhost:...
 (gdb) reverse-stepi
 ../../gdb/target.c:602: internal-error: default_execution_direction: to_execution_direction must be implemented for reverse async

I missed adding a to_execution_direction method to remote.c in commit
3223143295b5 (Adds target_execution_direction to make record targets
support async mode), GDB 7.4 time.  Later, GDB 7.8 switched to
target-async on by default, making the regression user-visible by
default too.

Fix is simply to add the missing to_execution_direction implementation
to target remote.

Tested by Andi Kleen against Simics.

gdb/ChangeLog:
2016-04-13  Pedro Alves  <palves@redhat.com>

PR remote/19840
* remote.c (struct remote_state) <last_resume_exec_dir>: New
field.
(new_remote_state): Default last_resume_exec_dir to EXEC_FORWARD.
(remote_open_1): Reset last_resume_exec_dir to EXEC_FORWARD.
(remote_resume): Store the last execution direction.
(remote_execution_direction): New function.
(init_remote_ops): Install it as to_execution_direction target_ops
method.

8 years agobtrace: fix test build error in gdb.btrace/instruction_history.c
Markus Metzger [Wed, 13 Apr 2016 12:06:51 +0000 (14:06 +0200)]
btrace: fix test build error in gdb.btrace/instruction_history.c

On systems with a newer version of GCC the gdb.btrace/instruction_history.exp
test fails to build like this:

    Running .../gdb.btrace/instruction_history.exp ...
    gdb compile failed, .../gdb.btrace/instruction_history.c:
    In function 'main': .../gdb.btrace/instruction_history.c:24:3: warning:
    implicit declaration of function 'loop' [-Wimplicit-function-declaration]
       loop ();
       ^

Declare loop to fix it.

testsuite/
* gdb.btrace/instruction_history.c (loop): Add declaration.

8 years agoUpdate x86-64 tests for --as-needed
H.J. Lu [Wed, 13 Apr 2016 12:41:36 +0000 (05:41 -0700)]
Update x86-64 tests for --as-needed

Since compiler may pass --as-needed to ld by default, link .o file
before .so file in x86-64 tests.

PR ld/19774
* testsuite/ld-x86-64/x86-64.exp: Link tmpdir/pr17689b.o before
tmpdir/pr17689.so, fix gotpcrel1 test and add more --as-needed
tests.

8 years agoMIPS/GAS: Correct branch relaxation for weak symbols
Maciej W. Rozycki [Sat, 9 Apr 2016 10:59:36 +0000 (11:59 +0100)]
MIPS/GAS: Correct branch relaxation for weak symbols

Weak symbols can be preempted at link time so always choose the longer
sequence in branch relaxation, according to the relaxation level chosen,
so that any symbol finally used as the branch target is reachable.

2016-04-13  Maciej W. Rozycki  <macro@imgtec.com>
            Andrew Bennett  <andrew.bennett@imgtec.com>

gas/
* config/tc-mips.c (relaxed_branch_length): Use the long
sequence where the target is a weak symbol.
(relaxed_micromips_32bit_branch_length): Likewise.
(relaxed_micromips_16bit_branch_length): Likewise.
* testsuite/gas/mips/branch-weak-1.d: New test.
* testsuite/gas/mips/branch-weak-2.d: New test.
* testsuite/gas/mips/branch-weak-3.d: New test.
* testsuite/gas/mips/branch-weak-4.d: New test.
* testsuite/gas/mips/branch-weak-5.d: New test.
* testsuite/gas/mips/branch-weak.l: New stderr output.
* testsuite/gas/mips/branch-weak.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoMIPS/GAS: Relax branches to symbols resolved at link time
Maciej W. Rozycki [Fri, 8 Apr 2016 23:20:35 +0000 (00:20 +0100)]
MIPS/GAS: Relax branches to symbols resolved at link time

Where branch relaxation is enabled emit the long sequence for branches
whose distance cannot be determined, i.e. to symbols that are undefined
or in a different segment.  These symbols are only resolved at link time
and therefore the longer sequence ensures the branch target is in range,
which cannot be guaranteed with a direct branch.

This is the opposite to the current implementation, originally proposed
here: <https://sourceware.org/ml/binutils/2002-09/msg00218.html>.  The
proposal was then extensively discussed before the final version was
posted here: <https://sourceware.org/ml/binutils/2002-10/msg00191.html>
and eventually committed:

commit 4a6a3df43dbb37853a7b88b10ae97d9ec5daf987
Author: Alexandre Oliva <aoliva@redhat.com>
Date:   Sat Oct 12 05:23:33 2002 +0000

The case considered here was not commented in the review however and the
original version remains.  With branch relaxation enabled it makes more
sense to do it consistently, so that all code impure with respect to
branch distances can be linked.  Direct branches are still produced for
the cases concerned where branch relaxation is disabled, which is the
default.

gas/
* config/tc-mips.c (relaxed_branch_length): Use the long
sequence where the distance cannot be determined.
(relaxed_micromips_32bit_branch_length): Likewise.
* testsuite/gas/mips/branch-extern-1.d: New test.
* testsuite/gas/mips/branch-extern-2.d: New test.
* testsuite/gas/mips/branch-extern-3.d: New test.
* testsuite/gas/mips/branch-extern-4.d: New test.
* testsuite/gas/mips/branch-extern.l: New stderr output.
* testsuite/gas/mips/branch-extern.s: New test source.
* testsuite/gas/mips/branch-section-1.d: New test.
* testsuite/gas/mips/branch-section-2.d: New test.
* testsuite/gas/mips/branch-section-3.d: New test.
* testsuite/gas/mips/branch-section-4.d: New test.
* testsuite/gas/mips/branch-section.l: New stderr output.
* testsuite/gas/mips/branch-section.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoAdd init_dwarf_regnames_s390
Andreas Arnez [Wed, 13 Apr 2016 08:56:30 +0000 (10:56 +0200)]
Add init_dwarf_regnames_s390

Define and use DWARF register names for s390.

binutils/ChangeLog:

* dwarf.h (init_dwarf_regnames_s390): Declare.
* dwarf.c (dwarf_regnames_s390): New.
(init_dwarf_regnames_s390): New.
(init_dwarf_regnames): Call it.
* objdump.c (dump_dwarf): Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 13 Apr 2016 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix typo in ftrace.exp condition testing
Antoine Tremblay [Tue, 12 Apr 2016 18:43:12 +0000 (14:43 -0400)]
Fix typo in ftrace.exp condition testing

This obvious patch replaces "ond" wiht "cond" as the test prefix for
conditional tests.

gdb/testsuite/ChangeLog:

* gdb.trace/ftrace.exp (proc): Change test prefix from "ond" to "cond".

8 years ago[C++] Switch TRY/CATCH to real C++ try/catch by default again
Pedro Alves [Tue, 12 Apr 2016 16:49:24 +0000 (17:49 +0100)]
[C++] Switch TRY/CATCH to real C++ try/catch by default again

Now that we don't ever throw GDB exceptions from signal handlers [1],
we can switch back to having TRY/CATCH implemented in terms of C++
try/catch instead of sigjmp/longjmp.

[1] - https://sourceware.org/ml/gdb-patches/2016-03/msg00351.html

Tested on x86_64 Fedora 23, native and gdbserver.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.h (GDB_XCPT_TRY): Update comment.
[__cplusplus] (GDB_XCPT): Define as GDB_XCPT_TRY.

8 years agoUse setjmp/longjmp for TRY/CATCH instead of sigsetjmp/siglongjmp
Pedro Alves [Tue, 12 Apr 2016 16:20:04 +0000 (17:20 +0100)]
Use setjmp/longjmp for TRY/CATCH instead of sigsetjmp/siglongjmp

Now that we don't ever throw GDB exceptions from signal handlers [1],
we can switch to have TRY/CATCH implemented in terms of plain
setjmp/longjmp instead of sigsetjmp/siglongjmp.

In https://sourceware.org/ml/gdb-patches/2015-02/msg00114.html, Yichun
Zhang mentions a 11%/14%+ speedup in his GDB python scripts with a
patch that did something similar to only a specific set of TRY/CATCH
calls.

[1] - https://sourceware.org/ml/gdb-patches/2016-03/msg00351.html

Tested on x86_64 Fedora 23, native and gdbserver.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.c (struct catcher) <buf>: Now a
'jmp_buf' instead of SIGJMP_BUF.
(exceptions_state_mc_init): Change return type to 'jmp_buf'.
(throw_exception): Use longjmp instead of SIGLONGJMP.
* common/common-exceptions.h: Include <setjmp.h> instead of
"gdb_setjmp.h".
(exceptions_state_mc_init): Change return type to 'jmp_buf'.
[GDB_XCPT == GDB_XCPT_SJMP] (TRY): Use setjmp instead of
SIGSETJMP.
* cp-support.c: Include "gdb_setjmp.h".

8 years agoEliminate prepare_to_throw_exception
Pedro Alves [Tue, 12 Apr 2016 16:17:13 +0000 (17:17 +0100)]
Eliminate prepare_to_throw_exception

No longer necessary.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* common/common-exceptions.c (exception_rethrow): Remove
prepare_to_throw_exception call.
* common/common-exceptions.h (prepare_to_throw_exception): Delete
declaration.
* exceptions.c (prepare_to_throw_exception): Delete.

gdb/gdbserver/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* utils.c (prepare_to_throw_exception): Delete.

8 years agoEliminate target_check_pending_interrupt
Pedro Alves [Tue, 12 Apr 2016 15:49:32 +0000 (16:49 +0100)]
Eliminate target_check_pending_interrupt

This is no longer called anywhere.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* target.c (target_check_pending_interrupt): Delete.
* target.h (struct target_ops) <to_check_pending_interrupt>:
Remove method.
(target_check_pending_interrupt): Remove declaration.
* target-delegates.c: Regenerate.

8 years agoEliminate immediate_quit
Pedro Alves [Tue, 12 Apr 2016 15:49:32 +0000 (16:49 +0100)]
Eliminate immediate_quit

This finally gets rid of immediate_quit (and surrounding
infrustruture), as nothing sets it anymore.

gdb_call_async_signal_handler was only necessary in order to handle
immediate_quit.  We can just call mark_async_signal_handler directly
on all hosts now.

In turn, we can clean up mingw-hdep.c's gdb_select a bit, as
sigint_event / sigint_handler is no longer needed.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* defs.h: Update comments on SIGINT handling.
(immediate_quit): Delete declaration.
* event-loop.c (call_async_signal_handler): Delete.
* event-loop.h (call_async_signal_handler): Delete declaration.
(mark_async_signal_handler): Update comments.
(gdb_call_async_signal_handler): Delete declaration.
* event-top.c (handle_sigint): Call mark_async_signal_handler
instead of gdb_call_async_signal_handler.
* exceptions.c (prepare_to_throw_exception): Remove reference to
immediate_quit.
(exception_fprintf): Remove comments about immediate_quit.
* mingw-hdep.c (sigint_event, sigint_handler): Delete.
(gdb_select): Don't wait on sigint_event.
(gdb_call_async_signal_handler): Delete.
(_initialize_mingw_hdep): Delete.
* posix-hdep.c (gdb_call_async_signal_handler): Delete.
* utils.c (immediate_quit): Delete.

8 years agotarget remote: Don't rely on immediate_quit (introduce quit handlers)
Pedro Alves [Tue, 12 Apr 2016 15:49:32 +0000 (16:49 +0100)]
target remote: Don't rely on immediate_quit (introduce quit handlers)

remote.c is the last user of immediate_quit.  It's relied on to
immediately break the initial remote connection sync up, if the user
does Ctrl-C, assuming that was because the target isn't responding.
At that stage, since the connection isn't synced yet, disconnecting is
the only safe thing to do.  This commit reworks that, to not rely on
throwing from the SIGINT signal handler.

So, this commit:

- Introduces the concept of a "quit handler".  This is used to
  override what does the QUIT macro do when the quit flag is set.

- Makes the "struct serial" reachar / write code call QUIT in the
  partial read/write loops, so the current quit handler is invoked
  whenever a serial->read_prim / serial->write_prim returns EINTR.

- Makes the "struct serial" reachar / write code call
  interruptible_select instead of gdb_select, so that QUITs are
  detected in a race-free manner.

- Stops remote.c from setting immediate_quit during the initial
  connection.

- Instead, we install a custom quit handler whenever we're calling
  into the serial code.  This custom quit handler knows to immediately
  throw a quit when we're in the initial connection setup, and
  otherwise defer handling the quit/Ctrl-C request to later, when
  we're safely out of a packet command/response sequence.  This also
  is what is now responsible for handling "double Ctrl-C because
  target connection is stuck/wedged."

- remote.c no longer installs a specialized SIGINT handlers, and
  instead re-uses the quit flag.  Since we want to rely on the QUIT
  macro, the SIGINT handler must also set the quit.  And the easiest
  is just to not install custom SIGINT handler in remote.c.  Let the
  standard SIGINT handler do its job of setting the quit flag.
  Centralizing SIGINT handlers seems like a good thing to me, anyway.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* defs.h (quit_handler_ftype, quit_handler)
(make_cleanup_override_quit_handler, default_quit_handler): New.
(QUIT): Adjust comments.
* event-top.c (default_quit_handler): New function.
(quit_handler): New global.
(struct quit_handler_cleanup_data): New.
(restore_quit_handler, restore_quit_handler_dtor)
(make_cleanup_override_quit_handler): New.
(async_request_quit): Call QUIT.
* remote.c (struct remote_state) <got_ctrlc_during_io>: New field.
(async_sigint_remote_twice_token, async_sigint_remote_token):
Delete.
(remote_close): Update comments.
(remote_start_remote): Don't set immediate_quit.  Set starting_up
earlier.
(remote_serial_quit_handler, remote_unpush_and_throw): New
functions.
(remote_open_1): Clear got_ctrlc_during_io.  Set
remote_async_terminal_ours_p unconditionally.
(async_initialize_sigint_signal_handler)
(async_handle_remote_sigint, async_handle_remote_sigint_twice)
(remote_check_pending_interrupt, async_remote_interrupt)
(async_remote_interrupt_twice)
(async_cleanup_sigint_signal_handler, ofunc)
(sync_remote_interrupt, sync_remote_interrupt_twice): Delete.
(remote_terminal_inferior, remote_terminal_ours): Remove async
checks.
(remote_wait_as): Don't install a SIGINT handler in sync mode.
(readchar, remote_serial_write): Override the quit handler with
remote_serial_quit_handler.
(getpkt_or_notif_sane_1): Don't call QUIT.
(initialize_remote_ops): Don't install
remote_check_pending_interrupt.
(_initialize_remote): Don't create async_sigint_remote_token and
async_sigint_remote_twice_token.
* ser-base.c (ser_base_wait_for): Call QUIT and use
interruptible_select.
(ser_base_write): Call QUIT.
* ser-go32.c (dos_readchar, dos_write): Call QUIT.
* ser-unix.c (wait_for): Don't use VTIME.  Always take the
gdb_select path, but call QUIT and interruptible_select.
* utils.c (maybe_quit): Call the current quit handler.  Don't call
target_check_pending_interrupt.
(defaulted_query, prompt_for_continue): Override the quit handler
with the default quit handler.

8 years agoTUI: GC tui_target_has_run
Pedro Alves [Tue, 12 Apr 2016 15:49:32 +0000 (16:49 +0100)]
TUI: GC tui_target_has_run

Nothing actually uses this global.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* tui/tui-hooks.c (tui_target_has_run): Delete.
(tui_about_to_proceed): Delete.
(tui_about_to_proceed_observer): Delete.
(tui_install_hooks, tui_remove_hooks): Don't install/remove an
about_to_proceed observer.

8 years agoUse target_terminal_ours_for_output in MI
Pedro Alves [Tue, 12 Apr 2016 15:49:32 +0000 (16:49 +0100)]
Use target_terminal_ours_for_output in MI

The MI code only does output, so leave raw/cooked mode alone, as well
as the SIGINT handler.  Restore terminal settings after output, while
at it.  Also, a couple events missed calling target_terminal_ours
before output, even.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* mi/mi-interp.c (mi_new_thread): Put
target_terminal_ours_for_output in effect while outputting.
(mi_thread_exit): Use target_terminal_ours_for_output instead of
target_terminal_ours.
(mi_record_changed, mi_inferior_added, mi_inferior_appeared)
(mi_inferior_exit, mi_inferior_removed, mi_traceframe_changed)
(mi_tsv_created, mi_tsv_deleted, mi_tsv_modified)
(mi_breakpoint_created, mi_breakpoint_deleted)
(mi_breakpoint_modified, mi_solib_loaded, mi_solib_unloaded)
(mi_command_param_changed, mi_memory_changed)
(report_initial_inferior): Use target_terminal_ours_for_output
instead of target_terminal_ours.  Restore terminal settings.
* mi/mi-main.c (mi_execute_command): Use
target_terminal_ours_for_output instead of target_terminal_ours.
Restore terminal settings.

8 years agoDo target_terminal_ours in query & friends instead of in all callers
Pedro Alves [Tue, 12 Apr 2016 15:49:32 +0000 (16:49 +0100)]
Do target_terminal_ours in query & friends instead of in all callers

Any time a caller calls query & friends / prompt_for_continue without
ensuring that gdb owns the terminal for input is a bug.  So do that in
defaulted_query / prompt_for_continue directly instead.

An example of a case where we currently miss calling
target_terminal_ours is internal_error.  Ever since defaulted_query
was made to use gdb_readline_callback, there's no way to answer the
internal error query if the internal error happens while the target is
has the terminal:

  (gdb) c
  Continuing.
  .../src/gdb/linux-nat.c:1676: internal-error: linux_nat_resume: Assertion `dummy_counter < 10' failed.
  A problem internal to GDB has been detected,
  further debugging may prove unreliable.
  Quit this debugging session? (y or n) _

Entering 'y' or 'n' does not work, GDB does not respond.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

PR gdb/19828
* gnu-nat.c (inf_validate_task_sc): Don't call
target_terminal_ours / target_terminal_inferior around query.
* i386-tdep.c (i386_record_lea_modrm, i386_process_record): Don't
call target_terminal_ours / target_terminal_inferior around
yquery.
* linux-record.c (record_linux_system_call): Don't call
target_terminal_ours / target_terminal_inferior around yquery.
* nto-procfs.c (interrupt_query): Don't call target_terminal_ours
/ target_terminal_inferior around query.
* record-full.c (record_full_check_insn_num): Remove
'set_terminal' parameter.  Don't call target_terminal_ours /
target_terminal_inferior around query.
(record_full_message, record_full_registers_change)
(record_full_xfer_partial): Adjust.
* remote.c (interrupt_query): Don't call target_terminal_ours /
target_terminal_inferior around query.
* utils.c (defaulted_query): Install cleanup to restore target
terminal.  Put target_terminal_ours_for_output in effect while
defaulted producing, and target_terminal_ours in in effect while
handling input.
(prompt_for_continue): Install cleanup to restore target terminal.
Put target_terminal_ours in in effect while handling input.

8 years agoAdd missing cleanups to defaulted_query and prompt_for_continue
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Add missing cleanups to defaulted_query and prompt_for_continue

Some of the error paths in these functions leak.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* utils.c (defaulted_query, prompt_for_continue): Free temporary
strings with cleanups, instead of xfree.

8 years agoUse target_terminal_ours_for_output in warning/internal_error
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Use target_terminal_ours_for_output in warning/internal_error

We're only doing output here, so leave raw/cooked mode alone, as well
as the SIGINT handler.

And restore terminal settings, while at it.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* utils.c (vwarning, internal_vproblem): Use
make_cleanup_restore_target_terminal and
target_terminal_ours_for_output.

8 years agoUse target_terminal_ours_for_output in infcmd.c
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Use target_terminal_ours_for_output in infcmd.c

We're only doing output here, so leave raw/cooked mode alone, as well
as the SIGINT handler.

No need to restore terminal settings, we'll set inferior modes on the
following resume.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* infcmd.c (post_create_inferior, prepare_one_step): Use
target_terminal_ours_for_output instead of target_terminal_ours.

8 years agoUse target_terminal_ours_for_output in exceptions.c
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Use target_terminal_ours_for_output in exceptions.c

We're only doing output here, so leave raw/cooked mode alone, as well
as the SIGINT handler.

Restore terminal settings after output, while at it.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* exceptions.c (print_flush): Use target_terminal_ours_for_output
instead of target_terminal_ours, and restore target terminal with
a cleanup.

8 years agoUse target_terminal_ours_for_output in cp-support.c
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Use target_terminal_ours_for_output in cp-support.c

We're only doing output here, so leave raw/cooked mode alone, as well
as the SIGINT handler.

Restore terminal settings after output, while at it.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* cp-support.c (gdb_demangle): Use target_terminal_ours_for_output
instead of target_terminal_ours, and restore target terminal with
a cleanup.

8 years agoada-lang.c: Introduce type_as_string and use it
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
ada-lang.c: Introduce type_as_string and use it

A couple wrong things here

  - We should not use target_terminal_ours when all we want is output.
    We should use target_terminal_ours_for_output instead, which
    preserves raw/cooked terminal modes, and SIGINT forwarding.

  - Most importantly, relying on stderr output immediately preceding
    the error/exception print isn't correct.  The exception could be
    caught and handled, for example; MI frontends won't display the
    stderr part in an error dialog box.  Etc.

This commit introduces a type_as_string helper that allows building a
full error string including type info.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* ada-lang.c (type_as_string, type_as_string_and_cleanup): New
functions.
(ada_lookup_struct_elt_type): Use type_as_string_and_cleanup.

8 years agoFix inconsistent handling of EINTR in ser-*.c backends
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Fix inconsistent handling of EINTR in ser-*.c backends

- If serial->write_prim returns EINTR, ser_bas_write returns it to the
  caller.  This just looks wrong to me -- part of the output may have
  already been sent, and there's no way for the caller to know that,
  and thus no way for a caller to handle a partial write correctly.

- While ser-unix.c:ser_unix_read_prim retries on EINTR,
  ser-tcp.c:net_read_prim does not.

This commit moves EINTR handling to the ser_base_write and
ser_base_readchar level, so all serial backends (at least those that
use it) end up handling EINTR consistently.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* ser-base.c (fd_event): Retry read_prim on EINTR.
(do_ser_base_readchar): Retry read_prim on EINTR.
(ser_base_write): Retry write_prim on EINTR.
* ser-unix.c (ser_unix_read_prim): Don't retry on EINTR here.
(ser_unix_write_prim): Remove comment.

8 years agoPass Ctrl-C to the target in target_terminal_inferior
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Pass Ctrl-C to the target in target_terminal_inferior

If the user presses Ctrl-C immediately before target_terminal_inferior
is called and the target is resumed, instead of after, the Ctrl-C ends
up pending in the quit flag until the target next stops.

remote.c has this bit to handle this:

      if (!target_is_async_p ())
{
  ofunc = signal (SIGINT, sync_remote_interrupt);
  /* If the user hit C-c before this packet, or between packets,
     pretend that it was hit right here.  */
  if (check_quit_flag ())
    sync_remote_interrupt (SIGINT);
}

But that's only reachable if async is off, while async is on by
default nowadays.  It's also obviously not reacheable on native
targets.

This patch generalizes that to all targets.

We can't remove that remote.c bit yet, until we get rid of the sync
SIGINT handler though.  That'll be done later in the series.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* remote.c (remote_pass_ctrlc): New function.
(init_remote_ops): Install it.
* target.c (target_terminal_inferior): Pass pending Ctrl-C to the
target.
(target_pass_ctrlc, default_target_pass_ctrlc): New functions.
* target.h (struct target_ops) <to_pass_ctrlc>: New method.
(target_pass_ctrlc, default_target_pass_ctrlc): New declarations.
* target-delegates.c: Regenerate.

8 years agoDecouple target_interrupt from all-stop/non-stop modes
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Decouple target_interrupt from all-stop/non-stop modes

In non-stop mode, "interrupt" results in a "stop with no signal",
while in all-stop mode, it results in a remote interrupt request /
stop with SIGINT.  This is currently implemented in both the Linux and
remote target backends.  Move it to the core code instead, making
target_interrupt specifically always about "Interrupting as if with
Ctrl-C", just like it is documented.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* infcmd.c (interrupt_target_1): Call target_stop is in non-stop
mode.
* linux-nat.c (linux_nat_interrupt): Delete.
(linux_nat_add_target): Don't install linux_nat_interrupt.
* remote.c (remote_interrupt_ns): Change return type to void.
Throw error if interrupting the target is not supported.
(remote_interrupt): Don't call the remote_stop_ns/remote_stop_as.

8 years agoEliminate clear_quit_flag
Pedro Alves [Tue, 12 Apr 2016 15:49:31 +0000 (16:49 +0100)]
Eliminate clear_quit_flag

Nothing calls this anymore.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* defs.h (clear_quit_flag): Remove declaration.
* extension-priv.h (struct extension_language_ops)
<clear_quit_flag>: Remove field and update comments.
* extension.c (clear_quit_flag): Delete.
* guile/guile.c (guile_extension_ops): Adjust.
* python/python.c (python_extension_ops): Adjust.
(gdbpy_clear_quit_flag): Delete.

8 years agoDon't call clear_quit_flag in captured_main
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Don't call clear_quit_flag in captured_main

This call seems pointless.  For instance, a SIGINT handler is only
installed later on.  And if wasn't, I can't see why we'd want to lose
a Ctrl-C request.

Getting rid of this allows getting rid of clear_quit_flag.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* main.c (captured_main): Don't clear the quit flag.

8 years agoDon't call clear_quit_flag in prepare_to_throw_exception
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Don't call clear_quit_flag in prepare_to_throw_exception

I think this is reminiscent of the time when a longjmp would always
jump to the top level.  Nowaways code that throw exceptions other than
a quit, which may even be caught and handled without reaching the top
level.  Certainly such exceptions shouldn't clear an interrupt
request...

(We also need to get rid of prepare_to_throw_exception in order to be
able to just do "throw ex;" in C++.)

One could argue that we should clear the quit flag when we throw a
quit from the SIGINT handler, when immediate_quit is in effect, to
handle a race, here:

 immediate_quit++;
 QUIT;

... that's the usual pattern code must use when enabling
immediate_quit.  The QUIT is there to catch the case of Ctrl-C having
already been pressed before immediate_quit was enabled.  However, this
can happen:

 immediate_quit++;
<< Ctrl-C pressed here too.
 QUIT;

And in that case, if the quit flag was already set, it'll stay set
even after throwing a quit from the SIGINT handler.  The end result is
a double quit.  But OTOH, the user did press Ctrl-C two times.  Since
I'm getting rid of immediate_quit, I'm not bothering with this.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* exceptions.c (prepare_to_throw_exception): Don't clear the quit
flag.

8 years agoDon't call clear_quit_flag in command_handler
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Don't call clear_quit_flag in command_handler

This just looks totally wrong to me, for completetly discarding a
user-requested Ctrl-C.  I can't think of why we'd want do this here.

Actually, I digged the history, and found out that this has been here
since at least 7b4ac7e1ed2c (gdb-2.4, the initial revision, 1988), at
a time were we had a top level setjmp/longjmp, long before that got
wrapped in throw_exception and friends, and this code was in an
explicit loop, with the quit_flag cleared on every iteration, before
executing a command...

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* event-top.c (command_handler): Don't call clear_quit_flag.

8 years agoDon't call clear_quit_flag after check_quit_flag
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Don't call clear_quit_flag after check_quit_flag

Obviously not necessary since check_quit_flag clears the flag as side
effect.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* remote-sim.c (gdb_os_poll_quit): Don't call clear_quit_flag.
* remote.c (remote_wait_as): Don't call clear_quit_flag.

8 years agoMake Python use a struct serial event
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Make Python use a struct serial event

Now that we have an abstract for wakeable events, use it instead of a
(heavier) serial pipe.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* python/python.c: Include "ser-event.h".
(gdbpy_event_fds): Delete.
(gdbpy_serial_event): New.
(gdbpy_run_events): Change prototype.  Use serial_event_clear
instead of serial_readchar.
(gdbpy_post_event): Use serial_event_set instead of serial_write.
(gdbpy_initialize_events): Use make_serial_event instead of
serial_pipe.

8 years agoIntroduce interruptible_select
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Introduce interruptible_select

We have places where we call a blocking gdb_select expecting that a
Ctrl-C will unblock it.  However, if the Ctrl-C is pressed just before
gdb_select, the SIGINT handler runs before gdb_select, and thus
gdb_select won't return.

For example gdb_readline_no_editing:

       QUIT;

       /* Wait until at least one byte of data is available.  Control-C
          can interrupt gdb_select, but not fgetc.  */
       FD_ZERO (&readfds);
       FD_SET (fd, &readfds);
       if (gdb_select (fd + 1, &readfds, NULL, NULL, NULL) == -1)

and stdio_file_read:

     /* For the benefit of Windows, call gdb_select before reading from
the file.  Wait until at least one byte of data is available.
Control-C can interrupt gdb_select, but not read.  */
     {
       fd_set readfds;
       FD_ZERO (&readfds);
       FD_SET (stdio->fd, &readfds);
       if (gdb_select (stdio->fd + 1, &readfds, NULL, NULL, NULL) == -1)
 return -1;
     }
     return read (stdio->fd, buf, length_buf);

This is a race classically fixed with either the self-pipe trick, or
by blocking SIGINT and then using pselect instead of select.

Blocking SIGINT most of the time would mean that check_quit_flag (and
thus QUIT) would need to do a syscall every time it is called, which
sounds best avoided, since QUIT is called in many loops.  Thus we take
the self-pipe trick route (wrapped in a serial event).

Instead of having all places that need this manually add an extra file
descriptor to the set of gdb_select's watched file descriptors, we
introduce a wrapper, interruptible_select, that does that.

The Windows version of gdb_select actually does not suffer from this,
because mingw-hdep.c:gdb_call_async_signal_handler sets a Windows
event that gdb_select always waits on.  So this patch can be seen as
generalization of that technique.  We can't remove that extra event
from mingw-hdep.c until we get rid of immediate_quit though.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* defs.h: Extend QUIT-related comments to mention
interruptible_select.
(quit_serial_event_set, quit_serial_event_clear): Declare.
* event-top.c: Include "ser-event.h" and "gdb_select.h".
(quit_serial_event): New global.
(async_init_signals): Make quit_serial_event.
(quit_serial_event_set, quit_serial_event_clear)
(quit_serial_event_fd, interruptible_select): New functions.
* extension.c (set_quit_flag): Set the quit serial event.
(check_quit_flag): Clear the quit serial event.
* gdb_select.h (interruptible_select): New declaration.
* guile/scm-ports.c (ioscm_input_waiting): Use
interruptible_select instead of gdb_select.
* top.c (gdb_readline_no_editing): Likewise.
* ui-file.c (stdio_file_read): Likewise.

8 years agoFix signal handler/event-loop races
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Fix signal handler/event-loop races

GDB's core signal handling suffers from a classical signal handler /
mainline code race:

  int
  gdb_do_one_event (void)
  {
  ...
  /* First let's see if there are any asynchronous signal handlers
       that are ready.  These would be the result of invoking any of the
       signal handlers.  */
    if (invoke_async_signal_handlers ())
      return 1;
  ...
    /* Block waiting for a new event.  (...).  */

    if (gdb_wait_for_event (1) < 0)
      return -1;
  ...
  }

If a signal is delivered while gdb is blocked in the poll/select
inside gdb_wait_for_event, then the select/poll breaks with EINTR,
we'll loop back around and call invoke_async_signal_handlers.

However, if the signal handler runs between
invoke_async_signal_handlers and gdb_wait_for_event,
gdb_wait_for_event will block, until the next unrelated event...

The fix is to a struct serial_event, and register it in the set of
files that select/poll in gdb_wait_for_event waits on.  The signal
handlers that defer work to invoke_async_signal_handlers call
mark_async_signal_handler, which is adjusted to also set the new
serial event in addition to setting a flag, and is thus now is
garanteed to immediately unblock the next gdb_select/poll call, up
until invoke_async_signal_handlers is called and the event is cleared.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* event-loop.c: Include "ser-event.h".
(async_signal_handlers_serial_event): New global.
(async_signals_handler, initialize_async_signal_handlers): New
functions.
(mark_async_signal_handler): Set
async_signal_handlers_serial_event.
(invoke_async_signal_handlers): Clear
async_signal_handlers_serial_event.
* event-top.c (async_init_signals): Call
initialize_async_signal_handlers.

8 years agoIntroduce a serial interface for select'able events
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Introduce a serial interface for select'able events

This patch adds a new "event" struct serial type, that is an
abstraction specifically for waking up blocking waits/selects,
implemented on top of a pipe on POSIX, and on top of a native Windows
event (CreateEvent, etc.) on Windows.

This will be used to plug signal handler / mainline code races.

For example, GDB can indefinitely delay handling a quit request if the
user presses Ctrl-C between the last QUIT call and the next (blocking)
gdb_select call in the event loop:

      QUIT;
                  <<< press ctrl-c here and end up blocked in gdb_select
      indefinitely.

      gdb_select (...); // whoops, SIGINT was already handled, no EINTR.

A global alone (either the quit flag, or the "ready" flag of the async
signal handlers in the event loop) is not sufficient.

To plug races such as these on POSIX systems, we have to register some
waitable file descriptor in the set of files gdb_select waits on, and
write to it from the signal handler.  This is classically a pipe, and
the pattern called the self-pipe trick.  On Linux, it could be a more
efficient eventfd instead, but I'm sticking with a pipe for
simplifity, as we need it for portability anyway.

(Alternatively, we could use pselect/ppoll, and block signals until
the pselect.  The latter is not a design I think GDB could use,
because we want the QUIT macro to be super cheap, as it is used in
loops.  Plus, Windows.)

This is a "struct serial" because Windows's gdb_select relies on that.
Windows's gdb_select, our "select" replacement, knows how to wait on
all kinds of handles (regular files, pipes, sockets, console, etc.)
unlike the native Windows "select" function, which can only wait on
sockets.  Each file descriptor for a "serial" type that is not
normally waitable with WaitForMultipleObjects must have a
corresponding struct serial instance.  gdb_select then internally
looks up the struct serial instance that wraps each file descriptor,
and asks it for the corresponding Windows waitable handle.

We could use serial_pipe() to create a "struct serial"-wrapped pipe
that is usable everywhere, including Windows.  That's what currently
python/python.c uses for cross-thread posting of events.

However, serial_write and serial_readchar are not designed to be
async-signal-safe on POSIX hosts.  It's easier to bypass those when
setting/clearing the event source.

And writing and a serial pipe is a bit heavy weight on Windows.
gdb_select requires an extra thread to wait on the pipe and several
Windows events, when a single manual-reset Windows event, with no
extra thread is sufficient.

The intended usage is simply:

- Call make_serial_event to create a serial event object.

- From the signal handler call serial_event_set to set the event.

- From mainline code, have select/poll wait for serial_event_fd(), in
  addition to whatever other files you're about to wait for.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* Makefile.in (SFILES): Add ser-event.c.
(HFILES_NO_SRCDIR): Add ser-event.h.
(COMMON_OBS): Add ser-event.o.
* ser-event.c, ser-event.h: New files.
* serial.c (new_serial): New function, factored out from
(serial_fdopen_ops): ... this.
(serial_open_ops_1): New function, factored out from
(serial_open): ... this.
(serial_open_ops): New function.
* serial.h (struct serial): Forware declare.
(serial_open_ops): New declaration.

8 years agoRemove unused struct serial::name field
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Remove unused struct serial::name field

Not used by anything.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* serial.c (serial_open, serial_fdopen_ops, do_serial_close):
Remove references to name.
* serial.h (struct serial) <name>: Delete.

8 years agoStop remote-fileio.c from throwing from SIGINT handler
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Stop remote-fileio.c from throwing from SIGINT handler

This code installs a custom signal handler that throws a quit
exception if remote_fio_no_longjmp is not set.

AFAICS, the only real reason for this might have been to unblock the
ui_file_read call, in remote_fileio_func_read.  But ever since:

  2009-11-13  Daniel Jacobowitz  <dan@codesourcery.com>

* ui-file.c (stdio_file_read): Call gdb_select before read.

at:

  https://sourceware.org/ml/gdb-patches/2009-11/msg00321.html

that call is interruptible.

This is not only useful for switching to native C++ exceptions, but
AFAICS, also fixes a potential mess up of the remote protocol
connection, since there are target_read_memory calls done while
remote_fio_no_longjmp is clear.  If the user presses ctrl-c while GDB
is sending or receiving a packet, we'll stop the communication
immediately, at a point where it isn't safe.

gdbserver doesn't support the File I/O remote protocol extension so I
can't test this.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* remote-fileio.c (sigint_fileio_token, remote_fio_no_longjmp):
Delete.
(async_remote_fileio_interrupt): Delete.
(remote_fileio_ctrl_c_signal_handler): Don't call the async signal
handler.  Instead just always set the ctrl_c flag.
(remote_fileio_reply): Clear remote_fio_ctrl_c_flag before
re-enabling the SIGINT handler.
(remote_fileio_func_open, remote_fileio_func_close)
(remote_fileio_func_read, remote_fileio_func_write)
(remote_fileio_func_lseek, remote_fileio_func_rename)
(remote_fileio_func_unlink, remote_fileio_func_stat)
(remote_fileio_func_fstat, remote_fileio_func_gettimeofday)
(remote_fileio_func_isatty, remote_fileio_func_system)
(remote_fileio_request): Remove references to
remote_fio_no_longjmp.
(initialize_remote_fileio): Don't create an async signal handler.

8 years agoDon't set immediate_quit in prompt_for_continue
Pedro Alves [Tue, 12 Apr 2016 15:49:30 +0000 (16:49 +0100)]
Don't set immediate_quit in prompt_for_continue

immediate_quit used to be necessary back when prompt_for_continue used
blocking fread, but nowadays it uses gdb_readline_wrapper, which is
implemented in terms of a nested event loop, which already knows how
to react to SIGINT:

 #0  throw_it (reason=RETURN_QUIT, error=GDB_NO_ERROR, fmt=0x9d6d7e "Quit", ap=0x7fffffffcb88)
     at .../src/gdb/common/common-exceptions.c:324
 #1  0x00000000007bab5d in throw_vquit (fmt=0x9d6d7e "Quit", ap=0x7fffffffcb88) at .../src/gdb/common/common-exceptions.c:366
 #2  0x00000000007bac9f in throw_quit (fmt=0x9d6d7e "Quit") at .../src/gdb/common/common-exceptions.c:385
 #3  0x0000000000773a2d in quit () at .../src/gdb/utils.c:1039
 #4  0x000000000065d81b in async_request_quit (arg=0x0) at .../src/gdb/event-top.c:893
 #5  0x000000000065c27b in invoke_async_signal_handlers () at .../src/gdb/event-loop.c:949
 #6  0x000000000065aeef in gdb_do_one_event () at .../src/gdb/event-loop.c:280
 #7  0x0000000000770838 in gdb_readline_wrapper (prompt=0x7fffffffcd40 "---Type <return> to continue, or q <return> to quit---")
     at .../src/gdb/top.c:873

The need for the QUIT in stdin_event_handler is then exposed by the
gdb.base/double-prompt-target-event-error.exp test, which has:

# We're now stopped in a pagination query while handling a
# target event (printing where the program stopped).  Quitting
# the pagination should result in only one prompt being
# output.
send_gdb "\003p 1\n"

Without that change we'd get:

 Continuing.
 ---Type <return> to continue, or q <return> to quit---PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: continue to pagination
 ^CpQuit
 (gdb)  1
 Undefined command: "1".  Try "help".
 (gdb) PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: first prompt
 ERROR: Undefined command "".
 UNRESOLVED: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: no double prompt

Vs:

 Continuing.
 ---Type <return> to continue, or q <return> to quit---PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: continue to pagination
 ^CQuit
 (gdb) p 1
 $1 = 1
 (gdb) PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: first prompt
 PASS: gdb.base/double-prompt-target-event-error.exp: ctrlc target event: continue: no double prompt

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* event-top.c (stdin_event_handler): Call QUIT;
(prompt_for_continue): Don't run with immediate_quit set.

8 years agoTUI: check whether in secondary prompt instead of immediate_quit
Pedro Alves [Tue, 12 Apr 2016 15:49:29 +0000 (16:49 +0100)]
TUI: check whether in secondary prompt instead of immediate_quit

As can be seen in the tui_redisplay_readline comment:

 "The command could call prompt_for_continue and we must not restore
 SingleKey so that the prompt and normal keymap are used."

immediate_quit is being used as proxy for "secondary prompt".

We have a better predicate nowadays, so use it.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* tui/tui-io.c (tui_redisplay_readline): Check
gdb_in_secondary_prompt_p instead of immediate_quit.
* tui/tui.c: Include top.h.
(tui_rl_startup_hook): Check gdb_in_secondary_prompt_p instead of
immediate_quit.

8 years agoInline command_loop in read_command_line
Pedro Alves [Tue, 12 Apr 2016 15:49:29 +0000 (16:49 +0100)]
Inline command_loop in read_command_line

read_command_line is the only caller, and here we can assume we're
reading a regular file, not stdin.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* top.c (read_command_file): Inline command_loop here.
(command_loop): Delete.

8 years agoDon't rely on immediate_quit in command_line_input
Pedro Alves [Tue, 12 Apr 2016 15:49:29 +0000 (16:49 +0100)]
Don't rely on immediate_quit in command_line_input

AFAICS, immediate_quit was only needed here nowdays to be able to
interrupt gdb_readline_no_editing.

command_line_input can also take the gdb_readline_wrapper path, but
since that is built on top of the event loop (gdb_select / poll and
asynchronous signal handlers), it can be interrupted.

gdb/ChangeLog:
2016-04-12  Pedro Alves  <palves@redhat.com>

* top.c: Include "gdb_select.h".
(gdb_readline_no_editing): Wait for input with gdb_select instead
of blocking in fgetc.
(command_line_input): Don't set immediate_quit.

8 years agoAdd support for .extCondCode, .extCoreRegister and .extAuxRegister.
Claudiu Zissulescu [Wed, 6 Apr 2016 14:08:04 +0000 (16:08 +0200)]
Add support for .extCondCode, .extCoreRegister and .extAuxRegister.

gas/
2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/gas/arc/textauxregister.d: New file.
* testsuite/gas/arc/textauxregister.s: Likewise.
* testsuite/gas/arc/textcondcode.d: Likewise.
* testsuite/gas/arc/textcondcode.s: Likewise.
* testsuite/gas/arc/textcoreregister.d: Likewise.
* testsuite/gas/arc/textcoreregister.s: Likewise.
* testsuite/gas/arc/textpseudoop.d: Likewise.
* testsuite/gas/arc/textpseudoop.s: Likewise.
* testsuite/gas/arc/ld2.d: Update test.
* testsuite/gas/arc/st.d: Likewise.
* testsuite/gas/arc/taux.d: Likewise.
* doc/c-arc.texi (ARC Directives): Add .extCondCode,
.extCoreRegister and .extAuxRegister documentation.
* config/tc-arc.c (arc_extcorereg): New function.
(md_pseudo_table): Add .extCondCode, .extCoreRegister and
.extAuxRegister pseudo-ops.
(extRegister_t): New type.
(ext_condcode, arc_aux_hash): New global variable.
(find_opcode_match): Check for extensions.
(preprocess_operands): Likewise.
(md_begin): Add aux registers in a hash.
(assemble_insn): Update use arc_flags member.
(tokenize_extregister): New function.
(create_extcore_section): Likewise.
* config/tc-arc.h (MAX_FLAG_NAME_LENGHT): Increase to 10.
(arc_flags): Delete code, add flgp.

include/
2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>

* opcode/arc.h (flag_class_t): Update.
(ARC_OPCODE_NONE): Define.
(ARC_OPCODE_ARCALL): Likewise.
(ARC_OPCODE_ARCFPX): Likewise.
(ARC_REGISTER_READONLY): Likewise.
(ARC_REGISTER_WRITEONLY): Likewise.
(ARC_REGISTER_NOSHORT_CUT): Likewise.
(arc_aux_reg): Add cpu.

opcodes/
2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>

* arc-dis.c (find_format): Check for extension flags.
(print_flags): New function.
(print_insn_arc): Update for .extCondCode, .extCoreRegister and
.extAuxRegister.
* arc-ext.c (arcExtMap_coreRegName): Use
LAST_EXTENSION_CORE_REGISTER.
(arcExtMap_coreReadWrite): Likewise.
(dump_ARC_extmap): Update printing.
* arc-opc.c (arc_flag_classes): Add F_CLASS_EXTEND flag.
(arc_aux_regs): Add cpu field.
* arc-regs.h: Add cpu field, lower case name aux registers.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoUpdate ARC instruction data-base.
Claudiu Zissulescu [Wed, 6 Apr 2016 14:47:56 +0000 (16:47 +0200)]
Update ARC instruction data-base.

gas/
2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/gas/arc/noargs_a7.d: New file.
* testsuite/gas/arc/noargs_a7.s: Likewise.
* testsuite/gas/arc/noargs_hs.d: Likewise.
* testsuite/gas/arc/noargs_hs.s: Likewise.

opcode/
2016-04-05  Claudiu Zissulescu  <claziss@synopsys.com>

* arc-tbl.h: Add rtsc, sleep with no arguments.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoAdd support for .extInstruction pseudo-op.
Claudiu Zissulescu [Mon, 4 Apr 2016 14:03:53 +0000 (16:03 +0200)]
Add support for .extInstruction pseudo-op.

gas/
2016-04-04  Claudiu Zissulescu  <claziss@synopsys.com>

* testsuite/gas/arc/textinsn-errors.d: New File.
* testsuite/gas/arc/textinsn-errors.err: Likewise.
* testsuite/gas/arc/textinsn-errors.s: Likewise.
* testsuite/gas/arc/textinsn2op.d: Likewise.
* testsuite/gas/arc/textinsn2op.s: Likewise.
* testsuite/gas/arc/textinsn2op01.d: Likewise.
* testsuite/gas/arc/textinsn2op01.s: Likewise.
* testsuite/gas/arc/textinsn3op.d: Likewise.
* testsuite/gas/arc/textinsn3op.s: Likewise.
* doc/c-arc.texi (ARC Directives): Add .extInstruction
documentation.
* config/tc-arc.c (arcext_section): New variable.
(arc_extinsn): New function.
(md_pseudo_table): Add .extInstruction pseudo op.
(attributes_t): New type.
(suffixclass, syntaxclass, syntaxclassmod): New constant
structures.
(find_opcode_match): Remove arc_num_opcodes.
(md_begin): Likewise.
(tokenize_extinsn): New function.
(arc_set_ext_seg): Likewise.
(create_extinst_section): Likewise.

include/
2016-04-04  Claudiu Zissulescu  <claziss@synopsys.com>

* opcode/arc.h (arc_num_opcodes): Remove.
(ARC_SYNTAX_3OP, ARC_SYNTAX_2OP, ARC_OP1_MUST_BE_IMM)
(ARC_OP1_IMM_IMPLIED, ARC_SUFFIX_NONE, ARC_SUFFIX_COND)
(ARC_SUFFIX_FLAG): Define.
(flags_none, flags_f, flags_cc, flags_ccf): Declare.
(arg_none, arg_32bit_rarbrc, arg_32bit_zarbrc, arg_32bit_rbrbrc)
(arg_32bit_rarbu6, arg_32bit_zarbu6, arg_32bit_rbrbu6)
(arg_32bit_rbrbs12, arg_32bit_ralimmrc, arg_32bit_rarblimm)
(arg_32bit_zalimmrc, arg_32bit_zarblimm, arg_32bit_rbrblimm)
(arg_32bit_ralimmu6, arg_32bit_zalimmu6, arg_32bit_zalimms12)
(arg_32bit_ralimmlimm, arg_32bit_zalimmlimm, arg_32bit_rbrc)
(arg_32bit_zarc, arg_32bit_rbu6, arg_32bit_zau6, arg_32bit_rblimm)
(arg_32bit_zalimm, arg_32bit_limmrc, arg_32bit_limmu6)
(arg_32bit_limms12, arg_32bit_limmlimm): Likewise.

opcodes/
2016-04-04  Claudiu Zissulescu  <claziss@synopsys.com>

* arc-opc.c (flags_none, flags_f, flags_cc, flags_ccf):
Initialize.
(arg_none, arg_32bit_rarbrc, arg_32bit_zarbrc, arg_32bit_rbrbrc)
(arg_32bit_rarbu6, arg_32bit_zarbu6, arg_32bit_rbrbu6)
(arg_32bit_rbrbs12, arg_32bit_ralimmrc, arg_32bit_rarblimm)
(arg_32bit_zalimmrc, arg_32bit_zarblimm, arg_32bit_rbrblimm)
(arg_32bit_ralimmu6, arg_32bit_zalimmu6, arg_32bit_zalimms12)
(arg_32bit_ralimmlimm, arg_32bit_zalimmlimm, arg_32bit_rbrc)
(arg_32bit_zarc, arg_32bit_rbu6, arg_32bit_zau6, arg_32bit_rblimm)
(arg_32bit_zalimm, arg_32bit_limmrc, arg_32bit_limmu6)
(arg_32bit_limms12, arg_32bit_limmlimm): Likewise.
(arc_opcode arc_opcodes): Null terminate the array.
(arc_num_opcodes): Remove.
* arc-ext.h (INSERT_XOP): Define.
(extInstruction_t): Likewise.
(arcExtMap_instName): Delete.
(arcExtMap_insn): New function.
(arcExtMap_genOpcode): Likewise.
* arc-ext.c (ExtInstruction): Remove.
(create_map): Zero initialize instruction fields.
(arcExtMap_instName): Remove.
(arcExtMap_insn): New function.
(dump_ARC_extmap): More info while debuging.
(arcExtMap_genOpcode): New function.
* arc-dis.c (find_format): New function.
(print_insn_arc): Use find_format.
(arc_get_disassembler): Enable dump_ARC_extmap only when
debugging.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoRemove unneeded AUX register symbols.
Claudiu Zissulescu [Thu, 31 Mar 2016 10:40:13 +0000 (12:40 +0200)]
Remove unneeded AUX register symbols.

gas/
2016-03-31  Claudiu Zissulescu  <claziss@synopsys.com>

* config/tc-arc.c (preprocess_operands): Mark AUX symbol.
(arc_adjust_symtab): New function.
* config/tc-arc.h (ARC_FLAG_AUX): Define.
(obj_adjust_symtab): Likewise.
* testsuite/gas/arc/taux.d: New file.
* testsuite/gas/arc/taux.s: Likewise.

Signed-off-by: Claudiu Zissulescu <claziss@synopsys.com>
8 years agoProperly handle dynamic reloc against normal symbol
H.J. Lu [Tue, 12 Apr 2016 02:41:37 +0000 (19:41 -0700)]
Properly handle dynamic reloc against normal symbol

We shouldn't issue an error for read-only segment with dynamic IFUNC
relocations when dynamic relocations are against normal symbols.

bfd/

PR ld/19939
* elf-bfd.h (_bfd_elf_allocate_ifunc_dyn_relocs): Add a pointer
to bfd_boolean.
* elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Updated.
Set *readonly_dynrelocs_against_ifunc_p to TRUE if dynamic reloc
applies to read-only section.
* elf32-i386.c (elf_i386_link_hash_table): Add
readonly_dynrelocs_against_ifunc.
(elf_i386_allocate_dynrelocs): Updated.
(elf_i386_size_dynamic_sections): Issue an error for read-only
segment with dynamic IFUNC relocations only if
readonly_dynrelocs_against_ifunc is TRUE.
* elf64-x86-64.c (elf_x86_64_link_hash_table): Add
readonly_dynrelocs_against_ifunc.
(elf_x86_64_allocate_dynrelocs): Updated.
(elf_x86_64_size_dynamic_sections): Issue an error for read-only
segment with dynamic IFUNC relocations only if
readonly_dynrelocs_against_ifunc is TRUE.
* elfnn-aarch64.c (elfNN_aarch64_allocate_ifunc_dynrelocs):
Updated.

ld/

PR ld/19939
* testsuite/ld-i386/i386.exp: Run PR ld/19939 tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
* testsuite/ld-i386/pr19939.s: New file.
* testsuite/ld-i386/pr19939a.d: Likewise.
* testsuite/ld-i386/pr19939b.d: Likewise.
* testsuite/ld-x86-64/pr19939.s: Likewise.
* testsuite/ld-x86-64/pr19939a.d: Likewise.
* testsuite/ld-x86-64/pr19939b.d: Likewise.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 12 Apr 2016 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/opcodes: Fix undecoded MIPS16 extended instruction bit disassembly
Maciej W. Rozycki [Mon, 11 Apr 2016 16:56:01 +0000 (17:56 +0100)]
MIPS/opcodes: Fix undecoded MIPS16 extended instruction bit disassembly

Correct the disassembly of hardware don't cares in MIPS16 extended
instructions.  Rather than e.g.:

   0: f008 0231  addiu v0,sp,16433
   4: f520 3260  sll v0,v1,-12

print:

   0: f008 0231  addiu v0,sp,16401
   4: f520 3260  sll v0,v1,20

respectively instead.

opcodes/
* mips-dis.c (print_mips16_insn_arg): Mask unused extended
instruction bits out.

binutils/
* testsuite/binutils-all/mips/mips16-undecoded.d: New test.
* testsuite/binutils-all/mips/mips16-undecoded.s: New test
source.
* testsuite/binutils-all/mips/mips.exp: Run the new test.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 11 Apr 2016 00:00:17 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix primary reason why the SH simulation hasn't been working on 64 bit hosts.
Oleg Endo [Sun, 10 Apr 2016 02:00:01 +0000 (11:00 +0900)]
Fix primary reason why the SH simulation hasn't been working on 64 bit hosts.

sim/sh/
* interp.c (dmul): Split into dmul_s and dmul_u.  Use explicit integer
width types and simplify implementation.
* gencode.c (dmuls.l, dmulu.l): Use new functions dmul_s and dmul_u.

8 years agoMove ChangeLog entries from sim/ChangeLog to sim/sh/ChangeLog.
Oleg Endo [Sun, 10 Apr 2016 01:53:20 +0000 (10:53 +0900)]
Move ChangeLog entries from sim/ChangeLog to sim/sh/ChangeLog.

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 10 Apr 2016 00:00:25 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/GAS: Sanitize `.option picX' pseudo-op
Maciej W. Rozycki [Sat, 9 Apr 2016 20:35:50 +0000 (21:35 +0100)]
MIPS/GAS: Sanitize `.option picX' pseudo-op

gas/
* config/tc-mips.c (s_option): Sanitize `.option picX'
pseudo-op.
* testsuite/gas/mips/option-pic-1.d: New test.
* testsuite/gas/mips/option-pic-2.l: New list test.
* testsuite/gas/mips/option-pic-1.s: New test source.
* testsuite/gas/mips/option-pic-2.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agoMIPS/GAS: Disallow `.option picX' with VxWorks PIC
Maciej W. Rozycki [Sat, 9 Apr 2016 20:23:40 +0000 (21:23 +0100)]
MIPS/GAS: Disallow `.option picX' with VxWorks PIC

gas/
* config/tc-mips.c (s_option): Reject `.option picX' if VxWorks
PIC.
* testsuite/gas/mips/option-pic-vxworks-1.l: New list test.
* testsuite/gas/mips/option-pic-vxworks-2.l: New list test.
* testsuite/gas/mips/option-pic-vxworks-1.s: New test source.
* testsuite/gas/mips/option-pic-vxworks-2.s: New test source.
* testsuite/gas/mips/mips.exp: Run the new tests.

8 years agogdb.python/py-mi-events-gdb.py: Add parentheses to print
Simon Marchi [Sat, 9 Apr 2016 12:41:41 +0000 (08:41 -0400)]
gdb.python/py-mi-events-gdb.py: Add parentheses to print

Required for Python 3

gdb/testsuite/ChangeLog:

* gdb.python/py-mi-events-gdb.py (signal_stop_handler): Add
parentheses to print.
(continue_handler): Likewise.

8 years agoMIPS/GAS: Correct call formatting in `can_swap_branch_p'
Maciej W. Rozycki [Sat, 9 Apr 2016 12:27:30 +0000 (13:27 +0100)]
MIPS/GAS: Correct call formatting in `can_swap_branch_p'

gas/
* config/tc-mips.c (can_swap_branch_p): Correct call formatting.

8 years agoGAS: Fix a typo in `as_bad' description
Maciej W. Rozycki [Sat, 9 Apr 2016 12:22:54 +0000 (13:22 +0100)]
GAS: Fix a typo in `as_bad' description

gas/
* messages.c (as_bad): Fix a typo in description.

8 years agoMIPS/GAS: Unify messages in `mips_check_options'
Maciej W. Rozycki [Sat, 9 Apr 2016 12:19:00 +0000 (13:19 +0100)]
MIPS/GAS: Unify messages in `mips_check_options'

gas/
* config/tc-mips.c (mips_check_options): Unify messages.

8 years agoMIPS/GAS: Use `opts->isa' consistently in `mips_check_options'
Maciej W. Rozycki [Sat, 9 Apr 2016 11:55:09 +0000 (12:55 +0100)]
MIPS/GAS: Use `opts->isa' consistently in `mips_check_options'

gas/
* config/tc-mips.c (mips_check_options): Use `opts->isa'
consistently.

8 years agoAdjust default memory size and stack base address for SH simulator.
Oleg Endo [Sat, 9 Apr 2016 01:24:00 +0000 (10:24 +0900)]
Adjust default memory size and stack base address for SH simulator.

ld/ChangeLog:
* sh/interp.c (sim_memory_size): Default init to 30.
(parse_and_set_memory_size): Adjust upper bound to 31.

sim/ChangeLog:
* sh/interp.c (sim_memory_size): Default init to 30.
(parse_and_set_memory_size): Adjust upper bound to 31.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 9 Apr 2016 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMake gdb.server/solib-list.exp work for remote targets
Simon Marchi [Fri, 8 Apr 2016 22:45:29 +0000 (18:45 -0400)]
Make gdb.server/solib-list.exp work for remote targets

There are a few small changes needed to make it work with a real remote
target.

 - Remove the [is_remote target] check.
 - Remove soname setting when building the lib, it's done by default now
   anyway.
 - In the compilation of the executable, pass the shared lib using the
   shlib option, so that RPATH is set.
 - Download the program to the target using gdb_remote_download, and
   record the remote path.  Remove loading of the program using
   gdb_load_shlibs, which was not really appropriate anyway.
 - Run the remote path through readlink (see comment in the code).
 - Start gdbserver with the remote path.

Also, don't set executable and objfile variables, as they are unused.

Tested with native, native-gdbserver, native-extended-gdbserver, and a
remote gdbserver.

gdb/testsuite/ChangeLog:

* gdb.server/solib-list.exp: Remove is_remote check.
Pass shlib= to gdb_compile.  Don't link shared library with
-soname.  Call gdb_remote_download instead of gdb_load_shlibs.
Run binary filename through "readlink -f" on the target.

8 years agoFix gdb.server/solib-list.exp regression
Pedro Alves [Thu, 7 Apr 2016 22:36:50 +0000 (23:36 +0100)]
Fix gdb.server/solib-list.exp regression

Commit 7817ea46148d (Improve gdb_remote_download, remove gdb_download)
caused:

 FAIL: gdb.server/solib-list.exp: non-stop 0: target extended-remote (timeout)
 FAIL: gdb.server/solib-list.exp: non-stop 0: continue (the program is no longer running)
 FAIL: gdb.server/solib-list.exp: non-stop 0: p libvar
 FAIL: gdb.server/solib-list.exp: non-stop 1: target extended-remote (timeout)
 FAIL: gdb.server/solib-list.exp: non-stop 1: continue (the program is no longer running)
 FAIL: gdb.server/solib-list.exp: non-stop 1: p libvar

gdb.log shows:

 system interpreter is: /lib64/ld-linux-x86-64.so.2
 ...
 spawn ../gdbserver/gdbserver --once :2347 /home/pedro/brno/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.server/solib-list/ld-linux-x86-64.so.2 /home/pedro/brno/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.server/solib-list/solib-list
 Process /home/pedro/brno/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.server/solib-list/ld-linux-x86-64.so.2 created; pid = 18637
 Cannot exec /home/pedro/brno/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.server/solib-list/ld-linux-x86-64.so.2: No such file or directory.
 ...

The test copied the interpreter to the outputs directory, however
ld-linux-x86-64.so.2 is a relative symlink that when copied points
nowhere:

 $ ls -l testsuite/outputs/gdb.server/solib-list/
 total 52
 -rwxrwxr-x. 1 pedro pedro 13450 Apr  7 10:52 gdb.log
 -rw-rw-r--. 1 pedro pedro  1512 Apr  7 10:52 gdb.sum
 lrwxrwxrwx. 1 pedro pedro    10 Apr  7 11:39 ld-linux-x86-64.so.2 -> ld-2.22.so
 -rwxrwxr-x. 1 pedro pedro  9464 Apr  7 11:39 solib-list
 -rw-rw-r--. 1 pedro pedro  3472 Apr  7 11:39 solib-list-lib.c.o
 -rw-rw-r--. 1 pedro pedro  2760 Apr  7 11:39 solib-list.o
 -rwxrwxr-x. 1 pedro pedro  9232 Apr  7 11:39 solib-list.so

The copying comes from gdbserver_spawn ->
gdbserver_download_current_prog -> gdb_remote_download.

There's actually no need to download the interpreter to the target -
it's part of the target system/environment.  So fix this by making the
test just not use gdb_load (and gdb_file_cmd as consequence) at all,
and instead pass the interpreter filename to gdbserver as an argument.

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

* gdb.server/solib-list.exp: Don't use gdb_load.  Instead pass the
interpreter filename as argument to gdbserver_spawn.
* lib/gdbserver-support.exp (gdbserver_download_current_prog):
Return empty if $last_loaded_file does not exist.

8 years agovalue: Make accessor methods' parameters const-correct
Martin Galvan [Fri, 8 Apr 2016 18:05:45 +0000 (15:05 -0300)]
value: Make accessor methods' parameters const-correct

I did a quick pass over value.c and value.h and made some of the accessor methods'
pass-by-reference parameters const-correct. Besides the obvious benefits, this is
required if we want to use them on values that are already declared as const
(such as the parameters to lval_funcs).

There's probably a lot more stuff that can be made const, here and elsewhere.

gdb/ChangeLog:
2016-04-08  Martin Galvan  <martin.galvan@tallertechnologies.com>

    * value.c (value_next): Make pass-by-reference parameters const-correct.
    (value_parent): Likewise.
    (value_enclosing_type): Likewise.
    (value_lazy): Likewise.
    (value_stack): Likewise.
    (value_embedded_offset): Likewise.
    (value_pointed_to_offset): Likewise.
    (value_raw_address): Likewise.
    (deprecated_value_modifiable): Likewise.
    (value_free_to_mark): Likewise.
    (value_release_to_mark): Likewise.
    (internalvar_name): Likewise.
    (readjust_indirect_value_type): Likewise.
    (value_initialized): Likewise.
    * value.h (value_next): Likewise.
    (value_parent): Likewise.
    (value_enclosing_type): Likewise.
    (value_lazy): Likewise.
    (value_stack): Likewise.
    (value_embedded_offset): Likewise.
    (value_pointed_to_offset): Likewise.
    (value_raw_address): Likewise.
    (deprecated_value_modifiable): Likewise.
    (value_free_to_mark): Likewise.
    (value_release_to_mark): Likewise.
    (internalvar_name): Likewise.
    (readjust_indirect_value_type): Likewise.
    (value_initialized): Likewise.

8 years agoPR18452, ld allows overlapping sections
Alan Modra [Fri, 8 Apr 2016 08:22:03 +0000 (17:52 +0930)]
PR18452, ld allows overlapping sections

PR 18452
* ldlang.c (maybe_overlays): Delete.
(lang_size_sections_1): Remove code setting maybe_overlays.
(lang_check_section_addresses): Instead detect overlays by
exact match of section VMAs here.  Fix memory leak.

8 years agotestsuite: Fix for gcc-4.8: gdb.base/jit.exp gdb.base/jit-so.exp
Jan Kratochvil [Fri, 8 Apr 2016 13:38:53 +0000 (15:38 +0200)]
testsuite: Fix for gcc-4.8: gdb.base/jit.exp gdb.base/jit-so.exp

on CentOS-7.2 I get

Running /home/jkratoch/redhat/gdb-test-reg/gdb/testsuite/gdb.base/jit.exp ...
FAIL: gdb.base/jit.exp: one_jit_test-1: continue to breakpoint: break here 2 (the program exited)
FAIL: gdb.base/jit.exp: one_jit_test-2: continue to breakpoint: break here 2 (the program exited)
FAIL: gdb.base/jit.exp: attach: one_jit_test-2: continue to breakpoint: break here 2 (the program exited)
FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: set var wait_for_gdb = 1
FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: detach (the program is no longer running)
FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: attach
FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: set var wait_for_gdb = 0
FAIL: gdb.base/jit.exp: PIE: one_jit_test-1: continue to breakpoint: break here 2 (the program exited)
Running /home/jkratoch/redhat/gdb-test-reg/gdb/testsuite/gdb.base/jit-so.exp ...
FAIL: gdb.base/jit-so.exp: one_jit_test-1: continue to breakpoint: break here 2 (the program exited)
FAIL: gdb.base/jit-so.exp: one_jit_test-2: continue to breakpoint: break here 2 (the program exited)

since:

85af34ee0211eedf8d30a5c44dfc59dddf8b512a is the first bad commit
commit 85af34ee0211eedf8d30a5c44dfc59dddf8b512a
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Mar 31 19:28:47 2016 +0100
    Add regression test for PR gdb/19858 (JIT code registration on attach)

The compiled code's .debug_line is wrong (for the simplistic approach of GDB
to put a breakpoint on the first address belonging to that source line) and so
GDB misses the breakpoint at the last line:
          WAIT_FOR_GDB; return 0;  /* gdb break here 2  */

Most of the patch is just about reindentation, no changes there.

gdb/testsuite/ChangeLog
2016-04-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

Fix compatibility with gcc-4.8.5-4.el7.x86_64.
* gdb.base/jit-main.c: Use exit after usage.

8 years agoFix regexps in PR19910 test to cope with COFF and AOUT sparc targets.
Nick Clifton [Fri, 8 Apr 2016 09:36:49 +0000 (10:36 +0100)]
Fix regexps in PR19910 test to cope with COFF and AOUT sparc targets.

PR target/19910
* testsuite/gas/sparc/pr19910-1.d: Adjust regexps to work with
COFF and AOUT sparc targets.

8 years agoShow sizes in linker map in target machine address units
Dan Gisselquist [Thu, 7 Apr 2016 12:57:47 +0000 (22:27 +0930)]
Show sizes in linker map in target machine address units

* ldlang.c (print_output_section_statement): Show minfo size
in target machine address units.
(print_reloc_statement): Likewise.
(print_padding_statement): Likewise.
(print_data_statement): Likewise.  Ensure minimum print_dot
increment of one address unit.

8 years agoAutomatic date update in version.in
GDB Administrator [Fri, 8 Apr 2016 00:00:22 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agotestsuite: Fix false FAILs with .bashrc GDBHISTFILE=...
Jan Kratochvil [Thu, 7 Apr 2016 20:18:49 +0000 (22:18 +0200)]
testsuite: Fix false FAILs with .bashrc GDBHISTFILE=...

$ GDBHISTFILE=/tmp/gdbhistfile runtest gdb.base/gdbhistsize-history.exp gdb.base/gdbinit-history.exp
Running ./gdb.base/gdbinit-history.exp ...
FAIL: gdb.base/gdbinit-history.exp: home=gdbinit-history/unlimited gdbhistsize=1000: show commands
FAIL: gdb.base/gdbinit-history.exp: home=gdbinit-history/unlimited gdbhistsize=foo: show commands
Running ./gdb.base/gdbhistsize-history.exp ...
FAIL: gdb.base/gdbhistsize-history.exp: histsize=: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=20: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize= 20 : show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=-5: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=not_an_integer: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=10zab: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=-5ab: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=99999999999999999999999999999999999: show commands
FAIL: gdb.base/gdbhistsize-history.exp: histsize=50: show commands

This happens for my setup due to my:
$ grep GDB ~/.bashrc
export GDBHISTFILE="$HOME/.gdb_history"

gdb/testsuite/ChangeLog
2016-04-07  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.base/gdbhistsize-history.exp: Save and unset GDBHISTFILE and
GDBHISTSIZE prior to the tests.
* gdb.base/gdbinit-history.exp: Likewise.

8 years agoFix gdb.compile/compile.exp shlib regression
Pedro Alves [Thu, 7 Apr 2016 18:28:40 +0000 (19:28 +0100)]
Fix gdb.compile/compile.exp shlib regression

Commit 6e774b13c3b8 (Make ftrace tests work with remote targets) made
a few gdb.compile/compile.exp tests disappear:

 -PASS: gdb.compile/compile.exp: call shared library function
 -PASS: gdb.compile/compile.exp: expect 1
 -PASS: gdb.compile/compile.exp: modify shared library variable
 -PASS: gdb.compile/compile.exp: expect 15

This is because the test uses ldflags instead of using the shlib
option, so it misses linking with -rpath, resulting in:

 (gdb) run
 Starting program: .../compile/compile-shlib
 .../compile/compile-shlib: error while loading shared libraries: compile-shlib.so: cannot open shared object file: No such file or directory
 [Inferior 1 (process 18014) exited with code 0177]

We were missing a gdb_load_shlibs call, which is needed for remote
testing.

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

* gdb.compile/compile.exp: Use gdb_compile with "shlib=" option
instead of build_executable.  Use gdb_load_shlibs.