Fix target async/delegation -list-target-features regression.

(and fix "attach" with "target sim")

Before the recent target method delegation rework, before being
connected to a target, on GNU/Linux with 'set target-async on' we'd
get:

 -list-target-features
 ^done,features=["async"]

But currently we get:

 -list-target-features
 ^done,features=[""]

Since the delegation rework, target_can_async_p no longer looks up in
the default run target itself.  Instead callers themselves look up the
right target to check.  But, -list-target-features wasn't updated in
that direction.

While looking for the right predicate to compare the current target
against, when looking up the target to use in the command, I realized
that find_run_target and find_attach_target have an issue.  E.g., say
we're already connected to a target, but that target doesn't implement
"to_attach".  E.g., the sim, before "run", on ppc64 GNU/Linux:

 $ ./gdb a.out
 GNU gdb (GDB) 7.7.50.20140325-cvs
 (gdb) tar sim
 Connected to the simulator.
 (gdb) attach 1
 Attaching to program: a.out, process 1
 ptrace: Operation not permitted.
 (gdb)

(I confirmed GDB "always" behaved this way.  Well, OK, I tried 7.7 and
7.6.)

We should not try to attach with the native target then, automatically
disconnecting from the target we were already connected to.  Instead
we should error out saying the target can't attach.  Like this (after
the patch):

 (gdb) tar sim
 Connected to the simulator.
 (gdb) attach 1
 Don't know how to attach.  Try "help target".

The right predicate should be what
target_info_proc/target_get_osdata/default_fileio_target already use:
if already connected to a process_stratum target, use that, otherwise,
try the default run (native) target.  That's now implemented in
find_connect_target.  Since that can return a target >
process_stratum, we need to make to_attach and to_create_inferior be
regular delegate methods.  And with that, target_require_runnable's
check of to_create_inferior against NULL no longer works, as the
method will always be non-null.  So to fix that, this adds a new
target_can_create_inferior method, and installs it on all targets that
do have a to_create_inferior method.  Native targets get it from
inf-child.c.

New test included to exercise the -list-target-features regression.

Tested on x86_64 Fedora 17, native, native gdbserver/remote, and
native gdbserver/extended-remote.

gdb/
2014-03-25  Pedro Alves  <palves@redhat.com>

	* inf-child.c (return_zero): Delete.
	(inf_child_target): Install tdefault_return_zero instead of
	return_zero.  Install tdefault_return_one as
	to_can_create_inferior method.
	* infcmd.c (run_command_1, attach_command): Use
	find_connect_target.
	* mi/mi-main.c (mi_cmd_list_target_features): Work with the target
	returned by find_connect_target.
	* monitor.c (init_base_monitor_ops): Install tdefault_return_one
	as to_can_create_inferior method.
	* remote-m32r-sdi.c (init_m32r_ops): Install tdefault_return_one
	as to_can_create_inferior method.
	* remote-mips.c (_initialize_remote_mips): Install
	tdefault_return_one as to_can_create_inferior method.
	* remote-sim.c (init_gdbsim_ops): Install tdefault_return_one as
	to_can_create_inferior method.
	* remote.c (init_extended_remote_ops): Install tdefault_return_one
	as to_can_create_inferior method.
	* target.c (tdefault_create_inferior, tdefault_attach): New
	functions.
	(complete_target_initialization): Adjust.
	(target_require_runnable): Use target_can_create_inferior instead
	of walking the target stack.  Remove now unreachable
	internal_error.
	(find_default_run_target): Delete forward declaration, and
	constify.
	(find_attach_target, find_run_target): Delete.
	(find_connect_target): New function.
	(target_info_proc, target_get_osdata, default_fileio_target): Use
	it.
	(return_zero): Rename to ...
	(tdefault_return_zero): ... this, and make extern.
	(tdefault_return_one): New function.
	(init_dummy_target): Adjust.
	* target.h (struct target_ops) <to_attach>: Install
	tdefault_attach as default method.
	<to_create_inferior>: Install tdefault_create_inferior as default
	method.
	<to_can_create_inferior>: New method.
	(find_default_attach, find_default_create_inferior): Delete
	declarations.
	(find_connect_target): New declaration.
	(tdefault_create_inferior, tdefault_attach, tdefault_return_zero)
	(tdefault_return_one): Add declarations.
	(target_can_create_inferior): New define.
	(find_attach_target, find_run_target): Delete
	declarations.
	* target-delegates.c: Regenerate.

gdb/testsuite/
2014-03-25  Pedro Alves  <palves@redhat.com>

	* gdb.mi/mi-list-target-features.exp: New file.
a