deliverable/binutils-gdb.git
9 years agoPR python/17372 - Python hangs when displaying help()
Pedro Alves [Thu, 23 Oct 2014 16:13:35 +0000 (17:13 +0100)] 
PR python/17372 - Python hangs when displaying help()

This is more of a readline/terminal issue than a Python one.

PR17372 is a regression in 7.8 caused by the fix for PR17072:

 commit 0017922d0292d8c374584f6100874580659c9973
 Author: Pedro Alves <palves@redhat.com>
 Date:   Mon Jul 14 19:55:32 2014 +0100

    Background execution + pagination aborts readline/gdb

    gdb_readline_wrapper_line removes the handler after a line is
    processed.  Usually, we'll end up re-displaying the prompt, and that
    reinstalls the handler.  But if the output is coming out of handling
    a stop event, we don't re-display the prompt, and nothing restores the
    handler.  So the next input wakes up the event loop and calls into
    readline, which aborts.
...
    gdb/
    2014-07-14  Pedro Alves  <palves@redhat.com>

        PR gdb/17072
        * top.c (gdb_readline_wrapper_line): Tweak comment.
        (gdb_readline_wrapper_cleanup): If readline is enabled, reinstall
        the input handler callback.

The problem is that installing the input handler callback also preps
the terminal, putting it in raw mode and with echo disabled, which is
bad if we're going to call a command that assumes cooked/canonical
mode, and echo enabled, like in the case of the PR, Python's
interactive shell.  Another example I came up with that doesn't depend
on Python is starting a subshell with "(gdb) shell /bin/sh" from a
multi-line command.  Tests covering both these examples are added.

The fix is to revert the original fix for PR gdb/17072, and instead
restore the callback handler after processing an asynchronous target
event.

Furthermore, calling rl_callback_handler_install when we already have
some input in readline's line buffer discards that input, which is
obviously a bad thing to do while the user is typing.  No specific
test is added for that, because I first tried calling it even if the
callback handler was still installed and that resulted in hundreds of
failures in the testsuite.

gdb/
2014-10-29  Pedro Alves  <palves@redhat.com>

PR python/17372
* event-top.c (change_line_handler): Call
gdb_rl_callback_handler_remove instead of
rl_callback_handler_remove.
(callback_handler_installed): New global.
(gdb_rl_callback_handler_remove, gdb_rl_callback_handler_install)
(gdb_rl_callback_handler_reinstall): New functions.
(display_gdb_prompt): Call gdb_rl_callback_handler_remove and
gdb_rl_callback_handler_install instead of
rl_callback_handler_remove and rl_callback_handler_install.
(gdb_disable_readline): Call gdb_rl_callback_handler_remove
instead of rl_callback_handler_remove.
* event-top.h (gdb_rl_callback_handler_remove)
(gdb_rl_callback_handler_install)
(gdb_rl_callback_handler_reinstall): New declarations.
* infrun.c (reinstall_readline_callback_handler_cleanup): New
cleanup function.
(fetch_inferior_event): Install it.
* top.c (gdb_readline_wrapper_line) Call
gdb_rl_callback_handler_remove instead of
rl_callback_handler_remove.
(gdb_readline_wrapper_cleanup): Don't call
rl_callback_handler_install.

gdb/testsuite/
2014-10-29  Pedro Alves  <palves@redhat.com>

PR python/17372
* gdb.python/python.exp: Test a multi-line command that spawns
interactive Python.
* gdb.base/multi-line-starts-subshell.exp: New file.

9 years agoThix fixes an obvious coding error that led to a GDB crash on AIX or HPUX.
Dennis Brueni [Wed, 29 Oct 2014 17:17:32 +0000 (17:17 +0000)] 
Thix fixes an obvious coding error that led to a GDB crash on AIX or HPUX.

* elf.c (elfcore_write_lwpstatus): fix typo in call to memcpy

9 years agoUpdated/new translations provided by the Translations Project.
Nick Clifton [Wed, 29 Oct 2014 16:34:04 +0000 (16:34 +0000)] 
Updated/new translations provided by the Translations Project.

9 years agoFix uninitialized value access when very first GDB command entered is <RET>
Pedro Alves [Wed, 29 Oct 2014 11:57:03 +0000 (11:57 +0000)] 
Fix uninitialized value access when very first GDB command entered is <RET>

While running GDB under Valgrind, I noticed that if the very first
command entered is just <RET>, GDB accesses an uninitialized value:

 $ valgrind ./gdb -q -nx
 ==26790== Memcheck, a memory error detector
 ==26790== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
 ==26790== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
 ==26790== Command: ./gdb -q -nx
 ==26790==

 (gdb)
 ==26790== Conditional jump or move depends on uninitialised value(s)
 ==26790==    at 0x619DFC: command_line_handler (event-top.c:588)
 ==26790==    by 0x7813D5: rl_callback_read_char (callback.c:220)
 ==26790==    by 0x6194B4: rl_callback_read_char_wrapper (event-top.c:166)
 ==26790==    by 0x61988A: stdin_event_handler (event-top.c:372)
 ==26790==    by 0x61847D: handle_file_event (event-loop.c:762)
 ==26790==    by 0x617964: process_event (event-loop.c:339)
 ==26790==    by 0x617A2B: gdb_do_one_event (event-loop.c:403)
 ==26790==    by 0x617A7B: start_event_loop (event-loop.c:428)
 ==26790==    by 0x6194E6: cli_command_loop (event-top.c:181)
 ==26790==    by 0x60F86B: current_interp_command_loop (interps.c:317)
 ==26790==    by 0x610A34: captured_command_loop (main.c:321)
 ==26790==    by 0x60C728: catch_errors (exceptions.c:237)
 ==26790==
 (gdb)

