binutils-gdb/gdb/gdbserver
Simon Marchi ad02e4fe87 Makefiles: Disable suffix rules and implicit rules
Since we don't use suffix rules nor implicit rules in gdb, we can
disable them.  The advantage is a slightly faster make [1].

Here are some numbers about the speedup.  I ran this on my trusty old
Intel Q6600, so the time numbers are probably higher than what you'd get
on any recent hardware.  I ran "make" in the gdb/ directory of an
already built repository (configured with --enable-targets=all).  I
recorded the time of execution (average of 5).  I then ran "make -d" and
recorded the number of printed lines, which gives a rough idea of the
number of operations done.

I compared the following configurations, to see the impact of both the
empty .SUFFIXES target and the empty pattern rules, as well as running
"make -r", which can be considered the "ideal" case.

 A - baseline
 B - baseline + .SUFFIXES
 C - baseline + pattern rules
 D - baseline + .SUFFIXES + pattern rules
 E - baseline + make -r

 config | time (s) | "make -d"
 -----------------------------
    A   |   5.74   |  2396643
    B   |   1.19   |   298469
    C   |   2.81   |  1266573
    D   |   1.13   |   245489
    E   |   1.01   |   163914

We can see that the empty .SUFFIXES target has a bigger impact than the
empty pattern rules, but still it doesn't hurt to disable the implicit
pattern rules as well.

There are still some mentions of implicit rules I can't get rid of in
the "make -d" output.  For example, it's trying to build .c files from
.w files:

  Looking for an implicit rule for '/home/simark/src/binutils-gdb/gdb/infrun.c'.
  Trying pattern rule with stem 'infrun'.
  Trying implicit prerequisite '/home/simark/src/binutils-gdb/gdb/infrun.w'.

and trying to build Makefile.in from a bunch of extensions:

  Looking for an implicit rule for 'Makefile.in'.
  Trying pattern rule with stem 'Makefile.in'.
  Trying implicit prerequisite 'Makefile.in.o'.
  Trying pattern rule with stem 'Makefile.in'.
  Trying implicit prerequisite 'Makefile.in.c'.
  Trying pattern rule with stem 'Makefile.in'.
  Trying implicit prerequisite 'Makefile.in.cc'.
  ... many more ...

If somebody knows how to disable them, we can do it, but at this point
the returns are minimal, so it is not that important.

I verified that both in-tree and out-of-tree builds work.

[1] Switching from explicit rules to pattern rules for files in
    subdirectories actually made it slower, so this is kind of a way to
    redeem myself.  But it the end it's faster than it was previously,
    so it was all worth it. :)

gdb/ChangeLog:

	* disable-implicit-rules.mk: New file.
	* Makefile.in: Include disable-implicit-rules.mk.
	* data-directory/Makefile.in: Likewise.
	* gnulib/Makefile.in: Likewise.

gdb/doc/ChangeLog:

	* Makefile.in: Likewise.

gdb/gdbserver/ChangeLog:

	* Makefile.in: Include disable-implicit-rules.mk.

gdb/testsuite/ChangeLog:

	* Makefile.in: Include disable-implicit-rules.mk.
