1 /* Memory-access and commands for "inferior" process, for GDB.
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
5 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
26 #include "gdb_string.h"
40 #include "completer.h"
42 #include "event-top.h"
43 #include "parser-defs.h"
45 #include "reggroups.h"
49 #include "gdb_assert.h"
51 #include "target-descriptions.h"
53 /* Functions exported for general use, in inferior.h: */
55 void all_registers_info (char *, int);
57 void registers_info (char *, int);
59 void nexti_command (char *, int);
61 void stepi_command (char *, int);
63 void continue_command (char *, int);
65 void interrupt_target_command (char *args, int from_tty);
67 /* Local functions: */
69 static void nofp_registers_info (char *, int);
71 static void print_return_value (int struct_return, struct type *value_type);
73 static void finish_command_continuation (struct continuation_arg *);
75 static void until_next_command (int);
77 static void until_command (char *, int);
79 static void path_info (char *, int);
81 static void path_command (char *, int);
83 static void unset_command (char *, int);
85 static void float_info (char *, int);
87 static void detach_command (char *, int);
89 static void disconnect_command (char *, int);
91 static void unset_environment_command (char *, int);
93 static void set_environment_command (char *, int);
95 static void environment_info (char *, int);
97 static void program_info (char *, int);
99 static void finish_command (char *, int);
101 static void signal_command (char *, int);
103 static void jump_command (char *, int);
105 static void step_1 (int, int, char *);
106 static void step_once (int skip_subroutines, int single_inst, int count);
107 static void step_1_continuation (struct continuation_arg *arg);
109 static void next_command (char *, int);
111 static void step_command (char *, int);
113 static void run_command (char *, int);
115 static void run_no_args_command (char *args, int from_tty);
117 static void go_command (char *line_no, int from_tty);
119 static int strip_bg_char (char **);
121 void _initialize_infcmd (void);
123 #define GO_USAGE "Usage: go <location>\n"
125 #define ERROR_NO_INFERIOR \
126 if (!target_has_execution) error (_("The program is not being run."));
128 /* String containing arguments to give to the program, separated by spaces.
129 Empty string (pointer to '\0') means no args. */
131 static char *inferior_args;
133 /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
134 then we must compute INFERIOR_ARGS from this (via the target). */
136 static int inferior_argc;
137 static char **inferior_argv;
139 /* File name for default use for standard in/out in the inferior. */
141 static char *inferior_io_terminal;
143 /* Pid of our debugged inferior, or 0 if no inferior now.
144 Since various parts of infrun.c test this to see whether there is a program
145 being debugged it should be nonzero (currently 3 is used) for remote
148 ptid_t inferior_ptid;
150 /* Last signal that the inferior received (why it stopped). */
152 enum target_signal stop_signal;
154 /* Address at which inferior stopped. */
158 /* Chain containing status of breakpoint(s) that we have stopped at. */
162 /* Flag indicating that a command has proceeded the inferior past the
163 current breakpoint. */
165 int breakpoint_proceeded;
167 /* Nonzero if stopped due to a step command. */
171 /* Nonzero if stopped due to completion of a stack dummy routine. */
173 int stop_stack_dummy;
175 /* Nonzero if stopped due to a random (unexpected) signal in inferior
178 int stopped_by_random_signal;
180 /* Range to single step within.
181 If this is nonzero, respond to a single-step signal
182 by continuing to step if the pc is in this range. */
184 CORE_ADDR step_range_start; /* Inclusive */
185 CORE_ADDR step_range_end; /* Exclusive */
187 /* Stack frame address as of when stepping command was issued.
188 This is how we know when we step into a subroutine call,
189 and how to set the frame for the breakpoint used to step out. */
191 struct frame_id step_frame_id;
193 enum step_over_calls_kind step_over_calls;
195 /* If stepping, nonzero means step count is > 1
196 so don't print frame next time inferior stops
197 if it stops due to stepping. */
201 /* Environment to use for running inferior,
202 in format described in environ.h. */
204 struct gdb_environ *inferior_environ;
206 /* Accessor routines. */
209 set_inferior_io_terminal (const char *terminal_name)
211 if (inferior_io_terminal)
212 xfree (inferior_io_terminal);
215 inferior_io_terminal = NULL;
217 inferior_io_terminal = savestring (terminal_name, strlen (terminal_name));
221 get_inferior_io_terminal (void)
223 return inferior_io_terminal;
227 get_inferior_args (void)
229 if (inferior_argc != 0)
233 n = gdbarch_construct_inferior_arguments (current_gdbarch,
234 inferior_argc, inferior_argv);
235 old = set_inferior_args (n);
239 if (inferior_args == NULL)
240 inferior_args = xstrdup ("");
242 return inferior_args;
246 set_inferior_args (char *newargs)
248 char *saved_args = inferior_args;
250 inferior_args = newargs;
258 set_inferior_args_vector (int argc, char **argv)
260 inferior_argc = argc;
261 inferior_argv = argv;
264 /* Notice when `set args' is run. */
266 notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
272 /* Notice when `show args' is run. */
274 notice_args_read (struct ui_file *file, int from_tty,
275 struct cmd_list_element *c, const char *value)
277 deprecated_show_value_hack (file, from_tty, c, value);
278 /* Might compute the value. */
279 get_inferior_args ();
283 /* Compute command-line string given argument vector. This does the
284 same shell processing as fork_inferior. */
286 construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
290 if (STARTUP_WITH_SHELL)
292 /* This holds all the characters considered special to the
293 typical Unix shells. We include `^' because the SunOS
294 /bin/sh treats it as a synonym for `|'. */
295 char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
300 /* We over-compute the size. It shouldn't matter. */
301 for (i = 0; i < argc; ++i)
302 length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
304 result = (char *) xmalloc (length);
307 for (i = 0; i < argc; ++i)
312 /* Need to handle empty arguments specially. */
313 if (argv[i][0] == '\0')
320 for (cp = argv[i]; *cp; ++cp)
322 if (strchr (special, *cp) != NULL)
332 /* In this case we can't handle arguments that contain spaces,
333 tabs, or newlines -- see breakup_args(). */
337 for (i = 0; i < argc; ++i)
339 char *cp = strchr (argv[i], ' ');
341 cp = strchr (argv[i], '\t');
343 cp = strchr (argv[i], '\n');
345 error (_("can't handle command-line argument containing whitespace"));
346 length += strlen (argv[i]) + 1;
349 result = (char *) xmalloc (length);
351 for (i = 0; i < argc; ++i)
354 strcat (result, " ");
355 strcat (result, argv[i]);
363 /* This function detects whether or not a '&' character (indicating
364 background execution) has been added as *the last* of the arguments ARGS
365 of a command. If it has, it removes it and returns 1. Otherwise it
366 does nothing and returns 0. */
368 strip_bg_char (char **args)
372 p = strchr (*args, '&');
376 if (p == (*args + strlen (*args) - 1))
378 if (strlen (*args) > 1)
382 while (*p == ' ' || *p == '\t');
394 tty_command (char *file, int from_tty)
397 error_no_arg (_("terminal name for running target process"));
399 set_inferior_io_terminal (file);
402 /* Common actions to take after creating any sort of inferior, by any
403 means (running, attaching, connecting, et cetera). The target
404 should be stopped. */
407 post_create_inferior (struct target_ops *target, int from_tty)
409 /* If the target hasn't taken care of this already, do it now.
410 Targets which need to access registers during to_open,
411 to_create_inferior, or to_attach should do it earlier; but many
413 target_find_description ();
417 /* Sometimes the platform-specific hook loads initial shared
418 libraries, and sometimes it doesn't. Try to do so first, so
419 that we can add them with the correct value for FROM_TTY. */
421 SOLIB_ADD (NULL, from_tty, target, auto_solib_add);
423 solib_add (NULL, from_tty, target, auto_solib_add);
426 /* Create the hooks to handle shared library load and unload
428 #ifdef SOLIB_CREATE_INFERIOR_HOOK
429 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
431 solib_create_inferior_hook ();
434 /* Enable any breakpoints which were disabled when the
435 underlying shared library was deleted. */
436 re_enable_breakpoints_in_shlibs ();
439 observer_notify_inferior_created (target, from_tty);
442 /* Kill the inferior if already running. This function is designed
443 to be called when we are about to start the execution of the program
444 from the beginning. Ask the user to confirm that he wants to restart
445 the program being debugged when FROM_TTY is non-null. */
448 kill_if_already_running (int from_tty)
450 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
453 && !query ("The program being debugged has been started already.\n\
454 Start it from the beginning? "))
455 error (_("Program not restarted."));
457 #if defined(SOLIB_RESTART)
460 init_wait_for_inferior ();
464 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
465 a temporary breakpoint at the begining of the main program before
466 running the program. */
469 run_command_1 (char *args, int from_tty, int tbreak_at_main)
475 kill_if_already_running (from_tty);
476 clear_breakpoint_hit_counts ();
478 /* Clean up any leftovers from other runs. Some other things from
479 this function should probably be moved into target_pre_inferior. */
480 target_pre_inferior (from_tty);
482 /* Purge old solib objfiles. */
483 objfile_purge_solibs ();
485 do_run_cleanups (NULL);
487 /* The comment here used to read, "The exec file is re-read every
488 time we do a generic_mourn_inferior, so we just have to worry
489 about the symbol file." The `generic_mourn_inferior' function
490 gets called whenever the program exits. However, suppose the
491 program exits, and *then* the executable file changes? We need
492 to check again here. Since reopen_exec_file doesn't do anything
493 if the timestamp hasn't changed, I don't see the harm. */
497 /* Insert the temporary breakpoint if a location was specified. */
499 tbreak_command (main_name (), 0);
501 exec_file = (char *) get_exec_file (0);
503 /* We keep symbols from add-symbol-file, on the grounds that the
504 user might want to add some symbols before running the program
505 (right?). But sometimes (dynamic loading where the user manually
506 introduces the new symbols with add-symbol-file), the code which
507 the symbols describe does not persist between runs. Currently
508 the user has to manually nuke all symbols between runs if they
509 want them to go away (PR 2207). This is probably reasonable. */
513 if (target_can_async_p ())
514 async_disable_stdin ();
518 int async_exec = strip_bg_char (&args);
520 /* If we get a request for running in the bg but the target
521 doesn't support it, error out. */
522 if (async_exec && !target_can_async_p ())
523 error (_("Asynchronous execution not supported on this target."));
525 /* If we don't get a request of running in the bg, then we need
526 to simulate synchronous (fg) execution. */
527 if (!async_exec && target_can_async_p ())
529 /* Simulate synchronous execution */
530 async_disable_stdin ();
533 /* If there were other args, beside '&', process them. */
536 char *old_args = set_inferior_args (xstrdup (args));
543 ui_out_field_string (uiout, NULL, "Starting program");
544 ui_out_text (uiout, ": ");
546 ui_out_field_string (uiout, "execfile", exec_file);
547 ui_out_spaces (uiout, 1);
548 /* We call get_inferior_args() because we might need to compute
550 ui_out_field_string (uiout, "infargs", get_inferior_args ());
551 ui_out_text (uiout, "\n");
552 ui_out_flush (uiout);
555 /* We call get_inferior_args() because we might need to compute
557 target_create_inferior (exec_file, get_inferior_args (),
558 environ_vector (inferior_environ), from_tty);
560 post_create_inferior (¤t_target, from_tty);
562 /* Start the target running. */
563 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
568 run_command (char *args, int from_tty)
570 run_command_1 (args, from_tty, 0);
574 run_no_args_command (char *args, int from_tty)
576 char *old_args = set_inferior_args (xstrdup (""));
581 /* Start the execution of the program up until the beginning of the main
585 start_command (char *args, int from_tty)
587 /* Some languages such as Ada need to search inside the program
588 minimal symbols for the location where to put the temporary
589 breakpoint before starting. */
590 if (!have_minimal_symbols ())
591 error (_("No symbol table loaded. Use the \"file\" command."));
593 /* Run the program until reaching the main procedure... */
594 run_command_1 (args, from_tty, 1);
598 continue_command (char *proc_count_exp, int from_tty)
603 /* Find out whether we must run in the background. */
604 if (proc_count_exp != NULL)
605 async_exec = strip_bg_char (&proc_count_exp);
607 /* If we must run in the background, but the target can't do it,
609 if (async_exec && !target_can_async_p ())
610 error (_("Asynchronous execution not supported on this target."));
612 /* If we are not asked to run in the bg, then prepare to run in the
613 foreground, synchronously. */
614 if (!async_exec && target_can_async_p ())
616 /* Simulate synchronous execution */
617 async_disable_stdin ();
620 /* If have argument (besides '&'), set proceed count of breakpoint
622 if (proc_count_exp != NULL)
624 bpstat bs = stop_bpstat;
625 int num = bpstat_num (&bs);
626 if (num == 0 && from_tty)
629 ("Not stopped at any breakpoint; argument ignored.\n");
633 set_ignore_count (num,
634 parse_and_eval_long (proc_count_exp) - 1,
636 /* set_ignore_count prints a message ending with a period.
637 So print two spaces before "Continuing.". */
639 printf_filtered (" ");
640 num = bpstat_num (&bs);
645 printf_filtered (_("Continuing.\n"));
647 clear_proceed_status ();
649 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
652 /* Step until outside of current statement. */
655 step_command (char *count_string, int from_tty)
657 step_1 (0, 0, count_string);
660 /* Likewise, but skip over subroutine calls as if single instructions. */
663 next_command (char *count_string, int from_tty)
665 step_1 (1, 0, count_string);
668 /* Likewise, but step only one instruction. */
671 stepi_command (char *count_string, int from_tty)
673 step_1 (0, 1, count_string);
677 nexti_command (char *count_string, int from_tty)
679 step_1 (1, 1, count_string);
683 disable_longjmp_breakpoint_cleanup (void *ignore)
685 disable_longjmp_breakpoint ();
689 step_1 (int skip_subroutines, int single_inst, char *count_string)
692 struct frame_info *frame;
693 struct cleanup *cleanups = 0;
699 async_exec = strip_bg_char (&count_string);
701 /* If we get a request for running in the bg but the target
702 doesn't support it, error out. */
703 if (async_exec && !target_can_async_p ())
704 error (_("Asynchronous execution not supported on this target."));
706 /* If we don't get a request of running in the bg, then we need
707 to simulate synchronous (fg) execution. */
708 if (!async_exec && target_can_async_p ())
710 /* Simulate synchronous execution */
711 async_disable_stdin ();
714 count = count_string ? parse_and_eval_long (count_string) : 1;
716 if (!single_inst || skip_subroutines) /* leave si command alone */
718 enable_longjmp_breakpoint ();
719 if (!target_can_async_p ())
720 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
722 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
725 /* In synchronous case, all is well, just use the regular for loop. */
726 if (!target_can_async_p ())
728 for (; count > 0; count--)
730 clear_proceed_status ();
732 frame = get_current_frame ();
733 if (!frame) /* Avoid coredump here. Why tho? */
734 error (_("No current frame"));
735 step_frame_id = get_frame_id (frame);
739 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
740 if (step_range_end == 0)
743 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
744 &step_range_end) == 0)
745 error (_("Cannot find bounds of current function"));
747 target_terminal_ours ();
748 printf_filtered (_("\
749 Single stepping until exit from function %s, \n\
750 which has no line number information.\n"), name);
755 /* Say we are stepping, but stop after one insn whatever it does. */
756 step_range_start = step_range_end = 1;
757 if (!skip_subroutines)
759 Don't step over function calls, not even to functions lacking
761 step_over_calls = STEP_OVER_NONE;
764 if (skip_subroutines)
765 step_over_calls = STEP_OVER_ALL;
767 step_multi = (count > 1);
768 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
774 if (!single_inst || skip_subroutines)
775 do_cleanups (cleanups);
778 /* In case of asynchronous target things get complicated, do only
779 one step for now, before returning control to the event loop. Let
780 the continuation figure out how many other steps we need to do,
781 and handle them one at the time, through step_once(). */
784 if (target_can_async_p ())
785 step_once (skip_subroutines, single_inst, count);
789 /* Called after we are done with one step operation, to check whether
790 we need to step again, before we print the prompt and return control
791 to the user. If count is > 1, we will need to do one more call to
792 proceed(), via step_once(). Basically it is like step_once and
793 step_1_continuation are co-recursive. */
795 step_1_continuation (struct continuation_arg *arg)
798 int skip_subroutines;
801 skip_subroutines = arg->data.integer;
802 single_inst = arg->next->data.integer;
803 count = arg->next->next->data.integer;
806 step_once (skip_subroutines, single_inst, count - 1);
808 if (!single_inst || skip_subroutines)
809 do_exec_cleanups (ALL_CLEANUPS);
812 /* Do just one step operation. If count >1 we will have to set up a
813 continuation to be done after the target stops (after this one
814 step). This is useful to implement the 'step n' kind of commands, in
815 case of asynchronous targets. We had to split step_1 into two parts,
816 one to be done before proceed() and one afterwards. This function is
817 called in case of step n with n>1, after the first step operation has
820 step_once (int skip_subroutines, int single_inst, int count)
822 struct continuation_arg *arg1;
823 struct continuation_arg *arg2;
824 struct continuation_arg *arg3;
825 struct frame_info *frame;
829 clear_proceed_status ();
831 frame = get_current_frame ();
832 if (!frame) /* Avoid coredump here. Why tho? */
833 error (_("No current frame"));
834 step_frame_id = get_frame_id (frame);
838 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
840 /* If we have no line info, switch to stepi mode. */
841 if (step_range_end == 0 && step_stop_if_no_debug)
843 step_range_start = step_range_end = 1;
845 else if (step_range_end == 0)
848 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
849 &step_range_end) == 0)
850 error (_("Cannot find bounds of current function"));
852 target_terminal_ours ();
853 printf_filtered (_("\
854 Single stepping until exit from function %s, \n\
855 which has no line number information.\n"), name);
860 /* Say we are stepping, but stop after one insn whatever it does. */
861 step_range_start = step_range_end = 1;
862 if (!skip_subroutines)
864 Don't step over function calls, not even to functions lacking
866 step_over_calls = STEP_OVER_NONE;
869 if (skip_subroutines)
870 step_over_calls = STEP_OVER_ALL;
872 step_multi = (count > 1);
874 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
876 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
878 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
880 arg1->data.integer = skip_subroutines;
882 arg2->data.integer = single_inst;
884 arg3->data.integer = count;
885 add_intermediate_continuation (step_1_continuation, arg1);
886 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
891 /* Continue program at specified address. */
894 jump_command (char *arg, int from_tty)
897 struct symtabs_and_lines sals;
898 struct symtab_and_line sal;
905 /* Find out whether we must run in the background. */
907 async_exec = strip_bg_char (&arg);
909 /* If we must run in the background, but the target can't do it,
911 if (async_exec && !target_can_async_p ())
912 error (_("Asynchronous execution not supported on this target."));
914 /* If we are not asked to run in the bg, then prepare to run in the
915 foreground, synchronously. */
916 if (!async_exec && target_can_async_p ())
918 /* Simulate synchronous execution */
919 async_disable_stdin ();
923 error_no_arg (_("starting address"));
925 sals = decode_line_spec_1 (arg, 1);
928 error (_("Unreasonable jump request"));
934 if (sal.symtab == 0 && sal.pc == 0)
935 error (_("No source file has been specified."));
937 resolve_sal_pc (&sal); /* May error out */
939 /* See if we are trying to jump to another function. */
940 fn = get_frame_function (get_current_frame ());
941 sfn = find_pc_function (sal.pc);
942 if (fn != NULL && sfn != fn)
944 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
945 SYMBOL_PRINT_NAME (fn)))
947 error (_("Not confirmed."));
954 fixup_symbol_section (sfn, 0);
955 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
956 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
958 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
960 error (_("Not confirmed."));
970 printf_filtered (_("Continuing at "));
971 deprecated_print_address_numeric (addr, 1, gdb_stdout);
972 printf_filtered (".\n");
975 clear_proceed_status ();
976 proceed (addr, TARGET_SIGNAL_0, 0);
980 /* Go to line or address in current procedure */
982 go_command (char *line_no, int from_tty)
984 if (line_no == (char *) NULL || !*line_no)
985 printf_filtered (GO_USAGE);
988 tbreak_command (line_no, from_tty);
989 jump_command (line_no, from_tty);
994 /* Continue program giving it specified signal. */
997 signal_command (char *signum_exp, int from_tty)
999 enum target_signal oursig;
1001 dont_repeat (); /* Too dangerous. */
1005 error_no_arg (_("signal number"));
1007 /* It would be even slicker to make signal names be valid expressions,
1008 (the type could be "enum $signal" or some such), then the user could
1009 assign them to convenience variables. */
1010 oursig = target_signal_from_name (signum_exp);
1012 if (oursig == TARGET_SIGNAL_UNKNOWN)
1014 /* No, try numeric. */
1015 int num = parse_and_eval_long (signum_exp);
1018 oursig = TARGET_SIGNAL_0;
1020 oursig = target_signal_from_command (num);
1025 if (oursig == TARGET_SIGNAL_0)
1026 printf_filtered (_("Continuing with no signal.\n"));
1028 printf_filtered (_("Continuing with signal %s.\n"),
1029 target_signal_to_name (oursig));
1032 clear_proceed_status ();
1033 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
1034 FIXME: Neither should "signal foo" but when I tried passing
1035 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
1036 tried to track down yet. */
1037 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
1040 /* Proceed until we reach a different source line with pc greater than
1041 our current one or exit the function. We skip calls in both cases.
1043 Note that eventually this command should probably be changed so
1044 that only source lines are printed out when we hit the breakpoint
1045 we set. This may involve changes to wait_for_inferior and the
1046 proceed status code. */
1049 until_next_command (int from_tty)
1051 struct frame_info *frame;
1053 struct symbol *func;
1054 struct symtab_and_line sal;
1056 clear_proceed_status ();
1058 frame = get_current_frame ();
1060 /* Step until either exited from this function or greater
1061 than the current line (if in symbolic section) or pc (if
1065 func = find_pc_function (pc);
1069 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1071 if (msymbol == NULL)
1072 error (_("Execution is not within a known function."));
1074 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1075 step_range_end = pc;
1079 sal = find_pc_line (pc, 0);
1081 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1082 step_range_end = sal.end;
1085 step_over_calls = STEP_OVER_ALL;
1086 step_frame_id = get_frame_id (frame);
1088 step_multi = 0; /* Only one call to proceed */
1090 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1094 until_command (char *arg, int from_tty)
1098 if (!target_has_execution)
1099 error (_("The program is not running."));
1101 /* Find out whether we must run in the background. */
1103 async_exec = strip_bg_char (&arg);
1105 /* If we must run in the background, but the target can't do it,
1107 if (async_exec && !target_can_async_p ())
1108 error (_("Asynchronous execution not supported on this target."));
1110 /* If we are not asked to run in the bg, then prepare to run in the
1111 foreground, synchronously. */
1112 if (!async_exec && target_can_async_p ())
1114 /* Simulate synchronous execution */
1115 async_disable_stdin ();
1119 until_break_command (arg, from_tty, 0);
1121 until_next_command (from_tty);
1125 advance_command (char *arg, int from_tty)
1129 if (!target_has_execution)
1130 error (_("The program is not running."));
1133 error_no_arg (_("a location"));
1135 /* Find out whether we must run in the background. */
1137 async_exec = strip_bg_char (&arg);
1139 /* If we must run in the background, but the target can't do it,
1141 if (async_exec && !target_can_async_p ())
1142 error (_("Asynchronous execution not supported on this target."));
1144 /* If we are not asked to run in the bg, then prepare to run in the
1145 foreground, synchronously. */
1146 if (!async_exec && target_can_async_p ())
1148 /* Simulate synchronous execution. */
1149 async_disable_stdin ();
1152 until_break_command (arg, from_tty, 1);
1155 /* Print the result of a function at the end of a 'finish' command. */
1158 print_return_value (int struct_return, struct type *value_type)
1160 struct gdbarch *gdbarch = current_gdbarch;
1161 struct cleanup *old_chain;
1162 struct ui_stream *stb;
1163 struct value *value;
1165 CHECK_TYPEDEF (value_type);
1166 gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
1168 /* FIXME: 2003-09-27: When returning from a nested inferior function
1169 call, it's possible (with no help from the architecture vector)
1170 to locate and return/print a "struct return" value. This is just
1171 a more complicated case of what is already being done in in the
1172 inferior function call code. In fact, when inferior function
1173 calls are made async, this will likely be made the norm. */
1175 switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))
1177 case RETURN_VALUE_REGISTER_CONVENTION:
1178 case RETURN_VALUE_ABI_RETURNS_ADDRESS:
1179 case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
1180 value = allocate_value (value_type);
1181 gdbarch_return_value (current_gdbarch, value_type, stop_registers,
1182 value_contents_raw (value), NULL);
1184 case RETURN_VALUE_STRUCT_CONVENTION:
1188 internal_error (__FILE__, __LINE__, _("bad switch"));
1194 stb = ui_out_stream_new (uiout);
1195 old_chain = make_cleanup_ui_out_stream_delete (stb);
1196 ui_out_text (uiout, "Value returned is ");
1197 ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
1198 record_latest_value (value));
1199 ui_out_text (uiout, " = ");
1200 value_print (value, stb->stream, 0, Val_no_prettyprint);
1201 ui_out_field_stream (uiout, "return-value", stb);
1202 ui_out_text (uiout, "\n");
1203 do_cleanups (old_chain);
1207 ui_out_text (uiout, "Value returned has type: ");
1208 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1209 ui_out_text (uiout, ".");
1210 ui_out_text (uiout, " Cannot determine contents\n");
1214 /* Stuff that needs to be done by the finish command after the target
1215 has stopped. In asynchronous mode, we wait for the target to stop
1216 in the call to poll or select in the event loop, so it is
1217 impossible to do all the stuff as part of the finish_command
1218 function itself. The only chance we have to complete this command
1219 is in fetch_inferior_event, which is called by the event loop as
1220 soon as it detects that the target has stopped. This function is
1221 called via the cmd_continuation pointer. */
1224 finish_command_continuation (struct continuation_arg *arg)
1226 struct symbol *function;
1227 struct breakpoint *breakpoint;
1228 struct cleanup *cleanups;
1230 breakpoint = (struct breakpoint *) arg->data.pointer;
1231 function = (struct symbol *) arg->next->data.pointer;
1232 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1234 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1235 && function != NULL)
1237 struct type *value_type;
1241 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1243 internal_error (__FILE__, __LINE__,
1244 _("finish_command: function has no target type"));
1246 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1248 do_exec_cleanups (cleanups);
1252 CHECK_TYPEDEF (value_type);
1253 gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
1254 struct_return = using_struct_return (value_type, gcc_compiled);
1256 print_return_value (struct_return, value_type);
1259 do_exec_cleanups (cleanups);
1262 /* "finish": Set a temporary breakpoint at the place the selected
1263 frame will return to, then continue. */
1266 finish_command (char *arg, int from_tty)
1268 struct symtab_and_line sal;
1269 struct frame_info *frame;
1270 struct symbol *function;
1271 struct breakpoint *breakpoint;
1272 struct cleanup *old_chain;
1273 struct continuation_arg *arg1, *arg2, *arg3;
1277 /* Find out whether we must run in the background. */
1279 async_exec = strip_bg_char (&arg);
1281 /* If we must run in the background, but the target can't do it,
1283 if (async_exec && !target_can_async_p ())
1284 error (_("Asynchronous execution not supported on this target."));
1286 /* If we are not asked to run in the bg, then prepare to run in the
1287 foreground, synchronously. */
1288 if (!async_exec && target_can_async_p ())
1290 /* Simulate synchronous execution. */
1291 async_disable_stdin ();
1295 error (_("The \"finish\" command does not take any arguments."));
1296 if (!target_has_execution)
1297 error (_("The program is not running."));
1299 frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
1301 error (_("\"finish\" not meaningful in the outermost frame."));
1303 clear_proceed_status ();
1305 sal = find_pc_line (get_frame_pc (frame), 0);
1306 sal.pc = get_frame_pc (frame);
1308 breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish);
1310 if (!target_can_async_p ())
1311 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1313 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1315 /* Find the function we will return from. */
1317 function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
1319 /* Print info on the selected frame, including level number but not
1323 printf_filtered (_("Run till exit from "));
1324 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1327 /* If running asynchronously and the target support asynchronous
1328 execution, set things up for the rest of the finish command to be
1329 completed later on, when gdb has detected that the target has
1330 stopped, in fetch_inferior_event. */
1331 if (target_can_async_p ())
1334 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1336 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1338 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1342 arg1->data.pointer = breakpoint;
1343 arg2->data.pointer = function;
1344 arg3->data.pointer = old_chain;
1345 add_continuation (finish_command_continuation, arg1);
1348 proceed_to_finish = 1; /* We want stop_registers, please... */
1349 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1351 /* Do this only if not running asynchronously or if the target
1352 cannot do async execution. Otherwise, complete this command when
1353 the target actually stops, in fetch_inferior_event. */
1354 if (!target_can_async_p ())
1356 /* Did we stop at our breakpoint? */
1357 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1358 && function != NULL)
1360 struct type *value_type;
1364 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1366 internal_error (__FILE__, __LINE__,
1367 _("finish_command: function has no target type"));
1369 /* FIXME: Shouldn't we do the cleanups before returning? */
1370 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1373 CHECK_TYPEDEF (value_type);
1374 gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
1375 struct_return = using_struct_return (value_type, gcc_compiled);
1377 print_return_value (struct_return, value_type);
1380 do_cleanups (old_chain);
1386 program_info (char *args, int from_tty)
1388 bpstat bs = stop_bpstat;
1389 int num = bpstat_num (&bs);
1391 if (!target_has_execution)
1393 printf_filtered (_("The program being debugged is not being run.\n"));
1397 target_files_info ();
1398 printf_filtered (_("Program stopped at %s.\n"),
1399 hex_string ((unsigned long) stop_pc));
1401 printf_filtered (_("It stopped after being stepped.\n"));
1404 /* There may be several breakpoints in the same place, so this
1405 isn't as strange as it seems. */
1410 printf_filtered (_("\
1411 It stopped at a breakpoint that has since been deleted.\n"));
1414 printf_filtered (_("It stopped at breakpoint %d.\n"), num);
1415 num = bpstat_num (&bs);
1418 else if (stop_signal != TARGET_SIGNAL_0)
1420 printf_filtered (_("It stopped with signal %s, %s.\n"),
1421 target_signal_to_name (stop_signal),
1422 target_signal_to_string (stop_signal));
1427 printf_filtered (_("\
1428 Type \"info stack\" or \"info registers\" for more information.\n"));
1433 environment_info (char *var, int from_tty)
1437 char *val = get_in_environ (inferior_environ, var);
1440 puts_filtered (var);
1441 puts_filtered (" = ");
1442 puts_filtered (val);
1443 puts_filtered ("\n");
1447 puts_filtered ("Environment variable \"");
1448 puts_filtered (var);
1449 puts_filtered ("\" not defined.\n");
1454 char **vector = environ_vector (inferior_environ);
1457 puts_filtered (*vector++);
1458 puts_filtered ("\n");
1464 set_environment_command (char *arg, int from_tty)
1466 char *p, *val, *var;
1470 error_no_arg (_("environment variable and value"));
1472 /* Find seperation between variable name and value */
1473 p = (char *) strchr (arg, '=');
1474 val = (char *) strchr (arg, ' ');
1476 if (p != 0 && val != 0)
1478 /* We have both a space and an equals. If the space is before the
1479 equals, walk forward over the spaces til we see a nonspace
1480 (possibly the equals). */
1485 /* Now if the = is after the char following the spaces,
1486 take the char following the spaces. */
1490 else if (val != 0 && p == 0)
1494 error_no_arg (_("environment variable to set"));
1496 if (p == 0 || p[1] == 0)
1500 p = arg + strlen (arg); /* So that savestring below will work */
1504 /* Not setting variable value to null */
1506 while (*val == ' ' || *val == '\t')
1510 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1513 var = savestring (arg, p - arg);
1516 printf_filtered (_("\
1517 Setting environment variable \"%s\" to null value.\n"),
1519 set_in_environ (inferior_environ, var, "");
1522 set_in_environ (inferior_environ, var, val);
1527 unset_environment_command (char *var, int from_tty)
1531 /* If there is no argument, delete all environment variables.
1532 Ask for confirmation if reading from the terminal. */
1533 if (!from_tty || query (_("Delete all environment variables? ")))
1535 free_environ (inferior_environ);
1536 inferior_environ = make_environ ();
1540 unset_in_environ (inferior_environ, var);
1543 /* Handle the execution path (PATH variable) */
1545 static const char path_var_name[] = "PATH";
1548 path_info (char *args, int from_tty)
1550 puts_filtered ("Executable and object file path: ");
1551 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1552 puts_filtered ("\n");
1555 /* Add zero or more directories to the front of the execution path. */
1558 path_command (char *dirname, int from_tty)
1563 env = get_in_environ (inferior_environ, path_var_name);
1564 /* Can be null if path is not set */
1567 exec_path = xstrdup (env);
1568 mod_path (dirname, &exec_path);
1569 set_in_environ (inferior_environ, path_var_name, exec_path);
1572 path_info ((char *) NULL, from_tty);
1576 /* Print out the machine register regnum. If regnum is -1, print all
1577 registers (print_all == 1) or all non-float and non-vector
1578 registers (print_all == 0).
1580 For most machines, having all_registers_info() print the
1581 register(s) one per line is good enough. If a different format is
1582 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1583 regs), or there is an existing convention for showing all the
1584 registers, define the architecture method PRINT_REGISTERS_INFO to
1585 provide that format. */
1588 default_print_registers_info (struct gdbarch *gdbarch,
1589 struct ui_file *file,
1590 struct frame_info *frame,
1591 int regnum, int print_all)
1594 const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
1595 gdb_byte buffer[MAX_REGISTER_SIZE];
1597 for (i = 0; i < numregs; i++)
1599 /* Decide between printing all regs, non-float / vector regs, or
1605 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1610 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1620 /* If the register name is empty, it is undefined for this
1621 processor, so don't display anything. */
1622 if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1625 fputs_filtered (REGISTER_NAME (i), file);
1626 print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
1628 /* Get the data in raw format. */
1629 if (! frame_register_read (frame, i, buffer))
1631 fprintf_filtered (file, "*value not available*\n");
1635 /* If virtual format is floating, print it that way, and in raw
1637 if (TYPE_CODE (register_type (current_gdbarch, i)) == TYPE_CODE_FLT)
1641 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1642 file, 0, 1, 0, Val_pretty_default);
1644 fprintf_filtered (file, "\t(raw 0x");
1645 for (j = 0; j < register_size (current_gdbarch, i); j++)
1648 if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
1651 idx = register_size (current_gdbarch, i) - 1 - j;
1652 fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
1654 fprintf_filtered (file, ")");
1658 /* Print the register in hex. */
1659 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1660 file, 'x', 1, 0, Val_pretty_default);
1661 /* If not a vector register, print it also according to its
1663 if (TYPE_VECTOR (register_type (current_gdbarch, i)) == 0)
1665 fprintf_filtered (file, "\t");
1666 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1667 file, 0, 1, 0, Val_pretty_default);
1671 fprintf_filtered (file, "\n");
1676 registers_info (char *addr_exp, int fpregs)
1678 struct frame_info *frame;
1679 int regnum, numregs;
1682 if (!target_has_registers)
1683 error (_("The program has no registers now."));
1684 frame = get_selected_frame (NULL);
1688 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1693 while (*addr_exp != '\0')
1698 /* Keep skipping leading white space. */
1699 if (isspace ((*addr_exp)))
1705 /* Discard any leading ``$''. Check that there is something
1706 resembling a register following it. */
1707 if (addr_exp[0] == '$')
1709 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1710 error (_("Missing register name"));
1712 /* Find the start/end of this register name/num/group. */
1714 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1718 /* Figure out what we've found and display it. */
1720 /* A register name? */
1722 int regnum = frame_map_name_to_regnum (frame,
1723 start, end - start);
1726 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1727 frame, regnum, fpregs);
1732 /* A register number? (how portable is this one?). */
1735 int regnum = strtol (start, &endptr, 0);
1738 && regnum < NUM_REGS + NUM_PSEUDO_REGS)
1740 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1741 frame, regnum, fpregs);
1746 /* A register group? */
1748 struct reggroup *group;
1749 for (group = reggroup_next (current_gdbarch, NULL);
1751 group = reggroup_next (current_gdbarch, group))
1753 /* Don't bother with a length check. Should the user
1754 enter a short register group name, go with the first
1755 group that matches. */
1756 if (strncmp (start, reggroup_name (group), end - start) == 0)
1762 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1764 if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
1766 gdbarch_print_registers_info (current_gdbarch,
1774 /* Nothing matched. */
1775 error (_("Invalid register `%.*s'"), (int) (end - start), start);
1780 all_registers_info (char *addr_exp, int from_tty)
1782 registers_info (addr_exp, 1);
1786 nofp_registers_info (char *addr_exp, int from_tty)
1788 registers_info (addr_exp, 0);
1792 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
1793 struct frame_info *frame, const char *args)
1795 if (gdbarch_print_vector_info_p (gdbarch))
1796 gdbarch_print_vector_info (gdbarch, file, frame, args);
1800 int printed_something = 0;
1802 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1804 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
1806 printed_something = 1;
1807 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1810 if (!printed_something)
1811 fprintf_filtered (file, "No vector information\n");
1816 vector_info (char *args, int from_tty)
1818 if (!target_has_registers)
1819 error (_("The program has no registers now."));
1821 print_vector_info (current_gdbarch, gdb_stdout,
1822 get_selected_frame (NULL), args);
1828 * Should save/restore the tty state since it might be that the
1829 * program to be debugged was started on this tty and it wants
1830 * the tty in some state other than what we want. If it's running
1831 * on another terminal or without a terminal, then saving and
1832 * restoring the tty state is a harmless no-op.
1833 * This only needs to be done if we are attaching to a process.
1838 takes a program started up outside of gdb and ``attaches'' to it.
1839 This stops it cold in its tracks and allows us to start debugging it.
1840 and wait for the trace-trap that results from attaching. */
1843 attach_command (char *args, int from_tty)
1846 char *full_exec_path = NULL;
1848 dont_repeat (); /* Not for the faint of heart */
1850 if (target_has_execution)
1852 if (query ("A program is being debugged already. Kill it? "))
1855 error (_("Not killed."));
1858 /* Clean up any leftovers from other runs. Some other things from
1859 this function should probably be moved into target_pre_inferior. */
1860 target_pre_inferior (from_tty);
1862 /* Clear out solib state. Otherwise the solib state of the previous
1863 inferior might have survived and is entirely wrong for the new
1864 target. This has been observed on GNU/Linux using glibc 2.3. How
1876 Cannot access memory at address 0xdeadbeef
1884 target_attach (args, from_tty);
1886 /* Set up the "saved terminal modes" of the inferior
1887 based on what modes we are starting it with. */
1888 target_terminal_init ();
1890 /* Set up execution context to know that we should return from
1891 wait_for_inferior as soon as the target reports a stop. */
1892 init_wait_for_inferior ();
1893 clear_proceed_status ();
1895 /* No traps are generated when attaching to inferior under Mach 3
1897 #ifndef ATTACH_NO_WAIT
1898 /* Careful here. See comments in inferior.h. Basically some OSes
1899 don't ignore SIGSTOPs on continue requests anymore. We need a
1900 way for handle_inferior_event to reset the stop_signal variable
1901 after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */
1902 stop_soon = STOP_QUIETLY_NO_SIGSTOP;
1903 wait_for_inferior ();
1904 stop_soon = NO_STOP_QUIETLY;
1908 * If no exec file is yet known, try to determine it from the
1911 exec_file = (char *) get_exec_file (0);
1914 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
1917 /* It's possible we don't have a full path, but rather just a
1918 filename. Some targets, such as HP-UX, don't provide the
1921 Attempt to qualify the filename against the source path.
1922 (If that fails, we'll just fall back on the original
1923 filename. Not much more we can do...)
1925 if (!source_full_path_of (exec_file, &full_exec_path))
1926 full_exec_path = savestring (exec_file, strlen (exec_file));
1928 exec_file_attach (full_exec_path, from_tty);
1929 symbol_file_add_main (full_exec_path, from_tty);
1934 reopen_exec_file ();
1938 /* Take any necessary post-attaching actions for this platform.
1940 target_post_attach (PIDGET (inferior_ptid));
1942 post_create_inferior (¤t_target, from_tty);
1944 /* Install inferior's terminal modes. */
1945 target_terminal_inferior ();
1949 if (deprecated_attach_hook)
1950 deprecated_attach_hook ();
1955 * takes a program previously attached to and detaches it.
1956 * The program resumes execution and will no longer stop
1957 * on signals, etc. We better not have left any breakpoints
1958 * in the program or it'll die when it hits one. For this
1959 * to work, it may be necessary for the process to have been
1960 * previously attached. It *might* work if the program was
1961 * started via the normal ptrace (PTRACE_TRACEME).
1965 detach_command (char *args, int from_tty)
1967 dont_repeat (); /* Not for the faint of heart. */
1968 target_detach (args, from_tty);
1969 #if defined(SOLIB_RESTART)
1972 if (deprecated_detach_hook)
1973 deprecated_detach_hook ();
1976 /* Disconnect from the current target without resuming it (leaving it
1977 waiting for a debugger).
1979 We'd better not have left any breakpoints in the program or the
1980 next debugger will get confused. Currently only supported for some
1981 remote targets, since the normal attach mechanisms don't work on
1982 stopped processes on some native platforms (e.g. GNU/Linux). */
1985 disconnect_command (char *args, int from_tty)
1987 dont_repeat (); /* Not for the faint of heart */
1988 target_disconnect (args, from_tty);
1989 #if defined(SOLIB_RESTART)
1992 if (deprecated_detach_hook)
1993 deprecated_detach_hook ();
1996 /* Stop the execution of the target while running in async mode, in
1999 interrupt_target_command (char *args, int from_tty)
2001 if (target_can_async_p ())
2003 dont_repeat (); /* Not for the faint of heart */
2009 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
2010 struct frame_info *frame, const char *args)
2012 if (gdbarch_print_float_info_p (gdbarch))
2013 gdbarch_print_float_info (gdbarch, file, frame, args);
2017 int printed_something = 0;
2019 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
2021 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
2023 printed_something = 1;
2024 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2027 if (!printed_something)
2028 fprintf_filtered (file, "\
2029 No floating-point info available for this processor.\n");
2034 float_info (char *args, int from_tty)
2036 if (!target_has_registers)
2037 error (_("The program has no registers now."));
2039 print_float_info (current_gdbarch, gdb_stdout,
2040 get_selected_frame (NULL), args);
2044 unset_command (char *args, int from_tty)
2046 printf_filtered (_("\
2047 \"unset\" must be followed by the name of an unset subcommand.\n"));
2048 help_list (unsetlist, "unset ", -1, gdb_stdout);
2052 _initialize_infcmd (void)
2054 struct cmd_list_element *c = NULL;
2056 /* add the filename of the terminal connected to inferior I/O */
2057 add_setshow_filename_cmd ("inferior-tty", class_run,
2058 &inferior_io_terminal, _("\
2059 Set terminal for future runs of program being debugged."), _("\
2060 Show terminal for future runs of program being debugged."), _("\
2061 Usage: set inferior-tty /dev/pts/1"), NULL, NULL, &setlist, &showlist);
2062 add_com_alias ("tty", "set inferior-tty", class_alias, 0);
2064 add_setshow_optional_filename_cmd ("args", class_run,
2065 &inferior_args, _("\
2066 Set argument list to give program being debugged when it is started."), _("\
2067 Show argument list to give program being debugged when it is started."), _("\
2068 Follow this command with any number of args, to be passed to the program."),
2071 &setlist, &showlist);
2073 c = add_cmd ("environment", no_class, environment_info, _("\
2074 The environment to give the program, or one variable's value.\n\
2075 With an argument VAR, prints the value of environment variable VAR to\n\
2076 give the program being debugged. With no arguments, prints the entire\n\
2077 environment to be given to the program."), &showlist);
2078 set_cmd_completer (c, noop_completer);
2080 add_prefix_cmd ("unset", no_class, unset_command,
2081 _("Complement to certain \"set\" commands."),
2082 &unsetlist, "unset ", 0, &cmdlist);
2084 c = add_cmd ("environment", class_run, unset_environment_command, _("\
2085 Cancel environment variable VAR for the program.\n\
2086 This does not affect the program until the next \"run\" command."),
2088 set_cmd_completer (c, noop_completer);
2090 c = add_cmd ("environment", class_run, set_environment_command, _("\
2091 Set environment variable value to give the program.\n\
2092 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2093 VALUES of environment variables are uninterpreted strings.\n\
2094 This does not affect the program until the next \"run\" command."),
2096 set_cmd_completer (c, noop_completer);
2098 c = add_com ("path", class_files, path_command, _("\
2099 Add directory DIR(s) to beginning of search path for object files.\n\
2100 $cwd in the path means the current working directory.\n\
2101 This path is equivalent to the $PATH shell variable. It is a list of\n\
2102 directories, separated by colons. These directories are searched to find\n\
2103 fully linked executable files and separately compiled object files as needed."));
2104 set_cmd_completer (c, filename_completer);
2106 c = add_cmd ("paths", no_class, path_info, _("\
2107 Current search path for finding object files.\n\
2108 $cwd in the path means the current working directory.\n\
2109 This path is equivalent to the $PATH shell variable. It is a list of\n\
2110 directories, separated by colons. These directories are searched to find\n\
2111 fully linked executable files and separately compiled object files as needed."),
2113 set_cmd_completer (c, noop_completer);
2115 add_com ("attach", class_run, attach_command, _("\
2116 Attach to a process or file outside of GDB.\n\
2117 This command attaches to another target, of the same type as your last\n\
2118 \"target\" command (\"info files\" will show your target stack).\n\
2119 The command may take as argument a process id or a device file.\n\
2120 For a process id, you must have permission to send the process a signal,\n\
2121 and it must have the same effective uid as the debugger.\n\
2122 When using \"attach\" with a process id, the debugger finds the\n\
2123 program running in the process, looking first in the current working\n\
2124 directory, or (if not found there) using the source file search path\n\
2125 (see the \"directory\" command). You can also use the \"file\" command\n\
2126 to specify the program, and to load its symbol table."));
2128 add_prefix_cmd ("detach", class_run, detach_command, _("\
2129 Detach a process or file previously attached.\n\
2130 If a process, it is no longer traced, and it continues its execution. If\n\
2131 you were debugging a file, the file is closed and gdb no longer accesses it."),
2132 &detachlist, "detach ", 0, &cmdlist);
2134 add_com ("disconnect", class_run, disconnect_command, _("\
2135 Disconnect from a target.\n\
2136 The target will wait for another debugger to connect. Not available for\n\
2139 add_com ("signal", class_run, signal_command, _("\
2140 Continue program giving it signal specified by the argument.\n\
2141 An argument of \"0\" means continue program without giving it a signal."));
2143 add_com ("stepi", class_run, stepi_command, _("\
2144 Step one instruction exactly.\n\
2145 Argument N means do this N times (or till program stops for another reason)."));
2146 add_com_alias ("si", "stepi", class_alias, 0);
2148 add_com ("nexti", class_run, nexti_command, _("\
2149 Step one instruction, but proceed through subroutine calls.\n\
2150 Argument N means do this N times (or till program stops for another reason)."));
2151 add_com_alias ("ni", "nexti", class_alias, 0);
2153 add_com ("finish", class_run, finish_command, _("\
2154 Execute until selected stack frame returns.\n\
2155 Upon return, the value returned is printed and put in the value history."));
2157 add_com ("next", class_run, next_command, _("\
2158 Step program, proceeding through subroutine calls.\n\
2159 Like the \"step\" command as long as subroutine calls do not happen;\n\
2160 when they do, the call is treated as one instruction.\n\
2161 Argument N means do this N times (or till program stops for another reason)."));
2162 add_com_alias ("n", "next", class_run, 1);
2164 add_com_alias ("S", "next", class_run, 1);
2166 add_com ("step", class_run, step_command, _("\
2167 Step program until it reaches a different source line.\n\
2168 Argument N means do this N times (or till program stops for another reason)."));
2169 add_com_alias ("s", "step", class_run, 1);
2171 c = add_com ("until", class_run, until_command, _("\
2172 Execute until the program reaches a source line greater than the current\n\
2173 or a specified location (same args as break command) within the current frame."));
2174 set_cmd_completer (c, location_completer);
2175 add_com_alias ("u", "until", class_run, 1);
2177 c = add_com ("advance", class_run, advance_command, _("\
2178 Continue the program up to the given location (same form as args for break command).\n\
2179 Execution will also stop upon exit from the current stack frame."));
2180 set_cmd_completer (c, location_completer);
2182 c = add_com ("jump", class_run, jump_command, _("\
2183 Continue program being debugged at specified line or address.\n\
2184 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2185 for an address to start at."));
2186 set_cmd_completer (c, location_completer);
2190 c = add_com ("go", class_run, go_command, _("\
2191 Usage: go <location>\n\
2192 Continue program being debugged, stopping at specified line or \n\
2194 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2195 expression for an address to start at.\n\
2196 This command is a combination of tbreak and jump."));
2197 set_cmd_completer (c, location_completer);
2201 add_com_alias ("g", "go", class_run, 1);
2203 add_com ("continue", class_run, continue_command, _("\
2204 Continue program being debugged, after signal or breakpoint.\n\
2205 If proceeding from breakpoint, a number N may be used as an argument,\n\
2206 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2207 the breakpoint won't break until the Nth time it is reached)."));
2208 add_com_alias ("c", "cont", class_run, 1);
2209 add_com_alias ("fg", "cont", class_run, 1);
2211 c = add_com ("run", class_run, run_command, _("\
2212 Start debugged program. You may specify arguments to give it.\n\
2213 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2214 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2215 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2216 To cancel previous arguments and run with no arguments,\n\
2217 use \"set args\" without arguments."));
2218 set_cmd_completer (c, filename_completer);
2219 add_com_alias ("r", "run", class_run, 1);
2221 add_com ("R", class_run, run_no_args_command,
2222 _("Start debugged program with no arguments."));
2224 c = add_com ("start", class_run, start_command, _("\
2225 Run the debugged program until the beginning of the main procedure.\n\
2226 You may specify arguments to give to your program, just as with the\n\
2227 \"run\" command."));
2228 set_cmd_completer (c, filename_completer);
2230 add_com ("interrupt", class_run, interrupt_target_command,
2231 _("Interrupt the execution of the debugged program."));
2233 add_info ("registers", nofp_registers_info, _("\
2234 List of integer registers and their contents, for selected stack frame.\n\
2235 Register name as argument means describe only that register."));
2236 add_info_alias ("r", "registers", 1);
2239 add_com ("lr", class_info, nofp_registers_info, _("\
2240 List of integer registers and their contents, for selected stack frame.\n\
2241 Register name as argument means describe only that register."));
2242 add_info ("all-registers", all_registers_info, _("\
2243 List of all registers and their contents, for selected stack frame.\n\
2244 Register name as argument means describe only that register."));
2246 add_info ("program", program_info,
2247 _("Execution status of the program."));
2249 add_info ("float", float_info,
2250 _("Print the status of the floating point unit\n"));
2252 add_info ("vector", vector_info,
2253 _("Print the status of the vector unit\n"));
2255 inferior_environ = make_environ ();
2256 init_environ (inferior_environ);