1 /* Memory-access and commands for "inferior" process, for GDB.
2 Copyright 1986, 87, 88, 89, 91, 92, 95, 96, 1998, 1999
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
24 #include "gdb_string.h"
41 #include "event-top.h"
42 #include "parser-defs.h"
44 /* Functions exported for general use: */
46 void nofp_registers_info (char *, int);
48 void all_registers_info (char *, int);
50 void registers_info (char *, int);
52 /* Local functions: */
54 void continue_command (char *, int);
56 static void print_return_value (int struct_return, struct type *value_type);
58 static void finish_command_continuation (struct continuation_arg *);
60 static void until_next_command (int);
62 static void until_command (char *, int);
64 static void path_info (char *, int);
66 static void path_command (char *, int);
68 static void unset_command (char *, int);
70 static void float_info (char *, int);
72 static void detach_command (char *, int);
74 static void interrupt_target_command (char *args, int from_tty);
76 static void unset_environment_command (char *, int);
78 static void set_environment_command (char *, int);
80 static void environment_info (char *, int);
82 static void program_info (char *, int);
84 static void finish_command (char *, int);
86 static void signal_command (char *, int);
88 static void jump_command (char *, int);
90 static void step_1 (int, int, char *);
91 static void step_once (int skip_subroutines, int single_inst, int count);
92 static void step_1_continuation (struct continuation_arg *arg);
94 void nexti_command (char *, int);
96 void stepi_command (char *, int);
98 static void next_command (char *, int);
100 static void step_command (char *, int);
102 static void run_command (char *, int);
104 static void run_no_args_command (char *args, int from_tty);
106 static void go_command (char *line_no, int from_tty);
108 static int strip_bg_char (char **);
110 void _initialize_infcmd (void);
112 #define GO_USAGE "Usage: go <location>\n"
114 static void breakpoint_auto_delete_contents (PTR);
116 #define ERROR_NO_INFERIOR \
117 if (!target_has_execution) error ("The program is not being run.");
119 /* String containing arguments to give to the program, separated by spaces.
120 Empty string (pointer to '\0') means no args. */
122 static char *inferior_args;
124 /* File name for default use for standard in/out in the inferior. */
126 char *inferior_io_terminal;
128 /* Pid of our debugged inferior, or 0 if no inferior now.
129 Since various parts of infrun.c test this to see whether there is a program
130 being debugged it should be nonzero (currently 3 is used) for remote
135 /* Last signal that the inferior received (why it stopped). */
137 enum target_signal stop_signal;
139 /* Address at which inferior stopped. */
143 /* Chain containing status of breakpoint(s) that we have stopped at. */
147 /* Flag indicating that a command has proceeded the inferior past the
148 current breakpoint. */
150 int breakpoint_proceeded;
152 /* Nonzero if stopped due to a step command. */
156 /* Nonzero if stopped due to completion of a stack dummy routine. */
158 int stop_stack_dummy;
160 /* Nonzero if stopped due to a random (unexpected) signal in inferior
163 int stopped_by_random_signal;
165 /* Range to single step within.
166 If this is nonzero, respond to a single-step signal
167 by continuing to step if the pc is in this range. */
169 CORE_ADDR step_range_start; /* Inclusive */
170 CORE_ADDR step_range_end; /* Exclusive */
172 /* Stack frame address as of when stepping command was issued.
173 This is how we know when we step into a subroutine call,
174 and how to set the frame for the breakpoint used to step out. */
176 CORE_ADDR step_frame_address;
178 /* Our notion of the current stack pointer. */
182 enum step_over_calls_kind step_over_calls;
184 /* If stepping, nonzero means step count is > 1
185 so don't print frame next time inferior stops
186 if it stops due to stepping. */
190 /* Environment to use for running inferior,
191 in format described in environ.h. */
193 struct environ *inferior_environ;
195 /* Accessor routines. */
198 get_inferior_args (void)
200 return inferior_args;
204 set_inferior_args (char *newargs)
206 char *saved_args = inferior_args;
208 inferior_args = newargs;
213 /* This function detects whether or not a '&' character (indicating
214 background execution) has been added as *the last* of the arguments ARGS
215 of a command. If it has, it removes it and returns 1. Otherwise it
216 does nothing and returns 0. */
218 strip_bg_char (char **args)
222 p = strchr (*args, '&');
226 if (p == (*args + strlen (*args) - 1))
228 if (strlen (*args) > 1)
232 while (*p == ' ' || *p == '\t');
245 tty_command (char *file, int from_tty)
248 error_no_arg ("terminal name for running target process");
250 inferior_io_terminal = savestring (file, strlen (file));
254 run_command (char *args, int from_tty)
260 if (inferior_pid != 0 && target_has_execution)
263 && !query ("The program being debugged has been started already.\n\
264 Start it from the beginning? "))
265 error ("Program not restarted.");
267 #if defined(SOLIB_RESTART)
270 init_wait_for_inferior ();
273 clear_breakpoint_hit_counts ();
275 exec_file = (char *) get_exec_file (0);
277 /* Purge old solib objfiles. */
278 objfile_purge_solibs ();
280 do_run_cleanups (NULL);
282 /* The exec file is re-read every time we do a generic_mourn_inferior, so
283 we just have to worry about the symbol file. */
286 /* We keep symbols from add-symbol-file, on the grounds that the
287 user might want to add some symbols before running the program
288 (right?). But sometimes (dynamic loading where the user manually
289 introduces the new symbols with add-symbol-file), the code which
290 the symbols describe does not persist between runs. Currently
291 the user has to manually nuke all symbols between runs if they
292 want them to go away (PR 2207). This is probably reasonable. */
296 if (event_loop_p && target_can_async_p ())
297 async_disable_stdin ();
301 int async_exec = strip_bg_char (&args);
303 /* If we get a request for running in the bg but the target
304 doesn't support it, error out. */
305 if (event_loop_p && async_exec && !target_can_async_p ())
306 error ("Asynchronous execution not supported on this target.");
308 /* If we don't get a request of running in the bg, then we need
309 to simulate synchronous (fg) execution. */
310 if (event_loop_p && !async_exec && target_can_async_p ())
312 /* Simulate synchronous execution */
313 async_disable_stdin ();
316 /* If there were other args, beside '&', process them. */
319 char *old_args = set_inferior_args (xstrdup (args));
327 ui_out_field_string (uiout, NULL, "Starting program");
328 ui_out_text (uiout, ": ");
330 ui_out_field_string (uiout, "execfile", exec_file);
331 ui_out_spaces (uiout, 1);
332 ui_out_field_string (uiout, "infargs", inferior_args);
333 ui_out_text (uiout, "\n");
334 ui_out_flush (uiout);
336 puts_filtered ("Starting program: ");
338 puts_filtered (exec_file);
340 puts_filtered (inferior_args);
341 puts_filtered ("\n");
342 gdb_flush (gdb_stdout);
346 target_create_inferior (exec_file, inferior_args,
347 environ_vector (inferior_environ));
352 run_no_args_command (char *args, int from_tty)
354 char *old_args = set_inferior_args (xstrdup (""));
360 continue_command (char *proc_count_exp, int from_tty)
365 /* Find out whether we must run in the background. */
366 if (proc_count_exp != NULL)
367 async_exec = strip_bg_char (&proc_count_exp);
369 /* If we must run in the background, but the target can't do it,
371 if (event_loop_p && async_exec && !target_can_async_p ())
372 error ("Asynchronous execution not supported on this target.");
374 /* If we are not asked to run in the bg, then prepare to run in the
375 foreground, synchronously. */
376 if (event_loop_p && !async_exec && target_can_async_p ())
378 /* Simulate synchronous execution */
379 async_disable_stdin ();
382 /* If have argument (besides '&'), set proceed count of breakpoint
384 if (proc_count_exp != NULL)
386 bpstat bs = stop_bpstat;
387 int num = bpstat_num (&bs);
388 if (num == 0 && from_tty)
391 ("Not stopped at any breakpoint; argument ignored.\n");
395 set_ignore_count (num,
396 parse_and_eval_long (proc_count_exp) - 1,
398 /* set_ignore_count prints a message ending with a period.
399 So print two spaces before "Continuing.". */
401 printf_filtered (" ");
402 num = bpstat_num (&bs);
407 printf_filtered ("Continuing.\n");
409 clear_proceed_status ();
411 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
414 /* Step until outside of current statement. */
418 step_command (char *count_string, int from_tty)
420 step_1 (0, 0, count_string);
423 /* Likewise, but skip over subroutine calls as if single instructions. */
427 next_command (char *count_string, int from_tty)
429 step_1 (1, 0, count_string);
432 /* Likewise, but step only one instruction. */
436 stepi_command (char *count_string, int from_tty)
438 step_1 (0, 1, count_string);
443 nexti_command (char *count_string, int from_tty)
445 step_1 (1, 1, count_string);
449 disable_longjmp_breakpoint_cleanup (void *ignore)
451 disable_longjmp_breakpoint ();
455 step_1 (int skip_subroutines, int single_inst, char *count_string)
457 register int count = 1;
458 struct frame_info *frame;
459 struct cleanup *cleanups = 0;
465 async_exec = strip_bg_char (&count_string);
467 /* If we get a request for running in the bg but the target
468 doesn't support it, error out. */
469 if (event_loop_p && async_exec && !target_can_async_p ())
470 error ("Asynchronous execution not supported on this target.");
472 /* If we don't get a request of running in the bg, then we need
473 to simulate synchronous (fg) execution. */
474 if (event_loop_p && !async_exec && target_can_async_p ())
476 /* Simulate synchronous execution */
477 async_disable_stdin ();
480 count = count_string ? parse_and_eval_long (count_string) : 1;
482 if (!single_inst || skip_subroutines) /* leave si command alone */
484 enable_longjmp_breakpoint ();
485 if (!event_loop_p || !target_can_async_p ())
486 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
488 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
491 /* In synchronous case, all is well, just use the regular for loop. */
492 if (!event_loop_p || !target_can_async_p ())
494 for (; count > 0; count--)
496 clear_proceed_status ();
498 frame = get_current_frame ();
499 if (!frame) /* Avoid coredump here. Why tho? */
500 error ("No current frame");
501 step_frame_address = FRAME_FP (frame);
502 step_sp = read_sp ();
506 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
507 if (step_range_end == 0)
510 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
511 &step_range_end) == 0)
512 error ("Cannot find bounds of current function");
514 target_terminal_ours ();
516 Single stepping until exit from function %s, \n\
517 which has no line number information.\n", name);
522 /* Say we are stepping, but stop after one insn whatever it does. */
523 step_range_start = step_range_end = 1;
524 if (!skip_subroutines)
526 Don't step over function calls, not even to functions lacking
528 step_over_calls = STEP_OVER_NONE;
531 if (skip_subroutines)
532 step_over_calls = STEP_OVER_ALL;
534 step_multi = (count > 1);
535 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
540 /* FIXME: On nexti, this may have already been done (when we hit the
541 step resume break, I think). Probably this should be moved to
542 wait_for_inferior (near the top). */
543 #if defined (SHIFT_INST_REGS)
548 if (!single_inst || skip_subroutines)
549 do_cleanups (cleanups);
552 /* In case of asynchronous target things get complicated, do only
553 one step for now, before returning control to the event loop. Let
554 the continuation figure out how many other steps we need to do,
555 and handle them one at the time, through step_once(). */
558 if (event_loop_p && target_can_async_p ())
559 step_once (skip_subroutines, single_inst, count);
563 /* Called after we are done with one step operation, to check whether
564 we need to step again, before we print the prompt and return control
565 to the user. If count is > 1, we will need to do one more call to
566 proceed(), via step_once(). Basically it is like step_once and
567 step_1_continuation are co-recursive. */
569 step_1_continuation (struct continuation_arg *arg)
572 int skip_subroutines;
575 skip_subroutines = arg->data.integer;
576 single_inst = arg->next->data.integer;
577 count = arg->next->next->data.integer;
581 /* FIXME: On nexti, this may have already been done (when we hit the
582 step resume break, I think). Probably this should be moved to
583 wait_for_inferior (near the top). */
584 #if defined (SHIFT_INST_REGS)
587 step_once (skip_subroutines, single_inst, count - 1);
590 if (!single_inst || skip_subroutines)
591 do_exec_cleanups (ALL_CLEANUPS);
594 /* Do just one step operation. If count >1 we will have to set up a
595 continuation to be done after the target stops (after this one
596 step). This is useful to implement the 'step n' kind of commands, in
597 case of asynchronous targets. We had to split step_1 into two parts,
598 one to be done before proceed() and one afterwards. This function is
599 called in case of step n with n>1, after the first step operation has
602 step_once (int skip_subroutines, int single_inst, int count)
604 struct continuation_arg *arg1;
605 struct continuation_arg *arg2;
606 struct continuation_arg *arg3;
607 struct frame_info *frame;
611 clear_proceed_status ();
613 frame = get_current_frame ();
614 if (!frame) /* Avoid coredump here. Why tho? */
615 error ("No current frame");
616 step_frame_address = FRAME_FP (frame);
617 step_sp = read_sp ();
621 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
623 /* If we have no line info, switch to stepi mode. */
624 if (step_range_end == 0 && step_stop_if_no_debug)
626 step_range_start = step_range_end = 1;
628 else if (step_range_end == 0)
631 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
632 &step_range_end) == 0)
633 error ("Cannot find bounds of current function");
635 target_terminal_ours ();
637 Single stepping until exit from function %s, \n\
638 which has no line number information.\n", name);
643 /* Say we are stepping, but stop after one insn whatever it does. */
644 step_range_start = step_range_end = 1;
645 if (!skip_subroutines)
647 Don't step over function calls, not even to functions lacking
649 step_over_calls = STEP_OVER_NONE;
652 if (skip_subroutines)
653 step_over_calls = STEP_OVER_ALL;
655 step_multi = (count > 1);
657 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
659 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
661 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
663 arg1->data.integer = skip_subroutines;
665 arg2->data.integer = single_inst;
667 arg3->data.integer = count;
668 add_intermediate_continuation (step_1_continuation, arg1);
669 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
674 /* Continue program at specified address. */
677 jump_command (char *arg, int from_tty)
679 register CORE_ADDR addr;
680 struct symtabs_and_lines sals;
681 struct symtab_and_line sal;
688 /* Find out whether we must run in the background. */
690 async_exec = strip_bg_char (&arg);
692 /* If we must run in the background, but the target can't do it,
694 if (event_loop_p && async_exec && !target_can_async_p ())
695 error ("Asynchronous execution not supported on this target.");
697 /* If we are not asked to run in the bg, then prepare to run in the
698 foreground, synchronously. */
699 if (event_loop_p && !async_exec && target_can_async_p ())
701 /* Simulate synchronous execution */
702 async_disable_stdin ();
706 error_no_arg ("starting address");
708 sals = decode_line_spec_1 (arg, 1);
711 error ("Unreasonable jump request");
717 if (sal.symtab == 0 && sal.pc == 0)
718 error ("No source file has been specified.");
720 resolve_sal_pc (&sal); /* May error out */
722 /* See if we are trying to jump to another function. */
723 fn = get_frame_function (get_current_frame ());
724 sfn = find_pc_function (sal.pc);
725 if (fn != NULL && sfn != fn)
727 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
728 SYMBOL_SOURCE_NAME (fn)))
730 error ("Not confirmed.");
737 fixup_symbol_section (sfn, 0);
738 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
739 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
741 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
743 error ("Not confirmed.");
753 printf_filtered ("Continuing at ");
754 print_address_numeric (addr, 1, gdb_stdout);
755 printf_filtered (".\n");
758 clear_proceed_status ();
759 proceed (addr, TARGET_SIGNAL_0, 0);
763 /* Go to line or address in current procedure */
765 go_command (char *line_no, int from_tty)
767 if (line_no == (char *) NULL || !*line_no)
768 printf_filtered (GO_USAGE);
771 tbreak_command (line_no, from_tty);
772 jump_command (line_no, from_tty);
777 /* Continue program giving it specified signal. */
780 signal_command (char *signum_exp, int from_tty)
782 enum target_signal oursig;
784 dont_repeat (); /* Too dangerous. */
788 error_no_arg ("signal number");
790 /* It would be even slicker to make signal names be valid expressions,
791 (the type could be "enum $signal" or some such), then the user could
792 assign them to convenience variables. */
793 oursig = target_signal_from_name (signum_exp);
795 if (oursig == TARGET_SIGNAL_UNKNOWN)
797 /* No, try numeric. */
798 int num = parse_and_eval_long (signum_exp);
801 oursig = TARGET_SIGNAL_0;
803 oursig = target_signal_from_command (num);
808 if (oursig == TARGET_SIGNAL_0)
809 printf_filtered ("Continuing with no signal.\n");
811 printf_filtered ("Continuing with signal %s.\n",
812 target_signal_to_name (oursig));
815 clear_proceed_status ();
816 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
817 FIXME: Neither should "signal foo" but when I tried passing
818 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
819 tried to track down yet. */
820 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
823 /* Call breakpoint_auto_delete on the current contents of the bpstat
824 pointed to by arg (which is really a bpstat *). */
827 breakpoint_auto_delete_contents (PTR arg)
829 breakpoint_auto_delete (*(bpstat *) arg);
833 /* Execute a "stack dummy", a piece of code stored in the stack
834 by the debugger to be executed in the inferior.
836 To call: first, do PUSH_DUMMY_FRAME.
837 Then push the contents of the dummy. It should end with a breakpoint insn.
838 Then call here, passing address at which to start the dummy.
840 The contents of all registers are saved before the dummy frame is popped
841 and copied into the buffer BUFFER.
843 The dummy's frame is automatically popped whenever that break is hit.
844 If that is the first time the program stops, run_stack_dummy
845 returns to its caller with that frame already gone and returns 0.
847 Otherwise, run_stack-dummy returns a non-zero value.
848 If the called function receives a random signal, we do not allow the user
849 to continue executing it as this may not work. The dummy frame is poped
851 If we hit a breakpoint, we leave the frame in place and return 2 (the frame
852 will eventually be popped when we do hit the dummy end breakpoint). */
855 run_stack_dummy (CORE_ADDR addr, char *buffer)
857 struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
860 /* Now proceed, having reached the desired place. */
861 clear_proceed_status ();
863 if (CALL_DUMMY_BREAKPOINT_OFFSET_P)
865 struct breakpoint *bpt;
866 struct symtab_and_line sal;
868 INIT_SAL (&sal); /* initialize to zeroes */
869 if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT)
871 sal.pc = CALL_DUMMY_ADDRESS ();
875 sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET;
877 sal.section = find_pc_overlay (sal.pc);
879 /* Set up a FRAME for the dummy frame so we can pass it to
880 set_momentary_breakpoint. We need to give the breakpoint a
881 frame in case there is only one copy of the dummy (e.g.
882 CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
883 flush_cached_frames ();
884 set_current_frame (create_new_frame (read_fp (), sal.pc));
886 /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
887 a breakpoint instruction. If not, the call dummy already has the
888 breakpoint instruction in it.
890 addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
891 so we need to subtract the CALL_DUMMY_START_OFFSET. */
892 bpt = set_momentary_breakpoint (sal,
893 get_current_frame (),
895 bpt->disposition = del;
897 /* If all error()s out of proceed ended up calling normal_stop (and
898 perhaps they should; it already does in the special case of error
899 out of resume()), then we wouldn't need this. */
900 make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
903 disable_watchpoints_before_interactive_call_start ();
904 proceed_to_finish = 1; /* We want stop_registers, please... */
906 if (target_can_async_p ())
907 saved_async = target_async_mask (0);
909 proceed (addr, TARGET_SIGNAL_0, 0);
912 target_async_mask (saved_async);
914 enable_watchpoints_after_interactive_call_stop ();
916 discard_cleanups (old_cleanups);
918 /* We can stop during an inferior call because a signal is received. */
919 if (stopped_by_random_signal)
922 /* We may also stop prematurely because we hit a breakpoint in the
924 if (!stop_stack_dummy)
927 /* On normal return, the stack dummy has been popped already. */
929 memcpy (buffer, stop_registers, REGISTER_BYTES);
933 /* Proceed until we reach a different source line with pc greater than
934 our current one or exit the function. We skip calls in both cases.
936 Note that eventually this command should probably be changed so
937 that only source lines are printed out when we hit the breakpoint
938 we set. This may involve changes to wait_for_inferior and the
939 proceed status code. */
943 until_next_command (int from_tty)
945 struct frame_info *frame;
948 struct symtab_and_line sal;
950 clear_proceed_status ();
952 frame = get_current_frame ();
954 /* Step until either exited from this function or greater
955 than the current line (if in symbolic section) or pc (if
959 func = find_pc_function (pc);
963 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
966 error ("Execution is not within a known function.");
968 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
973 sal = find_pc_line (pc, 0);
975 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
976 step_range_end = sal.end;
979 step_over_calls = STEP_OVER_ALL;
980 step_frame_address = FRAME_FP (frame);
981 step_sp = read_sp ();
983 step_multi = 0; /* Only one call to proceed */
985 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
989 until_command (char *arg, int from_tty)
993 if (!target_has_execution)
994 error ("The program is not running.");
996 /* Find out whether we must run in the background. */
998 async_exec = strip_bg_char (&arg);
1000 /* If we must run in the background, but the target can't do it,
1002 if (event_loop_p && async_exec && !target_can_async_p ())
1003 error ("Asynchronous execution not supported on this target.");
1005 /* If we are not asked to run in the bg, then prepare to run in the
1006 foreground, synchronously. */
1007 if (event_loop_p && !async_exec && target_can_async_p ())
1009 /* Simulate synchronous execution */
1010 async_disable_stdin ();
1014 until_break_command (arg, from_tty);
1016 until_next_command (from_tty);
1020 /* Print the result of a function at the end of a 'finish' command. */
1022 print_return_value (int structure_return, struct type *value_type)
1024 register value_ptr value;
1026 static struct ui_stream *stb = NULL;
1029 if (!structure_return)
1031 value = value_being_returned (value_type, stop_registers, structure_return);
1033 stb = ui_out_stream_new (uiout);
1034 ui_out_text (uiout, "Value returned is ");
1035 ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
1036 ui_out_text (uiout, " = ");
1037 value_print (value, stb->stream, 0, Val_no_prettyprint);
1038 ui_out_field_stream (uiout, "return-value", stb);
1039 ui_out_text (uiout, "\n");
1041 printf_filtered ("Value returned is $%d = ", record_latest_value (value));
1042 value_print (value, gdb_stdout, 0, Val_no_prettyprint);
1043 printf_filtered ("\n");
1048 /* We cannot determine the contents of the structure because
1049 it is on the stack, and we don't know where, since we did not
1050 initiate the call, as opposed to the call_function_by_hand case */
1051 #ifdef VALUE_RETURNED_FROM_STACK
1054 ui_out_text (uiout, "Value returned has type: ");
1055 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1056 ui_out_text (uiout, ".");
1057 ui_out_text (uiout, " Cannot determine contents\n");
1059 printf_filtered ("Value returned has type: %s.", TYPE_NAME (value_type));
1060 printf_filtered (" Cannot determine contents\n");
1063 value = value_being_returned (value_type, stop_registers, structure_return);
1065 stb = ui_out_stream_new (uiout);
1066 ui_out_text (uiout, "Value returned is ");
1067 ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
1068 ui_out_text (uiout, " = ");
1069 value_print (value, stb->stream, 0, Val_no_prettyprint);
1070 ui_out_field_stream (uiout, "return-value", stb);
1071 ui_out_text (uiout, "\n");
1073 printf_filtered ("Value returned is $%d = ", record_latest_value (value));
1074 value_print (value, gdb_stdout, 0, Val_no_prettyprint);
1075 printf_filtered ("\n");
1081 /* Stuff that needs to be done by the finish command after the target
1082 has stopped. In asynchronous mode, we wait for the target to stop in
1083 the call to poll or select in the event loop, so it is impossible to
1084 do all the stuff as part of the finish_command function itself. The
1085 only chance we have to complete this command is in
1086 fetch_inferior_event, which is called by the event loop as soon as it
1087 detects that the target has stopped. This function is called via the
1088 cmd_continuation pointer. */
1090 finish_command_continuation (struct continuation_arg *arg)
1092 register struct symbol *function;
1093 struct breakpoint *breakpoint;
1094 struct cleanup *cleanups;
1096 breakpoint = (struct breakpoint *) arg->data.pointer;
1097 function = (struct symbol *) arg->next->data.pointer;
1098 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1100 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1103 struct type *value_type;
1107 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1109 internal_error ("finish_command: function has no target type");
1111 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1113 do_exec_cleanups (cleanups);
1117 funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
1119 struct_return = using_struct_return (value_of_variable (function, NULL),
1121 check_typedef (value_type),
1122 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
1124 print_return_value (struct_return, value_type);
1126 do_exec_cleanups (cleanups);
1129 /* "finish": Set a temporary breakpoint at the place
1130 the selected frame will return to, then continue. */
1133 finish_command (char *arg, int from_tty)
1135 struct symtab_and_line sal;
1136 register struct frame_info *frame;
1137 register struct symbol *function;
1138 struct breakpoint *breakpoint;
1139 struct cleanup *old_chain;
1140 struct continuation_arg *arg1, *arg2, *arg3;
1144 /* Find out whether we must run in the background. */
1146 async_exec = strip_bg_char (&arg);
1148 /* If we must run in the background, but the target can't do it,
1150 if (event_loop_p && async_exec && !target_can_async_p ())
1151 error ("Asynchronous execution not supported on this target.");
1153 /* If we are not asked to run in the bg, then prepare to run in the
1154 foreground, synchronously. */
1155 if (event_loop_p && !async_exec && target_can_async_p ())
1157 /* Simulate synchronous execution */
1158 async_disable_stdin ();
1162 error ("The \"finish\" command does not take any arguments.");
1163 if (!target_has_execution)
1164 error ("The program is not running.");
1165 if (selected_frame == NULL)
1166 error ("No selected frame.");
1168 frame = get_prev_frame (selected_frame);
1170 error ("\"finish\" not meaningful in the outermost frame.");
1172 clear_proceed_status ();
1174 sal = find_pc_line (frame->pc, 0);
1177 breakpoint = set_momentary_breakpoint (sal, frame, bp_finish);
1179 if (!event_loop_p || !target_can_async_p ())
1180 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1182 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1184 /* Find the function we will return from. */
1186 function = find_pc_function (selected_frame->pc);
1188 /* Print info on the selected frame, including level number
1192 printf_filtered ("Run till exit from ");
1193 print_stack_frame (selected_frame, selected_frame_level, 0);
1196 /* If running asynchronously and the target support asynchronous
1197 execution, set things up for the rest of the finish command to be
1198 completed later on, when gdb has detected that the target has
1199 stopped, in fetch_inferior_event. */
1200 if (event_loop_p && target_can_async_p ())
1203 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1205 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1207 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1211 arg1->data.pointer = breakpoint;
1212 arg2->data.pointer = function;
1213 arg3->data.pointer = old_chain;
1214 add_continuation (finish_command_continuation, arg1);
1217 proceed_to_finish = 1; /* We want stop_registers, please... */
1218 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1220 /* Do this only if not running asynchronously or if the target
1221 cannot do async execution. Otherwise, complete this command when
1222 the target actually stops, in fetch_inferior_event. */
1223 if (!event_loop_p || !target_can_async_p ())
1226 /* Did we stop at our breakpoint? */
1227 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1230 struct type *value_type;
1234 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1236 internal_error ("finish_command: function has no target type");
1238 /* FIXME: Shouldn't we do the cleanups before returning? */
1239 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1242 funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
1245 using_struct_return (value_of_variable (function, NULL),
1247 check_typedef (value_type),
1248 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
1250 print_return_value (struct_return, value_type);
1252 do_cleanups (old_chain);
1258 program_info (char *args, int from_tty)
1260 bpstat bs = stop_bpstat;
1261 int num = bpstat_num (&bs);
1263 if (!target_has_execution)
1265 printf_filtered ("The program being debugged is not being run.\n");
1269 target_files_info ();
1270 printf_filtered ("Program stopped at %s.\n",
1271 local_hex_string ((unsigned long) stop_pc));
1273 printf_filtered ("It stopped after being stepped.\n");
1276 /* There may be several breakpoints in the same place, so this
1277 isn't as strange as it seems. */
1282 printf_filtered ("It stopped at a breakpoint that has ");
1283 printf_filtered ("since been deleted.\n");
1286 printf_filtered ("It stopped at breakpoint %d.\n", num);
1287 num = bpstat_num (&bs);
1290 else if (stop_signal != TARGET_SIGNAL_0)
1292 printf_filtered ("It stopped with signal %s, %s.\n",
1293 target_signal_to_name (stop_signal),
1294 target_signal_to_string (stop_signal));
1299 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1300 printf_filtered ("for more information.\n");
1305 environment_info (char *var, int from_tty)
1309 register char *val = get_in_environ (inferior_environ, var);
1312 puts_filtered (var);
1313 puts_filtered (" = ");
1314 puts_filtered (val);
1315 puts_filtered ("\n");
1319 puts_filtered ("Environment variable \"");
1320 puts_filtered (var);
1321 puts_filtered ("\" not defined.\n");
1326 register char **vector = environ_vector (inferior_environ);
1329 puts_filtered (*vector++);
1330 puts_filtered ("\n");
1336 set_environment_command (char *arg, int from_tty)
1338 register char *p, *val, *var;
1342 error_no_arg ("environment variable and value");
1344 /* Find seperation between variable name and value */
1345 p = (char *) strchr (arg, '=');
1346 val = (char *) strchr (arg, ' ');
1348 if (p != 0 && val != 0)
1350 /* We have both a space and an equals. If the space is before the
1351 equals, walk forward over the spaces til we see a nonspace
1352 (possibly the equals). */
1357 /* Now if the = is after the char following the spaces,
1358 take the char following the spaces. */
1362 else if (val != 0 && p == 0)
1366 error_no_arg ("environment variable to set");
1368 if (p == 0 || p[1] == 0)
1372 p = arg + strlen (arg); /* So that savestring below will work */
1376 /* Not setting variable value to null */
1378 while (*val == ' ' || *val == '\t')
1382 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1385 var = savestring (arg, p - arg);
1388 printf_filtered ("Setting environment variable ");
1389 printf_filtered ("\"%s\" to null value.\n", var);
1390 set_in_environ (inferior_environ, var, "");
1393 set_in_environ (inferior_environ, var, val);
1398 unset_environment_command (char *var, int from_tty)
1402 /* If there is no argument, delete all environment variables.
1403 Ask for confirmation if reading from the terminal. */
1404 if (!from_tty || query ("Delete all environment variables? "))
1406 free_environ (inferior_environ);
1407 inferior_environ = make_environ ();
1411 unset_in_environ (inferior_environ, var);
1414 /* Handle the execution path (PATH variable) */
1416 static const char path_var_name[] = "PATH";
1420 path_info (char *args, int from_tty)
1422 puts_filtered ("Executable and object file path: ");
1423 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1424 puts_filtered ("\n");
1427 /* Add zero or more directories to the front of the execution path. */
1430 path_command (char *dirname, int from_tty)
1435 env = get_in_environ (inferior_environ, path_var_name);
1436 /* Can be null if path is not set */
1439 exec_path = strsave (env);
1440 mod_path (dirname, &exec_path);
1441 set_in_environ (inferior_environ, path_var_name, exec_path);
1444 path_info ((char *) NULL, from_tty);
1448 #ifdef REGISTER_NAMES
1449 char *gdb_register_names[] = REGISTER_NAMES;
1451 /* Print out the machine register regnum. If regnum is -1,
1452 print all registers (fpregs == 1) or all non-float registers
1455 For most machines, having all_registers_info() print the
1456 register(s) one per line is good enough. If a different format
1457 is required, (eg, for MIPS or Pyramid 90x, which both have
1458 lots of regs), or there is an existing convention for showing
1459 all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
1460 to provide that format. */
1463 do_registers_info (int regnum, int fpregs)
1466 int numregs = ARCH_NUM_REGS;
1468 for (i = 0; i < numregs; i++)
1470 char raw_buffer[MAX_REGISTER_RAW_SIZE];
1471 char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
1473 /* Decide between printing all regs, nonfloat regs, or specific reg. */
1476 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !fpregs)
1485 /* If the register name is empty, it is undefined for this
1486 processor, so don't display anything. */
1487 if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1490 fputs_filtered (REGISTER_NAME (i), gdb_stdout);
1491 print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout);
1493 /* Get the data in raw format. */
1494 if (read_relative_register_raw_bytes (i, raw_buffer))
1496 printf_filtered ("*value not available*\n");
1500 /* Convert raw data to virtual format if necessary. */
1501 if (REGISTER_CONVERTIBLE (i))
1503 REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
1504 raw_buffer, virtual_buffer);
1508 memcpy (virtual_buffer, raw_buffer,
1509 REGISTER_VIRTUAL_SIZE (i));
1512 /* If virtual format is floating, print it that way, and in raw hex. */
1513 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
1517 #ifdef INVALID_FLOAT
1518 if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
1519 printf_filtered ("<invalid float>");
1522 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1523 gdb_stdout, 0, 1, 0, Val_pretty_default);
1525 printf_filtered ("\t(raw 0x");
1526 for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
1528 register int idx = TARGET_BYTE_ORDER == BIG_ENDIAN ? j
1529 : REGISTER_RAW_SIZE (i) - 1 - j;
1530 printf_filtered ("%02x", (unsigned char) raw_buffer[idx]);
1532 printf_filtered (")");
1535 /* FIXME! val_print probably can handle all of these cases now... */
1537 /* Else if virtual format is too long for printf,
1538 print in hex a byte at a time. */
1539 else if (REGISTER_VIRTUAL_SIZE (i) > (int) sizeof (long))
1542 printf_filtered ("0x");
1543 for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++)
1544 printf_filtered ("%02x", (unsigned char) virtual_buffer[j]);
1546 /* Else print as integer in hex and in decimal. */
1549 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1550 gdb_stdout, 'x', 1, 0, Val_pretty_default);
1551 printf_filtered ("\t");
1552 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1553 gdb_stdout, 0, 1, 0, Val_pretty_default);
1556 /* The SPARC wants to print even-numbered float regs as doubles
1557 in addition to printing them as floats. */
1558 #ifdef PRINT_REGISTER_HOOK
1559 PRINT_REGISTER_HOOK (i);
1562 printf_filtered ("\n");
1567 registers_info (char *addr_exp, int fpregs)
1569 int regnum, numregs;
1572 if (!target_has_registers)
1573 error ("The program has no registers now.");
1574 if (selected_frame == NULL)
1575 error ("No selected frame.");
1579 DO_REGISTERS_INFO (-1, fpregs);
1585 if (addr_exp[0] == '$')
1588 while (*end != '\0' && *end != ' ' && *end != '\t')
1590 numregs = ARCH_NUM_REGS;
1592 regnum = target_map_name_to_register (addr_exp, end - addr_exp);
1598 if (*addr_exp >= '0' && *addr_exp <= '9')
1599 regnum = atoi (addr_exp); /* Take a number */
1600 if (regnum >= numregs) /* Bad name, or bad number */
1601 error ("%.*s: invalid register", end - addr_exp, addr_exp);
1604 DO_REGISTERS_INFO (regnum, fpregs);
1607 while (*addr_exp == ' ' || *addr_exp == '\t')
1610 while (*addr_exp != '\0');
1614 all_registers_info (char *addr_exp, int from_tty)
1616 registers_info (addr_exp, 1);
1620 nofp_registers_info (char *addr_exp, int from_tty)
1622 registers_info (addr_exp, 0);
1628 * Should save/restore the tty state since it might be that the
1629 * program to be debugged was started on this tty and it wants
1630 * the tty in some state other than what we want. If it's running
1631 * on another terminal or without a terminal, then saving and
1632 * restoring the tty state is a harmless no-op.
1633 * This only needs to be done if we are attaching to a process.
1638 takes a program started up outside of gdb and ``attaches'' to it.
1639 This stops it cold in its tracks and allows us to start debugging it.
1640 and wait for the trace-trap that results from attaching. */
1643 attach_command (char *args, int from_tty)
1646 extern int auto_solib_add;
1650 char *full_exec_path = NULL;
1652 dont_repeat (); /* Not for the faint of heart */
1654 if (target_has_execution)
1656 if (query ("A program is being debugged already. Kill it? "))
1659 error ("Not killed.");
1662 target_attach (args, from_tty);
1664 /* Set up the "saved terminal modes" of the inferior
1665 based on what modes we are starting it with. */
1666 target_terminal_init ();
1668 /* Install inferior's terminal modes. */
1669 target_terminal_inferior ();
1671 /* Set up execution context to know that we should return from
1672 wait_for_inferior as soon as the target reports a stop. */
1673 init_wait_for_inferior ();
1674 clear_proceed_status ();
1676 /* No traps are generated when attaching to inferior under Mach 3
1678 #ifndef ATTACH_NO_WAIT
1679 stop_soon_quietly = 1;
1680 wait_for_inferior ();
1684 * If no exec file is yet known, try to determine it from the
1687 exec_file = (char *) get_exec_file (0);
1690 exec_file = target_pid_to_exec_file (inferior_pid);
1693 /* It's possible we don't have a full path, but rather just a
1694 filename. Some targets, such as HP-UX, don't provide the
1697 Attempt to qualify the filename against the source path.
1698 (If that fails, we'll just fall back on the original
1699 filename. Not much more we can do...)
1701 if (!source_full_path_of (exec_file, &full_exec_path))
1702 full_exec_path = savestring (exec_file, strlen (exec_file));
1704 exec_file_attach (full_exec_path, from_tty);
1705 symbol_file_add_main (full_exec_path, from_tty);
1712 /* Add shared library symbols from the newly attached process, if any. */
1713 SOLIB_ADD ((char *) 0, from_tty, ¤t_target);
1714 re_enable_breakpoints_in_shlibs ();
1718 /* Take any necessary post-attaching actions for this platform.
1720 target_post_attach (inferior_pid);
1730 * takes a program previously attached to and detaches it.
1731 * The program resumes execution and will no longer stop
1732 * on signals, etc. We better not have left any breakpoints
1733 * in the program or it'll die when it hits one. For this
1734 * to work, it may be necessary for the process to have been
1735 * previously attached. It *might* work if the program was
1736 * started via the normal ptrace (PTRACE_TRACEME).
1740 detach_command (char *args, int from_tty)
1742 dont_repeat (); /* Not for the faint of heart */
1743 target_detach (args, from_tty);
1744 #if defined(SOLIB_RESTART)
1751 /* Stop the execution of the target while running in async mode, in
1755 interrupt_target_command_wrapper (char *args, int from_tty)
1757 interrupt_target_command (args, from_tty);
1761 interrupt_target_command (char *args, int from_tty)
1763 if (event_loop_p && target_can_async_p ())
1765 dont_repeat (); /* Not for the faint of heart */
1772 float_info (char *addr_exp, int from_tty)
1777 printf_filtered ("No floating point info available for this processor.\n");
1783 unset_command (char *args, int from_tty)
1785 printf_filtered ("\"unset\" must be followed by the name of ");
1786 printf_filtered ("an unset subcommand.\n");
1787 help_list (unsetlist, "unset ", -1, gdb_stdout);
1791 _initialize_infcmd (void)
1793 struct cmd_list_element *c;
1795 add_com ("tty", class_run, tty_command,
1796 "Set terminal for future runs of program being debugged.");
1799 (add_set_cmd ("args", class_run, var_string_noescape,
1800 (char *) &inferior_args,
1801 "Set argument list to give program being debugged when it is started.\n\
1802 Follow this command with any number of args, to be passed to the program.",
1807 ("environment", no_class, environment_info,
1808 "The environment to give the program, or one variable's value.\n\
1809 With an argument VAR, prints the value of environment variable VAR to\n\
1810 give the program being debugged. With no arguments, prints the entire\n\
1811 environment to be given to the program.", &showlist);
1812 c->completer = noop_completer;
1814 add_prefix_cmd ("unset", no_class, unset_command,
1815 "Complement to certain \"set\" commands",
1816 &unsetlist, "unset ", 0, &cmdlist);
1818 c = add_cmd ("environment", class_run, unset_environment_command,
1819 "Cancel environment variable VAR for the program.\n\
1820 This does not affect the program until the next \"run\" command.",
1822 c->completer = noop_completer;
1824 c = add_cmd ("environment", class_run, set_environment_command,
1825 "Set environment variable value to give the program.\n\
1826 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
1827 VALUES of environment variables are uninterpreted strings.\n\
1828 This does not affect the program until the next \"run\" command.",
1830 c->completer = noop_completer;
1832 add_com ("path", class_files, path_command,
1833 "Add directory DIR(s) to beginning of search path for object files.\n\
1834 $cwd in the path means the current working directory.\n\
1835 This path is equivalent to the $PATH shell variable. It is a list of\n\
1836 directories, separated by colons. These directories are searched to find\n\
1837 fully linked executable files and separately compiled object files as needed.");
1839 c = add_cmd ("paths", no_class, path_info,
1840 "Current search path for finding object files.\n\
1841 $cwd in the path means the current working directory.\n\
1842 This path is equivalent to the $PATH shell variable. It is a list of\n\
1843 directories, separated by colons. These directories are searched to find\n\
1844 fully linked executable files and separately compiled object files as needed.",
1846 c->completer = noop_completer;
1848 add_com ("attach", class_run, attach_command,
1849 "Attach to a process or file outside of GDB.\n\
1850 This command attaches to another target, of the same type as your last\n\
1851 \"target\" command (\"info files\" will show your target stack).\n\
1852 The command may take as argument a process id or a device file.\n\
1853 For a process id, you must have permission to send the process a signal,\n\
1854 and it must have the same effective uid as the debugger.\n\
1855 When using \"attach\" with a process id, the debugger finds the\n\
1856 program running in the process, looking first in the current working\n\
1857 directory, or (if not found there) using the source file search path\n\
1858 (see the \"directory\" command). You can also use the \"file\" command\n\
1859 to specify the program, and to load its symbol table.");
1861 add_com ("detach", class_run, detach_command,
1862 "Detach a process or file previously attached.\n\
1863 If a process, it is no longer traced, and it continues its execution. If\n\
1864 you were debugging a file, the file is closed and gdb no longer accesses it.");
1866 add_com ("signal", class_run, signal_command,
1867 "Continue program giving it signal specified by the argument.\n\
1868 An argument of \"0\" means continue program without giving it a signal.");
1870 add_com ("stepi", class_run, stepi_command,
1871 "Step one instruction exactly.\n\
1872 Argument N means do this N times (or till program stops for another reason).");
1873 add_com_alias ("si", "stepi", class_alias, 0);
1875 add_com ("nexti", class_run, nexti_command,
1876 "Step one instruction, but proceed through subroutine calls.\n\
1877 Argument N means do this N times (or till program stops for another reason).");
1878 add_com_alias ("ni", "nexti", class_alias, 0);
1880 add_com ("finish", class_run, finish_command,
1881 "Execute until selected stack frame returns.\n\
1882 Upon return, the value returned is printed and put in the value history.");
1884 add_com ("next", class_run, next_command,
1885 "Step program, proceeding through subroutine calls.\n\
1886 Like the \"step\" command as long as subroutine calls do not happen;\n\
1887 when they do, the call is treated as one instruction.\n\
1888 Argument N means do this N times (or till program stops for another reason).");
1889 add_com_alias ("n", "next", class_run, 1);
1891 add_com_alias ("S", "next", class_run, 1);
1893 add_com ("step", class_run, step_command,
1894 "Step program until it reaches a different source line.\n\
1895 Argument N means do this N times (or till program stops for another reason).");
1896 add_com_alias ("s", "step", class_run, 1);
1898 add_com ("until", class_run, until_command,
1899 "Execute until the program reaches a source line greater than the current\n\
1900 or a specified line or address or function (same args as break command).\n\
1901 Execution will also stop upon exit from the current stack frame.");
1902 add_com_alias ("u", "until", class_run, 1);
1904 add_com ("jump", class_run, jump_command,
1905 "Continue program being debugged at specified line or address.\n\
1906 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
1907 for an address to start at.");
1910 add_com ("go", class_run, go_command,
1911 "Usage: go <location>\n\
1912 Continue program being debugged, stopping at specified line or \n\
1914 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
1915 expression for an address to start at.\n\
1916 This command is a combination of tbreak and jump.");
1919 add_com_alias ("g", "go", class_run, 1);
1921 add_com ("continue", class_run, continue_command,
1922 "Continue program being debugged, after signal or breakpoint.\n\
1923 If proceeding from breakpoint, a number N may be used as an argument,\n\
1924 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
1925 the breakpoint won't break until the Nth time it is reached).");
1926 add_com_alias ("c", "cont", class_run, 1);
1927 add_com_alias ("fg", "cont", class_run, 1);
1929 add_com ("run", class_run, run_command,
1930 "Start debugged program. You may specify arguments to give it.\n\
1931 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
1932 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
1933 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
1934 To cancel previous arguments and run with no arguments,\n\
1935 use \"set args\" without arguments.");
1936 add_com_alias ("r", "run", class_run, 1);
1938 add_com ("R", class_run, run_no_args_command,
1939 "Start debugged program with no arguments.");
1941 add_com ("interrupt", class_run, interrupt_target_command,
1942 "Interrupt the execution of the debugged program.");
1944 add_info ("registers", nofp_registers_info,
1945 "List of integer registers and their contents, for selected stack frame.\n\
1946 Register name as argument means describe only that register.");
1947 add_info_alias ("r", "registers", 1);
1950 add_com ("lr", class_info, nofp_registers_info,
1951 "List of integer registers and their contents, for selected stack frame.\n\
1952 Register name as argument means describe only that register.");
1953 add_info ("all-registers", all_registers_info,
1954 "List of all registers and their contents, for selected stack frame.\n\
1955 Register name as argument means describe only that register.");
1957 add_info ("program", program_info,
1958 "Execution status of the program.");
1960 add_info ("float", float_info,
1961 "Print the status of the floating point unit\n");
1963 set_inferior_args (xstrdup ("")); /* Initially no args */
1964 inferior_environ = make_environ ();
1965 init_environ (inferior_environ);