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, 2002, 2003, 2004
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"
41 #include "event-top.h"
42 #include "parser-defs.h"
44 #include "reggroups.h"
47 #include "gdb_assert.h"
49 /* Functions exported for general use, in inferior.h: */
51 void all_registers_info (char *, int);
53 void registers_info (char *, int);
55 void nexti_command (char *, int);
57 void stepi_command (char *, int);
59 void continue_command (char *, int);
61 void interrupt_target_command (char *args, int from_tty);
63 /* Local functions: */
65 static void nofp_registers_info (char *, int);
67 static void print_return_value (int struct_return, struct type *value_type);
69 static void finish_command_continuation (struct continuation_arg *);
71 static void until_next_command (int);
73 static void until_command (char *, int);
75 static void path_info (char *, int);
77 static void path_command (char *, int);
79 static void unset_command (char *, int);
81 static void float_info (char *, int);
83 static void detach_command (char *, int);
85 static void disconnect_command (char *, int);
87 static void unset_environment_command (char *, int);
89 static void set_environment_command (char *, int);
91 static void environment_info (char *, int);
93 static void program_info (char *, int);
95 static void finish_command (char *, int);
97 static void signal_command (char *, int);
99 static void jump_command (char *, int);
101 static void step_1 (int, int, char *);
102 static void step_once (int skip_subroutines, int single_inst, int count);
103 static void step_1_continuation (struct continuation_arg *arg);
105 static void next_command (char *, int);
107 static void step_command (char *, int);
109 static void run_command (char *, int);
111 static void run_no_args_command (char *args, int from_tty);
113 static void go_command (char *line_no, int from_tty);
115 static int strip_bg_char (char **);
117 void _initialize_infcmd (void);
119 #define GO_USAGE "Usage: go <location>\n"
121 #define ERROR_NO_INFERIOR \
122 if (!target_has_execution) error ("The program is not being run.");
124 /* String containing arguments to give to the program, separated by spaces.
125 Empty string (pointer to '\0') means no args. */
127 static char *inferior_args;
129 /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
130 then we must compute INFERIOR_ARGS from this (via the target). */
132 static int inferior_argc;
133 static char **inferior_argv;
135 /* File name for default use for standard in/out in the inferior. */
137 char *inferior_io_terminal;
139 /* Pid of our debugged inferior, or 0 if no inferior now.
140 Since various parts of infrun.c test this to see whether there is a program
141 being debugged it should be nonzero (currently 3 is used) for remote
144 ptid_t inferior_ptid;
146 /* Last signal that the inferior received (why it stopped). */
148 enum target_signal stop_signal;
150 /* Address at which inferior stopped. */
154 /* Chain containing status of breakpoint(s) that we have stopped at. */
158 /* Flag indicating that a command has proceeded the inferior past the
159 current breakpoint. */
161 int breakpoint_proceeded;
163 /* Nonzero if stopped due to a step command. */
167 /* Nonzero if stopped due to completion of a stack dummy routine. */
169 int stop_stack_dummy;
171 /* Nonzero if stopped due to a random (unexpected) signal in inferior
174 int stopped_by_random_signal;
176 /* Range to single step within.
177 If this is nonzero, respond to a single-step signal
178 by continuing to step if the pc is in this range. */
180 CORE_ADDR step_range_start; /* Inclusive */
181 CORE_ADDR step_range_end; /* Exclusive */
183 /* Stack frame address as of when stepping command was issued.
184 This is how we know when we step into a subroutine call,
185 and how to set the frame for the breakpoint used to step out. */
187 struct frame_id step_frame_id;
189 enum step_over_calls_kind step_over_calls;
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;
202 /* Accessor routines. */
205 get_inferior_args (void)
207 if (inferior_argc != 0)
211 n = gdbarch_construct_inferior_arguments (current_gdbarch,
212 inferior_argc, inferior_argv);
213 old = set_inferior_args (n);
217 if (inferior_args == NULL)
218 inferior_args = xstrdup ("");
220 return inferior_args;
224 set_inferior_args (char *newargs)
226 char *saved_args = inferior_args;
228 inferior_args = newargs;
236 set_inferior_args_vector (int argc, char **argv)
238 inferior_argc = argc;
239 inferior_argv = argv;
242 /* Notice when `set args' is run. */
244 notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
250 /* Notice when `show args' is run. */
252 notice_args_read (char *args, int from_tty, struct cmd_list_element *c)
254 /* Might compute the value. */
255 get_inferior_args ();
259 /* Compute command-line string given argument vector. This does the
260 same shell processing as fork_inferior. */
262 construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
266 if (STARTUP_WITH_SHELL)
268 /* This holds all the characters considered special to the
269 typical Unix shells. We include `^' because the SunOS
270 /bin/sh treats it as a synonym for `|'. */
271 char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
276 /* We over-compute the size. It shouldn't matter. */
277 for (i = 0; i < argc; ++i)
278 length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
280 result = (char *) xmalloc (length);
283 for (i = 0; i < argc; ++i)
288 /* Need to handle empty arguments specially. */
289 if (argv[i][0] == '\0')
296 for (cp = argv[i]; *cp; ++cp)
298 if (strchr (special, *cp) != NULL)
308 /* In this case we can't handle arguments that contain spaces,
309 tabs, or newlines -- see breakup_args(). */
313 for (i = 0; i < argc; ++i)
315 char *cp = strchr (argv[i], ' ');
317 cp = strchr (argv[i], '\t');
319 cp = strchr (argv[i], '\n');
321 error ("can't handle command-line argument containing whitespace");
322 length += strlen (argv[i]) + 1;
325 result = (char *) xmalloc (length);
327 for (i = 0; i < argc; ++i)
330 strcat (result, " ");
331 strcat (result, argv[i]);
339 /* This function detects whether or not a '&' character (indicating
340 background execution) has been added as *the last* of the arguments ARGS
341 of a command. If it has, it removes it and returns 1. Otherwise it
342 does nothing and returns 0. */
344 strip_bg_char (char **args)
348 p = strchr (*args, '&');
352 if (p == (*args + strlen (*args) - 1))
354 if (strlen (*args) > 1)
358 while (*p == ' ' || *p == '\t');
370 tty_command (char *file, int from_tty)
373 error_no_arg ("terminal name for running target process");
375 inferior_io_terminal = savestring (file, strlen (file));
378 /* Kill the inferior if already running. This function is designed
379 to be called when we are about to start the execution of the program
380 from the beginning. Ask the user to confirm that he wants to restart
381 the program being debugged when FROM_TTY is non-null. */
384 kill_if_already_running (int from_tty)
386 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
389 && !query ("The program being debugged has been started already.\n\
390 Start it from the beginning? "))
391 error ("Program not restarted.");
393 #if defined(SOLIB_RESTART)
396 init_wait_for_inferior ();
401 run_command (char *args, int from_tty)
407 kill_if_already_running (from_tty);
408 clear_breakpoint_hit_counts ();
410 /* Purge old solib objfiles. */
411 objfile_purge_solibs ();
413 do_run_cleanups (NULL);
415 /* The comment here used to read, "The exec file is re-read every
416 time we do a generic_mourn_inferior, so we just have to worry
417 about the symbol file." The `generic_mourn_inferior' function
418 gets called whenever the program exits. However, suppose the
419 program exits, and *then* the executable file changes? We need
420 to check again here. Since reopen_exec_file doesn't do anything
421 if the timestamp hasn't changed, I don't see the harm. */
425 exec_file = (char *) get_exec_file (0);
427 /* We keep symbols from add-symbol-file, on the grounds that the
428 user might want to add some symbols before running the program
429 (right?). But sometimes (dynamic loading where the user manually
430 introduces the new symbols with add-symbol-file), the code which
431 the symbols describe does not persist between runs. Currently
432 the user has to manually nuke all symbols between runs if they
433 want them to go away (PR 2207). This is probably reasonable. */
437 if (target_can_async_p ())
438 async_disable_stdin ();
442 int async_exec = strip_bg_char (&args);
444 /* If we get a request for running in the bg but the target
445 doesn't support it, error out. */
446 if (async_exec && !target_can_async_p ())
447 error ("Asynchronous execution not supported on this target.");
449 /* If we don't get a request of running in the bg, then we need
450 to simulate synchronous (fg) execution. */
451 if (!async_exec && target_can_async_p ())
453 /* Simulate synchronous execution */
454 async_disable_stdin ();
457 /* If there were other args, beside '&', process them. */
460 char *old_args = set_inferior_args (xstrdup (args));
467 ui_out_field_string (uiout, NULL, "Starting program");
468 ui_out_text (uiout, ": ");
470 ui_out_field_string (uiout, "execfile", exec_file);
471 ui_out_spaces (uiout, 1);
472 /* We call get_inferior_args() because we might need to compute
474 ui_out_field_string (uiout, "infargs", get_inferior_args ());
475 ui_out_text (uiout, "\n");
476 ui_out_flush (uiout);
479 /* We call get_inferior_args() because we might need to compute
481 target_create_inferior (exec_file, get_inferior_args (),
482 environ_vector (inferior_environ), from_tty);
487 run_no_args_command (char *args, int from_tty)
489 char *old_args = set_inferior_args (xstrdup (""));
494 /* Start the execution of the program up until the beginning of the main
498 start_command (char *args, int from_tty)
500 /* Some languages such as Ada need to search inside the program
501 minimal symbols for the location where to put the temporary
502 breakpoint before starting. */
503 if (!have_minimal_symbols ())
504 error ("No symbol table loaded. Use the \"file\" command.");
506 /* If the inferior is already running, we want to ask the user if we
507 should restart it or not before we insert the temporary breakpoint.
508 This makes sure that this command doesn't have any side effect if
509 the user changes its mind. */
510 kill_if_already_running (from_tty);
512 /* Insert the temporary breakpoint, and run... */
513 tbreak_command (main_name (), 0);
514 run_command (args, from_tty);
518 continue_command (char *proc_count_exp, int from_tty)
523 /* Find out whether we must run in the background. */
524 if (proc_count_exp != NULL)
525 async_exec = strip_bg_char (&proc_count_exp);
527 /* If we must run in the background, but the target can't do it,
529 if (async_exec && !target_can_async_p ())
530 error ("Asynchronous execution not supported on this target.");
532 /* If we are not asked to run in the bg, then prepare to run in the
533 foreground, synchronously. */
534 if (!async_exec && target_can_async_p ())
536 /* Simulate synchronous execution */
537 async_disable_stdin ();
540 /* If have argument (besides '&'), set proceed count of breakpoint
542 if (proc_count_exp != NULL)
544 bpstat bs = stop_bpstat;
545 int num = bpstat_num (&bs);
546 if (num == 0 && from_tty)
549 ("Not stopped at any breakpoint; argument ignored.\n");
553 set_ignore_count (num,
554 parse_and_eval_long (proc_count_exp) - 1,
556 /* set_ignore_count prints a message ending with a period.
557 So print two spaces before "Continuing.". */
559 printf_filtered (" ");
560 num = bpstat_num (&bs);
565 printf_filtered ("Continuing.\n");
567 clear_proceed_status ();
569 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
572 /* Step until outside of current statement. */
575 step_command (char *count_string, int from_tty)
577 step_1 (0, 0, count_string);
580 /* Likewise, but skip over subroutine calls as if single instructions. */
583 next_command (char *count_string, int from_tty)
585 step_1 (1, 0, count_string);
588 /* Likewise, but step only one instruction. */
591 stepi_command (char *count_string, int from_tty)
593 step_1 (0, 1, count_string);
597 nexti_command (char *count_string, int from_tty)
599 step_1 (1, 1, count_string);
603 disable_longjmp_breakpoint_cleanup (void *ignore)
605 disable_longjmp_breakpoint ();
609 step_1 (int skip_subroutines, int single_inst, char *count_string)
612 struct frame_info *frame;
613 struct cleanup *cleanups = 0;
619 async_exec = strip_bg_char (&count_string);
621 /* If we get a request for running in the bg but the target
622 doesn't support it, error out. */
623 if (async_exec && !target_can_async_p ())
624 error ("Asynchronous execution not supported on this target.");
626 /* If we don't get a request of running in the bg, then we need
627 to simulate synchronous (fg) execution. */
628 if (!async_exec && target_can_async_p ())
630 /* Simulate synchronous execution */
631 async_disable_stdin ();
634 count = count_string ? parse_and_eval_long (count_string) : 1;
636 if (!single_inst || skip_subroutines) /* leave si command alone */
638 enable_longjmp_breakpoint ();
639 if (!target_can_async_p ())
640 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
642 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
645 /* In synchronous case, all is well, just use the regular for loop. */
646 if (!target_can_async_p ())
648 for (; count > 0; count--)
650 clear_proceed_status ();
652 frame = get_current_frame ();
653 if (!frame) /* Avoid coredump here. Why tho? */
654 error ("No current frame");
655 step_frame_id = get_frame_id (frame);
659 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
660 if (step_range_end == 0)
663 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
664 &step_range_end) == 0)
665 error ("Cannot find bounds of current function");
667 target_terminal_ours ();
669 Single stepping until exit from function %s, \n\
670 which has no line number information.\n", name);
675 /* Say we are stepping, but stop after one insn whatever it does. */
676 step_range_start = step_range_end = 1;
677 if (!skip_subroutines)
679 Don't step over function calls, not even to functions lacking
681 step_over_calls = STEP_OVER_NONE;
684 if (skip_subroutines)
685 step_over_calls = STEP_OVER_ALL;
687 step_multi = (count > 1);
688 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
694 if (!single_inst || skip_subroutines)
695 do_cleanups (cleanups);
698 /* In case of asynchronous target things get complicated, do only
699 one step for now, before returning control to the event loop. Let
700 the continuation figure out how many other steps we need to do,
701 and handle them one at the time, through step_once(). */
704 if (target_can_async_p ())
705 step_once (skip_subroutines, single_inst, count);
709 /* Called after we are done with one step operation, to check whether
710 we need to step again, before we print the prompt and return control
711 to the user. If count is > 1, we will need to do one more call to
712 proceed(), via step_once(). Basically it is like step_once and
713 step_1_continuation are co-recursive. */
715 step_1_continuation (struct continuation_arg *arg)
718 int skip_subroutines;
721 skip_subroutines = arg->data.integer;
722 single_inst = arg->next->data.integer;
723 count = arg->next->next->data.integer;
726 step_once (skip_subroutines, single_inst, count - 1);
728 if (!single_inst || skip_subroutines)
729 do_exec_cleanups (ALL_CLEANUPS);
732 /* Do just one step operation. If count >1 we will have to set up a
733 continuation to be done after the target stops (after this one
734 step). This is useful to implement the 'step n' kind of commands, in
735 case of asynchronous targets. We had to split step_1 into two parts,
736 one to be done before proceed() and one afterwards. This function is
737 called in case of step n with n>1, after the first step operation has
740 step_once (int skip_subroutines, int single_inst, int count)
742 struct continuation_arg *arg1;
743 struct continuation_arg *arg2;
744 struct continuation_arg *arg3;
745 struct frame_info *frame;
749 clear_proceed_status ();
751 frame = get_current_frame ();
752 if (!frame) /* Avoid coredump here. Why tho? */
753 error ("No current frame");
754 step_frame_id = get_frame_id (frame);
758 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
760 /* If we have no line info, switch to stepi mode. */
761 if (step_range_end == 0 && step_stop_if_no_debug)
763 step_range_start = step_range_end = 1;
765 else if (step_range_end == 0)
768 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
769 &step_range_end) == 0)
770 error ("Cannot find bounds of current function");
772 target_terminal_ours ();
774 Single stepping until exit from function %s, \n\
775 which has no line number information.\n", name);
780 /* Say we are stepping, but stop after one insn whatever it does. */
781 step_range_start = step_range_end = 1;
782 if (!skip_subroutines)
784 Don't step over function calls, not even to functions lacking
786 step_over_calls = STEP_OVER_NONE;
789 if (skip_subroutines)
790 step_over_calls = STEP_OVER_ALL;
792 step_multi = (count > 1);
794 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
796 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
798 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
800 arg1->data.integer = skip_subroutines;
802 arg2->data.integer = single_inst;
804 arg3->data.integer = count;
805 add_intermediate_continuation (step_1_continuation, arg1);
806 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
811 /* Continue program at specified address. */
814 jump_command (char *arg, int from_tty)
817 struct symtabs_and_lines sals;
818 struct symtab_and_line sal;
825 /* Find out whether we must run in the background. */
827 async_exec = strip_bg_char (&arg);
829 /* If we must run in the background, but the target can't do it,
831 if (async_exec && !target_can_async_p ())
832 error ("Asynchronous execution not supported on this target.");
834 /* If we are not asked to run in the bg, then prepare to run in the
835 foreground, synchronously. */
836 if (!async_exec && target_can_async_p ())
838 /* Simulate synchronous execution */
839 async_disable_stdin ();
843 error_no_arg ("starting address");
845 sals = decode_line_spec_1 (arg, 1);
848 error ("Unreasonable jump request");
854 if (sal.symtab == 0 && sal.pc == 0)
855 error ("No source file has been specified.");
857 resolve_sal_pc (&sal); /* May error out */
859 /* See if we are trying to jump to another function. */
860 fn = get_frame_function (get_current_frame ());
861 sfn = find_pc_function (sal.pc);
862 if (fn != NULL && sfn != fn)
864 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
865 SYMBOL_PRINT_NAME (fn)))
867 error ("Not confirmed.");
874 fixup_symbol_section (sfn, 0);
875 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
876 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
878 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
880 error ("Not confirmed.");
890 printf_filtered ("Continuing at ");
891 print_address_numeric (addr, 1, gdb_stdout);
892 printf_filtered (".\n");
895 clear_proceed_status ();
896 proceed (addr, TARGET_SIGNAL_0, 0);
900 /* Go to line or address in current procedure */
902 go_command (char *line_no, int from_tty)
904 if (line_no == (char *) NULL || !*line_no)
905 printf_filtered (GO_USAGE);
908 tbreak_command (line_no, from_tty);
909 jump_command (line_no, from_tty);
914 /* Continue program giving it specified signal. */
917 signal_command (char *signum_exp, int from_tty)
919 enum target_signal oursig;
921 dont_repeat (); /* Too dangerous. */
925 error_no_arg ("signal number");
927 /* It would be even slicker to make signal names be valid expressions,
928 (the type could be "enum $signal" or some such), then the user could
929 assign them to convenience variables. */
930 oursig = target_signal_from_name (signum_exp);
932 if (oursig == TARGET_SIGNAL_UNKNOWN)
934 /* No, try numeric. */
935 int num = parse_and_eval_long (signum_exp);
938 oursig = TARGET_SIGNAL_0;
940 oursig = target_signal_from_command (num);
945 if (oursig == TARGET_SIGNAL_0)
946 printf_filtered ("Continuing with no signal.\n");
948 printf_filtered ("Continuing with signal %s.\n",
949 target_signal_to_name (oursig));
952 clear_proceed_status ();
953 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
954 FIXME: Neither should "signal foo" but when I tried passing
955 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
956 tried to track down yet. */
957 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
960 /* Proceed until we reach a different source line with pc greater than
961 our current one or exit the function. We skip calls in both cases.
963 Note that eventually this command should probably be changed so
964 that only source lines are printed out when we hit the breakpoint
965 we set. This may involve changes to wait_for_inferior and the
966 proceed status code. */
969 until_next_command (int from_tty)
971 struct frame_info *frame;
974 struct symtab_and_line sal;
976 clear_proceed_status ();
978 frame = get_current_frame ();
980 /* Step until either exited from this function or greater
981 than the current line (if in symbolic section) or pc (if
985 func = find_pc_function (pc);
989 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
992 error ("Execution is not within a known function.");
994 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
999 sal = find_pc_line (pc, 0);
1001 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1002 step_range_end = sal.end;
1005 step_over_calls = STEP_OVER_ALL;
1006 step_frame_id = get_frame_id (frame);
1008 step_multi = 0; /* Only one call to proceed */
1010 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1014 until_command (char *arg, int from_tty)
1018 if (!target_has_execution)
1019 error ("The program is not running.");
1021 /* Find out whether we must run in the background. */
1023 async_exec = strip_bg_char (&arg);
1025 /* If we must run in the background, but the target can't do it,
1027 if (async_exec && !target_can_async_p ())
1028 error ("Asynchronous execution not supported on this target.");
1030 /* If we are not asked to run in the bg, then prepare to run in the
1031 foreground, synchronously. */
1032 if (!async_exec && target_can_async_p ())
1034 /* Simulate synchronous execution */
1035 async_disable_stdin ();
1039 until_break_command (arg, from_tty, 0);
1041 until_next_command (from_tty);
1045 advance_command (char *arg, int from_tty)
1049 if (!target_has_execution)
1050 error ("The program is not running.");
1053 error_no_arg ("a location");
1055 /* Find out whether we must run in the background. */
1057 async_exec = strip_bg_char (&arg);
1059 /* If we must run in the background, but the target can't do it,
1061 if (async_exec && !target_can_async_p ())
1062 error ("Asynchronous execution not supported on this target.");
1064 /* If we are not asked to run in the bg, then prepare to run in the
1065 foreground, synchronously. */
1066 if (!async_exec && target_can_async_p ())
1068 /* Simulate synchronous execution. */
1069 async_disable_stdin ();
1072 until_break_command (arg, from_tty, 1);
1075 /* Print the result of a function at the end of a 'finish' command. */
1078 print_return_value (int struct_return, struct type *value_type)
1080 struct gdbarch *gdbarch = current_gdbarch;
1081 struct cleanup *old_chain;
1082 struct ui_stream *stb;
1083 struct value *value;
1085 gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
1087 /* FIXME: 2003-09-27: When returning from a nested inferior function
1088 call, it's possible (with no help from the architecture vector)
1089 to locate and return/print a "struct return" value. This is just
1090 a more complicated case of what is already being done in in the
1091 inferior function call code. In fact, when inferior function
1092 calls are made async, this will likely be made the norm. */
1094 switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))
1096 case RETURN_VALUE_REGISTER_CONVENTION:
1097 case RETURN_VALUE_ABI_RETURNS_ADDRESS:
1098 value = allocate_value (value_type);
1099 CHECK_TYPEDEF (value_type);
1100 gdbarch_return_value (current_gdbarch, value_type, stop_registers,
1101 VALUE_CONTENTS_RAW (value), NULL);
1103 case RETURN_VALUE_STRUCT_CONVENTION:
1107 internal_error (__FILE__, __LINE__, "bad switch");
1113 stb = ui_out_stream_new (uiout);
1114 old_chain = make_cleanup_ui_out_stream_delete (stb);
1115 ui_out_text (uiout, "Value returned is ");
1116 ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
1117 record_latest_value (value));
1118 ui_out_text (uiout, " = ");
1119 value_print (value, stb->stream, 0, Val_no_prettyprint);
1120 ui_out_field_stream (uiout, "return-value", stb);
1121 ui_out_text (uiout, "\n");
1122 do_cleanups (old_chain);
1126 ui_out_text (uiout, "Value returned has type: ");
1127 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1128 ui_out_text (uiout, ".");
1129 ui_out_text (uiout, " Cannot determine contents\n");
1133 /* Stuff that needs to be done by the finish command after the target
1134 has stopped. In asynchronous mode, we wait for the target to stop
1135 in the call to poll or select in the event loop, so it is
1136 impossible to do all the stuff as part of the finish_command
1137 function itself. The only chance we have to complete this command
1138 is in fetch_inferior_event, which is called by the event loop as
1139 soon as it detects that the target has stopped. This function is
1140 called via the cmd_continuation pointer. */
1143 finish_command_continuation (struct continuation_arg *arg)
1145 struct symbol *function;
1146 struct breakpoint *breakpoint;
1147 struct cleanup *cleanups;
1149 breakpoint = (struct breakpoint *) arg->data.pointer;
1150 function = (struct symbol *) arg->next->data.pointer;
1151 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1153 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1154 && function != NULL)
1156 struct type *value_type;
1160 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1162 internal_error (__FILE__, __LINE__,
1163 "finish_command: function has no target type");
1165 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1167 do_exec_cleanups (cleanups);
1171 CHECK_TYPEDEF (value_type);
1172 gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
1173 struct_return = using_struct_return (value_type, gcc_compiled);
1175 print_return_value (struct_return, value_type);
1178 do_exec_cleanups (cleanups);
1181 /* "finish": Set a temporary breakpoint at the place the selected
1182 frame will return to, then continue. */
1185 finish_command (char *arg, int from_tty)
1187 struct symtab_and_line sal;
1188 struct frame_info *frame;
1189 struct symbol *function;
1190 struct breakpoint *breakpoint;
1191 struct cleanup *old_chain;
1192 struct continuation_arg *arg1, *arg2, *arg3;
1196 /* Find out whether we must run in the background. */
1198 async_exec = strip_bg_char (&arg);
1200 /* If we must run in the background, but the target can't do it,
1202 if (async_exec && !target_can_async_p ())
1203 error ("Asynchronous execution not supported on this target.");
1205 /* If we are not asked to run in the bg, then prepare to run in the
1206 foreground, synchronously. */
1207 if (!async_exec && target_can_async_p ())
1209 /* Simulate synchronous execution. */
1210 async_disable_stdin ();
1214 error ("The \"finish\" command does not take any arguments.");
1215 if (!target_has_execution)
1216 error ("The program is not running.");
1217 if (deprecated_selected_frame == NULL)
1218 error ("No selected frame.");
1220 frame = get_prev_frame (deprecated_selected_frame);
1222 error ("\"finish\" not meaningful in the outermost frame.");
1224 clear_proceed_status ();
1226 sal = find_pc_line (get_frame_pc (frame), 0);
1227 sal.pc = get_frame_pc (frame);
1229 breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish);
1231 if (!target_can_async_p ())
1232 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1234 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1236 /* Find the function we will return from. */
1238 function = find_pc_function (get_frame_pc (deprecated_selected_frame));
1240 /* Print info on the selected frame, including level number but not
1244 printf_filtered ("Run till exit from ");
1245 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1248 /* If running asynchronously and the target support asynchronous
1249 execution, set things up for the rest of the finish command to be
1250 completed later on, when gdb has detected that the target has
1251 stopped, in fetch_inferior_event. */
1252 if (target_can_async_p ())
1255 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1257 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1259 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1263 arg1->data.pointer = breakpoint;
1264 arg2->data.pointer = function;
1265 arg3->data.pointer = old_chain;
1266 add_continuation (finish_command_continuation, arg1);
1269 proceed_to_finish = 1; /* We want stop_registers, please... */
1270 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1272 /* Do this only if not running asynchronously or if the target
1273 cannot do async execution. Otherwise, complete this command when
1274 the target actually stops, in fetch_inferior_event. */
1275 if (!target_can_async_p ())
1277 /* Did we stop at our breakpoint? */
1278 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1279 && function != NULL)
1281 struct type *value_type;
1285 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1287 internal_error (__FILE__, __LINE__,
1288 "finish_command: function has no target type");
1290 /* FIXME: Shouldn't we do the cleanups before returning? */
1291 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1294 CHECK_TYPEDEF (value_type);
1295 gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
1296 struct_return = using_struct_return (value_type, gcc_compiled);
1298 print_return_value (struct_return, value_type);
1301 do_cleanups (old_chain);
1307 program_info (char *args, int from_tty)
1309 bpstat bs = stop_bpstat;
1310 int num = bpstat_num (&bs);
1312 if (!target_has_execution)
1314 printf_filtered ("The program being debugged is not being run.\n");
1318 target_files_info ();
1319 printf_filtered ("Program stopped at %s.\n",
1320 hex_string ((unsigned long) stop_pc));
1322 printf_filtered ("It stopped after being stepped.\n");
1325 /* There may be several breakpoints in the same place, so this
1326 isn't as strange as it seems. */
1331 printf_filtered ("It stopped at a breakpoint that has ");
1332 printf_filtered ("since been deleted.\n");
1335 printf_filtered ("It stopped at breakpoint %d.\n", num);
1336 num = bpstat_num (&bs);
1339 else if (stop_signal != TARGET_SIGNAL_0)
1341 printf_filtered ("It stopped with signal %s, %s.\n",
1342 target_signal_to_name (stop_signal),
1343 target_signal_to_string (stop_signal));
1348 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1349 printf_filtered ("for more information.\n");
1354 environment_info (char *var, int from_tty)
1358 char *val = get_in_environ (inferior_environ, var);
1361 puts_filtered (var);
1362 puts_filtered (" = ");
1363 puts_filtered (val);
1364 puts_filtered ("\n");
1368 puts_filtered ("Environment variable \"");
1369 puts_filtered (var);
1370 puts_filtered ("\" not defined.\n");
1375 char **vector = environ_vector (inferior_environ);
1378 puts_filtered (*vector++);
1379 puts_filtered ("\n");
1385 set_environment_command (char *arg, int from_tty)
1387 char *p, *val, *var;
1391 error_no_arg ("environment variable and value");
1393 /* Find seperation between variable name and value */
1394 p = (char *) strchr (arg, '=');
1395 val = (char *) strchr (arg, ' ');
1397 if (p != 0 && val != 0)
1399 /* We have both a space and an equals. If the space is before the
1400 equals, walk forward over the spaces til we see a nonspace
1401 (possibly the equals). */
1406 /* Now if the = is after the char following the spaces,
1407 take the char following the spaces. */
1411 else if (val != 0 && p == 0)
1415 error_no_arg ("environment variable to set");
1417 if (p == 0 || p[1] == 0)
1421 p = arg + strlen (arg); /* So that savestring below will work */
1425 /* Not setting variable value to null */
1427 while (*val == ' ' || *val == '\t')
1431 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1434 var = savestring (arg, p - arg);
1437 printf_filtered ("Setting environment variable ");
1438 printf_filtered ("\"%s\" to null value.\n", var);
1439 set_in_environ (inferior_environ, var, "");
1442 set_in_environ (inferior_environ, var, val);
1447 unset_environment_command (char *var, int from_tty)
1451 /* If there is no argument, delete all environment variables.
1452 Ask for confirmation if reading from the terminal. */
1453 if (!from_tty || query ("Delete all environment variables? "))
1455 free_environ (inferior_environ);
1456 inferior_environ = make_environ ();
1460 unset_in_environ (inferior_environ, var);
1463 /* Handle the execution path (PATH variable) */
1465 static const char path_var_name[] = "PATH";
1468 path_info (char *args, int from_tty)
1470 puts_filtered ("Executable and object file path: ");
1471 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1472 puts_filtered ("\n");
1475 /* Add zero or more directories to the front of the execution path. */
1478 path_command (char *dirname, int from_tty)
1483 env = get_in_environ (inferior_environ, path_var_name);
1484 /* Can be null if path is not set */
1487 exec_path = xstrdup (env);
1488 mod_path (dirname, &exec_path);
1489 set_in_environ (inferior_environ, path_var_name, exec_path);
1492 path_info ((char *) NULL, from_tty);
1496 /* Print out the machine register regnum. If regnum is -1, print all
1497 registers (print_all == 1) or all non-float and non-vector
1498 registers (print_all == 0).
1500 For most machines, having all_registers_info() print the
1501 register(s) one per line is good enough. If a different format is
1502 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1503 regs), or there is an existing convention for showing all the
1504 registers, define the architecture method PRINT_REGISTERS_INFO to
1505 provide that format. */
1508 default_print_registers_info (struct gdbarch *gdbarch,
1509 struct ui_file *file,
1510 struct frame_info *frame,
1511 int regnum, int print_all)
1514 const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
1515 char buffer[MAX_REGISTER_SIZE];
1517 for (i = 0; i < numregs; i++)
1519 /* Decide between printing all regs, non-float / vector regs, or
1525 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1530 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1540 /* If the register name is empty, it is undefined for this
1541 processor, so don't display anything. */
1542 if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1545 fputs_filtered (REGISTER_NAME (i), file);
1546 print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
1548 /* Get the data in raw format. */
1549 if (! frame_register_read (frame, i, buffer))
1551 fprintf_filtered (file, "*value not available*\n");
1555 /* If virtual format is floating, print it that way, and in raw
1557 if (TYPE_CODE (register_type (current_gdbarch, i)) == TYPE_CODE_FLT)
1561 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1562 file, 0, 1, 0, Val_pretty_default);
1564 fprintf_filtered (file, "\t(raw 0x");
1565 for (j = 0; j < register_size (current_gdbarch, i); j++)
1568 if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
1571 idx = register_size (current_gdbarch, i) - 1 - j;
1572 fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
1574 fprintf_filtered (file, ")");
1578 /* Print the register in hex. */
1579 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1580 file, 'x', 1, 0, Val_pretty_default);
1581 /* If not a vector register, print it also according to its
1583 if (TYPE_VECTOR (register_type (current_gdbarch, i)) == 0)
1585 fprintf_filtered (file, "\t");
1586 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1587 file, 0, 1, 0, Val_pretty_default);
1591 fprintf_filtered (file, "\n");
1596 registers_info (char *addr_exp, int fpregs)
1598 int regnum, numregs;
1601 if (!target_has_registers)
1602 error ("The program has no registers now.");
1603 if (deprecated_selected_frame == NULL)
1604 error ("No selected frame.");
1608 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1609 deprecated_selected_frame, -1, fpregs);
1613 while (*addr_exp != '\0')
1618 /* Keep skipping leading white space. */
1619 if (isspace ((*addr_exp)))
1625 /* Discard any leading ``$''. Check that there is something
1626 resembling a register following it. */
1627 if (addr_exp[0] == '$')
1629 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1630 error ("Missing register name");
1632 /* Find the start/end of this register name/num/group. */
1634 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1638 /* Figure out what we've found and display it. */
1640 /* A register name? */
1642 int regnum = frame_map_name_to_regnum (deprecated_selected_frame,
1643 start, end - start);
1646 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1647 deprecated_selected_frame, regnum, fpregs);
1652 /* A register number? (how portable is this one?). */
1655 int regnum = strtol (start, &endptr, 0);
1658 && regnum < NUM_REGS + NUM_PSEUDO_REGS)
1660 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1661 deprecated_selected_frame, regnum, fpregs);
1666 /* A register group? */
1668 struct reggroup *group;
1669 for (group = reggroup_next (current_gdbarch, NULL);
1671 group = reggroup_next (current_gdbarch, group))
1673 /* Don't bother with a length check. Should the user
1674 enter a short register group name, go with the first
1675 group that matches. */
1676 if (strncmp (start, reggroup_name (group), end - start) == 0)
1682 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1684 if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
1686 gdbarch_print_registers_info (current_gdbarch,
1687 gdb_stdout, deprecated_selected_frame,
1694 /* Nothing matched. */
1695 error ("Invalid register `%.*s'", (int) (end - start), start);
1700 all_registers_info (char *addr_exp, int from_tty)
1702 registers_info (addr_exp, 1);
1706 nofp_registers_info (char *addr_exp, int from_tty)
1708 registers_info (addr_exp, 0);
1712 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
1713 struct frame_info *frame, const char *args)
1715 if (!target_has_registers)
1716 error ("The program has no registers now.");
1717 if (deprecated_selected_frame == NULL)
1718 error ("No selected frame.");
1720 if (gdbarch_print_vector_info_p (gdbarch))
1721 gdbarch_print_vector_info (gdbarch, file, frame, args);
1725 int printed_something = 0;
1727 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1729 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
1731 printed_something = 1;
1732 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1735 if (!printed_something)
1736 fprintf_filtered (file, "No vector information\n");
1741 vector_info (char *args, int from_tty)
1743 print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
1749 * Should save/restore the tty state since it might be that the
1750 * program to be debugged was started on this tty and it wants
1751 * the tty in some state other than what we want. If it's running
1752 * on another terminal or without a terminal, then saving and
1753 * restoring the tty state is a harmless no-op.
1754 * This only needs to be done if we are attaching to a process.
1759 takes a program started up outside of gdb and ``attaches'' to it.
1760 This stops it cold in its tracks and allows us to start debugging it.
1761 and wait for the trace-trap that results from attaching. */
1764 attach_command (char *args, int from_tty)
1767 char *full_exec_path = NULL;
1769 dont_repeat (); /* Not for the faint of heart */
1771 if (target_has_execution)
1773 if (query ("A program is being debugged already. Kill it? "))
1776 error ("Not killed.");
1779 /* Clear out solib state. Otherwise the solib state of the previous
1780 inferior might have survived and is entirely wrong for the new
1781 target. This has been observed on Linux using glibc 2.3. How to
1793 Cannot access memory at address 0xdeadbeef
1799 target_attach (args, from_tty);
1801 /* Set up the "saved terminal modes" of the inferior
1802 based on what modes we are starting it with. */
1803 target_terminal_init ();
1805 /* Set up execution context to know that we should return from
1806 wait_for_inferior as soon as the target reports a stop. */
1807 init_wait_for_inferior ();
1808 clear_proceed_status ();
1810 /* No traps are generated when attaching to inferior under Mach 3
1812 #ifndef ATTACH_NO_WAIT
1813 /* Careful here. See comments in inferior.h. Basically some OSes
1814 don't ignore SIGSTOPs on continue requests anymore. We need a
1815 way for handle_inferior_event to reset the stop_signal variable
1816 after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */
1817 stop_soon = STOP_QUIETLY_NO_SIGSTOP;
1818 wait_for_inferior ();
1819 stop_soon = NO_STOP_QUIETLY;
1823 * If no exec file is yet known, try to determine it from the
1826 exec_file = (char *) get_exec_file (0);
1829 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
1832 /* It's possible we don't have a full path, but rather just a
1833 filename. Some targets, such as HP-UX, don't provide the
1836 Attempt to qualify the filename against the source path.
1837 (If that fails, we'll just fall back on the original
1838 filename. Not much more we can do...)
1840 if (!source_full_path_of (exec_file, &full_exec_path))
1841 full_exec_path = savestring (exec_file, strlen (exec_file));
1843 exec_file_attach (full_exec_path, from_tty);
1844 symbol_file_add_main (full_exec_path, from_tty);
1849 reopen_exec_file ();
1854 /* Add shared library symbols from the newly attached process, if any. */
1855 SOLIB_ADD ((char *) 0, from_tty, ¤t_target, auto_solib_add);
1856 re_enable_breakpoints_in_shlibs ();
1859 /* Take any necessary post-attaching actions for this platform.
1861 target_post_attach (PIDGET (inferior_ptid));
1863 /* Install inferior's terminal modes. */
1864 target_terminal_inferior ();
1868 if (deprecated_attach_hook)
1869 deprecated_attach_hook ();
1874 * takes a program previously attached to and detaches it.
1875 * The program resumes execution and will no longer stop
1876 * on signals, etc. We better not have left any breakpoints
1877 * in the program or it'll die when it hits one. For this
1878 * to work, it may be necessary for the process to have been
1879 * previously attached. It *might* work if the program was
1880 * started via the normal ptrace (PTRACE_TRACEME).
1884 detach_command (char *args, int from_tty)
1886 dont_repeat (); /* Not for the faint of heart. */
1887 target_detach (args, from_tty);
1888 #if defined(SOLIB_RESTART)
1891 if (deprecated_detach_hook)
1892 deprecated_detach_hook ();
1895 /* Disconnect from the current target without resuming it (leaving it
1896 waiting for a debugger).
1898 We'd better not have left any breakpoints in the program or the
1899 next debugger will get confused. Currently only supported for some
1900 remote targets, since the normal attach mechanisms don't work on
1901 stopped processes on some native platforms (e.g. GNU/Linux). */
1904 disconnect_command (char *args, int from_tty)
1906 dont_repeat (); /* Not for the faint of heart */
1907 target_disconnect (args, from_tty);
1908 #if defined(SOLIB_RESTART)
1911 if (deprecated_detach_hook)
1912 deprecated_detach_hook ();
1915 /* Stop the execution of the target while running in async mode, in
1918 interrupt_target_command (char *args, int from_tty)
1920 if (target_can_async_p ())
1922 dont_repeat (); /* Not for the faint of heart */
1928 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
1929 struct frame_info *frame, const char *args)
1931 if (!target_has_registers)
1932 error ("The program has no registers now.");
1933 if (deprecated_selected_frame == NULL)
1934 error ("No selected frame.");
1936 if (gdbarch_print_float_info_p (gdbarch))
1937 gdbarch_print_float_info (gdbarch, file, frame, args);
1941 int printed_something = 0;
1943 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1945 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
1947 printed_something = 1;
1948 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1951 if (!printed_something)
1952 fprintf_filtered (file, "\
1953 No floating-point info available for this processor.\n");
1958 float_info (char *args, int from_tty)
1960 print_float_info (current_gdbarch, gdb_stdout,
1961 deprecated_selected_frame, args);
1965 unset_command (char *args, int from_tty)
1967 printf_filtered ("\"unset\" must be followed by the name of ");
1968 printf_filtered ("an unset subcommand.\n");
1969 help_list (unsetlist, "unset ", -1, gdb_stdout);
1973 _initialize_infcmd (void)
1975 struct cmd_list_element *c;
1977 c = add_com ("tty", class_run, tty_command,
1978 "Set terminal for future runs of program being debugged.");
1979 set_cmd_completer (c, filename_completer);
1981 c = add_set_cmd ("args", class_run, var_string_noescape,
1982 (char *) &inferior_args,
1983 "Set argument list to give program being debugged when it is started.\n\
1984 Follow this command with any number of args, to be passed to the program.",
1986 set_cmd_completer (c, filename_completer);
1987 set_cmd_sfunc (c, notice_args_set);
1988 c = deprecated_add_show_from_set (c, &showlist);
1989 set_cmd_sfunc (c, notice_args_read);
1992 ("environment", no_class, environment_info,
1993 "The environment to give the program, or one variable's value.\n\
1994 With an argument VAR, prints the value of environment variable VAR to\n\
1995 give the program being debugged. With no arguments, prints the entire\n\
1996 environment to be given to the program.", &showlist);
1997 set_cmd_completer (c, noop_completer);
1999 add_prefix_cmd ("unset", no_class, unset_command,
2000 "Complement to certain \"set\" commands.",
2001 &unsetlist, "unset ", 0, &cmdlist);
2003 c = add_cmd ("environment", class_run, unset_environment_command,
2004 "Cancel environment variable VAR for the program.\n\
2005 This does not affect the program until the next \"run\" command.",
2007 set_cmd_completer (c, noop_completer);
2009 c = add_cmd ("environment", class_run, set_environment_command,
2010 "Set environment variable value to give the program.\n\
2011 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2012 VALUES of environment variables are uninterpreted strings.\n\
2013 This does not affect the program until the next \"run\" command.",
2015 set_cmd_completer (c, noop_completer);
2017 c = add_com ("path", class_files, path_command,
2018 "Add directory DIR(s) to beginning of search path for object files.\n\
2019 $cwd in the path means the current working directory.\n\
2020 This path is equivalent to the $PATH shell variable. It is a list of\n\
2021 directories, separated by colons. These directories are searched to find\n\
2022 fully linked executable files and separately compiled object files as needed.");
2023 set_cmd_completer (c, filename_completer);
2025 c = add_cmd ("paths", no_class, path_info,
2026 "Current search path for finding object files.\n\
2027 $cwd in the path means the current working directory.\n\
2028 This path is equivalent to the $PATH shell variable. It is a list of\n\
2029 directories, separated by colons. These directories are searched to find\n\
2030 fully linked executable files and separately compiled object files as needed.",
2032 set_cmd_completer (c, noop_completer);
2034 add_com ("attach", class_run, attach_command,
2035 "Attach to a process or file outside of GDB.\n\
2036 This command attaches to another target, of the same type as your last\n\
2037 \"target\" command (\"info files\" will show your target stack).\n\
2038 The command may take as argument a process id or a device file.\n\
2039 For a process id, you must have permission to send the process a signal,\n\
2040 and it must have the same effective uid as the debugger.\n\
2041 When using \"attach\" with a process id, the debugger finds the\n\
2042 program running in the process, looking first in the current working\n\
2043 directory, or (if not found there) using the source file search path\n\
2044 (see the \"directory\" command). You can also use the \"file\" command\n\
2045 to specify the program, and to load its symbol table.");
2047 add_com ("detach", class_run, detach_command,
2048 "Detach a process or file previously attached.\n\
2049 If a process, it is no longer traced, and it continues its execution. If\n\
2050 you were debugging a file, the file is closed and gdb no longer accesses it.");
2052 add_com ("disconnect", class_run, disconnect_command,
2053 "Disconnect from a target.\n\
2054 The target will wait for another debugger to connect. Not available for\n\
2057 add_com ("signal", class_run, signal_command,
2058 "Continue program giving it signal specified by the argument.\n\
2059 An argument of \"0\" means continue program without giving it a signal.");
2061 add_com ("stepi", class_run, stepi_command,
2062 "Step one instruction exactly.\n\
2063 Argument N means do this N times (or till program stops for another reason).");
2064 add_com_alias ("si", "stepi", class_alias, 0);
2066 add_com ("nexti", class_run, nexti_command,
2067 "Step one instruction, but proceed through subroutine calls.\n\
2068 Argument N means do this N times (or till program stops for another reason).");
2069 add_com_alias ("ni", "nexti", class_alias, 0);
2071 add_com ("finish", class_run, finish_command,
2072 "Execute until selected stack frame returns.\n\
2073 Upon return, the value returned is printed and put in the value history.");
2075 add_com ("next", class_run, next_command,
2076 "Step program, proceeding through subroutine calls.\n\
2077 Like the \"step\" command as long as subroutine calls do not happen;\n\
2078 when they do, the call is treated as one instruction.\n\
2079 Argument N means do this N times (or till program stops for another reason).");
2080 add_com_alias ("n", "next", class_run, 1);
2082 add_com_alias ("S", "next", class_run, 1);
2084 add_com ("step", class_run, step_command,
2085 "Step program until it reaches a different source line.\n\
2086 Argument N means do this N times (or till program stops for another reason).");
2087 add_com_alias ("s", "step", class_run, 1);
2089 c = add_com ("until", class_run, until_command,
2090 "Execute until the program reaches a source line greater than the current\n\
2091 or a specified location (same args as break command) within the current frame.");
2092 set_cmd_completer (c, location_completer);
2093 add_com_alias ("u", "until", class_run, 1);
2095 c = add_com ("advance", class_run, advance_command,
2096 "Continue the program up to the given location (same form as args for break command).\n\
2097 Execution will also stop upon exit from the current stack frame.");
2098 set_cmd_completer (c, location_completer);
2100 c = add_com ("jump", class_run, jump_command,
2101 "Continue program being debugged at specified line or address.\n\
2102 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2103 for an address to start at.");
2104 set_cmd_completer (c, location_completer);
2108 c = add_com ("go", class_run, go_command,
2109 "Usage: go <location>\n\
2110 Continue program being debugged, stopping at specified line or \n\
2112 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2113 expression for an address to start at.\n\
2114 This command is a combination of tbreak and jump.");
2115 set_cmd_completer (c, location_completer);
2119 add_com_alias ("g", "go", class_run, 1);
2121 add_com ("continue", class_run, continue_command,
2122 "Continue program being debugged, after signal or breakpoint.\n\
2123 If proceeding from breakpoint, a number N may be used as an argument,\n\
2124 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2125 the breakpoint won't break until the Nth time it is reached).");
2126 add_com_alias ("c", "cont", class_run, 1);
2127 add_com_alias ("fg", "cont", class_run, 1);
2129 c = add_com ("run", class_run, run_command,
2130 "Start debugged program. You may specify arguments to give it.\n\
2131 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2132 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2133 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2134 To cancel previous arguments and run with no arguments,\n\
2135 use \"set args\" without arguments.");
2136 set_cmd_completer (c, filename_completer);
2137 add_com_alias ("r", "run", class_run, 1);
2139 add_com ("R", class_run, run_no_args_command,
2140 "Start debugged program with no arguments.");
2142 c = add_com ("start", class_run, start_command,
2144 Run the debugged program until the beginning of the main procedure.\n\
2145 You may specify arguments to give to your program, just as with the\n\
2147 set_cmd_completer (c, filename_completer);
2149 add_com ("interrupt", class_run, interrupt_target_command,
2150 "Interrupt the execution of the debugged program.");
2152 add_info ("registers", nofp_registers_info,
2153 "List of integer registers and their contents, for selected stack frame.\n\
2154 Register name as argument means describe only that register.");
2155 add_info_alias ("r", "registers", 1);
2158 add_com ("lr", class_info, nofp_registers_info,
2159 "List of integer registers and their contents, for selected stack frame.\n\
2160 Register name as argument means describe only that register.");
2161 add_info ("all-registers", all_registers_info,
2162 "List of all registers and their contents, for selected stack frame.\n\
2163 Register name as argument means describe only that register.");
2165 add_info ("program", program_info,
2166 "Execution status of the program.");
2168 add_info ("float", float_info,
2169 "Print the status of the floating point unit\n");
2171 add_info ("vector", vector_info,
2172 "Print the status of the vector unit\n");
2174 inferior_environ = make_environ ();
2175 init_environ (inferior_environ);