Fix xtensa ld segfault when linking linux modules

is_inconsistent_linkonce_section makes an assumption that section name
that starts with ".gnu.linkonce.prop." has one more dot in its suffix.
However gas generates such section name by insertion of "prop." right
after ".gnu.linkonce." part of the name of the original section. So, for
section named ".gnu.linkonce.this_module" corresponding property section
name does not satisfy the assumption. Such section names are common in
linux modules. This bug was exposed by the patch "a35d5e8 Fix alignment
for the first section frag on xtensa", that makes gas produce property
section for each section that has ".align" directive in it.

Use suffix that immediately follows ".gnu.linkonce.prop." when there are
no more dots following it.

2014-07-10  Max Filippov  <jcmvbkbc@gmail.com>

ld/
    * emultempl/xtensaelf.em (is_inconsistent_linkonce_section):
    correctly handle missing dot in section name after
    ".gnu.linkonce.prop.".
	* gdbthread.h (any_running): Declare.
	* thread.c (any_running): New function.
Revert gdbthread.h (any_running): Declare.
Not properly marked as 1/2.
This reverts commit 1a76d598884a052dacd8feb49f1999e1a0d537f1.
daily update
remote: call remote_check_symbols after attaching

When debugging a remote bare-metal target with "target
extended-remote" + attach, GDB won't send a qSymbol packet to initiate
symbol lookup.  This happens because all the previous places in which
GDB might have done this are guarded by conditions that don't hold in
the said scenario: there are no shared libraries, no vsyscall page and
the binary file didn't change in the time passed between the "file"
and the "attach" commands.

To solve this problem remote_check_symbols is called in the
target_post_attach hook.

gdb/
2014-07-11  Adrian Sendroiu  <adrian.sendroiu@freescale.com>

	* remote.c (extended_remote_post_attach): New function.
	(init_extended_remote_ops): Install it as to_post_attach method.
GDBserver crashes when killing a multi-thread process

Here's an example, with the new test:

 gdbserver :9999 gdb.threads/kill
 gdb gdb.threads/kill
 (gdb) b 52
 Breakpoint 1 at 0x4007f4: file kill.c, line 52.
 Continuing.

 Breakpoint 1, main () at kill.c:52
 52        return 0; /* set break here */
 (gdb) k
 Kill the program being debugged? (y or n) y

 gdbserver :9999 gdb.threads/kill
 Process gdb.base/watch_thread_num created; pid = 9719
 Listening on port 1234
 Remote debugging from host 127.0.0.1
 Killing all inferiors
 Segmentation fault (core dumped)

Backtrace:

 (gdb) bt
 #0  0x00000000004068a0 in find_inferior (list=0x66b060 <all_threads>, func=0x427637 <kill_one_lwp_callback>, arg=0x7fffffffd3fc) at src/gdb/gdbserver/inferiors.c:199
 #1  0x00000000004277b6 in linux_kill (pid=15708) at src/gdb/gdbserver/linux-low.c:966
 #2  0x000000000041354d in kill_inferior (pid=15708) at src/gdb/gdbserver/target.c:163
 #3  0x00000000004107e9 in kill_inferior_callback (entry=0x6704f0) at src/gdb/gdbserver/server.c:2934
 #4  0x0000000000406522 in for_each_inferior (list=0x66b050 <all_processes>, action=0x4107a6 <kill_inferior_callback>) at src/gdb/gdbserver/inferiors.c:57
 #5  0x0000000000412377 in process_serial_event () at src/gdb/gdbserver/server.c:3767
 #6  0x000000000041267c in handle_serial_event (err=0, client_data=0x0) at src/gdb/gdbserver/server.c:3880
 #7  0x00000000004189ff in handle_file_event (event_file_desc=4) at src/gdb/gdbserver/event-loop.c:434
 #8  0x00000000004181c6 in process_event () at src/gdb/gdbserver/event-loop.c:189
 #9  0x0000000000418f45 in start_event_loop () at src/gdb/gdbserver/event-loop.c:552
 #10 0x0000000000411272 in main (argc=3, argv=0x7fffffffd8d8) at src/gdb/gdbserver/server.c:3283

The problem is that linux_wait_for_event deletes lwps that have exited
(even those not passed in as lwps of interest), while the lwp/thread
list is being walked on with find_inferior.  find_inferior can handle
the current iterated inferior being deleted, but not others.

