Fix remote/17230

This patch is to fix PR remote/17230, which is a leftover of the
to_xfer_partial interface change.  I tried splint and it reprots this
problem like this,

../../../git/gdb/remote-mips.c:2236: Return value type unsigned long long does not match declared type enum target_xfer_status: len

and this problem only exists in remote-mips.c.

gdb:

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

	PR remote/17230
	* remote-mips.c (mips_xfer_memory): Set *xfered_len and return
	TARGET_XFER_OK instead of 0.
Tweak comments in struct dwarf2_per_cu_data

When I read the comments to field 'u' of struct dwarf2_per_cu_data,
I don't think the comments say anything useful.  I update it per
my understanding.

gdb:

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

	* dwarf2read.c (struct dwarf2_per_cu_data) <u>: Tweak comments.
Replace 0 with TARGET_XFER_EOF in to_xfer_partial

I run splint in gdb source and get the following warnings:

  ../../../git/gdb/corelow.c:740: Return value type int does not match declared type enum target_xfer_status: 0

'TARGET_XFER_EOF' (enum target_xfer_status) is expected to be returned,
but 0 is returned.  This patch is to replace 0 with TARGET_XFER_EOF
in the implementations of to_xfer_partial.

gdb:

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

	* corelow.c (core_xfer_partial): Replace 0 with TARGET_XFER_EOF.
	* remote-m32r-sdi.c (m32r_xfer_memory): Likewise.
	* remote.c (remote_read_bytes): Likewise.
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, nat and
target.  Some of the declared functions must be provided by the client
as documented by the header file comments.

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

	* common/errors.h: New file.
	* common/errors.c: Likewise.
	* Makefile.in (SFILES): Add common/errors.c.
	(HFILES_NO_SRCDIR): Add common/errors.h.
	(COMMON_OBS): Add errors.o.
	(errors.o): New rule.
	* common/common-defs.h: Include errors.h.
	* utils.h (perror_with_name, error, verror, warning, vwarning):
	Don't declare.
	* common/common-utils.h: (malloc_failure, internal_error):
	Likewise.

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

	* Makefile.in (SFILES): Add common/errors.c.
	(OBS): Add errors.o.
	(IPA_OBS): Add errors-ipa.o.
	(errors.o): New rule.
	(errors-ipa.o): Likewise.
	* utils.h (perror_with_name, error, warning): Don't declare.
	* utils.c (warning): Renamed and rewritten as...
	(vwarning): New function.
	(error): Renamed and rewritten as...
	(verror): New function.
	(internal_error): Renamed and rewritten as...
	(internal_verror): New function.
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.

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

	* common/common-types.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/common-types.h.
	* common/common-defs.h: Include common-types.h.
	* defs.h (gdb_byte, CORE_ADDR, CORE_ADDR_MAX, LONGEST)
	(ULONGEST): Remove.

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

	* server.h: Add static assertion.
	(gdb_byte, CORE_ADDR, LONGEST, ULONGEST): Remove.
Move print-utils.h to common-defs.h

This commit moves the inclusion of print-utils.h to common-defs.h
and removes all other inclusions.

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

	* common/common-defs.h: Include print-utils.h.
	* utils.h: Do not include print-utils.h.

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

	* utils.h: Do not include print-utils.h.
Introduce common-debug.h

This introduces common-debug.h.  This holds the flag debug_hw_points
(which can be set to enable debugging of the hardware breakpoint/
watchpoint support code) and debug_printf and debug_vprintf, two
functions that the common code can use to print debugging messages.
Clients of the common code are expected to implement debug_vprintf;
a debug_vprintf function is written from scratch for GDB, and
gdbserver's existing debug_printf is repurposed as debug_vprintf.

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, and a now-unnecessary
declaration of debug_hw_points is removed.

Various other files are changed to remove declarations of
debug_hw_points.

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

	* common/common-debug.h: New file.
	* common/common-debug.c: Likewise.
	* debug.c: Likewise.
	* Makefile.in (SFILES): Add common/common-debug.c.
	(HFILES_NO_SRCDIR): Add common/common-debug.h.
	(COMMON_OBS): Add common-debug.o and debug.o.
	(common-debug.o): New rule.
	* common/common-defs.h: Include common-debug.h.
	* common/agent.c (debug_agent_printf): New function.
	(DEBUG_AGENT): Redefine.
	* nat/i386-dregs.c (debug_printf): Undefine.
	(debug_hw_points): Remove.
	* aarch64-linux-nat.c (debug_hw_points): Likewise.
	* i386-nat.c (debug_hw_points): Likewise.

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

	* Makefile.in (SFILES): Add common/common-debug.c.
	(OBS): Add common-debug.o.
	(common-debug.o): New rule.
	* debug.h (debug_printf): Don't declare.
	* debug.c (debug_printf): Renamed and rewritten as...
	(debug_vprintf): New function.
	* server.h (debug_hw_points): Remove.
	* server.c (debug_hw_points): Likewise.
	* linux-aarch64-low.c (debug_hw_points): Likewise.