It's this check here:

  /* If we just got an empty line, and that is supposed to repeat the
     previous command, return the value in the global buffer.  */
  if (repeat && p == linebuffer && *p != '\\')
    {

The problem is that linebuffer's contents were never initialized at
this point.

gdb/
2014-10-29  Pedro Alves  <palves@redhat.com>

* event-top.c (command_line_handler): Clear the first byte of
linebuffer, when it is first allocated.

9 years agoPR tui/16138 is about failure to initialize curses resulting in GDB
Pedro Alves [Wed, 29 Oct 2014 14:49:05 +0000 (14:49 +0000)] 
PR tui/16138 is about failure to initialize curses resulting in GDB
exiting instead of throwing an error.  E.g.:

 $ TERM=foo gdb
 (gdb) layout asm
 Error opening terminal: foo.
 $

The problem is that we're calling initscr to initialize the screen.
As mentioned in
http://pubs.opengroup.org/onlinepubs/7908799/xcurses/initscr.html:

 If errors occur, initscr() writes an appropriate error message to
 standard error and exits.
                    ^^^^^

Instead, we should use newterm:

 "A program that needs an indication of error conditions, so it can
 continue to run in a line-oriented mode if the terminal cannot support
 a screen-oriented program, would also use this function."

After the patch:

 $ TERM=foo gdb -q -nx
 (gdb) layout asm
 Cannot enable the TUI: error opening terminal [TERM=foo]
 (gdb)

And then PR tui/17519 is about GDB not validating whether the terminal
has the necessary capabilities when enabling the TUI.  If one tries to
enable the TUI with TERM=dumb (and e.g., from a shell within emacs),
GDB ends up with a clear screen, the cursor is placed at the
bottom/right corner of the screen, there's no prompt, typing shows no
echo, and there's no indication of what's going on.  c-x,a gets you
out of the TUI, but it's completely non-obvious.

After the patch, we get:

 $ TERM=dumb gdb -q -nx
 (gdb) layout asm
 Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
 (gdb)

While at it, I've moved all the tui_allowed_p validation to
tui_enable, and expanded the error messages.  Previously we'd get:

 $ gdb -q -nx -i=mi
 (gdb)
 layout asm
 &"layout asm\n"
 &"TUI mode not allowed\n"
 ^error,msg="TUI mode not allowed"

and:

 $ gdb -q -nx -ex "layout asm" > foo
 TUI mode not allowed

While now we get:

 $ gdb -q -nx -i=mi
 (gdb)
 layout asm
 &"layout asm\n"
 &"Cannot enable the TUI when the interpreter is 'mi'\n"
 ^error,msg="Cannot enable the TUI when the interpreter is 'mi'"
 (gdb)

and:

 $ gdb -q -nx -ex "layout asm" > foo
 Cannot enable the TUI when output is not a terminal

Tested on x86_64 Fedora 20.

gdb/
2014-10-29  Pedro Alves  <palves@redhat.com>

PR tui/16138
PR tui/17519
* tui/tui-interp.c (tui_is_toplevel): Delete global.
(tui_allowed_p): Delete function.
* tui/tui.c: Include "interps.h".
(tui_enable): Don't use tui_allowed_p.  Error out here with
detailed error messages if the TUI is the top level interpreter,
or if output is not a terminal.  Use newterm instead of initscr,
and error out if initializing the terminal fails.  Also error out if
the terminal doesn't support cursor addressing.
* tui/tui.h (tui_allowed_p): Delete declaration.

9 years agoTUI: don't let exceptions escape while handling readline key bindings
Pedro Alves [Wed, 29 Oct 2014 11:58:12 +0000 (11:58 +0000)] 
TUI: don't let exceptions escape while handling readline key bindings

I noticed that with:

 $ TERM=dumb ./gdb -q -nx
 <c-x,a>
 Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
 (gdb)

The next key the user types is silently eaten.

The problem is that we're throwing an exception while in a readline
callback that isn't prepared for that:

(top-gdb) bt
#0  tui_enable () at /home/pedro/gdb/mygit/build/../src/gdb/tui/tui.c:388
#1  0x000000000051f47b in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/build/../src/gdb/tui/tui.c:101
#2  0x0000000000768d6f in _rl_dispatch_subseq (key=1, map=0xd069c0 <emacs_ctlx_keymap>, got_subseq=0) at /home/pedro/gdb/mygit/build/../src/readline/readline.c:774
#3  0x0000000000768acb in _rl_dispatch_callback (cxt=0x1ce6190) at /home/pedro/gdb/mygit/build/../src/readline/readline.c:686
#4  0x000000000078120b in rl_callback_read_char () at /home/pedro/gdb/mygit/build/../src/readline/callback.c:170
#5  0x0000000000619445 in rl_callback_read_char_wrapper (client_data=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/event-top.c:166
#6  0x000000000061981b in stdin_event_handler (error=0, client_data=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/event-top.c:372
#7  0x000000000061840e in handle_file_event (data=...) at /home/pedro/gdb/mygit/build/../src/gdb/event-loop.c:762
#8  0x00000000006178f5 in process_event () at /home/pedro/gdb/mygit/build/../src/gdb/event-loop.c:339
#9  0x00000000006179bc in gdb_do_one_event () at /home/pedro/gdb/mygit/build/../src/gdb/event-loop.c:403
#10 0x0000000000617a0c in start_event_loop () at /home/pedro/gdb/mygit/build/../src/gdb/event-loop.c:428

Here, in _rl_dispatch_subseq:

769
770               rl_executing_keymap = map;
771
772               rl_dispatching = 1;
773               RL_SETSTATE(RL_STATE_DISPATCHING);
774               (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
775               RL_UNSETSTATE(RL_STATE_DISPATCHING);
776               rl_dispatching = 0;
777
778               /* If we have input pending, then the last command was a prefix
779                  command.  Don't change the state of rl_last_func.  Otherwise,

GDB is called from line 774, but longjmp'ing at that point leaves
rl_dispatching and RL_STATE_DISPATCHING set.

Fix this by wrapping tui_rl_switch_mode in a TRY_CATCH.

gdb/
2014-10-29  Pedro Alves  <palves@redhat.com>

* tui/tui.c (tui_rl_switch_mode): Wrap tui_enable/tui_disable in
TRY_CATCH.

9 years agoPR tui/16138, PR tui/17519, and misc failures to initialize the terminal
Pedro Alves [Wed, 29 Oct 2014 14:23:57 +0000 (14:23 +0000)] 
PR tui/16138, PR tui/17519, and misc failures to initialize the terminal

PR tui/16138 is about failure to initialize curses resulting in GDB
exiting instead of throwing an error.  E.g.:

 $ TERM=foo gdb
 (gdb) layout asm
 Error opening terminal: foo.
 $

The problem is that we're calling initscr to initialize the screen.
As mentioned in
http://pubs.opengroup.org/onlinepubs/7908799/xcurses/initscr.html:

 If errors occur, initscr() writes an appropriate error message to
 standard error and exits.
                    ^^^^^

Instead, we should use newterm:

 "A program that needs an indication of error conditions, so it can
 continue to run in a line-oriented mode if the terminal cannot support
 a screen-oriented program, would also use this function."

After the patch:

 $ TERM=foo gdb -q -nx
 (gdb) layout asm
 Cannot enable the TUI: error opening terminal [TERM=foo]
 (gdb)

And then PR tui/17519 is about GDB not validating whether the terminal
has the necessary capabilities when enabling the TUI.  If one tries to
enable the TUI with TERM=dumb (and e.g., from a shell within emacs),
GDB ends up with a clear screen, the cursor is placed at the
bottom/right corner of the screen, there's no prompt, typing shows no
echo, and there's no indication of what's going on.  c-x,a gets you
out of the TUI, but it's completely non-obvious.

After the patch, we get:

 $ TERM=dumb gdb -q -nx
 (gdb) layout asm
 Cannot enable the TUI: terminal doesn't support cursor addressing [TERM=dumb]
 (gdb)

While at it, I've moved all the tui_allowed_p validation to
tui_enable, and expanded the error messages.  Previously we'd get:

 $ gdb -q -nx -i=mi
 (gdb)
 layout asm
 &"layout asm\n"
 &"TUI mode not allowed\n"
 ^error,msg="TUI mode not allowed"

and:

 $ gdb -q -nx -ex "layout asm" > foo
 TUI mode not allowed

While now we get:

 $ gdb -q -nx -i=mi
 (gdb)
 layout asm
 &"layout asm\n"
 &"Cannot enable the TUI when the interpreter is 'mi'\n"
 ^error,msg="Cannot enable the TUI when the interpreter is 'mi'"
 (gdb)

and:

 $ gdb -q -nx -ex "layout asm" > foo
 Cannot enable the TUI when output is not a terminal

Tested on x86_64 Fedora 20.

gdb/
2014-10-29  Pedro Alves  <palves@redhat.com>

PR tui/16138
PR tui/17519
* tui/tui-interp.c (tui_is_toplevel): Delete global.
(tui_allowed_p): Delete function.
* tui/tui.c: Include "interps.h".
(tui_enable): Don't use tui_allowed_p.  Error out here with
detailed error messages if the TUI is the top level interpreter,
or if output is not a terminal.  Use newterm instead of initscr,
and error out if initializing the terminal fails.  Also error out if
the terminal doesn't support cursor addressing.
* tui/tui.h (tui_allowed_p): Delete declaration.

9 years agoPrepare directory in case test_system fails
Yao Qi [Wed, 29 Oct 2014 13:43:05 +0000 (21:43 +0800)] 
Prepare directory in case test_system fails

In gdb.base/fileio.c, some functions may depend on others.  For
example, test_rename renames a file to one directory which is created
in test_system.  That is means, if test_system fails, test_rename
fails too, which is not a good practise, IMO.

In test_system, system ("mkdir -p XX") is used to create directories
needed for test_rename.  In this patch, we use dejagnu remote_exec
proc to create these directories on host.

In my gdb testing, mingw32 host and arm-none-eabi target, system
("mkdir -p XX") doesn't work properly (this issue can be addressed
separately), and this patch fixes the following fails.

FAIL: gdb.base/fileio.exp: Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST
FAIL: gdb.base/fileio.exp: Unlink a file
FAIL: gdb.base/fileio.exp: Unlinking a file in a directory w/o write access returns EACCES

gdb/testsuite:

2014-10-29  Yao Qi  <yao@codesourcery.com>

* gdb.base/fileio.exp: Make directories on host.

9 years agoClose the file in fileio.exp test
Yao Qi [Wed, 29 Oct 2014 13:43:05 +0000 (21:43 +0800)] 
Close the file in fileio.exp test

I see the following fail in fileio.exp on mingw32 host gdb,

rename 1: ret = -1, errno = 13^M
^M
Breakpoint 2, stop () at fileio.c:76^M
76      static void stop () {}^M
(gdb) FAIL: gdb.base/fileio.exp: Rename a file

the test fails to rename a file which is not expected.  The previous
test test_write doesn't close the file, so the rename fails as a
result on Windows.  This patch fixes it by closing file in test_write,
and the fail goes away.

rename 1: ret = 0, errno = 0 OK^M
^M
Breakpoint 2, stop () at fileio.c:76^M
76      static void stop () {}^M
(gdb) PASS: gdb.base/fileio.exp: Rename a file

gdb/testsuite:

2014-10-29  Yao Qi  <yao@codesourcery.com>

* gdb.base/fileio.c (test_write): Close the file.

9 years agoARM: stricter __stack_chk_guard check during prologue analysis
Joel Brobecker [Thu, 23 Oct 2014 15:25:20 +0000 (08:25 -0700)] 
ARM: stricter __stack_chk_guard check during prologue analysis

We are trying to insert a breakpoint on line 4 for the following
Ada code.

  3 procedure STR is
  4    XX : String (1 .. Blocks.Sz) := (others => 'X'); -- STOP
  5    K : Integer;
  6 begin
  7    K := 13;

The code generated on ARM (-march=armv7-m) starts like this:

    (gdb) disass str'address
    Dump of assembler code for function _ada_str:
       --# Line str.adb:3
       0x08000014 <+0>:     push    {r4, r7, lr}
       0x08000016 <+2>:     sub     sp, #28
       0x08000018 <+4>:     add     r7, sp, #0
       0x0800001a <+6>:     mov     r3, sp
       0x0800001c <+8>:     mov     r4, r3
       --# Line str.adb:4
       0x0800001e <+10>:    ldr     r3, [pc, #84]   ; (0x8000074 <_ada_str+96>)
       0x08000020 <+12>:    ldr     r3, [r3, #0]
       0x08000022 <+14>:    str     r3, [r7, #20]
       0x08000024 <+16>:    ldr     r3, [r7, #20]
       [...]

When computing the address related to str.adb:4, GDB correctly
resolves it to 0x0800001e first, but then considers the next
3 instructions as being part of the prologue because it thinks
they are part of stack-protector code. As a result, instead
of inserting the breakpoint at line 4, it skips those instruction
and consequently the rest of the instructions until the start
of the next line, which his line 7.

The stack-protector code is expected to start like this...

        ldr     Rn, .Label
        ....
        .Lable:
        .word   __stack_chk_guard

... but the implementation actually accepts a sequence where
the ldr location points to an address for which there is no symbol.
It only aborts if the address points to a symbol which is not
__stack_chk_guard.

Since the __stack_chk_guard symbol is always expected to exist
when used (it lives in .dynsym), this patch fixes the issue by
requiring that the ldr gets the address of the __stack_chk_guard
symbol. If the address could not be resolved, then it rejects
the sequence as being stack-protector code.

gdb/ChangeLog:

        * arm-tdep.c (arm_skip_stack_protector): Return early if
        address loaded by first "ldr" instruction does not have
        a corresponding minimal symbol.  Update comment.

Tested on arm-eabi using AdaCore's testsuite.
Tested on arm-linux-gnueabi by Yao as well.

9 years agoFix skipping stack protector on arm
Yao Qi [Wed, 29 Oct 2014 05:39:16 +0000 (13:39 +0800)] 
Fix skipping stack protector on arm

This patch fixes the bug in my patch skipping stack protector
https://www.sourceware.org/ml/gdb-patches/2010-12/msg00110.html

In my skipping stack protector patch, I misunderstood the constant vs.
immediate on instruction encodings, and treated immediate as constant
by mistake.  The instruction 'ldr Rd, [PC, #immed]' loads the
address of __stack_chk_guard to Rd, and #immed is an offset from PC.
We should get the __stack_chk_guard from *(pc + #immed).

As a result of this mistake, arm_analyze_load_stack_chk_guard returns
the wrong address of __stack_chk_guard, and the symbol
__stack_chk_guard can't be found.  However, we continue to match the
following instructions when symbol isn't found, so the code still
works.  In other words, the code just matches the instruction pattern
without checking __stack_chk_guard symbol correctly.

Joel's patch <https://sourceware.org/ml/gdb-patches/2014-10/msg00605.html>
makes the heuristics stricter that we stop matching instructions if
symbol __stack_chk_guard isn't found.  Then the bug is exposed.  This
patch is to correct the load address computation for ldr instruction,
and it fixes some fails in gdb.mi/gdb792.exp on armv4t both arm and
thumb mode.

Regression tested on arm-linux-gnueabi target with
{armv4t, armv7-a} x {marm, mthumb} x {-fstack-protector,-fno-stack-protector}

gdb:

2014-10-29  Yao Qi  <yao@codesourcery.com>

* arm-tdep.c (arm_analyze_load_stack_chk_guard): Compute the
loaded address correctly of ldr instruction.

9 years agodaily update
Alan Modra [Tue, 28 Oct 2014 23:01:03 +0000 (09:31 +1030)] 
daily update

9 years agoPR gdb/12623: non-stop crashes inferior, PC adjustment and 1-byte insns
Pedro Alves [Tue, 28 Oct 2014 13:42:11 +0000 (13:42 +0000)] 
PR gdb/12623: non-stop crashes inferior, PC adjustment and 1-byte insns

TL;DR - if we step an instruction that is as long as
decr_pc_after_break (1-byte on x86) right after removing the
breakpoint at PC, in non-stop mode, adjust_pc_after_break adjusts the
PC, but it shouldn't.

In non-stop mode, when a breakpoint is removed, it is moved to the
"moribund locations" list.  This is because other threads that are
running may have tripped on that breakpoint as well, and we haven't
heard about it.  When a trap is reported, we check if perhaps it was
such a deleted breakpoint that caused the trap.  If so, we also need
to adjust the PC (decr_pc_after_break).

Now, say that, on x86:

 - a breakpoint was placed at an address where we have an instruction
of the same length as decr_pc_after_break on this arch (1 on x86).

 - the breakpoint is removed, and thus put on the moribund locations
   list.

 - the thread is single-stepped.

As there's no breakpoint inserted at PC anymore, the single-step
actually executes the 1-byte instruction normally.  GDB should _not_
adjust the PC for the resulting SIGTRAP.  But, adjust_pc_after_break
confuses the step SIGTRAP reported for this single-step as being a
SIGTRAP for the moribund location of the breakpoint that used to be at
the previous PC, and so infrun applies the decr_pc_after_break
adjustment incorrectly.

The confusion comes from the special case mentioned in the comment:

 static void
 adjust_pc_after_break (struct execution_control_state *ecs)
 {
 ...
  As a special case, we could have hardware single-stepped a
  software breakpoint.  In this case (prev_pc == breakpoint_pc),
  we also need to back up to the breakpoint address.  */

       if (thread_has_single_step_breakpoints_set (ecs->event_thread)
   || !ptid_equal (ecs->ptid, inferior_ptid)
   || !currently_stepping (ecs->event_thread)
   || (ecs->event_thread->stepped_breakpoint
       && ecs->event_thread->prev_pc == breakpoint_pc))
 regcache_write_pc (regcache, breakpoint_pc);

The condition that incorrectly triggers is the
"ecs->event_thread->prev_pc == breakpoint_pc" one.

Afterwards, the next resume resume re-executes an instruction that had
already executed, which if you're lucky, results in the inferior
crashing.  If you're unlucky, you'll get silent bad behavior...

The fix is to remember that we stepped a breakpoint.  Turns out the
only case we step a breakpoint instruction today isn't covered by the
testsuite.  It's the case of a 'handle nostop" signal arriving while a
step is in progress _and_ we have a software watchpoint, which forces
always single-stepping.  This commit extends sigstep.exp to cover
that, and adds a new test for the adjust_pc_after_break issue.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-28  Pedro Alves  <palves@redhat.com>

PR gdb/12623
* gdbthread.h (struct thread_info) <stepped_breakpoint>: New
field.
* infrun.c (resume) <stepping breakpoint instruction>: Set the
thread's stepped_breakpoint field.  Skip if reverse debugging.
Add comment.
(init_thread_stepping_state, handle_signal_stop): Clear the
thread's stepped_breakpoint field.

gdb/testsuite/
2014-10-28  Pedro Alves  <palves@redhat.com>

PR gdb/12623
* gdb.base/sigstep.c (no_handler): New global.
(main): If 'no_handler is true, set the signal handlers to
SIG_IGN.
* gdb.base/sigstep.exp (breakpoint_over_handler): Add
with_sw_watch and no_handler parameters.  Handle them.
(top level) <stepping over handler when stopped at a breakpoint
test>: Add a test axis for testing with a software watchpoint, and
another for testing with the signal handler set to SIG_IGN.
* gdb.base/step-sw-breakpoint-adjust-pc.c: New file.
* gdb.base/step-sw-breakpoint-adjust-pc.exp: New file.

9 years agoTest for PR gdb/17511, spurious SIGTRAP after stepping into+in signal handler
Pedro Alves [Tue, 28 Oct 2014 15:51:30 +0000 (15:51 +0000)] 
Test for PR gdb/17511, spurious SIGTRAP after stepping into+in signal handler

I noticed that when I single-step into a signal handler with a
pending/queued signal, the following single-steps while the program is
in the signal handler leave $eflags.TF set.  That means subsequent
continues will trap after one instruction, resulting in a spurious
SIGTRAP being reported to the user.

This is a kernel bug; I've reported it to kernel devs (turned out to
be a known bug).  I'm seeing it on x86_64 Fedora 20 (Linux
3.16.4-200.fc20.x86_64), and I was told it's still not fixed upstream.

This commit extends gdb.base/sigstep.exp to cover this use case,
xfailed.

Here's what the bug looks like:

 (gdb) start
 Temporary breakpoint 1, main () at si-handler.c:48
 48        setup ();
 (gdb) next
 50        global = 0; /* set break here */

Let's queue a signal, so we can step into the handler:

 (gdb) handle SIGUSR1
 Signal        Stop      Print   Pass to program Description
 SIGUSR1       Yes       Yes     Yes             User defined signal 1
 (gdb) queue-signal SIGUSR1

TF is not set:

 (gdb) display $eflags
 1: $eflags = [ PF ZF IF ]

