]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-bz594560-core-vs-process.patch
- updated (performance fixes).
[packages/gdb.git] / gdb-bz594560-core-vs-process.patch
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}.
4  @cindex active targets
5  @cindex multiple targets
6  
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
11 -a core file.
12 -
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.)
22 -
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.
28 -
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
33 -Process}).
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
43 +execution.
44 +
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}).
49  
50  @node Target Commands
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,
55  
56    dont_repeat ();
57  
58 +  if (core_bfd)
59 +    {
60 +      core_file_command (NULL, from_tty);
61 +      if (core_bfd)
62 +       warning (_("Core file not unloaded."));
63 +    }
64 +
65    kill_if_already_running (from_tty);
66  
67    init_wait_for_inferior ();
68 @@ -2373,6 +2380,13 @@ attach_command (char *args, int from_tty
69         error (_("Not killed."));
70      }
71  
72 +  if (core_bfd)
73 +    {
74 +      core_file_command (NULL, from_tty);
75 +      if (core_bfd)
76 +       warning (_("Core file not unloaded."));
77 +    }
78 +
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)"
86  
87  gdb_test "core" "No core file now."
88 +
89 +
90 +# Test a run (start) command will clear any loaded core file.
91 +
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"
94 +
95 +set test "run: with core"
96 +if [runto_main] {
97 +    pass $test
98 +} else {
99 +    fail $test
100 +}
101 +
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 $" {
105 +       fail $test
106 +    }
107 +    "\r\n$gdb_prompt $" {
108 +       pass $test
109 +    }
110 +}
111 +
112 +gdb_exit
113 +
114 +
115 +# Test an attach command will clear any loaded core file.
116 +
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."
122 +       fail $test
123 +       return
124 +    }
125 +    set pid [exp_pid -i $res]
126 +    # We do not care of the startup phase where it will be caught.
127 +
128 +    gdb_start
129 +
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"
132 +
133 +    gdb_test "attach $pid" "Attaching to process $pid\r\n.*" "attach: with core"
134 +
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 $" {
138 +           fail $test
139 +       }
140 +       "\r\n$gdb_prompt $" {
141 +           pass $test
142 +       }
143 +    }
144 +
145 +    gdb_exit
146 +}
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 ()
150    func2 ();
151  }
152  
153 -int main ()
154 +int
155 +main (int argc, char **argv)
156  {
157 +  if (argc == 2 && strcmp (argv[1], "sleep") == 0)
158 +    {
159 +      sleep (60);
160 +      return 0;
161 +    }
162    mmapdata ();
163    func1 ();
164    return 0;
This page took 0.042497 seconds and 3 git commands to generate.