Introduce target/target.h

This introduces target/target.h.  This file declares some functions
that the shared code can use and that clients must implement.  It also
changes some shared code to use these functions.

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

	* target/target.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add target/target.h.
	* target.h: Include target/target.h.
	(target_resume, target_wait, target_stop, target_read_memory)
	(target_write_memory, non_stop): Don't declare.
	* target.c (target_read_uint32): New function.
	* common/agent.c: Include target/target.h.
	[!GDBSERVER]: Don't include target.h or infrun.h.
	(agent_get_helper_thread_id): Use target_read_uint32.
	(agent_run_command): Always use target_resume, target_stop,
	target_wait, target_write_memory, and target_read_memory.
	(agent_capability_check): Use target_read_uint32.

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

	* target.c (target_wait, target_stop, target_resume)
	(target_read_memory, target_read_uint32)
	(target_write_memory): New functions.
Introduce target/symbol.h

This introduces target/symbol.h.  This file declares a function that
the shared code can use and that the clients must implement.  It also
changes some shared code to use these functions.

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

	* target/symbol.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add target/symbol.h.
	* target.h: Include target/symbol.h.
	* target.c (target_look_up_symbol): New function.
	* common/agent.c: Include target/symbol.h.
	[!GDBSERVER]: Don't include objfiles.h.
	(agent_look_up_symbols): Use target_look_up_symbol.

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

	* target.c: Include target/symbol.h.
	(target_look_up_symbol): New function.
Introduce common-regcache.h

This introduces common-regcache.h.  This contains one function,
get_thread_regcache_for_ptid, that allows nat/linux-btrace.c to
be simplified.  A better long term solution would be unify the
regcache code, but this is sufficient for now.

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

	* common/common-regcache.h: New file.
	* Makefile.in (HFILES_NO_SRCDIR): Add common/common-regcache.h.
	* regcache.c: Include the above.
	(get_thread_regcache_for_ptid): New function.
	* nat/linux-btrace.c: Include common-regcache.h.
	(perf_event_read_bts): Use get_thread_regcache_for_ptid.

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

	* regcache.c: Include common-regcache.h.
	(get_thread_regcache_for_ptid): New function.
Include common-defs.h instead of defs.h/server.h in shared code

This commit makes 19 of the 22 shared .c files in common, nat and
target include common-defs.h instead of defs.h/server.h.  The
remaining three files need slight extra work and are dealt with
in separate commits.

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

	* common/agent.c: Include common-defs.h.
	Don't include defs.h or server.h.
	* common/buffer.c: Likewise.
	* common/common-debug.c: Likewise.
	* common/common-utils.c: Likewise.
	* common/errors.c: Likewise.
	* common/filestuff.c: Likewise.
	* common/format.c: Likewise.
	* common/gdb_vecs.c: Likewise.
	* common/print-utils.c: Likewise.
	* common/ptid.c: Likewise.
	* common/rsp-low.c: Likewise.
	* common/signals.c: Likewise.
	* common/vec.c: Likewise.
	* common/xml-utils.c: Likewise.
	* nat/linux-osdata.c: Likewise.
	* nat/linux-procfs.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/mips-linux-watch.c: Likewise.
	* target/waitstatus.c: Likewise.
Remove GDBSERVER uses from linux-btrace.c

This commit makes nat/linux-btrace.c include common-defs.h rather
than defs.h or server.h.  A couple of minor changes were required
to support this change.

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

	* nat/linux-btrace.c: Include common-defs.h.
	Don't include defs.h, server.h or gdbthread.h.
	* nat/linux-btrace.h (struct target_ops): New forward declaration.
Remove GDBSERVER uses from i386-dregs.c

This commit makes nat/i386-dregs.c include common-defs.h rather than
defs.h or server.h.  An extra header required including in order to
support this change.

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

	* nat/i386-dregs.c: Include common-defs.h and break-common.h.
	Don't include defs.h or server.h.
Remove one GDBSERVER use from linux-waitpid.c

This commit makes nat/linux-waitpid.c include common-defs.h rather
than defs.h or server.h.  A use of GDBSERVER had to be left in to
support some some thread_db debug code.  This hack will be removed
when the Linux thread_db code is unified and made shared.

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

	* nat/linux-waitpid.c: Include common-defs.h.
	Don't include defs.h or server.h.
	(linux_debug) [GDBSERVER]: Declare debug_threads.
New file gdb_setjmp.h
Move internal_{,v}warning to common/errors.[ch]
Move cleanups.[ch] to common
Tentative go at capturing main
Move more exceptions.h stuff across
Move gdb_setjmp.h to common-exceptions.h