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 /* Be sure we own the terminal in case write operations are performed. */
410 target_terminal_ours ();
412 /* If the target hasn't taken care of this already, do it now.
413 Targets which need to access registers during to_open,
414 to_create_inferior, or to_attach should do it earlier; but many
416 target_find_description ();
420 /* Sometimes the platform-specific hook loads initial shared
421 libraries, and sometimes it doesn't. Try to do so first, so
422 that we can add them with the correct value for FROM_TTY. */
424 SOLIB_ADD (NULL, from_tty, target, auto_solib_add);
426 solib_add (NULL, from_tty, target, auto_solib_add);
429 /* Create the hooks to handle shared library load and unload
431 #ifdef SOLIB_CREATE_INFERIOR_HOOK
432 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
434 solib_create_inferior_hook ();
437 /* Enable any breakpoints which were disabled when the
438 underlying shared library was deleted. */
439 re_enable_breakpoints_in_shlibs ();
442 observer_notify_inferior_created (target, from_tty);
445 /* Kill the inferior if already running. This function is designed
446 to be called when we are about to start the execution of the program
447 from the beginning. Ask the user to confirm that he wants to restart
448 the program being debugged when FROM_TTY is non-null. */
451 kill_if_already_running (int from_tty)
453 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
456 && !query ("The program being debugged has been started already.\n\
457 Start it from the beginning? "))
458 error (_("Program not restarted."));
460 #if defined(SOLIB_RESTART)
463 init_wait_for_inferior ();
467 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
468 a temporary breakpoint at the begining of the main program before
469 running the program. */
472 run_command_1 (char *args, int from_tty, int tbreak_at_main)
478 kill_if_already_running (from_tty);
479 clear_breakpoint_hit_counts ();
481 /* Clean up any leftovers from other runs. Some other things from
482 this function should probably be moved into target_pre_inferior. */
483 target_pre_inferior (from_tty);
485 /* Purge old solib objfiles. */
486 objfile_purge_solibs ();
488 do_run_cleanups (NULL);
490 /* The comment here used to read, "The exec file is re-read every
491 time we do a generic_mourn_inferior, so we just have to worry
492 about the symbol file." The `generic_mourn_inferior' function
493 gets called whenever the program exits. However, suppose the
494 program exits, and *then* the executable file changes? We need
495 to check again here. Since reopen_exec_file doesn't do anything
496 if the timestamp hasn't changed, I don't see the harm. */
500 /* Insert the temporary breakpoint if a location was specified. */
502 tbreak_command (main_name (), 0);
504 exec_file = (char *) get_exec_file (0);
506 /* We keep symbols from add-symbol-file, on the grounds that the
507 user might want to add some symbols before running the program
508 (right?). But sometimes (dynamic loading where the user manually
509 introduces the new symbols with add-symbol-file), the code which
510 the symbols describe does not persist between runs. Currently
511 the user has to manually nuke all symbols between runs if they
512 want them to go away (PR 2207). This is probably reasonable. */
516 if (target_can_async_p ())
517 async_disable_stdin ();
521 int async_exec = strip_bg_char (&args);
523 /* If we get a request for running in the bg but the target
524 doesn't support it, error out. */
525 if (async_exec && !target_can_async_p ())
526 error (_("Asynchronous execution not supported on this target."));
528 /* If we don't get a request of running in the bg, then we need
529 to simulate synchronous (fg) execution. */
530 if (!async_exec && target_can_async_p ())
532 /* Simulate synchronous execution */
533 async_disable_stdin ();
536 /* If there were other args, beside '&', process them. */
539 char *old_args = set_inferior_args (xstrdup (args));
546 ui_out_field_string (uiout, NULL, "Starting program");
547 ui_out_text (uiout, ": ");
549 ui_out_field_string (uiout, "execfile", exec_file);
550 ui_out_spaces (uiout, 1);
551 /* We call get_inferior_args() because we might need to compute
553 ui_out_field_string (uiout, "infargs", get_inferior_args ());
554 ui_out_text (uiout, "\n");
555 ui_out_flush (uiout);
558 /* We call get_inferior_args() because we might need to compute
560 target_create_inferior (exec_file, get_inferior_args (),
561 environ_vector (inferior_environ), from_tty);
563 post_create_inferior (¤t_target, from_tty);
565 /* Start the target running. */
566 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
571 run_command (char *args, int from_tty)
573 run_command_1 (args, from_tty, 0);
577 run_no_args_command (char *args, int from_tty)
579 char *old_args = set_inferior_args (xstrdup (""));
584 /* Start the execution of the program up until the beginning of the main
588 start_command (char *args, int from_tty)
590 /* Some languages such as Ada need to search inside the program
591 minimal symbols for the location where to put the temporary
592 breakpoint before starting. */
593 if (!have_minimal_symbols ())
594 error (_("No symbol table loaded. Use the \"file\" command."));
596 /* Run the program until reaching the main procedure... */
597 run_command_1 (args, from_tty, 1);
601 continue_command (char *proc_count_exp, int from_tty)
606 /* Find out whether we must run in the background. */
607 if (proc_count_exp != NULL)
608 async_exec = strip_bg_char (&proc_count_exp);
610 /* If we must run in the background, but the target can't do it,
612 if (async_exec && !target_can_async_p ())
613 error (_("Asynchronous execution not supported on this target."));
615 /* If we are not asked to run in the bg, then prepare to run in the
616 foreground, synchronously. */
617 if (!async_exec && target_can_async_p ())
619 /* Simulate synchronous execution */
620 async_disable_stdin ();
623 /* If have argument (besides '&'), set proceed count of breakpoint
625 if (proc_count_exp != NULL)
627 bpstat bs = stop_bpstat;
631 while ((stat = bpstat_num (&bs, &num)) != 0)
634 set_ignore_count (num,
635 parse_and_eval_long (proc_count_exp) - 1,
637 /* set_ignore_count prints a message ending with a period.
638 So print two spaces before "Continuing.". */
640 printf_filtered (" ");
644 if (!stopped && from_tty)
647 ("Not stopped at any breakpoint; argument ignored.\n");
652 printf_filtered (_("Continuing.\n"));
654 clear_proceed_status ();
656 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
659 /* Step until outside of current statement. */
662 step_command (char *count_string, int from_tty)
664 step_1 (0, 0, count_string);
667 /* Likewise, but skip over subroutine calls as if single instructions. */
670 next_command (char *count_string, int from_tty)
672 step_1 (1, 0, count_string);
675 /* Likewise, but step only one instruction. */
678 stepi_command (char *count_string, int from_tty)
680 step_1 (0, 1, count_string);
684 nexti_command (char *count_string, int from_tty)
686 step_1 (1, 1, count_string);
690 disable_longjmp_breakpoint_cleanup (void *ignore)
692 disable_longjmp_breakpoint ();
696 step_1 (int skip_subroutines, int single_inst, char *count_string)
699 struct frame_info *frame;
700 struct cleanup *cleanups = 0;
706 async_exec = strip_bg_char (&count_string);
708 /* If we get a request for running in the bg but the target
709 doesn't support it, error out. */
710 if (async_exec && !target_can_async_p ())
711 error (_("Asynchronous execution not supported on this target."));
713 /* If we don't get a request of running in the bg, then we need
714 to simulate synchronous (fg) execution. */
715 if (!async_exec && target_can_async_p ())
717 /* Simulate synchronous execution */
718 async_disable_stdin ();
721 count = count_string ? parse_and_eval_long (count_string) : 1;
723 if (!single_inst || skip_subroutines) /* leave si command alone */
725 enable_longjmp_breakpoint ();
726 if (!target_can_async_p ())
727 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
729 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
732 /* In synchronous case, all is well, just use the regular for loop. */
733 if (!target_can_async_p ())
735 for (; count > 0; count--)
737 clear_proceed_status ();
739 frame = get_current_frame ();
740 if (!frame) /* Avoid coredump here. Why tho? */
741 error (_("No current frame"));
742 step_frame_id = get_frame_id (frame);
746 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
747 if (step_range_end == 0)
750 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
751 &step_range_end) == 0)
752 error (_("Cannot find bounds of current function"));
754 target_terminal_ours ();
755 printf_filtered (_("\
756 Single stepping until exit from function %s, \n\
757 which has no line number information.\n"), name);
762 /* Say we are stepping, but stop after one insn whatever it does. */
763 step_range_start = step_range_end = 1;
764 if (!skip_subroutines)
766 Don't step over function calls, not even to functions lacking
768 step_over_calls = STEP_OVER_NONE;
771 if (skip_subroutines)
772 step_over_calls = STEP_OVER_ALL;
774 step_multi = (count > 1);
775 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
781 if (!single_inst || skip_subroutines)
782 do_cleanups (cleanups);
785 /* In case of asynchronous target things get complicated, do only
786 one step for now, before returning control to the event loop. Let
787 the continuation figure out how many other steps we need to do,
788 and handle them one at the time, through step_once(). */
791 if (target_can_async_p ())
792 step_once (skip_subroutines, single_inst, count);
796 /* Called after we are done with one step operation, to check whether
797 we need to step again, before we print the prompt and return control
798 to the user. If count is > 1, we will need to do one more call to
799 proceed(), via step_once(). Basically it is like step_once and
800 step_1_continuation are co-recursive. */
802 step_1_continuation (struct continuation_arg *arg)
805 int skip_subroutines;
808 skip_subroutines = arg->data.integer;
809 single_inst = arg->next->data.integer;
810 count = arg->next->next->data.integer;
813 step_once (skip_subroutines, single_inst, count - 1);
815 if (!single_inst || skip_subroutines)
816 do_exec_cleanups (ALL_CLEANUPS);
819 /* Do just one step operation. If count >1 we will have to set up a
820 continuation to be done after the target stops (after this one
821 step). This is useful to implement the 'step n' kind of commands, in
822 case of asynchronous targets. We had to split step_1 into two parts,
823 one to be done before proceed() and one afterwards. This function is
824 called in case of step n with n>1, after the first step operation has
827 step_once (int skip_subroutines, int single_inst, int count)
829 struct continuation_arg *arg1;
830 struct continuation_arg *arg2;
831 struct continuation_arg *arg3;
832 struct frame_info *frame;
836 clear_proceed_status ();
838 frame = get_current_frame ();
839 if (!frame) /* Avoid coredump here. Why tho? */
840 error (_("No current frame"));
841 step_frame_id = get_frame_id (frame);
845 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
847 /* If we have no line info, switch to stepi mode. */
848 if (step_range_end == 0 && step_stop_if_no_debug)
850 step_range_start = step_range_end = 1;
852 else if (step_range_end == 0)
855 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
856 &step_range_end) == 0)
857 error (_("Cannot find bounds of current function"));
859 target_terminal_ours ();
860 printf_filtered (_("\
861 Single stepping until exit from function %s, \n\
862 which has no line number information.\n"), name);
867 /* Say we are stepping, but stop after one insn whatever it does. */
868 step_range_start = step_range_end = 1;
869 if (!skip_subroutines)
871 Don't step over function calls, not even to functions lacking
873 step_over_calls = STEP_OVER_NONE;
876 if (skip_subroutines)
877 step_over_calls = STEP_OVER_ALL;
879 step_multi = (count > 1);
881 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
883 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
885 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
887 arg1->data.integer = skip_subroutines;
889 arg2->data.integer = single_inst;
891 arg3->data.integer = count;
892 add_intermediate_continuation (step_1_continuation, arg1);
893 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
898 /* Continue program at specified address. */
901 jump_command (char *arg, int from_tty)
904 struct symtabs_and_lines sals;
905 struct symtab_and_line sal;
912 /* Find out whether we must run in the background. */
914 async_exec = strip_bg_char (&arg);
916 /* If we must run in the background, but the target can't do it,
918 if (async_exec && !target_can_async_p ())
919 error (_("Asynchronous execution not supported on this target."));
921 /* If we are not asked to run in the bg, then prepare to run in the
922 foreground, synchronously. */
923 if (!async_exec && target_can_async_p ())
925 /* Simulate synchronous execution */
926 async_disable_stdin ();
930 error_no_arg (_("starting address"));
932 sals = decode_line_spec_1 (arg, 1);
935 error (_("Unreasonable jump request"));
941 if (sal.symtab == 0 && sal.pc == 0)
942 error (_("No source file has been specified."));
944 resolve_sal_pc (&sal); /* May error out */
946 /* See if we are trying to jump to another function. */
947 fn = get_frame_function (get_current_frame ());
948 sfn = find_pc_function (sal.pc);
949 if (fn != NULL && sfn != fn)
951 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
952 SYMBOL_PRINT_NAME (fn)))
954 error (_("Not confirmed."));
961 fixup_symbol_section (sfn, 0);
962 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
963 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
965 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
967 error (_("Not confirmed."));
977 printf_filtered (_("Continuing at "));
978 deprecated_print_address_numeric (addr, 1, gdb_stdout);
979 printf_filtered (".\n");
982 clear_proceed_status ();
983 proceed (addr, TARGET_SIGNAL_0, 0);
987 /* Go to line or address in current procedure */
989 go_command (char *line_no, int from_tty)
991 if (line_no == (char *) NULL || !*line_no)
992 printf_filtered (GO_USAGE);
995 tbreak_command (line_no, from_tty);
996 jump_command (line_no, from_tty);
1001 /* Continue program giving it specified signal. */
1004 signal_command (char *signum_exp, int from_tty)
1006 enum target_signal oursig;
1008 dont_repeat (); /* Too dangerous. */
1012 error_no_arg (_("signal number"));
1014 /* It would be even slicker to make signal names be valid expressions,
1015 (the type could be "enum $signal" or some such), then the user could
1016 assign them to convenience variables. */
1017 oursig = target_signal_from_name (signum_exp);
1019 if (oursig == TARGET_SIGNAL_UNKNOWN)
1021 /* No, try numeric. */
1022 int num = parse_and_eval_long (signum_exp);
1025 oursig = TARGET_SIGNAL_0;
1027 oursig = target_signal_from_command (num);
1032 if (oursig == TARGET_SIGNAL_0)
1033 printf_filtered (_("Continuing with no signal.\n"));
1035 printf_filtered (_("Continuing with signal %s.\n"),
1036 target_signal_to_name (oursig));
1039 clear_proceed_status ();
1040 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
1041 FIXME: Neither should "signal foo" but when I tried passing
1042 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
1043 tried to track down yet. */
1044 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
1047 /* Proceed until we reach a different source line with pc greater than
1048 our current one or exit the function. We skip calls in both cases.
1050 Note that eventually this command should probably be changed so
1051 that only source lines are printed out when we hit the breakpoint
1052 we set. This may involve changes to wait_for_inferior and the
1053 proceed status code. */
1056 until_next_command (int from_tty)
1058 struct frame_info *frame;
1060 struct symbol *func;
1061 struct symtab_and_line sal;
1063 clear_proceed_status ();
1065 frame = get_current_frame ();
1067 /* Step until either exited from this function or greater
1068 than the current line (if in symbolic section) or pc (if
1072 func = find_pc_function (pc);
1076 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1078 if (msymbol == NULL)
1079 error (_("Execution is not within a known function."));
1081 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1082 step_range_end = pc;
1086 sal = find_pc_line (pc, 0);
1088 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1089 step_range_end = sal.end;
1092 step_over_calls = STEP_OVER_ALL;
1093 step_frame_id = get_frame_id (frame);
1095 step_multi = 0; /* Only one call to proceed */
1097 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1101 until_command (char *arg, int from_tty)
1105 if (!target_has_execution)
1106 error (_("The program is not running."));
1108 /* Find out whether we must run in the background. */
1110 async_exec = strip_bg_char (&arg);
1112 /* If we must run in the background, but the target can't do it,
1114 if (async_exec && !target_can_async_p ())
1115 error (_("Asynchronous execution not supported on this target."));
1117 /* If we are not asked to run in the bg, then prepare to run in the
1118 foreground, synchronously. */
1119 if (!async_exec && target_can_async_p ())
1121 /* Simulate synchronous execution */
1122 async_disable_stdin ();
1126 until_break_command (arg, from_tty, 0);
1128 until_next_command (from_tty);
1132 advance_command (char *arg, int from_tty)
1136 if (!target_has_execution)
1137 error (_("The program is not running."));
1140 error_no_arg (_("a location"));
1142 /* Find out whether we must run in the background. */
1144 async_exec = strip_bg_char (&arg);
1146 /* If we must run in the background, but the target can't do it,
1148 if (async_exec && !target_can_async_p ())
1149 error (_("Asynchronous execution not supported on this target."));
1151 /* If we are not asked to run in the bg, then prepare to run in the
1152 foreground, synchronously. */
1153 if (!async_exec && target_can_async_p ())
1155 /* Simulate synchronous execution. */
1156 async_disable_stdin ();
1159 until_break_command (arg, from_tty, 1);
1162 /* Print the result of a function at the end of a 'finish' command. */
1165 print_return_value (int struct_return, struct type *value_type)
1167 struct gdbarch *gdbarch = current_gdbarch;
1168 struct cleanup *old_chain;
1169 struct ui_stream *stb;
1170 struct value *value;
1172 CHECK_TYPEDEF (value_type);
1173 gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
1175 /* FIXME: 2003-09-27: When returning from a nested inferior function
1176 call, it's possible (with no help from the architecture vector)
1177 to locate and return/print a "struct return" value. This is just
1178 a more complicated case of what is already being done in in the
1179 inferior function call code. In fact, when inferior function
1180 calls are made async, this will likely be made the norm. */
1182 switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))
1184 case RETURN_VALUE_REGISTER_CONVENTION:
1185 case RETURN_VALUE_ABI_RETURNS_ADDRESS:
1186 case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
1187 value = allocate_value (value_type);
1188 gdbarch_return_value (current_gdbarch, value_type, stop_registers,
1189 value_contents_raw (value), NULL);
1191 case RETURN_VALUE_STRUCT_CONVENTION:
1195 internal_error (__FILE__, __LINE__, _("bad switch"));
1201 stb = ui_out_stream_new (uiout);
1202 old_chain = make_cleanup_ui_out_stream_delete (stb);
1203 ui_out_text (uiout, "Value returned is ");
1204 ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
1205 record_latest_value (value));
1206 ui_out_text (uiout, " = ");
1207 value_print (value, stb->stream, 0, Val_no_prettyprint);
1208 ui_out_field_stream (uiout, "return-value", stb);
1209 ui_out_text (uiout, "\n");
1210 do_cleanups (old_chain);
1214 ui_out_text (uiout, "Value returned has type: ");
1215 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1216 ui_out_text (uiout, ".");
1217 ui_out_text (uiout, " Cannot determine contents\n");
1221 /* Stuff that needs to be done by the finish command after the target
1222 has stopped. In asynchronous mode, we wait for the target to stop
1223 in the call to poll or select in the event loop, so it is
1224 impossible to do all the stuff as part of the finish_command
1225 function itself. The only chance we have to complete this command
1226 is in fetch_inferior_event, which is called by the event loop as
1227 soon as it detects that the target has stopped. This function is
1228 called via the cmd_continuation pointer. */
1231 finish_command_continuation (struct continuation_arg *arg)
1233 struct symbol *function;
1234 struct breakpoint *breakpoint;
1235 struct cleanup *cleanups;
1237 breakpoint = (struct breakpoint *) arg->data.pointer;
1238 function = (struct symbol *) arg->next->data.pointer;
1239 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1241 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1242 && function != NULL)
1244 struct type *value_type;
1248 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1250 internal_error (__FILE__, __LINE__,
1251 _("finish_command: function has no target type"));
1253 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1255 do_exec_cleanups (cleanups);
1259 CHECK_TYPEDEF (value_type);
1260 gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
1261 struct_return = using_struct_return (value_type, gcc_compiled);
1263 print_return_value (struct_return, value_type);
1266 do_exec_cleanups (cleanups);
1269 /* "finish": Set a temporary breakpoint at the place the selected
1270 frame will return to, then continue. */
1273 finish_command (char *arg, int from_tty)
1275 struct symtab_and_line sal;
1276 struct frame_info *frame;
1277 struct symbol *function;
1278 struct breakpoint *breakpoint;
1279 struct cleanup *old_chain;
1280 struct continuation_arg *arg1, *arg2, *arg3;
1284 /* Find out whether we must run in the background. */
1286 async_exec = strip_bg_char (&arg);
1288 /* If we must run in the background, but the target can't do it,
1290 if (async_exec && !target_can_async_p ())
1291 error (_("Asynchronous execution not supported on this target."));
1293 /* If we are not asked to run in the bg, then prepare to run in the
1294 foreground, synchronously. */
1295 if (!async_exec && target_can_async_p ())
1297 /* Simulate synchronous execution. */
1298 async_disable_stdin ();
1302 error (_("The \"finish\" command does not take any arguments."));
1303 if (!target_has_execution)
1304 error (_("The program is not running."));
1306 frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
1308 error (_("\"finish\" not meaningful in the outermost frame."));
1310 clear_proceed_status ();
1312 sal = find_pc_line (get_frame_pc (frame), 0);
1313 sal.pc = get_frame_pc (frame);
1315 breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish);
1317 if (!target_can_async_p ())
1318 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1320 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1322 /* Find the function we will return from. */
1324 function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
1326 /* Print info on the selected frame, including level number but not
1330 printf_filtered (_("Run till exit from "));
1331 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1334 /* If running asynchronously and the target support asynchronous
1335 execution, set things up for the rest of the finish command to be
1336 completed later on, when gdb has detected that the target has
1337 stopped, in fetch_inferior_event. */
1338 if (target_can_async_p ())
1341 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1343 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1345 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1349 arg1->data.pointer = breakpoint;
1350 arg2->data.pointer = function;
1351 arg3->data.pointer = old_chain;
1352 add_continuation (finish_command_continuation, arg1);
1355 proceed_to_finish = 1; /* We want stop_registers, please... */
1356 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1358 /* Do this only if not running asynchronously or if the target
1359 cannot do async execution. Otherwise, complete this command when
1360 the target actually stops, in fetch_inferior_event. */
1361 if (!target_can_async_p ())
1363 /* Did we stop at our breakpoint? */
1364 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1365 && function != NULL)
1367 struct type *value_type;
1371 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1373 internal_error (__FILE__, __LINE__,
1374 _("finish_command: function has no target type"));
1376 /* FIXME: Shouldn't we do the cleanups before returning? */
1377 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1380 CHECK_TYPEDEF (value_type);
1381 gcc_compiled = BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function));
1382 struct_return = using_struct_return (value_type, gcc_compiled);
1384 print_return_value (struct_return, value_type);
1387 do_cleanups (old_chain);
1393 program_info (char *args, int from_tty)
1395 bpstat bs = stop_bpstat;
1397 int stat = bpstat_num (&bs, &num);
1399 if (!target_has_execution)
1401 printf_filtered (_("The program being debugged is not being run.\n"));
1405 target_files_info ();
1406 printf_filtered (_("Program stopped at %s.\n"),
1407 hex_string ((unsigned long) stop_pc));
1409 printf_filtered (_("It stopped after being stepped.\n"));
1412 /* There may be several breakpoints in the same place, so this
1413 isn't as strange as it seems. */
1418 printf_filtered (_("\
1419 It stopped at a breakpoint that has since been deleted.\n"));
1422 printf_filtered (_("It stopped at breakpoint %d.\n"), num);
1423 stat = bpstat_num (&bs, &num);
1426 else if (stop_signal != TARGET_SIGNAL_0)
1428 printf_filtered (_("It stopped with signal %s, %s.\n"),
1429 target_signal_to_name (stop_signal),
1430 target_signal_to_string (stop_signal));
1435 printf_filtered (_("\
1436 Type \"info stack\" or \"info registers\" for more information.\n"));
1441 environment_info (char *var, int from_tty)
1445 char *val = get_in_environ (inferior_environ, var);
1448 puts_filtered (var);
1449 puts_filtered (" = ");
1450 puts_filtered (val);
1451 puts_filtered ("\n");
1455 puts_filtered ("Environment variable \"");
1456 puts_filtered (var);
1457 puts_filtered ("\" not defined.\n");
1462 char **vector = environ_vector (inferior_environ);
1465 puts_filtered (*vector++);
1466 puts_filtered ("\n");
1472 set_environment_command (char *arg, int from_tty)
1474 char *p, *val, *var;
1478 error_no_arg (_("environment variable and value"));
1480 /* Find seperation between variable name and value */
1481 p = (char *) strchr (arg, '=');
1482 val = (char *) strchr (arg, ' ');
1484 if (p != 0 && val != 0)
1486 /* We have both a space and an equals. If the space is before the
1487 equals, walk forward over the spaces til we see a nonspace
1488 (possibly the equals). */
1493 /* Now if the = is after the char following the spaces,
1494 take the char following the spaces. */
1498 else if (val != 0 && p == 0)
1502 error_no_arg (_("environment variable to set"));
1504 if (p == 0 || p[1] == 0)
1508 p = arg + strlen (arg); /* So that savestring below will work */
1512 /* Not setting variable value to null */
1514 while (*val == ' ' || *val == '\t')
1518 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1521 var = savestring (arg, p - arg);
1524 printf_filtered (_("\
1525 Setting environment variable \"%s\" to null value.\n"),
1527 set_in_environ (inferior_environ, var, "");
1530 set_in_environ (inferior_environ, var, val);
1535 unset_environment_command (char *var, int from_tty)
1539 /* If there is no argument, delete all environment variables.
1540 Ask for confirmation if reading from the terminal. */
1541 if (!from_tty || query (_("Delete all environment variables? ")))
1543 free_environ (inferior_environ);
1544 inferior_environ = make_environ ();
1548 unset_in_environ (inferior_environ, var);
1551 /* Handle the execution path (PATH variable) */
1553 static const char path_var_name[] = "PATH";
1556 path_info (char *args, int from_tty)
1558 puts_filtered ("Executable and object file path: ");
1559 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1560 puts_filtered ("\n");
1563 /* Add zero or more directories to the front of the execution path. */
1566 path_command (char *dirname, int from_tty)
1571 env = get_in_environ (inferior_environ, path_var_name);
1572 /* Can be null if path is not set */
1575 exec_path = xstrdup (env);
1576 mod_path (dirname, &exec_path);
1577 set_in_environ (inferior_environ, path_var_name, exec_path);
1580 path_info ((char *) NULL, from_tty);
1584 /* Print out the machine register regnum. If regnum is -1, print all
1585 registers (print_all == 1) or all non-float and non-vector
1586 registers (print_all == 0).
1588 For most machines, having all_registers_info() print the
1589 register(s) one per line is good enough. If a different format is
1590 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1591 regs), or there is an existing convention for showing all the
1592 registers, define the architecture method PRINT_REGISTERS_INFO to
1593 provide that format. */
1596 default_print_registers_info (struct gdbarch *gdbarch,
1597 struct ui_file *file,
1598 struct frame_info *frame,
1599 int regnum, int print_all)
1602 const int numregs = gdbarch_num_regs (current_gdbarch)
1603 + gdbarch_num_pseudo_regs (current_gdbarch);
1604 gdb_byte buffer[MAX_REGISTER_SIZE];
1606 for (i = 0; i < numregs; i++)
1608 /* Decide between printing all regs, non-float / vector regs, or
1614 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1619 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1629 /* If the register name is empty, it is undefined for this
1630 processor, so don't display anything. */
1631 if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1634 fputs_filtered (REGISTER_NAME (i), file);
1635 print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
1637 /* Get the data in raw format. */
1638 if (! frame_register_read (frame, i, buffer))
1640 fprintf_filtered (file, "*value not available*\n");
1644 /* If virtual format is floating, print it that way, and in raw
1646 if (TYPE_CODE (register_type (current_gdbarch, i)) == TYPE_CODE_FLT)
1650 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1651 file, 0, 1, 0, Val_pretty_default);
1653 fprintf_filtered (file, "\t(raw 0x");
1654 for (j = 0; j < register_size (current_gdbarch, i); j++)
1657 if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
1660 idx = register_size (current_gdbarch, i) - 1 - j;
1661 fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
1663 fprintf_filtered (file, ")");
1667 /* Print the register in hex. */
1668 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1669 file, 'x', 1, 0, Val_pretty_default);
1670 /* If not a vector register, print it also according to its
1672 if (TYPE_VECTOR (register_type (current_gdbarch, i)) == 0)
1674 fprintf_filtered (file, "\t");
1675 val_print (register_type (current_gdbarch, i), buffer, 0, 0,
1676 file, 0, 1, 0, Val_pretty_default);
1680 fprintf_filtered (file, "\n");
1685 registers_info (char *addr_exp, int fpregs)
1687 struct frame_info *frame;
1688 int regnum, numregs;
1691 if (!target_has_registers)
1692 error (_("The program has no registers now."));
1693 frame = get_selected_frame (NULL);
1697 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1702 while (*addr_exp != '\0')
1707 /* Keep skipping leading white space. */
1708 if (isspace ((*addr_exp)))
1714 /* Discard any leading ``$''. Check that there is something
1715 resembling a register following it. */
1716 if (addr_exp[0] == '$')
1718 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1719 error (_("Missing register name"));
1721 /* Find the start/end of this register name/num/group. */
1723 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1727 /* Figure out what we've found and display it. */
1729 /* A register name? */
1731 int regnum = frame_map_name_to_regnum (frame,
1732 start, end - start);
1735 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1736 frame, regnum, fpregs);
1741 /* A register number? (how portable is this one?). */
1744 int regnum = strtol (start, &endptr, 0);
1747 && regnum < gdbarch_num_regs (current_gdbarch)
1748 + gdbarch_num_pseudo_regs (current_gdbarch))
1750 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1751 frame, regnum, fpregs);
1756 /* A register group? */
1758 struct reggroup *group;
1759 for (group = reggroup_next (current_gdbarch, NULL);
1761 group = reggroup_next (current_gdbarch, group))
1763 /* Don't bother with a length check. Should the user
1764 enter a short register group name, go with the first
1765 group that matches. */
1766 if (strncmp (start, reggroup_name (group), end - start) == 0)
1773 regnum < gdbarch_num_regs (current_gdbarch)
1774 + gdbarch_num_pseudo_regs (current_gdbarch);
1777 if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
1779 gdbarch_print_registers_info (current_gdbarch,
1787 /* Nothing matched. */
1788 error (_("Invalid register `%.*s'"), (int) (end - start), start);
1793 all_registers_info (char *addr_exp, int from_tty)
1795 registers_info (addr_exp, 1);
1799 nofp_registers_info (char *addr_exp, int from_tty)
1801 registers_info (addr_exp, 0);
1805 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
1806 struct frame_info *frame, const char *args)
1808 if (gdbarch_print_vector_info_p (gdbarch))
1809 gdbarch_print_vector_info (gdbarch, file, frame, args);
1813 int printed_something = 0;
1816 regnum < gdbarch_num_regs (current_gdbarch)
1817 + gdbarch_num_pseudo_regs (current_gdbarch);
1820 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
1822 printed_something = 1;
1823 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1826 if (!printed_something)
1827 fprintf_filtered (file, "No vector information\n");
1832 vector_info (char *args, int from_tty)
1834 if (!target_has_registers)
1835 error (_("The program has no registers now."));
1837 print_vector_info (current_gdbarch, gdb_stdout,
1838 get_selected_frame (NULL), args);
1844 * Should save/restore the tty state since it might be that the
1845 * program to be debugged was started on this tty and it wants
1846 * the tty in some state other than what we want. If it's running
1847 * on another terminal or without a terminal, then saving and
1848 * restoring the tty state is a harmless no-op.
1849 * This only needs to be done if we are attaching to a process.
1854 takes a program started up outside of gdb and ``attaches'' to it.
1855 This stops it cold in its tracks and allows us to start debugging it.
1856 and wait for the trace-trap that results from attaching. */
1859 attach_command (char *args, int from_tty)
1862 char *full_exec_path = NULL;
1864 dont_repeat (); /* Not for the faint of heart */
1866 if (target_has_execution)
1868 if (query ("A program is being debugged already. Kill it? "))
1871 error (_("Not killed."));
1874 /* Clean up any leftovers from other runs. Some other things from
1875 this function should probably be moved into target_pre_inferior. */
1876 target_pre_inferior (from_tty);
1878 /* Clear out solib state. Otherwise the solib state of the previous
1879 inferior might have survived and is entirely wrong for the new
1880 target. This has been observed on GNU/Linux using glibc 2.3. How
1892 Cannot access memory at address 0xdeadbeef
1900 target_attach (args, from_tty);
1902 /* Set up the "saved terminal modes" of the inferior
1903 based on what modes we are starting it with. */
1904 target_terminal_init ();
1906 /* Set up execution context to know that we should return from
1907 wait_for_inferior as soon as the target reports a stop. */
1908 init_wait_for_inferior ();
1909 clear_proceed_status ();
1911 /* No traps are generated when attaching to inferior under Mach 3
1913 #ifndef ATTACH_NO_WAIT
1914 /* Careful here. See comments in inferior.h. Basically some OSes
1915 don't ignore SIGSTOPs on continue requests anymore. We need a
1916 way for handle_inferior_event to reset the stop_signal variable
1917 after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */
1918 stop_soon = STOP_QUIETLY_NO_SIGSTOP;
1919 wait_for_inferior ();
1920 stop_soon = NO_STOP_QUIETLY;
1924 * If no exec file is yet known, try to determine it from the
1927 exec_file = (char *) get_exec_file (0);
1930 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
1933 /* It's possible we don't have a full path, but rather just a
1934 filename. Some targets, such as HP-UX, don't provide the
1937 Attempt to qualify the filename against the source path.
1938 (If that fails, we'll just fall back on the original
1939 filename. Not much more we can do...)
1941 if (!source_full_path_of (exec_file, &full_exec_path))
1942 full_exec_path = savestring (exec_file, strlen (exec_file));
1944 exec_file_attach (full_exec_path, from_tty);
1945 symbol_file_add_main (full_exec_path, from_tty);
1950 reopen_exec_file ();
1954 /* Take any necessary post-attaching actions for this platform.
1956 target_post_attach (PIDGET (inferior_ptid));
1958 post_create_inferior (¤t_target, from_tty);
1960 /* Install inferior's terminal modes. */
1961 target_terminal_inferior ();
1965 if (deprecated_attach_hook)
1966 deprecated_attach_hook ();
1971 * takes a program previously attached to and detaches it.
1972 * The program resumes execution and will no longer stop
1973 * on signals, etc. We better not have left any breakpoints
1974 * in the program or it'll die when it hits one. For this
1975 * to work, it may be necessary for the process to have been
1976 * previously attached. It *might* work if the program was
1977 * started via the normal ptrace (PTRACE_TRACEME).
1981 detach_command (char *args, int from_tty)
1983 dont_repeat (); /* Not for the faint of heart. */
1984 target_detach (args, from_tty);
1985 #if defined(SOLIB_RESTART)
1988 if (deprecated_detach_hook)
1989 deprecated_detach_hook ();
1992 /* Disconnect from the current target without resuming it (leaving it
1993 waiting for a debugger).
1995 We'd better not have left any breakpoints in the program or the
1996 next debugger will get confused. Currently only supported for some
1997 remote targets, since the normal attach mechanisms don't work on
1998 stopped processes on some native platforms (e.g. GNU/Linux). */
2001 disconnect_command (char *args, int from_tty)
2003 dont_repeat (); /* Not for the faint of heart */
2004 target_disconnect (args, from_tty);
2005 #if defined(SOLIB_RESTART)
2008 if (deprecated_detach_hook)
2009 deprecated_detach_hook ();
2012 /* Stop the execution of the target while running in async mode, in
2015 interrupt_target_command (char *args, int from_tty)
2017 if (target_can_async_p ())
2019 dont_repeat (); /* Not for the faint of heart */
2025 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
2026 struct frame_info *frame, const char *args)
2028 if (gdbarch_print_float_info_p (gdbarch))
2029 gdbarch_print_float_info (gdbarch, file, frame, args);
2033 int printed_something = 0;
2036 regnum < gdbarch_num_regs (current_gdbarch)
2037 + gdbarch_num_pseudo_regs (current_gdbarch);
2040 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
2042 printed_something = 1;
2043 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2046 if (!printed_something)
2047 fprintf_filtered (file, "\
2048 No floating-point info available for this processor.\n");
2053 float_info (char *args, int from_tty)
2055 if (!target_has_registers)
2056 error (_("The program has no registers now."));
2058 print_float_info (current_gdbarch, gdb_stdout,
2059 get_selected_frame (NULL), args);
2063 unset_command (char *args, int from_tty)
2065 printf_filtered (_("\
2066 \"unset\" must be followed by the name of an unset subcommand.\n"));
2067 help_list (unsetlist, "unset ", -1, gdb_stdout);
2071 _initialize_infcmd (void)
2073 struct cmd_list_element *c = NULL;
2075 /* add the filename of the terminal connected to inferior I/O */
2076 add_setshow_filename_cmd ("inferior-tty", class_run,
2077 &inferior_io_terminal, _("\
2078 Set terminal for future runs of program being debugged."), _("\
2079 Show terminal for future runs of program being debugged."), _("\
2080 Usage: set inferior-tty /dev/pts/1"), NULL, NULL, &setlist, &showlist);
2081 add_com_alias ("tty", "set inferior-tty", class_alias, 0);
2083 add_setshow_optional_filename_cmd ("args", class_run,
2084 &inferior_args, _("\
2085 Set argument list to give program being debugged when it is started."), _("\
2086 Show argument list to give program being debugged when it is started."), _("\
2087 Follow this command with any number of args, to be passed to the program."),
2090 &setlist, &showlist);
2092 c = add_cmd ("environment", no_class, environment_info, _("\
2093 The environment to give the program, or one variable's value.\n\
2094 With an argument VAR, prints the value of environment variable VAR to\n\
2095 give the program being debugged. With no arguments, prints the entire\n\
2096 environment to be given to the program."), &showlist);
2097 set_cmd_completer (c, noop_completer);
2099 add_prefix_cmd ("unset", no_class, unset_command,
2100 _("Complement to certain \"set\" commands."),
2101 &unsetlist, "unset ", 0, &cmdlist);
2103 c = add_cmd ("environment", class_run, unset_environment_command, _("\
2104 Cancel environment variable VAR for the program.\n\
2105 This does not affect the program until the next \"run\" command."),
2107 set_cmd_completer (c, noop_completer);
2109 c = add_cmd ("environment", class_run, set_environment_command, _("\
2110 Set environment variable value to give the program.\n\
2111 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2112 VALUES of environment variables are uninterpreted strings.\n\
2113 This does not affect the program until the next \"run\" command."),
2115 set_cmd_completer (c, noop_completer);
2117 c = add_com ("path", class_files, path_command, _("\
2118 Add directory DIR(s) to beginning of search path for object files.\n\
2119 $cwd in the path means the current working directory.\n\
2120 This path is equivalent to the $PATH shell variable. It is a list of\n\
2121 directories, separated by colons. These directories are searched to find\n\
2122 fully linked executable files and separately compiled object files as needed."));
2123 set_cmd_completer (c, filename_completer);
2125 c = add_cmd ("paths", no_class, path_info, _("\
2126 Current search path for finding object files.\n\
2127 $cwd in the path means the current working directory.\n\
2128 This path is equivalent to the $PATH shell variable. It is a list of\n\
2129 directories, separated by colons. These directories are searched to find\n\
2130 fully linked executable files and separately compiled object files as needed."),
2132 set_cmd_completer (c, noop_completer);
2134 add_com ("attach", class_run, attach_command, _("\
2135 Attach to a process or file outside of GDB.\n\
2136 This command attaches to another target, of the same type as your last\n\
2137 \"target\" command (\"info files\" will show your target stack).\n\
2138 The command may take as argument a process id or a device file.\n\
2139 For a process id, you must have permission to send the process a signal,\n\
2140 and it must have the same effective uid as the debugger.\n\
2141 When using \"attach\" with a process id, the debugger finds the\n\
2142 program running in the process, looking first in the current working\n\
2143 directory, or (if not found there) using the source file search path\n\
2144 (see the \"directory\" command). You can also use the \"file\" command\n\
2145 to specify the program, and to load its symbol table."));
2147 add_prefix_cmd ("detach", class_run, detach_command, _("\
2148 Detach a process or file previously attached.\n\
2149 If a process, it is no longer traced, and it continues its execution. If\n\
2150 you were debugging a file, the file is closed and gdb no longer accesses it."),
2151 &detachlist, "detach ", 0, &cmdlist);
2153 add_com ("disconnect", class_run, disconnect_command, _("\
2154 Disconnect from a target.\n\
2155 The target will wait for another debugger to connect. Not available for\n\
2158 add_com ("signal", class_run, signal_command, _("\
2159 Continue program giving it signal specified by the argument.\n\
2160 An argument of \"0\" means continue program without giving it a signal."));
2162 add_com ("stepi", class_run, stepi_command, _("\
2163 Step one instruction exactly.\n\
2164 Argument N means do this N times (or till program stops for another reason)."));
2165 add_com_alias ("si", "stepi", class_alias, 0);
2167 add_com ("nexti", class_run, nexti_command, _("\
2168 Step one instruction, but proceed through subroutine calls.\n\
2169 Argument N means do this N times (or till program stops for another reason)."));
2170 add_com_alias ("ni", "nexti", class_alias, 0);
2172 add_com ("finish", class_run, finish_command, _("\
2173 Execute until selected stack frame returns.\n\
2174 Upon return, the value returned is printed and put in the value history."));
2176 add_com ("next", class_run, next_command, _("\
2177 Step program, proceeding through subroutine calls.\n\
2178 Like the \"step\" command as long as subroutine calls do not happen;\n\
2179 when they do, the call is treated as one instruction.\n\
2180 Argument N means do this N times (or till program stops for another reason)."));
2181 add_com_alias ("n", "next", class_run, 1);
2183 add_com_alias ("S", "next", class_run, 1);
2185 add_com ("step", class_run, step_command, _("\
2186 Step program until it reaches a different source line.\n\
2187 Argument N means do this N times (or till program stops for another reason)."));
2188 add_com_alias ("s", "step", class_run, 1);
2190 c = add_com ("until", class_run, until_command, _("\
2191 Execute until the program reaches a source line greater than the current\n\
2192 or a specified location (same args as break command) within the current frame."));
2193 set_cmd_completer (c, location_completer);
2194 add_com_alias ("u", "until", class_run, 1);
2196 c = add_com ("advance", class_run, advance_command, _("\
2197 Continue the program up to the given location (same form as args for break command).\n\
2198 Execution will also stop upon exit from the current stack frame."));
2199 set_cmd_completer (c, location_completer);
2201 c = add_com ("jump", class_run, jump_command, _("\
2202 Continue program being debugged at specified line or address.\n\
2203 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2204 for an address to start at."));
2205 set_cmd_completer (c, location_completer);
2209 c = add_com ("go", class_run, go_command, _("\
2210 Usage: go <location>\n\
2211 Continue program being debugged, stopping at specified line or \n\
2213 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2214 expression for an address to start at.\n\
2215 This command is a combination of tbreak and jump."));
2216 set_cmd_completer (c, location_completer);
2220 add_com_alias ("g", "go", class_run, 1);
2222 add_com ("continue", class_run, continue_command, _("\
2223 Continue program being debugged, after signal or breakpoint.\n\
2224 If proceeding from breakpoint, a number N may be used as an argument,\n\
2225 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2226 the breakpoint won't break until the Nth time it is reached)."));
2227 add_com_alias ("c", "cont", class_run, 1);
2228 add_com_alias ("fg", "cont", class_run, 1);
2230 c = add_com ("run", class_run, run_command, _("\
2231 Start debugged program. You may specify arguments to give it.\n\
2232 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2233 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2234 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2235 To cancel previous arguments and run with no arguments,\n\
2236 use \"set args\" without arguments."));
2237 set_cmd_completer (c, filename_completer);
2238 add_com_alias ("r", "run", class_run, 1);
2240 add_com ("R", class_run, run_no_args_command,
2241 _("Start debugged program with no arguments."));
2243 c = add_com ("start", class_run, start_command, _("\
2244 Run the debugged program until the beginning of the main procedure.\n\
2245 You may specify arguments to give to your program, just as with the\n\
2246 \"run\" command."));
2247 set_cmd_completer (c, filename_completer);
2249 add_com ("interrupt", class_run, interrupt_target_command,
2250 _("Interrupt the execution of the debugged program."));
2252 add_info ("registers", nofp_registers_info, _("\
2253 List of integer registers and their contents, for selected stack frame.\n\
2254 Register name as argument means describe only that register."));
2255 add_info_alias ("r", "registers", 1);
2258 add_com ("lr", class_info, nofp_registers_info, _("\
2259 List of integer registers and their contents, for selected stack frame.\n\
2260 Register name as argument means describe only that register."));
2261 add_info ("all-registers", all_registers_info, _("\
2262 List of all registers and their contents, for selected stack frame.\n\
2263 Register name as argument means describe only that register."));
2265 add_info ("program", program_info,
2266 _("Execution status of the program."));
2268 add_info ("float", float_info,
2269 _("Print the status of the floating point unit\n"));
2271 add_info ("vector", vector_info,
2272 _("Print the status of the vector unit\n"));
2274 inferior_environ = make_environ ();
2275 init_environ (inferior_environ);