|
|
55dec14 |
--- ./gdb/doc/gdb.texinfo 2010-05-24 19:37:01.000000000 +0200
|
|
|
55dec14 |
+++ ./gdb/doc/gdb.texinfo 2010-05-24 19:38:56.000000000 +0200
|
|
|
55dec14 |
@@ -14768,33 +14768,21 @@ and @code{show architecture}.
|
|
|
55dec14 |
@cindex active targets
|
|
|
55dec14 |
@cindex multiple targets
|
|
|
55dec14 |
|
|
|
55dec14 |
-There are three classes of targets: processes, core files, and
|
|
|
55dec14 |
-executable files. @value{GDBN} can work concurrently on up to three
|
|
|
55dec14 |
-active targets, one in each class. This allows you to (for example)
|
|
|
55dec14 |
-start a process and inspect its activity without abandoning your work on
|
|
|
55dec14 |
-a core file.
|
|
|
55dec14 |
-
|
|
|
55dec14 |
-For example, if you execute @samp{gdb a.out}, then the executable file
|
|
|
55dec14 |
-@code{a.out} is the only active target. If you designate a core file as
|
|
|
55dec14 |
-well---presumably from a prior run that crashed and coredumped---then
|
|
|
55dec14 |
-@value{GDBN} has two active targets and uses them in tandem, looking
|
|
|
55dec14 |
-first in the corefile target, then in the executable file, to satisfy
|
|
|
55dec14 |
-requests for memory addresses. (Typically, these two classes of target
|
|
|
55dec14 |
-are complementary, since core files contain only a program's
|
|
|
55dec14 |
-read-write memory---variables and so on---plus machine status, while
|
|
|
55dec14 |
-executable files contain only the program text and initialized data.)
|
|
|
55dec14 |
-
|
|
|
55dec14 |
-When you type @code{run}, your executable file becomes an active process
|
|
|
55dec14 |
-target as well. When a process target is active, all @value{GDBN}
|
|
|
55dec14 |
-commands requesting memory addresses refer to that target; addresses in
|
|
|
55dec14 |
-an active core file or executable file target are obscured while the
|
|
|
55dec14 |
-process target is active.
|
|
|
55dec14 |
-
|
|
|
55dec14 |
-Use the @code{core-file} and @code{exec-file} commands to select a new
|
|
|
55dec14 |
-core file or executable target (@pxref{Files, ,Commands to Specify
|
|
|
55dec14 |
-Files}). To specify as a target a process that is already running, use
|
|
|
55dec14 |
-the @code{attach} command (@pxref{Attach, ,Debugging an Already-running
|
|
|
55dec14 |
-Process}).
|
|
|
55dec14 |
+There are multiple classes of targets such as: processes, executable files or
|
|
|
55dec14 |
+recording sessions. Core files belong to the process class, there can be
|
|
|
55dec14 |
+active only one of a core or a running process. Otherwise @value{GDBN} can
|
|
|
55dec14 |
+work concurrently on multiple active targets, one in each class. This allows
|
|
|
55dec14 |
+you to (for example) start a process and inspect its activity while still
|
|
|
55dec14 |
+having access to the executable file after the process finishes. Or if you
|
|
|
55dec14 |
+start process recording (@pxref{Reverse Execution}) and @code{reverse-step}
|
|
|
55dec14 |
+there you are presented a virtual layer of the recording target while the
|
|
|
55dec14 |
+process target remains stopped at the chronologically last point of the process
|
|
|
55dec14 |
+execution.
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+Use the @code{core-file} and @code{exec-file} commands to select a new core
|
|
|
55dec14 |
+file or executable target (@pxref{Files, ,Commands to Specify Files}). To
|
|
|
55dec14 |
+specify as a target a process that is already running, use the @code{attach}
|
|
|
55dec14 |
+command (@pxref{Attach, ,Debugging an Already-running Process}).
|
|
|
55dec14 |
|
|
|
55dec14 |
@node Target Commands
|
|
|
55dec14 |
@section Commands for Managing Targets
|
|
|
55dec14 |
--- ./gdb/infcmd.c 2010-05-24 19:37:01.000000000 +0200
|
|
|
55dec14 |
+++ ./gdb/infcmd.c 2010-05-24 19:41:21.000000000 +0200
|
|
|
55dec14 |
@@ -483,6 +483,13 @@ run_command_1 (char *args, int from_tty,
|
|
|
55dec14 |
|
|
|
55dec14 |
dont_repeat ();
|
|
|
55dec14 |
|
|
|
55dec14 |
+ if (core_bfd)
|
|
|
55dec14 |
+ {
|
|
|
55dec14 |
+ core_file_command (NULL, from_tty);
|
|
|
55dec14 |
+ if (core_bfd)
|
|
|
55dec14 |
+ warning (_("Core file not unloaded."));
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+
|
|
|
55dec14 |
kill_if_already_running (from_tty);
|
|
|
55dec14 |
|
|
|
55dec14 |
init_wait_for_inferior ();
|
|
|
55dec14 |
@@ -2373,6 +2380,13 @@ attach_command (char *args, int from_tty
|
|
|
55dec14 |
error (_("Not killed."));
|
|
|
55dec14 |
}
|
|
|
55dec14 |
|
|
|
55dec14 |
+ if (core_bfd)
|
|
|
55dec14 |
+ {
|
|
|
55dec14 |
+ core_file_command (NULL, from_tty);
|
|
|
55dec14 |
+ if (core_bfd)
|
|
|
55dec14 |
+ warning (_("Core file not unloaded."));
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+
|
|
|
55dec14 |
/* Clean up any leftovers from other runs. Some other things from
|
|
|
55dec14 |
this function should probably be moved into target_pre_inferior. */
|
|
|
55dec14 |
target_pre_inferior (from_tty);
|
|
|
55dec14 |
--- ./gdb/testsuite/gdb.base/corefile.exp 2010-01-09 01:14:11.000000000 +0100
|
|
|
55dec14 |
+++ ./gdb/testsuite/gdb.base/corefile.exp 2010-05-24 19:38:56.000000000 +0200
|
|
|
55dec14 |
@@ -182,3 +182,62 @@ gdb_load ${binfile}
|
|
|
55dec14 |
gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
|
|
|
55dec14 |
|
|
|
55dec14 |
gdb_test "core" "No core file now."
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+# Test a run (start) command will clear any loaded core file.
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
|
|
|
55dec14 |
+gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file"
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+set test "run: with core"
|
|
|
55dec14 |
+if [runto_main] {
|
|
|
55dec14 |
+ pass $test
|
|
|
55dec14 |
+} else {
|
|
|
55dec14 |
+ fail $test
|
|
|
55dec14 |
+}
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+set test "run: core file is cleared"
|
|
|
55dec14 |
+gdb_test_multiple "info files" $test {
|
|
|
55dec14 |
+ "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
|
|
|
55dec14 |
+ fail $test
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+ "\r\n$gdb_prompt $" {
|
|
|
55dec14 |
+ pass $test
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+}
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+gdb_exit
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+# Test an attach command will clear any loaded core file.
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+if ![is_remote target] {
|
|
|
55dec14 |
+ set test "attach: spawn sleep"
|
|
|
55dec14 |
+ set res [remote_spawn host "$binfile sleep"];
|
|
|
55dec14 |
+ if { $res < 0 || $res == "" } {
|
|
|
55dec14 |
+ perror "$test failed."
|
|
|
55dec14 |
+ fail $test
|
|
|
55dec14 |
+ return
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+ set pid [exp_pid -i $res]
|
|
|
55dec14 |
+ # We do not care of the startup phase where it will be caught.
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+ gdb_start
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+ gdb_test "core-file $corefile" "Core was generated by .*" "attach: load core again"
|
|
|
55dec14 |
+ gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "attach: sanity check we see the core file"
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+ gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core"
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+ set test "attach: core file is cleared"
|
|
|
55dec14 |
+ gdb_test_multiple "info files" $test {
|
|
|
55dec14 |
+ "\r\nLocal core dump file:\r\n.*\r\n$gdb_prompt $" {
|
|
|
55dec14 |
+ fail $test
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+ "\r\n$gdb_prompt $" {
|
|
|
55dec14 |
+ pass $test
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
+
|
|
|
55dec14 |
+ gdb_exit
|
|
|
55dec14 |
+}
|
|
|
55dec14 |
--- ./gdb/testsuite/gdb.base/coremaker.c 2010-01-01 08:32:00.000000000 +0100
|
|
|
55dec14 |
+++ ./gdb/testsuite/gdb.base/coremaker.c 2010-05-24 19:38:56.000000000 +0200
|
|
|
55dec14 |
@@ -133,8 +133,14 @@ func1 ()
|
|
|
55dec14 |
func2 ();
|
|
|
55dec14 |
}
|
|
|
55dec14 |
|
|
|
55dec14 |
-int main ()
|
|
|
55dec14 |
+int
|
|
|
55dec14 |
+main (int argc, char **argv)
|
|
|
55dec14 |
{
|
|
|
55dec14 |
+ if (argc == 2 && strcmp (argv[1], "sleep") == 0)
|
|
|
55dec14 |
+ {
|
|
|
55dec14 |
+ sleep (60);
|
|
|
55dec14 |
+ return 0;
|
|
|
55dec14 |
+ }
|
|
|
55dec14 |
mmapdata ();
|
|
|
55dec14 |
func1 ();
|
|
|
55dec14 |
return 0;
|