Constify regset structures.
Remove 'arch' field from regset structure.

Removes the 'arch' field from the regset structure, since it
represents the only "dynamic" data in a regset.  It was referenced in
some regset supply- and collect routines, to get access to the gdbarch
associated with the regset.  Naturally, the affected routines always
have access to the regcache to be supplied to or collected from.  Thus
the gdbarch associated with that regcache can be used instead.
AARCH64: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the tdep fields
'gregset' and 'fpregset' become obsolete and are thus removed.
ARM: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the appropriate tdep
fields become obsolete and are thus removed.
X86: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the appropriate tdep
fields become obsolete and are thus removed.
MIPS: Replace regset_alloc() invocations by static regset structures.

After removal of the regset_alloc invocations, the appropriate tdep
fields become obsolete and are thus removed.
MN10300: Replace regset_alloc() invocations by static regset structures.

On this architecture the change may fix a small memory leak.
SCORE: Replace regset_alloc() invocation by a static regset structure.

Since this changes makes the only member of the tdep structure
obsolete, the tdep structure is removed.
SPARC: Rename register maps from "*regset" to "*regmap"

Clear the naming confusion about "regset" versus "sparc*regset".  The
latter was used to represent the *map* of a register set, not the
register set itself, and is thus renamed accordingly.

The following identifiers are renamed:

  sparc32_bsd_fpregset => sparc32_bsd_fpregmap
  sparc32_linux_core_gregset => sparc32_linux_core_gregmap
  sparc32_sol2_fpregset => sparc32_sol2_fpregmap
  sparc32_sol2_gregset => sparc32_sol2_gregmap
  sparc32_sunos4_fpregset => sparc32_sunos4_fpregmap
  sparc32_sunos4_gregset => sparc32_sunos4_gregmap
  sparc32nbsd_gregset => sparc32nbsd_gregmap
  sparc64_bsd_fpregset => sparc64_bsd_fpregmap
  sparc64_linux_core_gregset => sparc64_linux_core_gregmap
  sparc64_linux_ptrace_gregset => sparc64_linux_ptrace_gregmap
  sparc64_sol2_fpregset => sparc64_sol2_fpregmap
  sparc64_sol2_gregset => sparc64_sol2_gregmap
  sparc64fbsd_gregset => sparc64fbsd_gregmap
  sparc64nbsd_gregset => sparc64nbsd_gregmap
  sparc64obsd_core_gregset => sparc64obsd_core_gregmap
  sparc64obsd_gregset => sparc64obsd_gregmap
  sparc_fpregset => sparc_fpregmap
  sparc_gregset => sparc_gregmap
  sparc_sol2_fpregset => sparc_sol2_fpregmap
  sparc_sol2_gregset => sparc_sol2_gregmap

Also, all local variables 'gregset' and 'fpregset' are renamed to
'gregmap' and 'fpregmap', respectively.
SPARC: Replace regset_alloc() invocations by static regset structures.
Drop regset_alloc().

Now that all invocations of regset_alloc() have been removed, the
function is dropped.  Since regset_alloc() was the only function
provided by regset.c, this source file is removed as well.
Rename "target child" to "target native".

I had been pondering renaming "target child" to something else.
"child" is a little lie in case of "attach", and not exactly very
clear to users, IMO.  By best suggestion is "target native".  If I
were to explain what "target child" is, I'd just start out with "it's
the native target" anyway.  I was worrying a little that "native"
might be a lie too if some port comes up with a default target that
can run but is not really native, but I think that's a very minor
issue - we can consider that "native" really means the default built
in target that GDB supports, instead of saying that's the target that
debugs host native processes, if it turns out necessary.

This change doesn't affect users much, because "target child" results
in error today:

 (gdb) target child
 Use the "run" command to start a child process.

Other places "child" is visible:

 (gdb) help target
 ...
 List of target subcommands:

 target child -- Child process (started by the "run" command)
 target core -- Use a core file as a target
 target exec -- Use an executable file as a target
 ...

 (gdb) info target
 Symbols from "/home/pedro/gdb/mygit/build/gdb/gdb".
 Child process:
	 Using the running image of child Thread 0x7ffff7fc9740 (LWP 4818).
	 While running this, GDB does not access memory from...
 ...

These places will say "native" instead.  I think that's a good thing.

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* inf-child.c (inf_child_open): Remove mention of "child".
	(inf_child_target): Rename target to "native" instead of "child".

