Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Memory-access and commands for "inferior" process, for GDB. |
96baa820 | 2 | Copyright 1986, 87, 88, 89, 91, 92, 95, 96, 1998, 1999 |
c906108c SS |
3 | Free Software Foundation, Inc. |
4 | ||
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
c906108c | 11 | |
c5aa993b JM |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
c906108c | 16 | |
c5aa993b JM |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
21 | |
22 | #include "defs.h" | |
23 | #include <signal.h> | |
24 | #include "gdb_string.h" | |
25 | #include "symtab.h" | |
26 | #include "gdbtypes.h" | |
27 | #include "frame.h" | |
28 | #include "inferior.h" | |
29 | #include "environ.h" | |
30 | #include "value.h" | |
31 | #include "gdbcmd.h" | |
32 | #include "gdbcore.h" | |
33 | #include "target.h" | |
34 | #include "language.h" | |
35 | #include "symfile.h" | |
36 | #include "objfiles.h" | |
6426a772 | 37 | #include "event-top.h" |
96baa820 | 38 | #include "parser-defs.h" |
c906108c SS |
39 | |
40 | /* Functions exported for general use: */ | |
41 | ||
42 | void nofp_registers_info PARAMS ((char *, int)); | |
43 | ||
44 | void all_registers_info PARAMS ((char *, int)); | |
45 | ||
46 | void registers_info PARAMS ((char *, int)); | |
47 | ||
48 | /* Local functions: */ | |
49 | ||
50 | void continue_command PARAMS ((char *, int)); | |
51 | ||
43ff13b4 JM |
52 | static void finish_command_continuation PARAMS ((struct continuation_arg *)); |
53 | ||
c906108c SS |
54 | static void until_next_command PARAMS ((int)); |
55 | ||
56 | static void until_command PARAMS ((char *, int)); | |
57 | ||
58 | static void path_info PARAMS ((char *, int)); | |
59 | ||
60 | static void path_command PARAMS ((char *, int)); | |
61 | ||
62 | static void unset_command PARAMS ((char *, int)); | |
63 | ||
64 | static void float_info PARAMS ((char *, int)); | |
65 | ||
66 | static void detach_command PARAMS ((char *, int)); | |
67 | ||
96baa820 JM |
68 | static void interrupt_target_command (char *args, int from_tty); |
69 | ||
c906108c SS |
70 | #if !defined (DO_REGISTERS_INFO) |
71 | static void do_registers_info PARAMS ((int, int)); | |
72 | #endif | |
73 | ||
74 | static void unset_environment_command PARAMS ((char *, int)); | |
75 | ||
76 | static void set_environment_command PARAMS ((char *, int)); | |
77 | ||
78 | static void environment_info PARAMS ((char *, int)); | |
79 | ||
80 | static void program_info PARAMS ((char *, int)); | |
81 | ||
82 | static void finish_command PARAMS ((char *, int)); | |
83 | ||
84 | static void signal_command PARAMS ((char *, int)); | |
85 | ||
86 | static void jump_command PARAMS ((char *, int)); | |
87 | ||
88 | static void step_1 PARAMS ((int, int, char *)); | |
89 | ||
90 | void nexti_command PARAMS ((char *, int)); | |
91 | ||
92 | void stepi_command PARAMS ((char *, int)); | |
93 | ||
94 | static void next_command PARAMS ((char *, int)); | |
95 | ||
96 | static void step_command PARAMS ((char *, int)); | |
97 | ||
98 | static void run_command PARAMS ((char *, int)); | |
99 | ||
392a587b JM |
100 | static void run_no_args_command PARAMS ((char *args, int from_tty)); |
101 | ||
102 | static void go_command PARAMS ((char *line_no, int from_tty)); | |
103 | ||
43ff13b4 JM |
104 | static int strip_bg_char PARAMS ((char **)); |
105 | ||
c906108c SS |
106 | void _initialize_infcmd PARAMS ((void)); |
107 | ||
108 | #define GO_USAGE "Usage: go <location>\n" | |
109 | ||
c906108c | 110 | static void breakpoint_auto_delete_contents PARAMS ((PTR)); |
c906108c SS |
111 | |
112 | #define ERROR_NO_INFERIOR \ | |
113 | if (!target_has_execution) error ("The program is not being run."); | |
114 | ||
115 | /* String containing arguments to give to the program, separated by spaces. | |
116 | Empty string (pointer to '\0') means no args. */ | |
117 | ||
118 | static char *inferior_args; | |
119 | ||
120 | /* File name for default use for standard in/out in the inferior. */ | |
121 | ||
122 | char *inferior_io_terminal; | |
123 | ||
124 | /* Pid of our debugged inferior, or 0 if no inferior now. | |
125 | Since various parts of infrun.c test this to see whether there is a program | |
126 | being debugged it should be nonzero (currently 3 is used) for remote | |
127 | debugging. */ | |
128 | ||
129 | int inferior_pid; | |
130 | ||
131 | /* Last signal that the inferior received (why it stopped). */ | |
132 | ||
133 | enum target_signal stop_signal; | |
134 | ||
135 | /* Address at which inferior stopped. */ | |
136 | ||
137 | CORE_ADDR stop_pc; | |
138 | ||
139 | /* Chain containing status of breakpoint(s) that we have stopped at. */ | |
140 | ||
141 | bpstat stop_bpstat; | |
142 | ||
143 | /* Flag indicating that a command has proceeded the inferior past the | |
144 | current breakpoint. */ | |
145 | ||
146 | int breakpoint_proceeded; | |
147 | ||
148 | /* Nonzero if stopped due to a step command. */ | |
149 | ||
150 | int stop_step; | |
151 | ||
152 | /* Nonzero if stopped due to completion of a stack dummy routine. */ | |
153 | ||
154 | int stop_stack_dummy; | |
155 | ||
156 | /* Nonzero if stopped due to a random (unexpected) signal in inferior | |
157 | process. */ | |
158 | ||
159 | int stopped_by_random_signal; | |
160 | ||
161 | /* Range to single step within. | |
162 | If this is nonzero, respond to a single-step signal | |
163 | by continuing to step if the pc is in this range. */ | |
164 | ||
c5aa993b JM |
165 | CORE_ADDR step_range_start; /* Inclusive */ |
166 | CORE_ADDR step_range_end; /* Exclusive */ | |
c906108c SS |
167 | |
168 | /* Stack frame address as of when stepping command was issued. | |
169 | This is how we know when we step into a subroutine call, | |
170 | and how to set the frame for the breakpoint used to step out. */ | |
171 | ||
172 | CORE_ADDR step_frame_address; | |
173 | ||
174 | /* Our notion of the current stack pointer. */ | |
175 | ||
176 | CORE_ADDR step_sp; | |
177 | ||
178 | /* 1 means step over all subroutine calls. | |
179 | 0 means don't step over calls (used by stepi). | |
180 | -1 means step over calls to undebuggable functions. */ | |
181 | ||
182 | int step_over_calls; | |
183 | ||
184 | /* If stepping, nonzero means step count is > 1 | |
185 | so don't print frame next time inferior stops | |
186 | if it stops due to stepping. */ | |
187 | ||
188 | int step_multi; | |
189 | ||
190 | /* Environment to use for running inferior, | |
191 | in format described in environ.h. */ | |
192 | ||
193 | struct environ *inferior_environ; | |
c906108c | 194 | \f |
c5aa993b | 195 | |
43ff13b4 JM |
196 | /* This function detects whether or not a '&' character (indicating |
197 | background execution) has been added as *the last* of the arguments ARGS | |
198 | of a command. If it has, it removes it and returns 1. Otherwise it | |
199 | does nothing and returns 0. */ | |
c5aa993b | 200 | static int |
43ff13b4 JM |
201 | strip_bg_char (args) |
202 | char **args; | |
203 | { | |
204 | char *p = NULL; | |
c5aa993b | 205 | |
9846de1b | 206 | p = strchr (*args, '&'); |
c5aa993b | 207 | |
9846de1b | 208 | if (p) |
43ff13b4 JM |
209 | { |
210 | if (p == (*args + strlen (*args) - 1)) | |
211 | { | |
c5aa993b | 212 | if (strlen (*args) > 1) |
43ff13b4 JM |
213 | { |
214 | do | |
215 | p--; | |
216 | while (*p == ' ' || *p == '\t'); | |
217 | *(p + 1) = '\0'; | |
218 | } | |
219 | else | |
220 | *args = 0; | |
221 | return 1; | |
222 | } | |
223 | } | |
224 | return 0; | |
225 | } | |
226 | ||
c906108c SS |
227 | /* ARGSUSED */ |
228 | void | |
229 | tty_command (file, from_tty) | |
230 | char *file; | |
231 | int from_tty; | |
232 | { | |
233 | if (file == 0) | |
234 | error_no_arg ("terminal name for running target process"); | |
235 | ||
236 | inferior_io_terminal = savestring (file, strlen (file)); | |
237 | } | |
238 | ||
239 | static void | |
240 | run_command (args, from_tty) | |
241 | char *args; | |
242 | int from_tty; | |
243 | { | |
244 | char *exec_file; | |
245 | ||
246 | dont_repeat (); | |
247 | ||
248 | if (inferior_pid != 0 && target_has_execution) | |
249 | { | |
adf40b2e JM |
250 | if (from_tty |
251 | && !query ("The program being debugged has been started already.\n\ | |
c906108c SS |
252 | Start it from the beginning? ")) |
253 | error ("Program not restarted."); | |
254 | target_kill (); | |
255 | #if defined(SOLIB_RESTART) | |
256 | SOLIB_RESTART (); | |
257 | #endif | |
258 | init_wait_for_inferior (); | |
259 | } | |
260 | ||
261 | clear_breakpoint_hit_counts (); | |
262 | ||
263 | exec_file = (char *) get_exec_file (0); | |
264 | ||
265 | /* Purge old solib objfiles. */ | |
266 | objfile_purge_solibs (); | |
267 | ||
268 | do_run_cleanups (NULL); | |
269 | ||
270 | /* The exec file is re-read every time we do a generic_mourn_inferior, so | |
271 | we just have to worry about the symbol file. */ | |
272 | reread_symbols (); | |
273 | ||
274 | /* We keep symbols from add-symbol-file, on the grounds that the | |
275 | user might want to add some symbols before running the program | |
276 | (right?). But sometimes (dynamic loading where the user manually | |
277 | introduces the new symbols with add-symbol-file), the code which | |
278 | the symbols describe does not persist between runs. Currently | |
279 | the user has to manually nuke all symbols between runs if they | |
280 | want them to go away (PR 2207). This is probably reasonable. */ | |
281 | ||
43ff13b4 | 282 | if (!args) |
6426a772 JM |
283 | { |
284 | if (event_loop_p && target_can_async_p ()) | |
285 | async_disable_stdin (); | |
286 | } | |
43ff13b4 | 287 | else |
c906108c SS |
288 | { |
289 | char *cmd; | |
43ff13b4 JM |
290 | int async_exec = strip_bg_char (&args); |
291 | ||
292 | /* If we get a request for running in the bg but the target | |
293 | doesn't support it, error out. */ | |
6426a772 | 294 | if (event_loop_p && async_exec && !target_can_async_p ()) |
43ff13b4 JM |
295 | error ("Asynchronous execution not supported on this target."); |
296 | ||
297 | /* If we don't get a request of running in the bg, then we need | |
c5aa993b | 298 | to simulate synchronous (fg) execution. */ |
6426a772 | 299 | if (event_loop_p && !async_exec && target_can_async_p ()) |
43ff13b4 JM |
300 | { |
301 | /* Simulate synchronous execution */ | |
6426a772 | 302 | async_disable_stdin (); |
43ff13b4 JM |
303 | } |
304 | ||
305 | /* If there were other args, beside '&', process them. */ | |
306 | if (args) | |
307 | { | |
308 | cmd = concat ("set args ", args, NULL); | |
309 | make_cleanup (free, cmd); | |
310 | execute_command (cmd, from_tty); | |
311 | } | |
c906108c SS |
312 | } |
313 | ||
314 | if (from_tty) | |
315 | { | |
c5aa993b | 316 | puts_filtered ("Starting program: "); |
c906108c | 317 | if (exec_file) |
c5aa993b JM |
318 | puts_filtered (exec_file); |
319 | puts_filtered (" "); | |
320 | puts_filtered (inferior_args); | |
321 | puts_filtered ("\n"); | |
c906108c SS |
322 | gdb_flush (gdb_stdout); |
323 | } | |
324 | ||
325 | target_create_inferior (exec_file, inferior_args, | |
326 | environ_vector (inferior_environ)); | |
327 | } | |
328 | ||
329 | ||
330 | static void | |
331 | run_no_args_command (args, from_tty) | |
332 | char *args; | |
333 | int from_tty; | |
334 | { | |
c5aa993b JM |
335 | execute_command ("set args", from_tty); |
336 | run_command ((char *) NULL, from_tty); | |
c906108c | 337 | } |
c906108c | 338 | \f |
c5aa993b | 339 | |
c906108c SS |
340 | void |
341 | continue_command (proc_count_exp, from_tty) | |
342 | char *proc_count_exp; | |
343 | int from_tty; | |
344 | { | |
c5aa993b | 345 | int async_exec = 0; |
c906108c SS |
346 | ERROR_NO_INFERIOR; |
347 | ||
43ff13b4 JM |
348 | /* Find out whether we must run in the background. */ |
349 | if (proc_count_exp != NULL) | |
350 | async_exec = strip_bg_char (&proc_count_exp); | |
351 | ||
352 | /* If we must run in the background, but the target can't do it, | |
353 | error out. */ | |
6426a772 | 354 | if (event_loop_p && async_exec && !target_can_async_p ()) |
43ff13b4 JM |
355 | error ("Asynchronous execution not supported on this target."); |
356 | ||
357 | /* If we are not asked to run in the bg, then prepare to run in the | |
358 | foreground, synchronously. */ | |
6426a772 | 359 | if (event_loop_p && !async_exec && target_can_async_p ()) |
c5aa993b | 360 | { |
43ff13b4 | 361 | /* Simulate synchronous execution */ |
6426a772 | 362 | async_disable_stdin (); |
43ff13b4 | 363 | } |
c906108c | 364 | |
43ff13b4 JM |
365 | /* If have argument (besides '&'), set proceed count of breakpoint |
366 | we stopped at. */ | |
c906108c SS |
367 | if (proc_count_exp != NULL) |
368 | { | |
369 | bpstat bs = stop_bpstat; | |
370 | int num = bpstat_num (&bs); | |
371 | if (num == 0 && from_tty) | |
372 | { | |
373 | printf_filtered | |
374 | ("Not stopped at any breakpoint; argument ignored.\n"); | |
375 | } | |
376 | while (num != 0) | |
377 | { | |
378 | set_ignore_count (num, | |
379 | parse_and_eval_address (proc_count_exp) - 1, | |
380 | from_tty); | |
381 | /* set_ignore_count prints a message ending with a period. | |
382 | So print two spaces before "Continuing.". */ | |
383 | if (from_tty) | |
384 | printf_filtered (" "); | |
385 | num = bpstat_num (&bs); | |
386 | } | |
387 | } | |
388 | ||
389 | if (from_tty) | |
390 | printf_filtered ("Continuing.\n"); | |
391 | ||
392 | clear_proceed_status (); | |
393 | ||
2acceee2 | 394 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); |
c906108c SS |
395 | } |
396 | \f | |
397 | /* Step until outside of current statement. */ | |
398 | ||
399 | /* ARGSUSED */ | |
400 | static void | |
401 | step_command (count_string, from_tty) | |
402 | char *count_string; | |
403 | int from_tty; | |
404 | { | |
405 | step_1 (0, 0, count_string); | |
406 | } | |
407 | ||
408 | /* Likewise, but skip over subroutine calls as if single instructions. */ | |
409 | ||
410 | /* ARGSUSED */ | |
411 | static void | |
412 | next_command (count_string, from_tty) | |
413 | char *count_string; | |
414 | int from_tty; | |
415 | { | |
416 | step_1 (1, 0, count_string); | |
417 | } | |
418 | ||
419 | /* Likewise, but step only one instruction. */ | |
420 | ||
421 | /* ARGSUSED */ | |
422 | void | |
423 | stepi_command (count_string, from_tty) | |
424 | char *count_string; | |
425 | int from_tty; | |
426 | { | |
427 | step_1 (0, 1, count_string); | |
428 | } | |
429 | ||
430 | /* ARGSUSED */ | |
431 | void | |
432 | nexti_command (count_string, from_tty) | |
433 | char *count_string; | |
434 | int from_tty; | |
435 | { | |
436 | step_1 (1, 1, count_string); | |
437 | } | |
438 | ||
439 | static void | |
440 | step_1 (skip_subroutines, single_inst, count_string) | |
441 | int skip_subroutines; | |
442 | int single_inst; | |
443 | char *count_string; | |
444 | { | |
445 | register int count = 1; | |
446 | struct frame_info *frame; | |
447 | struct cleanup *cleanups = 0; | |
43ff13b4 | 448 | int async_exec = 0; |
c5aa993b | 449 | |
c906108c | 450 | ERROR_NO_INFERIOR; |
43ff13b4 JM |
451 | |
452 | if (count_string) | |
453 | async_exec = strip_bg_char (&count_string); | |
c5aa993b | 454 | |
43ff13b4 JM |
455 | /* If we get a request for running in the bg but the target |
456 | doesn't support it, error out. */ | |
6426a772 | 457 | if (event_loop_p && async_exec && !target_can_async_p ()) |
43ff13b4 JM |
458 | error ("Asynchronous execution not supported on this target."); |
459 | ||
460 | /* If we don't get a request of running in the bg, then we need | |
461 | to simulate synchronous (fg) execution. */ | |
6426a772 | 462 | if (event_loop_p && !async_exec && target_can_async_p ()) |
43ff13b4 JM |
463 | { |
464 | /* Simulate synchronous execution */ | |
6426a772 | 465 | async_disable_stdin (); |
43ff13b4 JM |
466 | } |
467 | ||
c906108c SS |
468 | count = count_string ? parse_and_eval_address (count_string) : 1; |
469 | ||
c5aa993b | 470 | if (!single_inst || skip_subroutines) /* leave si command alone */ |
c906108c | 471 | { |
c5aa993b JM |
472 | enable_longjmp_breakpoint (); |
473 | cleanups = make_cleanup ((make_cleanup_func) disable_longjmp_breakpoint, | |
474 | 0); | |
c906108c SS |
475 | } |
476 | ||
477 | for (; count > 0; count--) | |
478 | { | |
479 | clear_proceed_status (); | |
480 | ||
481 | frame = get_current_frame (); | |
c5aa993b | 482 | if (!frame) /* Avoid coredump here. Why tho? */ |
c906108c SS |
483 | error ("No current frame"); |
484 | step_frame_address = FRAME_FP (frame); | |
485 | step_sp = read_sp (); | |
486 | ||
c5aa993b | 487 | if (!single_inst) |
c906108c SS |
488 | { |
489 | find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end); | |
490 | if (step_range_end == 0) | |
491 | { | |
492 | char *name; | |
493 | if (find_pc_partial_function (stop_pc, &name, &step_range_start, | |
494 | &step_range_end) == 0) | |
495 | error ("Cannot find bounds of current function"); | |
496 | ||
497 | target_terminal_ours (); | |
498 | printf_filtered ("\ | |
499 | Single stepping until exit from function %s, \n\ | |
500 | which has no line number information.\n", name); | |
501 | } | |
502 | } | |
503 | else | |
504 | { | |
505 | /* Say we are stepping, but stop after one insn whatever it does. */ | |
506 | step_range_start = step_range_end = 1; | |
507 | if (!skip_subroutines) | |
508 | /* It is stepi. | |
509 | Don't step over function calls, not even to functions lacking | |
510 | line numbers. */ | |
511 | step_over_calls = 0; | |
512 | } | |
513 | ||
514 | if (skip_subroutines) | |
515 | step_over_calls = 1; | |
516 | ||
517 | step_multi = (count > 1); | |
2acceee2 | 518 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
c5aa993b | 519 | if (!stop_step) |
c906108c SS |
520 | break; |
521 | ||
522 | /* FIXME: On nexti, this may have already been done (when we hit the | |
c5aa993b JM |
523 | step resume break, I think). Probably this should be moved to |
524 | wait_for_inferior (near the top). */ | |
c906108c | 525 | #if defined (SHIFT_INST_REGS) |
c5aa993b | 526 | SHIFT_INST_REGS (); |
c906108c SS |
527 | #endif |
528 | } | |
529 | ||
530 | if (!single_inst || skip_subroutines) | |
c5aa993b | 531 | do_cleanups (cleanups); |
c906108c SS |
532 | } |
533 | \f | |
534 | /* Continue program at specified address. */ | |
535 | ||
536 | static void | |
537 | jump_command (arg, from_tty) | |
538 | char *arg; | |
539 | int from_tty; | |
540 | { | |
541 | register CORE_ADDR addr; | |
542 | struct symtabs_and_lines sals; | |
543 | struct symtab_and_line sal; | |
544 | struct symbol *fn; | |
545 | struct symbol *sfn; | |
43ff13b4 | 546 | int async_exec = 0; |
c5aa993b | 547 | |
c906108c SS |
548 | ERROR_NO_INFERIOR; |
549 | ||
43ff13b4 JM |
550 | /* Find out whether we must run in the background. */ |
551 | if (arg != NULL) | |
552 | async_exec = strip_bg_char (&arg); | |
553 | ||
554 | /* If we must run in the background, but the target can't do it, | |
555 | error out. */ | |
6426a772 | 556 | if (event_loop_p && async_exec && !target_can_async_p ()) |
43ff13b4 JM |
557 | error ("Asynchronous execution not supported on this target."); |
558 | ||
559 | /* If we are not asked to run in the bg, then prepare to run in the | |
560 | foreground, synchronously. */ | |
6426a772 | 561 | if (event_loop_p && !async_exec && target_can_async_p ()) |
c5aa993b | 562 | { |
43ff13b4 | 563 | /* Simulate synchronous execution */ |
6426a772 | 564 | async_disable_stdin (); |
43ff13b4 JM |
565 | } |
566 | ||
c906108c SS |
567 | if (!arg) |
568 | error_no_arg ("starting address"); | |
569 | ||
570 | sals = decode_line_spec_1 (arg, 1); | |
571 | if (sals.nelts != 1) | |
572 | { | |
573 | error ("Unreasonable jump request"); | |
574 | } | |
575 | ||
576 | sal = sals.sals[0]; | |
c5aa993b | 577 | free ((PTR) sals.sals); |
c906108c SS |
578 | |
579 | if (sal.symtab == 0 && sal.pc == 0) | |
580 | error ("No source file has been specified."); | |
581 | ||
c5aa993b | 582 | resolve_sal_pc (&sal); /* May error out */ |
c906108c SS |
583 | |
584 | /* See if we are trying to jump to another function. */ | |
585 | fn = get_frame_function (get_current_frame ()); | |
586 | sfn = find_pc_function (sal.pc); | |
587 | if (fn != NULL && sfn != fn) | |
588 | { | |
589 | if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, | |
590 | SYMBOL_SOURCE_NAME (fn))) | |
591 | { | |
592 | error ("Not confirmed."); | |
593 | /* NOTREACHED */ | |
594 | } | |
595 | } | |
596 | ||
c5aa993b | 597 | if (sfn != NULL) |
c906108c SS |
598 | { |
599 | fixup_symbol_section (sfn, 0); | |
c5aa993b | 600 | if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) && |
c906108c SS |
601 | !section_is_mapped (SYMBOL_BFD_SECTION (sfn))) |
602 | { | |
603 | if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? ")) | |
604 | { | |
605 | error ("Not confirmed."); | |
606 | /* NOTREACHED */ | |
607 | } | |
608 | } | |
609 | } | |
610 | ||
c906108c SS |
611 | addr = sal.pc; |
612 | ||
613 | if (from_tty) | |
614 | { | |
615 | printf_filtered ("Continuing at "); | |
616 | print_address_numeric (addr, 1, gdb_stdout); | |
617 | printf_filtered (".\n"); | |
618 | } | |
619 | ||
620 | clear_proceed_status (); | |
621 | proceed (addr, TARGET_SIGNAL_0, 0); | |
622 | } | |
c906108c | 623 | \f |
c5aa993b | 624 | |
c906108c SS |
625 | /* Go to line or address in current procedure */ |
626 | static void | |
b83266a0 | 627 | go_command (line_no, from_tty) |
c906108c SS |
628 | char *line_no; |
629 | int from_tty; | |
630 | { | |
c5aa993b | 631 | if (line_no == (char *) NULL || !*line_no) |
b83266a0 | 632 | printf_filtered (GO_USAGE); |
c906108c SS |
633 | else |
634 | { | |
b83266a0 SS |
635 | tbreak_command (line_no, from_tty); |
636 | jump_command (line_no, from_tty); | |
c906108c SS |
637 | } |
638 | } | |
c906108c | 639 | \f |
c5aa993b | 640 | |
c906108c SS |
641 | /* Continue program giving it specified signal. */ |
642 | ||
643 | static void | |
644 | signal_command (signum_exp, from_tty) | |
645 | char *signum_exp; | |
646 | int from_tty; | |
647 | { | |
648 | enum target_signal oursig; | |
649 | ||
650 | dont_repeat (); /* Too dangerous. */ | |
651 | ERROR_NO_INFERIOR; | |
652 | ||
653 | if (!signum_exp) | |
654 | error_no_arg ("signal number"); | |
655 | ||
656 | /* It would be even slicker to make signal names be valid expressions, | |
657 | (the type could be "enum $signal" or some such), then the user could | |
658 | assign them to convenience variables. */ | |
659 | oursig = target_signal_from_name (signum_exp); | |
660 | ||
661 | if (oursig == TARGET_SIGNAL_UNKNOWN) | |
662 | { | |
663 | /* No, try numeric. */ | |
664 | int num = parse_and_eval_address (signum_exp); | |
665 | ||
666 | if (num == 0) | |
667 | oursig = TARGET_SIGNAL_0; | |
668 | else | |
669 | oursig = target_signal_from_command (num); | |
670 | } | |
671 | ||
672 | if (from_tty) | |
673 | { | |
674 | if (oursig == TARGET_SIGNAL_0) | |
675 | printf_filtered ("Continuing with no signal.\n"); | |
676 | else | |
677 | printf_filtered ("Continuing with signal %s.\n", | |
678 | target_signal_to_name (oursig)); | |
679 | } | |
680 | ||
681 | clear_proceed_status (); | |
682 | /* "signal 0" should not get stuck if we are stopped at a breakpoint. | |
683 | FIXME: Neither should "signal foo" but when I tried passing | |
684 | (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't | |
685 | tried to track down yet. */ | |
2acceee2 | 686 | proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0); |
c906108c SS |
687 | } |
688 | ||
689 | /* Call breakpoint_auto_delete on the current contents of the bpstat | |
690 | pointed to by arg (which is really a bpstat *). */ | |
691 | ||
c906108c SS |
692 | static void |
693 | breakpoint_auto_delete_contents (arg) | |
694 | PTR arg; | |
695 | { | |
c5aa993b | 696 | breakpoint_auto_delete (*(bpstat *) arg); |
c906108c SS |
697 | } |
698 | ||
c906108c SS |
699 | |
700 | /* Execute a "stack dummy", a piece of code stored in the stack | |
701 | by the debugger to be executed in the inferior. | |
702 | ||
703 | To call: first, do PUSH_DUMMY_FRAME. | |
704 | Then push the contents of the dummy. It should end with a breakpoint insn. | |
705 | Then call here, passing address at which to start the dummy. | |
706 | ||
707 | The contents of all registers are saved before the dummy frame is popped | |
708 | and copied into the buffer BUFFER. | |
709 | ||
710 | The dummy's frame is automatically popped whenever that break is hit. | |
711 | If that is the first time the program stops, run_stack_dummy | |
712 | returns to its caller with that frame already gone and returns 0. | |
713 | Otherwise, run_stack-dummy returns 1 (the frame will eventually be popped | |
714 | when we do hit that breakpoint). */ | |
715 | ||
c906108c SS |
716 | int |
717 | run_stack_dummy (addr, buffer) | |
718 | CORE_ADDR addr; | |
7a292a7a | 719 | char *buffer; |
c906108c SS |
720 | { |
721 | struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0); | |
722 | ||
723 | /* Now proceed, having reached the desired place. */ | |
724 | clear_proceed_status (); | |
96baa820 | 725 | |
7a292a7a SS |
726 | if (CALL_DUMMY_BREAKPOINT_OFFSET_P) |
727 | { | |
728 | struct breakpoint *bpt; | |
729 | struct symtab_and_line sal; | |
c5aa993b JM |
730 | |
731 | INIT_SAL (&sal); /* initialize to zeroes */ | |
7a292a7a SS |
732 | if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) |
733 | { | |
734 | sal.pc = CALL_DUMMY_ADDRESS (); | |
735 | } | |
736 | else | |
737 | { | |
738 | sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET; | |
739 | } | |
740 | sal.section = find_pc_overlay (sal.pc); | |
c5aa993b | 741 | |
7a292a7a | 742 | /* Set up a FRAME for the dummy frame so we can pass it to |
c5aa993b JM |
743 | set_momentary_breakpoint. We need to give the breakpoint a |
744 | frame in case there is only one copy of the dummy (e.g. | |
745 | CALL_DUMMY_LOCATION == AFTER_TEXT_END). */ | |
7a292a7a SS |
746 | flush_cached_frames (); |
747 | set_current_frame (create_new_frame (read_fp (), sal.pc)); | |
c5aa993b | 748 | |
7a292a7a | 749 | /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put |
c5aa993b JM |
750 | a breakpoint instruction. If not, the call dummy already has the |
751 | breakpoint instruction in it. | |
752 | ||
753 | addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET, | |
754 | so we need to subtract the CALL_DUMMY_START_OFFSET. */ | |
7a292a7a SS |
755 | bpt = set_momentary_breakpoint (sal, |
756 | get_current_frame (), | |
757 | bp_call_dummy); | |
758 | bpt->disposition = del; | |
c5aa993b | 759 | |
7a292a7a | 760 | /* If all error()s out of proceed ended up calling normal_stop (and |
c5aa993b JM |
761 | perhaps they should; it already does in the special case of error |
762 | out of resume()), then we wouldn't need this. */ | |
7a292a7a SS |
763 | make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat); |
764 | } | |
c906108c SS |
765 | |
766 | disable_watchpoints_before_interactive_call_start (); | |
767 | proceed_to_finish = 1; /* We want stop_registers, please... */ | |
768 | proceed (addr, TARGET_SIGNAL_0, 0); | |
769 | enable_watchpoints_after_interactive_call_stop (); | |
770 | ||
771 | discard_cleanups (old_cleanups); | |
772 | ||
773 | if (!stop_stack_dummy) | |
774 | return 1; | |
775 | ||
776 | /* On return, the stack dummy has been popped already. */ | |
777 | ||
7a292a7a | 778 | memcpy (buffer, stop_registers, REGISTER_BYTES); |
c906108c SS |
779 | return 0; |
780 | } | |
781 | \f | |
782 | /* Proceed until we reach a different source line with pc greater than | |
783 | our current one or exit the function. We skip calls in both cases. | |
784 | ||
785 | Note that eventually this command should probably be changed so | |
786 | that only source lines are printed out when we hit the breakpoint | |
787 | we set. This may involve changes to wait_for_inferior and the | |
788 | proceed status code. */ | |
789 | ||
790 | /* ARGSUSED */ | |
791 | static void | |
792 | until_next_command (from_tty) | |
793 | int from_tty; | |
794 | { | |
795 | struct frame_info *frame; | |
796 | CORE_ADDR pc; | |
797 | struct symbol *func; | |
798 | struct symtab_and_line sal; | |
c5aa993b | 799 | |
c906108c SS |
800 | clear_proceed_status (); |
801 | ||
802 | frame = get_current_frame (); | |
803 | ||
804 | /* Step until either exited from this function or greater | |
805 | than the current line (if in symbolic section) or pc (if | |
806 | not). */ | |
807 | ||
808 | pc = read_pc (); | |
809 | func = find_pc_function (pc); | |
c5aa993b | 810 | |
c906108c SS |
811 | if (!func) |
812 | { | |
813 | struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc); | |
c5aa993b | 814 | |
c906108c SS |
815 | if (msymbol == NULL) |
816 | error ("Execution is not within a known function."); | |
c5aa993b | 817 | |
c906108c SS |
818 | step_range_start = SYMBOL_VALUE_ADDRESS (msymbol); |
819 | step_range_end = pc; | |
820 | } | |
821 | else | |
822 | { | |
823 | sal = find_pc_line (pc, 0); | |
c5aa993b | 824 | |
c906108c SS |
825 | step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); |
826 | step_range_end = sal.end; | |
827 | } | |
c5aa993b | 828 | |
c906108c SS |
829 | step_over_calls = 1; |
830 | step_frame_address = FRAME_FP (frame); | |
831 | step_sp = read_sp (); | |
832 | ||
833 | step_multi = 0; /* Only one call to proceed */ | |
c5aa993b | 834 | |
2acceee2 | 835 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1); |
c906108c SS |
836 | } |
837 | ||
c5aa993b | 838 | static void |
c906108c SS |
839 | until_command (arg, from_tty) |
840 | char *arg; | |
841 | int from_tty; | |
842 | { | |
43ff13b4 JM |
843 | int async_exec = 0; |
844 | ||
c906108c SS |
845 | if (!target_has_execution) |
846 | error ("The program is not running."); | |
43ff13b4 JM |
847 | |
848 | /* Find out whether we must run in the background. */ | |
849 | if (arg != NULL) | |
850 | async_exec = strip_bg_char (&arg); | |
851 | ||
852 | /* If we must run in the background, but the target can't do it, | |
853 | error out. */ | |
6426a772 | 854 | if (event_loop_p && async_exec && !target_can_async_p ()) |
43ff13b4 JM |
855 | error ("Asynchronous execution not supported on this target."); |
856 | ||
857 | /* If we are not asked to run in the bg, then prepare to run in the | |
858 | foreground, synchronously. */ | |
6426a772 | 859 | if (event_loop_p && !async_exec && target_can_async_p ()) |
c5aa993b | 860 | { |
43ff13b4 | 861 | /* Simulate synchronous execution */ |
6426a772 | 862 | async_disable_stdin (); |
43ff13b4 JM |
863 | } |
864 | ||
c906108c SS |
865 | if (arg) |
866 | until_break_command (arg, from_tty); | |
867 | else | |
868 | until_next_command (from_tty); | |
869 | } | |
870 | \f | |
43ff13b4 JM |
871 | |
872 | /* Stuff that needs to be done by the finish command after the target | |
873 | has stopped. In asynchronous mode, we wait for the target to stop in | |
874 | the call to poll or select in the event loop, so it is impossible to | |
875 | do all the stuff as part of the finish_command function itself. The | |
876 | only chance we have to complete this command is in | |
877 | fetch_inferior_event, which is called by the event loop as soon as it | |
878 | detects that the target has stopped. This function is called via the | |
879 | cmd_continaution pointer. */ | |
880 | void | |
881 | finish_command_continuation (arg) | |
882 | struct continuation_arg *arg; | |
883 | { | |
884 | register struct symbol *function; | |
885 | struct breakpoint *breakpoint; | |
c5aa993b | 886 | |
43ff13b4 JM |
887 | breakpoint = (struct breakpoint *) arg->data; |
888 | function = (struct symbol *) (arg->next)->data; | |
889 | ||
c5aa993b | 890 | if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL |
43ff13b4 JM |
891 | && function != 0) |
892 | { | |
893 | struct type *value_type; | |
894 | register value_ptr val; | |
895 | CORE_ADDR funcaddr; | |
896 | int struct_return; | |
897 | ||
898 | value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); | |
899 | if (!value_type) | |
96baa820 | 900 | internal_error ("finish_command: function has no target type"); |
c5aa993b | 901 | |
43ff13b4 JM |
902 | if (TYPE_CODE (value_type) == TYPE_CODE_VOID) |
903 | { | |
904 | do_exec_cleanups (ALL_CLEANUPS); | |
905 | return; | |
906 | } | |
907 | ||
908 | funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); | |
909 | ||
910 | struct_return = using_struct_return (value_of_variable (function, NULL), | |
911 | ||
c5aa993b JM |
912 | funcaddr, |
913 | check_typedef (value_type), | |
914 | BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))); | |
43ff13b4 JM |
915 | |
916 | if (!struct_return) | |
c5aa993b JM |
917 | { |
918 | val = value_being_returned (value_type, stop_registers, struct_return); | |
919 | printf_filtered ("Value returned is $%d = ", record_latest_value (val)); | |
920 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); | |
921 | printf_filtered ("\n"); | |
922 | } | |
43ff13b4 | 923 | else |
c5aa993b JM |
924 | { |
925 | /* We cannot determine the contents of the structure because | |
926 | it is on the stack, and we don't know where, since we did not | |
927 | initiate the call, as opposed to the call_function_by_hand case */ | |
43ff13b4 | 928 | #ifdef VALUE_RETURNED_FROM_STACK |
c5aa993b JM |
929 | val = 0; |
930 | printf_filtered ("Value returned has type: %s.", | |
43ff13b4 | 931 | TYPE_NAME (value_type)); |
c5aa993b | 932 | printf_filtered (" Cannot determine contents\n"); |
43ff13b4 | 933 | #else |
c5aa993b | 934 | val = value_being_returned (value_type, stop_registers, |
43ff13b4 | 935 | struct_return); |
c5aa993b | 936 | printf_filtered ("Value returned is $%d = ", |
43ff13b4 | 937 | record_latest_value (val)); |
c5aa993b JM |
938 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); |
939 | printf_filtered ("\n"); | |
43ff13b4 | 940 | #endif |
c5aa993b JM |
941 | |
942 | } | |
43ff13b4 JM |
943 | } |
944 | do_exec_cleanups (ALL_CLEANUPS); | |
945 | } | |
946 | ||
c906108c SS |
947 | /* "finish": Set a temporary breakpoint at the place |
948 | the selected frame will return to, then continue. */ | |
949 | ||
950 | static void | |
951 | finish_command (arg, from_tty) | |
952 | char *arg; | |
953 | int from_tty; | |
954 | { | |
955 | struct symtab_and_line sal; | |
956 | register struct frame_info *frame; | |
957 | register struct symbol *function; | |
958 | struct breakpoint *breakpoint; | |
959 | struct cleanup *old_chain; | |
43ff13b4 JM |
960 | struct continuation_arg *arg1, *arg2; |
961 | ||
962 | int async_exec = 0; | |
963 | ||
964 | /* Find out whether we must run in the background. */ | |
965 | if (arg != NULL) | |
966 | async_exec = strip_bg_char (&arg); | |
967 | ||
968 | /* If we must run in the background, but the target can't do it, | |
969 | error out. */ | |
6426a772 | 970 | if (event_loop_p && async_exec && !target_can_async_p ()) |
43ff13b4 JM |
971 | error ("Asynchronous execution not supported on this target."); |
972 | ||
973 | /* If we are not asked to run in the bg, then prepare to run in the | |
974 | foreground, synchronously. */ | |
6426a772 | 975 | if (event_loop_p && !async_exec && target_can_async_p ()) |
c5aa993b | 976 | { |
43ff13b4 | 977 | /* Simulate synchronous execution */ |
6426a772 | 978 | async_disable_stdin (); |
43ff13b4 | 979 | } |
c906108c SS |
980 | |
981 | if (arg) | |
982 | error ("The \"finish\" command does not take any arguments."); | |
983 | if (!target_has_execution) | |
984 | error ("The program is not running."); | |
985 | if (selected_frame == NULL) | |
986 | error ("No selected frame."); | |
987 | ||
988 | frame = get_prev_frame (selected_frame); | |
989 | if (frame == 0) | |
990 | error ("\"finish\" not meaningful in the outermost frame."); | |
991 | ||
992 | clear_proceed_status (); | |
993 | ||
994 | sal = find_pc_line (frame->pc, 0); | |
995 | sal.pc = frame->pc; | |
996 | ||
997 | breakpoint = set_momentary_breakpoint (sal, frame, bp_finish); | |
998 | ||
6426a772 | 999 | if (!event_loop_p || !target_can_async_p ()) |
43ff13b4 JM |
1000 | old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint); |
1001 | else | |
1002 | make_exec_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint); | |
c906108c SS |
1003 | |
1004 | /* Find the function we will return from. */ | |
1005 | ||
1006 | function = find_pc_function (selected_frame->pc); | |
1007 | ||
1008 | /* Print info on the selected frame, including level number | |
1009 | but not source. */ | |
1010 | if (from_tty) | |
1011 | { | |
1012 | printf_filtered ("Run till exit from "); | |
1013 | print_stack_frame (selected_frame, selected_frame_level, 0); | |
1014 | } | |
1015 | ||
43ff13b4 JM |
1016 | /* If running asynchronously and the target support asynchronous |
1017 | execution, set things up for the rest of the finish command to be | |
1018 | completed later on, when gdb has detected that the target has | |
1019 | stopped, in fetch_inferior_event. */ | |
6426a772 | 1020 | if (event_loop_p && target_can_async_p ()) |
43ff13b4 | 1021 | { |
c5aa993b | 1022 | arg1 = |
43ff13b4 | 1023 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
c5aa993b | 1024 | arg2 = |
43ff13b4 JM |
1025 | (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg)); |
1026 | arg1->next = arg2; | |
1027 | arg2->next = NULL; | |
1028 | arg1->data = (PTR) breakpoint; | |
1029 | arg2->data = (PTR) function; | |
1030 | add_continuation (finish_command_continuation, arg1); | |
1031 | } | |
1032 | ||
c5aa993b | 1033 | proceed_to_finish = 1; /* We want stop_registers, please... */ |
2acceee2 | 1034 | proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0); |
c906108c | 1035 | |
43ff13b4 JM |
1036 | /* Do this only if not running asynchronously or if the target |
1037 | cannot do async execution. Otherwise, complete this command when | |
c5aa993b | 1038 | the target actually stops, in fetch_inferior_event. */ |
6426a772 | 1039 | if (!event_loop_p || !target_can_async_p ()) |
c5aa993b JM |
1040 | { |
1041 | ||
1042 | /* Did we stop at our breakpoint? */ | |
1043 | if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL | |
1044 | && function != 0) | |
1045 | { | |
1046 | struct type *value_type; | |
1047 | register value_ptr val; | |
1048 | CORE_ADDR funcaddr; | |
1049 | int struct_return; | |
1050 | ||
1051 | value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function)); | |
1052 | if (!value_type) | |
96baa820 | 1053 | internal_error ("finish_command: function has no target type"); |
c5aa993b JM |
1054 | |
1055 | /* FIXME: Shouldn't we do the cleanups before returning? */ | |
1056 | if (TYPE_CODE (value_type) == TYPE_CODE_VOID) | |
1057 | return; | |
1058 | ||
1059 | funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function)); | |
1060 | ||
1061 | struct_return = | |
1062 | using_struct_return (value_of_variable (function, NULL), | |
1063 | funcaddr, | |
1064 | check_typedef (value_type), | |
1065 | BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))); | |
1066 | ||
1067 | if (!struct_return) | |
1068 | { | |
1069 | val = | |
1070 | value_being_returned (value_type, stop_registers, struct_return); | |
1071 | printf_filtered ("Value returned is $%d = ", | |
1072 | record_latest_value (val)); | |
1073 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); | |
1074 | printf_filtered ("\n"); | |
1075 | } | |
1076 | else | |
1077 | { | |
1078 | /* We cannot determine the contents of the structure | |
1079 | because it is on the stack, and we don't know | |
1080 | where, since we did not initiate the call, as | |
1081 | opposed to the call_function_by_hand case */ | |
c906108c | 1082 | #ifdef VALUE_RETURNED_FROM_STACK |
c5aa993b JM |
1083 | val = 0; |
1084 | printf_filtered ("Value returned has type: %s.", | |
1085 | TYPE_NAME (value_type)); | |
1086 | printf_filtered (" Cannot determine contents\n"); | |
c906108c | 1087 | #else |
c5aa993b JM |
1088 | val = value_being_returned (value_type, stop_registers, |
1089 | struct_return); | |
1090 | printf_filtered ("Value returned is $%d = ", | |
1091 | record_latest_value (val)); | |
1092 | value_print (val, gdb_stdout, 0, Val_no_prettyprint); | |
1093 | printf_filtered ("\n"); | |
1094 | #endif | |
1095 | } | |
1096 | } | |
1097 | do_cleanups (old_chain); | |
1098 | } | |
c906108c SS |
1099 | } |
1100 | \f | |
1101 | /* ARGSUSED */ | |
1102 | static void | |
1103 | program_info (args, from_tty) | |
c5aa993b JM |
1104 | char *args; |
1105 | int from_tty; | |
c906108c SS |
1106 | { |
1107 | bpstat bs = stop_bpstat; | |
1108 | int num = bpstat_num (&bs); | |
c5aa993b | 1109 | |
c906108c SS |
1110 | if (!target_has_execution) |
1111 | { | |
1112 | printf_filtered ("The program being debugged is not being run.\n"); | |
1113 | return; | |
1114 | } | |
1115 | ||
1116 | target_files_info (); | |
1117 | printf_filtered ("Program stopped at %s.\n", | |
c5aa993b | 1118 | local_hex_string ((unsigned long) stop_pc)); |
c906108c SS |
1119 | if (stop_step) |
1120 | printf_filtered ("It stopped after being stepped.\n"); | |
1121 | else if (num != 0) | |
1122 | { | |
1123 | /* There may be several breakpoints in the same place, so this | |
c5aa993b | 1124 | isn't as strange as it seems. */ |
c906108c SS |
1125 | while (num != 0) |
1126 | { | |
1127 | if (num < 0) | |
1128 | { | |
1129 | printf_filtered ("It stopped at a breakpoint that has "); | |
1130 | printf_filtered ("since been deleted.\n"); | |
1131 | } | |
1132 | else | |
1133 | printf_filtered ("It stopped at breakpoint %d.\n", num); | |
1134 | num = bpstat_num (&bs); | |
1135 | } | |
1136 | } | |
1137 | else if (stop_signal != TARGET_SIGNAL_0) | |
1138 | { | |
1139 | printf_filtered ("It stopped with signal %s, %s.\n", | |
1140 | target_signal_to_name (stop_signal), | |
1141 | target_signal_to_string (stop_signal)); | |
1142 | } | |
1143 | ||
1144 | if (!from_tty) | |
1145 | { | |
1146 | printf_filtered ("Type \"info stack\" or \"info registers\" "); | |
1147 | printf_filtered ("for more information.\n"); | |
1148 | } | |
1149 | } | |
1150 | \f | |
1151 | static void | |
1152 | environment_info (var, from_tty) | |
1153 | char *var; | |
1154 | int from_tty; | |
1155 | { | |
1156 | if (var) | |
1157 | { | |
1158 | register char *val = get_in_environ (inferior_environ, var); | |
1159 | if (val) | |
1160 | { | |
1161 | puts_filtered (var); | |
1162 | puts_filtered (" = "); | |
1163 | puts_filtered (val); | |
1164 | puts_filtered ("\n"); | |
1165 | } | |
1166 | else | |
1167 | { | |
1168 | puts_filtered ("Environment variable \""); | |
1169 | puts_filtered (var); | |
1170 | puts_filtered ("\" not defined.\n"); | |
1171 | } | |
1172 | } | |
1173 | else | |
1174 | { | |
1175 | register char **vector = environ_vector (inferior_environ); | |
1176 | while (*vector) | |
1177 | { | |
1178 | puts_filtered (*vector++); | |
1179 | puts_filtered ("\n"); | |
1180 | } | |
1181 | } | |
1182 | } | |
1183 | ||
1184 | static void | |
1185 | set_environment_command (arg, from_tty) | |
1186 | char *arg; | |
1187 | int from_tty; | |
1188 | { | |
1189 | register char *p, *val, *var; | |
1190 | int nullset = 0; | |
1191 | ||
1192 | if (arg == 0) | |
1193 | error_no_arg ("environment variable and value"); | |
1194 | ||
1195 | /* Find seperation between variable name and value */ | |
1196 | p = (char *) strchr (arg, '='); | |
1197 | val = (char *) strchr (arg, ' '); | |
1198 | ||
1199 | if (p != 0 && val != 0) | |
1200 | { | |
1201 | /* We have both a space and an equals. If the space is before the | |
c5aa993b JM |
1202 | equals, walk forward over the spaces til we see a nonspace |
1203 | (possibly the equals). */ | |
c906108c SS |
1204 | if (p > val) |
1205 | while (*val == ' ') | |
1206 | val++; | |
1207 | ||
1208 | /* Now if the = is after the char following the spaces, | |
c5aa993b | 1209 | take the char following the spaces. */ |
c906108c SS |
1210 | if (p > val) |
1211 | p = val - 1; | |
1212 | } | |
1213 | else if (val != 0 && p == 0) | |
1214 | p = val; | |
1215 | ||
1216 | if (p == arg) | |
1217 | error_no_arg ("environment variable to set"); | |
1218 | ||
1219 | if (p == 0 || p[1] == 0) | |
1220 | { | |
1221 | nullset = 1; | |
1222 | if (p == 0) | |
1223 | p = arg + strlen (arg); /* So that savestring below will work */ | |
1224 | } | |
1225 | else | |
1226 | { | |
1227 | /* Not setting variable value to null */ | |
1228 | val = p + 1; | |
1229 | while (*val == ' ' || *val == '\t') | |
1230 | val++; | |
1231 | } | |
1232 | ||
c5aa993b JM |
1233 | while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) |
1234 | p--; | |
c906108c SS |
1235 | |
1236 | var = savestring (arg, p - arg); | |
1237 | if (nullset) | |
1238 | { | |
1239 | printf_filtered ("Setting environment variable "); | |
1240 | printf_filtered ("\"%s\" to null value.\n", var); | |
1241 | set_in_environ (inferior_environ, var, ""); | |
1242 | } | |
1243 | else | |
1244 | set_in_environ (inferior_environ, var, val); | |
1245 | free (var); | |
1246 | } | |
1247 | ||
1248 | static void | |
1249 | unset_environment_command (var, from_tty) | |
1250 | char *var; | |
1251 | int from_tty; | |
1252 | { | |
1253 | if (var == 0) | |
1254 | { | |
1255 | /* If there is no argument, delete all environment variables. | |
c5aa993b | 1256 | Ask for confirmation if reading from the terminal. */ |
c906108c SS |
1257 | if (!from_tty || query ("Delete all environment variables? ")) |
1258 | { | |
1259 | free_environ (inferior_environ); | |
1260 | inferior_environ = make_environ (); | |
1261 | } | |
1262 | } | |
1263 | else | |
1264 | unset_in_environ (inferior_environ, var); | |
1265 | } | |
1266 | ||
1267 | /* Handle the execution path (PATH variable) */ | |
1268 | ||
1269 | static const char path_var_name[] = "PATH"; | |
1270 | ||
1271 | /* ARGSUSED */ | |
1272 | static void | |
1273 | path_info (args, from_tty) | |
1274 | char *args; | |
1275 | int from_tty; | |
1276 | { | |
1277 | puts_filtered ("Executable and object file path: "); | |
1278 | puts_filtered (get_in_environ (inferior_environ, path_var_name)); | |
1279 | puts_filtered ("\n"); | |
1280 | } | |
1281 | ||
1282 | /* Add zero or more directories to the front of the execution path. */ | |
1283 | ||
1284 | static void | |
1285 | path_command (dirname, from_tty) | |
1286 | char *dirname; | |
1287 | int from_tty; | |
1288 | { | |
1289 | char *exec_path; | |
1290 | char *env; | |
1291 | dont_repeat (); | |
1292 | env = get_in_environ (inferior_environ, path_var_name); | |
1293 | /* Can be null if path is not set */ | |
1294 | if (!env) | |
1295 | env = ""; | |
1296 | exec_path = strsave (env); | |
1297 | mod_path (dirname, &exec_path); | |
1298 | set_in_environ (inferior_environ, path_var_name, exec_path); | |
1299 | free (exec_path); | |
1300 | if (from_tty) | |
c5aa993b | 1301 | path_info ((char *) NULL, from_tty); |
c906108c | 1302 | } |
c906108c | 1303 | \f |
c5aa993b | 1304 | |
c906108c SS |
1305 | #ifdef REGISTER_NAMES |
1306 | char *gdb_register_names[] = REGISTER_NAMES; | |
1307 | #endif | |
1308 | /* Print out the machine register regnum. If regnum is -1, | |
1309 | print all registers (fpregs == 1) or all non-float registers | |
1310 | (fpregs == 0). | |
1311 | ||
1312 | For most machines, having all_registers_info() print the | |
1313 | register(s) one per line is good enough. If a different format | |
1314 | is required, (eg, for MIPS or Pyramid 90x, which both have | |
1315 | lots of regs), or there is an existing convention for showing | |
1316 | all the registers, define the macro DO_REGISTERS_INFO(regnum, fp) | |
c5aa993b | 1317 | to provide that format. */ |
c906108c SS |
1318 | |
1319 | #if !defined (DO_REGISTERS_INFO) | |
1320 | ||
1321 | #define DO_REGISTERS_INFO(regnum, fp) do_registers_info(regnum, fp) | |
1322 | ||
1323 | static void | |
1324 | do_registers_info (regnum, fpregs) | |
1325 | int regnum; | |
1326 | int fpregs; | |
1327 | { | |
1328 | register int i; | |
1329 | int numregs = ARCH_NUM_REGS; | |
1330 | ||
1331 | for (i = 0; i < numregs; i++) | |
1332 | { | |
1333 | char raw_buffer[MAX_REGISTER_RAW_SIZE]; | |
1334 | char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE]; | |
1335 | ||
1336 | /* Decide between printing all regs, nonfloat regs, or specific reg. */ | |
c5aa993b JM |
1337 | if (regnum == -1) |
1338 | { | |
1339 | if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !fpregs) | |
1340 | continue; | |
1341 | } | |
1342 | else | |
1343 | { | |
1344 | if (i != regnum) | |
1345 | continue; | |
1346 | } | |
c906108c SS |
1347 | |
1348 | /* If the register name is empty, it is undefined for this | |
c5aa993b | 1349 | processor, so don't display anything. */ |
c906108c SS |
1350 | if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0') |
1351 | continue; | |
1352 | ||
1353 | fputs_filtered (REGISTER_NAME (i), gdb_stdout); | |
1354 | print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout); | |
1355 | ||
1356 | /* Get the data in raw format. */ | |
1357 | if (read_relative_register_raw_bytes (i, raw_buffer)) | |
1358 | { | |
1359 | printf_filtered ("*value not available*\n"); | |
1360 | continue; | |
1361 | } | |
1362 | ||
1363 | /* Convert raw data to virtual format if necessary. */ | |
c906108c SS |
1364 | if (REGISTER_CONVERTIBLE (i)) |
1365 | { | |
1366 | REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i), | |
1367 | raw_buffer, virtual_buffer); | |
1368 | } | |
1369 | else | |
392a587b JM |
1370 | { |
1371 | memcpy (virtual_buffer, raw_buffer, | |
1372 | REGISTER_VIRTUAL_SIZE (i)); | |
1373 | } | |
c906108c SS |
1374 | |
1375 | /* If virtual format is floating, print it that way, and in raw hex. */ | |
1376 | if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT) | |
1377 | { | |
1378 | register int j; | |
1379 | ||
1380 | #ifdef INVALID_FLOAT | |
1381 | if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i))) | |
1382 | printf_filtered ("<invalid float>"); | |
1383 | else | |
1384 | #endif | |
1385 | val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0, | |
1386 | gdb_stdout, 0, 1, 0, Val_pretty_default); | |
1387 | ||
1388 | printf_filtered ("\t(raw 0x"); | |
1389 | for (j = 0; j < REGISTER_RAW_SIZE (i); j++) | |
1390 | { | |
1391 | register int idx = TARGET_BYTE_ORDER == BIG_ENDIAN ? j | |
c5aa993b JM |
1392 | : REGISTER_RAW_SIZE (i) - 1 - j; |
1393 | printf_filtered ("%02x", (unsigned char) raw_buffer[idx]); | |
c906108c SS |
1394 | } |
1395 | printf_filtered (")"); | |
1396 | } | |
1397 | ||
1398 | /* FIXME! val_print probably can handle all of these cases now... */ | |
1399 | ||
1400 | /* Else if virtual format is too long for printf, | |
c5aa993b | 1401 | print in hex a byte at a time. */ |
c906108c SS |
1402 | else if (REGISTER_VIRTUAL_SIZE (i) > (int) sizeof (long)) |
1403 | { | |
1404 | register int j; | |
1405 | printf_filtered ("0x"); | |
1406 | for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++) | |
c5aa993b | 1407 | printf_filtered ("%02x", (unsigned char) virtual_buffer[j]); |
c906108c SS |
1408 | } |
1409 | /* Else print as integer in hex and in decimal. */ | |
1410 | else | |
1411 | { | |
1412 | val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0, | |
1413 | gdb_stdout, 'x', 1, 0, Val_pretty_default); | |
1414 | printf_filtered ("\t"); | |
1415 | val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0, | |
c5aa993b | 1416 | gdb_stdout, 0, 1, 0, Val_pretty_default); |
c906108c SS |
1417 | } |
1418 | ||
1419 | /* The SPARC wants to print even-numbered float regs as doubles | |
c5aa993b | 1420 | in addition to printing them as floats. */ |
c906108c SS |
1421 | #ifdef PRINT_REGISTER_HOOK |
1422 | PRINT_REGISTER_HOOK (i); | |
1423 | #endif | |
1424 | ||
1425 | printf_filtered ("\n"); | |
1426 | } | |
1427 | } | |
1428 | #endif /* no DO_REGISTERS_INFO. */ | |
1429 | ||
c906108c SS |
1430 | void |
1431 | registers_info (addr_exp, fpregs) | |
1432 | char *addr_exp; | |
1433 | int fpregs; | |
1434 | { | |
1435 | int regnum, numregs; | |
1436 | register char *end; | |
1437 | ||
1438 | if (!target_has_registers) | |
1439 | error ("The program has no registers now."); | |
1440 | if (selected_frame == NULL) | |
1441 | error ("No selected frame."); | |
1442 | ||
1443 | if (!addr_exp) | |
1444 | { | |
c5aa993b | 1445 | DO_REGISTERS_INFO (-1, fpregs); |
c906108c SS |
1446 | return; |
1447 | } | |
1448 | ||
1449 | do | |
c5aa993b | 1450 | { |
c906108c SS |
1451 | if (addr_exp[0] == '$') |
1452 | addr_exp++; | |
1453 | end = addr_exp; | |
1454 | while (*end != '\0' && *end != ' ' && *end != '\t') | |
1455 | ++end; | |
1456 | numregs = ARCH_NUM_REGS; | |
1457 | ||
1458 | regnum = target_map_name_to_register (addr_exp, end - addr_exp); | |
c5aa993b | 1459 | if (regnum >= 0) |
c906108c SS |
1460 | goto found; |
1461 | ||
1462 | regnum = numregs; | |
1463 | ||
1464 | if (*addr_exp >= '0' && *addr_exp <= '9') | |
c5aa993b JM |
1465 | regnum = atoi (addr_exp); /* Take a number */ |
1466 | if (regnum >= numregs) /* Bad name, or bad number */ | |
c906108c SS |
1467 | error ("%.*s: invalid register", end - addr_exp, addr_exp); |
1468 | ||
c5aa993b JM |
1469 | found: |
1470 | DO_REGISTERS_INFO (regnum, fpregs); | |
c906108c SS |
1471 | |
1472 | addr_exp = end; | |
1473 | while (*addr_exp == ' ' || *addr_exp == '\t') | |
1474 | ++addr_exp; | |
c5aa993b JM |
1475 | } |
1476 | while (*addr_exp != '\0'); | |
c906108c SS |
1477 | } |
1478 | ||
1479 | void | |
1480 | all_registers_info (addr_exp, from_tty) | |
1481 | char *addr_exp; | |
1482 | int from_tty; | |
1483 | { | |
1484 | registers_info (addr_exp, 1); | |
1485 | } | |
1486 | ||
1487 | void | |
1488 | nofp_registers_info (addr_exp, from_tty) | |
1489 | char *addr_exp; | |
1490 | int from_tty; | |
1491 | { | |
1492 | registers_info (addr_exp, 0); | |
1493 | } | |
c906108c | 1494 | \f |
c5aa993b | 1495 | |
c906108c SS |
1496 | /* |
1497 | * TODO: | |
1498 | * Should save/restore the tty state since it might be that the | |
1499 | * program to be debugged was started on this tty and it wants | |
1500 | * the tty in some state other than what we want. If it's running | |
1501 | * on another terminal or without a terminal, then saving and | |
1502 | * restoring the tty state is a harmless no-op. | |
1503 | * This only needs to be done if we are attaching to a process. | |
1504 | */ | |
1505 | ||
1506 | /* | |
1507 | attach_command -- | |
1508 | takes a program started up outside of gdb and ``attaches'' to it. | |
1509 | This stops it cold in its tracks and allows us to start debugging it. | |
1510 | and wait for the trace-trap that results from attaching. */ | |
1511 | ||
1512 | void | |
1513 | attach_command (args, from_tty) | |
1514 | char *args; | |
1515 | int from_tty; | |
1516 | { | |
1517 | #ifdef SOLIB_ADD | |
1518 | extern int auto_solib_add; | |
1519 | #endif | |
1520 | ||
c5aa993b JM |
1521 | char *exec_file; |
1522 | char *full_exec_path = NULL; | |
c906108c | 1523 | |
c5aa993b | 1524 | dont_repeat (); /* Not for the faint of heart */ |
c906108c SS |
1525 | |
1526 | if (target_has_execution) | |
1527 | { | |
1528 | if (query ("A program is being debugged already. Kill it? ")) | |
1529 | target_kill (); | |
1530 | else | |
1531 | error ("Not killed."); | |
1532 | } | |
1533 | ||
1534 | target_attach (args, from_tty); | |
1535 | ||
1536 | /* Set up the "saved terminal modes" of the inferior | |
1537 | based on what modes we are starting it with. */ | |
1538 | target_terminal_init (); | |
1539 | ||
1540 | /* Install inferior's terminal modes. */ | |
1541 | target_terminal_inferior (); | |
1542 | ||
1543 | /* Set up execution context to know that we should return from | |
1544 | wait_for_inferior as soon as the target reports a stop. */ | |
1545 | init_wait_for_inferior (); | |
1546 | clear_proceed_status (); | |
1547 | stop_soon_quietly = 1; | |
1548 | ||
1549 | /* No traps are generated when attaching to inferior under Mach 3 | |
1550 | or GNU hurd. */ | |
1551 | #ifndef ATTACH_NO_WAIT | |
1552 | wait_for_inferior (); | |
1553 | #endif | |
1554 | ||
1555 | /* | |
1556 | * If no exec file is yet known, try to determine it from the | |
1557 | * process itself. | |
1558 | */ | |
1559 | exec_file = (char *) get_exec_file (0); | |
c5aa993b JM |
1560 | if (!exec_file) |
1561 | { | |
1562 | exec_file = target_pid_to_exec_file (inferior_pid); | |
1563 | if (exec_file) | |
1564 | { | |
1565 | /* It's possible we don't have a full path, but rather just a | |
1566 | filename. Some targets, such as HP-UX, don't provide the | |
1567 | full path, sigh. | |
1568 | ||
1569 | Attempt to qualify the filename against the source path. | |
1570 | (If that fails, we'll just fall back on the original | |
1571 | filename. Not much more we can do...) | |
1572 | */ | |
1573 | if (!source_full_path_of (exec_file, &full_exec_path)) | |
1574 | full_exec_path = savestring (exec_file, strlen (exec_file)); | |
1575 | ||
1576 | exec_file_attach (full_exec_path, from_tty); | |
1577 | symbol_file_command (full_exec_path, from_tty); | |
1578 | } | |
c906108c | 1579 | } |
c906108c SS |
1580 | |
1581 | #ifdef SOLIB_ADD | |
1582 | if (auto_solib_add) | |
1583 | { | |
1584 | /* Add shared library symbols from the newly attached process, if any. */ | |
c5aa993b | 1585 | SOLIB_ADD ((char *) 0, from_tty, ¤t_target); |
c906108c SS |
1586 | re_enable_breakpoints_in_shlibs (); |
1587 | } | |
1588 | #endif | |
1589 | ||
1590 | /* Take any necessary post-attaching actions for this platform. | |
c5aa993b | 1591 | */ |
c906108c SS |
1592 | target_post_attach (inferior_pid); |
1593 | ||
1594 | normal_stop (); | |
6426a772 JM |
1595 | |
1596 | if (attach_hook) | |
1597 | attach_hook (); | |
c906108c SS |
1598 | } |
1599 | ||
1600 | /* | |
1601 | * detach_command -- | |
1602 | * takes a program previously attached to and detaches it. | |
1603 | * The program resumes execution and will no longer stop | |
1604 | * on signals, etc. We better not have left any breakpoints | |
1605 | * in the program or it'll die when it hits one. For this | |
1606 | * to work, it may be necessary for the process to have been | |
1607 | * previously attached. It *might* work if the program was | |
1608 | * started via the normal ptrace (PTRACE_TRACEME). | |
1609 | */ | |
1610 | ||
1611 | static void | |
1612 | detach_command (args, from_tty) | |
1613 | char *args; | |
1614 | int from_tty; | |
1615 | { | |
c5aa993b | 1616 | dont_repeat (); /* Not for the faint of heart */ |
c906108c SS |
1617 | target_detach (args, from_tty); |
1618 | #if defined(SOLIB_RESTART) | |
1619 | SOLIB_RESTART (); | |
1620 | #endif | |
6426a772 JM |
1621 | if (detach_hook) |
1622 | detach_hook (); | |
c906108c SS |
1623 | } |
1624 | ||
43ff13b4 JM |
1625 | /* Stop the execution of the target while running in async mode, in |
1626 | the backgound. */ | |
1627 | static void | |
1628 | interrupt_target_command (args, from_tty) | |
1629 | char *args; | |
1630 | int from_tty; | |
1631 | { | |
6426a772 | 1632 | if (event_loop_p && target_can_async_p ()) |
43ff13b4 | 1633 | { |
c5aa993b | 1634 | dont_repeat (); /* Not for the faint of heart */ |
43ff13b4 JM |
1635 | target_stop (); |
1636 | } | |
1637 | } | |
1638 | ||
c906108c SS |
1639 | /* ARGSUSED */ |
1640 | static void | |
1641 | float_info (addr_exp, from_tty) | |
1642 | char *addr_exp; | |
1643 | int from_tty; | |
1644 | { | |
1645 | #ifdef FLOAT_INFO | |
1646 | FLOAT_INFO; | |
1647 | #else | |
1648 | printf_filtered ("No floating point info available for this processor.\n"); | |
1649 | #endif | |
1650 | } | |
1651 | \f | |
1652 | /* ARGSUSED */ | |
1653 | static void | |
1654 | unset_command (args, from_tty) | |
1655 | char *args; | |
1656 | int from_tty; | |
1657 | { | |
1658 | printf_filtered ("\"unset\" must be followed by the name of "); | |
1659 | printf_filtered ("an unset subcommand.\n"); | |
1660 | help_list (unsetlist, "unset ", -1, gdb_stdout); | |
1661 | } | |
1662 | ||
1663 | void | |
1664 | _initialize_infcmd () | |
1665 | { | |
1666 | struct cmd_list_element *c; | |
c5aa993b | 1667 | |
c906108c SS |
1668 | add_com ("tty", class_run, tty_command, |
1669 | "Set terminal for future runs of program being debugged."); | |
1670 | ||
1671 | add_show_from_set | |
c5aa993b JM |
1672 | (add_set_cmd ("args", class_run, var_string_noescape, |
1673 | (char *) &inferior_args, | |
1674 | "Set argument list to give program being debugged when it is started.\n\ | |
c906108c SS |
1675 | Follow this command with any number of args, to be passed to the program.", |
1676 | &setlist), | |
1677 | &showlist); | |
1678 | ||
1679 | c = add_cmd | |
1680 | ("environment", no_class, environment_info, | |
1681 | "The environment to give the program, or one variable's value.\n\ | |
1682 | With an argument VAR, prints the value of environment variable VAR to\n\ | |
1683 | give the program being debugged. With no arguments, prints the entire\n\ | |
1684 | environment to be given to the program.", &showlist); | |
1685 | c->completer = noop_completer; | |
1686 | ||
1687 | add_prefix_cmd ("unset", no_class, unset_command, | |
1688 | "Complement to certain \"set\" commands", | |
1689 | &unsetlist, "unset ", 0, &cmdlist); | |
c5aa993b | 1690 | |
c906108c | 1691 | c = add_cmd ("environment", class_run, unset_environment_command, |
c5aa993b | 1692 | "Cancel environment variable VAR for the program.\n\ |
c906108c | 1693 | This does not affect the program until the next \"run\" command.", |
c5aa993b | 1694 | &unsetlist); |
c906108c SS |
1695 | c->completer = noop_completer; |
1696 | ||
1697 | c = add_cmd ("environment", class_run, set_environment_command, | |
1698 | "Set environment variable value to give the program.\n\ | |
1699 | Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\ | |
1700 | VALUES of environment variables are uninterpreted strings.\n\ | |
1701 | This does not affect the program until the next \"run\" command.", | |
c5aa993b | 1702 | &setlist); |
c906108c | 1703 | c->completer = noop_completer; |
c5aa993b | 1704 | |
c906108c | 1705 | add_com ("path", class_files, path_command, |
c5aa993b | 1706 | "Add directory DIR(s) to beginning of search path for object files.\n\ |
c906108c SS |
1707 | $cwd in the path means the current working directory.\n\ |
1708 | This path is equivalent to the $PATH shell variable. It is a list of\n\ | |
1709 | directories, separated by colons. These directories are searched to find\n\ | |
1710 | fully linked executable files and separately compiled object files as needed."); | |
1711 | ||
1712 | c = add_cmd ("paths", no_class, path_info, | |
c5aa993b | 1713 | "Current search path for finding object files.\n\ |
c906108c SS |
1714 | $cwd in the path means the current working directory.\n\ |
1715 | This path is equivalent to the $PATH shell variable. It is a list of\n\ | |
1716 | directories, separated by colons. These directories are searched to find\n\ | |
1717 | fully linked executable files and separately compiled object files as needed.", | |
1718 | &showlist); | |
1719 | c->completer = noop_completer; | |
1720 | ||
c5aa993b JM |
1721 | add_com ("attach", class_run, attach_command, |
1722 | "Attach to a process or file outside of GDB.\n\ | |
c906108c SS |
1723 | This command attaches to another target, of the same type as your last\n\ |
1724 | \"target\" command (\"info files\" will show your target stack).\n\ | |
1725 | The command may take as argument a process id or a device file.\n\ | |
1726 | For a process id, you must have permission to send the process a signal,\n\ | |
1727 | and it must have the same effective uid as the debugger.\n\ | |
1728 | When using \"attach\" with a process id, the debugger finds the\n\ | |
1729 | program running in the process, looking first in the current working\n\ | |
1730 | directory, or (if not found there) using the source file search path\n\ | |
1731 | (see the \"directory\" command). You can also use the \"file\" command\n\ | |
1732 | to specify the program, and to load its symbol table."); | |
1733 | ||
1734 | add_com ("detach", class_run, detach_command, | |
1735 | "Detach a process or file previously attached.\n\ | |
1736 | If a process, it is no longer traced, and it continues its execution. If\n\ | |
1737 | you were debugging a file, the file is closed and gdb no longer accesses it."); | |
1738 | ||
1739 | add_com ("signal", class_run, signal_command, | |
1740 | "Continue program giving it signal specified by the argument.\n\ | |
1741 | An argument of \"0\" means continue program without giving it a signal."); | |
1742 | ||
1743 | add_com ("stepi", class_run, stepi_command, | |
1744 | "Step one instruction exactly.\n\ | |
1745 | Argument N means do this N times (or till program stops for another reason)."); | |
1746 | add_com_alias ("si", "stepi", class_alias, 0); | |
1747 | ||
1748 | add_com ("nexti", class_run, nexti_command, | |
1749 | "Step one instruction, but proceed through subroutine calls.\n\ | |
1750 | Argument N means do this N times (or till program stops for another reason)."); | |
1751 | add_com_alias ("ni", "nexti", class_alias, 0); | |
1752 | ||
1753 | add_com ("finish", class_run, finish_command, | |
1754 | "Execute until selected stack frame returns.\n\ | |
1755 | Upon return, the value returned is printed and put in the value history."); | |
1756 | ||
1757 | add_com ("next", class_run, next_command, | |
1758 | "Step program, proceeding through subroutine calls.\n\ | |
1759 | Like the \"step\" command as long as subroutine calls do not happen;\n\ | |
1760 | when they do, the call is treated as one instruction.\n\ | |
1761 | Argument N means do this N times (or till program stops for another reason)."); | |
1762 | add_com_alias ("n", "next", class_run, 1); | |
1763 | if (xdb_commands) | |
c5aa993b | 1764 | add_com_alias ("S", "next", class_run, 1); |
c906108c SS |
1765 | |
1766 | add_com ("step", class_run, step_command, | |
1767 | "Step program until it reaches a different source line.\n\ | |
1768 | Argument N means do this N times (or till program stops for another reason)."); | |
1769 | add_com_alias ("s", "step", class_run, 1); | |
1770 | ||
1771 | add_com ("until", class_run, until_command, | |
c5aa993b | 1772 | "Execute until the program reaches a source line greater than the current\n\ |
c906108c SS |
1773 | or a specified line or address or function (same args as break command).\n\ |
1774 | Execution will also stop upon exit from the current stack frame."); | |
1775 | add_com_alias ("u", "until", class_run, 1); | |
c5aa993b | 1776 | |
c906108c SS |
1777 | add_com ("jump", class_run, jump_command, |
1778 | "Continue program being debugged at specified line or address.\n\ | |
1779 | Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\ | |
1780 | for an address to start at."); | |
1781 | ||
b83266a0 SS |
1782 | if (xdb_commands) |
1783 | add_com ("go", class_run, go_command, | |
1784 | "Usage: go <location>\n\ | |
c906108c SS |
1785 | Continue program being debugged, stopping at specified line or \n\ |
1786 | address.\n\ | |
1787 | Give as argument either LINENUM or *ADDR, where ADDR is an \n\ | |
1788 | expression for an address to start at.\n\ | |
1789 | This command is a combination of tbreak and jump."); | |
b83266a0 | 1790 | |
c906108c | 1791 | if (xdb_commands) |
c5aa993b | 1792 | add_com_alias ("g", "go", class_run, 1); |
c906108c SS |
1793 | |
1794 | add_com ("continue", class_run, continue_command, | |
1795 | "Continue program being debugged, after signal or breakpoint.\n\ | |
1796 | If proceeding from breakpoint, a number N may be used as an argument,\n\ | |
1797 | which means to set the ignore count of that breakpoint to N - 1 (so that\n\ | |
1798 | the breakpoint won't break until the Nth time it is reached)."); | |
1799 | add_com_alias ("c", "cont", class_run, 1); | |
1800 | add_com_alias ("fg", "cont", class_run, 1); | |
1801 | ||
1802 | add_com ("run", class_run, run_command, | |
1803 | "Start debugged program. You may specify arguments to give it.\n\ | |
1804 | Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\ | |
1805 | Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\ | |
1806 | With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\ | |
1807 | To cancel previous arguments and run with no arguments,\n\ | |
1808 | use \"set args\" without arguments."); | |
1809 | add_com_alias ("r", "run", class_run, 1); | |
1810 | if (xdb_commands) | |
1811 | add_com ("R", class_run, run_no_args_command, | |
c5aa993b | 1812 | "Start debugged program with no arguments."); |
c906108c | 1813 | |
43ff13b4 JM |
1814 | add_com ("interrupt", class_run, interrupt_target_command, |
1815 | "Interrupt the execution of the debugged program."); | |
1816 | ||
c906108c | 1817 | add_info ("registers", nofp_registers_info, |
c5aa993b | 1818 | "List of integer registers and their contents, for selected stack frame.\n\ |
c906108c SS |
1819 | Register name as argument means describe only that register."); |
1820 | ||
1821 | if (xdb_commands) | |
c5aa993b JM |
1822 | add_com ("lr", class_info, nofp_registers_info, |
1823 | "List of integer registers and their contents, for selected stack frame.\n\ | |
c906108c SS |
1824 | Register name as argument means describe only that register."); |
1825 | add_info ("all-registers", all_registers_info, | |
c5aa993b | 1826 | "List of all registers and their contents, for selected stack frame.\n\ |
c906108c SS |
1827 | Register name as argument means describe only that register."); |
1828 | ||
1829 | add_info ("program", program_info, | |
1830 | "Execution status of the program."); | |
1831 | ||
1832 | add_info ("float", float_info, | |
1833 | "Print the status of the floating point unit\n"); | |
1834 | ||
1835 | inferior_args = savestring ("", 1); /* Initially no args */ | |
1836 | inferior_environ = make_environ (); | |
1837 | init_environ (inferior_environ); | |
1838 | } |