2016-11-30 16:23:59 -05:00
..
.gitignore Update and add .gitignore's 2016-09-21 13:12:21 -04:00
acinclude.m4 gdb: Require C++11 2016-10-28 16:03:19 +01:00
aclocal.m4
ax.c
ax.h
ChangeLog Makefiles: Disable suffix rules and implicit rules 2016-11-30 16:23:59 -05:00
config.in gdb: Require C++11 2016-10-28 16:03:19 +01:00
configure Remove code that checks for GNU/non-GNU make 2016-11-17 12:00:10 -05:00
configure.ac Remove code that checks for GNU/non-GNU make 2016-11-17 12:00:10 -05:00
configure.srv Update the path arm-*.xml files for aarch64 2016-10-05 10:00:24 +01:00
debug.c gdb: Use C++11 std::chrono 2016-11-23 15:36:26 +00:00
debug.h
dll.c
dll.h
event-loop.c gdbserver: Use warning for warnings 2016-11-23 01:18:42 +00:00
event-loop.h
gdb_proc_service.h Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
gdbreplay.c
gdbthread.h
hostio-errno.c
hostio.c
hostio.h
i387-fp.c
i387-fp.h
inferiors.c Get pending events in random 2016-10-27 16:05:06 +01:00
inferiors.h Get pending events in random 2016-10-27 16:05:06 +01:00
linux-aarch32-low.c Share enum arm_breakpoint_kinds 2016-10-10 11:11:25 +01:00
linux-aarch32-low.h
linux-aarch64-ipa.c
linux-aarch64-low.c [GDBserver] Fix conversion warning 2016-10-24 11:07:24 +01:00
linux-amd64-ipa.c x32 Fast tracepoints: Customize jump pad address 2016-08-19 12:11:30 +01:00
linux-arm-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-bfin-low.c
linux-cris-low.c
linux-crisv32-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-i386-ipa.c
linux-ia64-low.c
linux-low.c gdbserver: Use warning for warnings 2016-11-23 01:18:42 +00:00
linux-low.h gdbserver: Leave already-vCont-resumed threads as they were 2016-10-26 16:22:27 +01:00
linux-m32r-low.c
linux-m68k-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-mips-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-nios2-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-ppc-ipa.c
linux-ppc-low.c
linux-ppc-tdesc.h
linux-s390-ipa.c
linux-s390-low.c
linux-s390-tdesc.h
linux-sh-low.c
linux-sparc-low.c
linux-tic6x-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-tile-low.c
linux-x86-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
linux-x86-tdesc.h
linux-xtensa-low.c Sync proc_service definition with GLIBC 2016-08-25 08:42:03 +01:00
lynx-i386-low.c
lynx-low.c
lynx-low.h
lynx-ppc-low.c
Makefile.in Makefiles: Disable suffix rules and implicit rules 2016-11-30 16:23:59 -05:00
mem-break.c gdbserver: Use warning for warnings 2016-11-23 01:18:42 +00:00
mem-break.h [GDBserver] Replace "reinsert_breakpoint" with "single_step_breakpoint" 2016-09-02 15:49:57 +01:00
notif.c gdbserver: Use debug_printf for debug output 2016-11-23 01:11:50 +00:00
notif.h
nto-low.c
nto-low.h
nto-x86-low.c
proc-service.c
proc-service.list
README
regcache.c
regcache.h
remote-utils.c gdbserver: Use debug_printf for debug output 2016-11-23 01:11:50 +00:00
remote-utils.h
server.c gdbserver: Use debug_printf for debug output 2016-11-23 01:11:50 +00:00
server.h gdbserver: Leave already-vCont-resumed threads as they were 2016-10-26 16:22:27 +01:00
spu-low.c
symbol.c
target.c Consolidate API of target_supports_multi_process 2016-10-06 17:00:53 -04:00
target.h Consolidate API of target_supports_multi_process 2016-10-06 17:00:53 -04:00
tdesc.c
tdesc.h
terminal.h
thread-db.c gdbserver: Use debug_printf for debug output 2016-11-23 01:11:50 +00:00
tracepoint.c gdb: Use C++11 std::chrono 2016-11-23 15:36:26 +00:00
tracepoint.h
utils.c
utils.h
win32-arm-low.c
win32-i386-low.c
win32-low.c
win32-low.h
wincecompat.c
wincecompat.h
x86-low.c
x86-low.h
xtensa-xtregs.c

		   README for GDBserver & GDBreplay
		    by Stu Grossman and Fred Fish

Introduction:

This is GDBserver, a remote server for Un*x-like systems.  It can be used to
control the execution of a program on a target system from a GDB on a different
host.  GDB and GDBserver communicate using the standard remote serial protocol
implemented in remote.c, and various *-stub.c files.  They communicate via
either a serial line or a TCP connection.

For more information about GDBserver, see the GDB manual.

Usage (server (target) side):

First, you need to have a copy of the program you want to debug put onto
the target system.  The program can be stripped to save space if needed, as
GDBserver doesn't care about symbols.  All symbol handling is taken care of by
the GDB running on the host system.