Now step into the handler -- "si" does PTRACE_SINGLESTEP+SIGUSR1:

 (gdb) si
 sigusr1_handler (sig=0) at si-handler.c:31
 31      {
 1: $eflags = [ PF ZF IF ]

No TF yet.  But another single-step...

 (gdb) si
 0x0000000000400621      31      {
 1: $eflags = [ PF ZF TF IF ]

... ends up with TF left set.  This results in PTRACE_CONTINUE
trapping after each instruction is executed:

 (gdb) c
 Continuing.

 Program received signal SIGTRAP, Trace/breakpoint trap.
 0x0000000000400624 in sigusr1_handler (sig=0) at si-handler.c:31
 31      {
 1: $eflags = [ PF ZF TF IF ]

 (gdb) c
 Continuing.

 Program received signal SIGTRAP, Trace/breakpoint trap.
 sigusr1_handler (sig=10) at si-handler.c:32
 32        global = 0;
 1: $eflags = [ PF ZF TF IF ]
 (gdb)

Note that even another PTRACE_SINGLESTEP does not fix it:

 (gdb) si
 33      }
 1: $eflags = [ PF ZF TF IF ]
 (gdb)

Eventually, it gets "fixed" by the rt_sigreturn syscall, when
returning out of the handler:

 (gdb) bt
 #0  sigusr1_handler (sig=10) at si-handler.c:33
 #1  <signal handler called>
 #2  main () at si-handler.c:50
 (gdb) set disassemble-next-line on
 (gdb) si
 0x0000000000400632      33      }
    0x0000000000400631 <sigusr1_handler+17>:     5d      pop    %rbp
 => 0x0000000000400632 <sigusr1_handler+18>:     c3      retq
 1: $eflags = [ PF ZF TF IF ]
 (gdb)
 <signal handler called>
 => 0x0000003b36a358f0 <__restore_rt+0>: 48 c7 c0 0f 00 00 00    mov    $0xf,%rax
 1: $eflags = [ PF ZF TF IF ]
 (gdb) si
 <signal handler called>
 => 0x0000003b36a358f7 <__restore_rt+7>: 0f 05   syscall
 1: $eflags = [ PF ZF TF IF ]
 (gdb)
 main () at si-handler.c:50
 50        global = 0; /* set break here */
 => 0x000000000040066b <main+9>: c7 05 cb 09 20 00 00 00 00 00   movl   $0x0,0x2009cb(%rip)        # 0x601040 <global>
 1: $eflags = [ PF ZF IF ]
 (gdb)

The bug doesn't happen if we instead PTRACE_CONTINUE into the signal
handler -- e.g., set a breakpoint in the handler, queue a signal, and
"continue".

gdb/testsuite/
2014-10-28  Pedro Alves  <palves@redhat.com>

PR gdb/17511
* gdb.base/sigstep.c (handler): Add a few more writes to 'done'.
* gdb.base/sigstep.exp (other_handler_location): New global.
(advance): Support stepping into the signal handler, and running
commands while in the handler.
(in_handler_map): New global.
(top level): In the advance test, add combinations for getting
into the handler with stepping commands, and for running commands
in the handler.  Add comment descripting the advancei tests.

9 years agoMore fixes for corrupt binaries crashing the binutils.
Nick Clifton [Tue, 28 Oct 2014 15:42:56 +0000 (15:42 +0000)] 
More fixes for corrupt binaries crashing the binutils.

PR binutils/17512
* elf.c (bfd_section_from_shdr): Allocate and free the recursion
detection table on a per-bfd basis.
* peXXigen.c (pe_print_edata): Handle binaries with a truncated
export table.

9 years agogdb.base/sigstep.exp: cleanup and make it easier to extend
Pedro Alves [Tue, 28 Oct 2014 13:42:10 +0000 (13:42 +0000)] 
gdb.base/sigstep.exp: cleanup and make it easier to extend

Hacking on sigstep.exp, I found it harder to understand and extend
than ideal.

 - GDB is currently not restarted between the different
   tests/combinations in the file, and some parts of the tests' setup
   are done on the top level, and shared between tests.  It's not
   trivial to understand which breakpoints each test procedure expects
   to be set or not set.  And it's not trivial to disable parts of the
   test if you want quickly try out just a subset of the tests
   (running the whole file takes a bit).

 - Because GDB is currently not restarted between tests, if some test
   triggers a ptrace/kernel bug, the following tests may end up with
   cascading fails.  That makes it hard to add a test to cover a
   kernel bug that isn't fixed yet, with a xfail/kfail.  E.g,. note
   how with kernels with bug gdb/8744 (stepi over sigreturn syscall
   exits program) the test program exits, and nothing restarts it
   afterwards...

 - The manual test message prefix management gets a bit in the way.
   Nowadays, we have with_test_prefix which makes it simpler.

 - 'i' is used as parameter name in the various procedures, meaning
   'the command the test', which isn't as obvious as it could.

This commit addresses all that.

gdb/testsuite/
2014-10-28  Pedro Alves  <palves@redhat.com>

* gdb.base/sigstep.exp: Use build_executable instead of
prepare_for_testing.
(top level): Move code that starts GDB, runs to main and creates a
display to ...
(restart): ... this new procedure.
(top level): Move backtrace from signal handler test to ...
(validate_backtrace): ... this new procedure.
(advance, advancei): Rename parameter from 'i' to 'cmd'.  Use
with_test_prefix.  Always restart GDB.
(skip_to_handler): Rename parameter from 'i' to 'cmd'.  Use
with_test_prefix.  Always restart GDB.  No need to delete
breakpoints after the test.
(test_skip_handler): Remove prefix parameter.
(skip_over_handler, breakpoint_to_handler)
(breakpoint_to_handler_entry, breakpoint_over_handler): Rename
parameter from 'i' to 'cmd'.  Use with_test_prefix.  Always
restart GDB.  No need to delete breakpoints after the test.
(top level): Use foreach to call the test procedures with
different commands.

9 years agoupdate bug numbers (GNATS -> Bugzilla) in a few signal related tests
Pedro Alves [Tue, 28 Oct 2014 14:32:51 +0000 (14:32 +0000)] 
update bug numbers (GNATS -> Bugzilla) in a few signal related tests

This makes it easier to find the bugs in Bugzilla.

gdb/testsuite/
2014-10-28  Pedro Alves  <palves@redhat.com>

* gdb.base/sigaltstack.exp: Update to use Bugzilla bug numbers
instead of GNATS numbers.
* gdb.base/sigbpt.exp: Likewise.
* gdb.base/siginfo.exp: Likewise.
* gdb.base/sigstep.exp: Likewise.

9 years agoWorkaround remote targets that report an empty list to qfThreadInfo
Pedro Alves [Tue, 28 Oct 2014 11:35:10 +0000 (11:35 +0000)] 
Workaround remote targets that report an empty list to qfThreadInfo

In https://sourceware.org/ml/gdb-patches/2014-10/msg00652.html, Sandra
shows a target that was broken by the recent update_thread_list
optimization:

 (gdb) target remote qa8-centos32-cs:10514
 ...
 (gdb) continue
 Continuing.
 Cannot execute this command without a live selected thread.
 (gdb)

The error means that the current thread is in "exited" state when the
continue command is processed.  The root of the problem was found
here:

 > Sending packet: $Hg0#df...Packet received:
 ...
 > Sending packet: $?#3f...Packet received: S00
 > Sending packet: $qfThreadInfo#bb...Packet received: l
 > Sending packet: $Hc-1#09...Packet received:
 > Sending packet: $qC#b4...Packet received: unset

This target doesn't really support threads (no thread indication in
stop reply packets; no support for qC), but then supports
qfThreadInfo, and returns an empty thread list to GDB.

See https://sourceware.org/ml/gdb-patches/2014-10/msg00665.html for
why the target does that.

As remote_update_thread_list deletes threads from GDB's list that are
not found in the thread list that the target reports, the result is
that GDB deletes the "fake" main thread that GDB added itself.  (As
that thread is currently selected, it is marked "exited" instead of
being deleted straight away.)

This commit avoids deleting the main thread in this scenario.

gdb/
2014-10-27  Pedro Alves  <palves@redhat.com>

* remote.c (remote_thread_alive): New, factored out from ...
(remote_thread_alive): ... this.
(remote_update_thread_list): Bail out before deleting threads if
the target returned an empty list, and, the current thread has a
magic/fake ptid.

9 years agoThis patch fixes a flaw in the SREC parser which could cause a stack overflow
Nick Clifton [Tue, 28 Oct 2014 10:48:14 +0000 (10:48 +0000)] 
This patch fixes a flaw in the SREC parser which could cause a stack overflow
and potential secuiryt breach.

PR binutils/17510
* srec.c (srec_bad_byte): Increase size of buf to allow for
negative values.
(srec_scan): Use an unsigned char buffer to hold header bytes.

9 years agodaily update
Alan Modra [Mon, 27 Oct 2014 23:00:34 +0000 (09:30 +1030)] 
daily update

9 years agostepi/nexti: skip signal handler if "handle nostop" signal arrives
Pedro Alves [Mon, 27 Oct 2014 20:24:59 +0000 (20:24 +0000)] 
stepi/nexti: skip signal handler if "handle nostop" signal arrives

I noticed that "si" behaves differently when a "handle nostop" signal
arrives while the step is in progress, depending on whether the
program was stopped at a breakpoint when "si" was entered.
Specifically, in case GDB needs to step off a breakpoint, the handler
is skipped and the program stops in the next "mainline" instruction.
Otherwise, the "si" stops in the first instruction of the signal
handler.

I was surprised the testsuite doesn't catch this difference.  Turns
out gdb.base/sigstep.exp covers a bunch of cases related to stepping
and signal handlers, but does not test stepi nor nexti, only
step/next/continue.

My first reaction was that stopping in the signal handler was the
correct thing to do, as it's where the next user-visible instruction
that is executed is.  I considered then "nexti" -- a signal handler
could be reasonably considered a subroutine call to step over, it'd
seem intuitive to me that "nexti" would skip it.

But then, I realized that signals that arrive while a plain/line
"step" is in progress _also_ have their handler skipped.  A user might
well be excused for being confused by this, given:

  (gdb) help step
  Step program until it reaches a different source line.

And the signal handler's sources will be in different source lines,
after all.

I think that having to explain that "stepi" steps into handlers, (and
that "nexti" wouldn't according to my reasoning above), while "step"
does not, is a sign of an awkward interface.

E.g., if a user truly is interested in stepping into signal handlers,
then it's odd that she has to either force the signal to "handle
stop", or recall to do "stepi" whenever such a signal might be
delivered.  For that use case, it'd seem nicer to me if "step" also
stepped into handlers.

This suggests to me that we either need a global "step-into-handlers"
setting, or perhaps better, make "handle pass/nopass stop/nostop
print/noprint" have have an additional axis - "handle
stepinto/nostepinto", so that the user could configure whether
handlers for specific signals should be stepped into.

In any case, I think it's simpler (and thus better) for all step
commands to behave the same.  This commit thus makes "si/ni" skip
handlers for "handle nostop" signals that arrive while the command was
already in progress, like step/next do.

To be clear, nothing changes if the program was stopped for a signal,
and the user enters a stepping command _then_ -- GDB still steps into
the handler.  The change concerns signals that don't cause a stop and
that arrive while the step is in progress.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-27  Pedro Alves  <palves@redhat.com>

* infrun.c (handle_signal_stop): Also skip handlers when a random
signal arrives while handling a "stepi" or a "nexti".  Set the
thread's 'step_after_step_resume_breakpoint' flag.

gdb/doc/
2014-10-27  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Continuing and Stepping): Add cross reference to
info on stepping and signal handlers.
(Signals): Explain stepping and signal handlers.  Add context
index entry, and cross references.

gdb/testsuite/
2014-10-27  Pedro Alves  <palves@redhat.com>

* gdb.base/sigstep.c (dummy): New global.
(main): Issue a couple writes to the new global.
* gdb.base/sigstep.exp (get_next_pc, test_skip_handler): New
procedures.
(skip_over_handler): Use test_skip_handler.
(top level): Call skip_over_handler for stepi and nexti too.
(breakpoint_over_handler): Use test_skip_handler.
(top level): Call breakpoint_over_handler for stepi and nexti too.

9 years agoThis fixes more seg-faults in tools like "strings" and "objdump" when
Nick Clifton [Mon, 27 Oct 2014 18:05:37 +0000 (18:05 +0000)] 
This fixes more seg-faults in tools like "strings" and "objdump" when
presented with corrupt binaries.

PR binutils/17512
* elf.c (bfd_section_from_shdr): Detect and warn about ELF
binaries with a group of sections linked by the string table
indicies.
* peXXigen.c (pe_print_edata): Detect out of range rvas and
entry counts for the Export Address table, Name Pointer table
 and Ordinal table.

9 years agoFix a seg-fault in strings and other binutuils when parsing a corrupt PE
Nick Clifton [Mon, 27 Oct 2014 14:45:06 +0000 (14:45 +0000)] 
Fix a seg-fault in strings and other binutuils when parsing a corrupt PE
executable with an invalid value in the NumberOfRvaAndSizes field of the
AOUT header.

PR binutils/17512
* peXXigen.c (_bfd_XXi_swap_aouthdr_in): Handle corrupt binaries
with an invalid value for NumberOfRvaAndSizes.

9 years agoThis patch closes a potential security hole in applications that use
Nick Clifton [Mon, 27 Oct 2014 12:43:16 +0000 (12:43 +0000)] 
This patch closes a potential security hole in applications that use
the bfd library to parse binaries containing maliciously corrupt section
group headers.

PR binutils/17510
* elf.c (setup_group): Improve handling of corrupt group
sections.

9 years agoFix trace file fails on powerpc64
Yao Qi [Mon, 27 Oct 2014 08:37:38 +0000 (16:37 +0800)] 
Fix trace file fails on powerpc64

I see the following fails on powerpc64-linux,

(gdb) target tfile tfile-basic.tf^M
warning: Uploaded tracepoint 1 has no source location, using raw address^M
Tracepoint 1 at 0x10012358^M
Created tracepoint 1 for target's tracepoint 1 at 0x10012358.^M
(gdb) PASS: gdb.trace/tfile.exp: target tfile tfile-basic.tf
info trace^M
Num     Type           Disp Enb Address            What^M
1       tracepoint     keep y   0x0000000010012358 <write_basic_trace_file>^M
        installed on target^M
(gdb) FAIL: gdb.trace/tfile.exp: info tracepoints on trace file

-target-select tfile tfile-basic.tf^M
=thread-group-started,id="i1",pid="1"^M
=thread-created,id="1",group-id="i1"^M
&"warning: Uploaded tracepoint 1 has no source location, using raw address\n"^M
=breakpoint-created,bkpt={number="1",type="tracepoint",disp="keep",enabled="y",
addr="0x0000000010012358",at="<write_basic_trace_file>",thread-groups=["i1"],
times="0",installed="y",original-location="*0x10012358"}^M
~"Created tracepoint 1 for target's tracepoint 1 at 0x10012358.\n"^M
^connected^M
(gdb) ^M
FAIL: gdb.trace/mi-traceframe-changed.exp: tfile: select trace file

These fails are caused by writing function descriptor address into trace
file instead of function address.  This patch is to teach tfile.c to
write function address on powerpc64 target.  With this patch applied,
fails in tfile.exp and mi-traceframe-changed.exp are fixed.  Is it
OK?

gdb/testsuite:

2014-10-27  Yao Qi  <yao@codesourcery.com>

* gdb.trace/tfile.c (adjust_function_address)
[__powerpc64__ && _CALL_ELF != 2]: Get function address from
function descriptor.

9 years agoFix ARM machine state testcase failures
Luis Machado [Mon, 27 Oct 2014 10:57:58 +0000 (08:57 -0200)] 
Fix ARM machine state testcase failures

When running GDB's reverse debugging testsuite against a few ARM
multilibs, i noticed failures in the machinestate* testcases.

Further investigation showed that push and pop instruction encodings
A1 and A2 were not being handled properly, thus we missed saving
important contents from registers and memory. When going backwards,
such contents were not restored and thus we ended up with a corrupted
state that did not correspond to the real values we had at a
particular point in time.

Attached is a patch that fixes around 36 failures for both
gdb.reverse/machinestate.exp and
gdb.reverse/machinestate-precsave.exp testcases, making them fully
pass. This is for both armv7 and armv4. I still see failures for
armv4 thumb though, so it needs a bit more investigation.

I see no regressions due to this patch for armv7, armv7 thumb, armv4
and armv4 thumb.

gdb/ChangeLog:

* arm-tdep.c (INSN_S_L_BIT_NUM): Document.
(arm_record_ld_st_imm_offset): Reimplement to cover all
load/store cases for ARM opcode 010.
(arm_record_ld_st_multiple): Reimplement to cover all
load/store cases for ARM opcode 100.

9 years agosymtab.c (lookup_symbol_aux_local): Fix typo in comment.
Doug Evans [Sun, 26 Oct 2014 23:46:52 +0000 (16:46 -0700)] 
symtab.c (lookup_symbol_aux_local): Fix typo in comment.

gdb/ChangeLog:

* symtab.c (lookup_symbol_aux_local): Fix typo in comment.

9 years agodaily update
Alan Modra [Sun, 26 Oct 2014 23:00:40 +0000 (09:30 +1030)] 
daily update

