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