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 2008, 2009, 2010, 2011 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 3 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, see <http://www.gnu.org/licenses/>. */
23 #include "arch-utils.h"
25 #include "gdb_string.h"
39 #include "completer.h"
41 #include "event-top.h"
42 #include "parser-defs.h"
44 #include "reggroups.h"
48 #include "gdb_assert.h"
50 #include "target-descriptions.h"
51 #include "user-regs.h"
52 #include "exceptions.h"
53 #include "cli/cli-decode.h"
54 #include "gdbthread.h"
56 #include "inline-frame.h"
57 #include "tracepoint.h"
59 /* Functions exported for general use, in inferior.h: */
61 void all_registers_info (char *, int);
63 void registers_info (char *, int);
65 void nexti_command (char *, int);
67 void stepi_command (char *, int);
69 void continue_command (char *, int);
71 void interrupt_target_command (char *args, int from_tty);
73 /* Local functions: */
75 static void nofp_registers_info (char *, int);
77 static void print_return_value (struct type *func_type,
78 struct type *value_type);
80 static void until_next_command (int);
82 static void until_command (char *, int);
84 static void path_info (char *, int);
86 static void path_command (char *, int);
88 static void unset_command (char *, int);
90 static void float_info (char *, int);
92 static void disconnect_command (char *, int);
94 static void unset_environment_command (char *, int);
96 static void set_environment_command (char *, int);
98 static void environment_info (char *, int);
100 static void program_info (char *, int);
102 static void finish_command (char *, int);
104 static void signal_command (char *, int);
106 static void jump_command (char *, int);
108 static void step_1 (int, int, char *);
109 static void step_once (int skip_subroutines, int single_inst,
110 int count, int thread);
112 static void next_command (char *, int);
114 static void step_command (char *, int);
116 static void run_command (char *, int);
118 static void run_no_args_command (char *args, int from_tty);
120 static void go_command (char *line_no, int from_tty);
122 static int strip_bg_char (char **);
124 void _initialize_infcmd (void);
126 #define ERROR_NO_INFERIOR \
127 if (!target_has_execution) error (_("The program is not being run."));
129 /* Scratch area where string containing arguments to give to the
130 program will be stored by 'set args'. As soon as anything is
131 stored, notice_args_set will move it into per-inferior storage.
132 Arguments are separated by spaces. Empty string (pointer to '\0')
135 static char *inferior_args_scratch;
137 /* Scratch area where 'set inferior-tty' will store user-provided value.
138 We'll immediate copy it into per-inferior storage. */
140 static char *inferior_io_terminal_scratch;
142 /* Pid of our debugged inferior, or 0 if no inferior now.
143 Since various parts of infrun.c test this to see whether there is a program
144 being debugged it should be nonzero (currently 3 is used) for remote
147 ptid_t inferior_ptid;
149 /* Address at which inferior stopped. */
153 /* Flag indicating that a command has proceeded the inferior past the
154 current breakpoint. */
156 int breakpoint_proceeded;
158 /* Nonzero if stopped due to completion of a stack dummy routine. */
160 enum stop_stack_kind stop_stack_dummy;
162 /* Nonzero if stopped due to a random (unexpected) signal in inferior
165 int stopped_by_random_signal;
168 /* Accessor routines. */
170 /* Set the io terminal for the current inferior. Ownership of
171 TERMINAL_NAME is not transferred. */
174 set_inferior_io_terminal (const char *terminal_name)
176 xfree (current_inferior ()->terminal);
177 current_inferior ()->terminal = terminal_name ? xstrdup (terminal_name) : 0;
181 get_inferior_io_terminal (void)
183 return current_inferior ()->terminal;
187 set_inferior_tty_command (char *args, int from_tty,
188 struct cmd_list_element *c)
190 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
191 Now route it to current inferior. */
192 set_inferior_io_terminal (inferior_io_terminal_scratch);
196 show_inferior_tty_command (struct ui_file *file, int from_tty,
197 struct cmd_list_element *c, const char *value)
199 /* Note that we ignore the passed-in value in favor of computing it
201 const char *inferior_io_terminal = get_inferior_io_terminal ();
203 if (inferior_io_terminal == NULL)
204 inferior_io_terminal = "";
205 fprintf_filtered (gdb_stdout,
206 _("Terminal for future runs of program being debugged "
207 "is \"%s\".\n"), inferior_io_terminal);
211 get_inferior_args (void)
213 if (current_inferior ()->argc != 0)
217 n = construct_inferior_arguments (current_inferior ()->argc,
218 current_inferior ()->argv);
219 set_inferior_args (n);
223 if (current_inferior ()->args == NULL)
224 current_inferior ()->args = xstrdup ("");
226 return current_inferior ()->args;
229 /* Set the arguments for the current inferior. Ownership of
230 NEWARGS is not transferred. */
233 set_inferior_args (char *newargs)
235 xfree (current_inferior ()->args);
236 current_inferior ()->args = newargs ? xstrdup (newargs) : NULL;
237 current_inferior ()->argc = 0;
238 current_inferior ()->argv = 0;
242 set_inferior_args_vector (int argc, char **argv)
244 current_inferior ()->argc = argc;
245 current_inferior ()->argv = argv;
248 /* Notice when `set args' is run. */
250 set_args_command (char *args, int from_tty, struct cmd_list_element *c)
252 /* CLI has assigned the user-provided value to inferior_args_scratch.
253 Now route it to current inferior. */
254 set_inferior_args (inferior_args_scratch);
257 /* Notice when `show args' is run. */
259 show_args_command (struct ui_file *file, int from_tty,
260 struct cmd_list_element *c, const char *value)
262 /* Note that we ignore the passed-in value in favor of computing it
264 deprecated_show_value_hack (file, from_tty, c, get_inferior_args ());
268 /* Compute command-line string given argument vector. This does the
269 same shell processing as fork_inferior. */
271 construct_inferior_arguments (int argc, char **argv)
275 if (STARTUP_WITH_SHELL)
277 /* This holds all the characters considered special to the
278 typical Unix shells. We include `^' because the SunOS
279 /bin/sh treats it as a synonym for `|'. */
280 char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
285 /* We over-compute the size. It shouldn't matter. */
286 for (i = 0; i < argc; ++i)
287 length += 3 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
289 result = (char *) xmalloc (length);
292 for (i = 0; i < argc; ++i)
297 /* Need to handle empty arguments specially. */
298 if (argv[i][0] == '\0')
305 for (cp = argv[i]; *cp; ++cp)
309 /* A newline cannot be quoted with a backslash (it
310 just disappears), only by putting it inside
318 if (strchr (special, *cp) != NULL)
329 /* In this case we can't handle arguments that contain spaces,
330 tabs, or newlines -- see breakup_args(). */
334 for (i = 0; i < argc; ++i)
336 char *cp = strchr (argv[i], ' ');
338 cp = strchr (argv[i], '\t');
340 cp = strchr (argv[i], '\n');
342 error (_("can't handle command-line "
343 "argument containing whitespace"));
344 length += strlen (argv[i]) + 1;
347 result = (char *) xmalloc (length);
349 for (i = 0; i < argc; ++i)
352 strcat (result, " ");
353 strcat (result, argv[i]);
361 /* This function detects whether or not a '&' character (indicating
362 background execution) has been added as *the last* of the arguments ARGS
363 of a command. If it has, it removes it and returns 1. Otherwise it
364 does nothing and returns 0. */
366 strip_bg_char (char **args)
370 p = strchr (*args, '&');
374 if (p == (*args + strlen (*args) - 1))
376 if (strlen (*args) > 1)
380 while (*p == ' ' || *p == '\t');
391 /* Common actions to take after creating any sort of inferior, by any
392 means (running, attaching, connecting, et cetera). The target
393 should be stopped. */
396 post_create_inferior (struct target_ops *target, int from_tty)
398 volatile struct gdb_exception ex;
400 /* Be sure we own the terminal in case write operations are performed. */
401 target_terminal_ours ();
403 /* If the target hasn't taken care of this already, do it now.
404 Targets which need to access registers during to_open,
405 to_create_inferior, or to_attach should do it earlier; but many
407 target_find_description ();
409 /* Now that we know the register layout, retrieve current PC. But
410 if the PC is unavailable (e.g., we're opening a core file with
411 missing registers info), ignore it. */
413 TRY_CATCH (ex, RETURN_MASK_ERROR)
415 stop_pc = regcache_read_pc (get_current_regcache ());
417 if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
418 throw_exception (ex);
422 /* Create the hooks to handle shared library load and unload
424 #ifdef SOLIB_CREATE_INFERIOR_HOOK
425 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
427 solib_create_inferior_hook (from_tty);
431 /* If the solist is global across processes, there's no need to
433 if (exec_bfd && !gdbarch_has_global_solist (target_gdbarch))
435 /* Sometimes the platform-specific hook loads initial shared
436 libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be
437 incorrectly 0 but such solib targets should be fixed anyway. If we
438 made all the inferior hook methods consistent, this call could be
439 removed. Call it only after the solib target has been initialized by
440 solib_create_inferior_hook. */
443 SOLIB_ADD (NULL, 0, target, auto_solib_add);
445 solib_add (NULL, 0, target, auto_solib_add);
449 /* If the user sets watchpoints before execution having started,
450 then she gets software watchpoints, because GDB can't know which
451 target will end up being pushed, or if it supports hardware
452 watchpoints or not. breakpoint_re_set takes care of promoting
453 watchpoints to hardware watchpoints if possible, however, if this
454 new inferior doesn't load shared libraries or we don't pull in
455 symbols from any other source on this target/arch,
456 breakpoint_re_set is never called. Call it now so that software
457 watchpoints get a chance to be promoted to hardware watchpoints
458 if the now pushed target supports hardware watchpoints. */
459 breakpoint_re_set ();
461 observer_notify_inferior_created (target, from_tty);
464 /* Kill the inferior if already running. This function is designed
465 to be called when we are about to start the execution of the program
466 from the beginning. Ask the user to confirm that he wants to restart
467 the program being debugged when FROM_TTY is non-null. */
470 kill_if_already_running (int from_tty)
472 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
474 /* Bail out before killing the program if we will not be able to
476 target_require_runnable ();
479 && !query (_("The program being debugged has been started already.\n\
480 Start it from the beginning? ")))
481 error (_("Program not restarted."));
486 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
487 a temporary breakpoint at the begining of the main program before
488 running the program. */
491 run_command_1 (char *args, int from_tty, int tbreak_at_main)
494 struct cleanup *old_chain;
499 kill_if_already_running (from_tty);
501 init_wait_for_inferior ();
502 clear_breakpoint_hit_counts ();
504 /* Clean up any leftovers from other runs. Some other things from
505 this function should probably be moved into target_pre_inferior. */
506 target_pre_inferior (from_tty);
508 /* The comment here used to read, "The exec file is re-read every
509 time we do a generic_mourn_inferior, so we just have to worry
510 about the symbol file." The `generic_mourn_inferior' function
511 gets called whenever the program exits. However, suppose the
512 program exits, and *then* the executable file changes? We need
513 to check again here. Since reopen_exec_file doesn't do anything
514 if the timestamp hasn't changed, I don't see the harm. */
518 /* Insert the temporary breakpoint if a location was specified. */
520 tbreak_command (main_name (), 0);
522 exec_file = (char *) get_exec_file (0);
524 if (non_stop && !target_supports_non_stop ())
525 error (_("The target does not support running in non-stop mode."));
527 /* We keep symbols from add-symbol-file, on the grounds that the
528 user might want to add some symbols before running the program
529 (right?). But sometimes (dynamic loading where the user manually
530 introduces the new symbols with add-symbol-file), the code which
531 the symbols describe does not persist between runs. Currently
532 the user has to manually nuke all symbols between runs if they
533 want them to go away (PR 2207). This is probably reasonable. */
537 if (target_can_async_p ())
538 async_disable_stdin ();
542 int async_exec = strip_bg_char (&args);
544 /* If we get a request for running in the bg but the target
545 doesn't support it, error out. */
546 if (async_exec && !target_can_async_p ())
547 error (_("Asynchronous execution not supported on this target."));
549 /* If we don't get a request of running in the bg, then we need
550 to simulate synchronous (fg) execution. */
551 if (!async_exec && target_can_async_p ())
553 /* Simulate synchronous execution. */
554 async_disable_stdin ();
557 /* If there were other args, beside '&', process them. */
559 set_inferior_args (args);
564 ui_out_field_string (uiout, NULL, "Starting program");
565 ui_out_text (uiout, ": ");
567 ui_out_field_string (uiout, "execfile", exec_file);
568 ui_out_spaces (uiout, 1);
569 /* We call get_inferior_args() because we might need to compute
571 ui_out_field_string (uiout, "infargs", get_inferior_args ());
572 ui_out_text (uiout, "\n");
573 ui_out_flush (uiout);
576 /* We call get_inferior_args() because we might need to compute
578 target_create_inferior (exec_file, get_inferior_args (),
579 environ_vector (current_inferior ()->environment),
582 /* We're starting off a new process. When we get out of here, in
583 non-stop mode, finish the state of all threads of that process,
584 but leave other threads alone, as they may be stopped in internal
585 events --- the frontend shouldn't see them as stopped. In
586 all-stop, always finish the state of all threads, as we may be
587 resuming more than just the new process. */
589 ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
591 ptid = minus_one_ptid;
592 old_chain = make_cleanup (finish_thread_state_cleanup, &ptid);
594 /* Pass zero for FROM_TTY, because at this point the "run" command
595 has done its thing; now we are setting up the running program. */
596 post_create_inferior (¤t_target, 0);
598 /* Start the target running. Do not use -1 continuation as it would skip
599 breakpoint right at the entry point. */
600 proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0);
602 /* Since there was no error, there's no need to finish the thread
604 discard_cleanups (old_chain);
608 run_command (char *args, int from_tty)
610 run_command_1 (args, from_tty, 0);
614 run_no_args_command (char *args, int from_tty)
616 set_inferior_args ("");
620 /* Start the execution of the program up until the beginning of the main
624 start_command (char *args, int from_tty)
626 /* Some languages such as Ada need to search inside the program
627 minimal symbols for the location where to put the temporary
628 breakpoint before starting. */
629 if (!have_minimal_symbols ())
630 error (_("No symbol table loaded. Use the \"file\" command."));
632 /* Run the program until reaching the main procedure... */
633 run_command_1 (args, from_tty, 1);
637 proceed_thread_callback (struct thread_info *thread, void *arg)
639 /* We go through all threads individually instead of compressing
640 into a single target `resume_all' request, because some threads
641 may be stopped in internal breakpoints/events, or stopped waiting
642 for its turn in the displaced stepping queue (that is, they are
643 running && !executing). The target side has no idea about why
644 the thread is stopped, so a `resume_all' command would resume too
645 much. If/when GDB gains a way to tell the target `hold this
646 thread stopped until I say otherwise', then we can optimize
648 if (!is_stopped (thread->ptid))
651 switch_to_thread (thread->ptid);
652 clear_proceed_status ();
653 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
658 ensure_valid_thread (void)
660 if (ptid_equal (inferior_ptid, null_ptid)
661 || is_exited (inferior_ptid))
662 error (_("Cannot execute this command without a live selected thread."));
665 /* If the user is looking at trace frames, any resumption of execution
666 is likely to mix up recorded and live target data. So simply
667 disallow those commands. */
670 ensure_not_tfind_mode (void)
672 if (get_traceframe_number () >= 0)
673 error (_("Cannot execute this command while looking at trace frames."));
677 continue_1 (int all_threads)
680 ensure_not_tfind_mode ();
682 if (non_stop && all_threads)
684 /* Don't error out if the current thread is running, because
685 there may be other stopped threads. */
686 struct cleanup *old_chain;
688 /* Backup current thread and selected frame. */
689 old_chain = make_cleanup_restore_current_thread ();
691 iterate_over_threads (proceed_thread_callback, NULL);
693 /* Restore selected ptid. */
694 do_cleanups (old_chain);
698 ensure_valid_thread ();
699 ensure_not_running ();
700 clear_proceed_status ();
701 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
705 /* continue [-a] [proceed-count] [&] */
707 continue_command (char *args, int from_tty)
713 /* Find out whether we must run in the background. */
715 async_exec = strip_bg_char (&args);
717 /* If we must run in the background, but the target can't do it,
719 if (async_exec && !target_can_async_p ())
720 error (_("Asynchronous execution not supported on this target."));
722 /* If we are not asked to run in the bg, then prepare to run in the
723 foreground, synchronously. */
724 if (!async_exec && target_can_async_p ())
726 /* Simulate synchronous execution. */
727 async_disable_stdin ();
732 if (strncmp (args, "-a", sizeof ("-a") - 1) == 0)
735 args += sizeof ("-a") - 1;
741 if (!non_stop && all_threads)
742 error (_("`-a' is meaningless in all-stop mode."));
744 if (args != NULL && all_threads)
745 error (_("Can't resume all threads and specify "
746 "proceed count simultaneously."));
748 /* If we have an argument left, set proceed count of breakpoint we
755 struct thread_info *tp;
758 tp = find_thread_ptid (inferior_ptid);
762 struct target_waitstatus ws;
764 get_last_target_status (&last_ptid, &ws);
765 tp = find_thread_ptid (last_ptid);
768 bs = tp->control.stop_bpstat;
770 while ((stat = bpstat_num (&bs, &num)) != 0)
773 set_ignore_count (num,
774 parse_and_eval_long (args) - 1,
776 /* set_ignore_count prints a message ending with a period.
777 So print two spaces before "Continuing.". */
779 printf_filtered (" ");
783 if (!stopped && from_tty)
786 ("Not stopped at any breakpoint; argument ignored.\n");
791 printf_filtered (_("Continuing.\n"));
793 continue_1 (all_threads);
796 /* Record the starting point of a "step" or "next" command. */
799 set_step_frame (void)
801 struct symtab_and_line sal;
803 find_frame_sal (get_current_frame (), &sal);
804 set_step_info (get_current_frame (), sal);
807 /* Step until outside of current statement. */
810 step_command (char *count_string, int from_tty)
812 step_1 (0, 0, count_string);
815 /* Likewise, but skip over subroutine calls as if single instructions. */
818 next_command (char *count_string, int from_tty)
820 step_1 (1, 0, count_string);
823 /* Likewise, but step only one instruction. */
826 stepi_command (char *count_string, int from_tty)
828 step_1 (0, 1, count_string);
832 nexti_command (char *count_string, int from_tty)
834 step_1 (1, 1, count_string);
838 delete_longjmp_breakpoint_cleanup (void *arg)
840 int thread = * (int *) arg;
841 delete_longjmp_breakpoint (thread);
845 step_1 (int skip_subroutines, int single_inst, char *count_string)
848 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
853 ensure_not_tfind_mode ();
854 ensure_valid_thread ();
855 ensure_not_running ();
858 async_exec = strip_bg_char (&count_string);
860 /* If we get a request for running in the bg but the target
861 doesn't support it, error out. */
862 if (async_exec && !target_can_async_p ())
863 error (_("Asynchronous execution not supported on this target."));
865 /* If we don't get a request of running in the bg, then we need
866 to simulate synchronous (fg) execution. */
867 if (!async_exec && target_can_async_p ())
869 /* Simulate synchronous execution. */
870 async_disable_stdin ();
873 count = count_string ? parse_and_eval_long (count_string) : 1;
875 if (!single_inst || skip_subroutines) /* Leave si command alone. */
877 struct thread_info *tp = inferior_thread ();
879 if (in_thread_list (inferior_ptid))
880 thread = pid_to_thread_id (inferior_ptid);
882 set_longjmp_breakpoint (tp, get_frame_id (get_current_frame ()));
884 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
887 /* In synchronous case, all is well; each step_once call will step once. */
888 if (!target_can_async_p ())
890 for (; count > 0; count--)
892 struct thread_info *tp;
894 step_once (skip_subroutines, single_inst, count, thread);
896 if (target_has_execution
897 && !ptid_equal (inferior_ptid, null_ptid))
898 tp = inferior_thread ();
902 if (!tp || !tp->control.stop_step || !tp->step_multi)
904 /* If we stopped for some reason that is not stepping
905 there are no further steps to make. */
912 do_cleanups (cleanups);
916 /* In the case of an asynchronous target things get complicated;
917 do only one step for now, before returning control to the
918 event loop. Let the continuation figure out how many other
919 steps we need to do, and handle them one at the time, through
921 step_once (skip_subroutines, single_inst, count, thread);
923 /* We are running, and the continuation is installed. It will
924 disable the longjmp breakpoint as appropriate. */
925 discard_cleanups (cleanups);
929 struct step_1_continuation_args
932 int skip_subroutines;
937 /* Called after we are done with one step operation, to check whether
938 we need to step again, before we print the prompt and return control
939 to the user. If count is > 1, we will need to do one more call to
940 proceed(), via step_once(). Basically it is like step_once and
941 step_1_continuation are co-recursive. */
943 step_1_continuation (void *args)
945 struct step_1_continuation_args *a = args;
947 if (target_has_execution)
949 struct thread_info *tp;
951 tp = inferior_thread ();
952 if (tp->step_multi && tp->control.stop_step)
954 /* There are more steps to make, and we did stop due to
955 ending a stepping range. Do another step. */
956 step_once (a->skip_subroutines, a->single_inst,
957 a->count - 1, a->thread);
963 /* We either stopped for some reason that is not stepping, or there
964 are no further steps to make. Cleanup. */
965 if (!a->single_inst || a->skip_subroutines)
966 delete_longjmp_breakpoint (a->thread);
969 /* Do just one step operation. This is useful to implement the 'step
970 n' kind of commands. In case of asynchronous targets, we will have
971 to set up a continuation to be done after the target stops (after
972 this one step). For synch targets, the caller handles further
976 step_once (int skip_subroutines, int single_inst, int count, int thread)
978 struct frame_info *frame = get_current_frame ();
982 /* Don't assume THREAD is a valid thread id. It is set to -1 if
983 the longjmp breakpoint was not required. Use the
984 INFERIOR_PTID thread instead, which is the same thread when
986 struct thread_info *tp = inferior_thread ();
988 clear_proceed_status ();
995 /* Step at an inlined function behaves like "down". */
996 if (!skip_subroutines && !single_inst
997 && inline_skipped_frames (inferior_ptid))
999 step_into_inline_frame (inferior_ptid);
1001 step_once (skip_subroutines, single_inst, count - 1, thread);
1003 /* Pretend that we've stopped. */
1008 pc = get_frame_pc (frame);
1009 find_pc_line_pc_range (pc,
1010 &tp->control.step_range_start,
1011 &tp->control.step_range_end);
1013 /* If we have no line info, switch to stepi mode. */
1014 if (tp->control.step_range_end == 0 && step_stop_if_no_debug)
1015 tp->control.step_range_start = tp->control.step_range_end = 1;
1016 else if (tp->control.step_range_end == 0)
1020 if (find_pc_partial_function (pc, &name,
1021 &tp->control.step_range_start,
1022 &tp->control.step_range_end) == 0)
1023 error (_("Cannot find bounds of current function"));
1025 target_terminal_ours ();
1026 printf_filtered (_("Single stepping until exit from function %s,"
1027 "\nwhich has no line number information.\n"),
1033 /* Say we are stepping, but stop after one insn whatever it does. */
1034 tp->control.step_range_start = tp->control.step_range_end = 1;
1035 if (!skip_subroutines)
1037 Don't step over function calls, not even to functions lacking
1039 tp->control.step_over_calls = STEP_OVER_NONE;
1042 if (skip_subroutines)
1043 tp->control.step_over_calls = STEP_OVER_ALL;
1045 tp->step_multi = (count > 1);
1046 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1048 /* For async targets, register a continuation to do any
1049 additional steps. For sync targets, the caller will handle
1050 further stepping. */
1051 if (target_can_async_p ())
1053 struct step_1_continuation_args *args;
1055 args = xmalloc (sizeof (*args));
1056 args->skip_subroutines = skip_subroutines;
1057 args->single_inst = single_inst;
1058 args->count = count;
1059 args->thread = thread;
1061 add_intermediate_continuation (tp, step_1_continuation, args, xfree);
1067 /* Continue program at specified address. */
1070 jump_command (char *arg, int from_tty)
1072 struct gdbarch *gdbarch = get_current_arch ();
1074 struct symtabs_and_lines sals;
1075 struct symtab_and_line sal;
1081 ensure_not_tfind_mode ();
1082 ensure_valid_thread ();
1083 ensure_not_running ();
1085 /* Find out whether we must run in the background. */
1087 async_exec = strip_bg_char (&arg);
1089 /* If we must run in the background, but the target can't do it,
1091 if (async_exec && !target_can_async_p ())
1092 error (_("Asynchronous execution not supported on this target."));
1095 error_no_arg (_("starting address"));
1097 sals = decode_line_spec_1 (arg, 1);
1098 if (sals.nelts != 1)
1100 error (_("Unreasonable jump request"));
1106 if (sal.symtab == 0 && sal.pc == 0)
1107 error (_("No source file has been specified."));
1109 resolve_sal_pc (&sal); /* May error out. */
1111 /* See if we are trying to jump to another function. */
1112 fn = get_frame_function (get_current_frame ());
1113 sfn = find_pc_function (sal.pc);
1114 if (fn != NULL && sfn != fn)
1116 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line,
1117 SYMBOL_PRINT_NAME (fn)))
1119 error (_("Not confirmed."));
1126 fixup_symbol_section (sfn, 0);
1127 if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn)) &&
1128 !section_is_mapped (SYMBOL_OBJ_SECTION (sfn)))
1130 if (!query (_("WARNING!!! Destination is in "
1131 "unmapped overlay! Jump anyway? ")))
1133 error (_("Not confirmed."));
1143 printf_filtered (_("Continuing at "));
1144 fputs_filtered (paddress (gdbarch, addr), gdb_stdout);
1145 printf_filtered (".\n");
1148 /* If we are not asked to run in the bg, then prepare to run in the
1149 foreground, synchronously. */
1150 if (!async_exec && target_can_async_p ())
1152 /* Simulate synchronous execution. */
1153 async_disable_stdin ();
1156 clear_proceed_status ();
1157 proceed (addr, TARGET_SIGNAL_0, 0);
1161 /* Go to line or address in current procedure. */
1163 go_command (char *line_no, int from_tty)
1165 if (line_no == (char *) NULL || !*line_no)
1166 printf_filtered (_("Usage: go <location>\n"));
1169 tbreak_command (line_no, from_tty);
1170 jump_command (line_no, from_tty);
1175 /* Continue program giving it specified signal. */
1178 signal_command (char *signum_exp, int from_tty)
1180 enum target_signal oursig;
1183 dont_repeat (); /* Too dangerous. */
1185 ensure_not_tfind_mode ();
1186 ensure_valid_thread ();
1187 ensure_not_running ();
1189 /* Find out whether we must run in the background. */
1190 if (signum_exp != NULL)
1191 async_exec = strip_bg_char (&signum_exp);
1193 /* If we must run in the background, but the target can't do it,
1195 if (async_exec && !target_can_async_p ())
1196 error (_("Asynchronous execution not supported on this target."));
1198 /* If we are not asked to run in the bg, then prepare to run in the
1199 foreground, synchronously. */
1200 if (!async_exec && target_can_async_p ())
1202 /* Simulate synchronous execution. */
1203 async_disable_stdin ();
1207 error_no_arg (_("signal number"));
1209 /* It would be even slicker to make signal names be valid expressions,
1210 (the type could be "enum $signal" or some such), then the user could
1211 assign them to convenience variables. */
1212 oursig = target_signal_from_name (signum_exp);
1214 if (oursig == TARGET_SIGNAL_UNKNOWN)
1216 /* No, try numeric. */
1217 int num = parse_and_eval_long (signum_exp);
1220 oursig = TARGET_SIGNAL_0;
1222 oursig = target_signal_from_command (num);
1227 if (oursig == TARGET_SIGNAL_0)
1228 printf_filtered (_("Continuing with no signal.\n"));
1230 printf_filtered (_("Continuing with signal %s.\n"),
1231 target_signal_to_name (oursig));
1234 clear_proceed_status ();
1235 proceed ((CORE_ADDR) -1, oursig, 0);
1238 /* A continuation callback for until_next_command. */
1241 until_next_continuation (void *arg)
1243 struct thread_info *tp = arg;
1245 delete_longjmp_breakpoint (tp->num);
1248 /* Proceed until we reach a different source line with pc greater than
1249 our current one or exit the function. We skip calls in both cases.
1251 Note that eventually this command should probably be changed so
1252 that only source lines are printed out when we hit the breakpoint
1253 we set. This may involve changes to wait_for_inferior and the
1254 proceed status code. */
1257 until_next_command (int from_tty)
1259 struct frame_info *frame;
1261 struct symbol *func;
1262 struct symtab_and_line sal;
1263 struct thread_info *tp = inferior_thread ();
1264 int thread = tp->num;
1265 struct cleanup *old_chain;
1267 clear_proceed_status ();
1270 frame = get_current_frame ();
1272 /* Step until either exited from this function or greater
1273 than the current line (if in symbolic section) or pc (if
1276 pc = get_frame_pc (frame);
1277 func = find_pc_function (pc);
1281 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1283 if (msymbol == NULL)
1284 error (_("Execution is not within a known function."));
1286 tp->control.step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1287 tp->control.step_range_end = pc;
1291 sal = find_pc_line (pc, 0);
1293 tp->control.step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1294 tp->control.step_range_end = sal.end;
1297 tp->control.step_over_calls = STEP_OVER_ALL;
1299 tp->step_multi = 0; /* Only one call to proceed */
1301 set_longjmp_breakpoint (tp, get_frame_id (frame));
1302 old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
1304 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1306 if (target_can_async_p () && is_running (inferior_ptid))
1308 discard_cleanups (old_chain);
1309 add_continuation (tp, until_next_continuation, tp, NULL);
1312 do_cleanups (old_chain);
1316 until_command (char *arg, int from_tty)
1321 ensure_not_tfind_mode ();
1322 ensure_valid_thread ();
1323 ensure_not_running ();
1325 /* Find out whether we must run in the background. */
1327 async_exec = strip_bg_char (&arg);
1329 /* If we must run in the background, but the target can't do it,
1331 if (async_exec && !target_can_async_p ())
1332 error (_("Asynchronous execution not supported on this target."));
1334 /* If we are not asked to run in the bg, then prepare to run in the
1335 foreground, synchronously. */
1336 if (!async_exec && target_can_async_p ())
1338 /* Simulate synchronous execution. */
1339 async_disable_stdin ();
1343 until_break_command (arg, from_tty, 0);
1345 until_next_command (from_tty);
1349 advance_command (char *arg, int from_tty)
1354 ensure_not_tfind_mode ();
1355 ensure_valid_thread ();
1356 ensure_not_running ();
1359 error_no_arg (_("a location"));
1361 /* Find out whether we must run in the background. */
1363 async_exec = strip_bg_char (&arg);
1365 /* If we must run in the background, but the target can't do it,
1367 if (async_exec && !target_can_async_p ())
1368 error (_("Asynchronous execution not supported on this target."));
1370 /* If we are not asked to run in the bg, then prepare to run in the
1371 foreground, synchronously. */
1372 if (!async_exec && target_can_async_p ())
1374 /* Simulate synchronous execution. */
1375 async_disable_stdin ();
1378 until_break_command (arg, from_tty, 1);
1381 /* Print the result of a function at the end of a 'finish' command. */
1384 print_return_value (struct type *func_type, struct type *value_type)
1386 struct gdbarch *gdbarch = get_regcache_arch (stop_registers);
1387 struct cleanup *old_chain;
1388 struct ui_stream *stb;
1389 struct value *value;
1391 CHECK_TYPEDEF (value_type);
1392 gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
1394 /* FIXME: 2003-09-27: When returning from a nested inferior function
1395 call, it's possible (with no help from the architecture vector)
1396 to locate and return/print a "struct return" value. This is just
1397 a more complicated case of what is already being done in in the
1398 inferior function call code. In fact, when inferior function
1399 calls are made async, this will likely be made the norm. */
1401 switch (gdbarch_return_value (gdbarch, func_type, value_type,
1404 case RETURN_VALUE_REGISTER_CONVENTION:
1405 case RETURN_VALUE_ABI_RETURNS_ADDRESS:
1406 case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
1407 value = allocate_value (value_type);
1408 gdbarch_return_value (gdbarch, func_type, value_type, stop_registers,
1409 value_contents_raw (value), NULL);
1411 case RETURN_VALUE_STRUCT_CONVENTION:
1415 internal_error (__FILE__, __LINE__, _("bad switch"));
1420 struct value_print_options opts;
1423 stb = ui_out_stream_new (uiout);
1424 old_chain = make_cleanup_ui_out_stream_delete (stb);
1425 ui_out_text (uiout, "Value returned is ");
1426 ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
1427 record_latest_value (value));
1428 ui_out_text (uiout, " = ");
1429 get_raw_print_options (&opts);
1430 value_print (value, stb->stream, &opts);
1431 ui_out_field_stream (uiout, "return-value", stb);
1432 ui_out_text (uiout, "\n");
1433 do_cleanups (old_chain);
1437 ui_out_text (uiout, "Value returned has type: ");
1438 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1439 ui_out_text (uiout, ".");
1440 ui_out_text (uiout, " Cannot determine contents\n");
1444 /* Stuff that needs to be done by the finish command after the target
1445 has stopped. In asynchronous mode, we wait for the target to stop
1446 in the call to poll or select in the event loop, so it is
1447 impossible to do all the stuff as part of the finish_command
1448 function itself. The only chance we have to complete this command
1449 is in fetch_inferior_event, which is called by the event loop as
1450 soon as it detects that the target has stopped. This function is
1451 called via the cmd_continuation pointer. */
1453 struct finish_command_continuation_args
1455 struct breakpoint *breakpoint;
1456 struct symbol *function;
1460 finish_command_continuation (void *arg)
1462 struct finish_command_continuation_args *a = arg;
1463 struct thread_info *tp = NULL;
1466 if (!ptid_equal (inferior_ptid, null_ptid)
1467 && target_has_execution
1468 && is_stopped (inferior_ptid))
1470 tp = inferior_thread ();
1471 bs = tp->control.stop_bpstat;
1474 if (bpstat_find_breakpoint (bs, a->breakpoint) != NULL
1475 && a->function != NULL)
1477 struct type *value_type;
1479 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (a->function));
1481 internal_error (__FILE__, __LINE__,
1482 _("finish_command: function has no target type"));
1484 if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
1486 volatile struct gdb_exception ex;
1488 TRY_CATCH (ex, RETURN_MASK_ALL)
1490 /* print_return_value can throw an exception in some
1491 circumstances. We need to catch this so that we still
1492 delete the breakpoint. */
1493 print_return_value (SYMBOL_TYPE (a->function), value_type);
1496 exception_print (gdb_stdout, ex);
1500 /* We suppress normal call of normal_stop observer and do it here so
1501 that the *stopped notification includes the return value. */
1502 if (bs != NULL && tp->control.proceed_to_finish)
1503 observer_notify_normal_stop (bs, 1 /* print frame */);
1504 delete_breakpoint (a->breakpoint);
1505 delete_longjmp_breakpoint (inferior_thread ()->num);
1509 finish_command_continuation_free_arg (void *arg)
1514 /* finish_backward -- helper function for finish_command. */
1517 finish_backward (struct symbol *function)
1519 struct symtab_and_line sal;
1520 struct thread_info *tp = inferior_thread ();
1521 struct breakpoint *breakpoint;
1522 struct cleanup *old_chain;
1524 CORE_ADDR func_addr;
1527 pc = get_frame_pc (get_current_frame ());
1529 if (find_pc_partial_function (pc, NULL, &func_addr, NULL) == 0)
1530 internal_error (__FILE__, __LINE__,
1531 _("Finish: couldn't find function."));
1533 sal = find_pc_line (func_addr, 0);
1535 /* We don't need a return value. */
1536 tp->control.proceed_to_finish = 0;
1537 /* Special case: if we're sitting at the function entry point,
1538 then all we need to do is take a reverse singlestep. We
1539 don't need to set a breakpoint, and indeed it would do us
1542 Note that this can only happen at frame #0, since there's
1543 no way that a function up the stack can have a return address
1544 that's equal to its entry point. */
1548 struct frame_info *frame = get_selected_frame (NULL);
1549 struct gdbarch *gdbarch = get_frame_arch (frame);
1551 /* Set breakpoint and continue. */
1553 set_momentary_breakpoint (gdbarch, sal,
1554 get_stack_frame_id (frame),
1556 /* Tell the breakpoint to keep quiet. We won't be done
1557 until we've done another reverse single-step. */
1558 breakpoint_set_silent (breakpoint, 1);
1559 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1560 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1561 /* We will be stopped when proceed returns. */
1562 back_up = (bpstat_find_breakpoint (tp->control.stop_bpstat, breakpoint)
1564 do_cleanups (old_chain);
1570 /* If in fact we hit the step-resume breakpoint (and not
1571 some other breakpoint), then we're almost there --
1572 we just need to back up by one more single-step. */
1573 tp->control.step_range_start = tp->control.step_range_end = 1;
1574 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1579 /* finish_forward -- helper function for finish_command. */
1582 finish_forward (struct symbol *function, struct frame_info *frame)
1584 struct gdbarch *gdbarch = get_frame_arch (frame);
1585 struct symtab_and_line sal;
1586 struct thread_info *tp = inferior_thread ();
1587 struct breakpoint *breakpoint;
1588 struct cleanup *old_chain;
1589 struct finish_command_continuation_args *cargs;
1590 int thread = tp->num;
1592 sal = find_pc_line (get_frame_pc (frame), 0);
1593 sal.pc = get_frame_pc (frame);
1595 breakpoint = set_momentary_breakpoint (gdbarch, sal,
1596 get_stack_frame_id (frame),
1599 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1601 set_longjmp_breakpoint (tp, get_frame_id (frame));
1602 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
1604 /* We want stop_registers, please... */
1605 tp->control.proceed_to_finish = 1;
1606 cargs = xmalloc (sizeof (*cargs));
1608 cargs->breakpoint = breakpoint;
1609 cargs->function = function;
1610 add_continuation (tp, finish_command_continuation, cargs,
1611 finish_command_continuation_free_arg);
1612 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1614 discard_cleanups (old_chain);
1615 if (!target_can_async_p ())
1616 do_all_continuations ();
1619 /* "finish": Set a temporary breakpoint at the place the selected
1620 frame will return to, then continue. */
1623 finish_command (char *arg, int from_tty)
1625 struct frame_info *frame;
1626 struct symbol *function;
1631 ensure_not_tfind_mode ();
1632 ensure_valid_thread ();
1633 ensure_not_running ();
1635 /* Find out whether we must run in the background. */
1637 async_exec = strip_bg_char (&arg);
1639 /* If we must run in the background, but the target can't do it,
1641 if (async_exec && !target_can_async_p ())
1642 error (_("Asynchronous execution not supported on this target."));
1644 /* Don't try to async in reverse. */
1645 if (async_exec && execution_direction == EXEC_REVERSE)
1646 error (_("Asynchronous 'finish' not supported in reverse."));
1648 /* If we are not asked to run in the bg, then prepare to run in the
1649 foreground, synchronously. */
1650 if (!async_exec && target_can_async_p ())
1652 /* Simulate synchronous execution. */
1653 async_disable_stdin ();
1657 error (_("The \"finish\" command does not take any arguments."));
1659 frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
1661 error (_("\"finish\" not meaningful in the outermost frame."));
1663 clear_proceed_status ();
1665 /* Finishing from an inline frame is completely different. We don't
1666 try to show the "return value" - no way to locate it. So we do
1667 not need a completion. */
1668 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1671 /* Claim we are stepping in the calling frame. An empty step
1672 range means that we will stop once we aren't in a function
1673 called by that frame. We don't use the magic "1" value for
1674 step_range_end, because then infrun will think this is nexti,
1675 and not step over the rest of this inlined function call. */
1676 struct thread_info *tp = inferior_thread ();
1677 struct symtab_and_line empty_sal;
1679 init_sal (&empty_sal);
1680 set_step_info (frame, empty_sal);
1681 tp->control.step_range_start = get_frame_pc (frame);
1682 tp->control.step_range_end = tp->control.step_range_start;
1683 tp->control.step_over_calls = STEP_OVER_ALL;
1685 /* Print info on the selected frame, including level number but not
1689 printf_filtered (_("Run till exit from "));
1690 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1693 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1697 /* Find the function we will return from. */
1699 function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
1701 /* Print info on the selected frame, including level number but not
1705 if (execution_direction == EXEC_REVERSE)
1706 printf_filtered (_("Run back to call of "));
1708 printf_filtered (_("Run till exit from "));
1710 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1713 if (execution_direction == EXEC_REVERSE)
1714 finish_backward (function);
1716 finish_forward (function, frame);
1721 program_info (char *args, int from_tty)
1725 struct thread_info *tp;
1728 if (!target_has_execution)
1730 printf_filtered (_("The program being debugged is not being run.\n"));
1735 ptid = inferior_ptid;
1738 struct target_waitstatus ws;
1740 get_last_target_status (&ptid, &ws);
1743 if (ptid_equal (ptid, null_ptid) || is_exited (ptid))
1744 error (_("Invalid selected thread."));
1745 else if (is_running (ptid))
1746 error (_("Selected thread is running."));
1748 tp = find_thread_ptid (ptid);
1749 bs = tp->control.stop_bpstat;
1750 stat = bpstat_num (&bs, &num);
1752 target_files_info ();
1753 printf_filtered (_("Program stopped at %s.\n"),
1754 paddress (target_gdbarch, stop_pc));
1755 if (tp->control.stop_step)
1756 printf_filtered (_("It stopped after being stepped.\n"));
1759 /* There may be several breakpoints in the same place, so this
1760 isn't as strange as it seems. */
1765 printf_filtered (_("It stopped at a breakpoint "
1766 "that has since been deleted.\n"));
1769 printf_filtered (_("It stopped at breakpoint %d.\n"), num);
1770 stat = bpstat_num (&bs, &num);
1773 else if (tp->suspend.stop_signal != TARGET_SIGNAL_0)
1775 printf_filtered (_("It stopped with signal %s, %s.\n"),
1776 target_signal_to_name (tp->suspend.stop_signal),
1777 target_signal_to_string (tp->suspend.stop_signal));
1782 printf_filtered (_("Type \"info stack\" or \"info "
1783 "registers\" for more information.\n"));
1788 environment_info (char *var, int from_tty)
1792 char *val = get_in_environ (current_inferior ()->environment, var);
1796 puts_filtered (var);
1797 puts_filtered (" = ");
1798 puts_filtered (val);
1799 puts_filtered ("\n");
1803 puts_filtered ("Environment variable \"");
1804 puts_filtered (var);
1805 puts_filtered ("\" not defined.\n");
1810 char **vector = environ_vector (current_inferior ()->environment);
1814 puts_filtered (*vector++);
1815 puts_filtered ("\n");
1821 set_environment_command (char *arg, int from_tty)
1823 char *p, *val, *var;
1827 error_no_arg (_("environment variable and value"));
1829 /* Find seperation between variable name and value. */
1830 p = (char *) strchr (arg, '=');
1831 val = (char *) strchr (arg, ' ');
1833 if (p != 0 && val != 0)
1835 /* We have both a space and an equals. If the space is before the
1836 equals, walk forward over the spaces til we see a nonspace
1837 (possibly the equals). */
1842 /* Now if the = is after the char following the spaces,
1843 take the char following the spaces. */
1847 else if (val != 0 && p == 0)
1851 error_no_arg (_("environment variable to set"));
1853 if (p == 0 || p[1] == 0)
1857 p = arg + strlen (arg); /* So that savestring below will work. */
1861 /* Not setting variable value to null. */
1863 while (*val == ' ' || *val == '\t')
1867 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1870 var = savestring (arg, p - arg);
1873 printf_filtered (_("Setting environment variable "
1874 "\"%s\" to null value.\n"),
1876 set_in_environ (current_inferior ()->environment, var, "");
1879 set_in_environ (current_inferior ()->environment, var, val);
1884 unset_environment_command (char *var, int from_tty)
1888 /* If there is no argument, delete all environment variables.
1889 Ask for confirmation if reading from the terminal. */
1890 if (!from_tty || query (_("Delete all environment variables? ")))
1892 free_environ (current_inferior ()->environment);
1893 current_inferior ()->environment = make_environ ();
1897 unset_in_environ (current_inferior ()->environment, var);
1900 /* Handle the execution path (PATH variable). */
1902 static const char path_var_name[] = "PATH";
1905 path_info (char *args, int from_tty)
1907 puts_filtered ("Executable and object file path: ");
1908 puts_filtered (get_in_environ (current_inferior ()->environment,
1910 puts_filtered ("\n");
1913 /* Add zero or more directories to the front of the execution path. */
1916 path_command (char *dirname, int from_tty)
1922 env = get_in_environ (current_inferior ()->environment, path_var_name);
1923 /* Can be null if path is not set. */
1926 exec_path = xstrdup (env);
1927 mod_path (dirname, &exec_path);
1928 set_in_environ (current_inferior ()->environment, path_var_name, exec_path);
1931 path_info ((char *) NULL, from_tty);
1935 /* Print out the machine register regnum. If regnum is -1, print all
1936 registers (print_all == 1) or all non-float and non-vector
1937 registers (print_all == 0).
1939 For most machines, having all_registers_info() print the
1940 register(s) one per line is good enough. If a different format is
1941 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1942 regs), or there is an existing convention for showing all the
1943 registers, define the architecture method PRINT_REGISTERS_INFO to
1944 provide that format. */
1947 default_print_registers_info (struct gdbarch *gdbarch,
1948 struct ui_file *file,
1949 struct frame_info *frame,
1950 int regnum, int print_all)
1953 const int numregs = gdbarch_num_regs (gdbarch)
1954 + gdbarch_num_pseudo_regs (gdbarch);
1956 for (i = 0; i < numregs; i++)
1958 struct type *regtype;
1961 /* Decide between printing all regs, non-float / vector regs, or
1967 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1972 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1982 /* If the register name is empty, it is undefined for this
1983 processor, so don't display anything. */
1984 if (gdbarch_register_name (gdbarch, i) == NULL
1985 || *(gdbarch_register_name (gdbarch, i)) == '\0')
1988 fputs_filtered (gdbarch_register_name (gdbarch, i), file);
1989 print_spaces_filtered (15 - strlen (gdbarch_register_name
1990 (gdbarch, i)), file);
1992 regtype = register_type (gdbarch, i);
1993 val = allocate_value (regtype);
1995 /* Get the data in raw format. */
1996 if (! frame_register_read (frame, i, value_contents_raw (val)))
1998 fprintf_filtered (file, "*value not available*\n");
2002 /* If virtual format is floating, print it that way, and in raw
2004 if (TYPE_CODE (regtype) == TYPE_CODE_FLT
2005 || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT)
2008 struct value_print_options opts;
2009 const gdb_byte *valaddr = value_contents_for_printing (val);
2011 get_user_print_options (&opts);
2015 value_contents_for_printing (val),
2016 value_embedded_offset (val), 0,
2017 file, 0, val, &opts, current_language);
2019 fprintf_filtered (file, "\t(raw 0x");
2020 for (j = 0; j < register_size (gdbarch, i); j++)
2024 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
2027 idx = register_size (gdbarch, i) - 1 - j;
2028 fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]);
2030 fprintf_filtered (file, ")");
2034 struct value_print_options opts;
2036 /* Print the register in hex. */
2037 get_formatted_print_options (&opts, 'x');
2040 value_contents_for_printing (val),
2041 value_embedded_offset (val), 0,
2042 file, 0, val, &opts, current_language);
2043 /* If not a vector register, print it also according to its
2045 if (TYPE_VECTOR (regtype) == 0)
2047 get_user_print_options (&opts);
2049 fprintf_filtered (file, "\t");
2051 value_contents_for_printing (val),
2052 value_embedded_offset (val), 0,
2053 file, 0, val, &opts, current_language);
2057 fprintf_filtered (file, "\n");
2062 registers_info (char *addr_exp, int fpregs)
2064 struct frame_info *frame;
2065 struct gdbarch *gdbarch;
2067 if (!target_has_registers)
2068 error (_("The program has no registers now."));
2069 frame = get_selected_frame (NULL);
2070 gdbarch = get_frame_arch (frame);
2074 gdbarch_print_registers_info (gdbarch, gdb_stdout,
2079 while (*addr_exp != '\0')
2084 /* Keep skipping leading white space. */
2085 if (isspace ((*addr_exp)))
2091 /* Discard any leading ``$''. Check that there is something
2092 resembling a register following it. */
2093 if (addr_exp[0] == '$')
2095 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
2096 error (_("Missing register name"));
2098 /* Find the start/end of this register name/num/group. */
2100 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
2104 /* Figure out what we've found and display it. */
2106 /* A register name? */
2108 int regnum = user_reg_map_name_to_regnum (gdbarch, start, end - start);
2112 /* User registers lie completely outside of the range of
2113 normal registers. Catch them early so that the target
2115 if (regnum >= gdbarch_num_regs (gdbarch)
2116 + gdbarch_num_pseudo_regs (gdbarch))
2118 struct value_print_options opts;
2119 struct value *val = value_of_user_reg (regnum, frame);
2121 printf_filtered ("%s: ", start);
2122 get_formatted_print_options (&opts, 'x');
2123 val_print_scalar_formatted (check_typedef (value_type (val)),
2124 value_contents_for_printing (val),
2125 value_embedded_offset (val),
2127 &opts, 0, gdb_stdout);
2128 printf_filtered ("\n");
2131 gdbarch_print_registers_info (gdbarch, gdb_stdout,
2132 frame, regnum, fpregs);
2137 /* A register group? */
2139 struct reggroup *group;
2141 for (group = reggroup_next (gdbarch, NULL);
2143 group = reggroup_next (gdbarch, group))
2145 /* Don't bother with a length check. Should the user
2146 enter a short register group name, go with the first
2147 group that matches. */
2148 if (strncmp (start, reggroup_name (group), end - start) == 0)
2156 regnum < gdbarch_num_regs (gdbarch)
2157 + gdbarch_num_pseudo_regs (gdbarch);
2160 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
2161 gdbarch_print_registers_info (gdbarch,
2169 /* Nothing matched. */
2170 error (_("Invalid register `%.*s'"), (int) (end - start), start);
2175 all_registers_info (char *addr_exp, int from_tty)
2177 registers_info (addr_exp, 1);
2181 nofp_registers_info (char *addr_exp, int from_tty)
2183 registers_info (addr_exp, 0);
2187 print_vector_info (struct ui_file *file,
2188 struct frame_info *frame, const char *args)
2190 struct gdbarch *gdbarch = get_frame_arch (frame);
2192 if (gdbarch_print_vector_info_p (gdbarch))
2193 gdbarch_print_vector_info (gdbarch, file, frame, args);
2197 int printed_something = 0;
2200 regnum < gdbarch_num_regs (gdbarch)
2201 + gdbarch_num_pseudo_regs (gdbarch);
2204 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
2206 printed_something = 1;
2207 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2210 if (!printed_something)
2211 fprintf_filtered (file, "No vector information\n");
2216 vector_info (char *args, int from_tty)
2218 if (!target_has_registers)
2219 error (_("The program has no registers now."));
2221 print_vector_info (gdb_stdout, get_selected_frame (NULL), args);
2224 /* Kill the inferior process. Make us have no inferior. */
2227 kill_command (char *arg, int from_tty)
2229 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2230 It should be a distinct flag that indicates that a target is active, cuz
2231 some targets don't have processes! */
2233 if (ptid_equal (inferior_ptid, null_ptid))
2234 error (_("The program is not being run."));
2235 if (!query (_("Kill the program being debugged? ")))
2236 error (_("Not confirmed."));
2239 /* If we still have other inferiors to debug, then don't mess with
2240 with their threads. */
2241 if (!have_inferiors ())
2243 init_thread_list (); /* Destroy thread info. */
2245 /* Killing off the inferior can leave us with a core file. If
2246 so, print the state we are left in. */
2247 if (target_has_stack)
2249 printf_filtered (_("In %s,\n"), target_longname);
2250 print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
2253 bfd_cache_close_all ();
2256 /* Used in `attach&' command. ARG is a point to an integer
2257 representing a process id. Proceed threads of this process iff
2258 they stopped due to debugger request, and when they did, they
2259 reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads
2260 that have been explicitly been told to stop. */
2263 proceed_after_attach_callback (struct thread_info *thread,
2266 int pid = * (int *) arg;
2268 if (ptid_get_pid (thread->ptid) == pid
2269 && !is_exited (thread->ptid)
2270 && !is_executing (thread->ptid)
2271 && !thread->stop_requested
2272 && thread->suspend.stop_signal == TARGET_SIGNAL_0)
2274 switch_to_thread (thread->ptid);
2275 clear_proceed_status ();
2276 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
2283 proceed_after_attach (int pid)
2285 /* Don't error out if the current thread is running, because
2286 there may be other stopped threads. */
2287 struct cleanup *old_chain;
2289 /* Backup current thread and selected frame. */
2290 old_chain = make_cleanup_restore_current_thread ();
2292 iterate_over_threads (proceed_after_attach_callback, &pid);
2294 /* Restore selected ptid. */
2295 do_cleanups (old_chain);
2300 * Should save/restore the tty state since it might be that the
2301 * program to be debugged was started on this tty and it wants
2302 * the tty in some state other than what we want. If it's running
2303 * on another terminal or without a terminal, then saving and
2304 * restoring the tty state is a harmless no-op.
2305 * This only needs to be done if we are attaching to a process.
2308 /* attach_command --
2309 takes a program started up outside of gdb and ``attaches'' to it.
2310 This stops it cold in its tracks and allows us to start debugging it.
2311 and wait for the trace-trap that results from attaching. */
2314 attach_command_post_wait (char *args, int from_tty, int async_exec)
2317 char *full_exec_path = NULL;
2318 struct inferior *inferior;
2320 inferior = current_inferior ();
2321 inferior->control.stop_soon = NO_STOP_QUIETLY;
2323 /* If no exec file is yet known, try to determine it from the
2325 exec_file = (char *) get_exec_file (0);
2328 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
2331 /* It's possible we don't have a full path, but rather just a
2332 filename. Some targets, such as HP-UX, don't provide the
2335 Attempt to qualify the filename against the source path.
2336 (If that fails, we'll just fall back on the original
2337 filename. Not much more we can do...) */
2339 if (!source_full_path_of (exec_file, &full_exec_path))
2340 full_exec_path = xstrdup (exec_file);
2342 exec_file_attach (full_exec_path, from_tty);
2343 symbol_file_add_main (full_exec_path, from_tty);
2348 reopen_exec_file ();
2352 /* Take any necessary post-attaching actions for this platform. */
2353 target_post_attach (PIDGET (inferior_ptid));
2355 post_create_inferior (¤t_target, from_tty);
2357 /* Install inferior's terminal modes. */
2358 target_terminal_inferior ();
2362 /* The user requested an `attach&', so be sure to leave threads
2363 that didn't get a signal running. */
2365 /* Immediatelly resume all suspended threads of this inferior,
2366 and this inferior only. This should have no effect on
2367 already running threads. If a thread has been stopped with a
2368 signal, leave it be. */
2370 proceed_after_attach (inferior->pid);
2373 if (inferior_thread ()->suspend.stop_signal == TARGET_SIGNAL_0)
2375 clear_proceed_status ();
2376 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
2382 /* The user requested a plain `attach', so be sure to leave
2383 the inferior stopped. */
2385 if (target_can_async_p ())
2386 async_enable_stdin ();
2388 /* At least the current thread is already stopped. */
2390 /* In all-stop, by definition, all threads have to be already
2391 stopped at this point. In non-stop, however, although the
2392 selected thread is stopped, others may still be executing.
2393 Be sure to explicitly stop all threads of the process. This
2394 should have no effect on already stopped threads. */
2396 target_stop (pid_to_ptid (inferior->pid));
2398 /* Tell the user/frontend where we're stopped. */
2400 if (deprecated_attach_hook)
2401 deprecated_attach_hook ();
2405 struct attach_command_continuation_args
2413 attach_command_continuation (void *args)
2415 struct attach_command_continuation_args *a = args;
2417 attach_command_post_wait (a->args, a->from_tty, a->async_exec);
2421 attach_command_continuation_free_args (void *args)
2423 struct attach_command_continuation_args *a = args;
2430 attach_command (char *args, int from_tty)
2433 struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
2435 dont_repeat (); /* Not for the faint of heart */
2437 if (gdbarch_has_global_solist (target_gdbarch))
2438 /* Don't complain if all processes share the same symbol
2441 else if (target_has_execution)
2443 if (query (_("A program is being debugged already. Kill it? ")))
2446 error (_("Not killed."));
2449 /* Clean up any leftovers from other runs. Some other things from
2450 this function should probably be moved into target_pre_inferior. */
2451 target_pre_inferior (from_tty);
2453 if (non_stop && !target_supports_non_stop ())
2454 error (_("Cannot attach to this target in non-stop mode"));
2458 async_exec = strip_bg_char (&args);
2460 /* If we get a request for running in the bg but the target
2461 doesn't support it, error out. */
2462 if (async_exec && !target_can_async_p ())
2463 error (_("Asynchronous execution not supported on this target."));
2466 /* If we don't get a request of running in the bg, then we need
2467 to simulate synchronous (fg) execution. */
2468 if (!async_exec && target_can_async_p ())
2470 /* Simulate synchronous execution. */
2471 async_disable_stdin ();
2472 make_cleanup ((make_cleanup_ftype *)async_enable_stdin, NULL);
2475 target_attach (args, from_tty);
2477 /* Set up the "saved terminal modes" of the inferior
2478 based on what modes we are starting it with. */
2479 target_terminal_init ();
2481 /* Set up execution context to know that we should return from
2482 wait_for_inferior as soon as the target reports a stop. */
2483 init_wait_for_inferior ();
2484 clear_proceed_status ();
2488 /* If we find that the current thread isn't stopped, explicitly
2489 do so now, because we're going to install breakpoints and
2493 /* The user requested an `attach&'; stop just one thread. */
2494 target_stop (inferior_ptid);
2496 /* The user requested an `attach', so stop all threads of this
2498 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid)));
2501 /* Some system don't generate traps when attaching to inferior.
2502 E.g. Mach 3 or GNU hurd. */
2503 if (!target_attach_no_wait)
2505 struct inferior *inferior = current_inferior ();
2507 /* Careful here. See comments in inferior.h. Basically some
2508 OSes don't ignore SIGSTOPs on continue requests anymore. We
2509 need a way for handle_inferior_event to reset the stop_signal
2510 variable after an attach, and this is what
2511 STOP_QUIETLY_NO_SIGSTOP is for. */
2512 inferior->control.stop_soon = STOP_QUIETLY_NO_SIGSTOP;
2514 if (target_can_async_p ())
2516 /* sync_execution mode. Wait for stop. */
2517 struct attach_command_continuation_args *a;
2519 a = xmalloc (sizeof (*a));
2520 a->args = xstrdup (args);
2521 a->from_tty = from_tty;
2522 a->async_exec = async_exec;
2523 add_inferior_continuation (attach_command_continuation, a,
2524 attach_command_continuation_free_args);
2525 discard_cleanups (back_to);
2529 wait_for_inferior (0);
2532 attach_command_post_wait (args, from_tty, async_exec);
2533 discard_cleanups (back_to);
2536 /* We had just found out that the target was already attached to an
2537 inferior. PTID points at a thread of this new inferior, that is
2538 the most likely to be stopped right now, but not necessarily so.
2539 The new inferior is assumed to be already added to the inferior
2540 list at this point. If LEAVE_RUNNING, then leave the threads of
2541 this inferior running, except those we've explicitly seen reported
2545 notice_new_inferior (ptid_t ptid, int leave_running, int from_tty)
2547 struct cleanup* old_chain;
2550 old_chain = make_cleanup (null_cleanup, NULL);
2552 /* If in non-stop, leave threads as running as they were. If
2553 they're stopped for some reason other than us telling it to, the
2554 target reports a signal != TARGET_SIGNAL_0. We don't try to
2555 resume threads with such a stop signal. */
2556 async_exec = non_stop;
2558 if (!ptid_equal (inferior_ptid, null_ptid))
2559 make_cleanup_restore_current_thread ();
2561 switch_to_thread (ptid);
2563 /* When we "notice" a new inferior we need to do all the things we
2564 would normally do if we had just attached to it. */
2566 if (is_executing (inferior_ptid))
2568 struct inferior *inferior = current_inferior ();
2570 /* We're going to install breakpoints, and poke at memory,
2571 ensure that the inferior is stopped for a moment while we do
2573 target_stop (inferior_ptid);
2575 inferior->control.stop_soon = STOP_QUIETLY_REMOTE;
2577 /* Wait for stop before proceeding. */
2578 if (target_can_async_p ())
2580 struct attach_command_continuation_args *a;
2582 a = xmalloc (sizeof (*a));
2583 a->args = xstrdup ("");
2584 a->from_tty = from_tty;
2585 a->async_exec = async_exec;
2586 add_inferior_continuation (attach_command_continuation, a,
2587 attach_command_continuation_free_args);
2589 do_cleanups (old_chain);
2593 wait_for_inferior (0);
2596 async_exec = leave_running;
2597 attach_command_post_wait ("" /* args */, from_tty, async_exec);
2599 do_cleanups (old_chain);
2604 * takes a program previously attached to and detaches it.
2605 * The program resumes execution and will no longer stop
2606 * on signals, etc. We better not have left any breakpoints
2607 * in the program or it'll die when it hits one. For this
2608 * to work, it may be necessary for the process to have been
2609 * previously attached. It *might* work if the program was
2610 * started via the normal ptrace (PTRACE_TRACEME).
2614 detach_command (char *args, int from_tty)
2616 dont_repeat (); /* Not for the faint of heart. */
2618 if (ptid_equal (inferior_ptid, null_ptid))
2619 error (_("The program is not being run."));
2621 disconnect_tracing (from_tty);
2623 target_detach (args, from_tty);
2625 /* If the solist is global across inferiors, don't clear it when we
2626 detach from a single inferior. */
2627 if (!gdbarch_has_global_solist (target_gdbarch))
2628 no_shared_libraries (NULL, from_tty);
2630 /* If we still have inferiors to debug, then don't mess with their
2632 if (!have_inferiors ())
2633 init_thread_list ();
2635 if (deprecated_detach_hook)
2636 deprecated_detach_hook ();
2639 /* Disconnect from the current target without resuming it (leaving it
2640 waiting for a debugger).
2642 We'd better not have left any breakpoints in the program or the
2643 next debugger will get confused. Currently only supported for some
2644 remote targets, since the normal attach mechanisms don't work on
2645 stopped processes on some native platforms (e.g. GNU/Linux). */
2648 disconnect_command (char *args, int from_tty)
2650 dont_repeat (); /* Not for the faint of heart. */
2651 target_disconnect (args, from_tty);
2652 no_shared_libraries (NULL, from_tty);
2653 init_thread_list ();
2654 if (deprecated_detach_hook)
2655 deprecated_detach_hook ();
2659 interrupt_target_1 (int all_threads)
2664 ptid = minus_one_ptid;
2666 ptid = inferior_ptid;
2669 /* Tag the thread as having been explicitly requested to stop, so
2670 other parts of gdb know not to resume this thread automatically,
2671 if it was stopped due to an internal event. Limit this to
2672 non-stop mode, as when debugging a multi-threaded application in
2673 all-stop mode, we will only get one stop event --- it's undefined
2674 which thread will report the event. */
2676 set_stop_requested (ptid, 1);
2679 /* Stop the execution of the target while running in async mode, in
2680 the backgound. In all-stop, stop the whole process. In non-stop
2681 mode, stop the current thread only by default, or stop all threads
2682 if the `-a' switch is used. */
2684 /* interrupt [-a] */
2686 interrupt_target_command (char *args, int from_tty)
2688 if (target_can_async_p ())
2690 int all_threads = 0;
2692 dont_repeat (); /* Not for the faint of heart. */
2695 && strncmp (args, "-a", sizeof ("-a") - 1) == 0)
2698 if (!non_stop && all_threads)
2699 error (_("-a is meaningless in all-stop mode."));
2701 interrupt_target_1 (all_threads);
2706 print_float_info (struct ui_file *file,
2707 struct frame_info *frame, const char *args)
2709 struct gdbarch *gdbarch = get_frame_arch (frame);
2711 if (gdbarch_print_float_info_p (gdbarch))
2712 gdbarch_print_float_info (gdbarch, file, frame, args);
2716 int printed_something = 0;
2719 regnum < gdbarch_num_regs (gdbarch)
2720 + gdbarch_num_pseudo_regs (gdbarch);
2723 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
2725 printed_something = 1;
2726 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2729 if (!printed_something)
2730 fprintf_filtered (file, "No floating-point info "
2731 "available for this processor.\n");
2736 float_info (char *args, int from_tty)
2738 if (!target_has_registers)
2739 error (_("The program has no registers now."));
2741 print_float_info (gdb_stdout, get_selected_frame (NULL), args);
2745 unset_command (char *args, int from_tty)
2747 printf_filtered (_("\"unset\" must be followed by the "
2748 "name of an unset subcommand.\n"));
2749 help_list (unsetlist, "unset ", -1, gdb_stdout);
2753 _initialize_infcmd (void)
2755 struct cmd_list_element *c = NULL;
2757 /* Add the filename of the terminal connected to inferior I/O. */
2758 add_setshow_filename_cmd ("inferior-tty", class_run,
2759 &inferior_io_terminal_scratch, _("\
2760 Set terminal for future runs of program being debugged."), _("\
2761 Show terminal for future runs of program being debugged."), _("\
2762 Usage: set inferior-tty /dev/pts/1"),
2763 set_inferior_tty_command,
2764 show_inferior_tty_command,
2765 &setlist, &showlist);
2766 add_com_alias ("tty", "set inferior-tty", class_alias, 0);
2768 add_setshow_optional_filename_cmd ("args", class_run,
2769 &inferior_args_scratch, _("\
2770 Set argument list to give program being debugged when it is started."), _("\
2771 Show argument list to give program being debugged when it is started."), _("\
2772 Follow this command with any number of args, to be passed to the program."),
2775 &setlist, &showlist);
2777 c = add_cmd ("environment", no_class, environment_info, _("\
2778 The environment to give the program, or one variable's value.\n\
2779 With an argument VAR, prints the value of environment variable VAR to\n\
2780 give the program being debugged. With no arguments, prints the entire\n\
2781 environment to be given to the program."), &showlist);
2782 set_cmd_completer (c, noop_completer);
2784 add_prefix_cmd ("unset", no_class, unset_command,
2785 _("Complement to certain \"set\" commands."),
2786 &unsetlist, "unset ", 0, &cmdlist);
2788 c = add_cmd ("environment", class_run, unset_environment_command, _("\
2789 Cancel environment variable VAR for the program.\n\
2790 This does not affect the program until the next \"run\" command."),
2792 set_cmd_completer (c, noop_completer);
2794 c = add_cmd ("environment", class_run, set_environment_command, _("\
2795 Set environment variable value to give the program.\n\
2796 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2797 VALUES of environment variables are uninterpreted strings.\n\
2798 This does not affect the program until the next \"run\" command."),
2800 set_cmd_completer (c, noop_completer);
2802 c = add_com ("path", class_files, path_command, _("\
2803 Add directory DIR(s) to beginning of search path for object files.\n\
2804 $cwd in the path means the current working directory.\n\
2805 This path is equivalent to the $PATH shell variable. It is a list of\n\
2806 directories, separated by colons. These directories are searched to find\n\
2807 fully linked executable files and separately compiled object files as \
2809 set_cmd_completer (c, filename_completer);
2811 c = add_cmd ("paths", no_class, path_info, _("\
2812 Current search path for finding object files.\n\
2813 $cwd in the path means the current working directory.\n\
2814 This path is equivalent to the $PATH shell variable. It is a list of\n\
2815 directories, separated by colons. These directories are searched to find\n\
2816 fully linked executable files and separately compiled object files as \
2819 set_cmd_completer (c, noop_completer);
2821 add_prefix_cmd ("kill", class_run, kill_command,
2822 _("Kill execution of program being debugged."),
2823 &killlist, "kill ", 0, &cmdlist);
2825 add_com ("attach", class_run, attach_command, _("\
2826 Attach to a process or file outside of GDB.\n\
2827 This command attaches to another target, of the same type as your last\n\
2828 \"target\" command (\"info files\" will show your target stack).\n\
2829 The command may take as argument a process id or a device file.\n\
2830 For a process id, you must have permission to send the process a signal,\n\
2831 and it must have the same effective uid as the debugger.\n\
2832 When using \"attach\" with a process id, the debugger finds the\n\
2833 program running in the process, looking first in the current working\n\
2834 directory, or (if not found there) using the source file search path\n\
2835 (see the \"directory\" command). You can also use the \"file\" command\n\
2836 to specify the program, and to load its symbol table."));
2838 add_prefix_cmd ("detach", class_run, detach_command, _("\
2839 Detach a process or file previously attached.\n\
2840 If a process, it is no longer traced, and it continues its execution. If\n\
2841 you were debugging a file, the file is closed and gdb no longer accesses it."),
2842 &detachlist, "detach ", 0, &cmdlist);
2844 add_com ("disconnect", class_run, disconnect_command, _("\
2845 Disconnect from a target.\n\
2846 The target will wait for another debugger to connect. Not available for\n\
2849 add_com ("signal", class_run, signal_command, _("\
2850 Continue program giving it signal specified by the argument.\n\
2851 An argument of \"0\" means continue program without giving it a signal."));
2853 add_com ("stepi", class_run, stepi_command, _("\
2854 Step one instruction exactly.\n\
2855 Argument N means do this N times (or till program stops for another \
2857 add_com_alias ("si", "stepi", class_alias, 0);
2859 add_com ("nexti", class_run, nexti_command, _("\
2860 Step one instruction, but proceed through subroutine calls.\n\
2861 Argument N means do this N times (or till program stops for another \
2863 add_com_alias ("ni", "nexti", class_alias, 0);
2865 add_com ("finish", class_run, finish_command, _("\
2866 Execute until selected stack frame returns.\n\
2867 Upon return, the value returned is printed and put in the value history."));
2868 add_com_alias ("fin", "finish", class_run, 1);
2870 add_com ("next", class_run, next_command, _("\
2871 Step program, proceeding through subroutine calls.\n\
2872 Like the \"step\" command as long as subroutine calls do not happen;\n\
2873 when they do, the call is treated as one instruction.\n\
2874 Argument N means do this N times (or till program stops for another \
2876 add_com_alias ("n", "next", class_run, 1);
2878 add_com_alias ("S", "next", class_run, 1);
2880 add_com ("step", class_run, step_command, _("\
2881 Step program until it reaches a different source line.\n\
2882 Argument N means do this N times (or till program stops for another \
2884 add_com_alias ("s", "step", class_run, 1);
2886 c = add_com ("until", class_run, until_command, _("\
2887 Execute until the program reaches a source line greater than the current\n\
2888 or a specified location (same args as break command) within the current \
2890 set_cmd_completer (c, location_completer);
2891 add_com_alias ("u", "until", class_run, 1);
2893 c = add_com ("advance", class_run, advance_command, _("\
2894 Continue the program up to the given location (same form as args for break \
2896 Execution will also stop upon exit from the current stack frame."));
2897 set_cmd_completer (c, location_completer);
2899 c = add_com ("jump", class_run, jump_command, _("\
2900 Continue program being debugged at specified line or address.\n\
2901 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2902 for an address to start at."));
2903 set_cmd_completer (c, location_completer);
2907 c = add_com ("go", class_run, go_command, _("\
2908 Usage: go <location>\n\
2909 Continue program being debugged, stopping at specified line or \n\
2911 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2912 expression for an address to start at.\n\
2913 This command is a combination of tbreak and jump."));
2914 set_cmd_completer (c, location_completer);
2918 add_com_alias ("g", "go", class_run, 1);
2920 add_com ("continue", class_run, continue_command, _("\
2921 Continue program being debugged, after signal or breakpoint.\n\
2922 If proceeding from breakpoint, a number N may be used as an argument,\n\
2923 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2924 the breakpoint won't break until the Nth time it is reached).\n\
2926 If non-stop mode is enabled, continue only the current thread,\n\
2927 otherwise all the threads in the program are continued. To \n\
2928 continue all stopped threads in non-stop mode, use the -a option.\n\
2929 Specifying -a and an ignore count simultaneously is an error."));
2930 add_com_alias ("c", "cont", class_run, 1);
2931 add_com_alias ("fg", "cont", class_run, 1);
2933 c = add_com ("run", class_run, run_command, _("\
2934 Start debugged program. You may specify arguments to give it.\n\
2935 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2936 Input and output redirection with \">\", \"<\", or \">>\" are also \
2938 With no arguments, uses arguments last specified (with \"run\" \
2939 or \"set args\").\n\
2940 To cancel previous arguments and run with no arguments,\n\
2941 use \"set args\" without arguments."));
2942 set_cmd_completer (c, filename_completer);
2943 add_com_alias ("r", "run", class_run, 1);
2945 add_com ("R", class_run, run_no_args_command,
2946 _("Start debugged program with no arguments."));
2948 c = add_com ("start", class_run, start_command, _("\
2949 Run the debugged program until the beginning of the main procedure.\n\
2950 You may specify arguments to give to your program, just as with the\n\
2951 \"run\" command."));
2952 set_cmd_completer (c, filename_completer);
2954 add_com ("interrupt", class_run, interrupt_target_command,
2955 _("Interrupt the execution of the debugged program.\n\
2956 If non-stop mode is enabled, interrupt only the current thread,\n\
2957 otherwise all the threads in the program are stopped. To \n\
2958 interrupt all running threads in non-stop mode, use the -a option."));
2960 add_info ("registers", nofp_registers_info, _("\
2961 List of integer registers and their contents, for selected stack frame.\n\
2962 Register name as argument means describe only that register."));
2963 add_info_alias ("r", "registers", 1);
2966 add_com ("lr", class_info, nofp_registers_info, _("\
2967 List of integer registers and their contents, for selected stack frame.\n\
2968 Register name as argument means describe only that register."));
2969 add_info ("all-registers", all_registers_info, _("\
2970 List of all registers and their contents, for selected stack frame.\n\
2971 Register name as argument means describe only that register."));
2973 add_info ("program", program_info,
2974 _("Execution status of the program."));
2976 add_info ("float", float_info,
2977 _("Print the status of the floating point unit\n"));
2979 add_info ("vector", vector_info,
2980 _("Print the status of the vector unit\n"));