9 years agoRename parameter "kind" to "block_index" in quick lookup functions.
Doug Evans [Sun, 26 Oct 2014 20:53:58 +0000 (13:53 -0700)] 
Rename parameter "kind" to "block_index" in quick lookup functions.

gdb/ChangeLog:

* symfile.h (struct quick_symbol_functions) <lookup_symbol>: Rename
parameter "kind" to "block_index".
* symtab.c (error_in_psymtab_expansion): Rename parameter "kind" to
"block_index".
(lookup_symbol_aux_quick, basic_lookup_transparent_type_quick): Ditto.

9 years ago* block.h (ALL_BLOCK_SYMBOLS): Fix comment.
Doug Evans [Sun, 26 Oct 2014 19:26:20 +0000 (12:26 -0700)] 
* block.h (ALL_BLOCK_SYMBOLS): Fix comment.

gdb/ChangeLog:

* block.h (ALL_BLOCK_SYMBOLS): Fix comment.

9 years agoblock.c (allocate_block): Use OBSTACK_ZALLOC instead of obstack_alloc.
Doug Evans [Sun, 26 Oct 2014 18:36:59 +0000 (11:36 -0700)] 
block.c (allocate_block): Use OBSTACK_ZALLOC instead of obstack_alloc.

gdb/ChangeLog:

* block.c (allocate_block): Use OBSTACK_ZALLOC instead of
obstack_alloc.

9 years agoMove block_found decl to symtab.h.
Doug Evans [Sun, 26 Oct 2014 17:42:26 +0000 (10:42 -0700)] 
Move block_found decl to symtab.h.

gdb/ChangeLog:

* parser-defs.h (block_found): Move decl from here ...
* symtab.h (block_found): ... to here.

9 years agoClean up some function comments in symtab.[ch].
Doug Evans [Sun, 26 Oct 2014 16:35:53 +0000 (09:35 -0700)] 
Clean up some function comments in symtab.[ch].

gdb/ChangeLog:

* symtab.h (struct field_of_this_result): Fix typo in comment.
(lookup_symbol_in_language): Move function comment here.
(lookup_symbol): Improve function comment.
(basic_lookup_symbol_nonlocal): Ditto.
(lookup_symbol_static, lookup_symbol_global): Ditto.
(lookup_symbol_aux_block): Ditto.
(lookup_language_this): Add function comment.
(lookup_static_symbol_aux): Explicitly mark as extern.  Improve
function comment.
(lookup_block_symbol): Improve function comment.
(lookup_struct): Fix capitalization in function comment.
(lookup_transparent_type): Add function comment.
(lookup_global_symbol_from_objfile): Explicitly mark as extern.
Improve function comment.
(lookup_objfile_from_block): Add function comment.
* symtab.c (lookup_symbol_in_language): Update function comment.
(lookup_symbol, lookup_language_this): Ditto.
(lookup_static_symbol_aux, lookup_objfile_from_block): Ditto.
(lookup_symbol_aux_block, lookup_global_symbol_from_objfile): Ditto.
(basic_lookup_symbol_nonlocal): Ditto.
(lookup_symbol_static, lookup_symbol_global): Ditto.
(lookup_transparent_type, lookup_block_symbol): Ditto.

9 years agosymtab.c: forward decl cleanup
Doug Evans [Sun, 26 Oct 2014 05:22:47 +0000 (22:22 -0700)] 
symtab.c: forward decl cleanup

gdb/ChangeLog:

* symtab.c (types_info): Delete forward decl.
(functions_info, variables_info, sources_info): Ditto.
(_initialize_symtab): Rewrite forward decl to use
initialize_file_ftype.

9 years agosymtab.c (lookup_symbol_aux_quick): Set block_found upon success.
Doug Evans [Sun, 26 Oct 2014 05:07:54 +0000 (22:07 -0700)] 
symtab.c (lookup_symbol_aux_quick): Set block_found upon success.

gdb/ChangeLog:

* symtab.c (lookup_symbol_aux_quick): Set block_found upon success.

9 years agoRemove second (nested) copy of local var child_die.
Doug Evans [Sun, 26 Oct 2014 04:46:00 +0000 (21:46 -0700)] 
Remove second (nested) copy of local var child_die.

gdb/ChangeLog:

* dwarf2read.c (process_structure_scope): Remove second (nested) copy
of local var child_die.

9 years agodaily update
Alan Modra [Sat, 25 Oct 2014 23:00:31 +0000 (09:30 +1030)] 
daily update

9 years agodaily update
Alan Modra [Fri, 24 Oct 2014 23:01:03 +0000 (09:31 +1030)] 
daily update

9 years agoFollow-fork message printing improvements
Don Breazeal [Fri, 24 Oct 2014 18:36:06 +0000 (11:36 -0700)] 
Follow-fork message printing improvements

This commit modifies the code that prints attach and detach messages
related to following fork and vfork.  The changes include using
target_terminal_ours_for_output instead of target_terminal_ours,
printing "vfork" instead of "fork" for all vfork-related messages,
and using _() for the format strings of all of the messages.

We also add a "detach" message for when a fork parent is detached.
Previously in this case the only message was notification of attaching
to the child.  We still do not print any messages when following the
parent and detaching the child (the default).  The rationale for this
is that from the user's perspective the new child was never attached.

Note that all of these messages are only printed when 'verbose' is set
or when debugging is turned on.

The tests gdb.base/foll-fork.exp and gdb.base/foll-vfork.exp were
modified to check for the new message.

Tested on x64 Ubuntu Lucid, native only.

gdb/ChangeLog:

* infrun.c (follow_fork_inferior): Update fork message printing
to use target_terminal_ours_for_output instead of
target_terminal_ours, to use _() for all format strings, to print
"vfork" instead of "fork" for vforks, and to add a detach message.
(handle_vfork_child_exec_or_exit): Update message printing to use
target_terminal_ours_for_output instead of target_terminal_ours, to
use _() for all format strings, and to fix some formatting.

gdb/testsuite/ChangeLog:

* gdb.base/foll-fork.exp (test_follow_fork,
catch_fork_child_follow): Check for updated fork messages emitted
from infrun.c.
* gdb.base/foll-vfork.exp (vfork_parent_follow_through_step,
vfork_parent_follow_to_bp, vfork_and_exec_child_follow_to_main_bp,
vfork_and_exec_child_follow_through_step): Check for updated vfork
messages emitted from infrun.c.

9 years agoRemove Vax Ultrix and VAX BSD support
Pedro Alves [Fri, 17 Oct 2014 13:49:04 +0000 (14:49 +0100)] 
Remove Vax Ultrix and VAX BSD support

Built and tested on x86_64 Fedora 20, with --enable-targets=all.

gdb/
2014-10-24  Pedro Alves  <palves@redhat.com>

* Makefile.in (ALLDEPFILES): Remove vax-nat.c.
* NEWS (Removed targets): Add VAX BSD and VAX Ultrix.
* config/vax/vax.mh: Delete.
* configure.host: Move vax-*-bsd* and vax-*-ultrix* to the
obsolete configurations section.
* configure.tgt (vax-*-*): Don't mention 4.2BSD nor Ultrix.
* vax-nat.c: Delete file.

gdb/testsuite/
2014-10-24  Pedro Alves  <palves@redhat.com>

* gdb.base/corefile.exp: Remove references to ultrix.
* gdb.base/interrupt.exp: Likewise.
* gdb.base/whatis.exp: Likewise.
* gdb.gdb/selftest.exp: Likewise.
* gdb.threads/manythreads.exp: Likewise.
* gdb.threads/print-threads.exp: Likewise.
* gdb.threads/pthreads.exp:: Likewise.
* gdb.threads/schedlock.exp: Likewise.

9 years agoNEWS: Clarify removed targets
Pedro Alves [Fri, 24 Oct 2014 16:56:29 +0000 (17:56 +0100)] 
NEWS: Clarify removed targets

gdb/
2014-10-24  Pedro Alves  <palves@redhat.com>

* NEWS (Removed targets): Add OS/arch column.

9 years agoGuard a call to TYPE_TARGET_TYPE in gnuv3_pass_by_reference.
Siva Chandra [Thu, 16 Oct 2014 14:14:13 +0000 (07:14 -0700)] 
Guard a call to TYPE_TARGET_TYPE in gnuv3_pass_by_reference.

gdb/ChangeLog:

* gnu-v3-abi.c (gnuv3_pass_by_reference): Call TYPE_TARGET_TYPE
on the arg type of a constructor only if it is of reference type.

gdb/testsuite/ChangeLog:

* gdb.cp/non-trivial-retval.cc: Add a test case.
* gdb.cp/non-trivial-retval.exp: Add a test.

9 years ago[AArch64] Cortex-A53 erratum 835769 linker workaround
Jiong Wang [Fri, 24 Oct 2014 10:39:35 +0000 (11:39 +0100)] 
[AArch64] Cortex-A53 erratum 835769 linker workaround

2014-10-22  Tejas Belagod  <tejas.belagod@arm.com>

