1 --- ./gdb/doc/gdb.texinfo 2010-05-24 19:37:01.000000000 +0200
2 +++ ./gdb/doc/gdb.texinfo 2010-05-24 19:38:56.000000000 +0200
3 @@ -14768,33 +14768,21 @@ and @code{show architecture}.
5 @cindex multiple targets
7 -There are three classes of targets: processes, core files, and
8 -executable files. @value{GDBN} can work concurrently on up to three
9 -active targets, one in each class. This allows you to (for example)
10 -start a process and inspect its activity without abandoning your work on
13 -For example, if you execute @samp{gdb a.out}, then the executable file
14 -@code{a.out} is the only active target. If you designate a core file as
15 -well---presumably from a prior run that crashed and coredumped---then
16 -@value{GDBN} has two active targets and uses them in tandem, looking
17 -first in the corefile target, then in the executable file, to satisfy
18 -requests for memory addresses. (Typically, these two classes of target
19 -are complementary, since core files contain only a program's
20 -read-write memory---variables and so on---plus machine status, while
21 -executable files contain only the program text and initialized data.)
23 -When you type @code{run}, your executable file becomes an active process
24 -target as well. When a process target is active, all @value{GDBN}
25 -commands requesting memory addresses refer to that target; addresses in
26 -an active core file or executable file target are obscured while the
27 -process target is active.
29 -Use the @code{core-file} and @code{exec-file} commands to select a new
30 -core file or executable target (@pxref{Files, ,Commands to Specify
31 -Files}). To specify as a target a process that is already running, use
32 -the @code{attach} command (@pxref{Attach, ,Debugging an Already-running
34 +There are multiple classes of targets such as: processes, executable files or
35 +recording sessions. Core files belong to the process class, there can be
36 +active only one of a core or a running process. Otherwise @value{GDBN} can
37 +work concurrently on multiple active targets, one in each class. This allows
38 +you to (for example) start a process and inspect its activity while still
39 +having access to the executable file after the process finishes. Or if you
40 +start process recording (@pxref{Reverse Execution}) and @code{reverse-step}
41 +there you are presented a virtual layer of the recording target while the
42 +process target remains stopped at the chronologically last point of the process
45 +Use the @code{core-file} and @code{exec-file} commands to select a new core
46 +file or executable target (@pxref{Files, ,Commands to Specify Files}). To
47 +specify as a target a process that is already running, use the @code{attach}
48 +command (@pxref{Attach, ,Debugging an Already-running Process}).
51 @section Commands for Managing Targets
52 --- ./gdb/infcmd.c 2010-05-24 19:37:01.000000000 +0200
53 +++ ./gdb/infcmd.c 2010-05-24 19:41:21.000000000 +0200
54 @@ -483,6 +483,13 @@ run_command_1 (char *args, int from_tty,
60 + core_file_command (NULL, from_tty);
62 + warning (_("Core file not unloaded."));
65 kill_if_already_running (from_tty);
67 init_wait_for_inferior ();
68 @@ -2373,6 +2380,13 @@ attach_command (char *args, int from_tty
69 error (_("Not killed."));
74 + core_file_command (NULL, from_tty);
76 + warning (_("Core file not unloaded."));
79 /* Clean up any leftovers from other runs. Some other things from
80 this function should probably be moved into target_pre_inferior. */
81 target_pre_inferior (from_tty);
82 --- ./gdb/testsuite/gdb.base/corefile.exp 2010-01-09 01:14:11.000000000 +0100
83 +++ ./gdb/testsuite/gdb.base/corefile.exp 2010-05-24 19:38:56.000000000 +0200
84 @@ -182,3 +182,62 @@ gdb_load ${binfile}
85 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
87 gdb_test "core" "No core file now."
90 +# Test a run (start) command will clear any loaded core file.
92 +gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
93 +gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"
95 +set test "run: with core"
102 +set test "run: core file is cleared"
103 +gdb_test_multiple "info files" $test {
104 + "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
107 + "\r\n$gdb_prompt $" {
115 +# Test an attach command will clear any loaded core file.
117 +if ![is_remote target] {
118 + set test "attach: spawn sleep"
119 + set res [remote_spawn host "$binfile sleep"];
120 + if { $res < 0 || $res == "" } {
121 + perror "$test failed."
125 + set pid [exp_pid -i $res]
126 + # We do not care of the startup phase where it will be caught.
130 + gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core again"
131 + gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity check we see the core file"
133 + gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core"
135 + set test "attach: core file is cleared"
136 + gdb_test_multiple "info files" $test {
137 + "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
140 + "\r\n$gdb_prompt $" {
147 --- ./gdb/testsuite/gdb.base/coremaker.c 2010-01-01 08:32:00.000000000 +0100
148 +++ ./gdb/testsuite/gdb.base/coremaker.c 2010-05-24 19:38:56.000000000 +0200
149 @@ -133,8 +133,14 @@ func1 ()
155 +main (int argc, char **argv)
157 + if (argc == 2 && strcmp (argv[1], "sleep") == 0)