When killing lwps, we don't really care about any of the pending
status handling of linux_wait_for_event.  We can just waitpid the lwps
directly, which is also what GDB does (see
linux-nat.c:kill_wait_callback).  This way the lwps are not deleted
while we're walking the list.  They'll be deleted by linux_mourn
afterwards.

This crash triggers several times when running the testsuite against
GDBserver with the native-gdbserver board (target remote), but as GDB
can't distinguish between GDBserver crashing and "kill" being
sucessful, as in both cases the connection is closed (the 'k' packet
doesn't require a reply), and the inferior is gone, that results in no
FAIL.

The patch adds a generic test that catches the issue with
extended-remote mode (and works fine with native testing too).  Here's
how it fails with the native-extended-gdbserver board without the fix:

 (gdb) info threads
   Id   Target Id         Frame
   6    Thread 15367.15374 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   5    Thread 15367.15373 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   4    Thread 15367.15372 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   3    Thread 15367.15371 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
   2    Thread 15367.15370 0x000000373bcbc98d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
 * 1    Thread 15367.15367 main () at .../gdb.threads/kill.c:52
 (gdb) kill
 Kill the program being debugged? (y or n) y
 Remote connection closed
 ^^^^^^^^^^^^^^^^^^^^^^^^
 (gdb) FAIL: gdb.threads/kill.exp: kill

Extended remote should remain connected after the kill.

gdb/gdbserver/
2014-07-11  Pedro Alves  <palves@redhat.com>

	* linux-low.c (kill_wait_lwp): New function, based on
	kill_one_lwp_callback, but use my_waitpid directly.
	(kill_one_lwp_callback, linux_kill): Use it.

gdb/testsuite/
2014-07-11  Pedro Alves  <palves@redhat.com>

	* gdb.threads/kill.c: New file.
	* gdb.threads/kill.exp: New file.
Don't print symbol on address 0x0

We see the following fails on arm-none-eabi target,

print (void*)v_signed_char^M
$190 = (void *) 0x0 <_ftext>^M
(gdb) FAIL: gdb.base/exprs.exp: print (void*)v_signed_char (print
(void*)v_signed_char)

GDB behaves correctly but the test assumes there is no symbol on
address 0x0.  This patch is set print symbol off, so that tests below
can match the address only.

gdb/testsuite:

2014-07-11  Yao Qi  <yao@codesourcery.com>

	* gdb.base/exprs.exp: "set print symbol off".
Rename identical functions

amd64-linux-nat.c and i386-linux-nat.c contain a number of functions
which are identical but for prefix on their names.  This commit
renames all such functions to have the prefix x86_ instead of the
prefixes amd64_ or i386_ and updates all uses of those functions.
The now-identical x86_ functions will be pulled out to a separate
shared file in a later commit.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (amd64_linux_dr_get): Renamed to
	x86_linux_dr_get.  All uses updated.
	(amd64_linux_dr_set): Renamed to
	x86_linux_dr_set.  All uses updated.
	(amd64_linux_dr_get_addr): Renamed to
	x86_linux_dr_get_addr.  All uses updated.
	(amd64_linux_dr_get_control): Renamed to
	x86_linux_dr_get_control.  All uses updated.
	(amd64_linux_dr_get_status): Renamed to
	x86_linux_dr_get_status.  All uses updated.
	(amd64_linux_dr_set_control): Renamed to
	x86_linux_dr_set_control.  All uses updated.
	(amd64_linux_dr_set_addr): Renamed to
	x86_linux_dr_set_addr.  All uses updated.
	(amd64_linux_prepare_to_resume): Renamed to
	x86_linux_prepare_to_resume.  All uses updated.
	(amd64_linux_new_thread): Renamed to
	x86_linux_new_thread.  All uses updated.
	(amd64_linux_new_fork): Renamed to
	x86_linux_new_fork.  All uses updated.
	(amd64_linux_child_post_startup_inferior): Renamed to
	x86_linux_child_post_startup_inferior.  All uses updated.
	(amd64_linux_enable_btrace): Renamed to
	x86_linux_enable_btrace.  All uses updated.
	(amd64_linux_disable_btrace): Renamed to
	x86_linux_disable_btrace.  All uses updated.
	(amd64_linux_teardown_btrace): Renamed to
	x86_linux_teardown_btrace.  All uses updated.
	(amd64_linux_read_btrace): Renamed to
	x86_linux_read_btrace.  All uses updated.
	* i386-linux-nat.c (i386_linux_dr_get): Renamed to
	x86_linux_dr_get.  All uses updated.
	(i386_linux_dr_set): Renamed to
	x86_linux_dr_set.  All uses updated.
	(i386_linux_dr_get_addr): Renamed to
	x86_linux_dr_get_addr.  All uses updated.
	(i386_linux_dr_get_control): Renamed to
	x86_linux_dr_get_control.  All uses updated.
	(i386_linux_dr_get_status): Renamed to
	x86_linux_dr_get_status.  All uses updated.
	(i386_linux_dr_set_control): Renamed to
	x86_linux_dr_set_control.  All uses updated.
	(i386_linux_dr_set_addr): Renamed to
	x86_linux_dr_set_addr.  All uses updated.
	(i386_linux_prepare_to_resume): Renamed to
	x86_linux_prepare_to_resume.  All uses updated.
	(i386_linux_new_thread): Renamed to
	x86_linux_new_thread.  All uses updated.
	(i386_linux_new_fork): Renamed to
	x86_linux_new_fork.  All uses updated.
	(i386_linux_child_post_startup_inferior): Renamed to
	x86_linux_child_post_startup_inferior.  All uses updated.
	(i386_linux_enable_btrace): Renamed to
	x86_linux_enable_btrace.  All uses updated.
	(i386_linux_disable_btrace): Renamed to
	x86_linux_disable_btrace.  All uses updated.
	(i386_linux_teardown_btrace): Renamed to
	x86_linux_teardown_btrace.  All uses updated.
	(i386_linux_read_btrace): Renamed to
	x86_linux_read_btrace.  All uses updated.
Merge {i386,amd64}_linux_read_description

This commit merges i386_ and amd64_linux_read_description, renaming
both to x86_linux_read_description.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (amd64_linux_read_description): Renamed to
	x86_linux_read_description.  All uses updated.  amd64-specific
	code conditionalized.  Conditionalized i386-specific code added.
	Redundant cast removed.
	* i386-linux-nat.c (i386_linux_read_description): Renamed to
	x86_linux_read_description.  All uses updated.  i386-specific
	code conditionalized.  Conditionalized amd64-specific code added.
	One sizeof replaced with the actual type it is describing.
Merge ps_get_thread_area

This commit adds a new helper, x86_linux_get_thread_area, to
hold the common parts of the ps_get_thread_area functions in
i386-linux-nat.c and amd64-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (x86_linux_get_thread_area): New function.
	(ps_get_thread_area): Delegate to the above in 32-bit mode.
	* i386-linux-nat.c (x86_linux_get_thread_area): New function.
	(ps_get_thread_area): Delegate to the above.
Pull out common parts of _initialize_{i386,amd64}_linux_nat

This commit adds two new helpers, x86_linux_create_target and
x86_linux_add_target, to hold the parts of _initialize_i386_linux_nat
and _initialize_amd64_linux_nat which are common.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (x86_linux_create_target): New function.
	(x86_linux_add_target): Likewise.
	(_initialize_amd64_linux_nat): Delegate to the above new functions.
	* i386-linux-nat.c (x86_linux_create_target): New function.
	(x86_linux_add_target): Likewise.
	(_initialize_i386_linux_nat): Delegate to the above new functions.
Comment and whitespace changes

This commit merges the comments and whitespace in the common
parts of i386-linux-nat.c and amd64-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c: Comment and whitespace changes.
	* i386-linux-nat.c: Comment and whitespace changes.
Move duplicated code into new files

This commit moves the duplicated code in {i386,amd64}-linux-nat.c
into the new files x86-linux-nat.[ch].  Additionally, a new
file i386-linux-nat.h was required to expose a value required
by the 32-bit code in x86-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* i386-linux-nat.h: New file.
	* x86-linux-nat.h: Likewise.
	* x86-linux-nat.c: Likewise.
	* Makefile.in (HFILES_NO_SRCDIR): Add the above new headers.
	* config/i386/linux.mh (NATDEPFILES): Add x86-linux-nat.o.
	* config/i386/linux64.mh (NATDEPFILES): Likewise.
	* amd64-linux-nat.c (x86-linux-nat.h): New include.
	(PTRACE_GETREGSET): Now in x86-linux-nat.h.
	(PTRACE_SETREGSET): Likewise.
	(arch_lwp_info): Now in x86-linux-nat.c.
	(have_ptrace_getregset): Now in x86-linux-nat.h.
	(x86_linux_dr_get): Now in x86-linux-nat.c.
	(x86_linux_dr_set): Likewise.
	(x86_linux_dr_get_addr): Likewise.
	(x86_linux_dr_get_control): Likewise.
	(x86_linux_dr_get_status): Likewise.
	(update_debug_registers_callback): Likewise.
	(x86_linux_dr_set_control): Likewise.
	(x86_linux_dr_set_addr): Likewise.
	(x86_linux_prepare_to_resume): Likewise.
	(x86_linux_new_thread): Likewise.
	(x86_linux_new_fork): Likewise.
	(x86_linux_get_thread_area): Likewise.
	(super_post_startup_inferior): Likewise.
	(x86_linux_child_post_startup_inferior): Likewise.
	(AMD64_LINUX_USER64_CS): Likewise.
	(AMD64_LINUX_X32_DS): Likewise.
	(x86_linux_read_description): Likewise.
	(x86_linux_enable_btrace): Likewise.
	(x86_linux_disable_btrace): Likewise.
	(x86_linux_teardown_btrace): Likewise.
	(x86_linux_read_btrace): Likewise.
	(x86_linux_create_target): Likewise.
	(x86_linux_add_target): Likewise.
	* i386-linux-nat.c (x86-linux-nat.h): New include.
	(PTRACE_GETREGSET): Now in x86-linux-nat.h.
	(PTRACE_SETREGSET): Likewise.
	(arch_lwp_info): Now in x86-linux-nat.c.
	(have_ptrace_getregset): Now in x86-linux-nat.h.
	(x86_linux_dr_get): Now in x86-linux-nat.c.
	(x86_linux_dr_set): Likewise.
	(x86_linux_dr_get_addr): Likewise.
	(x86_linux_dr_get_control): Likewise.
	(x86_linux_dr_get_status): Likewise.
	(update_debug_registers_callback): Likewise.
	(x86_linux_dr_set_control): Likewise.
	(x86_linux_dr_set_addr): Likewise.
	(x86_linux_prepare_to_resume): Likewise.
	(x86_linux_new_thread): Likewise.
	(x86_linux_new_fork): Likewise.
	(x86_linux_get_thread_area): Likewise.
	(super_post_startup_inferior): Likewise.
	(x86_linux_child_post_startup_inferior): Likewise.
	(AMD64_LINUX_USER64_CS): Likewise.
	(AMD64_LINUX_X32_DS): Likewise.
	(x86_linux_read_description): Likewise.
	(x86_linux_enable_btrace): Likewise.
	(x86_linux_disable_btrace): Likewise.
	(x86_linux_teardown_btrace): Likewise.
	(x86_linux_read_btrace): Likewise.
	(x86_linux_create_target): Likewise.
	(x86_linux_add_target): Likewise.
Tidy #include lists

This commit tidies up the #include lists in {i386,amd64}-linux-nat.c,
removing headers that are no longer required and reordering some lines
so that both files roughly match.  Additionally, an unused definition
was removed from the middle of the #include list in i386-linux-nat.c.

gdb/
2014-07-11  Gary Benson  <gbenson@redhat.com>

	* amd64-linux-nat.c (gdbcore.h): Remove include.
	(regset.h): Likewise.
	(nat/linux-btrace.h): Likewise.
	(btrace.h): Likewise.
	(gdb_assert.h): Likewise.
	(string.h): Likewise.
	(sys/uio.h): Likewise.
	(sys/debugreg.h): Likewise.
	(sys/syscall.h): Likewise.
	(sys/procfs.h): Likewise.
	(sys/user.h): Likewise.
	(asm/ptrace.h): Likewise.
	(i386-nat.h): Likewise.
	* i386-linux-nat.c (i386-nat.h): Likewise.
	(regset.h): Likewise.
	(target.h): Likewise.
	(linux-nat.h): Likewise.
	(nat/linux-btrace.h): Likewise.
	(btrace.h): Likewise.
	(gdb_assert.h): Likewise.
	(string.h): Likewise.
	(sys/uio.h): Likewise.
	(sys/user.h): Likewise.
	(sys/procfs.h): Likewise.
	(sys/reg.h): Likewise.
	(sys/debugreg.h): Likewise.
	(ORIG_EAX): Remove definition.