gdb/testsuite/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* gdb.base/default.exp: Test "target native" instead of "target
	child".
Rename "target djgpp" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* go32-nat.c (go32_target): Don't override to_shortname,
	to_longname or to_doc.
Rename "target darwin-child" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* darwin-nat.c (_initialize_darwin_inferior): Don't override
	to_shortname, to_longname or to_doc.
Rename "target GNU" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* gnu-nat.c (gnu): Don't override to_shortname, to_longname or
	to_doc.
Windows: Rename "target child" -> "target native"

To be like other native targets.

Leave to_shortname, to_longname, to_doc as inf-child.c sets them:

  t->to_shortname = "native";
  t->to_longname = "Native process";
  t->to_doc = "Native process (started by the \"run\" command).";

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* windows-nat.c (windows_target): Don't override to_shortname,
	to_longname or to_doc.
nto-procfs.c: Add "target native".

This makes QNX/NTO end up with two targets.  It preserves "target
procfs <node>", and adds a "native" target to be like other native
ports.

Not tested.

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* nto-procfs.c (procfs_can_run): New function.
	(nto_procfs_ops): New global.
	(init_procfs_targets): New, based on procfs_target.  Install
	"target native" in addition to "target procfs".
	(_initialize_procfs): Call init_procfs_targets instead of adding
	the target here.
go32-nat.c: Don't override to_open.

Although the string says "Done.", nothing is pushing the target as is.
Removing the method override let's us fall through to the the base
to_open implemention in inf-child.c, which will push the target in
reaction to "target native" in a follow up patch.

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* go32-nat.c (go32_open): Delete.
	(go32_target): Don't override the to_open method.
NEWS: Mention native target renames.

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* NEWS: Mention that the "child", "GNU, "djgpp", "darwin-child"
	and "procfs" targets are now called "native" instead.
Allow making GDB not automatically connect to the native target.

Sometimes it's useful to be able to disable the automatic connection
to the native target.  E.g., sometimes GDB disconnects from the
extended-remote target I was debugging, without me noticing it, and
then I do "run".  That starts the program locally, and only after a
little head scratch session do I figure out the program is running
locally instead of remotely as intended.  Same thing with "attach",
"info os", etc.

With the patch, we now can have this instead:

 (gdb) set auto-connect-native-target off
 (gdb) target extended-remote :9999
 ...
 *gdb disconnects*
 (gdb) run
 Don't know how to run.  Try "help target".

To still be able to connect to the native target with
auto-connect-native-target set to off, I've made "target native" work
instead of erroring out as today.

Before:

 (gdb) target native
 Use the "run" command to start a native process.

After:

 (gdb) target native
 Done.  Use the "run" command to start a process.
 (gdb) maint print target-stack
 The current target stack is:
   - native (Native process)
   - exec (Local exec file)
   - None (None)
 (gdb) run
 Starting program: ./a.out
 ...

I've also wanted this for the testsuite, when running against the
native-extended-gdbserver.exp board (runs against gdbserver in
extended-remote mode).  With a non-native-target board, it's always a
bug to launch a program with the native target.  Turns out we still
have one such case this patch catches:

 (gdb) break main
 Breakpoint 1 at 0x4009e5: file ../../../src/gdb/testsuite/gdb.base/coremaker.c, line 138.
 (gdb) run
 Don't know how to run.  Try "help target".
 (gdb) FAIL: gdb.base/corefile.exp: run: with core

