auto-generate most target debug methods

The target debug methods are inconsistently maintained.  Most to_*
methods have some kind of targetdebug awareness, but not all of them
do.  The ones that do vary in the quantity and quality of output they
generate.

This patch changes most of the target debug methods to be
automatically generated.  All the arguments are printed, and separate
lines are printed for entering and existing the outermost call to the
target stack.

For example now you'd see:

    -> multi-thread->to_terminal_ours (...)
    -> multi-thread->to_is_async_p (...)
    <- multi-thread->to_is_async_p (0x1ebb580) = 1
    <- multi-thread->to_terminal_ours (0x1ebb580)
    -> multi-thread->to_thread_address_space (...)
    <- multi-thread->to_thread_address_space (0x1ebb580, 26802) = 1

In this case you can see nested calls.  The "multi-thread" on the left
hand side is the topmost target's shortname.

There are some oddities with this patch.  I'm on the fence about it
all, I really just wrote it on a whim.

It's not simple to convert every possible method, since a few don't
participate in target delegation.

Printing is done by type, so I introduced some new
debug-printing-specific typedefs to handle cases where it is nicer to
do something else.

On the plus side, this lays the groundwork for making targetdebug
affect every layer of the target stack.  The idea would be to wrap
each target_ops in the stack with its own debug_target, and then you
could see calls propagate down the stack and back up; I suppose with
indentation to make it prettier.  (That said there are some gotchas
lurking in this idea due to target stack introspection.)

Regtested on x86-64 Fedora 20.

2014-07-24  Tom Tromey  <tromey@redhat.com>

	* make-target-delegates (munge_type, write_debugmethod): New
	functions.
	(debug_names): New global.
	($TARGET_DEBUG_PRINTER): New global.
	(write_function_header): Strip TARGET_DEBUG_PRINTER from the type
	name.
	Write debug methods.  Generate init_debug_target.
	* target-debug.h: New file.
	* target-delegates.c: Rebuild.
	* target.c: Include target-debug.h.
	(debug_target): Hoist definition.
	(target_kill, target_get_section_table, target_memory_map)
	(target_flash_erase, target_flash_done, target_detach)
	(target_disconnect, target_wait, target_resume)
	(target_pass_signals, target_program_signals, target_follow_fork)
	(target_mourn_inferior, target_search_memory)
	(target_thread_address_space, target_close)
	(target_find_new_threads, target_core_of_thread)
	(target_verify_memory, target_insert_mask_watchpoint)
	(target_remove_mask_watchpoint): Remove targetdebug code.
	(debug_to_post_attach, debug_to_prepare_to_store)
	(debug_to_files_info, debug_to_insert_breakpoint)
	(debug_to_remove_breakpoint, debug_to_can_use_hw_breakpoint)
	(debug_to_region_ok_for_hw_watchpoint)
	(debug_to_can_accel_watchpoint_condition)
	(debug_to_stopped_by_watchpoint, debug_to_stopped_data_address)
	(debug_to_watchpoint_addr_within_range)
	(debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint)
	(debug_to_insert_watchpoint, debug_to_remove_watchpoint)
	(debug_to_terminal_init, debug_to_terminal_inferior)
	(debug_to_terminal_ours_for_output, debug_to_terminal_ours)
	(debug_to_terminal_save_ours, debug_to_terminal_info)
	(debug_to_load, debug_to_post_startup_inferior)
	(debug_to_insert_fork_catchpoint)
	(debug_to_remove_fork_catchpoint)
	(debug_to_insert_vfork_catchpoint)
	(debug_to_remove_vfork_catchpoint)
	(debug_to_insert_exec_catchpoint)
	(debug_to_remove_exec_catchpoint, debug_to_has_exited)
	(debug_to_can_run, debug_to_thread_architecture, debug_to_stop)
	(debug_to_rcmd, debug_to_pid_to_exec_file): Remove.
	(setup_target_debug): Call init_debug_target.
	* target.h (TARGET_DEBUG_PRINTER): New macro.
	(struct target_ops) <to_resume, to_wait, to_pass_signals,
	to_program_signals>: Use TARGET_DEBUG_PRINTER.
Make gdbserver CORE_ADDR unsigned

gdbserver defines CORE_ADDR to be signed.  This seems erroneous to
me; and furthermore likely to cause problems in common/, as it is
different from gdb's definition.

