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"
39 #include "completer.h"
43 #include "event-top.h"
44 #include "parser-defs.h"
46 /* Functions exported for general use: */
48 void nofp_registers_info (char *, int);
50 void all_registers_info (char *, int);
52 void registers_info (char *, int);
54 /* Local functions: */
56 void continue_command (char *, int);
58 static void print_return_value (int struct_return
, struct type
*value_type
);
60 static void finish_command_continuation (struct continuation_arg
*);
62 static void until_next_command (int);
64 static void until_command (char *, int);
66 static void path_info (char *, int);
68 static void path_command (char *, int);
70 static void unset_command (char *, int);
72 static void float_info (char *, int);
74 static void detach_command (char *, int);
76 static void interrupt_target_command (char *args
, int from_tty
);
78 static void unset_environment_command (char *, int);
80 static void set_environment_command (char *, int);
82 static void environment_info (char *, int);
84 static void program_info (char *, int);
86 static void finish_command (char *, int);
88 static void signal_command (char *, int);
90 static void jump_command (char *, int);
92 static void step_1 (int, int, char *);
93 static void step_once (int skip_subroutines
, int single_inst
, int count
);
94 static void step_1_continuation (struct continuation_arg
*arg
);
96 void nexti_command (char *, int);
98 void stepi_command (char *, int);
100 static void next_command (char *, int);
102 static void step_command (char *, int);
104 static void run_command (char *, int);
106 static void run_no_args_command (char *args
, int from_tty
);
108 static void go_command (char *line_no
, int from_tty
);
110 static int strip_bg_char (char **);
112 void _initialize_infcmd (void);
114 #define GO_USAGE "Usage: go <location>\n"
116 static void breakpoint_auto_delete_contents (PTR
);
118 #define ERROR_NO_INFERIOR \
119 if (!target_has_execution) error ("The program is not being run.");
121 /* String containing arguments to give to the program, separated by spaces.
122 Empty string (pointer to '\0') means no args. */
124 static char *inferior_args
;
126 /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
127 then we must compute INFERIOR_ARGS from this (via the target). */
129 static int inferior_argc
;
130 static char **inferior_argv
;
132 /* File name for default use for standard in/out in the inferior. */
134 char *inferior_io_terminal
;
136 /* Pid of our debugged inferior, or 0 if no inferior now.
137 Since various parts of infrun.c test this to see whether there is a program
138 being debugged it should be nonzero (currently 3 is used) for remote
141 ptid_t inferior_ptid
;
143 /* Last signal that the inferior received (why it stopped). */
145 enum target_signal stop_signal
;
147 /* Address at which inferior stopped. */
151 /* Chain containing status of breakpoint(s) that we have stopped at. */
155 /* Flag indicating that a command has proceeded the inferior past the
156 current breakpoint. */
158 int breakpoint_proceeded
;
160 /* Nonzero if stopped due to a step command. */
164 /* Nonzero if stopped due to completion of a stack dummy routine. */
166 int stop_stack_dummy
;
168 /* Nonzero if stopped due to a random (unexpected) signal in inferior
171 int stopped_by_random_signal
;
173 /* Range to single step within.
174 If this is nonzero, respond to a single-step signal
175 by continuing to step if the pc is in this range. */
177 CORE_ADDR step_range_start
; /* Inclusive */
178 CORE_ADDR step_range_end
; /* Exclusive */
180 /* Stack frame address as of when stepping command was issued.
181 This is how we know when we step into a subroutine call,
182 and how to set the frame for the breakpoint used to step out. */
184 CORE_ADDR step_frame_address
;
186 /* Our notion of the current stack pointer. */
190 enum step_over_calls_kind step_over_calls
;
192 /* If stepping, nonzero means step count is > 1
193 so don't print frame next time inferior stops
194 if it stops due to stepping. */
198 /* Environment to use for running inferior,
199 in format described in environ.h. */
201 struct environ
*inferior_environ
;
203 /* Accessor routines. */
206 get_inferior_args (void)
208 if (inferior_argc
!= 0)
212 n
= gdbarch_construct_inferior_arguments (current_gdbarch
,
213 inferior_argc
, inferior_argv
);
214 old
= set_inferior_args (n
);
218 if (inferior_args
== NULL
)
219 inferior_args
= xstrdup ("");
221 return inferior_args
;
225 set_inferior_args (char *newargs
)
227 char *saved_args
= inferior_args
;
229 inferior_args
= newargs
;
237 set_inferior_args_vector (int argc
, char **argv
)
239 inferior_argc
= argc
;
240 inferior_argv
= argv
;
243 /* Notice when `set args' is run. */
245 notice_args_set (char *args
, int from_tty
, struct cmd_list_element
*c
)
251 /* Notice when `show args' is run. */
253 notice_args_read (struct cmd_list_element
*c
)
255 /* Might compute the value. */
256 get_inferior_args ();
260 /* Compute command-line string given argument vector. This does the
261 same shell processing as fork_inferior. */
264 construct_inferior_arguments (struct gdbarch
*gdbarch
, int argc
, char **argv
)
268 if (STARTUP_WITH_SHELL
)
270 /* This holds all the characters considered special to the
271 typical Unix shells. We include `^' because the SunOS
272 /bin/sh treats it as a synonym for `|'. */
273 char *special
= "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
278 /* We over-compute the size. It shouldn't matter. */
279 for (i
= 0; i
< argc
; ++i
)
280 length
+= 2 * strlen (argv
[i
]) + 1;
282 result
= (char *) xmalloc (length
);
285 for (i
= 0; i
< argc
; ++i
)
290 for (cp
= argv
[i
]; *cp
; ++cp
)
292 if (strchr (special
, *cp
) != NULL
)
301 /* In this case we can't handle arguments that contain spaces,
302 tabs, or newlines -- see breakup_args(). */
306 for (i
= 0; i
< argc
; ++i
)
308 char *cp
= strchr (argv
[i
], ' ');
310 cp
= strchr (argv
[i
], '\t');
312 cp
= strchr (argv
[i
], '\n');
314 error ("can't handle command-line argument containing whitespace");
315 length
+= strlen (argv
[i
]) + 1;
318 result
= (char *) xmalloc (length
);
320 for (i
= 0; i
< argc
; ++i
)
323 strcat (result
, " ");
324 strcat (result
, argv
[i
]);
332 /* This function detects whether or not a '&' character (indicating
333 background execution) has been added as *the last* of the arguments ARGS
334 of a command. If it has, it removes it and returns 1. Otherwise it
335 does nothing and returns 0. */
337 strip_bg_char (char **args
)
341 p
= strchr (*args
, '&');
345 if (p
== (*args
+ strlen (*args
) - 1))
347 if (strlen (*args
) > 1)
351 while (*p
== ' ' || *p
== '\t');
364 tty_command (char *file
, int from_tty
)
367 error_no_arg ("terminal name for running target process");
369 inferior_io_terminal
= savestring (file
, strlen (file
));
373 run_command (char *args
, int from_tty
)
379 if (! ptid_equal (inferior_ptid
, null_ptid
) && target_has_execution
)
382 && !query ("The program being debugged has been started already.\n\
383 Start it from the beginning? "))
384 error ("Program not restarted.");
386 #if defined(SOLIB_RESTART)
389 init_wait_for_inferior ();
392 clear_breakpoint_hit_counts ();
394 exec_file
= (char *) get_exec_file (0);
396 /* Purge old solib objfiles. */
397 objfile_purge_solibs ();
399 do_run_cleanups (NULL
);
401 /* The exec file is re-read every time we do a generic_mourn_inferior, so
402 we just have to worry about the symbol file. */
405 /* We keep symbols from add-symbol-file, on the grounds that the
406 user might want to add some symbols before running the program
407 (right?). But sometimes (dynamic loading where the user manually
408 introduces the new symbols with add-symbol-file), the code which
409 the symbols describe does not persist between runs. Currently
410 the user has to manually nuke all symbols between runs if they
411 want them to go away (PR 2207). This is probably reasonable. */
415 if (event_loop_p
&& target_can_async_p ())
416 async_disable_stdin ();
420 int async_exec
= strip_bg_char (&args
);
422 /* If we get a request for running in the bg but the target
423 doesn't support it, error out. */
424 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
425 error ("Asynchronous execution not supported on this target.");
427 /* If we don't get a request of running in the bg, then we need
428 to simulate synchronous (fg) execution. */
429 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
431 /* Simulate synchronous execution */
432 async_disable_stdin ();
435 /* If there were other args, beside '&', process them. */
438 char *old_args
= set_inferior_args (xstrdup (args
));
446 ui_out_field_string (uiout
, NULL
, "Starting program");
447 ui_out_text (uiout
, ": ");
449 ui_out_field_string (uiout
, "execfile", exec_file
);
450 ui_out_spaces (uiout
, 1);
451 /* We call get_inferior_args() because we might need to compute
453 ui_out_field_string (uiout
, "infargs", get_inferior_args ());
454 ui_out_text (uiout
, "\n");
455 ui_out_flush (uiout
);
457 puts_filtered ("Starting program: ");
459 puts_filtered (exec_file
);
461 /* We call get_inferior_args() because we might need to compute
463 puts_filtered (get_inferior_args ());
464 puts_filtered ("\n");
465 gdb_flush (gdb_stdout
);
469 /* We call get_inferior_args() because we might need to compute
471 target_create_inferior (exec_file
, get_inferior_args (),
472 environ_vector (inferior_environ
));
477 run_no_args_command (char *args
, int from_tty
)
479 char *old_args
= set_inferior_args (xstrdup (""));
485 continue_command (char *proc_count_exp
, int from_tty
)
490 /* Find out whether we must run in the background. */
491 if (proc_count_exp
!= NULL
)
492 async_exec
= strip_bg_char (&proc_count_exp
);
494 /* If we must run in the background, but the target can't do it,
496 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
497 error ("Asynchronous execution not supported on this target.");
499 /* If we are not asked to run in the bg, then prepare to run in the
500 foreground, synchronously. */
501 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
503 /* Simulate synchronous execution */
504 async_disable_stdin ();
507 /* If have argument (besides '&'), set proceed count of breakpoint
509 if (proc_count_exp
!= NULL
)
511 bpstat bs
= stop_bpstat
;
512 int num
= bpstat_num (&bs
);
513 if (num
== 0 && from_tty
)
516 ("Not stopped at any breakpoint; argument ignored.\n");
520 set_ignore_count (num
,
521 parse_and_eval_long (proc_count_exp
) - 1,
523 /* set_ignore_count prints a message ending with a period.
524 So print two spaces before "Continuing.". */
526 printf_filtered (" ");
527 num
= bpstat_num (&bs
);
532 printf_filtered ("Continuing.\n");
534 clear_proceed_status ();
536 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
539 /* Step until outside of current statement. */
543 step_command (char *count_string
, int from_tty
)
545 step_1 (0, 0, count_string
);
548 /* Likewise, but skip over subroutine calls as if single instructions. */
552 next_command (char *count_string
, int from_tty
)
554 step_1 (1, 0, count_string
);
557 /* Likewise, but step only one instruction. */
561 stepi_command (char *count_string
, int from_tty
)
563 step_1 (0, 1, count_string
);
568 nexti_command (char *count_string
, int from_tty
)
570 step_1 (1, 1, count_string
);
574 disable_longjmp_breakpoint_cleanup (void *ignore
)
576 disable_longjmp_breakpoint ();
580 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
582 register int count
= 1;
583 struct frame_info
*frame
;
584 struct cleanup
*cleanups
= 0;
590 async_exec
= strip_bg_char (&count_string
);
592 /* If we get a request for running in the bg but the target
593 doesn't support it, error out. */
594 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
595 error ("Asynchronous execution not supported on this target.");
597 /* If we don't get a request of running in the bg, then we need
598 to simulate synchronous (fg) execution. */
599 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
601 /* Simulate synchronous execution */
602 async_disable_stdin ();
605 count
= count_string
? parse_and_eval_long (count_string
) : 1;
607 if (!single_inst
|| skip_subroutines
) /* leave si command alone */
609 enable_longjmp_breakpoint ();
610 if (!event_loop_p
|| !target_can_async_p ())
611 cleanups
= make_cleanup (disable_longjmp_breakpoint_cleanup
, 0 /*ignore*/);
613 make_exec_cleanup (disable_longjmp_breakpoint_cleanup
, 0 /*ignore*/);
616 /* In synchronous case, all is well, just use the regular for loop. */
617 if (!event_loop_p
|| !target_can_async_p ())
619 for (; count
> 0; count
--)
621 clear_proceed_status ();
623 frame
= get_current_frame ();
624 if (!frame
) /* Avoid coredump here. Why tho? */
625 error ("No current frame");
626 step_frame_address
= FRAME_FP (frame
);
627 step_sp
= read_sp ();
631 find_pc_line_pc_range (stop_pc
, &step_range_start
, &step_range_end
);
632 if (step_range_end
== 0)
635 if (find_pc_partial_function (stop_pc
, &name
, &step_range_start
,
636 &step_range_end
) == 0)
637 error ("Cannot find bounds of current function");
639 target_terminal_ours ();
641 Single stepping until exit from function %s, \n\
642 which has no line number information.\n", name
);
647 /* Say we are stepping, but stop after one insn whatever it does. */
648 step_range_start
= step_range_end
= 1;
649 if (!skip_subroutines
)
651 Don't step over function calls, not even to functions lacking
653 step_over_calls
= STEP_OVER_NONE
;
656 if (skip_subroutines
)
657 step_over_calls
= STEP_OVER_ALL
;
659 step_multi
= (count
> 1);
660 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
665 /* FIXME: On nexti, this may have already been done (when we hit the
666 step resume break, I think). Probably this should be moved to
667 wait_for_inferior (near the top). */
668 #if defined (SHIFT_INST_REGS)
673 if (!single_inst
|| skip_subroutines
)
674 do_cleanups (cleanups
);
677 /* In case of asynchronous target things get complicated, do only
678 one step for now, before returning control to the event loop. Let
679 the continuation figure out how many other steps we need to do,
680 and handle them one at the time, through step_once(). */
683 if (event_loop_p
&& target_can_async_p ())
684 step_once (skip_subroutines
, single_inst
, count
);
688 /* Called after we are done with one step operation, to check whether
689 we need to step again, before we print the prompt and return control
690 to the user. If count is > 1, we will need to do one more call to
691 proceed(), via step_once(). Basically it is like step_once and
692 step_1_continuation are co-recursive. */
694 step_1_continuation (struct continuation_arg
*arg
)
697 int skip_subroutines
;
700 skip_subroutines
= arg
->data
.integer
;
701 single_inst
= arg
->next
->data
.integer
;
702 count
= arg
->next
->next
->data
.integer
;
706 /* FIXME: On nexti, this may have already been done (when we hit the
707 step resume break, I think). Probably this should be moved to
708 wait_for_inferior (near the top). */
709 #if defined (SHIFT_INST_REGS)
712 step_once (skip_subroutines
, single_inst
, count
- 1);
715 if (!single_inst
|| skip_subroutines
)
716 do_exec_cleanups (ALL_CLEANUPS
);
719 /* Do just one step operation. If count >1 we will have to set up a
720 continuation to be done after the target stops (after this one
721 step). This is useful to implement the 'step n' kind of commands, in
722 case of asynchronous targets. We had to split step_1 into two parts,
723 one to be done before proceed() and one afterwards. This function is
724 called in case of step n with n>1, after the first step operation has
727 step_once (int skip_subroutines
, int single_inst
, int count
)
729 struct continuation_arg
*arg1
;
730 struct continuation_arg
*arg2
;
731 struct continuation_arg
*arg3
;
732 struct frame_info
*frame
;
736 clear_proceed_status ();
738 frame
= get_current_frame ();
739 if (!frame
) /* Avoid coredump here. Why tho? */
740 error ("No current frame");
741 step_frame_address
= FRAME_FP (frame
);
742 step_sp
= read_sp ();
746 find_pc_line_pc_range (stop_pc
, &step_range_start
, &step_range_end
);
748 /* If we have no line info, switch to stepi mode. */
749 if (step_range_end
== 0 && step_stop_if_no_debug
)
751 step_range_start
= step_range_end
= 1;
753 else if (step_range_end
== 0)
756 if (find_pc_partial_function (stop_pc
, &name
, &step_range_start
,
757 &step_range_end
) == 0)
758 error ("Cannot find bounds of current function");
760 target_terminal_ours ();
762 Single stepping until exit from function %s, \n\
763 which has no line number information.\n", name
);
768 /* Say we are stepping, but stop after one insn whatever it does. */
769 step_range_start
= step_range_end
= 1;
770 if (!skip_subroutines
)
772 Don't step over function calls, not even to functions lacking
774 step_over_calls
= STEP_OVER_NONE
;
777 if (skip_subroutines
)
778 step_over_calls
= STEP_OVER_ALL
;
780 step_multi
= (count
> 1);
782 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
784 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
786 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
788 arg1
->data
.integer
= skip_subroutines
;
790 arg2
->data
.integer
= single_inst
;
792 arg3
->data
.integer
= count
;
793 add_intermediate_continuation (step_1_continuation
, arg1
);
794 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
799 /* Continue program at specified address. */
802 jump_command (char *arg
, int from_tty
)
804 register CORE_ADDR addr
;
805 struct symtabs_and_lines sals
;
806 struct symtab_and_line sal
;
813 /* Find out whether we must run in the background. */
815 async_exec
= strip_bg_char (&arg
);
817 /* If we must run in the background, but the target can't do it,
819 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
820 error ("Asynchronous execution not supported on this target.");
822 /* If we are not asked to run in the bg, then prepare to run in the
823 foreground, synchronously. */
824 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
826 /* Simulate synchronous execution */
827 async_disable_stdin ();
831 error_no_arg ("starting address");
833 sals
= decode_line_spec_1 (arg
, 1);
836 error ("Unreasonable jump request");
842 if (sal
.symtab
== 0 && sal
.pc
== 0)
843 error ("No source file has been specified.");
845 resolve_sal_pc (&sal
); /* May error out */
847 /* See if we are trying to jump to another function. */
848 fn
= get_frame_function (get_current_frame ());
849 sfn
= find_pc_function (sal
.pc
);
850 if (fn
!= NULL
&& sfn
!= fn
)
852 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal
.line
,
853 SYMBOL_SOURCE_NAME (fn
)))
855 error ("Not confirmed.");
862 fixup_symbol_section (sfn
, 0);
863 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn
)) &&
864 !section_is_mapped (SYMBOL_BFD_SECTION (sfn
)))
866 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
868 error ("Not confirmed.");
878 printf_filtered ("Continuing at ");
879 print_address_numeric (addr
, 1, gdb_stdout
);
880 printf_filtered (".\n");
883 clear_proceed_status ();
884 proceed (addr
, TARGET_SIGNAL_0
, 0);
888 /* Go to line or address in current procedure */
890 go_command (char *line_no
, int from_tty
)
892 if (line_no
== (char *) NULL
|| !*line_no
)
893 printf_filtered (GO_USAGE
);
896 tbreak_command (line_no
, from_tty
);
897 jump_command (line_no
, from_tty
);
902 /* Continue program giving it specified signal. */
905 signal_command (char *signum_exp
, int from_tty
)
907 enum target_signal oursig
;
909 dont_repeat (); /* Too dangerous. */
913 error_no_arg ("signal number");
915 /* It would be even slicker to make signal names be valid expressions,
916 (the type could be "enum $signal" or some such), then the user could
917 assign them to convenience variables. */
918 oursig
= target_signal_from_name (signum_exp
);
920 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
922 /* No, try numeric. */
923 int num
= parse_and_eval_long (signum_exp
);
926 oursig
= TARGET_SIGNAL_0
;
928 oursig
= target_signal_from_command (num
);
933 if (oursig
== TARGET_SIGNAL_0
)
934 printf_filtered ("Continuing with no signal.\n");
936 printf_filtered ("Continuing with signal %s.\n",
937 target_signal_to_name (oursig
));
940 clear_proceed_status ();
941 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
942 FIXME: Neither should "signal foo" but when I tried passing
943 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
944 tried to track down yet. */
945 proceed (oursig
== TARGET_SIGNAL_0
? (CORE_ADDR
) -1 : stop_pc
, oursig
, 0);
948 /* Call breakpoint_auto_delete on the current contents of the bpstat
949 pointed to by arg (which is really a bpstat *). */
952 breakpoint_auto_delete_contents (PTR arg
)
954 breakpoint_auto_delete (*(bpstat
*) arg
);
958 /* Execute a "stack dummy", a piece of code stored in the stack
959 by the debugger to be executed in the inferior.
961 To call: first, do PUSH_DUMMY_FRAME.
962 Then push the contents of the dummy. It should end with a breakpoint insn.
963 Then call here, passing address at which to start the dummy.
965 The contents of all registers are saved before the dummy frame is popped
966 and copied into the buffer BUFFER.
968 The dummy's frame is automatically popped whenever that break is hit.
969 If that is the first time the program stops, run_stack_dummy
970 returns to its caller with that frame already gone and returns 0.
972 Otherwise, run_stack-dummy returns a non-zero value.
973 If the called function receives a random signal, we do not allow the user
974 to continue executing it as this may not work. The dummy frame is poped
976 If we hit a breakpoint, we leave the frame in place and return 2 (the frame
977 will eventually be popped when we do hit the dummy end breakpoint). */
980 run_stack_dummy (CORE_ADDR addr
, char *buffer
)
982 struct cleanup
*old_cleanups
= make_cleanup (null_cleanup
, 0);
985 /* Now proceed, having reached the desired place. */
986 clear_proceed_status ();
988 if (CALL_DUMMY_BREAKPOINT_OFFSET_P
)
990 struct breakpoint
*bpt
;
991 struct symtab_and_line sal
;
993 INIT_SAL (&sal
); /* initialize to zeroes */
994 if (CALL_DUMMY_LOCATION
== AT_ENTRY_POINT
)
996 sal
.pc
= CALL_DUMMY_ADDRESS ();
1000 sal
.pc
= addr
- CALL_DUMMY_START_OFFSET
+ CALL_DUMMY_BREAKPOINT_OFFSET
;
1002 sal
.section
= find_pc_overlay (sal
.pc
);
1004 /* Set up a FRAME for the dummy frame so we can pass it to
1005 set_momentary_breakpoint. We need to give the breakpoint a
1006 frame in case there is only one copy of the dummy (e.g.
1007 CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
1008 flush_cached_frames ();
1009 set_current_frame (create_new_frame (read_fp (), sal
.pc
));
1011 /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
1012 a breakpoint instruction. If not, the call dummy already has the
1013 breakpoint instruction in it.
1015 addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
1016 so we need to subtract the CALL_DUMMY_START_OFFSET. */
1017 bpt
= set_momentary_breakpoint (sal
,
1018 get_current_frame (),
1020 bpt
->disposition
= disp_del
;
1022 /* If all error()s out of proceed ended up calling normal_stop (and
1023 perhaps they should; it already does in the special case of error
1024 out of resume()), then we wouldn't need this. */
1025 make_cleanup (breakpoint_auto_delete_contents
, &stop_bpstat
);
1028 disable_watchpoints_before_interactive_call_start ();
1029 proceed_to_finish
= 1; /* We want stop_registers, please... */
1031 if (target_can_async_p ())
1032 saved_async
= target_async_mask (0);
1034 proceed (addr
, TARGET_SIGNAL_0
, 0);
1037 target_async_mask (saved_async
);
1039 enable_watchpoints_after_interactive_call_stop ();
1041 discard_cleanups (old_cleanups
);
1043 /* We can stop during an inferior call because a signal is received. */
1044 if (stopped_by_random_signal
)
1047 /* We may also stop prematurely because we hit a breakpoint in the
1049 if (!stop_stack_dummy
)
1052 /* On normal return, the stack dummy has been popped already. */
1054 memcpy (buffer
, stop_registers
, REGISTER_BYTES
);
1058 /* Proceed until we reach a different source line with pc greater than
1059 our current one or exit the function. We skip calls in both cases.
1061 Note that eventually this command should probably be changed so
1062 that only source lines are printed out when we hit the breakpoint
1063 we set. This may involve changes to wait_for_inferior and the
1064 proceed status code. */
1068 until_next_command (int from_tty
)
1070 struct frame_info
*frame
;
1072 struct symbol
*func
;
1073 struct symtab_and_line sal
;
1075 clear_proceed_status ();
1077 frame
= get_current_frame ();
1079 /* Step until either exited from this function or greater
1080 than the current line (if in symbolic section) or pc (if
1084 func
= find_pc_function (pc
);
1088 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
1090 if (msymbol
== NULL
)
1091 error ("Execution is not within a known function.");
1093 step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
1094 step_range_end
= pc
;
1098 sal
= find_pc_line (pc
, 0);
1100 step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
1101 step_range_end
= sal
.end
;
1104 step_over_calls
= STEP_OVER_ALL
;
1105 step_frame_address
= FRAME_FP (frame
);
1106 step_sp
= read_sp ();
1108 step_multi
= 0; /* Only one call to proceed */
1110 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1114 until_command (char *arg
, int from_tty
)
1118 if (!target_has_execution
)
1119 error ("The program is not running.");
1121 /* Find out whether we must run in the background. */
1123 async_exec
= strip_bg_char (&arg
);
1125 /* If we must run in the background, but the target can't do it,
1127 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
1128 error ("Asynchronous execution not supported on this target.");
1130 /* If we are not asked to run in the bg, then prepare to run in the
1131 foreground, synchronously. */
1132 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
1134 /* Simulate synchronous execution */
1135 async_disable_stdin ();
1139 until_break_command (arg
, from_tty
);
1141 until_next_command (from_tty
);
1145 /* Print the result of a function at the end of a 'finish' command. */
1147 print_return_value (int structure_return
, struct type
*value_type
)
1149 struct value
*value
;
1151 static struct ui_stream
*stb
= NULL
;
1154 if (!structure_return
)
1156 value
= value_being_returned (value_type
, stop_registers
, structure_return
);
1158 stb
= ui_out_stream_new (uiout
);
1159 ui_out_text (uiout
, "Value returned is ");
1160 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d", record_latest_value (value
));
1161 ui_out_text (uiout
, " = ");
1162 value_print (value
, stb
->stream
, 0, Val_no_prettyprint
);
1163 ui_out_field_stream (uiout
, "return-value", stb
);
1164 ui_out_text (uiout
, "\n");
1166 printf_filtered ("Value returned is $%d = ", record_latest_value (value
));
1167 value_print (value
, gdb_stdout
, 0, Val_no_prettyprint
);
1168 printf_filtered ("\n");
1173 /* We cannot determine the contents of the structure because
1174 it is on the stack, and we don't know where, since we did not
1175 initiate the call, as opposed to the call_function_by_hand case */
1176 #ifdef VALUE_RETURNED_FROM_STACK
1179 ui_out_text (uiout
, "Value returned has type: ");
1180 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1181 ui_out_text (uiout
, ".");
1182 ui_out_text (uiout
, " Cannot determine contents\n");
1184 printf_filtered ("Value returned has type: %s.", TYPE_NAME (value_type
));
1185 printf_filtered (" Cannot determine contents\n");
1188 value
= value_being_returned (value_type
, stop_registers
, structure_return
);
1190 stb
= ui_out_stream_new (uiout
);
1191 ui_out_text (uiout
, "Value returned is ");
1192 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d", record_latest_value (value
));
1193 ui_out_text (uiout
, " = ");
1194 value_print (value
, stb
->stream
, 0, Val_no_prettyprint
);
1195 ui_out_field_stream (uiout
, "return-value", stb
);
1196 ui_out_text (uiout
, "\n");
1198 printf_filtered ("Value returned is $%d = ", record_latest_value (value
));
1199 value_print (value
, gdb_stdout
, 0, Val_no_prettyprint
);
1200 printf_filtered ("\n");
1206 /* Stuff that needs to be done by the finish command after the target
1207 has stopped. In asynchronous mode, we wait for the target to stop in
1208 the call to poll or select in the event loop, so it is impossible to
1209 do all the stuff as part of the finish_command function itself. The
1210 only chance we have to complete this command is in
1211 fetch_inferior_event, which is called by the event loop as soon as it
1212 detects that the target has stopped. This function is called via the
1213 cmd_continuation pointer. */
1215 finish_command_continuation (struct continuation_arg
*arg
)
1217 register struct symbol
*function
;
1218 struct breakpoint
*breakpoint
;
1219 struct cleanup
*cleanups
;
1221 breakpoint
= (struct breakpoint
*) arg
->data
.pointer
;
1222 function
= (struct symbol
*) arg
->next
->data
.pointer
;
1223 cleanups
= (struct cleanup
*) arg
->next
->next
->data
.pointer
;
1225 if (bpstat_find_breakpoint (stop_bpstat
, breakpoint
) != NULL
1228 struct type
*value_type
;
1232 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (function
));
1234 internal_error (__FILE__
, __LINE__
,
1235 "finish_command: function has no target type");
1237 if (TYPE_CODE (value_type
) == TYPE_CODE_VOID
)
1239 do_exec_cleanups (cleanups
);
1243 funcaddr
= BLOCK_START (SYMBOL_BLOCK_VALUE (function
));
1245 struct_return
= using_struct_return (value_of_variable (function
, NULL
),
1247 check_typedef (value_type
),
1248 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function
)));
1250 print_return_value (struct_return
, value_type
);
1252 do_exec_cleanups (cleanups
);
1255 /* "finish": Set a temporary breakpoint at the place
1256 the selected frame will return to, then continue. */
1259 finish_command (char *arg
, int from_tty
)
1261 struct symtab_and_line sal
;
1262 register struct frame_info
*frame
;
1263 register struct symbol
*function
;
1264 struct breakpoint
*breakpoint
;
1265 struct cleanup
*old_chain
;
1266 struct continuation_arg
*arg1
, *arg2
, *arg3
;
1270 /* Find out whether we must run in the background. */
1272 async_exec
= strip_bg_char (&arg
);
1274 /* If we must run in the background, but the target can't do it,
1276 if (event_loop_p
&& async_exec
&& !target_can_async_p ())
1277 error ("Asynchronous execution not supported on this target.");
1279 /* If we are not asked to run in the bg, then prepare to run in the
1280 foreground, synchronously. */
1281 if (event_loop_p
&& !async_exec
&& target_can_async_p ())
1283 /* Simulate synchronous execution */
1284 async_disable_stdin ();
1288 error ("The \"finish\" command does not take any arguments.");
1289 if (!target_has_execution
)
1290 error ("The program is not running.");
1291 if (selected_frame
== NULL
)
1292 error ("No selected frame.");
1294 frame
= get_prev_frame (selected_frame
);
1296 error ("\"finish\" not meaningful in the outermost frame.");
1298 clear_proceed_status ();
1300 sal
= find_pc_line (frame
->pc
, 0);
1303 breakpoint
= set_momentary_breakpoint (sal
, frame
, bp_finish
);
1305 if (!event_loop_p
|| !target_can_async_p ())
1306 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1308 old_chain
= make_exec_cleanup_delete_breakpoint (breakpoint
);
1310 /* Find the function we will return from. */
1312 function
= find_pc_function (selected_frame
->pc
);
1314 /* Print info on the selected frame, including level number
1318 printf_filtered ("Run till exit from ");
1319 print_stack_frame (selected_frame
, selected_frame_level
, 0);
1322 /* If running asynchronously and the target support asynchronous
1323 execution, set things up for the rest of the finish command to be
1324 completed later on, when gdb has detected that the target has
1325 stopped, in fetch_inferior_event. */
1326 if (event_loop_p
&& target_can_async_p ())
1329 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1331 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1333 (struct continuation_arg
*) xmalloc (sizeof (struct continuation_arg
));
1337 arg1
->data
.pointer
= breakpoint
;
1338 arg2
->data
.pointer
= function
;
1339 arg3
->data
.pointer
= old_chain
;
1340 add_continuation (finish_command_continuation
, arg1
);
1343 proceed_to_finish
= 1; /* We want stop_registers, please... */
1344 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1346 /* Do this only if not running asynchronously or if the target
1347 cannot do async execution. Otherwise, complete this command when
1348 the target actually stops, in fetch_inferior_event. */
1349 if (!event_loop_p
|| !target_can_async_p ())
1352 /* Did we stop at our breakpoint? */
1353 if (bpstat_find_breakpoint (stop_bpstat
, breakpoint
) != NULL
1356 struct type
*value_type
;
1360 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (function
));
1362 internal_error (__FILE__
, __LINE__
,
1363 "finish_command: function has no target type");
1365 /* FIXME: Shouldn't we do the cleanups before returning? */
1366 if (TYPE_CODE (value_type
) == TYPE_CODE_VOID
)
1369 funcaddr
= BLOCK_START (SYMBOL_BLOCK_VALUE (function
));
1372 using_struct_return (value_of_variable (function
, NULL
),
1374 check_typedef (value_type
),
1375 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function
)));
1377 print_return_value (struct_return
, value_type
);
1379 do_cleanups (old_chain
);
1385 program_info (char *args
, int from_tty
)
1387 bpstat bs
= stop_bpstat
;
1388 int num
= bpstat_num (&bs
);
1390 if (!target_has_execution
)
1392 printf_filtered ("The program being debugged is not being run.\n");
1396 target_files_info ();
1397 printf_filtered ("Program stopped at %s.\n",
1398 local_hex_string ((unsigned long) stop_pc
));
1400 printf_filtered ("It stopped after being stepped.\n");
1403 /* There may be several breakpoints in the same place, so this
1404 isn't as strange as it seems. */
1409 printf_filtered ("It stopped at a breakpoint that has ");
1410 printf_filtered ("since been deleted.\n");
1413 printf_filtered ("It stopped at breakpoint %d.\n", num
);
1414 num
= bpstat_num (&bs
);
1417 else if (stop_signal
!= TARGET_SIGNAL_0
)
1419 printf_filtered ("It stopped with signal %s, %s.\n",
1420 target_signal_to_name (stop_signal
),
1421 target_signal_to_string (stop_signal
));
1426 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1427 printf_filtered ("for more information.\n");
1432 environment_info (char *var
, int from_tty
)
1436 register char *val
= get_in_environ (inferior_environ
, var
);
1439 puts_filtered (var
);
1440 puts_filtered (" = ");
1441 puts_filtered (val
);
1442 puts_filtered ("\n");
1446 puts_filtered ("Environment variable \"");
1447 puts_filtered (var
);
1448 puts_filtered ("\" not defined.\n");
1453 register char **vector
= environ_vector (inferior_environ
);
1456 puts_filtered (*vector
++);
1457 puts_filtered ("\n");
1463 set_environment_command (char *arg
, int from_tty
)
1465 register char *p
, *val
, *var
;
1469 error_no_arg ("environment variable and value");
1471 /* Find seperation between variable name and value */
1472 p
= (char *) strchr (arg
, '=');
1473 val
= (char *) strchr (arg
, ' ');
1475 if (p
!= 0 && val
!= 0)
1477 /* We have both a space and an equals. If the space is before the
1478 equals, walk forward over the spaces til we see a nonspace
1479 (possibly the equals). */
1484 /* Now if the = is after the char following the spaces,
1485 take the char following the spaces. */
1489 else if (val
!= 0 && p
== 0)
1493 error_no_arg ("environment variable to set");
1495 if (p
== 0 || p
[1] == 0)
1499 p
= arg
+ strlen (arg
); /* So that savestring below will work */
1503 /* Not setting variable value to null */
1505 while (*val
== ' ' || *val
== '\t')
1509 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1512 var
= savestring (arg
, p
- arg
);
1515 printf_filtered ("Setting environment variable ");
1516 printf_filtered ("\"%s\" to null value.\n", var
);
1517 set_in_environ (inferior_environ
, var
, "");
1520 set_in_environ (inferior_environ
, var
, val
);
1525 unset_environment_command (char *var
, int from_tty
)
1529 /* If there is no argument, delete all environment variables.
1530 Ask for confirmation if reading from the terminal. */
1531 if (!from_tty
|| query ("Delete all environment variables? "))
1533 free_environ (inferior_environ
);
1534 inferior_environ
= make_environ ();
1538 unset_in_environ (inferior_environ
, var
);
1541 /* Handle the execution path (PATH variable) */
1543 static const char path_var_name
[] = "PATH";
1547 path_info (char *args
, int from_tty
)
1549 puts_filtered ("Executable and object file path: ");
1550 puts_filtered (get_in_environ (inferior_environ
, path_var_name
));
1551 puts_filtered ("\n");
1554 /* Add zero or more directories to the front of the execution path. */
1557 path_command (char *dirname
, int from_tty
)
1562 env
= get_in_environ (inferior_environ
, path_var_name
);
1563 /* Can be null if path is not set */
1566 exec_path
= xstrdup (env
);
1567 mod_path (dirname
, &exec_path
);
1568 set_in_environ (inferior_environ
, path_var_name
, exec_path
);
1571 path_info ((char *) NULL
, from_tty
);
1575 #ifdef REGISTER_NAMES
1576 char *gdb_register_names
[] = REGISTER_NAMES
;
1578 /* Print out the machine register regnum. If regnum is -1,
1579 print all registers (fpregs == 1) or all non-float registers
1582 For most machines, having all_registers_info() print the
1583 register(s) one per line is good enough. If a different format
1584 is required, (eg, for MIPS or Pyramid 90x, which both have
1585 lots of regs), or there is an existing convention for showing
1586 all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
1587 to provide that format. */
1590 do_registers_info (int regnum
, int fpregs
)
1593 int numregs
= NUM_REGS
+ NUM_PSEUDO_REGS
;
1594 char *raw_buffer
= (char*) alloca (MAX_REGISTER_RAW_SIZE
);
1595 char *virtual_buffer
= (char*) alloca (MAX_REGISTER_VIRTUAL_SIZE
);
1597 for (i
= 0; i
< numregs
; i
++)
1599 /* Decide between printing all regs, nonfloat regs, or specific reg. */
1602 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
&& !fpregs
)
1611 /* If the register name is empty, it is undefined for this
1612 processor, so don't display anything. */
1613 if (REGISTER_NAME (i
) == NULL
|| *(REGISTER_NAME (i
)) == '\0')
1616 fputs_filtered (REGISTER_NAME (i
), gdb_stdout
);
1617 print_spaces_filtered (15 - strlen (REGISTER_NAME (i
)), gdb_stdout
);
1619 /* Get the data in raw format. */
1620 if (read_relative_register_raw_bytes (i
, raw_buffer
))
1622 printf_filtered ("*value not available*\n");
1626 /* Convert raw data to virtual format if necessary. */
1627 if (REGISTER_CONVERTIBLE (i
))
1629 REGISTER_CONVERT_TO_VIRTUAL (i
, REGISTER_VIRTUAL_TYPE (i
),
1630 raw_buffer
, virtual_buffer
);
1634 memcpy (virtual_buffer
, raw_buffer
,
1635 REGISTER_VIRTUAL_SIZE (i
));
1638 /* If virtual format is floating, print it that way, and in raw hex. */
1639 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i
)) == TYPE_CODE_FLT
)
1643 #ifdef INVALID_FLOAT
1644 if (INVALID_FLOAT (virtual_buffer
, REGISTER_VIRTUAL_SIZE (i
)))
1645 printf_filtered ("<invalid float>");
1648 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1649 gdb_stdout
, 0, 1, 0, Val_pretty_default
);
1651 printf_filtered ("\t(raw 0x");
1652 for (j
= 0; j
< REGISTER_RAW_SIZE (i
); j
++)
1654 register int idx
= TARGET_BYTE_ORDER
== BIG_ENDIAN
? j
1655 : REGISTER_RAW_SIZE (i
) - 1 - j
;
1656 printf_filtered ("%02x", (unsigned char) raw_buffer
[idx
]);
1658 printf_filtered (")");
1660 /* Else print as integer in hex and in decimal. */
1663 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1664 gdb_stdout
, 'x', 1, 0, Val_pretty_default
);
1665 printf_filtered ("\t");
1666 val_print (REGISTER_VIRTUAL_TYPE (i
), virtual_buffer
, 0, 0,
1667 gdb_stdout
, 0, 1, 0, Val_pretty_default
);
1670 /* The SPARC wants to print even-numbered float regs as doubles
1671 in addition to printing them as floats. */
1672 #ifdef PRINT_REGISTER_HOOK
1673 PRINT_REGISTER_HOOK (i
);
1676 printf_filtered ("\n");
1681 registers_info (char *addr_exp
, int fpregs
)
1683 int regnum
, numregs
;
1686 if (!target_has_registers
)
1687 error ("The program has no registers now.");
1688 if (selected_frame
== NULL
)
1689 error ("No selected frame.");
1693 DO_REGISTERS_INFO (-1, fpregs
);
1699 if (addr_exp
[0] == '$')
1702 while (*end
!= '\0' && *end
!= ' ' && *end
!= '\t')
1704 numregs
= NUM_REGS
+ NUM_PSEUDO_REGS
;
1706 regnum
= target_map_name_to_register (addr_exp
, end
- addr_exp
);
1712 if (*addr_exp
>= '0' && *addr_exp
<= '9')
1713 regnum
= atoi (addr_exp
); /* Take a number */
1714 if (regnum
>= numregs
) /* Bad name, or bad number */
1715 error ("%.*s: invalid register", end
- addr_exp
, addr_exp
);
1718 DO_REGISTERS_INFO (regnum
, fpregs
);
1721 while (*addr_exp
== ' ' || *addr_exp
== '\t')
1724 while (*addr_exp
!= '\0');
1728 all_registers_info (char *addr_exp
, int from_tty
)
1730 registers_info (addr_exp
, 1);
1734 nofp_registers_info (char *addr_exp
, int from_tty
)
1736 registers_info (addr_exp
, 0);
1742 * Should save/restore the tty state since it might be that the
1743 * program to be debugged was started on this tty and it wants
1744 * the tty in some state other than what we want. If it's running
1745 * on another terminal or without a terminal, then saving and
1746 * restoring the tty state is a harmless no-op.
1747 * This only needs to be done if we are attaching to a process.
1752 takes a program started up outside of gdb and ``attaches'' to it.
1753 This stops it cold in its tracks and allows us to start debugging it.
1754 and wait for the trace-trap that results from attaching. */
1757 attach_command (char *args
, int from_tty
)
1760 char *full_exec_path
= NULL
;
1762 dont_repeat (); /* Not for the faint of heart */
1764 if (target_has_execution
)
1766 if (query ("A program is being debugged already. Kill it? "))
1769 error ("Not killed.");
1772 target_attach (args
, from_tty
);
1774 /* Set up the "saved terminal modes" of the inferior
1775 based on what modes we are starting it with. */
1776 target_terminal_init ();
1778 /* Install inferior's terminal modes. */
1779 target_terminal_inferior ();
1781 /* Set up execution context to know that we should return from
1782 wait_for_inferior as soon as the target reports a stop. */
1783 init_wait_for_inferior ();
1784 clear_proceed_status ();
1786 /* No traps are generated when attaching to inferior under Mach 3
1788 #ifndef ATTACH_NO_WAIT
1789 stop_soon_quietly
= 1;
1790 wait_for_inferior ();
1794 * If no exec file is yet known, try to determine it from the
1797 exec_file
= (char *) get_exec_file (0);
1800 exec_file
= target_pid_to_exec_file (PIDGET (inferior_ptid
));
1803 /* It's possible we don't have a full path, but rather just a
1804 filename. Some targets, such as HP-UX, don't provide the
1807 Attempt to qualify the filename against the source path.
1808 (If that fails, we'll just fall back on the original
1809 filename. Not much more we can do...)
1811 if (!source_full_path_of (exec_file
, &full_exec_path
))
1812 full_exec_path
= savestring (exec_file
, strlen (exec_file
));
1814 exec_file_attach (full_exec_path
, from_tty
);
1815 symbol_file_add_main (full_exec_path
, from_tty
);
1820 /* Add shared library symbols from the newly attached process, if any. */
1821 SOLIB_ADD ((char *) 0, from_tty
, ¤t_target
, auto_solib_add
);
1822 re_enable_breakpoints_in_shlibs ();
1825 /* Take any necessary post-attaching actions for this platform.
1827 target_post_attach (PIDGET (inferior_ptid
));
1837 * takes a program previously attached to and detaches it.
1838 * The program resumes execution and will no longer stop
1839 * on signals, etc. We better not have left any breakpoints
1840 * in the program or it'll die when it hits one. For this
1841 * to work, it may be necessary for the process to have been
1842 * previously attached. It *might* work if the program was
1843 * started via the normal ptrace (PTRACE_TRACEME).
1847 detach_command (char *args
, int from_tty
)
1849 dont_repeat (); /* Not for the faint of heart */
1850 target_detach (args
, from_tty
);
1851 #if defined(SOLIB_RESTART)
1858 /* Stop the execution of the target while running in async mode, in
1862 interrupt_target_command_wrapper (char *args
, int from_tty
)
1864 interrupt_target_command (args
, from_tty
);
1868 interrupt_target_command (char *args
, int from_tty
)
1870 if (event_loop_p
&& target_can_async_p ())
1872 dont_repeat (); /* Not for the faint of heart */
1879 float_info (char *addr_exp
, int from_tty
)
1884 printf_filtered ("No floating point info available for this processor.\n");
1890 unset_command (char *args
, int from_tty
)
1892 printf_filtered ("\"unset\" must be followed by the name of ");
1893 printf_filtered ("an unset subcommand.\n");
1894 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
1898 _initialize_infcmd (void)
1900 struct cmd_list_element
*c
;
1902 c
= add_com ("tty", class_run
, tty_command
,
1903 "Set terminal for future runs of program being debugged.");
1904 c
->completer
= filename_completer
;
1906 c
= add_set_cmd ("args", class_run
, var_string_noescape
,
1907 (char *) &inferior_args
,
1908 "Set argument list to give program being debugged when it is started.\n\
1909 Follow this command with any number of args, to be passed to the program.",
1911 c
->completer
= filename_completer
;
1912 c
->function
.sfunc
= notice_args_set
;
1913 c
= add_show_from_set (c
, &showlist
);
1914 c
->pre_show_hook
= notice_args_read
;
1917 ("environment", no_class
, environment_info
,
1918 "The environment to give the program, or one variable's value.\n\
1919 With an argument VAR, prints the value of environment variable VAR to\n\
1920 give the program being debugged. With no arguments, prints the entire\n\
1921 environment to be given to the program.", &showlist
);
1922 c
->completer
= noop_completer
;
1924 add_prefix_cmd ("unset", no_class
, unset_command
,
1925 "Complement to certain \"set\" commands",
1926 &unsetlist
, "unset ", 0, &cmdlist
);
1928 c
= add_cmd ("environment", class_run
, unset_environment_command
,
1929 "Cancel environment variable VAR for the program.\n\
1930 This does not affect the program until the next \"run\" command.",
1932 c
->completer
= noop_completer
;
1934 c
= add_cmd ("environment", class_run
, set_environment_command
,
1935 "Set environment variable value to give the program.\n\
1936 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
1937 VALUES of environment variables are uninterpreted strings.\n\
1938 This does not affect the program until the next \"run\" command.",
1940 c
->completer
= noop_completer
;
1942 c
= add_com ("path", class_files
, path_command
,
1943 "Add directory DIR(s) to beginning of search path for object files.\n\
1944 $cwd in the path means the current working directory.\n\
1945 This path is equivalent to the $PATH shell variable. It is a list of\n\
1946 directories, separated by colons. These directories are searched to find\n\
1947 fully linked executable files and separately compiled object files as needed.");
1948 c
->completer
= filename_completer
;
1950 c
= add_cmd ("paths", no_class
, path_info
,
1951 "Current search path for finding object files.\n\
1952 $cwd in the path means the current working directory.\n\
1953 This path is equivalent to the $PATH shell variable. It is a list of\n\
1954 directories, separated by colons. These directories are searched to find\n\
1955 fully linked executable files and separately compiled object files as needed.",
1957 c
->completer
= noop_completer
;
1959 add_com ("attach", class_run
, attach_command
,
1960 "Attach to a process or file outside of GDB.\n\
1961 This command attaches to another target, of the same type as your last\n\
1962 \"target\" command (\"info files\" will show your target stack).\n\
1963 The command may take as argument a process id or a device file.\n\
1964 For a process id, you must have permission to send the process a signal,\n\
1965 and it must have the same effective uid as the debugger.\n\
1966 When using \"attach\" with a process id, the debugger finds the\n\
1967 program running in the process, looking first in the current working\n\
1968 directory, or (if not found there) using the source file search path\n\
1969 (see the \"directory\" command). You can also use the \"file\" command\n\
1970 to specify the program, and to load its symbol table.");
1972 add_com ("detach", class_run
, detach_command
,
1973 "Detach a process or file previously attached.\n\
1974 If a process, it is no longer traced, and it continues its execution. If\n\
1975 you were debugging a file, the file is closed and gdb no longer accesses it.");
1977 add_com ("signal", class_run
, signal_command
,
1978 "Continue program giving it signal specified by the argument.\n\
1979 An argument of \"0\" means continue program without giving it a signal.");
1981 add_com ("stepi", class_run
, stepi_command
,
1982 "Step one instruction exactly.\n\
1983 Argument N means do this N times (or till program stops for another reason).");
1984 add_com_alias ("si", "stepi", class_alias
, 0);
1986 add_com ("nexti", class_run
, nexti_command
,
1987 "Step one instruction, but proceed through subroutine calls.\n\
1988 Argument N means do this N times (or till program stops for another reason).");
1989 add_com_alias ("ni", "nexti", class_alias
, 0);
1991 add_com ("finish", class_run
, finish_command
,
1992 "Execute until selected stack frame returns.\n\
1993 Upon return, the value returned is printed and put in the value history.");
1995 add_com ("next", class_run
, next_command
,
1996 "Step program, proceeding through subroutine calls.\n\
1997 Like the \"step\" command as long as subroutine calls do not happen;\n\
1998 when they do, the call is treated as one instruction.\n\
1999 Argument N means do this N times (or till program stops for another reason).");
2000 add_com_alias ("n", "next", class_run
, 1);
2002 add_com_alias ("S", "next", class_run
, 1);
2004 add_com ("step", class_run
, step_command
,
2005 "Step program until it reaches a different source line.\n\
2006 Argument N means do this N times (or till program stops for another reason).");
2007 add_com_alias ("s", "step", class_run
, 1);
2009 c
= add_com ("until", class_run
, until_command
,
2010 "Execute until the program reaches a source line greater than the current\n\
2011 or a specified line or address or function (same args as break command).\n\
2012 Execution will also stop upon exit from the current stack frame.");
2013 c
->completer
= location_completer
;
2014 add_com_alias ("u", "until", class_run
, 1);
2016 c
= add_com ("jump", class_run
, jump_command
,
2017 "Continue program being debugged at specified line or address.\n\
2018 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2019 for an address to start at.");
2020 c
->completer
= location_completer
;
2024 c
= add_com ("go", class_run
, go_command
,
2025 "Usage: go <location>\n\
2026 Continue program being debugged, stopping at specified line or \n\
2028 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2029 expression for an address to start at.\n\
2030 This command is a combination of tbreak and jump.");
2031 c
->completer
= location_completer
;
2035 add_com_alias ("g", "go", class_run
, 1);
2037 add_com ("continue", class_run
, continue_command
,
2038 "Continue program being debugged, after signal or breakpoint.\n\
2039 If proceeding from breakpoint, a number N may be used as an argument,\n\
2040 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2041 the breakpoint won't break until the Nth time it is reached).");
2042 add_com_alias ("c", "cont", class_run
, 1);
2043 add_com_alias ("fg", "cont", class_run
, 1);
2045 c
= add_com ("run", class_run
, run_command
,
2046 "Start debugged program. You may specify arguments to give it.\n\
2047 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2048 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2049 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2050 To cancel previous arguments and run with no arguments,\n\
2051 use \"set args\" without arguments.");
2052 c
->completer
= filename_completer
;
2053 add_com_alias ("r", "run", class_run
, 1);
2055 add_com ("R", class_run
, run_no_args_command
,
2056 "Start debugged program with no arguments.");
2058 add_com ("interrupt", class_run
, interrupt_target_command
,
2059 "Interrupt the execution of the debugged program.");
2061 add_info ("registers", nofp_registers_info
,
2062 "List of integer registers and their contents, for selected stack frame.\n\
2063 Register name as argument means describe only that register.");
2064 add_info_alias ("r", "registers", 1);
2067 add_com ("lr", class_info
, nofp_registers_info
,
2068 "List of integer registers and their contents, for selected stack frame.\n\
2069 Register name as argument means describe only that register.");
2070 add_info ("all-registers", all_registers_info
,
2071 "List of all registers and their contents, for selected stack frame.\n\
2072 Register name as argument means describe only that register.");
2074 add_info ("program", program_info
,
2075 "Execution status of the program.");
2077 add_info ("float", float_info
,
2078 "Print the status of the floating point unit\n");
2080 inferior_environ
= make_environ ();
2081 init_environ (inferior_environ
);