On the patch itself, probably the least obvious bit is the need to go
through all targets, and move the unpush_target call to after the
generic_mourn_inferior call instead of before.  This is what
inf-ptrace.c does too, ever since multi-process support was added.
The reason inf-ptrace.c does things in that order is that in the
current multi-process/single-target model, we shouldn't unpush the
target if there are still other live inferiors being debugged.  The
check for that is "have_inferiors ()" (a misnomer nowadays...), which
does:

 have_inferiors (void)
 {
   for (inf = inferior_list; inf; inf = inf->next)
     if (inf->pid != 0)
       return 1;

It's generic_mourn_inferior that ends up clearing inf->pid, so we need
to call it before the have_inferiors check.  To make all native
targets behave the same WRT to explicit "target native", I've added an
inf_child_maybe_unpush_target function that targets call instead of
calling unpush_target directly, and as that includes the
have_inferiors check, I needed to adjust the targets.

Tested on x86_64 Fedora 20, native, and also with the
extended-gdbserver board.

Confirmed a cross build of djgpp gdb still builds.

Smoke tested a cross build of Windows gdb under Wine.

Untested otherwise.

gdb/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* inf-child.c (inf_child_ops, inf_child_explicitly_opened): New
	globals.
	(inf_child_open_target): New function.
	(inf_child_open): Use inf_child_open_target to push the target
	instead of erroring out.
	(inf_child_disconnect, inf_child_close)
	(inf_child_maybe_unpush_target): New functions.
	(inf_child_target): Install inf_child_disconnect and
	inf_child_close.  Store a pointer to the returned object.
	* inf-child.h (inf_child_open_target, inf_child_maybe_unpush): New
	declarations.
	* target.c (auto_connect_native_target): New global.
	(show_default_run_target): New function.
	(find_default_run_target): Return NULL if automatically connecting
	to the native target is disabled.
	(_initialize_target): Install set/show auto-connect-native-target.
	* NEWS: Mention "set auto-connect-native-target", and "target
	native".
	* linux-nat.c (super_close): New global.
	(linux_nat_close): Call super_close.
	(linux_nat_add_target): Store a pointer to the base class's
	to_close method.
	* inf-ptrace.c (inf_ptrace_mourn_inferior, inf_ptrace_detach): Use
	inf_child_maybe_unpush.
	* inf-ttrace.c (inf_ttrace_him): Don't push the target if it is
	already pushed.
	(inf_ttrace_mourn_inferior): Only unpush the target after mourning
	the inferior.  Use inf_child_maybe_unpush_target.
	(inf_ttrace_attach): Don't push the target if it is already
	pushed.
	(inf_ttrace_detach): Use inf_child_maybe_unpush_target.
	* darwin-nat.c (darwin_mourn_inferior): Only unpush the target
	after mourning the inferior.  Use inf_child_maybe_unpush_target.
	(darwin_attach_pid): Don't push the target if it is already
	pushed.
	* gnu-nat.c (gnu_mourn_inferior): Only unpush the target after
	mourning the inferior.  Use inf_child_maybe_unpush_target.
	(gnu_detach): Use inf_child_maybe_unpush_target.
	* go32-nat.c (go32_create_inferior): Don't push the target if it
	is already pushed.
	(go32_mourn_inferior): Use inf_child_maybe_unpush_target.
	* nto-procfs.c (procfs_is_nto_target): Adjust comment.
	(procfs_open): Rename to ...
	(procfs_open_1): ... this.  Add target_ops parameter.  Adjust
	comments.  Can target_preopen before changing node.  Call
	inf_child_open_target to push the target explicitly.
	(procfs_attach): Don't push the target if it is already pushed.
	(procfs_detach): Use inf_child_maybe_unpush_target.
	(procfs_create_inferior): Don't push the target if it is already
	pushed.
	(nto_native_ops): New global.
	(procfs_open): Reimplement.
	(procfs_native_open): New function.
	(init_procfs_targets): Install procfs_native_open as to_open of
	"target native".  Store a pointer to the "native" target in
	nto_native_ops.
	* procfs.c (procfs_attach): Don't push the target if it is already
	pushed.
	(procfs_detach): Use inf_child_maybe_unpush_target.
	(procfs_mourn_inferior): Only unpush the target after mourning the
	inferior.  Use inf_child_maybe_unpush_target.
	(procfs_init_inferior): Don't push the target if it is already
	pushed.
	* windows-nat.c (do_initial_windows_stuff): Don't push the target
	if it is already pushed.
	(windows_detach): Use inf_child_maybe_unpush_target.
	(windows_mourn_inferior): Only unpush the target after mourning
	the inferior.  Use inf_child_maybe_unpush_target.

gdb/doc/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* gdb.texinfo (Starting): Document "set/show
	auto-connect-native-target".
	(Target Commands): Document "target native".

gdb/testsuite/
2014-05-21  Pedro Alves  <palves@redhat.com>

	* boards/gdbserver-base.exp (GDBFLAGS): Set to "set
	auto-connect-native-target off".
	* gdb.base/auto-connect-native-target.c: New file.
	* gdb.base/auto-connect-native-target.exp: New file.