gdb/gdbserver/
2014-07-24  Tom Tromey  <tromey@redhat.com>
	    Gary Benson  <gbenson@redhat.com>

	* server.h (CORE_ADDR): Now unsigned.
Remove some GDBSERVER checks from linux-ptrace

This patch removes some GDBSERVER checks from nat/linux-ptrace.c.
Currently the code uses a compile-time check to decide whether some
flags should be used.  This changes the code to instead let users of
the module specify an additional set of flags; and then changes gdb's
linux-nat.c to call this function.  At some later date, when the back
ends are fully merged, we will be able to remove this function again.

gdb/
2014-07-24  Tom Tromey  <tromey@redhat.com>
	    Gary Benson  <gbenson@redhat.com>

	* nat/linux-ptrace.c (additional_flags): New global.
	(linux_test_for_tracesysgood, linux_test_for_tracefork): Use
	additional_flags; don't check GDBSERVER.
	(linux_ptrace_set_additional_flags): New function.
	* nat/linux-ptrace.h (linux_ptrace_set_additional_flags):
	Declare.
	* linux-nat.c (_initialize_linux_nat): Call
	linux_ptrace_set_additional_flags.
Introduce common/errors.h

This introduces common/errors.h.  This holds some error- and
warning-related declarations that can be used by the code in common.
Clients of the "common" code must provide definitions for these
functions.
Introduce common-types.h

This introduces common-types.h.  This file defines various standard
types used by gdb and gdbserver.

Currently these types are conditionally defined based on GDBSERVER.
The long term goal is to remove all such tests; however, this is
difficult as currently gdb uses definitions from BFD.  In the meantime
this is still a step in the right direction.
Introduce and use debug_printf and debug_vprintf

This introduces debug_printf and debug_vprintf, a function that
clients of "common" are expected to implement.  gdbserver's
existing debug_printf is repurposed as debug_vprintf, and a new
wrapper is written.

common/agent.c is changed to use debug_vprintf rather than
defining the macro DEBUG_AGENT depending on GDBSERVER.

nat/i386-dregs.c is changed to use the externally-implemented
debug_printf, rather than defining it itself.
Remove simple GDBSERVER uses from common, nat and target

This removes various simple GDBSERVER uses from common, nat and
target.  The simple uses are just cases where the code includes defs.h
or server.h depending on GDBSERVER.  Instead, now the files include
the headers that they require.  Unfortunately we still need to check
GDBSERVER for some files to decide which gnulib config header to
import, but this is a step in the right direction.
Remove GDBSERVER use from nat/i386-dregs.c

This removes the use of GDBSERVER from nat/i386-dregs.c.  Neither
defs.h or server.h are included: the specific files required are
listed instead.  Also, a declaration previously made only outside
of gdbserver is made unconditional.
Make btrace-common.h not use GDBSERVER

This changes btrace-common.h not to include defs.h or server.h.
Instead it moves the defs.h include to btrace.c.
Mostly remove GDBSERVER from linux-waitpid.c

This commit mostly removes the use of GDBSERVER from
nat/linux-waitpid.c.  A use remains for some debugging
code that I will remove when the Linux thread_db code
is refactored.
Add target/target.h

This adds target/target.h.  This file declares some functions that the
"common" code can use and that the clients must implement.  It also
changes code in common to use these functions.
More target unification

This unifies a few more top-level target functions -- target_resume,
target_wait, and target_stop -- and the declaration of the variable
"non_stop".  This follows the usual pattern, where clients of "common"
are expected to define the objects appropriately, thus simplifying
common/agent.c a bit more.
Add target/symbol.h, update users

This adds a new "target/symbol.h" file, that declares a symbol-lookup
function used by code in common.  It follows the usual pattern, where
clients of "common" have their own definitions of this function.  This
simplifies agent.c a bit.
Finally remove GDBSERVER (mostly) from agent.c

This reduces the use of the GDBSERVER define in agent.c to deciding
which gnulib header to include.
Introduce get_thread_regcache_for_ptid

This introduces get_thread_regcache_for_ptid so that we can simplify
nat/linux-btrace.c.  A better long term solution would be unify the
regcache code, but this is sufficient for now.
Finally remove GDBSERVER (mostly) from linux-btrace.c

This applies the usual GDBSERVER treatment to linux-btrace.c.
Now it is used only to find the gnulib header.