bfd/
* bfd-in.h (bfd_elf64_aarch64_set_options): Add a parameter.
* bfd-in2.h (bfd_elf64_aarch64_set_options): Likewise.
* elfnn-aarch64.c (aarch64_erratum_835769_stub): New.
(elf_aarch64_stub_type): Add new type
aarch64_stub_erratum_835769_veneer.
(elf_aarch64_stub_hash_entry): New fields for erratum 835769.
(aarch64_erratum_835769_fix): New data struct to record erratum
835769.
(elf_aarch64_link_hash_table: Global flags for 835769.
(aarch64_build_one_stub): Add case for 835769.
(aarch64_size_one_stub): Likewise.
(aarch64_mem_op_p, aarch64_mlxl_p,
aarch64_erratum_sequence,erratum_835769_scan):
New. Decode and scan functions for erratum 835769.
(elf_aarch64_create_or_find_stub_sec): New.
(elfNN_aarch64_size_stubs): Look for erratum 835769 and record
them.
(bfd_elfNN_aarch64_set_options: Set global flag for 835769.
(erratum_835769_branch_to_stub_data,
make_branch_to_erratum_835769_stub):New. Connect up all the
erratum stubs to occurances by branches.
(elfNN_aarch64_write_section): New hook.
(aarch64_map_one_stub): Output erratum stub symbol.
(elfNN_aarch64_size_dynamic_sections): Init mapping symbol
information for erratum 835769.
(elf_backend_write_section): Define.

ld/
* emultempl/aarch64elf.em: Add command-line option for erratum
835769.

ld/testsuite/

* ld-aarch64/aarch64-elf.exp (aarch64elftests): Drive erratum
835769 tests.
* ld-aarch64/erratum835769.d: New.
* ld-aarch64/erratum835769.s: New.

9 years agodaily update
Alan Modra [Thu, 23 Oct 2014 23:00:51 +0000 (09:30 +1030)] 
daily update

9 years agoRefactoring/cleanup of nios2 opcodes and assembler code.
Sandra Loosemore [Thu, 23 Oct 2014 16:54:15 +0000 (09:54 -0700)] 
Refactoring/cleanup of nios2 opcodes and assembler code.

2014-10-23  Sandra Loosemore  <sandra@codesourcery.com>

include/opcode/
* nios2.h (enum iw_format_type): New.
(struct nios2_opcode): Update comments.  Add size and format fields.
(NIOS2_INSN_OPTARG): New.
(REG_NORMAL, REG_CONTROL, REG_COPROCESSOR): New.
(struct nios2_reg): Add regtype field.
(GET_INSN_FIELD, SET_INSN_FIELD): Delete.
(IW_A_LSB, IW_A_MSB, IW_A_SZ, IW_A_MASK): Delete.
(IW_B_LSB, IW_B_MSB, IW_B_SZ, IW_B_MASK): Delete.
(IW_C_LSB, IW_C_MSB, IW_C_SZ, IW_C_MASK): Delete.
(IW_IMM16_LSB, IW_IMM16_MSB, IW_IMM16_SZ, IW_IMM16_MASK): Delete.
(IW_IMM26_LSB, IW_IMM26_MSB, IW_IMM26_SZ, IW_IMM26_MASK): Delete.
(IW_OP_LSB, IW_OP_MSB, IW_OP_SZ, IW_OP_MASK): Delete.
(IW_OPX_LSB, IW_OPX_MSB, IW_OPX_SZ, IW_OPX_MASK): Delete.
(IW_SHIFT_IMM5_LSB, IW_SHIFT_IMM5_MSB): Delete.
(IW_SHIFT_IMM5_SZ, IW_SHIFT_IMM5_MASK): Delete.
(IW_CONTROL_REGNUM_LSB, IW_CONTROL_REGNUM_MSB): Delete.
(IW_CONTROL_REGNUM_SZ, IW_CONTROL_REGNUM_MASK): Delete.
(OP_MASK_OP, OP_SH_OP): Delete.
(OP_MASK_IOP, OP_SH_IOP): Delete.
(OP_MASK_IRD, OP_SH_IRD): Delete.
(OP_MASK_IRT, OP_SH_IRT): Delete.
(OP_MASK_IRS, OP_SH_IRS): Delete.
(OP_MASK_ROP, OP_SH_ROP): Delete.
(OP_MASK_RRD, OP_SH_RRD): Delete.
(OP_MASK_RRT, OP_SH_RRT): Delete.
(OP_MASK_RRS, OP_SH_RRS): Delete.
(OP_MASK_JOP, OP_SH_JOP): Delete.
(OP_MASK_IMM26, OP_SH_IMM26): Delete.
(OP_MASK_RCTL, OP_SH_RCTL): Delete.
(OP_MASK_IMM5, OP_SH_IMM5): Delete.
(OP_MASK_CACHE_OPX, OP_SH_CACHE_OPX): Delete.
(OP_MASK_CACHE_RRS, OP_SH_CACHE_RRS): Delete.
(OP_MASK_CUSTOM_A, OP_SH_CUSTOM_A): Delete.
(OP_MASK_CUSTOM_B, OP_SH_CUSTOM_B): Delete.
(OP_MASK_CUSTOM_C, OP_SH_CUSTOM_C): Delete.
(OP_MASK_CUSTOM_N, OP_SH_CUSTOM_N): Delete.
(OP_<insn>, OPX_<insn>, OP_MATCH_<insn>, OPX_MATCH_<insn>): Delete.
(OP_MASK_<insn>, OP_MASK): Delete.
(GET_IW_A, GET_IW_B, GET_IW_C, GET_IW_CONTROL_REGNUM): Delete.
(GET_IW_IMM16, GET_IW_IMM26, GET_IW_OP, GET_IW_OPX): Delete.
Include nios2r1.h to define new instruction opcode constants
and accessors.
(nios2_builtin_opcodes): Rename to nios2_r1_opcodes.
(bfd_nios2_num_builtin_opcodes): Rename to nios2_num_r1_opcodes.
(bfd_nios2_num_opcodes): Rename to nios2_num_opcodes.
(NUMOPCODES, NUMREGISTERS): Delete.
* nios2r1.h: New file.

opcodes/
* nios2-opc.c (nios2_builtin_regs): Add regtype field initializers.
(nios2_builtin_opcodes): Rename to nios2_r1_opcodes.  Use new
MATCH_R1_<insn> and MASK_R1_<insn> macros in initializers.  Add
size and format initializers.  Merge 'b' arguments into 'j'.
(NIOS2_NUM_OPCODES): Adjust definition.
(bfd_nios2_num_builtin_opcodes): Rename to nios2_num_r1_opcodes.
(nios2_opcodes): Adjust.
(bfd_nios2_num_opcodes): Rename to nios2_num_opcodes.
* nios2-dis.c (INSNLEN): Update comment.
(nios2_hash_init, nios2_hash): Delete.
(OPCODE_HASH_SIZE): New.
(nios2_r1_extract_opcode): New.
(nios2_disassembler_state): New.
(nios2_r1_disassembler_state): New.
(nios2_init_opcode_hash): Add state parameter.  Adjust to use it.
(nios2_find_opcode_hash): Use state object.
(bad_opcode): New.
(nios2_print_insn_arg): Add op parameter.  Use it to access
format.  Remove 'b' case.
(nios2_disassemble): Remove special case for nop.  Remove
hard-coded instruction size.

gas/
* config/tc-nios2.c (nios2_insn_infoS): Add constant_bits field.
(nios2_arg_infoS, nios2_arg_hash, nios2_arg_lookup): Delete.
(nios2_control_register_arg_p): Delete.
(nios2_coproc_reg): Delete.
(nios2_relax_frag): Remove hard-coded instruction size.
(md_convert_frag): Use new insn accessor macros.
(nios2_diagnose_overflow): Remove hard-coded instruction size.
(md_apply_fix): Likewise.
(bad_opcode): New.
(nios2_parse_reg): New.
(nios2_assemble_expression): Remove prev_reloc parameter.  Adjust
uses and callers.
(nios2_assemble_arg_c): New.
(nios2_assemble_arg_d): New.
(nios2_assemble_arg_s): New.
(nios2_assemble_arg_t): New.
(nios2_assemble_arg_i): New.
(nios2_assemble_arg_u): New.
(nios2_assemble_arg_o): New.
(nios2_assemble_arg_j): New.
(nios2_assemble_arg_l): New.
(nios2_assemble_arg_m): New.
(nios2_assemble_args): New.
(nios2_assemble_args_dst): Delete.
(nios2_assemble_args_tsi): Delete.
(nios2_assemble_args_tsu): Delete.
(nios2_assemble_args_sto): Delete.
(nios2_assemble_args_o): Delete.
(nios2_assemble_args_is): Delete.
(nios2_assemble_args_m): Delete.
(nios2_assemble_args_s): Delete.
(nios2_assemble_args_tis): Delete.
(nios2_assemble_args_dc): Delete.
(nios2_assemble_args_cs): Delete.
(nios2_assemble_args_ds): Delete.
(nios2_assemble_args_ldst): Delete.
(nios2_assemble_args_none): Delete.
(nios2_assemble_args_dsj): Delete.
(nios2_assemble_args_d): Delete.
(nios2_assemble_args_b): Delete.
(nios2_arg_info_structs): Delete.
(NIOS2_NUM_ARGS): Delete.
(nios2_consume_arg): Remove insn parameter.  Use new macros.
Don't check register arguments here.  Remove 'b' case.
(nios2_consume_separator): Move check for missing separators to...
(nios2_parse_args): ...here.  Remove special case for optional
arguments.
(output_insn): Avoid using hard-coded insn size.
(output_ubranch): Likewise.
(output_cbranch): Likewise.
(output_call): Use new macros.
(output_addi): Likewise.
(output_ori): Likewise.
(output_xori): Likewise.
(output_movia): Likewise.
(md_begin): Remove nios2_arg_info_structs initialization.
(md_assemble): Initialize constant_bits field.  Use
nios2_parse_args instead of looking up parse function in hash table.

gdb/
* nios2-tdep.c (nios2_analyze_prologue): Use new instruction field
accessors and constants from nios2 opcodes update.
(nios2_get_next_pc): Likewise.

9 years agoARM: plt_size functions need to read instructions in right byte order
Victor Kamensky [Thu, 23 Oct 2014 01:23:53 +0000 (11:53 +1030)] 
ARM: plt_size functions need to read instructions in right byte order

elf32_arm_plt0_size and elf32_arm_plt_size read instructions
to determine what is size of PLT entry.  However it does not
read instruction correctly in case of ARM big endian V7 case.
In this case instructions are still kept in little endian
order (BE8).

* elf32-arm.c (read_code32): New function to read 32 bit
arm instruction.
(read_code16): New function to read 16 bit thumb instrution.
(elf32_arm_plt0_size, elf32_arm_plt_size): Use read_code32
and read_code16 to read instructions.

9 years agodaily update
Alan Modra [Wed, 22 Oct 2014 23:00:53 +0000 (09:30 +1030)] 
daily update

9 years agoMIPS Documentation fixes
Matthew Fortune [Tue, 21 Oct 2014 10:58:19 +0000 (11:58 +0100)] 
MIPS Documentation fixes

gas/
* doc/as.texinfo: Update the MIPS FP ABI descriptions.
* doc/c-mips.texi: Spell check and correct throughout.

9 years agoShow information about unknown ASEs and extensions in .MIPS.abiflags
Matthew Fortune [Fri, 17 Oct 2014 10:07:17 +0000 (11:07 +0100)] 
Show information about unknown ASEs and extensions in .MIPS.abiflags

bfd/
* elfxx-mips.c (print_mips_ases): Print unknown ASEs.
(print_mips_isa_ext): Print the value of an unknown extension.

binutils/

* readelf.c (print_mips_ases): Print unknown ASEs.
(print_mips_isa_ext): Print the value of an unknown extension.

include/

* elf/mips.h (AFL_ASE_MASK): Define.

9 years agodaily update
Alan Modra [Tue, 21 Oct 2014 23:00:32 +0000 (09:30 +1030)] 
daily update

9 years agoMIPS/GAS: Correct file option settings with `.insn'
Maciej W. Rozycki [Tue, 21 Oct 2014 22:06:23 +0000 (23:06 +0100)] 
MIPS/GAS: Correct file option settings with `.insn'

This makes sure `HAVE_CODE_COMPRESSION' evaluates correctly when the
`.insn' directive is used at the beginning of a source file before any
instructions have been produced and that ELF file header's MIPS16 and
microMIPS ASE flags are set correctly in the case where no instructions
have been produced other than with the said directive.

gas/
* config/tc-mips.c (s_insn): Set file options.

gas/testsuite/
* gas/mips/insn-opts.d: New test.
* gas/mips/insn-opts.s: New test source.
* gas/mips/mips.exp: Run the new test.

9 years ago[GOLD] Add gcc-4.9 libgomp symbols requiring --plt-thread-safe for power7
Alan Modra [Tue, 21 Oct 2014 21:38:30 +0000 (08:08 +1030)] 
[GOLD] Add gcc-4.9 libgomp symbols requiring --plt-thread-safe for power7

As for bfd.ld.  Refer 2300b5a14

* powerpc.cc (do_relax): Add gcc-4.9 libgomp functions to
thread_starter.

9 years ago[AARCH64] Add thunderx support to gas
Andrew Pinski [Mon, 20 Oct 2014 18:39:49 +0000 (11:39 -0700)] 
[AARCH64] Add thunderx support to gas

This patch adds -mcpu=thunderx support to gas.

OK? Tested with no regressions.

ChangeLog:
* config/tc-aarch64.c (aarch64_cpus):
Add thunderx.
* doc/c-aarch64.texi: Document that thunderx
is a valid processor name.

9 years agoRelax ppc64_elf_tls_optimize assertion
Alan Modra [Tue, 21 Oct 2014 10:14:38 +0000 (20:44 +1030)] 
Relax ppc64_elf_tls_optimize assertion

The code in ppc64_elf_tls_optimize looking at the .toc is only
interested in .toc entries that are addresses.  .toc can contain more
than just an array of addresses, so if we have items that aren't
8-byte aligned, ignore them.

* elf64-ppc.c (ppc64_elf_tls_optimize): Ignore relocs against toc
entries that aren't a multiple of 8 rather than failing assertion.

9 years agogas: avoid bogus warnings in false branches of conditional
Jan Beulich [Tue, 21 Oct 2014 07:57:41 +0000 (09:57 +0200)] 
gas: avoid bogus warnings in false branches of conditional

The construct being added to the cond.s test case otherwise triggered
both the "missing closing ..." and the "stray ..." (twice) warnings in
_find_end_of_line(). As that code fragments suggests, this is needed to
support (include) files that can be used for both assembler .include
and compiler #include directives.

9 years agoppc: enable msgclr and msgsnd on Power8
Jan Beulich [Tue, 21 Oct 2014 07:56:38 +0000 (09:56 +0200)] 
ppc: enable msgclr and msgsnd on Power8

According to my reading of the spec it was an oversight for them to
not having got enabled when Power8 support got added.

9 years agoaarch64: move bogus assertion
Jan Beulich [Tue, 21 Oct 2014 07:53:25 +0000 (09:53 +0200)] 
aarch64: move bogus assertion

Asserting "idx" to be non-negative when subsequent code handles this
case is bogus. In fact the assertion triggers e.g. when mistakenly
using the arm32 comment character @ following an instruction.

While doing this I also noticed that despite there being local
variables "detail" and "idx", not all places where they could be used
did actually make use of them, so this is being adjusted at once.

Finally, for the code to be slightly more robust, also change
comparisons against -1 to such checking for a (non-)negative value.

9 years agoAdd gcc-4.9 libgomp symbols requiring --plt-thread-safe for power7
Alan Modra [Tue, 21 Oct 2014 06:36:01 +0000 (17:06 +1030)] 
Add gcc-4.9 libgomp symbols requiring --plt-thread-safe for power7

powerpc64 ld builds plt call stubs with a read barrier to provide
thread safety on lazy plt updates, necessary on multi-threaded apps
with power7 or later weakly ordered memory.  gcc-4.9 libgomp
introduced more functions that could call pthread_create, which means
we have more functions that if referenced in an executable should
cause a default of --plt-thread-safe.

* elf64-ppc.c (ppc64_elf_size_stubs): Add gcc-4.9 libgomp functions
to thread_starter.

9 years agodaily update
Alan Modra [Mon, 20 Oct 2014 23:00:53 +0000 (09:30 +1030)] 
daily update

9 years agoSmall fixes to the Python API doc
Simon Marchi [Mon, 20 Oct 2014 17:29:36 +0000 (13:29 -0400)] 
Small fixes to the Python API doc

First:
"Breakpoint.delete" is missing parenthesis.

Second:
Someone on IRC asked, how come there is no disable() method in the
Breakpoint object.  It turns out you have to do "bp.enabled = False".
Since every normal person would probably search for "disable" in that page
if their intent is to disable a python breakpoint, I thought it would be
useful if the description contained "disable" so it would be easy to find.
The result might seem a bit silly and redundant, so I am open to
suggestions.

gdb/doc/ChangeLog:

* python.texi (Breakpoints In Python): Add parenthesis after
Breakpoint.delete.  Clarify Breakpoint.enabled description so
that it contains "disable".

9 years agoRename py-objfile-script-gdb.py.in to py-objfile-script-gdb.py
Yao Qi [Mon, 29 Sep 2014 13:37:32 +0000 (21:37 +0800)] 
Rename py-objfile-script-gdb.py.in to py-objfile-script-gdb.py

Patch <https://sourceware.org/ml/gdb-patches/2011-07/msg00225.html> was
to fix the problem that py-objfile-script-gdb.py is removed after an
in-tree build and test.  As a result of the previous patch (we don't
remove files copied to host any more), this patch is no longer needed.
This patch is to revert it logically.

gdb/testsuite:

2014-10-20  Yao Qi  <yao@codesourcery.com>

* gdb.python/py-objfile-script-gdb.py.in: Rename it to ...
* gdb.python/py-objfile-script-gdb.py: New file.
* gdb.python/py-objfile-script.exp: Update reference to
py-objfile-script-gdb.py.in.  Use gdb_remote_donwload instead
of remote_download.  Remove the dest file.

9 years agoDon't remove files copied to host
Yao Qi [Mon, 29 Sep 2014 12:47:30 +0000 (20:47 +0800)] 
Don't remove files copied to host

Nowadays, if we do in-tree build and run tests sequentially, some source
files are removed, due to the following pattern:

set pi_txt [gdb_remote_download host ${srcdir}/${subdir}/pi.txt]

remote_exec host "rm -f $pi_txt"

If testing is run sequentially, file ${srcdir}/${subdir}/pi.txt is
copied to ${objdir}/${subdir}/pi.txt.  However, ${objdir} is ${srcdir}
in the in-tree build/test, so the file is coped to itself, as a nop.
As a result, the file in source is removed at the end of test.

This patch fixes this problem by not removing files copied to host in
each test.  This patch also addresses the question we've had that why
don't we keep files copied to host because they are needed to reproduce
certain fails.

gdb/testsuite:

2014-10-20  Yao Qi  <yao@codesourcery.com>

* gdb.base/checkpoint.exp: Don't remove file copied on host.
* gdb.base/step-line.exp: Likewise.
* gdb.dwarf2/dw2-anonymous-func.exp: Likewise.
* gdb.dwarf2/dw2-basic.exp: Likewise.
* gdb.dwarf2/dw2-compressed.exp: Likewise.
* gdb.dwarf2/dw2-filename.exp: Likewise.
* gdb.dwarf2/dw2-intercu.exp: Likewise.
* gdb.dwarf2/dw2-intermix.exp: Likewise.
* gdb.dwarf2/dw2-producer.exp: Likewise.
* gdb.dwarf2/mac-fileno.exp: Likewise.
* gdb.python/py-frame-args.exp: Likewise.
* gdb.python/py-framefilter.exp: Likewise.
* gdb.python/py-mi.exp: Likewise.
* gdb.python/py-objfile-script.exp: Likewise
* gdb.python/py-pp-integral.exp: Likewise.
* gdb.python/py-pp-re-notag.exp: Likewise.
* gdb.python/py-prettyprint.exp: Likewise.
* gdb.python/py-section-script.exp: Likewise.
* gdb.python/py-typeprint.exp: Likewise.
* gdb.python/py-xmethods.exp: Likewise.
* gdb.stabs/weird.exp: Likewise.
* gdb.xml/tdesc-regs.exp: Likewise.

9 years agodaily update
Alan Modra [Sun, 19 Oct 2014 23:00:41 +0000 (09:30 +1030)] 
daily update

9 years agoFix some comments to say minus_one_ptid instead of PID == -1.
Doug Evans [Sun, 19 Oct 2014 20:36:54 +0000 (13:36 -0700)] 
Fix some comments to say minus_one_ptid instead of PID == -1.

gdb/ChangeLog:

* gdbthread.h (set_running): Fix comment.
(set_executing, finish_thread_state): Fix comment.

9 years agolinux-nat.c (linux_nat_wait_1): Make local prev_mask non-static.
Doug Evans [Sun, 19 Oct 2014 04:24:47 +0000 (21:24 -0700)] 
linux-nat.c (linux_nat_wait_1): Make local prev_mask non-static.

gdb/ChangeLog:

linux-nat.c (linux_nat_wait_1): Make local prev_mask non-static.

9 years agodaily update
Alan Modra [Sat, 18 Oct 2014 23:00:47 +0000 (09:30 +1030)] 
daily update

9 years agoFix the gdb.dwarf2/dw2-dir-file-name.exp test on MIPS
Kwok Cheung Yeung [Sat, 18 Oct 2014 20:45:36 +0000 (21:45 +0100)] 
Fix the gdb.dwarf2/dw2-dir-file-name.exp test on MIPS

This patch fixes the failures that occur with the
gdb.dwarf2/dw2-dir-file-name.exp test on 64-bit MIPS and compressed
MIPS ISAs (i.e. MIPS16 and microMIPS).

The failures on 64-bit occur because the generated DWARF address
information is always 32-bit, which causes the upper 32-bits of
addresses to be truncated and causes breakpoints to be set on the
wrong address if any of the upper 32-bits are non-zero.  I suspect
that other 64-bit architectures get away with it because they
place all their instructions at a VMA lower than 2^32 by default.
This patch causes 64-bit addresses to be generated if a 64-bit
target is detected.

The failures on MIPS16 and microMIPS occur because the breakpoint
address needs to have the LSB set to 1 (used to indicate that the
code is compressed). However, the function name is interpreted as
a data label, causing GDB to set breakpoints at even addresses.
This is fixed by explicitly adding a '.insn' directive (see
https://sourceware.org/binutils/docs/as/MIPS-insn.html) after the
label on MIPS only.

gdb/testsuite/

2014-10-18  Kwok Cheung Yeung  <kcy@codesourcery.com>

* gdb.dwarf2/dw2-dir-file-name.exp (addr_len): New.
(out_cu): Use addr_len for the size of addresses.
(out_line): Likewise.  Size DW_LNE_set_address instruction
according to addr_len.
* gdb.dwarf2/dw2-dir-file-name.c (START_INSNS): New.
(FUNC): Add START_INSNS to definition.

9 years agoSkip testing argv[0] on target argv[0] isn't available
Yao Qi [Tue, 14 Oct 2014 07:40:15 +0000 (15:40 +0800)] 
Skip testing argv[0] on target argv[0] isn't available

I see the following two fails on arm-none-eabi target, because argv[0]
isn't available.

print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept file symbolic link name

print argv[0]^M
$1 = 0x1f78 "/dev/null"^M
(gdb) FAIL: gdb.base/argv0-symlink.exp: kept directory symbolic link name

My first thought is to check [target_info exists noargs], and skip the
test if it returns true.  However, noargs is set in gdbserver board
files, so argv0-symlink.exp will be skipped on gdbserver board file.
The change is too aggressive.

When the program is running with gdbserver, argv[1] to argv[N] aren't
available, but argv[0] is.  Fortunately, argv0-symlink.exp only
requires argv[0].  argv0-symlink.exp can be run with gdbserver board
file, as what we do now.

What we need to check is whether argv[0] is available, so I add a new
proc gdb_has_argv0 to do so by starting a program, and check
argc/argv[0] to see whether argv[0] is available.

Dan fixed the similar problem by checking noargs, which is too strong.
https://sourceware.org/ml/gdb-patches/2010-02/msg00398.html as a
result, the test is skipped on gdbserver.  This patch fixed it too.

gdb/testsuite:

2014-10-18  Yao Qi  <yao@codesourcery.com>

* gdb.base/argv0-symlink.exp: Check argv[0] value if
gdb_has_argv0 return true.
* gdb.guile/scm-value.exp (test_value_in_inferior): Don't
check [target_info exists noargs], check [gdb_has_argv0]
instead.
* gdb.python/py-value.exp (test_value_in_inferior): Likewise.
* lib/gdb.exp (gdb_has_argv0, gdb_has_argv0_1): New
procedures.

9 years agoPowerPC64 ELFv1 function symbol definition vs LTO and discarded sections
Alan Modra [Sat, 18 Oct 2014 11:16:48 +0000 (21:46 +1030)] 
PowerPC64 ELFv1 function symbol definition vs LTO and discarded sections

When functions are emitted in comdat groups, global symbols defined in
duplicates of the group are treated as if they were undefined.  That
prevents the symbols in the discarded sections from affecting the
linker's global symbol hash table or causing duplicate symbol errors.
Annoyingly, when gcc emits a function to a comdat group, it does not
put *all* of a function's code and data in the comdat group.
Typically, constant tables, exception handling info, and debug info
are emitted to normal sections outside of the group, which is a
perennial source of linker problems due to the special handling needed
to deal with the extra-group pieces that ought to be discarded.  In
the case of powerpc64-gcc, the OPD entry for a function is not put in
the group.  Since the function symbol is defined on the OPD entry this
means we need to handle symbols in .opd specially.

To see how this affects LTO in particular, consider the linker
testcase PR ld/12942 (1).  This testcase links an LTO object file
pr12942a.o with a normal (non-LTO) object pr12942b.o.  Both objects
contain a definition for _Z4testv in a comdat group.  On loading
pr12942a.o, the linker sees a comdat group (actually linkonce section)
for _Z4testv and a weak _Z4testv defined in the IR.  On loading
pr12942b.o, the linker sees the same comdat group, and thus discards
it.  However, _Z4testv is a weak symbol defined in .opd, not part of
the group, so this weak symbol overrides the weak IR symbol.  On
(re)loading the LTO version of pr12942a.o, the linker sees another
weak _Z4testv, but this one does not override the value we have from
pr12942b.o.  The result is a linker complaint about "`_Z4testv'
... defined in discarded section `.group' of tmpdir/pr12942b.o".

* elf64-ppc.c (ppc64_elf_add_symbol_hook): If function code
section for function symbols defined in .opd is discarded, let
the symbol appear to be undefined.
(opd_entry_value): Ensure the result section is that for the
function code section in the same object as the OPD entry.

9 years agoFix PR17493, attempted output of *GAS `reg' section* symbol
Alan Modra [Sat, 18 Oct 2014 00:40:53 +0000 (11:10 +1030)] 
Fix PR17493, attempted output of *GAS `reg' section* symbol

The write.c change is to make gas report an error if reg_section
symbols should leak in future.  The tc-i386.c change is the real fix.

Note that the error isn't the most helpful, "redefined symbol cannot
be used on reloc", but I'm not inclined to improve what is really an
internal gas error.  reg_section symbols shouldn't leak..

gas/
PR 17493
* write.c (adjust_reloc_syms): Don't allow symbols in reg_section
to be reduced to reg_section section symbol.
* gas/config/tc-i386.c (i386_finalize_immediate): Reject all
reg_section immediates.
gas/testsuite/
* gas/i386/inval-equ-2.l: Adjust.

9 years ago* configure.tgt (targ_extra_obj) [aarch64*-*]: Define.
Andreas Schwab [Sat, 18 Oct 2014 08:30:54 +0000 (10:30 +0200)] 
* configure.tgt (targ_extra_obj) [aarch64*-*]: Define.

9 years agoAdd "typename" keyword to satisfy GCC 4.2.
Cary Coutant [Fri, 17 Oct 2014 23:22:55 +0000 (16:22 -0700)] 
Add "typename" keyword to satisfy GCC 4.2.

gold/
* aarch64.cc (AArch64_relocate_functions::maybe_apply_stub):
Add "typename" keyword.

9 years agodaily update
Alan Modra [Fri, 17 Oct 2014 23:00:32 +0000 (09:30 +1030)] 
daily update

9 years agoopcodes, elf: annotate instructions with HWCAP2_VIS3B.
Jose E. Marchesi [Wed, 15 Oct 2014 06:46:54 +0000 (08:46 +0200)] 
opcodes, elf: annotate instructions with HWCAP2_VIS3B.

This patch annotates the following SPARC instructions as VIS3B
instructions: ldx *, %efsr, fpadd64, fpsub64, fpcmpule8, fpcmpune8,
fpcmpugt8, fpcmpueq8.  It also improves the documentation of the VIS3B
capability in several headers.

Tested in sparc64-unknown-linux-gnu and sparc-unknown-linux-gnu.
No visible regressions.

opcodes/ChangeLog:

  2014-10-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-opc.c (sparc-opcodes): Annotate several instructions with
the HWCAP2_VIS3B hwcap.

include/opcodes/ChangeLog:

  2014-10-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc.h (HWCAP2_VIS3B): Documentation improved.

include/elf/ChangeLog:

  2014-10-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc.h (ELF_SPARC_HWCAP2_VIS3B): Documentation improved.

9 years agoopcodes: fix several misplaced hwcap entries.
Jose E. Marchesi [Fri, 17 Oct 2014 19:56:41 +0000 (21:56 +0200)] 
opcodes: fix several misplaced hwcap entries.

This patch fixes the hwcap entries in `sparc-opcodes' (which were
incorrectly located in the flags field) for the following
instructions:

  wr r,r,%sys_tick
  wr r,i,%sys_tick
  wr r,r,%sys_tick_cmpr
  wr r,i,%sys_tick_cmpr
  edge8n edge8ln edge16n edge16ln edge32n edge32ln
  bmask bshuffle siam

Tested in sparc-unknown-linux-gnu and sparc64-unknown-linux-gnu.
No visible regressions.

opcodes/ChangeLog:

  2014-10-17  Jose E. Marchesi  <jose.marchesi@oracle.com>

* sparc-opc.c (sparc-opcodes): Fix several misplaced hwcap
entries.

9 years agoFix bad @value references in MIPS documentation
Matthew Fortune [Fri, 17 Oct 2014 19:25:09 +0000 (20:25 +0100)] 
Fix bad @value references in MIPS documentation

gas/

* doc/c-mips.texi: Fix bad @value references.

9 years agoNew python event "clear_objfiles".
Doug Evans [Fri, 17 Oct 2014 18:12:17 +0000 (11:12 -0700)] 
New python event "clear_objfiles".

If one is watching new_objfile events in python, it helps to know
when the list of objfiles is cleared.  This patch adds a new
clear_objfiles event to support this.

This patch is all just cut-n-paste-n-tweak derived from
the new_objfiles event.

gdb/ChangeLog:

* NEWS: Mention new event gdb.clear_objfiles.
* python/py-event.h (emit_clear_objfiles_event): Clear
* python/py-events.h (events_object): New member clear_objfiles.
* python/py-evts.c (gdbpy_initialize_py_events): Add clear_objfiles
event.
* python/py-inferior.c (python_new_objfile): If objfile is NULL,
emit clear_objfiles event.
* python/py-newobjfileevent.c (create_clear_objfiles_event_object): New
function.
(emit_clear_objfiles_event): New function.
(clear_objfiles): New event.
* python/python-internal.h (gdbpy_initialize_clear_objfiles_event):
Declare.
* python/python.c (_initialize_python): Call
gdbpy_initialize_clear_objfiles_event.

gdb/doc/ChangeLog:

* python.texi (Events In Python): Document clear_objfiles event.

gdb/testsuite/ChangeLog:

* gdb.python/py-events.exp: Update expected output for clear_objfiles
event.
* gdb.python/py-events.py: Add clear_objfiles event.

9 years agoAdd gdb.Objfile.progspace attribute.
Doug Evans [Fri, 17 Oct 2014 17:57:26 +0000 (10:57 -0700)] 
Add gdb.Objfile.progspace attribute.

gdb/ChangeLog:

* NEWS: Mention new gdb.Objfile.progspace attribute.
* python/py-objfile.c (objfpy_get_progspace): New function.
(objfile_getset): New entry for "progspace".

gdb/doc/ChangeLog:

* python.texi (Objfiles In Python): Document new progspace attribute.

gdb/testsuite/ChangeLog:

* gdb.python/py-objfile.exp: Test progspace attribute.

9 years agoFix mingw32 failures due to incorrect directory separator in pattern
Luis Machado [Fri, 17 Oct 2014 14:28:17 +0000 (11:28 -0300)] 
Fix mingw32 failures due to incorrect directory separator in pattern

Some testcases, mostly gdb.reverse ones, assume the presence of a
'/' directory separator before the source file name. This is
incorrect for mingw32 hosts, generating false failures for those
tests.

I attempted to catch most of the occurrences of the pattern
".*/$srcfile" and replaced them with ".*$srcfile". The latter
is used elsewhere in the testsuite. The resulting patch is attached.

I also see other occurrences of the same assumption throughout the
testsuite, but usually they are arguments for function calls and i
seem to recall either the test harness or GDB deals with those
paths properly.

gdb/testsuite:

2014-10-17  Luis Machado  <lgustavo@codesourcery.com>

* gdb.guile/scm-breakpoint.exp: Do not assume any
directory separators when matching source file paths.
* gdb.python/py-breakpoint.exp: Likewise.
* gdb.reverse/break-precsave.exp: Likewise.
* gdb.reverse/break-reverse.exp: Likewise.
* gdb.reverse/consecutive-precsave.exp: Likewise.
* gdb.reverse/finish-precsave.exp: Likewise.
* gdb.reverse/finish-reverse-bkpt.exp: Likewise.
* gdb.reverse/finish-reverse.exp: Likewise.
* gdb.reverse/i386-precsave.exp: Likewise.
* gdb.reverse/i387-env-reverse.exp: Likewise.
* gdb.reverse/i387-stack-reverse.exp: Likewise.
* gdb.reverse/machinestate-precsave.exp: Likewise.
* gdb.reverse/machinestate.exp: Likewise.
* gdb.reverse/sigall-precsave.exp: Likewise.
* gdb.reverse/solib-precsave.exp: Likewise.
* gdb.reverse/step-precsave.exp: Likewise.
* gdb.reverse/until-precsave.exp: Likewise.
* gdb.reverse/watch-precsave.exp: Likewise.
* gdb.reverse/watch-reverse.exp: Likewise.

9 years agoCopy xml files to host
Yao Qi [Fri, 15 Aug 2014 03:28:39 +0000 (11:28 +0800)] 
Copy xml files to host

When I run test with board file local-remote-host-native.exp, I see
the following warning,

$ make check RUNTESTFLAGS="--host_board=local-remote-host-native
--target_board=local-remote-host-native tdesc-arch.exp
HOST_DIR=/tmp/foo/"

(gdb) set tdesc filename ../../../../git/gdb/testsuite/gdb.xml/trivial.xml^M
warning: Could not open "../../../../git/gdb/testsuite/gdb.xml/trivial.xml"
(gdb) quit^

because "${srcdir}/gdb.xml/trivial.xml" doesn't exist on host.  This
patch is to copy trivial.xml to host and the warning goes away.

(gdb) set tdesc filename /tmp/foo/trivial.xml^M
(gdb) quit^

tdesc-regs.exp has the similar problem that single-reg.xml may not
exist on host at all, and it should be copied to host too.

gdb/testsuite:

2014-10-17  Yao Qi  <yao@codesourcery.com>

* lib/gdb.exp (gdb_skip_xml_test): Copy trivial.xml to host.
* gdb.xml/tdesc-regs.exp: Copy single-reg.xml to host.

9 years agoPR gdb/17471: Repeating a background command makes it foreground
Pedro Alves [Fri, 17 Oct 2014 12:31:26 +0000 (13:31 +0100)] 
PR gdb/17471: Repeating a background command makes it foreground

When we repeat a command, by just pressing <ret>, the input from the
previous command is reused for the new command invocation.

When an execution command strips the "&" out of its incoming argument
string, to detect background execution, we poke a '\0' directly to the
incoming argument string.

Combine both, and a repeat of a background command loses the "&".

This is actually only visible if args other than "&" are specified
(e.g., "c 1&" or "next 2&" or "c -a&"), as in the special case of "&"
alone (e.g. "c&") doesn't actually clobber the incoming string.

Fix this by making strip_bg_char return a new string instead of poking
a hole in the input string.

New test included.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

PR gdb/17471
* infcmd.c (strip_bg_char): Change prototype and rewrite.  Now
returns a copy of the input.
(run_command_1, continue_command, step_1, jump_command)
(signal_command, until_command, advance_command, finish_command)
(attach_command): Adjust and install a cleanup to free the
stripped args.

gdb/testsuite/
2014-10-17  Pedro Alves  <palves@redhat.com>

PR gdb/17471
* gdb.base/bg-execution-repeat.c: New file.
* gdb.base/bg-execution-repeat.exp: New file.

9 years agoPR gdb/17300: Input after "c -a" crashes readline/GDB
Pedro Alves [Fri, 17 Oct 2014 12:31:25 +0000 (13:31 +0100)] 
PR gdb/17300: Input after "c -a" crashes readline/GDB

If all threads in the target were already running when the user does
"c -a", nothing puts the inferior's terminal settings in effect and
removes stdin from the event loop, which we must when running a
foreground command.  The result is that user input afterwards crashes
readline/gdb:

 (gdb) start
 Temporary breakpoint 1 at 0x4005d4: file continue-all-already-running.c, line 23.
 Starting program: continue-all-already-running

 Temporary breakpoint 1, main () at continue-all-already-running.c:23
 23        sleep (10);
 (gdb) c -a&
 Continuing.
 (gdb) c -a
 Continuing.
 p 1
 readline: readline_callback_read_char() called with no handler!
 Aborted (core dumped)
 $

Backtrace:

 Program received signal SIGABRT, Aborted.
 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
 (top-gdb) p 1
 $1 = 1
 (top-gdb) bt
 #0  0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #1  0x0000003b36a36f68 in __GI_abort () at abort.c:89
 #2  0x0000000000784aa9 in rl_callback_read_char () at readline/callback.c:116
 #3  0x0000000000619181 in rl_callback_read_char_wrapper (client_data=0x0) at gdb/event-top.c:167
 #4  0x0000000000619557 in stdin_event_handler (error=0, client_data=0x0) at gdb/event-top.c:373
 #5  0x000000000061814a in handle_file_event (data=...) at gdb/event-loop.c:763
 #6  0x0000000000617631 in process_event () at gdb/event-loop.c:340
 #7  0x00000000006176f8 in gdb_do_one_event () at gdb/event-loop.c:404
 #8  0x0000000000617748 in start_event_loop () at gdb/event-loop.c:429
 #9  0x00000000006191b3 in cli_command_loop (data=0x0) at gdb/event-top.c:182
 #10 0x000000000060f538 in current_interp_command_loop () at gdb/interps.c:318
 #11 0x0000000000610701 in captured_command_loop (data=0x0) at gdb/main.c:323
 #12 0x000000000060c3f5 in catch_errors (func=0x6106e6 <captured_command_loop>, func_args=0x0, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
     at gdb/exceptions.c:237
 #13 0x0000000000611bff in captured_main (data=0x7fffffffd780) at gdb/main.c:1151
 #14 0x000000000060c3f5 in catch_errors (func=0x610afe <captured_main>, func_args=0x7fffffffd780, errstring=0x9002c1 "", mask=RETURN_MASK_ALL)
     at gdb/exceptions.c:237
 #15 0x0000000000611c28 in gdb_main (args=0x7fffffffd780) at gdb/main.c:1159
 #16 0x000000000045ef97 in main (argc=5, argv=0x7fffffffd888) at gdb/gdb.c:32
 (top-gdb)

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

PR gdb/17300
* infcmd.c (continue_1): If continuing all threads in the
foreground, make sure the inferior's terminal settings are put in
effect.

gdb/testsuite/
2014-10-17  Pedro Alves  <palves@redhat.com>

PR gdb/17300
* gdb.base/continue-all-already-running.c: New file.
* gdb.base/continue-all-already-running.exp: New file.

9 years agoPR gdb/17472: With annotations, input while executing in the foreground crashes readl...
Pedro Alves [Fri, 17 Oct 2014 12:31:25 +0000 (13:31 +0100)] 
PR gdb/17472: With annotations, input while executing in the foreground crashes readline/GDB

Jan caught an intermittent GDB crash with the annota1.exp test:

 Starting program: .../gdb/testsuite/gdb.base/annota1 ^M
 [...]
 FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout)
 [...]
 readline: readline_callback_read_char() called with no handler!^M
 ERROR: Process no longer exists

All we need to is to continue the inferior in the foreground, and type
a command while the inferior is running.  E.g.:

 (gdb) set annotate 2

 ▒▒pre-prompt
 (gdb)
 ▒▒prompt
 c

 ▒▒post-prompt
 Continuing.

 ▒▒starting

 ▒▒frames-invalid

 *inferior is running now*

 p 1<ret>

 readline: readline_callback_read_char() called with no handler!
 Aborted (core dumped)
 $

When we run a foreground execution command we call
target_terminal_inferior to stop GDB from processing input, and to put
the inferior's terminal settings in effect.  Then we tell readline to
hide the prompt with display_gdb_prompt, which clears readline's input
callback too.  When the target stops, we call target_terminal_ours,
which re-installs stdin in the event loop, and then we redisplay the
prompt, reinstalling the readline callbacks.

However, when annotations are in effect, the "frames-invalid"
annotation code calls target_terminal_ours after 'resume' had already
called target_terminal_inferior:

 (top-gdb) bt
 #0  0x000000000056b82f in annotate_frames_invalid () at gdb/annotate.c:219
 #1  0x000000000072e6cc in reinit_frame_cache () at gdb/frame.c:1705
 #2  0x0000000000594bb9 in registers_changed_ptid (ptid=...) at gdb/regcache.c:612
 #3  0x000000000064cca1 in target_resume (ptid=..., step=1, signal=GDB_SIGNAL_0) at gdb/target.c:2136
 #4  0x00000000005f57af in resume (step=1, sig=GDB_SIGNAL_0) at gdb/infrun.c:2263
 #5  0x00000000005f6051 in proceed (addr=18446744073709551615, siggnal=GDB_SIGNAL_DEFAULT, step=1) at gdb/infrun.c:2613

And then once we hide the prompt and remove readline's input handler
callback, we're in a bad state.  We end up with the target running
supposedly in the foreground, but with stdin still installed on the
event loop.  Any input then calls into readline, which aborts because
no rl_linefunc callback handler is installed:

 Program received signal SIGABRT, Aborted.
 0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);

 (top-gdb) bt
 #0  0x0000003b36a35877 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
 #1  0x0000003b36a36f68 in __GI_abort () at abort.c:89
 During symbol reading, debug info gives source 9 included from file at zero line 0.
 During symbol reading, debug info gives command-line macro definition with non-zero line 19: _STDC_PREDEF_H 1.
 #2  0x0000000000784a25 in rl_callback_read_char () at src/readline/callback.c:116
 #3  0x0000000000619111 in rl_callback_read_char_wrapper (client_data=0x0) at src/gdb/event-top.c:167
 #4  0x00000000006194e7 in stdin_event_handler (error=0, client_data=0x0) at src/gdb/event-top.c:373
 #5  0x00000000006180da in handle_file_event (data=...) at src/gdb/event-loop.c:763
 #6  0x00000000006175c1 in process_event () at src/gdb/event-loop.c:340
 #7  0x0000000000617688 in gdb_do_one_event () at src/gdb/event-loop.c:404
 #8  0x00000000006176d8 in start_event_loop () at src/gdb/event-loop.c:429
 #9  0x0000000000619143 in cli_command_loop (data=0x0) at src/gdb/event-top.c:182
 #10 0x000000000060f4c8 in current_interp_command_loop () at src/gdb/interps.c:318
 #11 0x0000000000610691 in captured_command_loop (data=0x0) at src/gdb/main.c:323
 #12 0x000000000060c385 in catch_errors (func=0x610676 <captured_command_loop>, func_args=0x0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
     at src/gdb/exceptions.c:237
 #13 0x0000000000611b8f in captured_main (data=0x7fffffffd7b0) at src/gdb/main.c:1151
 #14 0x000000000060c385 in catch_errors (func=0x610a8e <captured_main>, func_args=0x7fffffffd7b0, errstring=0x900241 "", mask=RETURN_MASK_ALL)
     at src/gdb/exceptions.c:237
 #15 0x0000000000611bb8 in gdb_main (args=0x7fffffffd7b0) at src/gdb/main.c:1159
 #16 0x000000000045ef57 in main (argc=3, argv=0x7fffffffd8b8) at src/gdb/gdb.c:32

