binutils-gdb.git
8 years agoFix PR 19461: strange "info thread" behavior in non-stop
Pedro Alves [Mon, 25 Jan 2016 12:00:20 +0000 (12:00 +0000)]
Fix PR 19461: strange "info thread" behavior in non-stop

If you have "set follow-fork child" set, then if you do "info threads"
right after a fork, and before the child reports any other event to
GDB core, you'll see:

(gdb) info threads
  Id   Target Id         Frame
* 1.1  Thread 0x7ffff7fc1740 (LWP 31875) "fork-plus-threa" (running)
  2.1  process 31879 "fork-plus-threa" Selected thread is running.
(gdb)

The "Selected thread is running." bit is a bogus error.  That was GDB
trying to fetch the current frame of thread 2.1, because the external
runnning state is "stopped", and then throwing an error because the
thread is actually running.

This actually affects all-stop + schedule-multiple as well.

The problem here is that on a fork event, GDB doesn't update the
external parent/child running states.

New comprehensive test included.  The "kill inferior 1" / "kill
inferior 2" bits also trip on PR gdb/19494 (hang killing unfollowed
fork children), which was fixed by the previous patch.

gdb/ChangeLog:
2016-01-25  Pedro Alves  <palves@redhat.com>

PR threads/19461
* infrun.c (handle_inferior_event_1) <fork/vfork>: Update
parent/child running states.

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

PR threads/19461
* gdb.base/fork-running-state.c: New file.
* gdb.base/fork-running-state.exp: New file.

8 years agoFix PR 19494: hang when killing unfollowed fork children
Pedro Alves [Mon, 25 Jan 2016 12:00:20 +0000 (12:00 +0000)]
Fix PR 19494: hang when killing unfollowed fork children

linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event...  This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.

New test included.  The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child.  Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone.  The test uses a pipe
for that.  The program forks twice, so you have grandparent, child and
grandchild.  The grandchild inherits the write side of the pipe.  The
grandparent hangs reading from the pipe, since nothing ever writes to
it.  If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:

 FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
 FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)

No regressions on x86_64 Fedora 20.  New test passes with gdbserver as
well.

gdb/ChangeLog:
2016-01-25  Pedro Alves  <palves@redhat.com>

PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.

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

PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.

8 years agoMove foreach_with_prefix to lib/gdb.exp
Pedro Alves [Mon, 25 Jan 2016 12:00:18 +0000 (12:00 +0000)]
Move foreach_with_prefix to lib/gdb.exp

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

* gdb.base/step-sw-breakpoint-adjust-pc.exp (foreach_with_prefix):
Delete, moved to lib/gdb.exp.
* gdb.threads/forking-threads-plus-breakpoint.exp
(foreach_with_prefix): Likewise.
* gdb.threads/process-dies-while-handling-bp.exp
(foreach_with_prefix): Likewise.
* lib/gdb.exp (foreach_with_prefix): New procedure.

8 years agoDelete ChangeLog entry from the wrong place
Pedro Alves [Mon, 25 Jan 2016 12:54:48 +0000 (12:54 +0000)]
Delete ChangeLog entry from the wrong place

Missed actually removing this in 37e42b4fe92c...

8 years agogdb.trace/testsuite: Bump stack collection fudge factor.
Marcin Kościelnicki [Sat, 23 Jan 2016 14:42:11 +0000 (15:42 +0100)]
gdb.trace/testsuite: Bump stack collection fudge factor.

These two tests collect 64 words from $sp onwards, hoping that's enough
to capture a few whole stack frames.  Unfortunately, that's not enough
for s390, which tends to have large frame sizes - minimum 24 words on
s390, 20 on s390x (which just barely passes).  Bump it to 128 words,
let's hope no machine needs more.

Tested on x86_64, s390, s390x.

gdb/testsuite/ChangeLog:

* gdb.trace/backtrace.exp: Bump stack collection fudge factor.
* gdb.trace/entry-values.exp: Bump stack collection fudge factor.

8 years agoAdd missing end-of-comment marker to previous delta. (Doh!)
Nick Clifton [Mon, 25 Jan 2016 09:44:18 +0000 (09:44 +0000)]
Add missing end-of-comment marker to previous delta.  (Doh!)

8 years agoFix memory corruption on Mach-O systems by suppressing a memory tidy up.
Nick Clifton [Mon, 25 Jan 2016 09:35:33 +0000 (09:35 +0000)]
Fix memory corruption on Mach-O systems by suppressing a memory tidy up.

PR target/19435
* mach-o.c (bfd_mach_o_close_and_cleanup): Suppress code to free
dsym filename buffer.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 25 Jan 2016 00:00:18 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS/BFD: Simplify register index calculation in BZ16_REG_FIELD
Maciej W. Rozycki [Sun, 24 Jan 2016 00:55:13 +0000 (00:55 +0000)]
MIPS/BFD: Simplify register index calculation in BZ16_REG_FIELD

Just mask higher bits off, which returns the same set of 3-bit register
encodings of { 0, 1, 2, 3, 4, 5, 6, 7 } for the allowed 5-bit encodings
of { 16, 17, 2, 3, 4, 5, 6, 7 }.  Input has already been validated with
OP16_VALID_REG.

bfd/
* elfxx-mips.c (BZ16_REG_FIELD): Simplify calculation.

8 years agoMIPS/BFD: Correct register index calculation in BZ16_REG
Maciej W. Rozycki [Sun, 24 Jan 2016 00:49:26 +0000 (00:49 +0000)]
MIPS/BFD: Correct register index calculation in BZ16_REG

For the 3-bit register encodings of { 0, 1, 2, 3, 4, 5, 6, 7 } return
the 5-bit encodings of { 16, 17, 2, 3, 4, 5, 6, 7 } respectively rather
than { 24, 25, 2, 3, 4, 5, 6, 7 }.

bfd/
* elfxx-mips.c (BZ16_REG): Correct calculation.

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

8 years agogdb.trace: Fix unavailable-dwarf-piece.exp on big endian targets
Marcin Kościelnicki [Sat, 23 Jan 2016 12:17:34 +0000 (13:17 +0100)]
gdb.trace: Fix unavailable-dwarf-piece.exp on big endian targets

The test constructs fake DWARF info for a C structure involving bitfields.
DWARF bitfields are always counted from LSB, while the order in which
bitfields are allocated in a C struct depends on the target endianness -
thus the generated DWARF marks different bitfields as unavailable when
target is big endian.  Accordingly, we need different expected outputs.

Tested on s390 and s390x, no regression on x86_64.

gdb/testsuite/ChangeLog:

* gdb.trace/unavailable-dwarf-piece.exp: Fix bitfield handling on big
endian targets.

8 years agogdb.trace: Fix another expected message on continue.
Marcin Kościelnicki [Sat, 23 Jan 2016 11:06:08 +0000 (12:06 +0100)]
gdb.trace: Fix another expected message on continue.

Missed one message in bd0a71fa16f668341a9361c695bc3ca44d27b322, since it
didn't trigger on s390x or amd64 (fast tracepoint out of range due to
shared library usage), noticed on s390.

Pushed as obvious.

gdb/testsuite/ChangeLog:

* gdb.trace/pending.exp: Fix expected message on continue.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 23 Jan 2016 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agotestsuite: gdb.gdb/selftest.exp: Drop expected Thread number
Jan Kratochvil [Fri, 22 Jan 2016 20:49:38 +0000 (21:49 +0100)]
testsuite: gdb.gdb/selftest.exp: Drop expected Thread number

Pedro Alves:
Looks like you forgot to amend before pushing though -- the version
checked in still had "Thread 1".

gdb/testsuite/ChangeLog
2016-01-22  Jan Kratochvil  <jan.kratochvil@redhat.com>
    Pedro Alves  <palves@redhat.com>

Fix testsuite compatibility with Guile.
* gdb.gdb/selftest.exp (send ^C to child process): Drop expected Thread
number.

8 years agotestsuite: Fix PR threads/19422 regression + Guile regression
Jan Kratochvil [Fri, 22 Jan 2016 20:21:45 +0000 (21:21 +0100)]
testsuite: Fix PR threads/19422 regression + Guile regression

The PR threads/19422 patchset added a new regression.

Additionally below it there was already a regression if --with-guile (which is
default if Guile is found) was used.

racy case #1:

(xgdb) PASS: gdb.gdb/selftest.exp: Set xgdb_prompt
^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff583bfdd in poll () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.gdb/selftest.exp: send ^C to child process
signal SIGINT^M
Continuing with signal SIGINT.^M
^C^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff5779da0 in sigprocmask () from /lib64/libc.so.6^M
(gdb) PASS: gdb.gdb/selftest.exp: send SIGINT signal to child process
backtrace^M
errstring=errstring@entry=0x7e0e6c "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240^M
errstring=errstring@entry=0x7e0e6c "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240^M
(gdb) PASS: gdb.gdb/selftest.exp: backtrace through signal handler

racy case #2:

(xgdb) PASS: gdb.gdb/selftest.exp: Set xgdb_prompt
^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff583bfdd in poll () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.gdb/selftest.exp: send ^C to child process
signal SIGINT^M
Continuing with signal SIGINT.^M
^C^M
Thread 2 "xgdb" received signal SIGINT, Interrupt.^M
[Switching to Thread 0x7ffff3b7f700 (LWP 13227)]^M
0x00007ffff6b88b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0^M
(gdb) PASS: gdb.gdb/selftest.exp: send SIGINT signal to child process
backtrace^M
(gdb) FAIL: gdb.gdb/selftest.exp: backtrace through signal handler