To use the server, you log on to the target system, and run the `gdbserver'
program.  You must tell it (a) how to communicate with GDB, (b) the name of
your program, and (c) its arguments.  The general syntax is:

	target> gdbserver COMM PROGRAM [ARGS ...]

For example, using a serial port, you might say:

	target> gdbserver /dev/com1 emacs foo.txt

This tells GDBserver to debug emacs with an argument of foo.txt, and to
communicate with GDB via /dev/com1.  GDBserver now waits patiently for the
host GDB to communicate with it.

To use a TCP connection, you could say:

	target> gdbserver host:2345 emacs foo.txt

This says pretty much the same thing as the last example, except that we are
going to communicate with the host GDB via TCP.  The `host:2345' argument means
that we are expecting to see a TCP connection from `host' to local TCP port
2345.  (Currently, the `host' part is ignored.)  You can choose any number you
want for the port number as long as it does not conflict with any existing TCP
ports on the target system.  This same port number must be used in the host
GDBs `target remote' command, which will be described shortly.  Note that if
you chose a port number that conflicts with another service, GDBserver will
print an error message and exit.

On some targets, GDBserver can also attach to running programs.  This is
accomplished via the --attach argument.  The syntax is:

	target> gdbserver --attach COMM PID

PID is the process ID of a currently running process.  It isn't necessary
to point GDBserver at a binary for the running process.

Usage (host side):

You need an unstripped copy of the target program on your host system, since
GDB needs to examine it's symbol tables and such.  Start up GDB as you normally
would, with the target program as the first argument.  (You may need to use the
--baud option if the serial line is running at anything except 9600 baud.)
Ie: `gdb TARGET-PROG', or `gdb --baud BAUD TARGET-PROG'.  After that, the only
new command you need to know about is `target remote'.  It's argument is either
a device name (usually a serial device, like `/dev/ttyb'), or a HOST:PORT
descriptor.  For example:

	(gdb) target remote /dev/ttyb

communicates with the server via serial line /dev/ttyb, and:

	(gdb) target remote the-target:2345

communicates via a TCP connection to port 2345 on host `the-target', where
you previously started up GDBserver with the same port number.  Note that for
TCP connections, you must start up GDBserver prior to using the `target remote'
command, otherwise you may get an error that looks something like
`Connection refused'.

Building GDBserver:

The supported targets as of November 2006 are:
	arm-*-linux*
	bfin-*-uclinux
	bfin-*-linux-uclibc
	crisv32-*-linux*
	cris-*-linux*
	i[34567]86-*-cygwin*
	i[34567]86-*-linux*
	i[34567]86-*-mingw*
	ia64-*-linux*
	m32r*-*-linux*
	m68*-*-linux*
	m68*-*-uclinux*
	mips*64*-*-linux*
	mips*-*-linux*
	powerpc[64]-*-linux*
	s390[x]-*-linux*
	sh-*-linux*
	spu*-*-*
	x86_64-*-linux*

Configuring GDBserver you should specify the same machine for host and
target (which are the machine that GDBserver is going to run on.  This
is not the same as the machine that GDB is going to run on; building
GDBserver automatically as part of building a whole tree of tools does
not currently work if cross-compilation is involved (we don't get the
right CC in the Makefile, to start with)).

Building GDBserver for your target is very straightforward.  If you build
GDB natively on a target which GDBserver supports, it will be built
automatically when you build GDB.  You can also build just GDBserver:

	% mkdir obj
	% cd obj
	% path-to-gdbserver-sources/configure
	% make

If you prefer to cross-compile to your target, then you can also build
GDBserver that way.  In a Bourne shell, for example:

	% export CC=your-cross-compiler
	% path-to-gdbserver-sources/configure your-target-name
	% make

Using GDBreplay:

A special hacked down version of GDBserver can be used to replay remote
debug log files created by GDB.  Before using the GDB "target" command to
initiate a remote debug session, use "set remotelogfile <filename>" to tell
GDB that you want to make a recording of the serial or tcp session.  Note
that when replaying the session, GDB communicates with GDBreplay via tcp,
regardless of whether the original session was via a serial link or tcp.

Once you are done with the remote debug session, start GDBreplay and
tell it the name of the log file and the host and port number that GDB
should connect to (typically the same as the host running GDB):

	$ gdbreplay logfile host:port

Then start GDB (preferably in a different screen or window) and use the
"target" command to connect to GDBreplay:

	(gdb) target remote host:port

Repeat the same sequence of user commands to GDB that you gave in the
original debug session.  GDB should not be able to tell that it is talking
to GDBreplay rather than a real target, all other things being equal.  Note
that GDBreplay echos the command lines to stderr, as well as the contents of
the packets it sends and receives.  The last command echoed by GDBreplay is
the next command that needs to be typed to GDB to continue the session in
sync with the original session.