The fix is to make the annotation code call target_terminal_inferior
again after printing, if the inferior's settings were in effect.

While at it, when we're doing output only, instead of
target_terminal_ours, we should call target_terminal_ours_for_output.
The latter doesn't actually remove stdin from the event loop, and also
leaves SIGINT forwarded to the target.

New test included.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

PR gdb/17472
* annotate.c (annotate_breakpoints_invalid): Use
target_terminal_our_for_output instead of target_terminal_ours.
Give back the terminal to the target.
(annotate_frames_invalid): Likewise.

gdb/testsuite/
2014-10-17  Pedro Alves  <palves@redhat.com>

PR gdb/17472
* gdb.base/annota-input-while-running.c: New file.
* gdb.base/annota-input-while-running.exp: New file.

9 years agoMake common code handle target_terminal_* idempotency
Pedro Alves [Fri, 17 Oct 2014 12:31:25 +0000 (13:31 +0100)] 
Make common code handle target_terminal_* idempotency

I found a place that should be giving back the terminal to the target,
but only if the target was already owning it.  So I need to add a
getter for who owns the terminal.

The trouble is that several places/target have their own globals to
track this state:

 - inflow.c:terminal_is_ours
 - remote.c:remote_async_terminal_ours_p
 - linux-nat.c:async_terminal_is_ours
 - go32-nat.c:terminal_is_ours

