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