Pedro Alves:
Not all targets support thread names, and even those that do, not all
use the program name as default thread name -- I think that's only true
for GNU/Linux, actually.  So I think it's best to not expect that, like:
            -re "(Thread .*|Program) received signal SIGINT.*$gdb_prompt $" {

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

Fix testsuite compatibility with Guile.
* gdb.gdb/selftest.exp (send ^C to child process): Accept also Thread.
(thread 1): New test for backtrace through signal handler.

8 years agoReword the string description of native FreeBSD ptids.
John Baldwin [Thu, 21 Jan 2016 17:51:35 +0000 (09:51 -0800)]
Reword the string description of native FreeBSD ptids.

The prior format led to confusing messages when threads were created
or added such as "[New process 14757, LWP 100537]".  The new format
reports this as "[New LWP 100434 of process 15652]".

gdb/ChangeLog:

* fbsd-nat.c (fbsd_pid_to_str): Adjust string format.

8 years agogdb.trace: Fix write_inferior_data_ptr on 32-bit big-endian machines.
Marcin Kościelnicki [Fri, 22 Jan 2016 13:25:02 +0000 (14:25 +0100)]
gdb.trace: Fix write_inferior_data_ptr on 32-bit big-endian machines.

Noticed and tested on 31-bit s390.  This bug caused completely broken
fast tracepoints.

gdb/gdbserver/ChangeLog:

* tracepoint.c (write_inferior_data_ptr): Cast to uintptr_t, so that
it works properly on big-endian machines where sizeof (CORE_ADDR)
!= sizeof (void *).

8 years ago[testsuite] Unbuffer the output in gdb.base/multi-forks.c
Yao Qi [Thu, 21 Jan 2016 17:28:06 +0000 (17:28 +0000)]
[testsuite] Unbuffer the output in gdb.base/multi-forks.c

This patch unbuffer the output of the program so that the test harness
can count the number of "done" from output correctly.

gdb/testsuite:

2016-01-22  Yao Qi  <yao.qi@linaro.org>

PR testsuite/19491
* gdb.base/multi-forks.c: Include
../lib/unbuffer_output.c
(main): Call gdb_unbuffer_output.

8 years ago[ARM] perror_with_name when failed to fetch/store registers
Yao Qi [Fri, 22 Jan 2016 09:01:09 +0000 (09:01 +0000)]
[ARM] perror_with_name when failed to fetch/store registers

I see the following test fail on native arm-linux gdb testing...

(gdb) PASS: gdb.base/killed-outside.exp: registers: get pid of inferior
Executing on target: kill -9 2346    (timeout = 300)
spawn kill -9 2346^M
flushregs^M
Register cache flushed.^M
warning: Unable to fetch general registers.^M
PC not available^M
(gdb) PASS: gdb.base/killed-outside.exp: registers: flushregs
info threads^M
  Id   Target Id         Frame ^M
* 1    process 2346 "killed-outside" (gdb) FAIL: gdb.base/killed-outside.exp: registers: info threads (timeout)

since the inferior disappeared, ptrace will fail.  In that case, the
exception should be thrown, so that the caller can handle that.

gdb:

2016-01-22  Yao Qi  <yao.qi@linaro.org>

* arm-linux-nat.c (fetch_fpregs): Call perror_with_name
instead of warning.
(store_fpregs, fetch_regs, store_regs): Likewise.
(fetch_wmmx_regs, store_wmmx_regs): Likewise.
(fetch_vfp_regs, store_vfp_regs): Likewise.

8 years ago* breakpoint.c (init_breakpoint_sal): Add comment.
Doug Evans [Fri, 22 Jan 2016 01:02:39 +0000 (17:02 -0800)]
* breakpoint.c (init_breakpoint_sal): Add comment.

8 years ago* lib/ada.exp (gdb_compile_ada): Fix typo.
Doug Evans [Fri, 22 Jan 2016 00:20:02 +0000 (16:20 -0800)]
* lib/ada.exp (gdb_compile_ada): Fix typo.

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

8 years agogdb.trace: Fix string collection for 64-bit platforms.
Marcin Kościelnicki [Thu, 21 Jan 2016 15:58:12 +0000 (16:58 +0100)]
gdb.trace: Fix string collection for 64-bit platforms.

String collection always used ref32 to fetch the string pointer.  Make it
use gen_fetch instead.

As a side effect, this patch changes dup+const+trace+pop sequence used
for collecting the string's address to a trace_quick opcode.  This
results in a shorter agent expression.

This appeared to work on x86_64 since it's a little-endian platform, and
malloc (used in gdb.trace/collection.exp) returns addresses in low 4GB.
Noticed and tested on s390x-ibm-linux-gnu, also tested on
i686-unknown-linux-gnu and x86_64-unknown-linux-gnu.

gdb/ChangeLog:

* ax-gdb.c (gen_traced_pop): Use gen_fetch for string collection.

8 years agoFix linker testsuite failures for ARM netbsdelf target.
Nick Clifton [Thu, 21 Jan 2016 15:20:57 +0000 (15:20 +0000)]
Fix linker testsuite failures for ARM netbsdelf target.

PR ld/19453
* testsuite/ld-arm/arm-elf.exp: Skip tests that do not work for
the arm-netbsdelf target.

8 years agoFix gas testsuite failures for ARM netbesdelf configuration.
Nick Clifton [Thu, 21 Jan 2016 14:39:34 +0000 (14:39 +0000)]
Fix gas testsuite failures for ARM netbesdelf configuration.

PR gas/19454
* testsuite/gas/arm/mapshort-elf.d: Fix expected output to cope
with arm-netbsdelf target.
* testsuite/gas/arm/blx-bl-convert.d: Skip for netbsdelf.

8 years agoFix compile time errors building ARC target on a 32-bit host.
Nick Clifton [Thu, 21 Jan 2016 13:54:11 +0000 (13:54 +0000)]
Fix compile time errors building ARC target on a 32-bit host.

* elf32-arc.c (ADD_RELA): Fix compile time warning errors by
changing the type of _loc to be bfd_byte *.
(elf_arc_finish_dynamic_symbol): Likewise.

8 years agogdb: Small cleanup to disasm.c:maybe_add_dis_line_entry
Andrew Burgess [Thu, 21 Jan 2016 11:56:25 +0000 (12:56 +0100)]
gdb: Small cleanup to disasm.c:maybe_add_dis_line_entry

Give the function a better name (drop "maybe_") and update the header
comment.

gdb/ChangeLog:

* disasm.c (maybe_add_dis_line_entry): Rename to...
(add_dis_line_entry): ...this, and update header comment.
(do_mixed_source_and_assembly): Now use add_dis_line_entry.

8 years agogdb: Respect CXXFLAGS when building with C++ compiler
Pedro Alves [Thu, 21 Jan 2016 11:18:45 +0000 (11:18 +0000)]
gdb: Respect CXXFLAGS when building with C++ compiler

Currently, even when built with --enable-build-with-cxx, gdb uses
CFLAGS instead of CXXFLAGS.  This commit fixes it.

CXXFLAGS set in the environment when configure was run is now honored
in the generated gdb/Makefile, and you can also override CXXFLAGS in
the command like at make time, with the usual 'make CXXFLAGS="..."'

Objects built with a C compiler (e.g., gnulib) still honor CFLAGS
instead.

gdb/ChangeLog:
2016-01-21  Pedro Alves  <palves@redhat.com>

* Makefile.in (COMPILER_CFLAGS): New.
(CXXFLAGS): Get it from configure.
(INTERNAL_CFLAGS_BASE, INTERNAL_LDFLAGS): Use COMPILER_CFLAGS
instead of CFLAGS.
* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Set and AC_SUBST
COMPILER_CFLAGS.
* configure: Regenerate.

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

* Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New.
(INTERNAL_CFLAGS_BASE): Use COMPILER_CFLAGS instead of CFLAGS.
* configure: Regenerate.

8 years agoFix unexpected failures in the linker testsuite for ARM VxWorks targets.
Nick Clifton [Thu, 21 Jan 2016 10:51:25 +0000 (10:51 +0000)]
Fix unexpected failures in the linker testsuite for ARM VxWorks targets.

PR ld/19455
* elf32-arm.c (elf32_arm_create_dynamic_sections): Set the ELF
class of the linker stub bfd.
(elf32_arm_check_relocs): Skip check for pic format after
processing a vxWorks R_ARM_ABS12 reloc.
* elflink.c (bfd_elf_final_link): Check for ELFCLASSNONE when
reporting a class mismatch.

* testsuite/ld-arm/vxworks1-lib.dd: Update for current
disassmebler output.
* testsuite/ld-arm/vxworks1-lib.rd: Likewise.
* testsuite/ld-arm/vxworks1.dd: Likewise.
* testsuite/ld-arm/vxworks1.rd: Likewise.
* testsuite/ld-arm/vxworks1.ld: Set the output format.

8 years agoFix regression introduced in "break *<EXPR>" by explicit location patches.
Joel Brobecker [Tue, 8 Dec 2015 18:04:56 +0000 (19:04 +0100)]
Fix regression introduced in "break *<EXPR>" by explicit location patches.

A relatively recent patch support for explicit locations, and part
of that patch cleaned up the way we parse breakpoint locations.
Unfortunatly, a small regression crept in for "*<EXPR>" breakpoint
locations. In particular, on PIE programs, one can see the issue by
doing the following, with any program:

    (gdb) b *main
    Breakpoint 1 at 0x51a: file hello.c, line 3.
    (gdb) run
    Starting program: /[...]/hello
    Error in re-setting breakpoint 1: Warning:
    Cannot insert breakpoint 1.
    Cannot access memory at address 0x51a

    Warning:
    Cannot insert breakpoint 1.
    Cannot access memory at address 0x51a

Just for the record, this regression was introduced by:

    commit a06efdd6effd149a1d392df8d62824e44872003a
    Date:   Tue Aug 11 17:09:35 2015 -0700
    Subject: Explicit locations: introduce address locations

What happens is that the patch makes the implicit assumption that
the address computed the first time is static, as if it was designed
to only support litteral expressions (Eg. "*0x1234"). This allows
the shortcut of not re-computing the breakpoint location's address
when re-setting breakpoints.

However, this does not work in general, as demonstrated in the example
above.

This patch plugs that hole simply by saving the original expression
used to compute the address as part of the address location, so as
to then re-evaluate that expression during breakpoint re-set.

gdb/ChangeLog:

        * location.h (new_address_location): Add new parameters
        "addr_string" and "addr_string_len".
        (get_address_string_location): Add declaration.
        * location.c (new_address_location): Add new parameters
        "addr_string" and "addr_string_len".  If not NULL, store
        a copy of the addr_string in the new location as well.
        (get_address_string_location): New function.
        (string_to_event_location): Update call to new_address_location.
        * linespec.c (event_location_to_sals) <ADDRESS_LOCATION>:
        Save the event location in the parser's state before
        passing it to convert_address_location_to_sals.
        * breakpoint.c (create_thread_event_breakpoint): Update call
        to new_address_location.
        (init_breakpoint_sal): Get the event location's string, if any,
        and use it to update call to new_address_location.
        * python/py-finishbreakpoint.c (bpfinishpy_init):
        Update call to new_address_location.
        * spu-tdep.c (spu_catch_start): Likewise.

        * config/djgpp/fnchange.lst: Add entries for
        gdb/testsuite/gdb.base/break-fun-addr1.c and
        gdb/testsuite/gdb.base/break-fun-addr2.c.

gdb/testsuite/ChangeLog:

        * gdb.base/break-fun-addr.exp: New file.
        * gdb.base/break-fun-addr1.c: New file.
        * gdb.base/break-fun-addr2.c: New file.

8 years ago[AArch64] Relax long branch veneer insertion for non STT_FUNC symbol
Jiong Wang [Wed, 20 Jan 2016 16:57:59 +0000 (16:57 +0000)]
[AArch64] Relax long branch veneer insertion for non STT_FUNC symbol

  As defined at AArch64 ELF Specification (4.6.7 Call and Jump
  relocations), symbol with type of non STT_FUNC but in different input
  section with relocation place should insert long branch veneer also.

  Meanwhile the current long branch veneer infrastructure havn't considered
  the situation where the branch destination is "sym_value + rela->addend".

  This was OK because we only insert veneer for long call destination is
  STT_FUNC symbol for which the addend is always zero. But as we relax the
  support to other situations by this patch, we need to handle addend be
  non-zero value. For example, for static function, relocation against
  "local symbol" are turned into relocation against "section symbol + offset"
  where there is a valid addend.

  bfd/
* elfnn-aarch64.c (aarch64_type_of_stub): Allow insert long branch
veneer for sym_sec != input_sec.
(elfNN_aarch64_size_stub): Support STT_SECTION symbol.
(elfNN_aarch64_final_link_relocate): Take rela addend into account when
calculation destination.

  ld/
* testsuite/ld-aarch64/farcall-section.d: Delete.
* testsuite/ld-aarch64/farcall-section.s: Delete.
* testsuite/ld-aarch64/farcall-b-section.d: New expectation file.
* testsuite/ld-aarch64/farcall-bl-section.d: Likewise.
* testsuite/ld-aarch64/farcall-b-section.s: New testcase.
* testsuite/ld-aarch64/farcall-bl-section.s: Likewise.
* testsuite/ld-aarch64/aarch64-elf.exp: Likewise.

8 years agoConvert macros in elf-linux-core.h to inline functions
Alan Modra [Thu, 21 Jan 2016 03:03:53 +0000 (13:33 +1030)]
Convert macros in elf-linux-core.h to inline functions

Besides changing some macros into inline functions, this removes
redundant memsets and uses bfd_put_* rather than H_PUT_*.

* elf-linux-core.h (swap_linux_prpsinfo32_out): New function.
(swap_linux_prpsinfo64_out): New function.
(LINUX_PRPSINFO32_SWAP_FIELDS): Delete.
(LINUX_PRPSINFO64_SWAP_FIELDS): Delete.
* elf.c (elfcore_write_linux_prpsinfo32): Adjust.  Don't memset.
(elfcore_write_linux_prpsinfo64): Likewise.
* elf32-ppc.c (swap_ppc_linux_prpsinfo32_out): New function.
(PPC_LINUX_PRPSINFO32_SWAP_FIELDS): Delete.
(elfcore_write_ppc_linux_prpsinfo32): Adjust.  Don't memset.

8 years agoRename elf-linux-psinfo.h to elf-linux-core.h
Alan Modra [Thu, 21 Jan 2016 02:45:02 +0000 (13:15 +1030)]
Rename elf-linux-psinfo.h to elf-linux-core.h

Since it will sometime have more than just prpsinfo.  Also,
elf32-ppc.c needlessly includes this header.

* elf-linux-core.h: Rename from elf-linux-psinfo.h.
* elf.c: Adjust #include.
* elf32-ppc.c: Don't #include elf-linux-psinfo.h
* Makefile.am (SOURCE_HFILES): Update.
* Makefile.in: Regenerate.
* po/SRC-PORFILES.in: Regenerate.

8 years agobfd/configure reorganisation
Alan Modra [Tue, 19 Jan 2016 01:54:09 +0000 (12:24 +1030)]
bfd/configure reorganisation

Corefile code should be moved after running config.bfd, because it
uses want64.

* configure.ac: Move corefile selection later in file.  Move
tdefaults code immediately after other target vector code.
* configure: Regenerate.

8 years agoDetect the arm/thumb mode of code SIGRETURN or RT_SIGRETURN returns to
Yao Qi [Thu, 21 Jan 2016 07:48:50 +0000 (07:48 +0000)]
Detect the arm/thumb mode of code SIGRETURN or RT_SIGRETURN returns to

This patch fixes the following regression introduced by commit d0e59a68

step^M
39      } /* handler */^M
1: x/i $pc^M
=> 0x8740 <handler+80>: sub     sp, r11, #0^M
(gdb) step^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
setitimer () at ../sysdeps/unix/syscall-template.S:81^M
81      ../sysdeps/unix/syscall-template.S: No such file or directory.^M
1: x/i $pc^M
=> 0xb6eff9c0 <setitimer>:      push    {r7}^M
(gdb) FAIL: gdb.base/sigstep.exp: continue to handler, si+advance in handler, step from handler: leave handler