While one might think of adding a new target_ops method to query this,
conceptually, this state isn't really part of a particular target_ops.
Considering multi-target, the core shouldn't have to ask all targets
to know whether it's GDB that owns the terminal.  There's only one GDB
(or rather, only one top level interpreter).

So what this comment does is add a new global that is tracked by the
core instead.  A subsequent pass may later remove the other globals.

Tested on x86_64 Fedora 20, native and gdbserver.

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

* target.c (enum terminal_state): New enum.
(terminal_state): New global.
(target_terminal_init): New function.
(target_terminal_inferior): Skip if inferior already owns the
terminal.
(target_terminal_ours, target_terminal_ours_for_output): New
functions.
* target.h (target_terminal_init): Convert to function prototype.
(target_terminal_ours_for_output): Convert to function prototype
and tweak comment.
(target_terminal_ours): Convert to function prototype and tweak
comment.
* windows-nat.c (do_initial_windows_stuff): Call
target_terminal_init instead of child_terminal_init_with_pgrp.

9 years agoFix ld tests with sysroot=/ and --enable-targets=all and test --print-sysroot
Hans-Peter Nilsson [Fri, 17 Oct 2014 11:10:18 +0000 (13:10 +0200)] 
Fix ld tests with sysroot=/ and --enable-targets=all and test --print-sysroot

* ld-scripts/sysroot-prefix.exp: Log $ld_sysroot.  Handle sysroot
== "/" as a separate sysroot-configuration with separable
test-types.
(sysroot_prefix_tests): Include all existing sysroot tests in
sysroot == "/" tests except exclude those where a --sysroot option
is not specified.
* lib/ld-lib.exp (check_sysroot_available): Rewrite to use
--print-sysroot instead of relying on error code from using
--sysroot=...  Also, set $ld_sysroot.

The reason we exclude not just the failing "full-path =-prefixed
without" but also the passing "plain =-prefixed without but -Lpath"
for sysroot == "/" is that for the latter to succeed, we have to make
assumptions about the system not having a /sysroot directory or
assumptions about its contents etc.

When passing --enable-targets=all --enable-64-bit-bfd (the
latter not required for a "64-bit-host" of course) the ld --help
output got too much to handle for poor tcl (or maybe dejagnu is
to blame) and remote_exec exited with an error, so the
configuration being tested was mishandled as being a
sysroot-less configuration.  Using --version instead of --help
would work too, but the new --print-sysroot option calls for
nominal coverage, so why not use that instead.

9 years agoImplement --print-sysroot in ld.
Hans-Peter Nilsson [Fri, 17 Oct 2014 11:07:09 +0000 (13:07 +0200)] 
Implement --print-sysroot in ld.

* ldlex.h (enum option_values): Add entry OPTION_PRINT_SYSROOT.
* lexsup.c (ld_options): Add entry for --print-sysroot.
(parse_args) <OPTION_PRINT_SYSROOT>: Print sysroot and exit early.

