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"
40 #include "event-top.h"
41 #include "parser-defs.h"
43 /* Functions exported for general use: */
45 void nofp_registers_info
PARAMS ((char *, int));
47 void all_registers_info
PARAMS ((char *, int));
49 void registers_info
PARAMS ((char *, int));
51 /* Local functions: */
53 void continue_command
PARAMS ((char *, int));
55 static void print_return_value (int struct_return
, struct type
*value_type
);
57 static void finish_command_continuation
PARAMS ((struct continuation_arg
*));
59 static void until_next_command
PARAMS ((int));
61 static void until_command
PARAMS ((char *, int));
63 static void path_info
PARAMS ((char *, int));
65 static void path_command
PARAMS ((char *, int));
67 static void unset_command
PARAMS ((char *, int));
69 static void float_info
PARAMS ((char *, int));
71 static void detach_command
PARAMS ((char *, int));
73 static void interrupt_target_command (char *args
, int from_tty
);
75 #if !defined (DO_REGISTERS_INFO)
76 static void do_registers_info
PARAMS ((int, int));
79 static void unset_environment_command
PARAMS ((char *, int));
81 static void set_environment_command
PARAMS ((char *, int));
83 static void environment_info
PARAMS ((char *, int));
85 static void program_info
PARAMS ((char *, int));
87 static void finish_command
PARAMS ((char *, int));
89 static void signal_command
PARAMS ((char *, int));
91 static void jump_command
PARAMS ((char *, int));
93 static void step_1
PARAMS ((int, int, char *));
94 static void step_once (int skip_subroutines
, int single_inst
, int count
);
95 static void step_1_continuation (struct continuation_arg
*arg
);
97 void nexti_command
PARAMS ((char *, int));
99 void stepi_command
PARAMS ((char *, int));
101 static void next_command
PARAMS ((char *, int));
103 static void step_command
PARAMS ((char *, int));
105 static void run_command
PARAMS ((char *, int));
107 static void run_no_args_command
PARAMS ((char *args
, int from_tty
));
109 static void go_command
PARAMS ((char *line_no
, int from_tty
));
111 static int strip_bg_char
PARAMS ((char **));
113 void _initialize_infcmd
PARAMS ((void));
115 #define GO_USAGE "Usage: go <location>\n"
117 static void breakpoint_auto_delete_contents
PARAMS ((PTR
));
119 #define ERROR_NO_INFERIOR \
120 if (!target_has_execution) error ("The program is not being run.");
122 /* String containing arguments to give to the program, separated by spaces.
123 Empty string (pointer to '\0') means no args. */
125 static char *inferior_args
;
127 /* File name for default use for standard in/out in the inferior. */
129 char *inferior_io_terminal
;
131 /* Pid of our debugged inferior, or 0 if no inferior now.
132 Since various parts of infrun.c test this to see whether there is a program
133 being debugged it should be nonzero (currently 3 is used) for remote
138 /* Last signal that the inferior received (why it stopped). */
140 enum target_signal stop_signal
;
142 /* Address at which inferior stopped. */
146 /* Chain containing status of breakpoint(s) that we have stopped at. */
150 /* Flag indicating that a command has proceeded the inferior past the
151 current breakpoint. */
153 int breakpoint_proceeded
;
155 /* Nonzero if stopped due to a step command. */
159 /* Nonzero if stopped due to completion of a stack dummy routine. */
161 int stop_stack_dummy
;
163 /* Nonzero if stopped due to a random (unexpected) signal in inferior
166 int stopped_by_random_signal
;
168 /* Range to single step within.
169 If this is nonzero, respond to a single-step signal
170 by continuing to step if the pc is in this range. */
172 CORE_ADDR step_range_start
; /* Inclusive */
173 CORE_ADDR step_range_end
; /* Exclusive */
175 /* Stack frame address as of when stepping command was issued.
176 This is how we know when we step into a subroutine call,
177 and how to set the frame for the breakpoint used to step out. */
179 CORE_ADDR step_frame_address
;
181 /* Our notion of the current stack pointer. */
185 /* 1 means step over all subroutine calls.
186 0 means don't step over calls (used by stepi).
187 -1 means step over calls to undebuggable functions. */
191 /* If stepping, nonzero means step count is > 1
192 so don't print frame next time inferior stops
193 if it stops due to stepping. */
197 /* Environment to use for running inferior,
198 in format described in environ.h. */
200 struct environ
*inferior_environ
;
203 /* This function detects whether or not a '&' character (indicating
204 background execution) has been added as *the last* of the arguments ARGS
205 of a command. If it has, it removes it and returns 1. Otherwise it
206 does nothing and returns 0. */
213 p
= strchr (*args
, '&');
217 if (p
== (*args
+ strlen (*args
) - 1))
219 if (strlen (*args
) > 1)
223 while (*p
== ' ' || *p
== '\t');
236 tty_command (file
, from_tty
)
241 error_no_arg ("terminal name for running target process");
243 inferior_io_terminal
= savestring (file
, strlen (file
));
247 run_command (args
, from_tty
)
255 if (inferior_pid
!= 0 && target_has_execution
)
258 && !query ("The program being debugged has been started already.\n\
259 Start it from the beginning? "))
260 error ("Program not restarted.");
262 #if defined(SOLIB_RESTART)
265 init_wait_for_inferior ();
268 clear_breakpoint_hit_counts ();
270 exec_file
= (char *) get_exec_file (0);
272 /* Purge old solib objfiles. */
273 objfile_purge_solibs ();
275 do_run_cleanups (NULL
);
277 /* The exec file is re-read every time we do a generic_mourn_inferior, so
278 we just have to worry about the symbol file. */
281 /* We keep symbols from add-symbol-file, on the grounds that the
282 user might want to add some symbols before running the program
283 (right?). But sometimes (dynamic loading where the user manually
284 introduces the new symbols with add-symbol-file), the code which
285 the symbols describe does not persist between runs. Currently
286 the user has to manually nuke all symbols between runs if they
287 want them to go away (PR 2207). This is probably reasonable. */
291 if (event_loop_p
&& target_can_async_p ())
292 async_disable_stdin ();
297 int async_exec
= strip_bg_char (&args
);
299 /* If we get a request for running in the bg but the target
300 doesn't support it, error out. */
301 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
302 error ("Asynchronous execution not supported on this target.");
304 /* If we don't get a request of running in the bg, then we need
305 to simulate synchronous (fg) execution. */
306 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
308 /* Simulate synchronous execution */
309 async_disable_stdin ();
312 /* If there were other args, beside '&', process them. */
315 cmd
= concat ("set args ", args
, NULL
);
316 make_cleanup (free
, cmd
);
317 execute_command (cmd
, from_tty
);
324 ui_out_field_string (uiout
, NULL
, "Starting program");
325 ui_out_text (uiout
, ": ");
327 ui_out_field_string (uiout
, "execfile", exec_file
);
328 ui_out_spaces (uiout
, 1);
329 ui_out_field_string (uiout
, "infargs", inferior_args
);
330 ui_out_text (uiout
, "\n");
331 ui_out_flush (uiout
);
333 puts_filtered ("Starting program: ");
335 puts_filtered (exec_file
);
337 puts_filtered (inferior_args
);
338 puts_filtered ("\n");
339 gdb_flush (gdb_stdout
);
343 target_create_inferior (exec_file
, inferior_args
,
344 environ_vector (inferior_environ
));
349 run_no_args_command (args
, from_tty
)
353 execute_command ("set args", from_tty
);
354 run_command ((char *) NULL
, from_tty
);
359 continue_command (proc_count_exp
, from_tty
)
360 char *proc_count_exp
;
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_address (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 (count_string
, from_tty
)
423 step_1 (0, 0, count_string
);
426 /* Likewise, but skip over subroutine calls as if single instructions. */
430 next_command (count_string
, from_tty
)
434 step_1 (1, 0, count_string
);
437 /* Likewise, but step only one instruction. */
441 stepi_command (count_string
, from_tty
)
445 step_1 (0, 1, count_string
);
450 nexti_command (count_string
, from_tty
)
454 step_1 (1, 1, count_string
);
458 step_1 (skip_subroutines
, single_inst
, count_string
)
459 int skip_subroutines
;
463 register int count
= 1;
464 struct frame_info
*frame
;
465 struct cleanup
*cleanups
= 0;
471 async_exec
= strip_bg_char (&count_string
);
473 /* If we get a request for running in the bg but the target
474 doesn't support it, error out. */
475 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
476 error ("Asynchronous execution not supported on this target.");
478 /* If we don't get a request of running in the bg, then we need
479 to simulate synchronous (fg) execution. */
480 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
482 /* Simulate synchronous execution */
483 async_disable_stdin ();
486 count
= count_string
? parse_and_eval_address (count_string
) : 1;
488 if (!single_inst
|| skip_subroutines
) /* leave si command alone */
490 enable_longjmp_breakpoint ();
491 if (!event_loop_p
|| !target_can_async_p ())
492 cleanups
= make_cleanup ((make_cleanup_func
) disable_longjmp_breakpoint
,
495 make_exec_cleanup ((make_cleanup_func
) disable_longjmp_breakpoint
, 0);
498 /* In synchronous case, all is well, just use the regular for loop. */
499 if (!event_loop_p
|| !target_can_async_p ())
501 for (; count
> 0; count
--)
503 clear_proceed_status ();
505 frame
= get_current_frame ();
506 if (!frame
) /* Avoid coredump here. Why tho? */
507 error ("No current frame");
508 step_frame_address
= FRAME_FP (frame
);
509 step_sp
= read_sp ();
513 find_pc_line_pc_range (stop_pc
, &step_range_start
, &step_range_end
);
514 if (step_range_end
== 0)
517 if (find_pc_partial_function (stop_pc
, &name
, &step_range_start
,
518 &step_range_end
) == 0)
519 error ("Cannot find bounds of current function");
521 target_terminal_ours ();
523 Single stepping until exit from function %s, \n\
524 which has no line number information.\n", name
);
529 /* Say we are stepping, but stop after one insn whatever it does. */
530 step_range_start
= step_range_end
= 1;
531 if (!skip_subroutines
)
533 Don't step over function calls, not even to functions lacking
538 if (skip_subroutines
)
541 step_multi
= (count
> 1);
542 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
547 /* FIXME: On nexti, this may have already been done (when we hit the
548 step resume break, I think). Probably this should be moved to
549 wait_for_inferior (near the top). */
550 #if defined (SHIFT_INST_REGS)
555 if (!single_inst
|| skip_subroutines
)
556 do_cleanups (cleanups
);
559 /* In case of asynchronous target things get complicated, do only
560 one step for now, before returning control to the event loop. Let
561 the continuation figure out how many other steps we need to do,
562 and handle them one at the time, through step_once(). */
565 if (event_loop_p
&& target_can_async_p ())
566 step_once (skip_subroutines
, single_inst
, count
);
570 /* Called after we are done with one step operation, to check whether
571 we need to step again, before we print the prompt and return control
572 to the user. If count is > 1, we will need to do one more call to
573 proceed(), via step_once(). Basically it is like step_once and
574 step_1_continuation are co-recursive. */
576 step_1_continuation (arg
)
577 struct continuation_arg
*arg
;
580 int skip_subroutines
;
583 skip_subroutines
= (int) arg
->data
;
584 single_inst
= (int) (arg
->next
)->data
;
585 count
= (int) ((arg
->next
)->next
)->data
;
589 /* FIXME: On nexti, this may have already been done (when we hit the
590 step resume break, I think). Probably this should be moved to
591 wait_for_inferior (near the top). */
592 #if defined (SHIFT_INST_REGS)
595 step_once (skip_subroutines
, single_inst
, count
- 1);
598 if (!single_inst
|| skip_subroutines
)
599 do_exec_cleanups (ALL_CLEANUPS
);
602 /* Do just one step operation. If count >1 we will have to set up a
603 continuation to be done after the target stops (after this one
604 step). This is useful to implement the 'step n' kind of commands, in
605 case of asynchronous targets. We had to split step_1 into two parts,
606 one to be done before proceed() and one afterwards. This function is
607 called in case of step n with n>1, after the first step operation has
610 step_once (int skip_subroutines
, int single_inst
, int count
)
612 struct continuation_arg
*arg1
;
613 struct continuation_arg
*arg2
;
614 struct continuation_arg
*arg3
;
615 struct frame_info
*frame
;
619 clear_proceed_status ();
621 frame
= get_current_frame ();
622 if (!frame
) /* Avoid coredump here. Why tho? */
623 error ("No current frame");
624 step_frame_address
= FRAME_FP (frame
);
625 step_sp
= read_sp ();
629 find_pc_line_pc_range (stop_pc
, &step_range_start
, &step_range_end
);
630 if (step_range_end
== 0)
633 if (find_pc_partial_function (stop_pc
, &name
, &step_range_start
,
634 &step_range_end
) == 0)
635 error ("Cannot find bounds of current function");
637 target_terminal_ours ();
639 Single stepping until exit from function %s, \n\
640 which has no line number information.\n", name
);
645 /* Say we are stepping, but stop after one insn whatever it does. */
646 step_range_start
= step_range_end
= 1;
647 if (!skip_subroutines
)
649 Don't step over function calls, not even to functions lacking
654 if (skip_subroutines
)
657 step_multi
= (count
> 1);
659 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
661 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
663 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
665 arg1
->data
= (PTR
) skip_subroutines
;
667 arg2
->data
= (PTR
) single_inst
;
669 arg3
->data
= (PTR
) count
;
670 add_intermediate_continuation (step_1_continuation
, arg1
);
671 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
676 /* Continue program at specified address. */
679 jump_command (arg
, from_tty
)
683 register CORE_ADDR addr
;
684 struct symtabs_and_lines sals
;
685 struct symtab_and_line sal
;
692 /* Find out whether we must run in the background. */
694 async_exec
= strip_bg_char (&arg
);
696 /* If we must run in the background, but the target can't do it,
698 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
699 error ("Asynchronous execution not supported on this target.");
701 /* If we are not asked to run in the bg, then prepare to run in the
702 foreground, synchronously. */
703 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
705 /* Simulate synchronous execution */
706 async_disable_stdin ();
710 error_no_arg ("starting address");
712 sals
= decode_line_spec_1 (arg
, 1);
715 error ("Unreasonable jump request");
719 free ((PTR
) sals
.sals
);
721 if (sal
.symtab
== 0 && sal
.pc
== 0)
722 error ("No source file has been specified.");
724 resolve_sal_pc (&sal
); /* May error out */
726 /* See if we are trying to jump to another function. */
727 fn
= get_frame_function (get_current_frame ());
728 sfn
= find_pc_function (sal
.pc
);
729 if (fn
!= NULL
&& sfn
!= fn
)
731 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal
.line
,
732 SYMBOL_SOURCE_NAME (fn
)))
734 error ("Not confirmed.");
741 fixup_symbol_section (sfn
, 0);
742 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn
)) &&
743 !section_is_mapped (SYMBOL_BFD_SECTION (sfn
)))
745 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
747 error ("Not confirmed.");
757 printf_filtered ("Continuing at ");
758 print_address_numeric (addr
, 1, gdb_stdout
);
759 printf_filtered (".\n");
762 clear_proceed_status ();
763 proceed (addr
, TARGET_SIGNAL_0
, 0);
767 /* Go to line or address in current procedure */
769 go_command (line_no
, from_tty
)
773 if (line_no
== (char *) NULL
|| !*line_no
)
774 printf_filtered (GO_USAGE
);
777 tbreak_command (line_no
, from_tty
);
778 jump_command (line_no
, from_tty
);
783 /* Continue program giving it specified signal. */
786 signal_command (signum_exp
, from_tty
)
790 enum target_signal oursig
;
792 dont_repeat (); /* Too dangerous. */
796 error_no_arg ("signal number");
798 /* It would be even slicker to make signal names be valid expressions,
799 (the type could be "enum $signal" or some such), then the user could
800 assign them to convenience variables. */
801 oursig
= target_signal_from_name (signum_exp
);
803 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
805 /* No, try numeric. */
806 int num
= parse_and_eval_address (signum_exp
);
809 oursig
= TARGET_SIGNAL_0
;
811 oursig
= target_signal_from_command (num
);
816 if (oursig
== TARGET_SIGNAL_0
)
817 printf_filtered ("Continuing with no signal.\n");
819 printf_filtered ("Continuing with signal %s.\n",
820 target_signal_to_name (oursig
));
823 clear_proceed_status ();
824 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
825 FIXME: Neither should "signal foo" but when I tried passing
826 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
827 tried to track down yet. */
828 proceed (oursig
== TARGET_SIGNAL_0
? (CORE_ADDR
) -1 : stop_pc
, oursig
, 0);
831 /* Call breakpoint_auto_delete on the current contents of the bpstat
832 pointed to by arg (which is really a bpstat *). */
835 breakpoint_auto_delete_contents (arg
)
838 breakpoint_auto_delete (*(bpstat
*) arg
);
842 /* Execute a "stack dummy", a piece of code stored in the stack
843 by the debugger to be executed in the inferior.
845 To call: first, do PUSH_DUMMY_FRAME.
846 Then push the contents of the dummy. It should end with a breakpoint insn.
847 Then call here, passing address at which to start the dummy.
849 The contents of all registers are saved before the dummy frame is popped
850 and copied into the buffer BUFFER.
852 The dummy's frame is automatically popped whenever that break is hit.
853 If that is the first time the program stops, run_stack_dummy
854 returns to its caller with that frame already gone and returns 0.
856 Otherwise, run_stack-dummy returns a non-zero value.
857 If the called function receives a random signal, we do not allow the user
858 to continue executing it as this may not work. The dummy frame is poped
860 If we hit a breakpoint, we leave the frame in place and return 2 (the frame
861 will eventually be popped when we do hit the dummy end breakpoint). */
864 run_stack_dummy (addr
, buffer
)
868 struct cleanup
*old_cleanups
= make_cleanup (null_cleanup
, 0);
871 /* Now proceed, having reached the desired place. */
872 clear_proceed_status ();
874 if (CALL_DUMMY_BREAKPOINT_OFFSET_P
)
876 struct breakpoint
*bpt
;
877 struct symtab_and_line sal
;
879 INIT_SAL (&sal
); /* initialize to zeroes */
880 if (CALL_DUMMY_LOCATION
== AT_ENTRY_POINT
)
882 sal
.pc
= CALL_DUMMY_ADDRESS ();
886 sal
.pc
= addr
- CALL_DUMMY_START_OFFSET
+ CALL_DUMMY_BREAKPOINT_OFFSET
;
888 sal
.section
= find_pc_overlay (sal
.pc
);
890 /* Set up a FRAME for the dummy frame so we can pass it to
891 set_momentary_breakpoint. We need to give the breakpoint a
892 frame in case there is only one copy of the dummy (e.g.
893 CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
894 flush_cached_frames ();
895 set_current_frame (create_new_frame (read_fp (), sal
.pc
));
897 /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
898 a breakpoint instruction. If not, the call dummy already has the
899 breakpoint instruction in it.
901 addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
902 so we need to subtract the CALL_DUMMY_START_OFFSET. */
903 bpt
= set_momentary_breakpoint (sal
,
904 get_current_frame (),
906 bpt
->disposition
= del
;
908 /* If all error()s out of proceed ended up calling normal_stop (and
909 perhaps they should; it already does in the special case of error
910 out of resume()), then we wouldn't need this. */
911 make_cleanup (breakpoint_auto_delete_contents
, &stop_bpstat
);
914 disable_watchpoints_before_interactive_call_start ();
915 proceed_to_finish
= 1; /* We want stop_registers, please... */
917 if (target_can_async_p ())
918 saved_async
= target_async_mask (0);
920 proceed (addr
, TARGET_SIGNAL_0
, 0);
923 target_async_mask (saved_async
);
925 enable_watchpoints_after_interactive_call_stop ();
927 discard_cleanups (old_cleanups
);
929 if (stopped_by_random_signal
)
931 /* If the inferior execution fails we need to restore our
932 stack. It is not done by proceed() in this case. */
933 /* Pop the empty frame that contains the stack dummy.
934 POP_FRAME ends with a setting of the current frame, so we
935 can use that next. */
940 /* We may also stop prematurely because we hit a breakpoint in the
941 called routine. We do not pop the frame as the user may wish
942 to single step or continue from there. */
943 if (!stop_stack_dummy
)
946 /* On normal return, the stack dummy has been popped already. */
948 memcpy (buffer
, stop_registers
, REGISTER_BYTES
);
952 /* Proceed until we reach a different source line with pc greater than
953 our current one or exit the function. We skip calls in both cases.
955 Note that eventually this command should probably be changed so
956 that only source lines are printed out when we hit the breakpoint
957 we set. This may involve changes to wait_for_inferior and the
958 proceed status code. */
962 until_next_command (from_tty
)
965 struct frame_info
*frame
;
968 struct symtab_and_line sal
;
970 clear_proceed_status ();
972 frame
= get_current_frame ();
974 /* Step until either exited from this function or greater
975 than the current line (if in symbolic section) or pc (if
979 func
= find_pc_function (pc
);
983 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
986 error ("Execution is not within a known function.");
988 step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
993 sal
= find_pc_line (pc
, 0);
995 step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
996 step_range_end
= sal
.end
;
1000 step_frame_address
= FRAME_FP (frame
);
1001 step_sp
= read_sp ();
1003 step_multi
= 0; /* Only one call to proceed */
1005 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1009 until_command (arg
, from_tty
)
1015 if (!target_has_execution
)
1016 error ("The program is not running.");
1018 /* Find out whether we must run in the background. */
1020 async_exec
= strip_bg_char (&arg
);
1022 /* If we must run in the background, but the target can't do it,
1024 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
1025 error ("Asynchronous execution not supported on this target.");
1027 /* If we are not asked to run in the bg, then prepare to run in the
1028 foreground, synchronously. */
1029 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
1031 /* Simulate synchronous execution */
1032 async_disable_stdin ();
1036 until_break_command (arg
, from_tty
);
1038 until_next_command (from_tty
);
1042 /* Print the result of a function at the end of a 'finish' command. */
1044 print_return_value (int structure_return
, struct type
*value_type
)
1046 register value_ptr value
;
1048 static struct ui_stream
*stb
= NULL
;
1051 if (!structure_return
)
1053 value
= value_being_returned (value_type
, stop_registers
, structure_return
);
1055 stb
= ui_out_stream_new (uiout
);
1056 ui_out_text (uiout
, "Value returned is ");
1057 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d", record_latest_value (value
));
1058 ui_out_text (uiout
, "= ");
1059 value_print (value
, stb
->stream
, 0, Val_no_prettyprint
);
1060 ui_out_field_stream (uiout
, "return-value", stb
);
1061 ui_out_text (uiout
, "\n");
1063 printf_filtered ("Value returned is $%d = ", record_latest_value (value
));
1064 value_print (value
, gdb_stdout
, 0, Val_no_prettyprint
);
1065 printf_filtered ("\n");
1070 /* We cannot determine the contents of the structure because
1071 it is on the stack, and we don't know where, since we did not
1072 initiate the call, as opposed to the call_function_by_hand case */
1073 #ifdef VALUE_RETURNED_FROM_STACK
1076 ui_out_text (uiout
, "Value returned has type: ");
1077 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1078 ui_out_text (uiout
, ".");
1079 ui_out_text (uiout
, " Cannot determine contents\n");
1081 printf_filtered ("Value returned has type: %s.", TYPE_NAME (value_type
));
1082 printf_filtered (" Cannot determine contents\n");
1085 value
= value_being_returned (value_type
, stop_registers
, structure_return
);
1087 stb
= ui_out_stream_new (uiout
);
1088 ui_out_text (uiout
, "Value returned is ");
1089 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d", record_latest_value (value
));
1090 ui_out_text (uiout
, "= ");
1091 value_print (value
, stb
->stream
, 0, Val_no_prettyprint
);
1092 ui_out_field_stream (uiout
, "return-value", stb
);
1093 ui_out_text (uiout
, "\n");
1095 printf_filtered ("Value returned is $%d = ", record_latest_value (value
));
1096 value_print (value
, gdb_stdout
, 0, Val_no_prettyprint
);
1097 printf_filtered ("\n");
1103 /* Stuff that needs to be done by the finish command after the target
1104 has stopped. In asynchronous mode, we wait for the target to stop in
1105 the call to poll or select in the event loop, so it is impossible to
1106 do all the stuff as part of the finish_command function itself. The
1107 only chance we have to complete this command is in
1108 fetch_inferior_event, which is called by the event loop as soon as it
1109 detects that the target has stopped. This function is called via the
1110 cmd_continaution pointer. */
1112 finish_command_continuation (arg
)
1113 struct continuation_arg
*arg
;
1115 register struct symbol
*function
;
1116 struct breakpoint
*breakpoint
;
1117 struct cleanup
*cleanups
;
1119 breakpoint
= (struct breakpoint
*) arg
->data
;
1120 function
= (struct symbol
*) (arg
->next
)->data
;
1121 cleanups
= (struct cleanup
*) (arg
->next
->next
)->data
;
1123 if (bpstat_find_breakpoint (stop_bpstat
, breakpoint
) != NULL
1126 struct type
*value_type
;
1130 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (function
));
1132 internal_error ("finish_command: function has no target type");
1134 if (TYPE_CODE (value_type
) == TYPE_CODE_VOID
)
1136 do_exec_cleanups (cleanups
);
1140 funcaddr
= BLOCK_START (SYMBOL_BLOCK_VALUE (function
));
1142 struct_return
= using_struct_return (value_of_variable (function
, NULL
),
1144 check_typedef (value_type
),
1145 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function
)));
1147 print_return_value (struct_return
, value_type
);
1149 do_exec_cleanups (cleanups
);
1152 /* "finish": Set a temporary breakpoint at the place
1153 the selected frame will return to, then continue. */
1156 finish_command (arg
, from_tty
)
1160 struct symtab_and_line sal
;
1161 register struct frame_info
*frame
;
1162 register struct symbol
*function
;
1163 struct breakpoint
*breakpoint
;
1164 struct cleanup
*old_chain
;
1165 struct continuation_arg
*arg1
, *arg2
, *arg3
;
1169 /* Find out whether we must run in the background. */
1171 async_exec
= strip_bg_char (&arg
);
1173 /* If we must run in the background, but the target can't do it,
1175 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
1176 error ("Asynchronous execution not supported on this target.");
1178 /* If we are not asked to run in the bg, then prepare to run in the
1179 foreground, synchronously. */
1180 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
1182 /* Simulate synchronous execution */
1183 async_disable_stdin ();
1187 error ("The \"finish\" command does not take any arguments.");
1188 if (!target_has_execution
)
1189 error ("The program is not running.");
1190 if (selected_frame
== NULL
)
1191 error ("No selected frame.");
1193 frame
= get_prev_frame (selected_frame
);
1195 error ("\"finish\" not meaningful in the outermost frame.");
1197 clear_proceed_status ();
1199 sal
= find_pc_line (frame
->pc
, 0);
1202 breakpoint
= set_momentary_breakpoint (sal
, frame
, bp_finish
);
1204 if (!event_loop_p
|| !target_can_async_p ())
1205 old_chain
= make_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
1207 old_chain
= make_exec_cleanup ((make_cleanup_func
) delete_breakpoint
, breakpoint
);
1209 /* Find the function we will return from. */
1211 function
= find_pc_function (selected_frame
->pc
);
1213 /* Print info on the selected frame, including level number
1217 printf_filtered ("Run till exit from ");
1218 print_stack_frame (selected_frame
, selected_frame_level
, 0);
1221 /* If running asynchronously and the target support asynchronous
1222 execution, set things up for the rest of the finish command to be
1223 completed later on, when gdb has detected that the target has
1224 stopped, in fetch_inferior_event. */
1225 if (event_loop_p
&& target_can_async_p ())
1228 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1230 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1232 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1236 arg1
->data
= (PTR
) breakpoint
;
1237 arg2
->data
= (PTR
) function
;
1238 arg3
->data
= (PTR
) old_chain
;
1239 add_continuation (finish_command_continuation
, arg1
);
1242 proceed_to_finish
= 1; /* We want stop_registers, please... */
1243 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1245 /* Do this only if not running asynchronously or if the target
1246 cannot do async execution. Otherwise, complete this command when
1247 the target actually stops, in fetch_inferior_event. */
1248 if (!event_loop_p
|| !target_can_async_p ())
1251 /* Did we stop at our breakpoint? */
1252 if (bpstat_find_breakpoint (stop_bpstat
, breakpoint
) != NULL
1255 struct type
*value_type
;
1259 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (function
));
1261 internal_error ("finish_command: function has no target type");
1263 /* FIXME: Shouldn't we do the cleanups before returning? */
1264 if (TYPE_CODE (value_type
) == TYPE_CODE_VOID
)
1267 funcaddr
= BLOCK_START (SYMBOL_BLOCK_VALUE (function
));
1270 using_struct_return (value_of_variable (function
, NULL
),
1272 check_typedef (value_type
),
1273 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function
)));
1275 print_return_value (struct_return
, value_type
);
1277 do_cleanups (old_chain
);
1283 program_info (args
, from_tty
)
1287 bpstat bs
= stop_bpstat
;
1288 int num
= bpstat_num (&bs
);
1290 if (!target_has_execution
)
1292 printf_filtered ("The program being debugged is not being run.\n");
1296 target_files_info ();
1297 printf_filtered ("Program stopped at %s.\n",
1298 local_hex_string ((unsigned long) stop_pc
));
1300 printf_filtered ("It stopped after being stepped.\n");
1303 /* There may be several breakpoints in the same place, so this
1304 isn't as strange as it seems. */
1309 printf_filtered ("It stopped at a breakpoint that has ");
1310 printf_filtered ("since been deleted.\n");
1313 printf_filtered ("It stopped at breakpoint %d.\n", num
);
1314 num
= bpstat_num (&bs
);
1317 else if (stop_signal
!= TARGET_SIGNAL_0
)
1319 printf_filtered ("It stopped with signal %s, %s.\n",
1320 target_signal_to_name (stop_signal
),
1321 target_signal_to_string (stop_signal
));
1326 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1327 printf_filtered ("for more information.\n");
1332 environment_info (var
, from_tty
)
1338 register char *val
= get_in_environ (inferior_environ
, var
);
1341 puts_filtered (var
);
1342 puts_filtered (" = ");
1343 puts_filtered (val
);
1344 puts_filtered ("\n");
1348 puts_filtered ("Environment variable \"");
1349 puts_filtered (var
);
1350 puts_filtered ("\" not defined.\n");
1355 register char **vector
= environ_vector (inferior_environ
);
1358 puts_filtered (*vector
++);
1359 puts_filtered ("\n");
1365 set_environment_command (arg
, from_tty
)
1369 register char *p
, *val
, *var
;
1373 error_no_arg ("environment variable and value");
1375 /* Find seperation between variable name and value */
1376 p
= (char *) strchr (arg
, '=');
1377 val
= (char *) strchr (arg
, ' ');
1379 if (p
!= 0 && val
!= 0)
1381 /* We have both a space and an equals. If the space is before the
1382 equals, walk forward over the spaces til we see a nonspace
1383 (possibly the equals). */
1388 /* Now if the = is after the char following the spaces,
1389 take the char following the spaces. */
1393 else if (val
!= 0 && p
== 0)
1397 error_no_arg ("environment variable to set");
1399 if (p
== 0 || p
[1] == 0)
1403 p
= arg
+ strlen (arg
); /* So that savestring below will work */
1407 /* Not setting variable value to null */
1409 while (*val
== ' ' || *val
== '\t')
1413 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1416 var
= savestring (arg
, p
- arg
);
1419 printf_filtered ("Setting environment variable ");
1420 printf_filtered ("\"%s\" to null value.\n", var
);
1421 set_in_environ (inferior_environ
, var
, "");
1424 set_in_environ (inferior_environ
, var
, val
);
1429 unset_environment_command (var
, from_tty
)
1435 /* If there is no argument, delete all environment variables.
1436 Ask for confirmation if reading from the terminal. */
1437 if (!from_tty
|| query ("Delete all environment variables? "))
1439 free_environ (inferior_environ
);
1440 inferior_environ
= make_environ ();
1444 unset_in_environ (inferior_environ
, var
);
1447 /* Handle the execution path (PATH variable) */
1449 static const char path_var_name
[] = "PATH";
1453 path_info (args
, from_tty
)
1457 puts_filtered ("Executable and object file path: ");
1458 puts_filtered (get_in_environ (inferior_environ
, path_var_name
));
1459 puts_filtered ("\n");
1462 /* Add zero or more directories to the front of the execution path. */
1465 path_command (dirname
, from_tty
)
1472 env
= get_in_environ (inferior_environ
, path_var_name
);
1473 /* Can be null if path is not set */
1476 exec_path
= strsave (env
);
1477 mod_path (dirname
, &exec_path
);
1478 set_in_environ (inferior_environ
, path_var_name
, exec_path
);
1481 path_info ((char *) NULL
, from_tty
);
1485 #ifdef REGISTER_NAMES
1486 char *gdb_register_names
[] = REGISTER_NAMES
;
1488 /* Print out the machine register regnum. If regnum is -1,
1489 print all registers (fpregs == 1) or all non-float registers
1492 For most machines, having all_registers_info() print the
1493 register(s) one per line is good enough. If a different format
1494 is required, (eg, for MIPS or Pyramid 90x, which both have
1495 lots of regs), or there is an existing convention for showing
1496 all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
1497 to provide that format. */
1499 #if !defined (DO_REGISTERS_INFO)
1501 #define DO_REGISTERS_INFO(regnum, fp) do_registers_info(regnum, fp)
1504 do_registers_info (regnum
, fpregs
)
1509 int numregs
= ARCH_NUM_REGS
;
1511 for (i
= 0; i
< numregs
; i
++)
1513 char raw_buffer
[MAX_REGISTER_RAW_SIZE
];
1514 char virtual_buffer
[MAX_REGISTER_VIRTUAL_SIZE
];
1516 /* Decide between printing all regs, nonfloat regs, or specific reg. */
1519 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
&& !fpregs
)
1528 /* If the register name is empty, it is undefined for this
1529 processor, so don't display anything. */
1530 if (REGISTER_NAME (i
) == NULL
|| *(REGISTER_NAME (i
)) == '\0')
1533 fputs_filtered (REGISTER_NAME (i
), gdb_stdout
);
1534 print_spaces_filtered (15 - strlen (REGISTER_NAME (i
)), gdb_stdout
);
1536 /* Get the data in raw format. */
1537 if (read_relative_register_raw_bytes (i
, raw_buffer
))
1539 printf_filtered ("*value not available*\n");
1543 /* Convert raw data to virtual format if necessary. */
1544 if (REGISTER_CONVERTIBLE (i
))
1546 REGISTER_CONVERT_TO_VIRTUAL (i
, REGISTER_VIRTUAL_TYPE (i
),
1547 raw_buffer
, virtual_buffer
);
1551 memcpy (virtual_buffer
, raw_buffer
,
1552 REGISTER_VIRTUAL_SIZE (i
));
1555 /* If virtual format is floating, print it that way, and in raw hex. */
1556 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
1560 #ifdef INVALID_FLOAT
1561 if (INVALID_FLOAT (virtual_buffer
, REGISTER_VIRTUAL_SIZE (i
)))
1562 printf_filtered ("<invalid float>");
1565 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1566 gdb_stdout
, 0, 1, 0, Val_pretty_default
);
1568 printf_filtered ("\t(raw 0x");
1569 for (j
= 0; j
< REGISTER_RAW_SIZE (i
); j
++)
1571 register int idx
= TARGET_BYTE_ORDER
== BIG_ENDIAN
? j
1572 : REGISTER_RAW_SIZE (i
) - 1 - j
;
1573 printf_filtered ("%02x", (unsigned char) raw_buffer
[idx
]);
1575 printf_filtered (")");
1578 /* FIXME! val_print probably can handle all of these cases now... */
1580 /* Else if virtual format is too long for printf,
1581 print in hex a byte at a time. */
1582 else if (REGISTER_VIRTUAL_SIZE (i
) > (int) sizeof (long))
1585 printf_filtered ("0x");
1586 for (j
= 0; j
< REGISTER_VIRTUAL_SIZE (i
); j
++)
1587 printf_filtered ("%02x", (unsigned char) virtual_buffer
[j
]);
1589 /* Else print as integer in hex and in decimal. */
1592 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1593 gdb_stdout
, 'x', 1, 0, Val_pretty_default
);
1594 printf_filtered ("\t");
1595 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1596 gdb_stdout
, 0, 1, 0, Val_pretty_default
);
1599 /* The SPARC wants to print even-numbered float regs as doubles
1600 in addition to printing them as floats. */
1601 #ifdef PRINT_REGISTER_HOOK
1602 PRINT_REGISTER_HOOK (i
);
1605 printf_filtered ("\n");
1608 #endif /* no DO_REGISTERS_INFO. */
1611 registers_info (addr_exp
, fpregs
)
1615 int regnum
, numregs
;
1618 if (!target_has_registers
)
1619 error ("The program has no registers now.");
1620 if (selected_frame
== NULL
)
1621 error ("No selected frame.");
1625 DO_REGISTERS_INFO (-1, fpregs
);
1631 if (addr_exp
[0] == '$')
1634 while (*end
!= '\0' && *end
!= ' ' && *end
!= '\t')
1636 numregs
= ARCH_NUM_REGS
;
1638 regnum
= target_map_name_to_register (addr_exp
, end
- addr_exp
);
1644 if (*addr_exp
>= '0' && *addr_exp
<= '9')
1645 regnum
= atoi (addr_exp
); /* Take a number */
1646 if (regnum
>= numregs
) /* Bad name, or bad number */
1647 error ("%.*s: invalid register", end
- addr_exp
, addr_exp
);
1650 DO_REGISTERS_INFO (regnum
, fpregs
);
1653 while (*addr_exp
== ' ' || *addr_exp
== '\t')
1656 while (*addr_exp
!= '\0');
1660 all_registers_info (addr_exp
, from_tty
)
1664 registers_info (addr_exp
, 1);
1668 nofp_registers_info (addr_exp
, from_tty
)
1672 registers_info (addr_exp
, 0);
1678 * Should save/restore the tty state since it might be that the
1679 * program to be debugged was started on this tty and it wants
1680 * the tty in some state other than what we want. If it's running
1681 * on another terminal or without a terminal, then saving and
1682 * restoring the tty state is a harmless no-op.
1683 * This only needs to be done if we are attaching to a process.
1688 takes a program started up outside of gdb and ``attaches'' to it.
1689 This stops it cold in its tracks and allows us to start debugging it.
1690 and wait for the trace-trap that results from attaching. */
1693 attach_command (args
, from_tty
)
1698 extern int auto_solib_add
;
1702 char *full_exec_path
= NULL
;
1704 dont_repeat (); /* Not for the faint of heart */
1706 if (target_has_execution
)
1708 if (query ("A program is being debugged already. Kill it? "))
1711 error ("Not killed.");
1714 target_attach (args
, from_tty
);
1716 /* Set up the "saved terminal modes" of the inferior
1717 based on what modes we are starting it with. */
1718 target_terminal_init ();
1720 /* Install inferior's terminal modes. */
1721 target_terminal_inferior ();
1723 /* Set up execution context to know that we should return from
1724 wait_for_inferior as soon as the target reports a stop. */
1725 init_wait_for_inferior ();
1726 clear_proceed_status ();
1727 stop_soon_quietly
= 1;
1729 /* No traps are generated when attaching to inferior under Mach 3
1731 #ifndef ATTACH_NO_WAIT
1732 wait_for_inferior ();
1736 * If no exec file is yet known, try to determine it from the
1739 exec_file
= (char *) get_exec_file (0);
1742 exec_file
= target_pid_to_exec_file (inferior_pid
);
1745 /* It's possible we don't have a full path, but rather just a
1746 filename. Some targets, such as HP-UX, don't provide the
1749 Attempt to qualify the filename against the source path.
1750 (If that fails, we'll just fall back on the original
1751 filename. Not much more we can do...)
1753 if (!source_full_path_of (exec_file
, &full_exec_path
))
1754 full_exec_path
= savestring (exec_file
, strlen (exec_file
));
1756 exec_file_attach (full_exec_path
, from_tty
);
1757 symbol_file_command (full_exec_path
, from_tty
);
1764 /* Add shared library symbols from the newly attached process, if any. */
1765 SOLIB_ADD ((char *) 0, from_tty
, ¤t_target
);
1766 re_enable_breakpoints_in_shlibs ();
1770 /* Take any necessary post-attaching actions for this platform.
1772 target_post_attach (inferior_pid
);
1782 * takes a program previously attached to and detaches it.
1783 * The program resumes execution and will no longer stop
1784 * on signals, etc. We better not have left any breakpoints
1785 * in the program or it'll die when it hits one. For this
1786 * to work, it may be necessary for the process to have been
1787 * previously attached. It *might* work if the program was
1788 * started via the normal ptrace (PTRACE_TRACEME).
1792 detach_command (args
, from_tty
)
1796 dont_repeat (); /* Not for the faint of heart */
1797 target_detach (args
, from_tty
);
1798 #if defined(SOLIB_RESTART)
1805 /* Stop the execution of the target while running in async mode, in
1809 interrupt_target_command_wrapper (args
, from_tty
)
1813 interrupt_target_command (args
, from_tty
);
1817 interrupt_target_command (args
, from_tty
)
1821 if (event_loop_p
&& target_can_async_p ())
1823 dont_repeat (); /* Not for the faint of heart */
1830 float_info (addr_exp
, from_tty
)
1837 printf_filtered ("No floating point info available for this processor.\n");
1843 unset_command (args
, from_tty
)
1847 printf_filtered ("\"unset\" must be followed by the name of ");
1848 printf_filtered ("an unset subcommand.\n");
1849 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
1853 _initialize_infcmd ()
1855 struct cmd_list_element
*c
;
1857 add_com ("tty", class_run
, tty_command
,
1858 "Set terminal for future runs of program being debugged.");
1861 (add_set_cmd ("args", class_run
, var_string_noescape
,
1862 (char *) &inferior_args
,
1863 "Set argument list to give program being debugged when it is started.\n\
1864 Follow this command with any number of args, to be passed to the program.",
1869 ("environment", no_class
, environment_info
,
1870 "The environment to give the program, or one variable's value.\n\
1871 With an argument VAR, prints the value of environment variable VAR to\n\
1872 give the program being debugged. With no arguments, prints the entire\n\
1873 environment to be given to the program.", &showlist
);
1874 c
->completer
= noop_completer
;
1876 add_prefix_cmd ("unset", no_class
, unset_command
,
1877 "Complement to certain \"set\" commands",
1878 &unsetlist
, "unset ", 0, &cmdlist
);
1880 c
= add_cmd ("environment", class_run
, unset_environment_command
,
1881 "Cancel environment variable VAR for the program.\n\
1882 This does not affect the program until the next \"run\" command.",
1884 c
->completer
= noop_completer
;
1886 c
= add_cmd ("environment", class_run
, set_environment_command
,
1887 "Set environment variable value to give the program.\n\
1888 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
1889 VALUES of environment variables are uninterpreted strings.\n\
1890 This does not affect the program until the next \"run\" command.",
1892 c
->completer
= noop_completer
;
1894 add_com ("path", class_files
, path_command
,
1895 "Add directory DIR(s) to beginning of search path for object files.\n\
1896 $cwd in the path means the current working directory.\n\
1897 This path is equivalent to the $PATH shell variable. It is a list of\n\
1898 directories, separated by colons. These directories are searched to find\n\
1899 fully linked executable files and separately compiled object files as needed.");
1901 c
= add_cmd ("paths", no_class
, path_info
,
1902 "Current search path for finding object files.\n\
1903 $cwd in the path means the current working directory.\n\
1904 This path is equivalent to the $PATH shell variable. It is a list of\n\
1905 directories, separated by colons. These directories are searched to find\n\
1906 fully linked executable files and separately compiled object files as needed.",
1908 c
->completer
= noop_completer
;
1910 add_com ("attach", class_run
, attach_command
,
1911 "Attach to a process or file outside of GDB.\n\
1912 This command attaches to another target, of the same type as your last\n\
1913 \"target\" command (\"info files\" will show your target stack).\n\
1914 The command may take as argument a process id or a device file.\n\
1915 For a process id, you must have permission to send the process a signal,\n\
1916 and it must have the same effective uid as the debugger.\n\
1917 When using \"attach\" with a process id, the debugger finds the\n\
1918 program running in the process, looking first in the current working\n\
1919 directory, or (if not found there) using the source file search path\n\
1920 (see the \"directory\" command). You can also use the \"file\" command\n\
1921 to specify the program, and to load its symbol table.");
1923 add_com ("detach", class_run
, detach_command
,
1924 "Detach a process or file previously attached.\n\
1925 If a process, it is no longer traced, and it continues its execution. If\n\
1926 you were debugging a file, the file is closed and gdb no longer accesses it.");
1928 add_com ("signal", class_run
, signal_command
,
1929 "Continue program giving it signal specified by the argument.\n\
1930 An argument of \"0\" means continue program without giving it a signal.");
1932 add_com ("stepi", class_run
, stepi_command
,
1933 "Step one instruction exactly.\n\
1934 Argument N means do this N times (or till program stops for another reason).");
1935 add_com_alias ("si", "stepi", class_alias
, 0);
1937 add_com ("nexti", class_run
, nexti_command
,
1938 "Step one instruction, but proceed through subroutine calls.\n\
1939 Argument N means do this N times (or till program stops for another reason).");
1940 add_com_alias ("ni", "nexti", class_alias
, 0);
1942 add_com ("finish", class_run
, finish_command
,
1943 "Execute until selected stack frame returns.\n\
1944 Upon return, the value returned is printed and put in the value history.");
1946 add_com ("next", class_run
, next_command
,
1947 "Step program, proceeding through subroutine calls.\n\
1948 Like the \"step\" command as long as subroutine calls do not happen;\n\
1949 when they do, the call is treated as one instruction.\n\
1950 Argument N means do this N times (or till program stops for another reason).");
1951 add_com_alias ("n", "next", class_run
, 1);
1953 add_com_alias ("S", "next", class_run
, 1);
1955 add_com ("step", class_run
, step_command
,
1956 "Step program until it reaches a different source line.\n\
1957 Argument N means do this N times (or till program stops for another reason).");
1958 add_com_alias ("s", "step", class_run
, 1);
1960 add_com ("until", class_run
, until_command
,
1961 "Execute until the program reaches a source line greater than the current\n\
1962 or a specified line or address or function (same args as break command).\n\
1963 Execution will also stop upon exit from the current stack frame.");
1964 add_com_alias ("u", "until", class_run
, 1);
1966 add_com ("jump", class_run
, jump_command
,
1967 "Continue program being debugged at specified line or address.\n\
1968 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
1969 for an address to start at.");
1972 add_com ("go", class_run
, go_command
,
1973 "Usage: go <location>\n\
1974 Continue program being debugged, stopping at specified line or \n\
1976 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
1977 expression for an address to start at.\n\
1978 This command is a combination of tbreak and jump.");
1981 add_com_alias ("g", "go", class_run
, 1);
1983 add_com ("continue", class_run
, continue_command
,
1984 "Continue program being debugged, after signal or breakpoint.\n\
1985 If proceeding from breakpoint, a number N may be used as an argument,\n\
1986 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
1987 the breakpoint won't break until the Nth time it is reached).");
1988 add_com_alias ("c", "cont", class_run
, 1);
1989 add_com_alias ("fg", "cont", class_run
, 1);
1991 add_com ("run", class_run
, run_command
,
1992 "Start debugged program. You may specify arguments to give it.\n\
1993 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
1994 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
1995 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
1996 To cancel previous arguments and run with no arguments,\n\
1997 use \"set args\" without arguments.");
1998 add_com_alias ("r", "run", class_run
, 1);
2000 add_com ("R", class_run
, run_no_args_command
,
2001 "Start debugged program with no arguments.");
2003 add_com ("interrupt", class_run
, interrupt_target_command
,
2004 "Interrupt the execution of the debugged program.");
2006 add_info ("registers", nofp_registers_info
,
2007 "List of integer registers and their contents, for selected stack frame.\n\
2008 Register name as argument means describe only that register.");
2011 add_com ("lr", class_info
, nofp_registers_info
,
2012 "List of integer registers and their contents, for selected stack frame.\n\
2013 Register name as argument means describe only that register.");
2014 add_info ("all-registers", all_registers_info
,
2015 "List of all registers and their contents, for selected stack frame.\n\
2016 Register name as argument means describe only that register.");
2018 add_info ("program", program_info
,
2019 "Execution status of the program.");
2021 add_info ("float", float_info
,
2022 "Print the status of the floating point unit\n");
2024 inferior_args
= savestring ("", 1); /* Initially no args */
2025 inferior_environ
= make_environ ();
2026 init_environ (inferior_environ
);