in my test setting, program is compiled in arm mode, but the glibc
is built in thumb mode, so when we do 'step' to step over syscall
instruction svc for SIGRETURN, GDB should set breakpoint for arm mode
in the program, even though the current program in glibc is in thumb
mode.  Current GDB doesn't consider the case that the mode of program
SIGRETURN goes to can be different from current program mode.

In fact, GDB has taken care of this arm/thumb mode changes already,
see

/* Copy the value of next pc of sigreturn and rt_sigrturn into PC,
   return 1.  In addition, set IS_THUMB depending on whether we
   will return to ARM or Thumb code.  Return 0 if it is not a
   rt_sigreturn/sigreturn syscall.  */
static int
arm_linux_sigreturn_return_addr (struct frame_info *frame,
 unsigned long svc_number,
 CORE_ADDR *pc, int *is_thumb)

but in the commit d0e59a68

> -  arm_linux_sigreturn_return_addr (frame, svc_number, &return_addr, &is_thumb);
> +  if (svc_number == ARM_SIGRETURN || svc_number == ARM_RT_SIGRETURN)
> +    next_pc = arm_linux_sigreturn_next_pc (regcache, svc_number);

the IS_THUMB setting is lost, so it is a regression.

gdb:

2016-01-21  Yao Qi  <yao.qi@linaro.org>

* arm-linux-tdep.c (arm_linux_sigreturn_next_pc): Add parameter
is_thumb and set it according to CPSR saved on the stack.
(arm_linux_get_next_pcs_syscall_next_pc): Pass is_thumb to
arm_linux_sigreturn_next_pc.

gdb/gdbserver:

2016-01-21  Yao Qi  <yao.qi@linaro.org>

* linux-arm-low.c (arm_sigreturn_next_pc): Add parameter
is_thumb and set it according to CPSR saved on the stack.
(get_next_pcs_syscall_next_pc): Pass is_thumb to
arm_sigreturn_next_pc.