9 years agoImplement --print-sysroot in ld.
Hans-Peter Nilsson [Fri, 17 Oct 2014 11:06:56 +0000 (13:06 +0200)] 
Implement --print-sysroot in ld.

* ldlex.h (enum option_values): Add entry OPTION_PRINT_SYSROOT.
* lexsup.c (ld_options): Add entry for --print-sysroot.
(parse_args) <OPTION_PRINT_SYSROOT>: Print sysroot and exit early.

9 years agoDelete Tru64 support
Pedro Alves [Fri, 17 Oct 2014 10:18:59 +0000 (11:18 +0100)] 
Delete Tru64 support

This commit does most of the mechanical removal.  IOW, the easy part.

procfs.c isn't touched beyond removing a couple obvious bits that are
guarded by a couple macros defined in config/alpha/nm-osf3.h.  Going
beyond that for procfs.c & co would be a harder excision that
potentially affects Solaris.

Some comments in the generic alpha code ABIs that may still be
relevant and I wouldn't know what to do with them.  That can always be
done on a separate pass, preferably by someone who can test on alpha.

A couple other spots have references to OSF/Tru64 and related files
being removed, but it felt like removing them would make things worse,
not better.  We can revisit those when we next need to touch that
code.

I didn't remove a reference to osf in testsuite/lib/future.exp, as I
believe that code is imported from DejaGNU.

Built and tested on x86_64 Fedora 20, with --enable-targets=all.

Tested that building for --target=alpha-osf3 on x86_64 Fedora 20
fails with:

 checking for default auto-load directory... $debugdir:$datadir/auto-load
 checking for default auto-load safe-path... $debugdir:$datadir/auto-load
 *** Configuration alpha-unknown-osf3 is obsolete.
 *** Support has been REMOVED.
 make[1]: *** [configure-gdb] Error 1
 make[1]: Leaving directory `build-osf'
 make: *** [all] Error 2

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

* Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o.
(HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h.
(ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and
solib-osf.c.
* NEWS: Mention that support for alpha*-*-osf* has been removed.
* ada-lang.h [__alpha__ && __osf__]
(ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete.
* alpha-nat.c, alpha-osf1-tdep.c: Delete files.
* alpha-tdep.c (alpha_gdbarch_init): Remove reference to
GDB_OSABI_OSF1.
* config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete
files.
* config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh)
(config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete.
* configure: Regenerate.
* configure.ac: Remove references to osf.
* configure.host: Handle alpha*-*-osf* in the obsolete hosts
section.  Remove all other references to osf.
* configure.tgt: Add alpha*-*-osf* to the obsolete targets section.
Remove all other references to osf.
* dec-thread.c: Delete file.
* defs.h (GDB_OSABI_OSF1): Delete.
* inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally
defined.
* osabi.c (gdb_osabi_names): Delete "OSF/1".
* procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]:
Delete code.
(unconditionally_kill_inferior)
[PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code.
* solib-osf.c: Delete file.

gdb/testsuite/
2014-10-17  Pedro Alves  <palves@redhat.com>

* gdb.base/callfuncs.exp: emove references to osf.
* gdb.base/sigall.exp: Likewise.
* gdb.gdb/selftest.exp: Likewise.
* gdb.hp/gdb.base-hp/callfwmall.exp: Likewise.
* gdb.mi/non-stop.c: Likewise.
* gdb.mi/pthreads.c: Likewise.
* gdb.reverse/sigall-precsave.exp: Likewise.
* gdb.reverse/sigall-reverse.exp: Likewise.
* gdb.threads/pthreads.c: Likewise.
* gdb.threads/pthreads.exp: Likewise.

gdb/doc/
2014-10-17  Pedro Alves  <palves@redhat.com>

* gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64.
(SVR4 Process Information): Delete mention of OSF/1.

9 years agoFix build without libexpat
Pedro Alves [Fri, 17 Oct 2014 10:05:06 +0000 (11:05 +0100)] 
Fix build without libexpat

clear_threads_listing_context is used for thread listing methods other
than the xml based, but it's only defined when HAVE_LIBEXPAT is defined.

gdb/
2014-10-17  Pedro Alves  <palves@redhat.com>

* remote.c (clear_threads_listing_context): Move higher up, out of
the HAVE_LIBEXPAT guard.

9 years agoDon't check target_info exists noargs in commands.exp
Yao Qi [Fri, 10 Oct 2014 13:17:11 +0000 (21:17 +0800)] 
Don't check target_info exists noargs in commands.exp

I am confused by the noargs checking at each proc in commands.exp,

    if [target_info exists noargs] {
        verbose "Skipping progvar_simple_while_test because of noargs."
        return
    }
    gdb_test_no_output "set args 5" "set args in progvar_simple_while_test"
    if { ![runto factorial] } then { gdb_suppress_tests }
    # Don't depend upon argument passing, since most simulators don't
    # currently support it.  Bash value variable to be what we want.
    gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #2"

They are conflicting to me.  If the argument passing can't be done on
the target, we skip this test, why do we still have to set value below?
On the other hand, the test case is compiled with -DFAKEARGV, it doesn't
get anything from argv[1], why do we need to skip it if noargs is true?

I don't find any useful clues from the git log, as the code is quite
old, predating import to sourceware cvs.  However, I find something
useful from the ChangeLog.

Thu Jul 20 13:28:36 1995  Jeffrey A. Law  <law@rtl.cygnus.com>

        .....
        * gdb.base/commands.exp: Protect tests which need arguments with
        $noargs conditionals.

Mon Apr 21 13:38:58 1997  Fred Fish  <fnf@cygnus.com>

        * gdb.base/run.c: Use FAKEARGV to build test executable that
        does not require a command line arg, since most simulators
        don't currently support passing such an arg into the simulated
        program.
        * gdb.base/commands.exp: Change tests to insert the proper
        value as the arg to the first recursive factorial call.  Change
        compilation line to define FAKEARGV at compile time.

Jeff added noargs checking as argument is passed to the inferior.  Then,
I presume Fred wanted to run this test on simulators which don't support
argument passing, and change the code not get input from argv.  (I guess)
noargs wasn't set in simulator board files at that moment.

Since Fred changed test to set input by gdb, instead of getting input
from argv, the test should be able to run on target doesn't support
argument passing, such as simulator and gdbserver.

This patch is to remove these checks to noargs and "set args".  I run
commands.exp with these board files, and no fail is found

 - unix and native-gdbserver
 - arm-none-eabi with qemu
 - gdbserver on arm-linux-gnueabi with qemu

gdb/testsuite:

2014-10-17  Yao Qi  <yao@codesourcery.com>

* gdb.base/commands.exp (gdbvar_complex_if_while_test): Don't check
'target_info exists noargs'.
(test_command_prompt_position): Likewise.
(progvar_simple_if_test): Don't check 'target_info exists noargs'.
 Remove "set args".
(progvar_simple_while_test): Likewise.
(progvar_complex_if_while_test): Likewise.
(if_while_breakpoint_command_test): Likewise.
(infrun_breakpoint_command_test): Likewise.
(breakpoint_command_test): Likewise.
(watchpoint_command_test): Likewise.
(bp_deleted_in_command_test): Likewise.
(temporary_breakpoint_commands): Likewise.

9 years agodaily update
Alan Modra [Thu, 16 Oct 2014 23:01:12 +0000 (09:31 +1030)] 
daily update

9 years agoUse strtod instead of strtold in libiberty/d-demangle.c
Joel Brobecker [Tue, 14 Oct 2014 16:47:43 +0000 (12:47 -0400)] 
Use strtod instead of strtold in libiberty/d-demangle.c

strtold is currently used to decode templates which have a floating-point
value encoded inside; but this routine is not available on some systems,
such as Solaris 2.9 for instance.

This patch fixes the issue by replace the use of strtold by strtod.
It reduces a bit the precision, but it should still remain acceptable
in most cases.

libiberty/ChangeLog:

        * d-demangle.c: Replace strtold with strtod in global comment.
        (strtold): Remove declaration.
        (strtod): New declaration.
        (dlang_parse_real): Declare value as double instead of long
        double.  Replace call to strtold by call to strtod.
        Update format in call to snprintf.

9 years agoDarwin: sanitize %gs and %fs values.
Tristan Gingold [Thu, 16 Oct 2014 11:50:07 +0000 (13:50 +0200)] 
Darwin: sanitize %gs and %fs values.

Some Darwin kernels return values out of bounds for gs and fs segments.
With this commit, they are masked to avoid garbage.

gdb/ChangeLog:
* i386-darwin-nat.c (i386_darwin_fetch_inferior_registers)
(i386_darwin_store_inferior_registers): Sanitize gs and fs values
on amd64.

9 years agoFix 17492, ld segfault with --oformat=binary
Alan Modra [Thu, 16 Oct 2014 10:46:07 +0000 (21:16 +1030)] 
Fix 17492, ld segfault with --oformat=binary

PR 17492
* elf32-arm.c (elf32_arm_add_symbol_hook): Only set has_gnu_symbols
on ELF output bfd.
* elf32-i386.c (elf_i386_add_symbol_hook): Likewise.
* elf32-m68k.c (elf_m68k_add_symbol_hook): Likewise.
* elf32-ppc.c (ppc_elf_add_symbol_hook): Likewise.
* elf32-sparc.c (elf32_sparc_add_symbol_hook): Likewise.
* elf64-ppc.c (ppc64_elf_add_symbol_hook): Likewise.
* elf64-sparc.c (elf64_sparc_add_symbol_hook): Likewise.
* elf64-x86-64.c (elf_x86_64_add_symbol_hook): Likewise.
* elfxx-aarch64.c (_bfd_aarch64_elf_add_symbol_hook): Likewise.
* elf-s390-common.c (elf_s390_add_symbol_hook): Likewise.  Handle
STB_GNU_UNIQUE too.

9 years agoDon't check noargs in remotetimeout.exp
Yao Qi [Fri, 10 Oct 2014 12:52:25 +0000 (20:52 +0800)] 
Don't check noargs in remotetimeout.exp

The condition [target_info exists noargs] is checked when
remotetimeout.exp was added
https://sourceware.org/ml/gdb-patches/2005-02/msg00052.html

noargs means GDB does not support argument passing for inferior,
rather than doesn't support argument passing to GDB.  remotetimeout.exp
passes -l to GDB only, doesn't pass any arguments to the inferior.

This patch is to remove such unnecessary checking, and
remotetimeout.exp then can be run with native-gdbserver board file.

gdb/testsuite:

2014-10-16  Yao Qi  <yao@codesourcery.com>

* gdb.base/remotetimeout.exp: Remove noargs checking.

9 years agoPR17488, powerpc64-linux-ld segfault
Alan Modra [Wed, 15 Oct 2014 23:08:09 +0000 (09:38 +1030)] 
PR17488, powerpc64-linux-ld segfault

For binary ouput, we don't have an ELF bfd output so can't access
elf_elfheader.  The elf64-ppc.c changes are really just a tidy,
triggered by looking at all places where the abiversion bits are
accessed.

bfd/
* elf64-ppc.c (ppc64_elf_before_check_relocs): Do .opd processing
even when output is not ppc64 ELF.  Remove redundant tests on
type of input bfd.
ld/
PR 17488
* emultempl/ppc64elf.em (gld${EMULATION_NAME}_finish): Don't attempt
to access ELF header e_flags when not ppc64 ELF output.

9 years agodaily update
Alan Modra [Wed, 15 Oct 2014 23:01:12 +0000 (09:31 +1030)] 
daily update

9 years agoHere we have the patch for gold aarch64 backend to support relaxation.
Han Shen [Wed, 15 Oct 2014 22:23:01 +0000 (15:23 -0700)] 
Here we have the patch for gold aarch64 backend to support relaxation.

In short relaxation is the linker's generation of stubs that fixes the
out-of-range jumps/branches in the original object file.

With this implementation, we are able to link a 456MB aarch64 application.

Tested:
1) Build natively on x86_64 and aarch64 machines.
2) Pass unit tests regarding relaxation.

9 years agoDEC threads: Simplify updating the thread list
Pedro Alves [Wed, 15 Oct 2014 21:48:35 +0000 (22:48 +0100)] 
DEC threads: Simplify updating the thread list

Seems to me that we can simplify DEC thread's
target_update_thread_list implementation, avoiding the need to build
the array of GDB threads.

I have no way to test this, but then again support for Tru64 is about
to be removed.

Pushing anyway to have the last version in git be the cleanest one
should start from, if this file turns out to be resurrected in the
future.

gdb/
2014-10-15  Pedro Alves  <palves@redhat.com>

* dec-thread.c (dec_thread_count_gdb_threads)
(dec_thread_add_gdb_thread): Delete.
(dec_thread_update_thread_list): Delete.
(dec_thread_find_new_threads): Rename to ...
(dec_thread_update_thread_list): ... this.  Delete GDB-size
threads that are no longer found in dec_thread_list.
(resync_thread_list): Delete.
(dec_thread_wait): Call dec_thread_update_thread_list instead of
resync_thread_list.

9 years agoremote: get rid of all the T packets when syncing the thread list
Pedro Alves [Wed, 15 Oct 2014 21:44:00 +0000 (22:44 +0100)] 
remote: get rid of all the T packets when syncing the thread list

This commit avoids the prune_threads call in the remote target's
target_update_thread_list's implementation, eliminating all the "thread
alive" RSP traffic (one packet per thread) whenever we fetch the
thread list.

IOW, this:

 Sending packet: $Tp2141.2150#82...Packet received: OK
 Sending packet: $Tp2141.214f#b7...Packet received: OK
 Sending packet: $Tp2141.2141#82...Packet received: OK
 ... more T packets; it's one per previously known live thread ...
 Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n

Becomes:

 Sending packet: $qXfer:threads:read::0,fff#03...Packet received: l<threads>\n<thread id="p2141.2141" core="2"/>\n<thread id="p2141.214f" core="1"/>\n<thread id="p2141.2150" core="2"/>\n</threads>\n

Tested on x86_64 Fedora 20, native gdbserver:
  - tests the qXfer:threads:read method.

Tested on x86_64 Fedora 20, native gdbserver with qXfer:threads:read
force-disabled in gdbserver:
  - So that GDB falls back to the qfThreadInfo/qsThreadInfo method.

And also manually smoked tested force disabling both
qXfer:threads:read and qfThreadInfo/qsThreadInfo in gdbserver.

gdb/
2014-10-15  Pedro Alves  <palves@redhat.com>

* gdbthread.h (ALL_NON_EXITED_THREADS_SAFE): New macro.
* remote.c (remote_update_thread_list): Skip calling prune_threads
if any thread listing method is supported, and instead walk over
the set of remote threads listed, deleting those that are not
found in GDB's thread list.

This page took 0.071015 seconds and 4 git commands to generate.