• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision19d9d4efd18bcc633e99cb6a3e39bd9b22ca70ce (tree)
Time2015-12-15 04:18:06
AuthorDon Breazeal <donb@code...>
CommiterDon Breazeal

Log Message

Target remote mode fork and exec event documentation

This patch implements documentation updates for target remote mode fork and
exec events. A summary of the rationale for the changes made here:

* Connecting to a remote target -- explain that the two protocols exist.

* Connecting in target remote mode -- explain invoking gdbserver for target

remote mode, and move remote-specific text from original "Connecting to a
remote target" section.

* Connecting in target extended-remote mode -- promote this section from

"Using the gdbserver Program | Running gdbserver | Multi-Process Mode for
gdbserver". Put it next to the target remote mode section.

* Host and target files -- collect paragraphs dealing with how to locate

symbol files from original sections "Connecting to a remote target" and
"Using the gdbserver program | Connecting to gdbserver".

* Steps for connecting to a remote target -- used to be "Using the

gdbserver program | Connecting to gdbserver"

* Remote connection commands -- used to be the bulk of "Connecting to a

remote target". Added "target extended-remote" commands and information.

gdb/ChangeLog:

* NEWS: Announce fork and exec event support for target remote.

gdb/doc/ChangeLog:

* gdb.texinfo (Forks): Correct Linux kernel version where
fork and exec events are supported, add notes about support
of these events in target remote mode.
(Connecting): Reorganize and clarify distinctions between
target remote, extended-remote, and multiprocess.
Reorganize related text from separate sections into new
sections.
(Server): Note effects of target extended-remote mode.
Delete section on Multi-Process Mode for gdbserver.
Move some text to "Connecting" node.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
11 2015-12-11 Don Breazeal <donb@codesourcery.com>
22
3+ * NEWS: Announce fork and exec event support for target remote.
4+
5+2015-12-11 Don Breazeal <donb@codesourcery.com>
6+
37 * inferior.c (number_of_live_inferiors): New function.
48 (have_live_inferiors): Use number_of_live_inferiors in place
59 of duplicate code.
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -135,6 +135,13 @@ show remote exec-event-feature-packet
135135 The reply to qXfer:threads:read may now include a name attribute for each
136136 thread.
137137
138+* Target remote mode fork and exec events
139+
140+ ** GDB now has support for fork and exec events on target remote mode
141+ Linux targets. For such targets with Linux kernels 2.5.46 and later,
142+ this enables follow-fork-mode, detach-on-fork, follow-exec-mode, and
143+ fork and exec catchpoints.
144+
138145 * MI changes
139146
140147 ** The -var-set-format command now accepts the zero-hexadecimal
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,16 @@
1+2015-12-11 Don Breazeal <donb@codesourcery.com>
2+
3+ * gdb.texinfo (Forks): Correct Linux kernel version where
4+ fork and exec events are supported, add notes about support
5+ of these events in target remote mode.
6+ (Connecting): Reorganize and clarify distinctions between
7+ target remote, extended-remote, and multiprocess.
8+ Reorganize related text from separate sections into new
9+ sections.
10+ (Server): Note effects of target extended-remote mode.
11+ Delete section on Multi-Process Mode for gdbserver.
12+ Move some text to "Connecting" node.
13+
114 2015-12-10 Pedro Alves <palves@redhat.com>
215
316 * gdb.texinfo (Threads): Replace warning with explanation
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -3119,10 +3119,11 @@ the child process just like any other process which you attached to.
31193119 On some systems, @value{GDBN} provides support for debugging programs
31203120 that create additional processes using the @code{fork} or @code{vfork}
31213121 functions. On @sc{gnu}/Linux platforms, this feature is supported
3122-with kernel version 2.5.60 and later.
3122+with kernel version 2.5.46 and later.
31233123
3124-The fork debugging commands are supported in both native mode and when
3125-connected to @code{gdbserver} using @kbd{target extended-remote}.
3124+The fork debugging commands are supported in native mode and when
3125+connected to @code{gdbserver} in either @code{target remote} mode or
3126+@code{target extended-remote} mode.
31263127
31273128 By default, when a program forks, @value{GDBN} will continue to debug
31283129 the parent process and the child process will run unimpeded.
@@ -3268,6 +3269,9 @@ Program exited normally.
32683269 @end table
32693270 @end table
32703271
3272+@code{follow-exec-mode} is supported in native mode and
3273+@code{target extended-remote} mode.
3274+
32713275 You can use the @code{catch} command to make @value{GDBN} stop whenever
32723276 a @code{fork}, @code{vfork}, or @code{exec} call is made. @xref{Set
32733277 Catchpoints, ,Setting Catchpoints}.
@@ -19248,28 +19252,148 @@ configuration of @value{GDBN}; use @code{help target} to list them.
1924819252
1924919253 @node Connecting
1925019254 @section Connecting to a Remote Target
19255+@cindex remote debugging, connecting
19256+@cindex @code{gdbserver}, connecting
19257+@cindex remote debugging, types of connections
19258+@cindex @code{gdbserver}, types of connections
19259+@cindex @code{gdbserver}, @code{target remote} mode
19260+@cindex @code{gdbserver}, @code{target extended-remote} mode
19261+
19262+This section describes how to connect to a remote target, including the
19263+types of connections and their differences, how to set up executable and
19264+symbol files on the host and target, and the commands used for
19265+connecting to and disconnecting from the remote target.
19266+
19267+@subsection Types of Remote Connections
19268+
19269+@value{GDBN} supports two types of remote connections, @code{target remote}
19270+mode and @code{target extended-remote} mode. Note that many remote targets
19271+support only @code{target remote} mode. There are several major
19272+differences between the two types of connections, enumerated here:
1925119273
19252-@value{GDBN} needs an unstripped copy of your program to access symbol
19253-and debugging information. Some remote targets (@pxref{qXfer
19254-executable filename read}, and @pxref{Host I/O Packets}) allow
19255-@value{GDBN} to access program files over the same connection used to
19256-communicate with @value{GDBN}. With such a target, if the remote
19257-program is unstripped, the only command you need is @code{target
19258-remote}. Otherwise, start up @value{GDBN} using the name of the local
19274+@table @asis
19275+
19276+@cindex remote debugging, detach and program exit
19277+@item Result of detach or program exit
19278+@strong{With target remote mode:} When the debugged program exits or you
19279+detach from it, @value{GDBN} disconnects from the target. When using
19280+@code{gdbserver}, @code{gdbserver} will exit.
19281+
19282+@strong{With target extended-remote mode:} When the debugged program exits or
19283+you detach from it, @value{GDBN} remains connected to the target, even
19284+though no program is running. You can rerun the program, attach to a
19285+running program, or use @code{monitor} commands specific to the target.
19286+
19287+When using @code{gdbserver} in this case, it does not exit unless it was
19288+invoked using the @option{--once} option. If the @option{--once} option
19289+was not used, you can ask @code{gdbserver} to exit using the
19290+@code{monitor exit} command (@pxref{Monitor Commands for gdbserver}).
19291+
19292+@item Specifying the program to debug
19293+For both connection types you use the @code{file} command to specify the
19294+program on the host system. If you are using @code{gdbserver} there are
19295+some differences in how to specify the location of the program on the
19296+target.
19297+
19298+@strong{With target remote mode:} You must either specify the program to debug
19299+on the @code{gdbserver} command line or use the @option{--attach} option
19300+(@pxref{Attaching to a program,,Attaching to a Running Program}).
19301+
19302+@cindex @option{--multi}, @code{gdbserver} option
19303+@strong{With target extended-remote mode:} You may specify the program to debug
19304+on the @code{gdbserver} command line, or you can load the program or attach
19305+to it using @value{GDBN} commands after connecting to @code{gdbserver}.
19306+
19307+@anchor{--multi Option in Types of Remote Connnections}
19308+You can start @code{gdbserver} without supplying an initial command to run
19309+or process ID to attach. To do this, use the @option{--multi} command line
19310+option. Then you can connect using @code{target extended-remote} and start
19311+the program you want to debug (see below for details on using the
19312+@code{run} command in this scenario). Note that the conditions under which
19313+@code{gdbserver} terminates depend on how @value{GDBN} connects to it
19314+(@code{target remote} or @code{target extended-remote}). The
19315+@option{--multi} option to @code{gdbserver} has no influence on that.
19316+
19317+@item The @code{run} command
19318+@strong{With target remote mode:} The @code{run} command is not
19319+supported. Once a connection has been established, you can use all
19320+the usual @value{GDBN} commands to examine and change data. The
19321+remote program is already running, so you can use commands like
19322+@kbd{step} and @kbd{continue}.
19323+
19324+@strong{With target extended-remote mode:} The @code{run} command is
19325+supported. The @code{run} command uses the value set by
19326+@code{set remote exec-file} (@pxref{set remote exec-file}) to select
19327+the program to run. Command line arguments are supported, except for
19328+wildcard expansion and I/O redirection (@pxref{Arguments}).
19329+
19330+If you specify the program to debug on the command line, then the
19331+@code{run} command is not required to start execution, and you can
19332+resume using commands like @kbd{step} and @kbd{continue} as with
19333+@code{target remote} mode.
19334+
19335+@anchor{Attaching in Types of Remote Connections}
19336+@item Attaching
19337+@strong{With target remote mode:} The @value{GDBN} command @code{attach} is
19338+not supported. To attach to a running program using @code{gdbserver}, you
19339+must use the @option{--attach} option (@pxref{Running gdbserver}).
19340+
19341+@strong{With target extended-remote mode:} To attach to a running program,
19342+you may use the @code{attach} command after the connection has been
19343+established. If you are using @code{gdbserver}, you may also invoke
19344+@code{gdbserver} using the @option{--attach} option
19345+(@pxref{Running gdbserver}).
19346+
19347+@end table
19348+
19349+@anchor{Host and target files}
19350+@subsection Host and Target Files
19351+@cindex remote debugging, symbol files
19352+@cindex symbol files, remote debugging
19353+
19354+@value{GDBN}, running on the host, needs access to symbol and debugging
19355+information for your program running on the target. This requires
19356+access to an unstripped copy of your program, and possibly any associated
19357+symbol files. Note that this section applies equally to both @code{target
19358+remote} mode and @code{target extended-remote} mode.
19359+
19360+Some remote targets (@pxref{qXfer executable filename read}, and
19361+@pxref{Host I/O Packets}) allow @value{GDBN} to access program files over
19362+the same connection used to communicate with @value{GDBN}. With such a
19363+target, if the remote program is unstripped, the only command you need is
19364+@code{target remote} (or @code{target extended-remote}).
19365+
19366+If the remote program is stripped, or the target does not support remote
19367+program file access, start up @value{GDBN} using the name of the local
1925919368 unstripped copy of your program as the first argument, or use the
19260-@code{file} command.
19369+@code{file} command. Use @code{set sysroot} to specify the location (on
19370+the host) of target libraries (unless your @value{GDBN} was compiled with
19371+the correct sysroot using @code{--with-sysroot}). Alternatively, you
19372+may use @code{set solib-search-path} to specify how @value{GDBN} locates
19373+target libraries.
19374+
19375+The symbol file and target libraries must exactly match the executable
19376+and libraries on the target, with one exception: the files on the host
19377+system should not be stripped, even if the files on the target system
19378+are. Mismatched or missing files will lead to confusing results
19379+during debugging. On @sc{gnu}/Linux targets, mismatched or missing
19380+files may also prevent @code{gdbserver} from debugging multi-threaded
19381+programs.
1926119382
19262-@cindex @code{target remote}
19383+@subsection Remote Connection Commands
19384+@cindex remote connection commands
1926319385 @value{GDBN} can communicate with the target over a serial line, or
1926419386 over an @acronym{IP} network using @acronym{TCP} or @acronym{UDP}. In
1926519387 each case, @value{GDBN} uses the same protocol for debugging your
1926619388 program; only the medium carrying the debugging packets varies. The
19267-@code{target remote} command establishes a connection to the target.
19268-Its arguments indicate which medium to use:
19389+@code{target remote} and @code{target extended-remote} commands
19390+establish a connection to the target. Both commands accept the same
19391+arguments, which indicate the medium to use:
1926919392
1927019393 @table @code
1927119394
1927219395 @item target remote @var{serial-device}
19396+@itemx target extended-remote @var{serial-device}
1927319397 @cindex serial line, @code{target remote}
1927419398 Use @var{serial-device} to communicate with the target. For example,
1927519399 to use a serial line connected to the device named @file{/dev/ttyb}:
@@ -19285,6 +19409,8 @@ If you're using a serial line, you may want to give @value{GDBN} the
1928519409
1928619410 @item target remote @code{@var{host}:@var{port}}
1928719411 @itemx target remote @code{tcp:@var{host}:@var{port}}
19412+@itemx target extended-remote @code{@var{host}:@var{port}}
19413+@itemx target extended-remote @code{tcp:@var{host}:@var{port}}
1928819414 @cindex @acronym{TCP} port, @code{target remote}
1928919415 Debug using a @acronym{TCP} connection to @var{port} on @var{host}.
1929019416 The @var{host} may be either a host name or a numeric @acronym{IP}
@@ -19313,6 +19439,7 @@ target remote :1234
1931319439 Note that the colon is still required here.
1931419440
1931519441 @item target remote @code{udp:@var{host}:@var{port}}
19442+@itemx target extended-remote @code{udp:@var{host}:@var{port}}
1931619443 @cindex @acronym{UDP} port, @code{target remote}
1931719444 Debug using @acronym{UDP} packets to @var{port} on @var{host}. For example, to
1931819445 connect to @acronym{UDP} port 2828 on a terminal server named @code{manyfarms}:
@@ -19327,6 +19454,7 @@ can silently drop packets on busy or unreliable networks, which will
1932719454 cause havoc with your debugging session.
1932819455
1932919456 @item target remote | @var{command}
19457+@itemx target extended-remote | @var{command}
1933019458 @cindex pipe, @code{target remote} to
1933119459 Run @var{command} in the background and communicate with it using a
1933219460 pipe. The @var{command} is a shell command, to be parsed and expanded
@@ -19342,11 +19470,6 @@ program has already exited, this will have no effect.)
1934219470
1934319471 @end table
1934419472
19345-Once the connection has been established, you can use all the usual
19346-commands to examine and change data. The remote program is already
19347-running; you can use @kbd{step} and @kbd{continue}, and you do not
19348-need to use @kbd{run}.
19349-
1935019473 @cindex interrupting remote programs
1935119474 @cindex remote programs, interrupting
1935219475 Whenever @value{GDBN} is waiting for the remote program, if you type the
@@ -19360,10 +19483,13 @@ Interrupted while waiting for the program.
1936019483 Give up (and stop debugging it)? (y or n)
1936119484 @end smallexample
1936219485
19363-If you type @kbd{y}, @value{GDBN} abandons the remote debugging session.
19364-(If you decide you want to try again later, you can use @samp{target
19365-remote} again to connect once more.) If you type @kbd{n}, @value{GDBN}
19366-goes back to waiting.
19486+In @code{target remote} mode, if you type @kbd{y}, @value{GDBN} abandons
19487+the remote debugging session. (If you decide you want to try again later,
19488+you can use @kbd{target remote} again to connect once more.) If you type
19489+@kbd{n}, @value{GDBN} goes back to waiting.
19490+
19491+In @code{target extended-remote} mode, typing @kbd{n} will leave
19492+@value{GDBN} connected to the target.
1936719493
1936819494 @table @code
1936919495 @kindex detach (remote)
@@ -19372,11 +19498,13 @@ When you have finished debugging the remote program, you can use the
1937219498 @code{detach} command to release it from @value{GDBN} control.
1937319499 Detaching from the target normally resumes its execution, but the results
1937419500 will depend on your particular remote stub. After the @code{detach}
19375-command, @value{GDBN} is free to connect to another target.
19501+command in @code{target remote} mode, @value{GDBN} is free to connect to
19502+another target. In @code{target extended-remote} mode, @value{GDBN} is
19503+still connected to the target.
1937619504
1937719505 @kindex disconnect
1937819506 @item disconnect
19379-The @code{disconnect} command behaves like @code{detach}, except that
19507+The @code{disconnect} command closes the connection to the target, and
1938019508 the target is generally not resumed. It will wait for @value{GDBN}
1938119509 (this instance or another one) to connect and continue debugging. After
1938219510 the @code{disconnect} command, @value{GDBN} is again free to connect to
@@ -19433,7 +19561,8 @@ Delete @var{targetfile} from the target system.
1943319561 @cindex remote connection without stubs
1943419562 @code{gdbserver} is a control program for Unix-like systems, which
1943519563 allows you to connect your program with a remote @value{GDBN} via
19436-@code{target remote}---but without linking in the usual debugging stub.
19564+@code{target remote} or @code{target extended-remote}---but without
19565+linking in the usual debugging stub.
1943719566
1943819567 @code{gdbserver} is not a complete replacement for the debugging stubs,
1943919568 because it requires essentially the same operating-system facilities
@@ -19461,6 +19590,7 @@ target system with the same privileges as the user running
1946119590 @code{gdbserver}.
1946219591 @end quotation
1946319592
19593+@anchor{Running gdbserver}
1946419594 @subsection Running @code{gdbserver}
1946519595 @cindex arguments, to @code{gdbserver}
1946619596 @cindex @code{gdbserver}, command-line arguments
@@ -19528,6 +19658,7 @@ Programs started with stdio-connected gdbserver have @file{/dev/null} for
1952819658 display through a pipe connected to gdbserver.
1952919659 Both @code{stdout} and @code{stderr} use the same pipe.
1953019660
19661+@anchor{Attaching to a program}
1953119662 @subsubsection Attaching to a Running Program
1953219663 @cindex attach to a program, @code{gdbserver}
1953319664 @cindex @option{--attach}, @code{gdbserver} option
@@ -19539,8 +19670,12 @@ This is accomplished via the @code{--attach} argument. The syntax is:
1953919670 target> gdbserver --attach @var{comm} @var{pid}
1954019671 @end smallexample
1954119672
19542-@var{pid} is the process ID of a currently running process. It isn't necessary
19543-to point @code{gdbserver} at a binary for the running process.
19673+@var{pid} is the process ID of a currently running process. It isn't
19674+necessary to point @code{gdbserver} at a binary for the running process.
19675+
19676+In @code{target extended-remote} mode, you can also attach using the
19677+@value{GDBN} attach command
19678+(@pxref{Attaching in Types of Remote Connections}).
1954419679
1954519680 @pindex pidof
1954619681 You can debug processes by name instead of process ID if your target has the
@@ -19554,41 +19689,10 @@ In case more than one copy of @var{program} is running, or @var{program}
1955419689 has multiple threads, most versions of @code{pidof} support the
1955519690 @code{-s} option to only return the first process ID.
1955619691
19557-@subsubsection Multi-Process Mode for @code{gdbserver}
19558-@cindex @code{gdbserver}, multiple processes
19559-@cindex multiple processes with @code{gdbserver}
19560-
19561-When you connect to @code{gdbserver} using @code{target remote},
19562-@code{gdbserver} debugs the specified program only once. When the
19563-program exits, or you detach from it, @value{GDBN} closes the connection
19564-and @code{gdbserver} exits.
19565-
19566-If you connect using @kbd{target extended-remote}, @code{gdbserver}
19567-enters multi-process mode. When the debugged program exits, or you
19568-detach from it, @value{GDBN} stays connected to @code{gdbserver} even
19569-though no program is running. The @code{run} and @code{attach}
19570-commands instruct @code{gdbserver} to run or attach to a new program.
19571-The @code{run} command uses @code{set remote exec-file} (@pxref{set
19572-remote exec-file}) to select the program to run. Command line
19573-arguments are supported, except for wildcard expansion and I/O
19574-redirection (@pxref{Arguments}).
19575-
19576-@cindex @option{--multi}, @code{gdbserver} option
19577-To start @code{gdbserver} without supplying an initial command to run
19578-or process ID to attach, use the @option{--multi} command line option.
19579-Then you can connect using @kbd{target extended-remote} and start
19580-the program you want to debug.
19581-
19582-In multi-process mode @code{gdbserver} does not automatically exit unless you
19583-use the option @option{--once}. You can terminate it by using
19584-@code{monitor exit} (@pxref{Monitor Commands for gdbserver}). Note that the
19585-conditions under which @code{gdbserver} terminates depend on how @value{GDBN}
19586-connects to it (@kbd{target remote} or @kbd{target extended-remote}). The
19587-@option{--multi} option to @code{gdbserver} has no influence on that.
19588-
1958919692 @subsubsection TCP port allocation lifecycle of @code{gdbserver}
1959019693
19591-This section applies only when @code{gdbserver} is run to listen on a TCP port.
19694+This section applies only when @code{gdbserver} is run to listen on a TCP
19695+port.
1959219696
1959319697 @code{gdbserver} normally terminates after all of its debugged processes have
1959419698 terminated in @kbd{target remote} mode. On the other hand, for @kbd{target
@@ -19619,6 +19723,12 @@ instance closes its port after the first connection.
1961919723 @anchor{Other Command-Line Arguments for gdbserver}
1962019724 @subsubsection Other Command-Line Arguments for @code{gdbserver}
1962119725
19726+You can use the @option{--multi} option to start @code{gdbserver} without
19727+specifying a program to debug or a process to attach to. Then you can
19728+attach in @code{target extended-remote} mode and run or attach to a
19729+program. For more information,
19730+@pxref{--multi Option in Types of Remote Connnections}.
19731+
1962219732 @cindex @option{--debug}, @code{gdbserver} option
1962319733 The @option{--debug} option tells @code{gdbserver} to display extra
1962419734 status information about the debugging process.
@@ -19670,32 +19780,34 @@ $ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog
1967019780
1967119781 @subsection Connecting to @code{gdbserver}
1967219782
19673-Run @value{GDBN} on the host system.
19783+The basic procedure for connecting to the remote target is:
19784+@itemize
1967419785
19675-First make sure you have the necessary symbol files. Load symbols for
19676-your application using the @code{file} command before you connect. Use
19677-@code{set sysroot} to locate target libraries (unless your @value{GDBN}
19678-was compiled with the correct sysroot using @code{--with-sysroot}).
19786+@item
19787+Run @value{GDBN} on the host system.
1967919788
19680-The symbol file and target libraries must exactly match the executable
19681-and libraries on the target, with one exception: the files on the host
19682-system should not be stripped, even if the files on the target system
19683-are. Mismatched or missing files will lead to confusing results
19684-during debugging. On @sc{gnu}/Linux targets, mismatched or missing
19685-files may also prevent @code{gdbserver} from debugging multi-threaded
19686-programs.
19789+@item
19790+Make sure you have the necessary symbol files
19791+(@pxref{Host and target files}).
19792+Load symbols for your application using the @code{file} command before you
19793+connect. Use @code{set sysroot} to locate target libraries (unless your
19794+@value{GDBN} was compiled with the correct sysroot using
19795+@code{--with-sysroot}).
1968719796
19797+@item
1968819798 Connect to your target (@pxref{Connecting,,Connecting to a Remote Target}).
1968919799 For TCP connections, you must start up @code{gdbserver} prior to using
19690-the @code{target remote} command. Otherwise you may get an error whose
19800+the @code{target} command. Otherwise you may get an error whose
1969119801 text depends on the host system, but which usually looks something like
1969219802 @samp{Connection refused}. Don't use the @code{load}
19693-command in @value{GDBN} when using @code{gdbserver}, since the program is
19694-already on the target.
19803+command in @value{GDBN} when using @code{target remote} mode, since the
19804+program is already on the target.
19805+
19806+@end itemize
1969519807
19808+@anchor{Monitor Commands for gdbserver}
1969619809 @subsection Monitor Commands for @code{gdbserver}
1969719810 @cindex monitor commands, for @code{gdbserver}
19698-@anchor{Monitor Commands for gdbserver}
1969919811
1970019812 During a @value{GDBN} session using @code{gdbserver}, you can use the
1970119813 @code{monitor} command to send special requests to @code{gdbserver}.