8 years agoAutomatic date update in version.in
GDB Administrator [Thu, 21 Jan 2016 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix sorting of enum values in FlagEnumerationPrinter
Simon Marchi [Wed, 20 Jan 2016 18:42:53 +0000 (13:42 -0500)]
Fix sorting of enum values in FlagEnumerationPrinter

The lambda function used to sort the enumerator list does not work
properly.  This list consists of tuples, (enum label, enum value).  The
key function returns x.enumval.  enumval not being defined for a tuple,
we see this exception in the test log:

  Python Exception <class 'AttributeError'> 'tuple' object has no attribute 'enumval'

The function should return the second item of the tuple, which is the
enumval.

The pretty-printer still worked mostly correctly, except that the
enumeration values were not sorted.  The test still passed because the
enumeration values are already sorted where they are defined.  The test
also passed despite the exception being printed, because the right output
was printed after the exception:

  print (enum flag_enum) (FLAG_1)
  Python Exception <type 'exceptions.AttributeError'> 'tuple' objecthas no attribute 'enumval':M
  $7 = 0x1 [FLAG_1]
  (gdb) PASS: gdb.python/py-pp-maint.exp: print FLAG_1

New in v2:

- Improved test case, I stole Pedro's example directly.  It verifies
  that the sorting of enumerators by value works, by checking that
  printing FOO_MASK appears as FOO_1 | FOO_2 | FOO_3.

  I noticed that I could change the regexps to almost anything and the
  tests would still pass.  I think it was because of the | in there.  I
  made them more robust by using string_to_regexp.  I used curly braces
  { } instead of quoting marks " " for strings, so that I could use
  square brackets [ ] in them without having to escape them all.  I also
  removed the "message" part of the tests, since they are redundant with
  the command, and it's just more maintenance to have to update them.

  Tested with Python 2.7 and 3.5.

gdb/ChangeLog:

* python/lib/gdb/printing.py (FlagEnumerationPrinter.__call__):
Fix enumerators sort key function.

gdb/testsuite/ChangeLog:

* gdb.python/py-pp-maint.exp: Change/add enum flag tests.
* gdb.python/py-pp-maint.c (enum flag_enum): Use more complex
enum flag values.

8 years agognu_vector.exp: Respect `should_kfail' for PR 8549
Andreas Arnez [Wed, 20 Jan 2016 18:41:45 +0000 (19:41 +0100)]
gnu_vector.exp: Respect `should_kfail' for PR 8549

The gnu_vector test case yields a new FAIL on s390x:

  FAIL: gdb.base/gnu_vector.exp: verify vector return value

It was introduced by commit 77ae9c1933b50 "gdb.base/gnu_vector.exp:
Don't test output from the inferior".  That commit dropped the special
handling for GDB's inability (on some targets) to set the return value.

This change re-establishes the logic from before, converting the above
FAIL to a KFAIL (PRMS gdb/8549).

gdb/testsuite/ChangeLog:

* gdb.base/gnu_vector.exp: Re-establish handling for should_kfail
when GDB can not set the vector return value.  Add more comments
for clarification.

8 years agoFix missing IPA lib in tspeed.exp in some configurations.
Antoine Tremblay [Wed, 20 Jan 2016 17:30:53 +0000 (12:30 -0500)]
Fix missing IPA lib in tspeed.exp in some configurations.

On Ubuntu 14.04 the following failure would be seen when running the
tspeed.exp test on a target that supports fast tracepoints like x86_64:

Target returns error code '.In-process agent library not loaded in
process.  Fast and static tracepoints unavailable.'.
(gdb) FAIL: gdb.trace/tspeed.exp: start trace experiment

This is because the default is to link with --as-needed and the
gdb_compile for the test is using the libs argument instead of shlib which
corrects this issue since 6ebea266fd0a7a56c90db3ab6237ff9f6c919747 by
adding -Wl,--no-as-needed.

This patch fixes the issue by passing the lib as the shlib argument to
gdb_compile.

Tested on Ubuntu 14.04 x86_64.

gdb/testsuite/ChangeLog:

* gdb.trace/tspeed.exp:  Use shlib instead of libs in gdb_compile
command.

8 years agoFix unexpected failures in GAS testsuite for ARM VxWorks target.
Nick Clifton [Wed, 20 Jan 2016 17:02:42 +0000 (17:02 +0000)]
Fix unexpected failures in GAS testsuite for ARM VxWorks target.

PR 19456
* testsuite/gas/arm/weakdef-1.d: Skip for VxWorks.
* testsuite/gas/arm/blx-bl-convert.d
* testsuite/gas/arm/plt-1.d: Likewise.
* testsuite/gas/arm/reloc-bad.d: Likewise.
* testsuite/gas/arm/thumb-w-good.d: Likewise.
* testsuite/gas/arm/thumb2_pool.d: Likewise.
* testsuite/gas/arm/ldconst.d: Adjust so that it works with VxWorks
* testsuite/gas/arm/tls_vxworks.d: Update expected output.

8 years agoUpda the documentation on assembler error message generation.
Nick Clifton [Wed, 20 Jan 2016 16:21:34 +0000 (16:21 +0000)]
Upda the documentation on assembler error message generation.

PR 19499
* doc/as.texinfo (Errors): Correct documentation describing the
interaction of .file and .line with warning and error messages.

8 years agoFix linker testsuite failures for arm-pe targets.
Nick Clifton [Wed, 20 Jan 2016 15:41:06 +0000 (15:41 +0000)]
Fix linker testsuite failures for arm-pe targets.

PR 19457
* testsuite/ld-scripts/script.exp (extract_symbol_test): Stop test
early for PE based targets.
* testsuite/ld-scripts/align.t: Use 0x1000 as VMA alignment.
* testsuite/ld-pe/tlssec32.d: Allow for relocatable output.

8 years agoSkip ARM v8 tests for COFF based targets.
Nick Clifton [Wed, 20 Jan 2016 15:00:57 +0000 (15:00 +0000)]
Skip ARM v8 tests for COFF based targets.

8 years agoFix dlltool tests for ARM targets, which do not support the --leading-underscore...
Nick Clifton [Wed, 20 Jan 2016 14:52:33 +0000 (14:52 +0000)]
Fix dlltool tests for ARM targets, which do not support the --leading-underscore option.

PR 19495
* testsuite/binutils-all/dlltool.exp: Fix tests for targets which
do not support inserting leading underscores.

8 years ago[AArch64] Reject invalid immediate operands to MSR UAO
Matthew Wahab [Wed, 20 Jan 2016 14:25:46 +0000 (14:25 +0000)]
[AArch64] Reject invalid immediate operands to MSR UAO

In the instruction to write to the ARMv8.2 PSTATE field UAO,
MSR UAO, #<imm>, the immediate should be either 0 or 1 but GAS accepts
any unsigned 4-bit integer.

This patch implements the constraint on the immediate, generating an
error if the immediate operand is invalid, and adds tests for the
illegal forms.

opcodes/
2016-01-20  Matthew Wahab  <matthew.wahab@arm.com>

* aarch64-opc.c (operand_general_constraint_met_p): Check validity
of MSR UAO immediate operand.

gas/
2016-01-20  Matthew Wahab  <matthew.wahab@arm.com>

* testsuite/gas/aarch64/armv8_2-a-illegal.d: New.
* testsuite/gas/aarch64/armv8_2-a-illegal.l: New.
* testsuite/gas/aarch64/armv8_2-a-illegal.s: New.

Change-Id: Ibdec4967c00b1ef3be9dbc43d23b2c70d1a0b28c

8 years agoFix gdb/ChangeLog typo
Pedro Alves [Wed, 20 Jan 2016 13:10:41 +0000 (13:10 +0000)]
Fix gdb/ChangeLog typo

8 years agoMove ChangeLog entry to proper place (gdb/testsuite/ -> gdb/)
Pedro Alves [Wed, 20 Jan 2016 13:03:40 +0000 (13:03 +0000)]
Move ChangeLog entry to proper place (gdb/testsuite/ -> gdb/)

8 years agoAdd support for an ARM specific 'y' section attribute flag to mark the section as...
Mickael Guene [Wed, 20 Jan 2016 12:53:50 +0000 (12:53 +0000)]
Add support for an ARM specific 'y' section attribute flag to mark the section as NOREAD.

bfd/ChangeLog:
      * elf32-arm.c ((elf32_arm_special_sections): Remove catch of noread
      section using '.text.noread' pattern.

gas/ChangeLog:
      * config/obj-elf.c (obj_elf_change_section) : Allow arm section with
      SHF_ARM_NOREAD section flag.
      * config/tc-arm.h (md_elf_section_letter) : Implement this hook to
      handle letter 'y'.
     (arm_elf_section_letter) : Declare it.
      * config/tc-arm.c (arm_elf_section_letter): Handle letter 'y' to set
      SHF_ARM_NOREAD section flag.
      * doc/c-arm.texi (ARM section attribute 'y'): Document it.

gas/testsuite/ChangeLog:
      * gas/arm/section-execute-only.s: New test case.
      * gas/arm/section-execute-only.d: Expected output.

ld/testsuite/ChangeLog:
      * ld-arm/thumb1-noread-not-present-mixing-two-section.s: Add 'y'
      attribute usage.
      * ld-arm/thumb1-noread-present-one-section.s: Likewise.
      * ld-arm/thumb1-noread-present-two-section.s: Likewise.
      * ld-arm/thumb1-input-section-flag-match.s: Likewise.

binutils/ChangeLog:
      * readelf.c (get_elf_section_flags): Display y letter for section
      with SHF_ARM_NOREAD section flag in readelf section output.
      (process_section_headers): Add y letter in readelf section output
      key mapping for ARM architecture.

8 years agominor reformatting in printcmd.c::print_scalar_formatted
Joel Brobecker [Wed, 20 Jan 2016 04:01:39 +0000 (08:01 +0400)]
minor reformatting in printcmd.c::print_scalar_formatted

(GNU Coding Standard...)

gdb/ChangeLog:

        * printcmd.c (print_scalar_formatted): move binary operator from
        end of line to beginning of next line.  Adjust formatting
        accordingly.

8 years agoAutomatic date update in version.in
GDB Administrator [Wed, 20 Jan 2016 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoUse a separate variable for the size passed to sysctl.
John Baldwin [Tue, 19 Jan 2016 18:23:00 +0000 (10:23 -0800)]
Use a separate variable for the size passed to sysctl.

This fixes a sign mismatch warning.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_pid_to_exec_file): Use new "buflen" instead of
"len" with sysctl.

8 years agoRemove an unused variable.
John Baldwin [Tue, 19 Jan 2016 17:06:33 +0000 (09:06 -0800)]
Remove an unused variable.

binutils/ChangeLog:

* readelf.c (get_freebsd_elfcore_note_type): Remove unused variable.

8 years agoDump register notes for each thread when generating a FreeBSD core.
John Baldwin [Tue, 22 Dec 2015 00:34:15 +0000 (16:34 -0800)]
Dump register notes for each thread when generating a FreeBSD core.

gdb/ChangeLog:

* fbsd-tdep.c (find_stop_signal): Remove.
(struct fbsd_collect_regset_section_cb) <lwp>: New field.
<stop_signal>: New field.
<abort_iteration>: New field.
(fbsd_collect_regset_section_cb): Use new fields.
(fbsd_collect_thread_registers): New function.
(struct fbsd_corefile_thread_data): New structure.
(fbsd_corefile_thread): New function.
(fbsd_make_corefile_notes): Use new function to dump notes for each
non-exited thread in a process.

8 years agoAdd support for LWP-based threads on FreeBSD.
John Baldwin [Wed, 29 Apr 2015 15:53:43 +0000 (11:53 -0400)]
Add support for LWP-based threads on FreeBSD.

Older versions of FreeBSD supported userland threading via a pure
user-space threading library (N threads scheduled on 1 process) and
a N:M model (N threads scheduled on M LWPs).  However, modern FreeBSD
versions only support a M:M threading model where each user thread is
backed by a dedicated LWP.  This thread target only supports this
threading model.  It also uses ptrace to query and alter LWP state
directly rather than using libthread_db to simplify the implementation.

FreeBSD recently gained support for reporting LWP events (birth and death
of LWPs).  GDB will use LWP events when present.  For older systems it
fetches the list of LWPs in the to_update_thread_list target op to update
the list of threads on each stop.

This target supports scheduler locking by using ptrace to suspend
individual LWPs as necessary before resuming a process.

gdb/ChangeLog:

* configure.ac: Check for support for LWP names on FreeBSD.
* fbsd-nat.c [PT_LWPINFO] New variable debug_fbsd_lwp.
[TDP_RFPPWAIT || HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]
(fbsd_fetch_kinfo_proc): Move function earlier.
[PT_LWPINFO] (fbsd_thread_alive): New function.
[PT_LWPINFO] (fbsd_pid_to_str): New function.
[HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME] (fbsd_thread_name): New function.
[PT_LWP_EVENTS] (fbsd_enable_lwp_events): New function.
[PT_LWPINFO] (fbsd_add_threads): New function.
[PT_LWPINFO] (fbsd_update_thread_list): New function.
[PT_LWPINFO] New variable super_resume.
[PT_LWPINFO] (resume_one_thread_cb): New function.
[PT_LWPINFO] (resume_all_threads_cb): New function.
[PT_LWPINFO] (fbsd_resume): New function.
(fbsd_remember_child): Save full ptid instead of plain pid.
(fbsd_is_child_pending): Return ptid of saved child process.
(fbsd_wait): Include lwp in returned ptid and switch to LWP ptid on
first stop.
[PT_LWP_EVENTS] Handle LWP events.
[TDP_RFPPWAIT] Include LWP in child ptid.
(fbsd_post_startup_inferior) [PT_LWP_EVENTS]: Enable LWP events.
(fbsd_post_attach) [PT_LWP_EVENTS]: Enable LWP events.
Add threads for existing processes.
(fbsd_nat_add_target) [PT_LWPINFO]: Set "to_thread_alive" to
"fbsd_thread_alive".
Set "to_pid_to_str" to "fbsd_pid_to_str".
[HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME]: Set "to_thread_name" to
"fbsd_thread_name".
[PT_LWPINFO]: Set "to_update_thread_list" to "fbsd_update_thread_list".
Set "to_has_thread_control" to "tc_schedlock".
Set "to_resume" to "fbsd_resume".
(_initialize_fbsd_nat): New function.
* configure: Regenerate.
* config.in: Regenerate.

gdb/doc/ChangeLog:

* gdb.texinfo (Debugging Output): Document "set/show debug fbsd-lwp".

8 years agoUse LWP IDs with ptrace register requests on FreeBSD.
John Baldwin [Fri, 15 Jan 2016 20:21:07 +0000 (12:21 -0800)]
Use LWP IDs with ptrace register requests on FreeBSD.

This allows gdb to fetch per-thread registers for multi-threaded FreeBSD
processes.

Export get_ptrace_pid() from inf-ptrace.c and use it to determine the PID
to pass to ptrace in pan-BSD native targets.  NetBSD and OpenBSD also accept
LWP IDs for ptrace requests to fetch per-thread state.

gdb/ChangeLog:

* amd64bsd-nat.c (amd64bsd_fetch_inferior_registers): Use
get_ptrace_pid.
(amd64bsd_store_inferior_registers): Use get_ptrace_pid.
(amd64bsd_dr_get): Use get_ptrace_pid.
(amd64bsd_dr_set): Use get_ptrace_pid.
* i386bsd-nat.c (i386bsd_fetch_inferior_registers): Use get_ptrace_pid.
(i386bsd_store_inferior_registers): Use get_ptrace_pid.
(i386bsd_dr_get): Use get_ptrace_pid.
(i386bsd_dr_set): Use get_ptrace_pid.
* inf-ptrace.c (get_ptrace_pid): Export.
* inf-ptrace.h (get_ptrace_pid): Declare.
* ppcfbsd-nat.c (ppcfbsd_fetch_inferior_registers): Use lwp id.
(ppcfbsd_store_inferior_registers): Use lwp id.

8 years agoDisplay per-thread information for threads in FreeBSD cores.
John Baldwin [Mon, 14 Dec 2015 05:49:52 +0000 (21:49 -0800)]
Display per-thread information for threads in FreeBSD cores.

Display the LWP ID of each thread in a FreeBSD core.  Extract thread
names from the per-thread THRMISC note.

gdb/ChangeLog:

* fbsd_tdep.c (fbsd_core_pid_to_str): New function.
(fbsd_core_thread_name): New function.
(fbsd_init_abi): Add "core_pid_to_str" gdbarch method.
Add "core_thread_name" gdbarch method.

8 years agoAdd support for extracting thread names from cores.
John Baldwin [Mon, 18 Jan 2016 17:49:23 +0000 (09:49 -0800)]
Add support for extracting thread names from cores.

Add a new gdbarch method to extract a thread name from a core for a
given thread.  Use this new method in core_thread_name to implement the
to_thread_name target op.

gdb/ChangeLog:

* corelow.c (core_thread_name): New function.
(init_core_ops): Use "core_thread_name" for the "to_thread_name"
target op.
* gdbarch.sh (core_thread_name): New gdbarch callback.
* gdbarch.h: Re-generate.
* gdbarch.c: Re-generate.

8 years agoAdd a pseudosection for the NT_FREEBSD_THRMISC note.
John Baldwin [Mon, 14 Dec 2015 06:47:25 +0000 (22:47 -0800)]
Add a pseudosection for the NT_FREEBSD_THRMISC note.

bfd/ChangeLog:

* elf.c (elfcore_grok_note): Recognize NT_FREEBSD_THRMISC notes.

8 years agoAdd support to readelf for reading FreeBSD ELF core notes.
John Baldwin [Mon, 14 Dec 2015 06:26:19 +0000 (22:26 -0800)]
Add support to readelf for reading FreeBSD ELF core notes.

binutils/ChangeLog:

* readelf.c (get_freebsd_elfcore_note_type): New
(process_note): Add support for FreeBSD core notes.

include/ChangeLog:

* elf/common.h (NT_FREEBSD_THRMISC): Define.
(NT_FREEBSD_PROCSTAT_PROC): Define.
(NT_FREEBSD_PROCSTAT_FILES): Define.
(NT_FREEBSD_PROCSTAT_VMMAP): Define.
(NT_FREEBSD_PROCSTAT_GROUPS): Define.
(NT_FREEBSD_PROCSTAT_UMASK): Define.
(NT_FREEBSD_PROCSTAT_RLIMIT): Define.
(NT_FREEBSD_PROCSTAT_OSREL): Define.
(NT_FREEBSD_PROCSTAT_PSSTRINGS): Define.
(NT_FREEBSD_PROCSTAT_AUXV): Define.

8 years agoFix enum flag with Python 3
Simon Marchi [Tue, 19 Jan 2016 16:07:07 +0000 (11:07 -0500)]
Fix enum flag with Python 3

Using Python 3.5 (I assume it's the same with 3.4 and lower, but I didn't
test), I see this:

  print (enum flag_enum) (FLAG_1)^M
  Python Exception <class 'TypeError'> %x format: an integer is required, not gdb.Value: ^M
  $7 = ^M
  (gdb) FAIL: gdb.python/py-pp-maint.exp: print FLAG_1

Apparently, this idiom, where v is a gdb.Value, was possible with Python 2,
but not with Python 3:

  '%x' % v

In Python 2, it would automatically get converted to an integer.  To solve
it, I simply added wrapped v in a call to int().

  '%x' % int(v)

In Python 2, the int type is implemented with a "long" in C, so on x86-32 it's
32-bits.  I was worried that doing int(v) would truncate the value and give
wrong results for enum values > 32-bits.  However, the int type != the int
function.  The int function does the right thing, selecting the right integer
type for the given value.  I tested with large enum values on x86-32 and
Python 2, and everything works as expected.

gdb/ChangeLog:

* python/lib/gdb/printing.py (_EnumInstance.to_string): Explicitly
convert gdb.Value to integer type using int().

8 years agotestsuite: Factor out --status in DO_RUNTEST
Simon Marchi [Tue, 19 Jan 2016 16:06:11 +0000 (11:06 -0500)]
testsuite: Factor out --status in DO_RUNTEST

gdb/testsuite/ChangeLog:

* Makefile.in (DO_RUNTEST): Add --status and update usages.

8 years agoAdd missing ChangeLog entries for the last 2 commits
Simon Marchi [Tue, 19 Jan 2016 15:48:03 +0000 (10:48 -0500)]
Add missing ChangeLog entries for the last 2 commits

I did a wrong manipulation and pushed the last 2 commits without
amending them with the ChangeLog entries.

8 years agotestsuite: Add --status to runtest invocation
Simon Marchi [Mon, 18 Jan 2016 18:54:04 +0000 (13:54 -0500)]
testsuite: Add --status to runtest invocation

By default, if a test driver (a test .exp) ends with an uncaught
error/exception, the runtest command will still have a return code of 0
(success).  However, if a test (or the environment) is broken and does
not work properly, it should be considered as failed so that we can
notice it and fix it.

Passing the --status flag to runtest will make it return an error if one
of the test it runs ends up with an uncaught error.

gdb/testsuite/ChangeLog:

* Makefile.in (check-single): Pass --status to runtest.
(check/%.exp): Likewise.

8 years agotestsuite: Make check-parallel return non-zero if a test failed
Simon Marchi [Mon, 18 Jan 2016 19:07:10 +0000 (14:07 -0500)]
testsuite: Make check-parallel return non-zero if a test failed

When using the check-parallel target, the return code of make is always 0,
regardless of test results.  This patch makes it return the same code as
the "make do-check-parallel" sub-command.  So if there is a FAIL somewhere,
non-zero will be returned by make.

For the sake of example, I introduced a failure in gdb.base/break.exp.

  $ make check-single TESTS="gdb.base/break.exp gdb.python/py-value.exp" && echo 'Success :D' || echo 'Fail :('
  ...
  FAIL: gdb.base/break.exp: allo
  ...
  Fail :(

I think the parallel run should do the same.  Currently:

  $ make check-parallel TESTS="gdb.base/break.exp gdb.python/py-value.exp" && echo 'Success :D' || echo 'Fail :('
  ...
  FAIL: gdb.base/break.exp: allo
  ...
  Success :D

And with the patch (no big surprises there):

  $ make check-parallel TESTS="gdb.base/break.exp gdb.python/py-value.exp" && echo 'Success :D' || echo 'Fail :('
  ...
  FAIL: gdb.base/break.exp: allo
  ...
  Fail :(

What do you think?

gdb/testsuite/ChangeLog:

* Makefile.in (check-parallel): Propagate return code from make
do-check-parallel.

8 years agoFix detection of "r_fs" and "r_gs" on FreeBSD.
John Baldwin [Mon, 18 Jan 2016 19:59:45 +0000 (11:59 -0800)]
Fix detection of "r_fs" and "r_gs" on FreeBSD.

Include <sys/types.h> as a prerequisite for <machine/reg.h> when checking
for the r_fs and r_gs members in struct reg.  Note that the previous test
for <machine/reg.h> already includes <sys/types.h> as a prerequisite.

gdb/ChangeLog:

* configure.ac: Include <sys/types.h when checking for "r_fs" in
"struct reg".
* configure: Regenerate.

8 years agoAdd PIC and TLS support to the ARC target.
Miranda Cupertino [Tue, 19 Jan 2016 15:25:58 +0000 (15:25 +0000)]
Add PIC and TLS support to the ARC target.

bfd/ChangeLog:
* arc-plt.def: New file.
* arc-plt.h: Likewise.
* elf32-arc.c (elf_arc_abs_plt0_entry, elf_arc_abs_pltn_entry,
       elf_arcV2_abs_plt0_entry, elf_arcV2_abs_pltn_entry,
       elf_arc_pic_plt0_entry, elf_arc_pic_pltn_entry,
       elf_arcV2_pic_plt0_entry, elf_arcV2_pic_pltn_entry): Remove.
(name_for_global_symbol): Added.
(ADD_RELA): Helper to create dynamic relocs.
(new_got_entry_to_list): Create a new got entry in linked list.
(symbol_has_entry_of_type): Search for specific type of entry in
list.
(is_reloc_for_GOT): return FALSE for any TLS related relocs.
(is_reloc_for_TLS, arc_elf_set_private_flags)
(arc_elf_print_private_bfd_data, arc_elf_copy_private_bfd_data)
(arc_elf_merge_private_bfd_data): New functions.
(debug_arc_reloc): Cleaned debug info printing.
(PDATA reloc): Changed not to perform address alignment.
(reverse_me): Added. Fix for ARC_32 relocs.
(arc_do_relocation): Return bfd_reloc_of when no relocation should
occur.
(arc_get_local_got_ents): Renamed from arc_get_local_got_offsets.
Changed function to access an array of list of GOT entries instead
of just an array of offsets.
(elf_arc_relocate_section): Added support for PIC and TLS related relocations.
(elf_arc_check_relocs): Likewise.
(elf_arc_adjust_dynamic_symbol, elf_arc_finish_dynamic_symbol,
(elf_arc_finish_dynamic_sections): Likewise
(arc_create_dynamic_sections): Modified conditions to create
dynamic sections.
(ADD_SYMBOL_REF_SEC_AND_RELOC): New macro.
(plt_do_relocs_for_symbol, relocate_plt_for_symbol)
(relocate_plt_for_entry): Changed to support new way to define PLT
related code.
(add_symbol_to_plt): Likewise.
(arc_elf_link_hash_table_create): New function.

include/ChangeLog:
* elf/arc-reloc.def (ARC_32, ARC_GOTPC, ARC_TLS_GD_GOT)
(ARC_TLS_IE_GOT, ARC_TLS_DTPOFF, ARC_TLS_DTPOFF_S9, ARC_TLS_LE_S9)
(ARC_TLS_LE_32): Fixed formula.
(ARC_TLS_GD_LD): Use new special function.
* opcode/arc-func.h: Changed all the replacement
functions to clear the patching bits before doing an or it with the value
argument.

8 years agoLimit breakpoint re-set to the current program space
Pedro Alves [Tue, 19 Jan 2016 12:18:14 +0000 (12:18 +0000)]
Limit breakpoint re-set to the current program space

Currently, we always re-set all locations of all breakpoints.  This
commit makes us re-set only locations of the current program space.

If we loaded symbols to a program space (e.g., "file" command or some
shared library was loaded), GDB must run through all breakpoints and
determine if any new locations need to be added to the breakpoint.
However, there's no reason to recreate locations for _other_ program
spaces, as those haven't changed.

Similarly, when we create a new inferior, through e.g., a fork, GDB
must run through all breakpoints and determine if any new locations
need to be added to the breakpoint.  There's no reason to destroy the
locations of the parent inferior and other inferiors.  We know those
won't change.

In addition to being inneficient, resetting breakpoints of inferiors
that are currently running is problematic, because:

 - some targets can't read memory while the inferior is running.

 - the inferior might exit while we're re-setting its breakpoints,
   which may confuse prologue skipping.

I went through all the places where we call breakpoint_re_set, and it
seems to me that all can be changed to only re-set locations of the
current program space.

The patch that reversed threads order in "info threads" etc. happened
to make gdb.threads/fork-plus-thread.exp expose this problem when
testing on x86/-m32.  The problem was latent and masked out by chance
by the code-cache:

 https://sourceware.org/ml/gdb-patches/2016-01/msg00213.html

Tested on x86-64 F20, native (-m64/-m32) and extended-remote
gdbserver.

Fixes the regression discussed in the url above with --target_board=unix/-m32:

 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited
 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left (timeout)
 -FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left (the program exited)
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: no threads left
 +PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: only inferior 1 left

gdb/ChangeLog:
2016-01-19  Pedro Alves  <palves@redhat.com>

* ax-gdb.c (agent_command_1): Adjust call to decode_line_full.
* break-catch-throw.c (re_set_exception_catchpoint): Pass the
current program space down to linespec decoding and breakpoint
location updating.
* breakpoint.c (parse_breakpoint_sals): Adjust calls to
decode_line_full.
(until_break_command): Adjust calls to decode_line_1.
(base_breakpoint_decode_location, bkpt_decode_location): Add
'search_pspace' parameter.  Pass it along.
(bkpt_probe_create_sals_from_location): Adjust calls to
parse_probes.
(tracepoint_decode_location, tracepoint_probe_decode_location)
(strace_marker_decode_location): Add 'search_pspace' parameter.
Pass it along.
(all_locations_are_pending): Rewrite to take a breakpoint and
program space as arguments instead.
(hoist_existing_locations): New function.
(update_breakpoint_locations): Add 'filter_pspace' parameter.  Use
hoist_existing_locations instead of always removing all locations,
and adjust to all_locations_are_pending change.
(location_to_sals): Add 'search_pspace' parameter.  Pass it along.
Don't disable the breakpoint if there are other locations in
another program space.
(breakpoint_re_set_default): Adjust to pass down the current
program space as filter program space.
(decode_location_default): Add 'search_pspace' parameter and pass
it along.
(prepare_re_set_context): Don't switch program space here.
(breakpoint_re_set): Use save_current_space_and_thread instead of
save_current_program_space.
* breakpoint.h (struct breakpoint_ops) <decode_location>: Add
'search_pspace' parameter.
(update_breakpoint_locations): Add 'filter_pspace' parameter.
* cli/cli-cmds.c (edit_command, list_command): Adjust calls to
decode_line_1.
* elfread.c (elf_gnu_ifunc_resolver_return_stop): Pass the current
program space as filter program space.
* linespec.c (struct linespec_state) <search_pspace>: New field.
(create_sals_line_offset, convert_explicit_location_to_sals)
(parse_linespec): Pass the search program space down.
(linespec_state_constructor): Add 'search_pspace' parameter.
Store it.
(linespec_parser_new): Add 'search_pspace' parameter and pass it
along.
(linespec_lex_to_end): Adjust.
(decode_line_full, decode_line_1): Add 'search_pspace' parameter
and pass it along.
(decode_line_with_last_displayed): Adjust.
(collect_symtabs_from_filename, symtabs_from_filename): New
'search_pspace' parameter.  Use it.
(find_function_symbols): Pass the search program space down.
* linespec.h (decode_line_1, decode_line_full): Add
'search_pspace' parameter.
* probe.c (parse_probes_in_pspace): New function, factored out
from ...
(parse_probes): ... this.  Add 'search_pspace' parameter and use
it.
* probe.h (parse_probes): Add pspace' parameter.
* python/python.c (gdbpy_decode_line): Adjust.
* tracepoint.c (scope_info): Adjust.

8 years agotestsuite/gdb.trace: Fix expected message on continue.
Marcin Kościelnicki [Tue, 19 Jan 2016 11:30:34 +0000 (12:30 +0100)]
testsuite/gdb.trace: Fix expected message on continue.

This is fallout from f303dbd60d9c7984832446eeb9d4e4d89703c615.

The testcases themselves are single-threaded, but they load the IPA library,
which injects a thread in the inferior - making them multithreaded.
This results in printing the thread numbers in breakpoint messages.

gdb/testsuite/ChangeLog:

* gdb.trace/ftrace.exp: Fix expected message on continue.
* gdb.trace/pending.exp: Fix expected message on continue.
* gdb.trace/trace-break.exp: Fix expected message on continue.

8 years agoFix PR18735 test for RL78.
Nick Clifton [Tue, 19 Jan 2016 09:57:03 +0000 (09:57 +0000)]
Fix PR18735 test for RL78.

* testsuite/ld-elf/pr18735.d: Allow for extra symbols between
foo@FOO and bar@@FOO.

8 years agoAutomatic date update in version.in
GDB Administrator [Tue, 19 Jan 2016 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoMIPS: Remove remnants of 48-bit microMIPS instruction support
Maciej W. Rozycki [Mon, 18 Jan 2016 21:29:37 +0000 (21:29 +0000)]
MIPS: Remove remnants of 48-bit microMIPS instruction support

The POOL48A major opcode was defined in early revisions of the 64-bit
microMIPS ISA, has never been implemented, and was removed before the
64-bit microMIPS ISA specification[1] has been finalized.

This complements commit a6c7053929dd ("MIPS/opcodes: Remove microMIPS
48-bit LI instruction").

References:

[1] "MIPS Architecture for Programmers, Volume II-B: The microMIPS64
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00594,
    Revision 3.06, October 17, 2012, Table 6.2 "microMIPS64 Encoding of
    Major Opcode Field", p. 578

gas/
* config/tc-mips.c (micromips_insn_length): Remove the mention
of 48-bit microMIPS instructions.

gdb/
* mips-tdep.c (mips_insn_size): Remove 48-bit microMIPS
instruction support.
(micromips_next_pc): Likewise.
(micromips_scan_prologue): Likewise.
(micromips_deal_with_atomic_sequence): Likewise.
(micromips_stack_frame_destroyed_p): Likewise.
(mips_breakpoint_from_pc): Likewise.

opcodes/
* mips-dis.c (print_insn_micromips): Remove 48-bit microMIPS
instruction support.

8 years agoMIPS: Only build microMIPS specific simulator functions if microMIPS support is required.
Andrew Bennett [Mon, 18 Jan 2016 21:25:19 +0000 (21:25 +0000)]
MIPS: Only build microMIPS specific simulator functions if microMIPS support is required.

This fixes PR sim/19441.  In the MIPS simulator the microMIPS
functions in micromips.igen were not predicated on the microMIPS
models.  This was causing build issues for some target triples.
This patch sets all the microMIPS specific functions to only be built if
the micromips32, micromips64 or micromipsdsp models are used.

PR sim/19441
* micromips.igen (delayslot_micromips): Enable for `micromips32',
`micromips64' and `micromipsdsp' only.
(process_isa_mode): Enable for `micromips32' and `micromips64' only.
(do_micromips_jalr, do_micromips_jal): Likewise.
(compute_movep_src_reg): Likewise.
(compute_andi16_imm): Likewise.
(convert_fmt_micromips): Likewise.
(convert_fmt_micromips_cvt_d): Likewise.
(convert_fmt_micromips_cvt_s): Likewise.
(FMT_MICROMIPS): Likewise.
(FMT_MICROMIPS_CVT_D): Likewise.
(FMT_MICROMIPS_CVT_S): Likewise.

8 years agoMIPS: Fix microMIPS instruction size determination
Maciej W. Rozycki [Mon, 18 Jan 2016 20:24:34 +0000 (20:24 +0000)]
MIPS: Fix microMIPS instruction size determination

Fix a bug in `micromips_insn_at_pc_has_delay_slot' in instruction size
determination via `mips_insn_size'.  In the microMIPS case the latter
function expects a lone 16-bit instruction word containing the major
opcode regardless of whether the opcode requires another 16-bit word to
follow, to form a complete 32-bit instruction.  Code however passes the
16-bit word previously retrieved shifted left by 16 bits.  Consequently
`mips_insn_size', which examines the low 16-bit only, always sees 0.

By pure coincidence a major opcode of 0 denotes a 32-bit instruction in
the microMIPS instruction set, so the size of 4 is always returned here,
and the following 16-bit word is then merged in the low 16 bits of the
instruction previously shifted by 16 bits.  The resulting 32-bit value
is then passed to `micromips_instruction_has_delay_slot' for delay slot
presence determination.  This function in turn first examines the high
16 bits of the instruction word received and ignores the low 16 bits for
16-bit instructions.

Consequently the only effect of this bug is an extraneous memory read
issued to retrieve a subsequent 16-bit word where a 16-bit instruction
is being examined.  Which in turn may fail if the instruction is located
right at the end of a readable memory area, in which case the lack of a
delay slot will be reported to the caller, which may be incorrect.

This code is used in breakpoint maintenance, for delay slot avoidance,
so the bug would only trigger for the unlikely case of someone placing
a breakpoint in a delay slot of an instruction which is at the end of
readable memory.  Which explains why the bug remained unnoticed so long.

gdb/
* mips-tdep.c (micromips_insn_at_pc_has_delay_slot): Pass
unshifted 16-bit microMIPS instruction word to `mips_insn_size'.

8 years agotestsuite: Remove unused global references in gdb_test
Simon Marchi [Mon, 18 Jan 2016 16:56:41 +0000 (11:56 -0500)]
testsuite: Remove unused global references in gdb_test

Those are unused since gdb_test_multiple was added, factoring out most
of the content of gdb_test.

gdb/testsuite/ChangeLog:

* lib/gdb.exp (gdb_test): Remove unused global references.

8 years agoUse a 32-bit value to hold the section number in the internal COFF symbol structure.
Nick Clifton [Mon, 18 Jan 2016 15:58:47 +0000 (15:58 +0000)]
Use a 32-bit value to hold the section number in the internal COFF symbol structure.

PR ld/19440
inc * coff/internal.h (internal_syment): Use int to hold section
number.
(N_UNDEF): Cast to int not short.
(N_ABS): Likewise.
(N_DEBUG): Likewise.
(N_TV): Likewise.
(P_TV): Likewise.

bfd PR ld/19440
* coff-rs6000.c (_bfd_xcoff_swap_sym_in): Sign extend external
section number into internal section number.
* coff64-rs6000.c (_bfd_xcoff64_swap_sym_in): Likewise.
* coffswap.h (coff_swap_sym_in): Likewise.
* peXXigen.c (_bfd_XXi_swap_sym_in): Likewise.
* coffcode.h (_coff_bigobj_swap_sym_in): Make sure that internal
section number field is big enough to hold the external value.

8 years agoFix PR threads/19422 - show which thread caused stop
Pedro Alves [Mon, 18 Jan 2016 15:15:18 +0000 (15:15 +0000)]
Fix PR threads/19422 - show which thread caused stop

This commit changes GDB like this:

 - Program received signal SIGINT, Interrupt.
 + Thread 1 "main" received signal SIGINT, Interrupt.

 - Breakpoint 1 at 0x40087a: file threads.c, line 87.
 + Thread 3 "bar" hit Breakpoint 1 at 0x40087a: file threads.c, line 87.

 ... once the program goes multi-threaded.  Until GDB sees a second
thread spawn, the output is still the same as before, per the
discussion back in 2012:

  https://www.sourceware.org/ml/gdb/2012-11/msg00010.html

This helps non-stop mode, where you can't easily tell which thread hit
a breakpoint or received a signal:

 (gdb) info threads
   Id   Target Id         Frame
 * 1    Thread 0x7ffff7fc1740 (LWP 19362) "main" (running)
   2    Thread 0x7ffff7fc0700 (LWP 19366) "foo" (running)
   3    Thread 0x7ffff77bf700 (LWP 19367) "bar" (running)
 (gdb)
 Program received signal SIGUSR1, User defined signal 1.
 0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
 92          lll_wait_tid (pd->tid);
 (gdb) b threads.c:87
 Breakpoint 1 at 0x40087a: file threads.c, line 87.
 (gdb)
 Breakpoint 1, thread_function1 (arg=0x1) at threads.c:87
 87              usleep (1);  /* Loop increment.  */

The best the user can do is run "info threads" and try to figure
things out.

It actually also affects all-stop mode, in case of "handle SIG print
nostop":

...
  Program received signal SIGUSR1, User defined signal 1.

  Program received signal SIGUSR1, User defined signal 1.

  Program received signal SIGUSR1, User defined signal 1.

  Program received signal SIGUSR1, User defined signal 1.
...

The above doesn't give any clue that these were different threads
getting the SIGUSR1 signal.

I initially thought of lowercasing "breakpoint" in

  "Thread 3 hit Breakpoint 1"

but then after trying it I realized that leaving "Breakpoint"
uppercase helps the eye quickly find the relevant information.  It's
also easier to implement not showing anything about threads until the
program goes multi-threaded this way.

Here's a larger example session in non-stop mode:

  (gdb) c -a&
  Continuing.
  (gdb) interrupt -a
  (gdb)
  Thread 1 "main" stopped.
  0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
  92          lll_wait_tid (pd->tid);

  Thread 2 "foo" stopped.
  0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)

  Thread 3 "bar" stopped.
  0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
  b threads.c:87
  Breakpoint 4 at 0x40087a: file threads.c, line 87.
  (gdb) b threads.c:67
  Breakpoint 5 at 0x400811: file threads.c, line 67.
  (gdb) c -a&
  Continuing.
  (gdb)
  Thread 3 "bar" hit Breakpoint 4, thread_function1 (arg=0x1) at threads.c:87
  87              usleep (1);  /* Loop increment.  */

  Thread 2 "foo" hit Breakpoint 5, thread_function0 (arg=0x0) at threads.c:68
  68              (*myp) ++;
  info threads
    Id   Target Id         Frame
  * 1  Thread 0x7ffff7fc1740 (LWP 31957) "main" (running)
    2  Thread 0x7ffff7fc0700 (LWP 31961) "foo" thread_function0 (arg=0x0) at threads.c:68
    3  Thread 0x7ffff77bf700 (LWP 31962) "bar" thread_function1 (arg=0x1) at threads.c:87
  (gdb) shell kill -SIGINT 31957
  (gdb)
  Thread 1 "main" received signal SIGINT, Interrupt.
  0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
  92          lll_wait_tid (pd->tid);
  info threads
    Id   Target Id         Frame
  * 1  Thread 0x7ffff7fc1740 (LWP 31957) "main" 0x0000003616a09237 in pthread_join (threadid=140737353877248, thread_return=0x7fffffffd5b8) at pthread_join.c:92
    2  Thread 0x7ffff7fc0700 (LWP 31961) "foo" thread_function0 (arg=0x0) at threads.c:68
    3  Thread 0x7ffff77bf700 (LWP 31962) "bar" thread_function1 (arg=0x1) at threads.c:87
  (gdb) t 2
  [Switching to thread 2, Thread 0x7ffff7fc0700 (LWP 31961)]
  #0  thread_function0 (arg=0x0) at threads.c:68
  68              (*myp) ++;
  (gdb) catch syscall
  Catchpoint 6 (any syscall)
  (gdb) c&
  Continuing.
  (gdb)
  Thread 2 "foo" hit Catchpoint 6 (call to syscall nanosleep), 0x0000003615ebc6ed in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  81      T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)

I'll work on documentation next if this looks agreeable.

This patch applies on top of the star wildcards thread IDs series:

  https://sourceware.org/ml/gdb-patches/2016-01/msg00291.html

For convenience, I've pushed this to the
users/palves/show-which-thread-caused-stop branch.

gdb/doc/ChangeLog:
2016-01-18  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Threads): Mention that GDB displays the ID and name
of the thread that hit a breakpoint or received a signal.

gdb/ChangeLog:
2016-01-18  Pedro Alves  <palves@redhat.com>

* NEWS: Mention that GDB now displays the ID and name of the
thread that hit a breakpoint or received a signal.
* break-catch-sig.c (signal_catchpoint_print_it): Use
maybe_print_thread_hit_breakpoint.
* break-catch-syscall.c (print_it_catch_syscall): Likewise.
* break-catch-throw.c (print_it_exception_catchpoint): Likewise.
* breakpoint.c (maybe_print_thread_hit_breakpoint): New function.
(print_it_catch_fork, print_it_catch_vfork, print_it_catch_solib)
(print_it_catch_exec, print_it_ranged_breakpoint)
(print_it_watchpoint, print_it_masked_watchpoint, bkpt_print_it):
Use maybe_print_thread_hit_breakpoint.
* breakpoint.h (maybe_print_thread_hit_breakpoint): Declare.
* gdbthread.h (show_thread_that_caused_stop): Declare.
* infrun.c (print_signal_received_reason): Print which thread
received signal.
* thread.c (show_thread_that_caused_stop): New function.

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

* gdb.base/async-shell.exp: Adjust expected output.
* gdb.base/dprintf-non-stop.exp: Adjust expected output.
* gdb.base/siginfo-thread.exp: Adjust expected output.
* gdb.base/watchpoint-hw-hit-once.exp: Adjust expected output.
* gdb.java/jnpe.exp: Adjust expected output.
* gdb.threads/clone-new-thread-event.exp: Adjust expected output.
* gdb.threads/continue-pending-status.exp: Adjust expected output.
* gdb.threads/leader-exit.exp: Adjust expected output.
* gdb.threads/manythreads.exp: Adjust expected output.
* gdb.threads/pthreads.exp: Adjust expected output.
* gdb.threads/schedlock.exp: Adjust expected output.
* gdb.threads/siginfo-threads.exp: Adjust expected output.
* gdb.threads/signal-command-multiple-signals-pending.exp: Adjust
expected output.
* gdb.threads/signal-delivered-right-thread.exp: Adjust expected
output.
* gdb.threads/sigthread.exp: Adjust expected output.
* gdb.threads/watchpoint-fork.exp: Adjust expected output.

8 years agoReplace some $ARCH_{get,set}_pc with linux_{get,set}_pc_64bit
Yao Qi [Mon, 18 Jan 2016 15:03:18 +0000 (15:03 +0000)]
Replace some $ARCH_{get,set}_pc with linux_{get,set}_pc_64bit

This patch is the follow-up of
https://sourceware.org/ml/gdb-patches/2016-01/msg00164.html to provide
linux_{get,set}_pc_64bit functions.

Rebuild GDBserver with tilegx-linux-gcc.  Not tested.

I think about pc in Tile-GX a little bit.  Looks current Tile-GX
supports debugging 32-bit program (multi-arch), but PC is always
64-bit.  See this thread
https://sourceware.org/ml/gdb-patches/2013-02/msg00113.html
and GDBserver reads PC as 64-bit through ptrace.  However, if
the inferior is 32-bit, the PC in the target description and
regcache is 32-bit, so only 32-bit contents are sent back GDB.
Anyway, Tile-GX GDBserver may have some problems here, but this
patch doesn't change anything.

gdb/gdbserver:

2016-01-18  Yao Qi  <yao.qi@linaro.org>

* linux-low.c (linux_set_pc_64bit): New function.
(linux_get_pc_64bit): New function.
* linux-low.h (linux_set_pc_64bit, linux_get_pc_64bit):
Declare.
* linux-sparc-low.c (debug_threads): Remove declaration.
(sparc_get_pc): Remove.
(the_low_target): Use linux_get_pc_64bit instead of
sparc_get_pc.
* linux-tile-low.c (tile_get_pc, tile_set_pc): Remove.
(the_low_target): Use linux_get_pc_64bit and
linux_set_pc_64bit.

8 years agoReplace some $ARCH_{get,set}_pc with linux_{get,set}_pc_32bit
Yao Qi [Mon, 18 Jan 2016 14:49:50 +0000 (14:49 +0000)]
Replace some $ARCH_{get,set}_pc with linux_{get,set}_pc_32bit

This patch adds a pair of new functions linux_get_pc_32bit and
linux_set_pc_32bit which get and set 32-bit register "pc" from
regcache.  This function can be used some targets and these own
$ARCH_{get,set}_pc are replaced by linux_{get,set}_pc_32bit
respectively.

This patch touches many targets, but I only have arm board to
test and no regression.  I also rebuilt nios2-linux GDBserver.
If it is right to go, I'll post the 64-bit counterpart later.

gdb/gdbserver:

2016-01-18  Yao Qi  <yao.qi@linaro.org>

* linux-arm-low.c (debug_threads): Remove declaration.
(arm_get_pc, arm_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-bfin-low.c (bfin_get_pc, bfin_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-cris-low.c (debug_threads): Remove declaration.
(cris_get_pc, cris_set_pc,): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-crisv32-low.c (debug_threads): Remove declaration.
(cris_get_pc, cris_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-low.c: Include inttypes.h.
(linux_get_pc_32bit, linux_set_pc_32bit): New functions.
* linux-low.h (linux_get_pc_32bit, linux_set_pc_32bit): Declare.
* linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-m68k-low.c (m68k_get_pc, m68k_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-nios2-low.c (nios2_get_pc, nios2_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-sh-low.c (sh_get_pc, sh_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.
* linux-xtensa-low.c (xtensa_get_pc, xtensa_set_pc): Remove.
(the_low_target): Use linux_get_pc_32bit and
linux_set_pc_32bit.

8 years ago[testsuite] @progbits -> %progbits
Yao Qi [Mon, 18 Jan 2016 14:29:53 +0000 (14:29 +0000)]
[testsuite] @progbits -> %progbits

The ARM assembler has "@" as a comment character, so there are compile
errors in {py,scm}-section-script.c,

 gdb compile failed, /tmp/ccHEzYqy.s: Assembler messages:
 /tmp/ccHEzYqy.s:19: Error: junk at end of line, first unrecognized character is `,'
 /tmp/ccHEzYqy.s:24: Error: junk at end of line, first unrecognized character is `,'
 /tmp/ccHEzYqy.s:29: Error: junk at end of line, first unrecognized character is `,'
 /tmp/ccHEzYqy.s:41: Error: junk at end of line, first unrecognized character is `,'

This patch replaces @progbits with %progbits.

gdb/testsuite:

2016-01-18  Yao Qi  <yao.qi@linaro.org>

* gdb.guile/scm-section-script.c: Replace @progbits with
%progbits.
* gdb.python/py-section-script.c: Likewise.

8 years agoRe-enable rgn-at11 test for MIPS targets with adjusted section alignment.
Nick Clifton [Mon, 18 Jan 2016 13:00:33 +0000 (13:00 +0000)]
Re-enable rgn-at11 test for MIPS targets with adjusted section alignment.

* testsuite/ld-scripts/rgn-at11.s: New file - based on rgn-at10.s
but with 16 byte section alignment.
* testsuite/ld-scripts/rgn-at11.d: Use new source file.  Reenable
test for MIPS targets.

8 years agoProvide AC_PROG_LEX that copes with LEX=missing from top-level
Alan Modra [Mon, 18 Jan 2016 05:36:49 +0000 (16:06 +1030)]
Provide AC_PROG_LEX that copes with LEX=missing from top-level

config/
PR binutils/19481
* override.m4 (AC_PROG_LEX): Define.
binutils/
* configure: Regenerate.
gas/
* configure: Regenerate.
ld/
* configure: Regenerate.

8 years agoFix gdbserver build failure on targets without fork
Gary Benson [Mon, 18 Jan 2016 09:45:10 +0000 (09:45 +0000)]
Fix gdbserver build failure on targets without fork

This commit fixes nat/linux-namespaces.c to build correctly on
targets without fork.

gdb/ChangeLog:

* nat/linux-namespaces.c (do_fork): New function.
(linux_mntns_get_helper): Use the above.

gdb/gdbserver/ChangeLog:

* configure.ac (AC_FUNC_FORK): New check.
* config.in: Regenerate.
* configure: Likewise.

8 years agoSkip linker plugin tests if the linker has not been configured to support plugins.
Nick Clifton [Mon, 18 Jan 2016 11:23:44 +0000 (11:23 +0000)]
Skip linker plugin tests if the linker has not been configured to support plugins.

* ld-plugin/plugin.exp: Skip plugin tests if the linker is not
configured to support plugins.

8 years agoAutomatic date update in version.in
GDB Administrator [Mon, 18 Jan 2016 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoGDB SIGSEGV opening a Fortran program compiled with ifort
Jonas Hahnfeld [Wed, 6 Jan 2016 06:10:39 +0000 (10:10 +0400)]
GDB SIGSEGV opening a Fortran program compiled with ifort

This patch fixes a SIGSEGV when trying to open a Fortran program
compiled with ifort (reproduced using version using version 16.0.1.150).
The error can be reproduce with most, if not any program. For instance,
a single file only containing "end", compiled with no additional flag,
suffices.

gdb/ChangeLog:

       PR gdb/19208
       * dwarf2read.c (read_partial_die): Do not call set_objfile_main_name
       if the function has no name.

8 years agofix gdb version parsing in src-release.sh
Joel Brobecker [Sun, 17 Jan 2016 06:01:55 +0000 (10:01 +0400)]
fix gdb version parsing in src-release.sh

Small change required after we switched the gdb version scheme to
using a -git suffix rather than a -cvs one.

ChangeLog:

        * src-release.sh: Compute the gdb tarball name by stripping
        '-git' rather than '-cvs'.

Tested by running "src-release.sh gdb" and verifying the tarball
name as well as its contents.

8 years agoMinor comment fixes in sim/common/sim-fpu.c.
Joel Brobecker [Sun, 10 Jan 2016 06:04:54 +0000 (07:04 +0100)]
Minor comment fixes in sim/common/sim-fpu.c.

This patch makes a fair number of fixes in the various comments of
sim-fpu.c, mostly to either better conform to the GNU Coding Standards
(sentences start with a capital letter, end with a period), or to
fix spelling mistakes.

sim/common/ChangeLog:

        * sim-fpu.c: Minor comment fixes throughout.

8 years agominor reformatting in sim/common/sim-fpu.c.
Joel Brobecker [Sun, 10 Jan 2016 06:02:25 +0000 (07:02 +0100)]
minor reformatting in sim/common/sim-fpu.c.

This patch just makes a copy of formatting changes to better conform
with the GNU Coding Style.

sim/common/ChangeLog:

        * sim-fpu.c (print_bits): Minor reformatting (no code change).
        (sim_fpu_map): Likewise.

8 years agoRegen configure
Alan Modra [Sun, 17 Jan 2016 01:50:55 +0000 (12:20 +1030)]
Regen configure

Picks up 2016-01-12 libtool.m4 change.

bfd/
* configure: Regenerate.
binutils/
* configure: Regenerate.
gas/
* configure: Regenerate.
gprof/
* configure: Regenerate.
ld/
* configure: Regenerate.
opcodes/
* configure: Regenerate.

8 years agom68hc11/12 and xgate config.sub weirdness
Alan Modra [Sun, 17 Jan 2016 01:43:43 +0000 (12:13 +1030)]
m68hc11/12 and xgate config.sub weirdness

Oddly, config.sub converts a duple ending in -elf for these target to
-unknown-none, which means they aren't seen as elf targets by
binutils.  So, counter that.  This exposes a number of testsuite
issues (ones you would have seen if configuring with a full triple,
say m68hc11-unknown-elf).

binutils/
* testsuite/lib/binutils-common.exp (is_elf_format): Return true
for m68hc11/12 and xgate triples.
gas/
* testsuite/gas/cfi/cfi.exp: Exclude m68hc11/12 from m68k test.
ld/
* testsuite/lib/ld-lib.exp (check_shared_lib_support): Exclude xgate.
* testsuite/ld-elf/endsym.d: xfail m68hc11/12 and xgate.
* testsuite/ld-elf/pr14156a.d: Likewise.
* testsuite/ld-elf/pr14926.d: Don't run for m68hc11/12 and xgate.
* testsuite/ld-elf/sec64k.exp: Likewise.

8 years agom68hc11/12 readelf support
Alan Modra [Sun, 17 Jan 2016 01:43:30 +0000 (12:13 +1030)]
m68hc11/12 readelf support

Supports relocation of debug sections.

* readelf.c (is_32bit_abs_reloc): Add R_M68HC11_32.

8 years agoAutomatic date update in version.in
GDB Administrator [Sun, 17 Jan 2016 00:00:08 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years ago[gold][aarch64] PR gold/19472 - DSOs need pc-relative stubs.
Han Shen [Fri, 15 Jan 2016 17:31:23 +0000 (09:31 -0800)]
[gold][aarch64] PR gold/19472 - DSOs need pc-relative stubs.

The stub generated during relaxation uses absolute addressing mode for
shared libraries, which is not correct. Use pc-relative addressing
instead.

gold/ChangeLog:

2016-01-15 Han Shen  <shenhan@google.com>

PR gold/19472 - DSOs need pc-relative stubs.

* aarch64.cc (Reloc_stub::stub_type_for_reloc): Return
PC-relative stub type for DSOs and pie executables.

8 years agoAutomatic date update in version.in
GDB Administrator [Sat, 16 Jan 2016 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in

8 years agoFix phony_iconv wide character support.
Sandra Loosemore [Fri, 15 Jan 2016 22:45:19 +0000 (14:45 -0800)]
Fix phony_iconv wide character support.

2016-01-15  Sandra Loosemore  <sandra@codesourcery.com>

gdb/
* charset.c [PHONY_ICONV] (GDB_DEFAULT_HOST_CHARSET):
Conditionalize for Windows host.
(GDB_DEFAULT_TARGET_CHARSET): Match GDB_DEFAULT_HOST_CHARSET.
(GDB_DEFAULT_TARGET_WIDE_CHARSET): Use UTF-32.
(phony_iconv_open): Handle both UTF-32 endiannesses.
(phony_iconv): Likewise.  Check for output overflow and clean up
out-of-input cases.  Correct adjustment to input buffer pointer.
(set_be_le_names) [PHONY_ICONV]: Use hard-wired names to match
phony_iconv_open.

8 years agoStar wildcard ranges (e.g., "info thread 2.*")
Pedro Alves [Fri, 15 Jan 2016 21:46:23 +0000 (21:46 +0000)]
Star wildcard ranges (e.g., "info thread 2.*")

Add support for specifying "all threads of inferior N", by writing "*"
as thread number/range in thread ID lists.

E.g., "info threads 2.*" or "thread apply 2.* bt".

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

* NEWS: Mention star wildcard ranges.
* cli/cli-utils.c (get_number_or_range): Check state->in_range first.
(number_range_setup_range): New function.
* cli/cli-utils.h (number_range_setup_range): New declaration.
* thread.c (thread_apply_command): Support star TID ranges.
* tid-parse.c (tid_range_parser_finished)
(tid_range_parser_string, tid_range_parser_skip)
(get_tid_or_range, get_tid_or_range): Handle
TID_RANGE_STATE_STAR_RANGE.
(tid_range_parser_star_range): New function.
* tid-parse.h (enum tid_range_state) <TID_RANGE_STATE_STAR_RANGE>:
New value.
(tid_range_parser_star_range): New declaration.

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

* gdb.texinfo (Threads) <thread ID lists>: Document star ranges.

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

* gdb.multi/tids.exp: Test star wildcard ranges.

8 years agoFix "thread apply $conv_var" and misc other related problems
Pedro Alves [Fri, 15 Jan 2016 21:46:22 +0000 (21:46 +0000)]
Fix "thread apply $conv_var" and misc other related problems

This fixes a few bugs in "thread apply".

While this works:

 (gdb) thread apply 1 p 1234

 Thread 1 (Thread 0x7ffff7fc1740 (LWP 14048)):
 $1 = 1234

This doesn't:

 (gdb) thread apply $thr p 1234

 Thread 1 (Thread 0x7ffff7fc1740 (LWP 12039)):
 Invalid thread ID: p 1234
 (gdb)

~~~~

Also, while this works:
 (gdb) thread apply 1
 Please specify a command following the thread ID list

This doesn't:
 (gdb) thread apply $thr
 Thread 1 (Thread 0x7ffff7fc1740 (LWP 12039)):
 [Current thread is 1 (Thread 0x7ffff7fc1740 (LWP 12039))]
 (gdb)

~~~~

And, while this works:
 (gdb) thread apply
 Please specify a thread ID list

This obviously bogus invocation is just silent:
 (gdb) thread apply bt
 (gdb)

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

* thread.c (thread_apply_command): Use the tid range parser to
advance past the thread ID list.
* tid-parse.c (get_positive_number_trailer): New function.
(parse_thread_id): Use it.
(get_tid_or_range): Use it.  Return 0 instead of throwing invalid
thread ID error.
(get_tid_or_range): Detect negative values.  Return 0 instead of
throwing invalid thread ID error.

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

* gdb.multi/tids.exp (thr_apply_info_thr_error): Remove "p 1234"
command from "thread apply" invocation.
(thr_apply_info_thr_invalid): Default the expected output to the
input tid list.
(top level): Add tests that use convenience variables.  Add tests
for "thread apply" with a valid TID list, but missing the command.

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

8 years agoFix display of RL78 MOVW instructions that use the stack pointer.
Nick Clifton [Thu, 14 Jan 2016 16:23:35 +0000 (16:23 +0000)]
Fix display of RL78 MOVW instructions that use the stack pointer.

* rl78-decode.opc (rl78_decode_opcode): Add 's' operand to movw
instructions that can support stack pointer operations.
* rl78-decode.c: Regenerate.
* rl78-dis.c: Fix display of stack pointer in MOVW based
instructions.

* testsuite/gas/rl78/sp-relative-movw.s: New test.
* testsuite/gas/rl78/sp-relative-movw.d: Expected disassembly.
* testsuite/gas/rl78/rl78.exp: Run the new test.