1 /* Memory-access and commands for "inferior" process, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000, 2001
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #include "gdb_string.h"
42 #include "event-top.h"
43 #include "parser-defs.h"
45 /* Functions exported for general use: */
47 void nofp_registers_info (char *, int);
49 void all_registers_info (char *, int);
51 void registers_info (char *, int);
53 /* Local functions: */
55 void continue_command (char *, int);
57 static void print_return_value (int struct_return
, struct type
*value_type
);
59 static void finish_command_continuation (struct continuation_arg
*);
61 static void until_next_command (int);
63 static void until_command (char *, int);
65 static void path_info (char *, int);
67 static void path_command (char *, int);
69 static void unset_command (char *, int);
71 static void float_info (char *, int);
73 static void detach_command (char *, int);
75 static void interrupt_target_command (char *args
, int from_tty
);
77 static void unset_environment_command (char *, int);
79 static void set_environment_command (char *, int);
81 static void environment_info (char *, int);
83 static void program_info (char *, int);
85 static void finish_command (char *, int);
87 static void signal_command (char *, int);
89 static void jump_command (char *, int);
91 static void step_1 (int, int, char *);
92 static void step_once (int skip_subroutines
, int single_inst
, int count
);
93 static void step_1_continuation (struct continuation_arg
*arg
);
95 void nexti_command (char *, int);
97 void stepi_command (char *, int);
99 static void next_command (char *, int);
101 static void step_command (char *, int);
103 static void run_command (char *, int);
105 static void run_no_args_command (char *args
, int from_tty
);
107 static void go_command (char *line_no
, int from_tty
);
109 static int strip_bg_char (char **);
111 void _initialize_infcmd (void);
113 #define GO_USAGE "Usage: go <location>\n"
115 static void breakpoint_auto_delete_contents (PTR
);
117 #define ERROR_NO_INFERIOR \
118 if (!target_has_execution) error ("The program is not being run.");
120 /* String containing arguments to give to the program, separated by spaces.
121 Empty string (pointer to '\0') means no args. */
123 static char *inferior_args
;
125 /* File name for default use for standard in/out in the inferior. */
127 char *inferior_io_terminal
;
129 /* Pid of our debugged inferior, or 0 if no inferior now.
130 Since various parts of infrun.c test this to see whether there is a program
131 being debugged it should be nonzero (currently 3 is used) for remote
136 /* Last signal that the inferior received (why it stopped). */
138 enum target_signal stop_signal
;
140 /* Address at which inferior stopped. */
144 /* Chain containing status of breakpoint(s) that we have stopped at. */
148 /* Flag indicating that a command has proceeded the inferior past the
149 current breakpoint. */
151 int breakpoint_proceeded
;
153 /* Nonzero if stopped due to a step command. */
157 /* Nonzero if stopped due to completion of a stack dummy routine. */
159 int stop_stack_dummy
;
161 /* Nonzero if stopped due to a random (unexpected) signal in inferior
164 int stopped_by_random_signal
;
166 /* Range to single step within.
167 If this is nonzero, respond to a single-step signal
168 by continuing to step if the pc is in this range. */
170 CORE_ADDR step_range_start
; /* Inclusive */
171 CORE_ADDR step_range_end
; /* Exclusive */
173 /* Stack frame address as of when stepping command was issued.
174 This is how we know when we step into a subroutine call,
175 and how to set the frame for the breakpoint used to step out. */
177 CORE_ADDR step_frame_address
;
179 /* Our notion of the current stack pointer. */
183 enum step_over_calls_kind step_over_calls
;
185 /* If stepping, nonzero means step count is > 1
186 so don't print frame next time inferior stops
187 if it stops due to stepping. */
191 /* Environment to use for running inferior,
192 in format described in environ.h. */
194 struct environ
*inferior_environ
;
196 /* Accessor routines. */
199 get_inferior_args (void)
201 return inferior_args
;
205 set_inferior_args (char *newargs
)
207 char *saved_args
= inferior_args
;
209 inferior_args
= newargs
;
214 /* This function detects whether or not a '&' character (indicating
215 background execution) has been added as *the last* of the arguments ARGS
216 of a command. If it has, it removes it and returns 1. Otherwise it
217 does nothing and returns 0. */
219 strip_bg_char (char **args
)
223 p
= strchr (*args
, '&');
227 if (p
== (*args
+ strlen (*args
) - 1))
229 if (strlen (*args
) > 1)
233 while (*p
== ' ' || *p
== '\t');
246 tty_command (char *file
, int from_tty
)
249 error_no_arg ("terminal name for running target process");
251 inferior_io_terminal
= savestring (file
, strlen (file
));
255 run_command (char *args
, int from_tty
)
261 if (inferior_pid
!= 0 && target_has_execution
)
264 && !query ("The program being debugged has been started already.\n\
265 Start it from the beginning? "))
266 error ("Program not restarted.");
268 #if defined(SOLIB_RESTART)
271 init_wait_for_inferior ();
274 clear_breakpoint_hit_counts ();
276 exec_file
= (char *) get_exec_file (0);
278 /* Purge old solib objfiles. */
279 objfile_purge_solibs ();
281 do_run_cleanups (NULL
);
283 /* The exec file is re-read every time we do a generic_mourn_inferior, so
284 we just have to worry about the symbol file. */
287 /* We keep symbols from add-symbol-file, on the grounds that the
288 user might want to add some symbols before running the program
289 (right?). But sometimes (dynamic loading where the user manually
290 introduces the new symbols with add-symbol-file), the code which
291 the symbols describe does not persist between runs. Currently
292 the user has to manually nuke all symbols between runs if they
293 want them to go away (PR 2207). This is probably reasonable. */
297 if (event_loop_p
&& target_can_async_p ())
298 async_disable_stdin ();
302 int async_exec
= strip_bg_char (&args
);
304 /* If we get a request for running in the bg but the target
305 doesn't support it, error out. */
306 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
307 error ("Asynchronous execution not supported on this target.");
309 /* If we don't get a request of running in the bg, then we need
310 to simulate synchronous (fg) execution. */
311 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
313 /* Simulate synchronous execution */
314 async_disable_stdin ();
317 /* If there were other args, beside '&', process them. */
320 char *old_args
= set_inferior_args (xstrdup (args
));
328 ui_out_field_string (uiout
, NULL
, "Starting program");
329 ui_out_text (uiout
, ": ");
331 ui_out_field_string (uiout
, "execfile", exec_file
);
332 ui_out_spaces (uiout
, 1);
333 ui_out_field_string (uiout
, "infargs", inferior_args
);
334 ui_out_text (uiout
, "\n");
335 ui_out_flush (uiout
);
337 puts_filtered ("Starting program: ");
339 puts_filtered (exec_file
);
341 puts_filtered (inferior_args
);
342 puts_filtered ("\n");
343 gdb_flush (gdb_stdout
);
347 target_create_inferior (exec_file
, inferior_args
,
348 environ_vector (inferior_environ
));
353 run_no_args_command (char *args
, int from_tty
)
355 char *old_args
= set_inferior_args (xstrdup (""));
361 continue_command (char *proc_count_exp
, int from_tty
)
366 /* Find out whether we must run in the background. */
367 if (proc_count_exp
!= NULL
)
368 async_exec
= strip_bg_char (&proc_count_exp
);
370 /* If we must run in the background, but the target can't do it,
372 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
373 error ("Asynchronous execution not supported on this target.");
375 /* If we are not asked to run in the bg, then prepare to run in the
376 foreground, synchronously. */
377 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
379 /* Simulate synchronous execution */
380 async_disable_stdin ();
383 /* If have argument (besides '&'), set proceed count of breakpoint
385 if (proc_count_exp
!= NULL
)
387 bpstat bs
= stop_bpstat
;
388 int num
= bpstat_num (&bs
);
389 if (num
== 0 && from_tty
)
392 ("Not stopped at any breakpoint; argument ignored.\n");
396 set_ignore_count (num
,
397 parse_and_eval_long (proc_count_exp
) - 1,
399 /* set_ignore_count prints a message ending with a period.
400 So print two spaces before "Continuing.". */
402 printf_filtered (" ");
403 num
= bpstat_num (&bs
);
408 printf_filtered ("Continuing.\n");
410 clear_proceed_status ();
412 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
415 /* Step until outside of current statement. */
419 step_command (char *count_string
, int from_tty
)
421 step_1 (0, 0, count_string
);
424 /* Likewise, but skip over subroutine calls as if single instructions. */
428 next_command (char *count_string
, int from_tty
)
430 step_1 (1, 0, count_string
);
433 /* Likewise, but step only one instruction. */
437 stepi_command (char *count_string
, int from_tty
)
439 step_1 (0, 1, count_string
);
444 nexti_command (char *count_string
, int from_tty
)
446 step_1 (1, 1, count_string
);
450 disable_longjmp_breakpoint_cleanup (void *ignore
)
452 disable_longjmp_breakpoint ();
456 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
458 register int count
= 1;
459 struct frame_info
*frame
;
460 struct cleanup
*cleanups
= 0;
466 async_exec
= strip_bg_char (&count_string
);
468 /* If we get a request for running in the bg but the target
469 doesn't support it, error out. */
470 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
471 error ("Asynchronous execution not supported on this target.");
473 /* If we don't get a request of running in the bg, then we need
474 to simulate synchronous (fg) execution. */
475 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
477 /* Simulate synchronous execution */
478 async_disable_stdin ();
481 count
= count_string
? parse_and_eval_long (count_string
) : 1;
483 if (!single_inst
|| skip_subroutines
) /* leave si command alone */
485 enable_longjmp_breakpoint ();
486 if (!event_loop_p
|| !target_can_async_p ())
487 cleanups
= make_cleanup (disable_longjmp_breakpoint_cleanup
, 0 /*ignore*/);
489 make_exec_cleanup (disable_longjmp_breakpoint_cleanup
, 0 /*ignore*/);
492 /* In synchronous case, all is well, just use the regular for loop. */
493 if (!event_loop_p
|| !target_can_async_p ())
495 for (; count
> 0; count
--)
497 clear_proceed_status ();
499 frame
= get_current_frame ();
500 if (!frame
) /* Avoid coredump here. Why tho? */
501 error ("No current frame");
502 step_frame_address
= FRAME_FP (frame
);
503 step_sp
= read_sp ();
507 find_pc_line_pc_range (stop_pc
, &step_range_start
, &step_range_end
);
508 if (step_range_end
== 0)
511 if (find_pc_partial_function (stop_pc
, &name
, &step_range_start
,
512 &step_range_end
) == 0)
513 error ("Cannot find bounds of current function");
515 target_terminal_ours ();
517 Single stepping until exit from function %s, \n\
518 which has no line number information.\n", name
);
523 /* Say we are stepping, but stop after one insn whatever it does. */
524 step_range_start
= step_range_end
= 1;
525 if (!skip_subroutines
)
527 Don't step over function calls, not even to functions lacking
529 step_over_calls
= STEP_OVER_NONE
;
532 if (skip_subroutines
)
533 step_over_calls
= STEP_OVER_ALL
;
535 step_multi
= (count
> 1);
536 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
541 /* FIXME: On nexti, this may have already been done (when we hit the
542 step resume break, I think). Probably this should be moved to
543 wait_for_inferior (near the top). */
544 #if defined (SHIFT_INST_REGS)
549 if (!single_inst
|| skip_subroutines
)
550 do_cleanups (cleanups
);
553 /* In case of asynchronous target things get complicated, do only
554 one step for now, before returning control to the event loop. Let
555 the continuation figure out how many other steps we need to do,
556 and handle them one at the time, through step_once(). */
559 if (event_loop_p
&& target_can_async_p ())
560 step_once (skip_subroutines
, single_inst
, count
);
564 /* Called after we are done with one step operation, to check whether
565 we need to step again, before we print the prompt and return control
566 to the user. If count is > 1, we will need to do one more call to
567 proceed(), via step_once(). Basically it is like step_once and
568 step_1_continuation are co-recursive. */
570 step_1_continuation (struct continuation_arg
*arg
)
573 int skip_subroutines
;
576 skip_subroutines
= arg
->data
.integer
;
577 single_inst
= arg
->next
->data
.integer
;
578 count
= arg
->next
->next
->data
.integer
;
582 /* FIXME: On nexti, this may have already been done (when we hit the
583 step resume break, I think). Probably this should be moved to
584 wait_for_inferior (near the top). */
585 #if defined (SHIFT_INST_REGS)
588 step_once (skip_subroutines
, single_inst
, count
- 1);
591 if (!single_inst
|| skip_subroutines
)
592 do_exec_cleanups (ALL_CLEANUPS
);
595 /* Do just one step operation. If count >1 we will have to set up a
596 continuation to be done after the target stops (after this one
597 step). This is useful to implement the 'step n' kind of commands, in
598 case of asynchronous targets. We had to split step_1 into two parts,
599 one to be done before proceed() and one afterwards. This function is
600 called in case of step n with n>1, after the first step operation has
603 step_once (int skip_subroutines
, int single_inst
, int count
)
605 struct continuation_arg
*arg1
;
606 struct continuation_arg
*arg2
;
607 struct continuation_arg
*arg3
;
608 struct frame_info
*frame
;
612 clear_proceed_status ();
614 frame
= get_current_frame ();
615 if (!frame
) /* Avoid coredump here. Why tho? */
616 error ("No current frame");
617 step_frame_address
= FRAME_FP (frame
);
618 step_sp
= read_sp ();
622 find_pc_line_pc_range (stop_pc
, &step_range_start
, &step_range_end
);
624 /* If we have no line info, switch to stepi mode. */
625 if (step_range_end
== 0 && step_stop_if_no_debug
)
627 step_range_start
= step_range_end
= 1;
629 else if (step_range_end
== 0)
632 if (find_pc_partial_function (stop_pc
, &name
, &step_range_start
,
633 &step_range_end
) == 0)
634 error ("Cannot find bounds of current function");
636 target_terminal_ours ();
638 Single stepping until exit from function %s, \n\
639 which has no line number information.\n", name
);
644 /* Say we are stepping, but stop after one insn whatever it does. */
645 step_range_start
= step_range_end
= 1;
646 if (!skip_subroutines
)
648 Don't step over function calls, not even to functions lacking
650 step_over_calls
= STEP_OVER_NONE
;
653 if (skip_subroutines
)
654 step_over_calls
= STEP_OVER_ALL
;
656 step_multi
= (count
> 1);
658 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
660 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
662 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
664 arg1
->data
.integer
= skip_subroutines
;
666 arg2
->data
.integer
= single_inst
;
668 arg3
->data
.integer
= count
;
669 add_intermediate_continuation (step_1_continuation
, arg1
);
670 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
675 /* Continue program at specified address. */
678 jump_command (char *arg
, int from_tty
)
680 register CORE_ADDR addr
;
681 struct symtabs_and_lines sals
;
682 struct symtab_and_line sal
;
689 /* Find out whether we must run in the background. */
691 async_exec
= strip_bg_char (&arg
);
693 /* If we must run in the background, but the target can't do it,
695 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
696 error ("Asynchronous execution not supported on this target.");
698 /* If we are not asked to run in the bg, then prepare to run in the
699 foreground, synchronously. */
700 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
702 /* Simulate synchronous execution */
703 async_disable_stdin ();
707 error_no_arg ("starting address");
709 sals
= decode_line_spec_1 (arg
, 1);
712 error ("Unreasonable jump request");
718 if (sal
.symtab
== 0 && sal
.pc
== 0)
719 error ("No source file has been specified.");
721 resolve_sal_pc (&sal
); /* May error out */
723 /* See if we are trying to jump to another function. */
724 fn
= get_frame_function (get_current_frame ());
725 sfn
= find_pc_function (sal
.pc
);
726 if (fn
!= NULL
&& sfn
!= fn
)
728 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal
.line
,
729 SYMBOL_SOURCE_NAME (fn
)))
731 error ("Not confirmed.");
738 fixup_symbol_section (sfn
, 0);
739 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn
)) &&
740 !section_is_mapped (SYMBOL_BFD_SECTION (sfn
)))
742 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
744 error ("Not confirmed.");
754 printf_filtered ("Continuing at ");
755 print_address_numeric (addr
, 1, gdb_stdout
);
756 printf_filtered (".\n");
759 clear_proceed_status ();
760 proceed (addr
, TARGET_SIGNAL_0
, 0);
764 /* Go to line or address in current procedure */
766 go_command (char *line_no
, int from_tty
)
768 if (line_no
== (char *) NULL
|| !*line_no
)
769 printf_filtered (GO_USAGE
);
772 tbreak_command (line_no
, from_tty
);
773 jump_command (line_no
, from_tty
);
778 /* Continue program giving it specified signal. */
781 signal_command (char *signum_exp
, int from_tty
)
783 enum target_signal oursig
;
785 dont_repeat (); /* Too dangerous. */
789 error_no_arg ("signal number");
791 /* It would be even slicker to make signal names be valid expressions,
792 (the type could be "enum $signal" or some such), then the user could
793 assign them to convenience variables. */
794 oursig
= target_signal_from_name (signum_exp
);
796 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
798 /* No, try numeric. */
799 int num
= parse_and_eval_long (signum_exp
);
802 oursig
= TARGET_SIGNAL_0
;
804 oursig
= target_signal_from_command (num
);
809 if (oursig
== TARGET_SIGNAL_0
)
810 printf_filtered ("Continuing with no signal.\n");
812 printf_filtered ("Continuing with signal %s.\n",
813 target_signal_to_name (oursig
));
816 clear_proceed_status ();
817 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
818 FIXME: Neither should "signal foo" but when I tried passing
819 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
820 tried to track down yet. */
821 proceed (oursig
== TARGET_SIGNAL_0
? (CORE_ADDR
) -1 : stop_pc
, oursig
, 0);
824 /* Call breakpoint_auto_delete on the current contents of the bpstat
825 pointed to by arg (which is really a bpstat *). */
828 breakpoint_auto_delete_contents (PTR arg
)
830 breakpoint_auto_delete (*(bpstat
*) arg
);
834 /* Execute a "stack dummy", a piece of code stored in the stack
835 by the debugger to be executed in the inferior.
837 To call: first, do PUSH_DUMMY_FRAME.
838 Then push the contents of the dummy. It should end with a breakpoint insn.
839 Then call here, passing address at which to start the dummy.
841 The contents of all registers are saved before the dummy frame is popped
842 and copied into the buffer BUFFER.
844 The dummy's frame is automatically popped whenever that break is hit.
845 If that is the first time the program stops, run_stack_dummy
846 returns to its caller with that frame already gone and returns 0.
848 Otherwise, run_stack-dummy returns a non-zero value.
849 If the called function receives a random signal, we do not allow the user
850 to continue executing it as this may not work. The dummy frame is poped
852 If we hit a breakpoint, we leave the frame in place and return 2 (the frame
853 will eventually be popped when we do hit the dummy end breakpoint). */
856 run_stack_dummy (CORE_ADDR addr
, char *buffer
)
858 struct cleanup
*old_cleanups
= make_cleanup (null_cleanup
, 0);
861 /* Now proceed, having reached the desired place. */
862 clear_proceed_status ();
864 if (CALL_DUMMY_BREAKPOINT_OFFSET_P
)
866 struct breakpoint
*bpt
;
867 struct symtab_and_line sal
;
869 INIT_SAL (&sal
); /* initialize to zeroes */
870 if (CALL_DUMMY_LOCATION
== AT_ENTRY_POINT
)
872 sal
.pc
= CALL_DUMMY_ADDRESS ();
876 sal
.pc
= addr
- CALL_DUMMY_START_OFFSET
+ CALL_DUMMY_BREAKPOINT_OFFSET
;
878 sal
.section
= find_pc_overlay (sal
.pc
);
880 /* Set up a FRAME for the dummy frame so we can pass it to
881 set_momentary_breakpoint. We need to give the breakpoint a
882 frame in case there is only one copy of the dummy (e.g.
883 CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
884 flush_cached_frames ();
885 set_current_frame (create_new_frame (read_fp (), sal
.pc
));
887 /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
888 a breakpoint instruction. If not, the call dummy already has the
889 breakpoint instruction in it.
891 addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
892 so we need to subtract the CALL_DUMMY_START_OFFSET. */
893 bpt
= set_momentary_breakpoint (sal
,
894 get_current_frame (),
896 bpt
->disposition
= del
;
898 /* If all error()s out of proceed ended up calling normal_stop (and
899 perhaps they should; it already does in the special case of error
900 out of resume()), then we wouldn't need this. */
901 make_cleanup (breakpoint_auto_delete_contents
, &stop_bpstat
);
904 disable_watchpoints_before_interactive_call_start ();
905 proceed_to_finish
= 1; /* We want stop_registers, please... */
907 if (target_can_async_p ())
908 saved_async
= target_async_mask (0);
910 proceed (addr
, TARGET_SIGNAL_0
, 0);
913 target_async_mask (saved_async
);
915 enable_watchpoints_after_interactive_call_stop ();
917 discard_cleanups (old_cleanups
);
919 /* We can stop during an inferior call because a signal is received. */
920 if (stopped_by_random_signal
)
923 /* We may also stop prematurely because we hit a breakpoint in the
925 if (!stop_stack_dummy
)
928 /* On normal return, the stack dummy has been popped already. */
930 memcpy (buffer
, stop_registers
, REGISTER_BYTES
);
934 /* Proceed until we reach a different source line with pc greater than
935 our current one or exit the function. We skip calls in both cases.
937 Note that eventually this command should probably be changed so
938 that only source lines are printed out when we hit the breakpoint
939 we set. This may involve changes to wait_for_inferior and the
940 proceed status code. */
944 until_next_command (int from_tty
)
946 struct frame_info
*frame
;
949 struct symtab_and_line sal
;
951 clear_proceed_status ();
953 frame
= get_current_frame ();
955 /* Step until either exited from this function or greater
956 than the current line (if in symbolic section) or pc (if
960 func
= find_pc_function (pc
);
964 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
967 error ("Execution is not within a known function.");
969 step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
974 sal
= find_pc_line (pc
, 0);
976 step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
977 step_range_end
= sal
.end
;
980 step_over_calls
= STEP_OVER_ALL
;
981 step_frame_address
= FRAME_FP (frame
);
982 step_sp
= read_sp ();
984 step_multi
= 0; /* Only one call to proceed */
986 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
990 until_command (char *arg
, int from_tty
)
994 if (!target_has_execution
)
995 error ("The program is not running.");
997 /* Find out whether we must run in the background. */
999 async_exec
= strip_bg_char (&arg
);
1001 /* If we must run in the background, but the target can't do it,
1003 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
1004 error ("Asynchronous execution not supported on this target.");
1006 /* If we are not asked to run in the bg, then prepare to run in the
1007 foreground, synchronously. */
1008 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
1010 /* Simulate synchronous execution */
1011 async_disable_stdin ();
1015 until_break_command (arg
, from_tty
);
1017 until_next_command (from_tty
);
1021 /* Print the result of a function at the end of a 'finish' command. */
1023 print_return_value (int structure_return
, struct type
*value_type
)
1025 register value_ptr value
;
1027 static struct ui_stream
*stb
= NULL
;
1030 if (!structure_return
)
1032 value
= value_being_returned (value_type
, stop_registers
, structure_return
);
1034 stb
= ui_out_stream_new (uiout
);
1035 ui_out_text (uiout
, "Value returned is ");
1036 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d", record_latest_value (value
));
1037 ui_out_text (uiout
, " = ");
1038 value_print (value
, stb
->stream
, 0, Val_no_prettyprint
);
1039 ui_out_field_stream (uiout
, "return-value", stb
);
1040 ui_out_text (uiout
, "\n");
1042 printf_filtered ("Value returned is $%d = ", record_latest_value (value
));
1043 value_print (value
, gdb_stdout
, 0, Val_no_prettyprint
);
1044 printf_filtered ("\n");
1049 /* We cannot determine the contents of the structure because
1050 it is on the stack, and we don't know where, since we did not
1051 initiate the call, as opposed to the call_function_by_hand case */
1052 #ifdef VALUE_RETURNED_FROM_STACK
1055 ui_out_text (uiout
, "Value returned has type: ");
1056 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1057 ui_out_text (uiout
, ".");
1058 ui_out_text (uiout
, " Cannot determine contents\n");
1060 printf_filtered ("Value returned has type: %s.", TYPE_NAME (value_type
));
1061 printf_filtered (" Cannot determine contents\n");
1064 value
= value_being_returned (value_type
, stop_registers
, structure_return
);
1066 stb
= ui_out_stream_new (uiout
);
1067 ui_out_text (uiout
, "Value returned is ");
1068 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d", record_latest_value (value
));
1069 ui_out_text (uiout
, " = ");
1070 value_print (value
, stb
->stream
, 0, Val_no_prettyprint
);
1071 ui_out_field_stream (uiout
, "return-value", stb
);
1072 ui_out_text (uiout
, "\n");
1074 printf_filtered ("Value returned is $%d = ", record_latest_value (value
));
1075 value_print (value
, gdb_stdout
, 0, Val_no_prettyprint
);
1076 printf_filtered ("\n");
1082 /* Stuff that needs to be done by the finish command after the target
1083 has stopped. In asynchronous mode, we wait for the target to stop in
1084 the call to poll or select in the event loop, so it is impossible to
1085 do all the stuff as part of the finish_command function itself. The
1086 only chance we have to complete this command is in
1087 fetch_inferior_event, which is called by the event loop as soon as it
1088 detects that the target has stopped. This function is called via the
1089 cmd_continuation pointer. */
1091 finish_command_continuation (struct continuation_arg
*arg
)
1093 register struct symbol
*function
;
1094 struct breakpoint
*breakpoint
;
1095 struct cleanup
*cleanups
;
1097 breakpoint
= (struct breakpoint
*) arg
->data
.pointer
;
1098 function
= (struct symbol
*) arg
->next
->data
.pointer
;
1099 cleanups
= (struct cleanup
*) arg
->next
->next
->data
.pointer
;
1101 if (bpstat_find_breakpoint (stop_bpstat
, breakpoint
) != NULL
1104 struct type
*value_type
;
1108 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (function
));
1110 internal_error (__FILE__
, __LINE__
,
1111 "finish_command: function has no target type");
1113 if (TYPE_CODE (value_type
) == TYPE_CODE_VOID
)
1115 do_exec_cleanups (cleanups
);
1119 funcaddr
= BLOCK_START (SYMBOL_BLOCK_VALUE (function
));
1121 struct_return
= using_struct_return (value_of_variable (function
, NULL
),
1123 check_typedef (value_type
),
1124 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function
)));
1126 print_return_value (struct_return
, value_type
);
1128 do_exec_cleanups (cleanups
);
1131 /* "finish": Set a temporary breakpoint at the place
1132 the selected frame will return to, then continue. */
1135 finish_command (char *arg
, int from_tty
)
1137 struct symtab_and_line sal
;
1138 register struct frame_info
*frame
;
1139 register struct symbol
*function
;
1140 struct breakpoint
*breakpoint
;
1141 struct cleanup
*old_chain
;
1142 struct continuation_arg
*arg1
, *arg2
, *arg3
;
1146 /* Find out whether we must run in the background. */
1148 async_exec
= strip_bg_char (&arg
);
1150 /* If we must run in the background, but the target can't do it,
1152 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
1153 error ("Asynchronous execution not supported on this target.");
1155 /* If we are not asked to run in the bg, then prepare to run in the
1156 foreground, synchronously. */
1157 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
1159 /* Simulate synchronous execution */
1160 async_disable_stdin ();
1164 error ("The \"finish\" command does not take any arguments.");
1165 if (!target_has_execution
)
1166 error ("The program is not running.");
1167 if (selected_frame
== NULL
)
1168 error ("No selected frame.");
1170 frame
= get_prev_frame (selected_frame
);
1172 error ("\"finish\" not meaningful in the outermost frame.");
1174 clear_proceed_status ();
1176 sal
= find_pc_line (frame
->pc
, 0);
1179 breakpoint
= set_momentary_breakpoint (sal
, frame
, bp_finish
);
1181 if (!event_loop_p
|| !target_can_async_p ())
1182 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1184 old_chain
= make_exec_cleanup_delete_breakpoint (breakpoint
);
1186 /* Find the function we will return from. */
1188 function
= find_pc_function (selected_frame
->pc
);
1190 /* Print info on the selected frame, including level number
1194 printf_filtered ("Run till exit from ");
1195 print_stack_frame (selected_frame
, selected_frame_level
, 0);
1198 /* If running asynchronously and the target support asynchronous
1199 execution, set things up for the rest of the finish command to be
1200 completed later on, when gdb has detected that the target has
1201 stopped, in fetch_inferior_event. */
1202 if (event_loop_p
&& target_can_async_p ())
1205 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1207 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1209 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1213 arg1
->data
.pointer
= breakpoint
;
1214 arg2
->data
.pointer
= function
;
1215 arg3
->data
.pointer
= old_chain
;
1216 add_continuation (finish_command_continuation
, arg1
);
1219 proceed_to_finish
= 1; /* We want stop_registers, please... */
1220 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1222 /* Do this only if not running asynchronously or if the target
1223 cannot do async execution. Otherwise, complete this command when
1224 the target actually stops, in fetch_inferior_event. */
1225 if (!event_loop_p
|| !target_can_async_p ())
1228 /* Did we stop at our breakpoint? */
1229 if (bpstat_find_breakpoint (stop_bpstat
, breakpoint
) != NULL
1232 struct type
*value_type
;
1236 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (function
));
1238 internal_error (__FILE__
, __LINE__
,
1239 "finish_command: function has no target type");
1241 /* FIXME: Shouldn't we do the cleanups before returning? */
1242 if (TYPE_CODE (value_type
) == TYPE_CODE_VOID
)
1245 funcaddr
= BLOCK_START (SYMBOL_BLOCK_VALUE (function
));
1248 using_struct_return (value_of_variable (function
, NULL
),
1250 check_typedef (value_type
),
1251 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function
)));
1253 print_return_value (struct_return
, value_type
);
1255 do_cleanups (old_chain
);
1261 program_info (char *args
, int from_tty
)
1263 bpstat bs
= stop_bpstat
;
1264 int num
= bpstat_num (&bs
);
1266 if (!target_has_execution
)
1268 printf_filtered ("The program being debugged is not being run.\n");
1272 target_files_info ();
1273 printf_filtered ("Program stopped at %s.\n",
1274 local_hex_string ((unsigned long) stop_pc
));
1276 printf_filtered ("It stopped after being stepped.\n");
1279 /* There may be several breakpoints in the same place, so this
1280 isn't as strange as it seems. */
1285 printf_filtered ("It stopped at a breakpoint that has ");
1286 printf_filtered ("since been deleted.\n");
1289 printf_filtered ("It stopped at breakpoint %d.\n", num
);
1290 num
= bpstat_num (&bs
);
1293 else if (stop_signal
!= TARGET_SIGNAL_0
)
1295 printf_filtered ("It stopped with signal %s, %s.\n",
1296 target_signal_to_name (stop_signal
),
1297 target_signal_to_string (stop_signal
));
1302 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1303 printf_filtered ("for more information.\n");
1308 environment_info (char *var
, int from_tty
)
1312 register char *val
= get_in_environ (inferior_environ
, var
);
1315 puts_filtered (var
);
1316 puts_filtered (" = ");
1317 puts_filtered (val
);
1318 puts_filtered ("\n");
1322 puts_filtered ("Environment variable \"");
1323 puts_filtered (var
);
1324 puts_filtered ("\" not defined.\n");
1329 register char **vector
= environ_vector (inferior_environ
);
1332 puts_filtered (*vector
++);
1333 puts_filtered ("\n");
1339 set_environment_command (char *arg
, int from_tty
)
1341 register char *p
, *val
, *var
;
1345 error_no_arg ("environment variable and value");
1347 /* Find seperation between variable name and value */
1348 p
= (char *) strchr (arg
, '=');
1349 val
= (char *) strchr (arg
, ' ');
1351 if (p
!= 0 && val
!= 0)
1353 /* We have both a space and an equals. If the space is before the
1354 equals, walk forward over the spaces til we see a nonspace
1355 (possibly the equals). */
1360 /* Now if the = is after the char following the spaces,
1361 take the char following the spaces. */
1365 else if (val
!= 0 && p
== 0)
1369 error_no_arg ("environment variable to set");
1371 if (p
== 0 || p
[1] == 0)
1375 p
= arg
+ strlen (arg
); /* So that savestring below will work */
1379 /* Not setting variable value to null */
1381 while (*val
== ' ' || *val
== '\t')
1385 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1388 var
= savestring (arg
, p
- arg
);
1391 printf_filtered ("Setting environment variable ");
1392 printf_filtered ("\"%s\" to null value.\n", var
);
1393 set_in_environ (inferior_environ
, var
, "");
1396 set_in_environ (inferior_environ
, var
, val
);
1401 unset_environment_command (char *var
, int from_tty
)
1405 /* If there is no argument, delete all environment variables.
1406 Ask for confirmation if reading from the terminal. */
1407 if (!from_tty
|| query ("Delete all environment variables? "))
1409 free_environ (inferior_environ
);
1410 inferior_environ
= make_environ ();
1414 unset_in_environ (inferior_environ
, var
);
1417 /* Handle the execution path (PATH variable) */
1419 static const char path_var_name
[] = "PATH";
1423 path_info (char *args
, int from_tty
)
1425 puts_filtered ("Executable and object file path: ");
1426 puts_filtered (get_in_environ (inferior_environ
, path_var_name
));
1427 puts_filtered ("\n");
1430 /* Add zero or more directories to the front of the execution path. */
1433 path_command (char *dirname
, int from_tty
)
1438 env
= get_in_environ (inferior_environ
, path_var_name
);
1439 /* Can be null if path is not set */
1442 exec_path
= xstrdup (env
);
1443 mod_path (dirname
, &exec_path
);
1444 set_in_environ (inferior_environ
, path_var_name
, exec_path
);
1447 path_info ((char *) NULL
, from_tty
);
1451 #ifdef REGISTER_NAMES
1452 char *gdb_register_names
[] = REGISTER_NAMES
;
1454 /* Print out the machine register regnum. If regnum is -1,
1455 print all registers (fpregs == 1) or all non-float registers
1458 For most machines, having all_registers_info() print the
1459 register(s) one per line is good enough. If a different format
1460 is required, (eg, for MIPS or Pyramid 90x, which both have
1461 lots of regs), or there is an existing convention for showing
1462 all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
1463 to provide that format. */
1466 do_registers_info (int regnum
, int fpregs
)
1469 int numregs
= NUM_REGS
+ NUM_PSEUDO_REGS
;
1471 for (i
= 0; i
< numregs
; i
++)
1473 char *raw_buffer
= (char*) alloca (MAX_REGISTER_RAW_SIZE
);
1474 char *virtual_buffer
= (char*) alloca (MAX_REGISTER_VIRTUAL_SIZE
);
1476 /* Decide between printing all regs, nonfloat regs, or specific reg. */
1479 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
&& !fpregs
)
1488 /* If the register name is empty, it is undefined for this
1489 processor, so don't display anything. */
1490 if (REGISTER_NAME (i
) == NULL
|| *(REGISTER_NAME (i
)) == '\0')
1493 fputs_filtered (REGISTER_NAME (i
), gdb_stdout
);
1494 print_spaces_filtered (15 - strlen (REGISTER_NAME (i
)), gdb_stdout
);
1496 /* Get the data in raw format. */
1497 if (read_relative_register_raw_bytes (i
, raw_buffer
))
1499 printf_filtered ("*value not available*\n");
1503 /* Convert raw data to virtual format if necessary. */
1504 if (REGISTER_CONVERTIBLE (i
))
1506 REGISTER_CONVERT_TO_VIRTUAL (i
, REGISTER_VIRTUAL_TYPE (i
),
1507 raw_buffer
, virtual_buffer
);
1511 memcpy (virtual_buffer
, raw_buffer
,
1512 REGISTER_VIRTUAL_SIZE (i
));
1515 /* If virtual format is floating, print it that way, and in raw hex. */
1516 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
1520 #ifdef INVALID_FLOAT
1521 if (INVALID_FLOAT (virtual_buffer
, REGISTER_VIRTUAL_SIZE (i
)))
1522 printf_filtered ("<invalid float>");
1525 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1526 gdb_stdout
, 0, 1, 0, Val_pretty_default
);
1528 printf_filtered ("\t(raw 0x");
1529 for (j
= 0; j
< REGISTER_RAW_SIZE (i
); j
++)
1531 register int idx
= TARGET_BYTE_ORDER
== BIG_ENDIAN
? j
1532 : REGISTER_RAW_SIZE (i
) - 1 - j
;
1533 printf_filtered ("%02x", (unsigned char) raw_buffer
[idx
]);
1535 printf_filtered (")");
1538 /* FIXME! val_print probably can handle all of these cases now... */
1540 /* Else if virtual format is too long for printf,
1541 print in hex a byte at a time. */
1542 else if (REGISTER_VIRTUAL_SIZE (i
) > (int) sizeof (long))
1545 printf_filtered ("0x");
1546 for (j
= 0; j
< REGISTER_VIRTUAL_SIZE (i
); j
++)
1547 printf_filtered ("%02x", (unsigned char) virtual_buffer
[j
]);
1549 /* Else print as integer in hex and in decimal. */
1552 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1553 gdb_stdout
, 'x', 1, 0, Val_pretty_default
);
1554 printf_filtered ("\t");
1555 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1556 gdb_stdout
, 0, 1, 0, Val_pretty_default
);
1559 /* The SPARC wants to print even-numbered float regs as doubles
1560 in addition to printing them as floats. */
1561 #ifdef PRINT_REGISTER_HOOK
1562 PRINT_REGISTER_HOOK (i
);
1565 printf_filtered ("\n");
1570 registers_info (char *addr_exp
, int fpregs
)
1572 int regnum
, numregs
;
1575 if (!target_has_registers
)
1576 error ("The program has no registers now.");
1577 if (selected_frame
== NULL
)
1578 error ("No selected frame.");
1582 DO_REGISTERS_INFO (-1, fpregs
);
1588 if (addr_exp
[0] == '$')
1591 while (*end
!= '\0' && *end
!= ' ' && *end
!= '\t')
1593 numregs
= NUM_REGS
+ NUM_PSEUDO_REGS
;
1595 regnum
= target_map_name_to_register (addr_exp
, end
- addr_exp
);
1601 if (*addr_exp
>= '0' && *addr_exp
<= '9')
1602 regnum
= atoi (addr_exp
); /* Take a number */
1603 if (regnum
>= numregs
) /* Bad name, or bad number */
1604 error ("%.*s: invalid register", end
- addr_exp
, addr_exp
);
1607 DO_REGISTERS_INFO (regnum
, fpregs
);
1610 while (*addr_exp
== ' ' || *addr_exp
== '\t')
1613 while (*addr_exp
!= '\0');
1617 all_registers_info (char *addr_exp
, int from_tty
)
1619 registers_info (addr_exp
, 1);
1623 nofp_registers_info (char *addr_exp
, int from_tty
)
1625 registers_info (addr_exp
, 0);
1631 * Should save/restore the tty state since it might be that the
1632 * program to be debugged was started on this tty and it wants
1633 * the tty in some state other than what we want. If it's running
1634 * on another terminal or without a terminal, then saving and
1635 * restoring the tty state is a harmless no-op.
1636 * This only needs to be done if we are attaching to a process.
1641 takes a program started up outside of gdb and ``attaches'' to it.
1642 This stops it cold in its tracks and allows us to start debugging it.
1643 and wait for the trace-trap that results from attaching. */
1646 attach_command (char *args
, int from_tty
)
1649 extern int auto_solib_add
;
1653 char *full_exec_path
= NULL
;
1655 dont_repeat (); /* Not for the faint of heart */
1657 if (target_has_execution
)
1659 if (query ("A program is being debugged already. Kill it? "))
1662 error ("Not killed.");
1665 target_attach (args
, from_tty
);
1667 /* Set up the "saved terminal modes" of the inferior
1668 based on what modes we are starting it with. */
1669 target_terminal_init ();
1671 /* Install inferior's terminal modes. */
1672 target_terminal_inferior ();
1674 /* Set up execution context to know that we should return from
1675 wait_for_inferior as soon as the target reports a stop. */
1676 init_wait_for_inferior ();
1677 clear_proceed_status ();
1679 /* No traps are generated when attaching to inferior under Mach 3
1681 #ifndef ATTACH_NO_WAIT
1682 stop_soon_quietly
= 1;
1683 wait_for_inferior ();
1687 * If no exec file is yet known, try to determine it from the
1690 exec_file
= (char *) get_exec_file (0);
1693 exec_file
= target_pid_to_exec_file (inferior_pid
);
1696 /* It's possible we don't have a full path, but rather just a
1697 filename. Some targets, such as HP-UX, don't provide the
1700 Attempt to qualify the filename against the source path.
1701 (If that fails, we'll just fall back on the original
1702 filename. Not much more we can do...)
1704 if (!source_full_path_of (exec_file
, &full_exec_path
))
1705 full_exec_path
= savestring (exec_file
, strlen (exec_file
));
1707 exec_file_attach (full_exec_path
, from_tty
);
1708 symbol_file_add_main (full_exec_path
, from_tty
);
1715 /* Add shared library symbols from the newly attached process, if any. */
1716 SOLIB_ADD ((char *) 0, from_tty
, ¤t_target
);
1717 re_enable_breakpoints_in_shlibs ();
1721 /* Take any necessary post-attaching actions for this platform.
1723 target_post_attach (inferior_pid
);
1733 * takes a program previously attached to and detaches it.
1734 * The program resumes execution and will no longer stop
1735 * on signals, etc. We better not have left any breakpoints
1736 * in the program or it'll die when it hits one. For this
1737 * to work, it may be necessary for the process to have been
1738 * previously attached. It *might* work if the program was
1739 * started via the normal ptrace (PTRACE_TRACEME).
1743 detach_command (char *args
, int from_tty
)
1745 dont_repeat (); /* Not for the faint of heart */
1746 target_detach (args
, from_tty
);
1747 #if defined(SOLIB_RESTART)
1754 /* Stop the execution of the target while running in async mode, in
1758 interrupt_target_command_wrapper (char *args
, int from_tty
)
1760 interrupt_target_command (args
, from_tty
);
1764 interrupt_target_command (char *args
, int from_tty
)
1766 if (event_loop_p
&& target_can_async_p ())
1768 dont_repeat (); /* Not for the faint of heart */
1775 float_info (char *addr_exp
, int from_tty
)
1780 printf_filtered ("No floating point info available for this processor.\n");
1786 unset_command (char *args
, int from_tty
)
1788 printf_filtered ("\"unset\" must be followed by the name of ");
1789 printf_filtered ("an unset subcommand.\n");
1790 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
1794 _initialize_infcmd (void)
1796 struct cmd_list_element
*c
;
1798 c
= add_com ("tty", class_run
, tty_command
,
1799 "Set terminal for future runs of program being debugged.");
1800 c
->completer
= filename_completer
;
1802 c
= add_set_cmd ("args", class_run
, var_string_noescape
,
1803 (char *) &inferior_args
,
1804 "Set argument list to give program being debugged when it is started.\n\
1805 Follow this command with any number of args, to be passed to the program.",
1807 add_show_from_set (c
, &showlist
);
1808 c
->completer
= filename_completer
;
1811 ("environment", no_class
, environment_info
,
1812 "The environment to give the program, or one variable's value.\n\
1813 With an argument VAR, prints the value of environment variable VAR to\n\
1814 give the program being debugged. With no arguments, prints the entire\n\
1815 environment to be given to the program.", &showlist
);
1816 c
->completer
= noop_completer
;
1818 add_prefix_cmd ("unset", no_class
, unset_command
,
1819 "Complement to certain \"set\" commands",
1820 &unsetlist
, "unset ", 0, &cmdlist
);
1822 c
= add_cmd ("environment", class_run
, unset_environment_command
,
1823 "Cancel environment variable VAR for the program.\n\
1824 This does not affect the program until the next \"run\" command.",
1826 c
->completer
= noop_completer
;
1828 c
= add_cmd ("environment", class_run
, set_environment_command
,
1829 "Set environment variable value to give the program.\n\
1830 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
1831 VALUES of environment variables are uninterpreted strings.\n\
1832 This does not affect the program until the next \"run\" command.",
1834 c
->completer
= noop_completer
;
1836 c
= add_com ("path", class_files
, path_command
,
1837 "Add directory DIR(s) to beginning of search path for object files.\n\
1838 $cwd in the path means the current working directory.\n\
1839 This path is equivalent to the $PATH shell variable. It is a list of\n\
1840 directories, separated by colons. These directories are searched to find\n\
1841 fully linked executable files and separately compiled object files as needed.");
1842 c
->completer
= filename_completer
;
1844 c
= add_cmd ("paths", no_class
, path_info
,
1845 "Current search path for finding object files.\n\
1846 $cwd in the path means the current working directory.\n\
1847 This path is equivalent to the $PATH shell variable. It is a list of\n\
1848 directories, separated by colons. These directories are searched to find\n\
1849 fully linked executable files and separately compiled object files as needed.",
1851 c
->completer
= noop_completer
;
1853 add_com ("attach", class_run
, attach_command
,
1854 "Attach to a process or file outside of GDB.\n\
1855 This command attaches to another target, of the same type as your last\n\
1856 \"target\" command (\"info files\" will show your target stack).\n\
1857 The command may take as argument a process id or a device file.\n\
1858 For a process id, you must have permission to send the process a signal,\n\
1859 and it must have the same effective uid as the debugger.\n\
1860 When using \"attach\" with a process id, the debugger finds the\n\
1861 program running in the process, looking first in the current working\n\
1862 directory, or (if not found there) using the source file search path\n\
1863 (see the \"directory\" command). You can also use the \"file\" command\n\
1864 to specify the program, and to load its symbol table.");
1866 add_com ("detach", class_run
, detach_command
,
1867 "Detach a process or file previously attached.\n\
1868 If a process, it is no longer traced, and it continues its execution. If\n\
1869 you were debugging a file, the file is closed and gdb no longer accesses it.");
1871 add_com ("signal", class_run
, signal_command
,
1872 "Continue program giving it signal specified by the argument.\n\
1873 An argument of \"0\" means continue program without giving it a signal.");
1875 add_com ("stepi", class_run
, stepi_command
,
1876 "Step one instruction exactly.\n\
1877 Argument N means do this N times (or till program stops for another reason).");
1878 add_com_alias ("si", "stepi", class_alias
, 0);
1880 add_com ("nexti", class_run
, nexti_command
,
1881 "Step one instruction, but proceed through subroutine calls.\n\
1882 Argument N means do this N times (or till program stops for another reason).");
1883 add_com_alias ("ni", "nexti", class_alias
, 0);
1885 add_com ("finish", class_run
, finish_command
,
1886 "Execute until selected stack frame returns.\n\
1887 Upon return, the value returned is printed and put in the value history.");
1889 add_com ("next", class_run
, next_command
,
1890 "Step program, proceeding through subroutine calls.\n\
1891 Like the \"step\" command as long as subroutine calls do not happen;\n\
1892 when they do, the call is treated as one instruction.\n\
1893 Argument N means do this N times (or till program stops for another reason).");
1894 add_com_alias ("n", "next", class_run
, 1);
1896 add_com_alias ("S", "next", class_run
, 1);
1898 add_com ("step", class_run
, step_command
,
1899 "Step program until it reaches a different source line.\n\
1900 Argument N means do this N times (or till program stops for another reason).");
1901 add_com_alias ("s", "step", class_run
, 1);
1903 add_com ("until", class_run
, until_command
,
1904 "Execute until the program reaches a source line greater than the current\n\
1905 or a specified line or address or function (same args as break command).\n\
1906 Execution will also stop upon exit from the current stack frame.");
1907 add_com_alias ("u", "until", class_run
, 1);
1909 add_com ("jump", class_run
, jump_command
,
1910 "Continue program being debugged at specified line or address.\n\
1911 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
1912 for an address to start at.");
1915 add_com ("go", class_run
, go_command
,
1916 "Usage: go <location>\n\
1917 Continue program being debugged, stopping at specified line or \n\
1919 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
1920 expression for an address to start at.\n\
1921 This command is a combination of tbreak and jump.");
1924 add_com_alias ("g", "go", class_run
, 1);
1926 add_com ("continue", class_run
, continue_command
,
1927 "Continue program being debugged, after signal or breakpoint.\n\
1928 If proceeding from breakpoint, a number N may be used as an argument,\n\
1929 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
1930 the breakpoint won't break until the Nth time it is reached).");
1931 add_com_alias ("c", "cont", class_run
, 1);
1932 add_com_alias ("fg", "cont", class_run
, 1);
1934 c
= add_com ("run", class_run
, run_command
,
1935 "Start debugged program. You may specify arguments to give it.\n\
1936 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
1937 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
1938 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
1939 To cancel previous arguments and run with no arguments,\n\
1940 use \"set args\" without arguments.");
1941 c
->completer
= filename_completer
;
1942 add_com_alias ("r", "run", class_run
, 1);
1944 add_com ("R", class_run
, run_no_args_command
,
1945 "Start debugged program with no arguments.");
1947 add_com ("interrupt", class_run
, interrupt_target_command
,
1948 "Interrupt the execution of the debugged program.");
1950 add_info ("registers", 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_alias ("r", "registers", 1);
1956 add_com ("lr", class_info
, nofp_registers_info
,
1957 "List of integer registers and their contents, for selected stack frame.\n\
1958 Register name as argument means describe only that register.");
1959 add_info ("all-registers", all_registers_info
,
1960 "List of all registers and their contents, for selected stack frame.\n\
1961 Register name as argument means describe only that register.");
1963 add_info ("program", program_info
,
1964 "Execution status of the program.");
1966 add_info ("float", float_info
,
1967 "Print the status of the floating point unit\n");
1969 set_inferior_args (xstrdup ("")); /* Initially no args */
1970 inferior_environ
= make_environ ();
1971 init_environ (inferior_environ
);