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 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/>. */
24 #include "gdb_string.h"
38 #include "completer.h"
40 #include "event-top.h"
41 #include "parser-defs.h"
43 #include "reggroups.h"
47 #include "gdb_assert.h"
49 #include "target-descriptions.h"
50 #include "user-regs.h"
51 #include "exceptions.h"
52 #include "cli/cli-decode.h"
53 #include "gdbthread.h"
55 #include "inline-frame.h"
57 /* Functions exported for general use, in inferior.h: */
59 void all_registers_info (char *, int);
61 void registers_info (char *, int);
63 void nexti_command (char *, int);
65 void stepi_command (char *, int);
67 void continue_command (char *, int);
69 void interrupt_target_command (char *args
, int from_tty
);
71 /* Local functions: */
73 static void nofp_registers_info (char *, int);
75 static void print_return_value (struct type
*func_type
,
76 struct type
*value_type
);
78 static void until_next_command (int);
80 static void until_command (char *, int);
82 static void path_info (char *, int);
84 static void path_command (char *, int);
86 static void unset_command (char *, int);
88 static void float_info (char *, int);
90 static void disconnect_command (char *, int);
92 static void unset_environment_command (char *, int);
94 static void set_environment_command (char *, int);
96 static void environment_info (char *, int);
98 static void program_info (char *, int);
100 static void finish_command (char *, int);
102 static void signal_command (char *, int);
104 static void jump_command (char *, int);
106 static void step_1 (int, int, char *);
107 static void step_once (int skip_subroutines
, int single_inst
, int count
, int thread
);
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 ERROR_NO_INFERIOR \
124 if (!target_has_execution) error (_("The program is not being run."));
126 /* String containing arguments to give to the program, separated by spaces.
127 Empty string (pointer to '\0') means no args. */
129 static char *inferior_args
;
131 /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
132 then we must compute INFERIOR_ARGS from this (via the target). */
134 static int inferior_argc
;
135 static char **inferior_argv
;
137 /* File name for default use for standard in/out in the inferior. */
139 static char *inferior_io_terminal
;
141 /* Pid of our debugged inferior, or 0 if no inferior now.
142 Since various parts of infrun.c test this to see whether there is a program
143 being debugged it should be nonzero (currently 3 is used) for remote
146 ptid_t inferior_ptid
;
148 /* Address at which inferior stopped. */
152 /* Flag indicating that a command has proceeded the inferior past the
153 current breakpoint. */
155 int breakpoint_proceeded
;
157 /* Nonzero if stopped due to completion of a stack dummy routine. */
159 int stop_stack_dummy
;
161 /* Nonzero if stopped due to a random (unexpected) signal in inferior
164 int stopped_by_random_signal
;
166 /* Environment to use for running inferior,
167 in format described in environ.h. */
169 struct gdb_environ
*inferior_environ
;
171 /* Accessor routines. */
174 set_inferior_io_terminal (const char *terminal_name
)
176 if (inferior_io_terminal
)
177 xfree (inferior_io_terminal
);
180 inferior_io_terminal
= NULL
;
182 inferior_io_terminal
= xstrdup (terminal_name
);
186 get_inferior_io_terminal (void)
188 return inferior_io_terminal
;
192 get_inferior_args (void)
194 if (inferior_argc
!= 0)
198 n
= construct_inferior_arguments (inferior_argc
, inferior_argv
);
199 old
= set_inferior_args (n
);
203 if (inferior_args
== NULL
)
204 inferior_args
= xstrdup ("");
206 return inferior_args
;
210 set_inferior_args (char *newargs
)
212 char *saved_args
= inferior_args
;
214 inferior_args
= newargs
;
222 set_inferior_args_vector (int argc
, char **argv
)
224 inferior_argc
= argc
;
225 inferior_argv
= argv
;
228 /* Notice when `set args' is run. */
230 notice_args_set (char *args
, int from_tty
, struct cmd_list_element
*c
)
236 /* Notice when `show args' is run. */
238 notice_args_read (struct ui_file
*file
, int from_tty
,
239 struct cmd_list_element
*c
, const char *value
)
241 /* Note that we ignore the passed-in value in favor of computing it
243 deprecated_show_value_hack (file
, from_tty
, c
, get_inferior_args ());
247 /* Compute command-line string given argument vector. This does the
248 same shell processing as fork_inferior. */
250 construct_inferior_arguments (int argc
, char **argv
)
254 if (STARTUP_WITH_SHELL
)
256 /* This holds all the characters considered special to the
257 typical Unix shells. We include `^' because the SunOS
258 /bin/sh treats it as a synonym for `|'. */
259 char *special
= "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
264 /* We over-compute the size. It shouldn't matter. */
265 for (i
= 0; i
< argc
; ++i
)
266 length
+= 3 * strlen (argv
[i
]) + 1 + 2 * (argv
[i
][0] == '\0');
268 result
= (char *) xmalloc (length
);
271 for (i
= 0; i
< argc
; ++i
)
276 /* Need to handle empty arguments specially. */
277 if (argv
[i
][0] == '\0')
284 for (cp
= argv
[i
]; *cp
; ++cp
)
288 /* A newline cannot be quoted with a backslash (it
289 just disappears), only by putting it inside
297 if (strchr (special
, *cp
) != NULL
)
308 /* In this case we can't handle arguments that contain spaces,
309 tabs, or newlines -- see breakup_args(). */
313 for (i
= 0; i
< argc
; ++i
)
315 char *cp
= strchr (argv
[i
], ' ');
317 cp
= strchr (argv
[i
], '\t');
319 cp
= strchr (argv
[i
], '\n');
321 error (_("can't handle command-line argument containing whitespace"));
322 length
+= strlen (argv
[i
]) + 1;
325 result
= (char *) xmalloc (length
);
327 for (i
= 0; i
< argc
; ++i
)
330 strcat (result
, " ");
331 strcat (result
, argv
[i
]);
339 /* This function detects whether or not a '&' character (indicating
340 background execution) has been added as *the last* of the arguments ARGS
341 of a command. If it has, it removes it and returns 1. Otherwise it
342 does nothing and returns 0. */
344 strip_bg_char (char **args
)
348 p
= strchr (*args
, '&');
352 if (p
== (*args
+ strlen (*args
) - 1))
354 if (strlen (*args
) > 1)
358 while (*p
== ' ' || *p
== '\t');
370 tty_command (char *file
, int from_tty
)
373 error_no_arg (_("terminal name for running target process"));
375 set_inferior_io_terminal (file
);
378 /* Common actions to take after creating any sort of inferior, by any
379 means (running, attaching, connecting, et cetera). The target
380 should be stopped. */
383 post_create_inferior (struct target_ops
*target
, int from_tty
)
385 /* Be sure we own the terminal in case write operations are performed. */
386 target_terminal_ours ();
388 /* If the target hasn't taken care of this already, do it now.
389 Targets which need to access registers during to_open,
390 to_create_inferior, or to_attach should do it earlier; but many
392 target_find_description ();
394 /* Now that we know the register layout, retrieve current PC. */
395 stop_pc
= regcache_read_pc (get_current_regcache ());
397 /* If the solist is global across processes, there's no need to
399 if (exec_bfd
&& !gdbarch_has_global_solist (target_gdbarch
))
401 /* Sometimes the platform-specific hook loads initial shared
402 libraries, and sometimes it doesn't. Try to do so first, so
403 that we can add them with the correct value for FROM_TTY.
404 If we made all the inferior hook methods consistent,
405 this call could be removed. */
407 SOLIB_ADD (NULL
, from_tty
, target
, auto_solib_add
);
409 solib_add (NULL
, from_tty
, target
, auto_solib_add
);
415 /* Create the hooks to handle shared library load and unload
417 #ifdef SOLIB_CREATE_INFERIOR_HOOK
418 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid
));
420 solib_create_inferior_hook ();
424 /* If the user sets watchpoints before execution having started,
425 then she gets software watchpoints, because GDB can't know which
426 target will end up being pushed, or if it supports hardware
427 watchpoints or not. breakpoint_re_set takes care of promoting
428 watchpoints to hardware watchpoints if possible, however, if this
429 new inferior doesn't load shared libraries or we don't pull in
430 symbols from any other source on this target/arch,
431 breakpoint_re_set is never called. Call it now so that software
432 watchpoints get a chance to be promoted to hardware watchpoints
433 if the now pushed target supports hardware watchpoints. */
434 breakpoint_re_set ();
436 observer_notify_inferior_created (target
, from_tty
);
439 /* Kill the inferior if already running. This function is designed
440 to be called when we are about to start the execution of the program
441 from the beginning. Ask the user to confirm that he wants to restart
442 the program being debugged when FROM_TTY is non-null. */
445 kill_if_already_running (int from_tty
)
447 if (! ptid_equal (inferior_ptid
, null_ptid
) && target_has_execution
)
449 /* Bail out before killing the program if we will not be able to
451 target_require_runnable ();
454 && !query (_("The program being debugged has been started already.\n\
455 Start it from the beginning? ")))
456 error (_("Program not restarted."));
461 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
462 a temporary breakpoint at the begining of the main program before
463 running the program. */
466 run_command_1 (char *args
, int from_tty
, int tbreak_at_main
)
469 struct cleanup
*old_chain
;
474 kill_if_already_running (from_tty
);
476 init_wait_for_inferior ();
477 clear_breakpoint_hit_counts ();
479 /* Clean up any leftovers from other runs. Some other things from
480 this function should probably be moved into target_pre_inferior. */
481 target_pre_inferior (from_tty
);
483 /* The comment here used to read, "The exec file is re-read every
484 time we do a generic_mourn_inferior, so we just have to worry
485 about the symbol file." The `generic_mourn_inferior' function
486 gets called whenever the program exits. However, suppose the
487 program exits, and *then* the executable file changes? We need
488 to check again here. Since reopen_exec_file doesn't do anything
489 if the timestamp hasn't changed, I don't see the harm. */
493 /* Insert the temporary breakpoint if a location was specified. */
495 tbreak_command (main_name (), 0);
497 exec_file
= (char *) get_exec_file (0);
499 if (non_stop
&& !target_supports_non_stop ())
500 error (_("The target does not support running in non-stop mode."));
502 /* We keep symbols from add-symbol-file, on the grounds that the
503 user might want to add some symbols before running the program
504 (right?). But sometimes (dynamic loading where the user manually
505 introduces the new symbols with add-symbol-file), the code which
506 the symbols describe does not persist between runs. Currently
507 the user has to manually nuke all symbols between runs if they
508 want them to go away (PR 2207). This is probably reasonable. */
512 if (target_can_async_p ())
513 async_disable_stdin ();
517 int async_exec
= strip_bg_char (&args
);
519 /* If we get a request for running in the bg but the target
520 doesn't support it, error out. */
521 if (async_exec
&& !target_can_async_p ())
522 error (_("Asynchronous execution not supported on this target."));
524 /* If we don't get a request of running in the bg, then we need
525 to simulate synchronous (fg) execution. */
526 if (!async_exec
&& target_can_async_p ())
528 /* Simulate synchronous execution */
529 async_disable_stdin ();
532 /* If there were other args, beside '&', process them. */
535 char *old_args
= set_inferior_args (xstrdup (args
));
542 ui_out_field_string (uiout
, NULL
, "Starting program");
543 ui_out_text (uiout
, ": ");
545 ui_out_field_string (uiout
, "execfile", exec_file
);
546 ui_out_spaces (uiout
, 1);
547 /* We call get_inferior_args() because we might need to compute
549 ui_out_field_string (uiout
, "infargs", get_inferior_args ());
550 ui_out_text (uiout
, "\n");
551 ui_out_flush (uiout
);
554 /* We call get_inferior_args() because we might need to compute
556 target_create_inferior (exec_file
, get_inferior_args (),
557 environ_vector (inferior_environ
), from_tty
);
559 /* We're starting off a new process. When we get out of here, in
560 non-stop mode, finish the state of all threads of that process,
561 but leave other threads alone, as they may be stopped in internal
562 events --- the frontend shouldn't see them as stopped. In
563 all-stop, always finish the state of all threads, as we may be
564 resuming more than just the new process. */
566 ptid
= pid_to_ptid (ptid_get_pid (inferior_ptid
));
568 ptid
= minus_one_ptid
;
569 old_chain
= make_cleanup (finish_thread_state_cleanup
, &ptid
);
571 /* Pass zero for FROM_TTY, because at this point the "run" command
572 has done its thing; now we are setting up the running program. */
573 post_create_inferior (¤t_target
, 0);
575 /* Start the target running. */
576 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_0
, 0);
578 /* Since there was no error, there's no need to finish the thread
580 discard_cleanups (old_chain
);
584 run_command (char *args
, int from_tty
)
586 run_command_1 (args
, from_tty
, 0);
590 run_no_args_command (char *args
, int from_tty
)
592 char *old_args
= set_inferior_args (xstrdup (""));
597 /* Start the execution of the program up until the beginning of the main
601 start_command (char *args
, int from_tty
)
603 /* Some languages such as Ada need to search inside the program
604 minimal symbols for the location where to put the temporary
605 breakpoint before starting. */
606 if (!have_minimal_symbols ())
607 error (_("No symbol table loaded. Use the \"file\" command."));
609 /* Run the program until reaching the main procedure... */
610 run_command_1 (args
, from_tty
, 1);
614 proceed_thread_callback (struct thread_info
*thread
, void *arg
)
616 /* We go through all threads individually instead of compressing
617 into a single target `resume_all' request, because some threads
618 may be stopped in internal breakpoints/events, or stopped waiting
619 for its turn in the displaced stepping queue (that is, they are
620 running && !executing). The target side has no idea about why
621 the thread is stopped, so a `resume_all' command would resume too
622 much. If/when GDB gains a way to tell the target `hold this
623 thread stopped until I say otherwise', then we can optimize
625 if (!is_stopped (thread
->ptid
))
628 switch_to_thread (thread
->ptid
);
629 clear_proceed_status ();
630 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
635 ensure_valid_thread (void)
637 if (ptid_equal (inferior_ptid
, null_ptid
)
638 || is_exited (inferior_ptid
))
640 Cannot execute this command without a live selected thread."));
644 continue_1 (int all_threads
)
648 if (non_stop
&& all_threads
)
650 /* Don't error out if the current thread is running, because
651 there may be other stopped threads. */
652 struct cleanup
*old_chain
;
654 /* Backup current thread and selected frame. */
655 old_chain
= make_cleanup_restore_current_thread ();
657 iterate_over_threads (proceed_thread_callback
, NULL
);
659 /* Restore selected ptid. */
660 do_cleanups (old_chain
);
664 ensure_valid_thread ();
665 ensure_not_running ();
666 clear_proceed_status ();
667 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
671 /* continue [-a] [proceed-count] [&] */
673 continue_command (char *args
, int from_tty
)
679 /* Find out whether we must run in the background. */
681 async_exec
= strip_bg_char (&args
);
683 /* If we must run in the background, but the target can't do it,
685 if (async_exec
&& !target_can_async_p ())
686 error (_("Asynchronous execution not supported on this target."));
688 /* If we are not asked to run in the bg, then prepare to run in the
689 foreground, synchronously. */
690 if (!async_exec
&& target_can_async_p ())
692 /* Simulate synchronous execution */
693 async_disable_stdin ();
698 if (strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
701 args
+= sizeof ("-a") - 1;
707 if (!non_stop
&& all_threads
)
708 error (_("`-a' is meaningless in all-stop mode."));
710 if (args
!= NULL
&& all_threads
)
712 Can't resume all threads and specify proceed count simultaneously."));
714 /* If we have an argument left, set proceed count of breakpoint we
721 struct thread_info
*tp
;
724 tp
= find_thread_ptid (inferior_ptid
);
728 struct target_waitstatus ws
;
730 get_last_target_status (&last_ptid
, &ws
);
731 tp
= find_thread_ptid (last_ptid
);
734 bs
= tp
->stop_bpstat
;
736 while ((stat
= bpstat_num (&bs
, &num
)) != 0)
739 set_ignore_count (num
,
740 parse_and_eval_long (args
) - 1,
742 /* set_ignore_count prints a message ending with a period.
743 So print two spaces before "Continuing.". */
745 printf_filtered (" ");
749 if (!stopped
&& from_tty
)
752 ("Not stopped at any breakpoint; argument ignored.\n");
757 printf_filtered (_("Continuing.\n"));
759 continue_1 (all_threads
);
762 /* Record the starting point of a "step" or "next" command. */
765 set_step_frame (void)
767 struct symtab_and_line sal
;
769 find_frame_sal (get_current_frame (), &sal
);
770 set_step_info (get_current_frame (), sal
);
773 /* Step until outside of current statement. */
776 step_command (char *count_string
, int from_tty
)
778 step_1 (0, 0, count_string
);
781 /* Likewise, but skip over subroutine calls as if single instructions. */
784 next_command (char *count_string
, int from_tty
)
786 step_1 (1, 0, count_string
);
789 /* Likewise, but step only one instruction. */
792 stepi_command (char *count_string
, int from_tty
)
794 step_1 (0, 1, count_string
);
798 nexti_command (char *count_string
, int from_tty
)
800 step_1 (1, 1, count_string
);
804 delete_longjmp_breakpoint_cleanup (void *arg
)
806 int thread
= * (int *) arg
;
807 delete_longjmp_breakpoint (thread
);
811 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
814 struct frame_info
*frame
;
815 struct cleanup
*cleanups
= make_cleanup (null_cleanup
, NULL
);
820 ensure_valid_thread ();
821 ensure_not_running ();
824 async_exec
= strip_bg_char (&count_string
);
826 /* If we get a request for running in the bg but the target
827 doesn't support it, error out. */
828 if (async_exec
&& !target_can_async_p ())
829 error (_("Asynchronous execution not supported on this target."));
831 /* If we don't get a request of running in the bg, then we need
832 to simulate synchronous (fg) execution. */
833 if (!async_exec
&& target_can_async_p ())
835 /* Simulate synchronous execution */
836 async_disable_stdin ();
839 count
= count_string
? parse_and_eval_long (count_string
) : 1;
841 if (!single_inst
|| skip_subroutines
) /* leave si command alone */
843 if (in_thread_list (inferior_ptid
))
844 thread
= pid_to_thread_id (inferior_ptid
);
846 set_longjmp_breakpoint (thread
);
848 make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
851 /* In synchronous case, all is well; each step_once call will step once. */
852 if (!target_can_async_p ())
854 for (; count
> 0; count
--)
856 struct thread_info
*tp
;
857 step_once (skip_subroutines
, single_inst
, count
, thread
);
859 if (target_has_execution
860 && !ptid_equal (inferior_ptid
, null_ptid
))
861 tp
= inferior_thread ();
865 if (!tp
|| !tp
->stop_step
|| !tp
->step_multi
)
867 /* If we stopped for some reason that is not stepping
868 there are no further steps to make. */
875 do_cleanups (cleanups
);
879 /* In the case of an asynchronous target things get complicated;
880 do only one step for now, before returning control to the
881 event loop. Let the continuation figure out how many other
882 steps we need to do, and handle them one at the time, through
884 step_once (skip_subroutines
, single_inst
, count
, thread
);
886 /* We are running, and the continuation is installed. It will
887 disable the longjmp breakpoint as appropriate. */
888 discard_cleanups (cleanups
);
892 struct step_1_continuation_args
895 int skip_subroutines
;
900 /* Called after we are done with one step operation, to check whether
901 we need to step again, before we print the prompt and return control
902 to the user. If count is > 1, we will need to do one more call to
903 proceed(), via step_once(). Basically it is like step_once and
904 step_1_continuation are co-recursive. */
906 step_1_continuation (void *args
)
908 struct step_1_continuation_args
*a
= args
;
910 if (target_has_execution
)
912 struct thread_info
*tp
;
914 tp
= inferior_thread ();
915 if (tp
->step_multi
&& tp
->stop_step
)
917 /* There are more steps to make, and we did stop due to
918 ending a stepping range. Do another step. */
919 step_once (a
->skip_subroutines
, a
->single_inst
,
920 a
->count
- 1, a
->thread
);
926 /* We either stopped for some reason that is not stepping, or there
927 are no further steps to make. Cleanup. */
928 if (!a
->single_inst
|| a
->skip_subroutines
)
929 delete_longjmp_breakpoint (a
->thread
);
932 /* Do just one step operation. This is useful to implement the 'step
933 n' kind of commands. In case of asynchronous targets, we will have
934 to set up a continuation to be done after the target stops (after
935 this one step). For synch targets, the caller handles further
939 step_once (int skip_subroutines
, int single_inst
, int count
, int thread
)
941 struct frame_info
*frame
= get_current_frame ();
945 /* Don't assume THREAD is a valid thread id. It is set to -1 if
946 the longjmp breakpoint was not required. Use the
947 INFERIOR_PTID thread instead, which is the same thread when
949 struct thread_info
*tp
= inferior_thread ();
950 clear_proceed_status ();
957 /* Step at an inlined function behaves like "down". */
958 if (!skip_subroutines
&& !single_inst
959 && inline_skipped_frames (inferior_ptid
))
961 step_into_inline_frame (inferior_ptid
);
963 step_once (skip_subroutines
, single_inst
, count
- 1, thread
);
965 /* Pretend that we've stopped. */
970 pc
= get_frame_pc (frame
);
971 find_pc_line_pc_range (pc
,
972 &tp
->step_range_start
, &tp
->step_range_end
);
974 /* If we have no line info, switch to stepi mode. */
975 if (tp
->step_range_end
== 0 && step_stop_if_no_debug
)
976 tp
->step_range_start
= tp
->step_range_end
= 1;
977 else if (tp
->step_range_end
== 0)
980 if (find_pc_partial_function (pc
, &name
,
981 &tp
->step_range_start
,
982 &tp
->step_range_end
) == 0)
983 error (_("Cannot find bounds of current function"));
985 target_terminal_ours ();
986 printf_filtered (_("\
987 Single stepping until exit from function %s, \n\
988 which has no line number information.\n"), name
);
993 /* Say we are stepping, but stop after one insn whatever it does. */
994 tp
->step_range_start
= tp
->step_range_end
= 1;
995 if (!skip_subroutines
)
997 Don't step over function calls, not even to functions lacking
999 tp
->step_over_calls
= STEP_OVER_NONE
;
1002 if (skip_subroutines
)
1003 tp
->step_over_calls
= STEP_OVER_ALL
;
1005 tp
->step_multi
= (count
> 1);
1006 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1008 /* For async targets, register a continuation to do any
1009 additional steps. For sync targets, the caller will handle
1010 further stepping. */
1011 if (target_can_async_p ())
1013 struct step_1_continuation_args
*args
;
1015 args
= xmalloc (sizeof (*args
));
1016 args
->skip_subroutines
= skip_subroutines
;
1017 args
->single_inst
= single_inst
;
1018 args
->count
= count
;
1019 args
->thread
= thread
;
1021 add_intermediate_continuation (tp
, step_1_continuation
, args
, xfree
);
1027 /* Continue program at specified address. */
1030 jump_command (char *arg
, int from_tty
)
1033 struct symtabs_and_lines sals
;
1034 struct symtab_and_line sal
;
1040 ensure_valid_thread ();
1041 ensure_not_running ();
1043 /* Find out whether we must run in the background. */
1045 async_exec
= strip_bg_char (&arg
);
1047 /* If we must run in the background, but the target can't do it,
1049 if (async_exec
&& !target_can_async_p ())
1050 error (_("Asynchronous execution not supported on this target."));
1053 error_no_arg (_("starting address"));
1055 sals
= decode_line_spec_1 (arg
, 1);
1056 if (sals
.nelts
!= 1)
1058 error (_("Unreasonable jump request"));
1064 if (sal
.symtab
== 0 && sal
.pc
== 0)
1065 error (_("No source file has been specified."));
1067 resolve_sal_pc (&sal
); /* May error out */
1069 /* See if we are trying to jump to another function. */
1070 fn
= get_frame_function (get_current_frame ());
1071 sfn
= find_pc_function (sal
.pc
);
1072 if (fn
!= NULL
&& sfn
!= fn
)
1074 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal
.line
,
1075 SYMBOL_PRINT_NAME (fn
)))
1077 error (_("Not confirmed."));
1084 fixup_symbol_section (sfn
, 0);
1085 if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn
)) &&
1086 !section_is_mapped (SYMBOL_OBJ_SECTION (sfn
)))
1088 if (!query (_("WARNING!!! Destination is in unmapped overlay! Jump anyway? ")))
1090 error (_("Not confirmed."));
1100 printf_filtered (_("Continuing at "));
1101 fputs_filtered (paddress (addr
), gdb_stdout
);
1102 printf_filtered (".\n");
1105 /* If we are not asked to run in the bg, then prepare to run in the
1106 foreground, synchronously. */
1107 if (!async_exec
&& target_can_async_p ())
1109 /* Simulate synchronous execution */
1110 async_disable_stdin ();
1113 clear_proceed_status ();
1114 proceed (addr
, TARGET_SIGNAL_0
, 0);
1118 /* Go to line or address in current procedure */
1120 go_command (char *line_no
, int from_tty
)
1122 if (line_no
== (char *) NULL
|| !*line_no
)
1123 printf_filtered (_("Usage: go <location>\n"));
1126 tbreak_command (line_no
, from_tty
);
1127 jump_command (line_no
, from_tty
);
1132 /* Continue program giving it specified signal. */
1135 signal_command (char *signum_exp
, int from_tty
)
1137 enum target_signal oursig
;
1140 dont_repeat (); /* Too dangerous. */
1142 ensure_valid_thread ();
1143 ensure_not_running ();
1145 /* Find out whether we must run in the background. */
1146 if (signum_exp
!= NULL
)
1147 async_exec
= strip_bg_char (&signum_exp
);
1149 /* If we must run in the background, but the target can't do it,
1151 if (async_exec
&& !target_can_async_p ())
1152 error (_("Asynchronous execution not supported on this target."));
1154 /* If we are not asked to run in the bg, then prepare to run in the
1155 foreground, synchronously. */
1156 if (!async_exec
&& target_can_async_p ())
1158 /* Simulate synchronous execution. */
1159 async_disable_stdin ();
1163 error_no_arg (_("signal number"));
1165 /* It would be even slicker to make signal names be valid expressions,
1166 (the type could be "enum $signal" or some such), then the user could
1167 assign them to convenience variables. */
1168 oursig
= target_signal_from_name (signum_exp
);
1170 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
1172 /* No, try numeric. */
1173 int num
= parse_and_eval_long (signum_exp
);
1176 oursig
= TARGET_SIGNAL_0
;
1178 oursig
= target_signal_from_command (num
);
1183 if (oursig
== TARGET_SIGNAL_0
)
1184 printf_filtered (_("Continuing with no signal.\n"));
1186 printf_filtered (_("Continuing with signal %s.\n"),
1187 target_signal_to_name (oursig
));
1190 clear_proceed_status ();
1191 proceed ((CORE_ADDR
) -1, oursig
, 0);
1194 /* Proceed until we reach a different source line with pc greater than
1195 our current one or exit the function. We skip calls in both cases.
1197 Note that eventually this command should probably be changed so
1198 that only source lines are printed out when we hit the breakpoint
1199 we set. This may involve changes to wait_for_inferior and the
1200 proceed status code. */
1203 until_next_command (int from_tty
)
1205 struct frame_info
*frame
;
1207 struct symbol
*func
;
1208 struct symtab_and_line sal
;
1209 struct thread_info
*tp
= inferior_thread ();
1211 clear_proceed_status ();
1214 frame
= get_current_frame ();
1216 /* Step until either exited from this function or greater
1217 than the current line (if in symbolic section) or pc (if
1220 pc
= get_frame_pc (frame
);
1221 func
= find_pc_function (pc
);
1225 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
1227 if (msymbol
== NULL
)
1228 error (_("Execution is not within a known function."));
1230 tp
->step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
1231 tp
->step_range_end
= pc
;
1235 sal
= find_pc_line (pc
, 0);
1237 tp
->step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
1238 tp
->step_range_end
= sal
.end
;
1241 tp
->step_over_calls
= STEP_OVER_ALL
;
1243 tp
->step_multi
= 0; /* Only one call to proceed */
1245 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1249 until_command (char *arg
, int from_tty
)
1253 if (!target_has_execution
)
1254 error (_("The program is not running."));
1256 /* Find out whether we must run in the background. */
1258 async_exec
= strip_bg_char (&arg
);
1260 /* If we must run in the background, but the target can't do it,
1262 if (async_exec
&& !target_can_async_p ())
1263 error (_("Asynchronous execution not supported on this target."));
1265 /* If we are not asked to run in the bg, then prepare to run in the
1266 foreground, synchronously. */
1267 if (!async_exec
&& target_can_async_p ())
1269 /* Simulate synchronous execution */
1270 async_disable_stdin ();
1274 until_break_command (arg
, from_tty
, 0);
1276 until_next_command (from_tty
);
1280 advance_command (char *arg
, int from_tty
)
1284 if (!target_has_execution
)
1285 error (_("The program is not running."));
1288 error_no_arg (_("a location"));
1290 /* Find out whether we must run in the background. */
1292 async_exec
= strip_bg_char (&arg
);
1294 /* If we must run in the background, but the target can't do it,
1296 if (async_exec
&& !target_can_async_p ())
1297 error (_("Asynchronous execution not supported on this target."));
1299 /* If we are not asked to run in the bg, then prepare to run in the
1300 foreground, synchronously. */
1301 if (!async_exec
&& target_can_async_p ())
1303 /* Simulate synchronous execution. */
1304 async_disable_stdin ();
1307 until_break_command (arg
, from_tty
, 1);
1310 /* Print the result of a function at the end of a 'finish' command. */
1313 print_return_value (struct type
*func_type
, struct type
*value_type
)
1315 struct gdbarch
*gdbarch
= get_regcache_arch (stop_registers
);
1316 struct cleanup
*old_chain
;
1317 struct ui_stream
*stb
;
1318 struct value
*value
;
1320 CHECK_TYPEDEF (value_type
);
1321 gdb_assert (TYPE_CODE (value_type
) != TYPE_CODE_VOID
);
1323 /* FIXME: 2003-09-27: When returning from a nested inferior function
1324 call, it's possible (with no help from the architecture vector)
1325 to locate and return/print a "struct return" value. This is just
1326 a more complicated case of what is already being done in in the
1327 inferior function call code. In fact, when inferior function
1328 calls are made async, this will likely be made the norm. */
1330 switch (gdbarch_return_value (gdbarch
, func_type
, value_type
,
1333 case RETURN_VALUE_REGISTER_CONVENTION
:
1334 case RETURN_VALUE_ABI_RETURNS_ADDRESS
:
1335 case RETURN_VALUE_ABI_PRESERVES_ADDRESS
:
1336 value
= allocate_value (value_type
);
1337 gdbarch_return_value (gdbarch
, func_type
, value_type
, stop_registers
,
1338 value_contents_raw (value
), NULL
);
1340 case RETURN_VALUE_STRUCT_CONVENTION
:
1344 internal_error (__FILE__
, __LINE__
, _("bad switch"));
1349 struct value_print_options opts
;
1352 stb
= ui_out_stream_new (uiout
);
1353 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
1354 ui_out_text (uiout
, "Value returned is ");
1355 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d",
1356 record_latest_value (value
));
1357 ui_out_text (uiout
, " = ");
1358 get_raw_print_options (&opts
);
1359 value_print (value
, stb
->stream
, &opts
);
1360 ui_out_field_stream (uiout
, "return-value", stb
);
1361 ui_out_text (uiout
, "\n");
1362 do_cleanups (old_chain
);
1366 ui_out_text (uiout
, "Value returned has type: ");
1367 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1368 ui_out_text (uiout
, ".");
1369 ui_out_text (uiout
, " Cannot determine contents\n");
1373 /* Stuff that needs to be done by the finish command after the target
1374 has stopped. In asynchronous mode, we wait for the target to stop
1375 in the call to poll or select in the event loop, so it is
1376 impossible to do all the stuff as part of the finish_command
1377 function itself. The only chance we have to complete this command
1378 is in fetch_inferior_event, which is called by the event loop as
1379 soon as it detects that the target has stopped. This function is
1380 called via the cmd_continuation pointer. */
1382 struct finish_command_continuation_args
1384 struct breakpoint
*breakpoint
;
1385 struct symbol
*function
;
1389 finish_command_continuation (void *arg
)
1391 struct finish_command_continuation_args
*a
= arg
;
1392 struct thread_info
*tp
= NULL
;
1395 if (!ptid_equal (inferior_ptid
, null_ptid
)
1396 && target_has_execution
1397 && is_stopped (inferior_ptid
))
1399 tp
= inferior_thread ();
1400 bs
= tp
->stop_bpstat
;
1403 if (bpstat_find_breakpoint (bs
, a
->breakpoint
) != NULL
1404 && a
->function
!= NULL
)
1406 struct type
*value_type
;
1408 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (a
->function
));
1410 internal_error (__FILE__
, __LINE__
,
1411 _("finish_command: function has no target type"));
1413 if (TYPE_CODE (value_type
) != TYPE_CODE_VOID
)
1414 print_return_value (SYMBOL_TYPE (a
->function
), value_type
);
1417 /* We suppress normal call of normal_stop observer and do it here so
1418 that the *stopped notification includes the return value. */
1419 if (bs
!= NULL
&& tp
->proceed_to_finish
)
1420 observer_notify_normal_stop (bs
, 1 /* print frame */);
1421 delete_breakpoint (a
->breakpoint
);
1425 finish_command_continuation_free_arg (void *arg
)
1430 /* finish_backward -- helper function for finish_command. */
1433 finish_backward (struct symbol
*function
)
1435 struct symtab_and_line sal
;
1436 struct thread_info
*tp
= inferior_thread ();
1437 struct breakpoint
*breakpoint
;
1438 struct cleanup
*old_chain
;
1440 CORE_ADDR func_addr
;
1443 pc
= get_frame_pc (get_current_frame ());
1445 if (find_pc_partial_function (pc
, NULL
, &func_addr
, NULL
) == 0)
1446 internal_error (__FILE__
, __LINE__
,
1447 _("Finish: couldn't find function."));
1449 sal
= find_pc_line (func_addr
, 0);
1451 /* We don't need a return value. */
1452 tp
->proceed_to_finish
= 0;
1453 /* Special case: if we're sitting at the function entry point,
1454 then all we need to do is take a reverse singlestep. We
1455 don't need to set a breakpoint, and indeed it would do us
1458 Note that this can only happen at frame #0, since there's
1459 no way that a function up the stack can have a return address
1460 that's equal to its entry point. */
1464 struct frame_info
*frame
= get_selected_frame (NULL
);
1465 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1467 /* Set breakpoint and continue. */
1469 set_momentary_breakpoint (gdbarch
, sal
,
1470 get_stack_frame_id (frame
),
1472 /* Tell the breakpoint to keep quiet. We won't be done
1473 until we've done another reverse single-step. */
1474 make_breakpoint_silent (breakpoint
);
1475 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1476 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1477 /* We will be stopped when proceed returns. */
1478 back_up
= bpstat_find_breakpoint (tp
->stop_bpstat
, breakpoint
) != NULL
;
1479 do_cleanups (old_chain
);
1485 /* If in fact we hit the step-resume breakpoint (and not
1486 some other breakpoint), then we're almost there --
1487 we just need to back up by one more single-step. */
1488 tp
->step_range_start
= tp
->step_range_end
= 1;
1489 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1494 /* finish_forward -- helper function for finish_command. */
1497 finish_forward (struct symbol
*function
, struct frame_info
*frame
)
1499 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1500 struct symtab_and_line sal
;
1501 struct thread_info
*tp
= inferior_thread ();
1502 struct breakpoint
*breakpoint
;
1503 struct cleanup
*old_chain
;
1504 struct finish_command_continuation_args
*cargs
;
1506 sal
= find_pc_line (get_frame_pc (frame
), 0);
1507 sal
.pc
= get_frame_pc (frame
);
1509 breakpoint
= set_momentary_breakpoint (gdbarch
, sal
,
1510 get_stack_frame_id (frame
),
1513 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1515 tp
->proceed_to_finish
= 1; /* We want stop_registers, please... */
1516 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1518 cargs
= xmalloc (sizeof (*cargs
));
1520 cargs
->breakpoint
= breakpoint
;
1521 cargs
->function
= function
;
1522 add_continuation (tp
, finish_command_continuation
, cargs
,
1523 finish_command_continuation_free_arg
);
1525 discard_cleanups (old_chain
);
1526 if (!target_can_async_p ())
1527 do_all_continuations ();
1530 /* "finish": Set a temporary breakpoint at the place the selected
1531 frame will return to, then continue. */
1534 finish_command (char *arg
, int from_tty
)
1536 struct frame_info
*frame
;
1537 struct symbol
*function
;
1541 /* Find out whether we must run in the background. */
1543 async_exec
= strip_bg_char (&arg
);
1545 /* If we must run in the background, but the target can't do it,
1547 if (async_exec
&& !target_can_async_p ())
1548 error (_("Asynchronous execution not supported on this target."));
1550 /* Don't try to async in reverse. */
1551 if (async_exec
&& execution_direction
== EXEC_REVERSE
)
1552 error (_("Asynchronous 'finish' not supported in reverse."));
1554 /* If we are not asked to run in the bg, then prepare to run in the
1555 foreground, synchronously. */
1556 if (!async_exec
&& target_can_async_p ())
1558 /* Simulate synchronous execution. */
1559 async_disable_stdin ();
1563 error (_("The \"finish\" command does not take any arguments."));
1564 if (!target_has_execution
)
1565 error (_("The program is not running."));
1567 frame
= get_prev_frame (get_selected_frame (_("No selected frame.")));
1569 error (_("\"finish\" not meaningful in the outermost frame."));
1571 clear_proceed_status ();
1573 /* Finishing from an inline frame is completely different. We don't
1574 try to show the "return value" - no way to locate it. So we do
1575 not need a completion. */
1576 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1579 /* Claim we are stepping in the calling frame. An empty step
1580 range means that we will stop once we aren't in a function
1581 called by that frame. We don't use the magic "1" value for
1582 step_range_end, because then infrun will think this is nexti,
1583 and not step over the rest of this inlined function call. */
1584 struct thread_info
*tp
= inferior_thread ();
1585 struct symtab_and_line empty_sal
;
1586 init_sal (&empty_sal
);
1587 set_step_info (frame
, empty_sal
);
1588 tp
->step_range_start
= tp
->step_range_end
= get_frame_pc (frame
);
1589 tp
->step_over_calls
= STEP_OVER_ALL
;
1591 /* Print info on the selected frame, including level number but not
1595 printf_filtered (_("Run till exit from "));
1596 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1599 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1603 /* Find the function we will return from. */
1605 function
= find_pc_function (get_frame_pc (get_selected_frame (NULL
)));
1607 /* Print info on the selected frame, including level number but not
1611 if (execution_direction
== EXEC_REVERSE
)
1612 printf_filtered (_("Run back to call of "));
1614 printf_filtered (_("Run till exit from "));
1616 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1619 if (execution_direction
== EXEC_REVERSE
)
1620 finish_backward (function
);
1622 finish_forward (function
, frame
);
1627 program_info (char *args
, int from_tty
)
1631 struct thread_info
*tp
;
1634 if (!target_has_execution
)
1636 printf_filtered (_("The program being debugged is not being run.\n"));
1641 ptid
= inferior_ptid
;
1644 struct target_waitstatus ws
;
1645 get_last_target_status (&ptid
, &ws
);
1648 if (ptid_equal (ptid
, null_ptid
) || is_exited (ptid
))
1649 error (_("Invalid selected thread."));
1650 else if (is_running (ptid
))
1651 error (_("Selected thread is running."));
1653 tp
= find_thread_ptid (ptid
);
1654 bs
= tp
->stop_bpstat
;
1655 stat
= bpstat_num (&bs
, &num
);
1657 target_files_info ();
1658 printf_filtered (_("Program stopped at %s.\n"), paddress (stop_pc
));
1660 printf_filtered (_("It stopped after being stepped.\n"));
1663 /* There may be several breakpoints in the same place, so this
1664 isn't as strange as it seems. */
1669 printf_filtered (_("\
1670 It stopped at a breakpoint that has since been deleted.\n"));
1673 printf_filtered (_("It stopped at breakpoint %d.\n"), num
);
1674 stat
= bpstat_num (&bs
, &num
);
1677 else if (tp
->stop_signal
!= TARGET_SIGNAL_0
)
1679 printf_filtered (_("It stopped with signal %s, %s.\n"),
1680 target_signal_to_name (tp
->stop_signal
),
1681 target_signal_to_string (tp
->stop_signal
));
1686 printf_filtered (_("\
1687 Type \"info stack\" or \"info registers\" for more information.\n"));
1692 environment_info (char *var
, int from_tty
)
1696 char *val
= get_in_environ (inferior_environ
, var
);
1699 puts_filtered (var
);
1700 puts_filtered (" = ");
1701 puts_filtered (val
);
1702 puts_filtered ("\n");
1706 puts_filtered ("Environment variable \"");
1707 puts_filtered (var
);
1708 puts_filtered ("\" not defined.\n");
1713 char **vector
= environ_vector (inferior_environ
);
1716 puts_filtered (*vector
++);
1717 puts_filtered ("\n");
1723 set_environment_command (char *arg
, int from_tty
)
1725 char *p
, *val
, *var
;
1729 error_no_arg (_("environment variable and value"));
1731 /* Find seperation between variable name and value */
1732 p
= (char *) strchr (arg
, '=');
1733 val
= (char *) strchr (arg
, ' ');
1735 if (p
!= 0 && val
!= 0)
1737 /* We have both a space and an equals. If the space is before the
1738 equals, walk forward over the spaces til we see a nonspace
1739 (possibly the equals). */
1744 /* Now if the = is after the char following the spaces,
1745 take the char following the spaces. */
1749 else if (val
!= 0 && p
== 0)
1753 error_no_arg (_("environment variable to set"));
1755 if (p
== 0 || p
[1] == 0)
1759 p
= arg
+ strlen (arg
); /* So that savestring below will work */
1763 /* Not setting variable value to null */
1765 while (*val
== ' ' || *val
== '\t')
1769 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1772 var
= savestring (arg
, p
- arg
);
1775 printf_filtered (_("\
1776 Setting environment variable \"%s\" to null value.\n"),
1778 set_in_environ (inferior_environ
, var
, "");
1781 set_in_environ (inferior_environ
, var
, val
);
1786 unset_environment_command (char *var
, int from_tty
)
1790 /* If there is no argument, delete all environment variables.
1791 Ask for confirmation if reading from the terminal. */
1792 if (!from_tty
|| query (_("Delete all environment variables? ")))
1794 free_environ (inferior_environ
);
1795 inferior_environ
= make_environ ();
1799 unset_in_environ (inferior_environ
, var
);
1802 /* Handle the execution path (PATH variable) */
1804 static const char path_var_name
[] = "PATH";
1807 path_info (char *args
, int from_tty
)
1809 puts_filtered ("Executable and object file path: ");
1810 puts_filtered (get_in_environ (inferior_environ
, path_var_name
));
1811 puts_filtered ("\n");
1814 /* Add zero or more directories to the front of the execution path. */
1817 path_command (char *dirname
, int from_tty
)
1822 env
= get_in_environ (inferior_environ
, path_var_name
);
1823 /* Can be null if path is not set */
1826 exec_path
= xstrdup (env
);
1827 mod_path (dirname
, &exec_path
);
1828 set_in_environ (inferior_environ
, path_var_name
, exec_path
);
1831 path_info ((char *) NULL
, from_tty
);
1835 /* Print out the machine register regnum. If regnum is -1, print all
1836 registers (print_all == 1) or all non-float and non-vector
1837 registers (print_all == 0).
1839 For most machines, having all_registers_info() print the
1840 register(s) one per line is good enough. If a different format is
1841 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1842 regs), or there is an existing convention for showing all the
1843 registers, define the architecture method PRINT_REGISTERS_INFO to
1844 provide that format. */
1847 default_print_registers_info (struct gdbarch
*gdbarch
,
1848 struct ui_file
*file
,
1849 struct frame_info
*frame
,
1850 int regnum
, int print_all
)
1853 const int numregs
= gdbarch_num_regs (gdbarch
)
1854 + gdbarch_num_pseudo_regs (gdbarch
);
1855 gdb_byte buffer
[MAX_REGISTER_SIZE
];
1857 for (i
= 0; i
< numregs
; i
++)
1859 /* Decide between printing all regs, non-float / vector regs, or
1865 if (!gdbarch_register_reggroup_p (gdbarch
, i
, all_reggroup
))
1870 if (!gdbarch_register_reggroup_p (gdbarch
, i
, general_reggroup
))
1880 /* If the register name is empty, it is undefined for this
1881 processor, so don't display anything. */
1882 if (gdbarch_register_name (gdbarch
, i
) == NULL
1883 || *(gdbarch_register_name (gdbarch
, i
)) == '\0')
1886 fputs_filtered (gdbarch_register_name (gdbarch
, i
), file
);
1887 print_spaces_filtered (15 - strlen (gdbarch_register_name
1888 (gdbarch
, i
)), file
);
1890 /* Get the data in raw format. */
1891 if (! frame_register_read (frame
, i
, buffer
))
1893 fprintf_filtered (file
, "*value not available*\n");
1897 /* If virtual format is floating, print it that way, and in raw
1899 if (TYPE_CODE (register_type (gdbarch
, i
)) == TYPE_CODE_FLT
1900 || TYPE_CODE (register_type (gdbarch
, i
)) == TYPE_CODE_DECFLOAT
)
1903 struct value_print_options opts
;
1905 get_user_print_options (&opts
);
1907 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1908 file
, 0, &opts
, current_language
);
1910 fprintf_filtered (file
, "\t(raw 0x");
1911 for (j
= 0; j
< register_size (gdbarch
, i
); j
++)
1914 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
1917 idx
= register_size (gdbarch
, i
) - 1 - j
;
1918 fprintf_filtered (file
, "%02x", (unsigned char) buffer
[idx
]);
1920 fprintf_filtered (file
, ")");
1924 struct value_print_options opts
;
1926 /* Print the register in hex. */
1927 get_formatted_print_options (&opts
, 'x');
1929 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1932 /* If not a vector register, print it also according to its
1934 if (TYPE_VECTOR (register_type (gdbarch
, i
)) == 0)
1936 get_user_print_options (&opts
);
1938 fprintf_filtered (file
, "\t");
1939 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1940 file
, 0, &opts
, current_language
);
1944 fprintf_filtered (file
, "\n");
1949 registers_info (char *addr_exp
, int fpregs
)
1951 struct frame_info
*frame
;
1952 struct gdbarch
*gdbarch
;
1953 int regnum
, numregs
;
1956 if (!target_has_registers
)
1957 error (_("The program has no registers now."));
1958 frame
= get_selected_frame (NULL
);
1959 gdbarch
= get_frame_arch (frame
);
1963 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
1968 while (*addr_exp
!= '\0')
1973 /* Keep skipping leading white space. */
1974 if (isspace ((*addr_exp
)))
1980 /* Discard any leading ``$''. Check that there is something
1981 resembling a register following it. */
1982 if (addr_exp
[0] == '$')
1984 if (isspace ((*addr_exp
)) || (*addr_exp
) == '\0')
1985 error (_("Missing register name"));
1987 /* Find the start/end of this register name/num/group. */
1989 while ((*addr_exp
) != '\0' && !isspace ((*addr_exp
)))
1993 /* Figure out what we've found and display it. */
1995 /* A register name? */
1997 int regnum
= user_reg_map_name_to_regnum (gdbarch
, start
, end
- start
);
2000 /* User registers lie completely outside of the range of
2001 normal registers. Catch them early so that the target
2003 if (regnum
>= gdbarch_num_regs (gdbarch
)
2004 + gdbarch_num_pseudo_regs (gdbarch
))
2006 struct value_print_options opts
;
2007 struct value
*val
= value_of_user_reg (regnum
, frame
);
2009 printf_filtered ("%s: ", start
);
2010 get_formatted_print_options (&opts
, 'x');
2011 print_scalar_formatted (value_contents (val
),
2012 check_typedef (value_type (val
)),
2013 &opts
, 0, gdb_stdout
);
2014 printf_filtered ("\n");
2017 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2018 frame
, regnum
, fpregs
);
2023 /* A register group? */
2025 struct reggroup
*group
;
2026 for (group
= reggroup_next (gdbarch
, NULL
);
2028 group
= reggroup_next (gdbarch
, group
))
2030 /* Don't bother with a length check. Should the user
2031 enter a short register group name, go with the first
2032 group that matches. */
2033 if (strncmp (start
, reggroup_name (group
), end
- start
) == 0)
2040 regnum
< gdbarch_num_regs (gdbarch
)
2041 + gdbarch_num_pseudo_regs (gdbarch
);
2044 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
2045 gdbarch_print_registers_info (gdbarch
,
2053 /* Nothing matched. */
2054 error (_("Invalid register `%.*s'"), (int) (end
- start
), start
);
2059 all_registers_info (char *addr_exp
, int from_tty
)
2061 registers_info (addr_exp
, 1);
2065 nofp_registers_info (char *addr_exp
, int from_tty
)
2067 registers_info (addr_exp
, 0);
2071 print_vector_info (struct ui_file
*file
,
2072 struct frame_info
*frame
, const char *args
)
2074 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2076 if (gdbarch_print_vector_info_p (gdbarch
))
2077 gdbarch_print_vector_info (gdbarch
, file
, frame
, args
);
2081 int printed_something
= 0;
2084 regnum
< gdbarch_num_regs (gdbarch
)
2085 + gdbarch_num_pseudo_regs (gdbarch
);
2088 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, vector_reggroup
))
2090 printed_something
= 1;
2091 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2094 if (!printed_something
)
2095 fprintf_filtered (file
, "No vector information\n");
2100 vector_info (char *args
, int from_tty
)
2102 if (!target_has_registers
)
2103 error (_("The program has no registers now."));
2105 print_vector_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2108 /* Kill the inferior process. Make us have no inferior. */
2111 kill_command (char *arg
, int from_tty
)
2113 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2114 It should be a distinct flag that indicates that a target is active, cuz
2115 some targets don't have processes! */
2117 if (ptid_equal (inferior_ptid
, null_ptid
))
2118 error (_("The program is not being run."));
2119 if (!query (_("Kill the program being debugged? ")))
2120 error (_("Not confirmed."));
2123 /* If we still have other inferiors to debug, then don't mess with
2124 with their threads. */
2125 if (!have_inferiors ())
2127 init_thread_list (); /* Destroy thread info */
2129 /* Killing off the inferior can leave us with a core file. If
2130 so, print the state we are left in. */
2131 if (target_has_stack
)
2133 printf_filtered (_("In %s,\n"), target_longname
);
2134 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
);
2137 bfd_cache_close_all ();
2140 /* Used in `attach&' command. ARG is a point to an integer
2141 representing a process id. Proceed threads of this process iff
2142 they stopped due to debugger request, and when they did, they
2143 reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads
2144 that have been explicitly been told to stop. */
2147 proceed_after_attach_callback (struct thread_info
*thread
,
2150 int pid
= * (int *) arg
;
2152 if (ptid_get_pid (thread
->ptid
) == pid
2153 && !is_exited (thread
->ptid
)
2154 && !is_executing (thread
->ptid
)
2155 && !thread
->stop_requested
2156 && thread
->stop_signal
== TARGET_SIGNAL_0
)
2158 switch_to_thread (thread
->ptid
);
2159 clear_proceed_status ();
2160 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2167 proceed_after_attach (int pid
)
2169 /* Don't error out if the current thread is running, because
2170 there may be other stopped threads. */
2171 struct cleanup
*old_chain
;
2173 /* Backup current thread and selected frame. */
2174 old_chain
= make_cleanup_restore_current_thread ();
2176 iterate_over_threads (proceed_after_attach_callback
, &pid
);
2178 /* Restore selected ptid. */
2179 do_cleanups (old_chain
);
2184 * Should save/restore the tty state since it might be that the
2185 * program to be debugged was started on this tty and it wants
2186 * the tty in some state other than what we want. If it's running
2187 * on another terminal or without a terminal, then saving and
2188 * restoring the tty state is a harmless no-op.
2189 * This only needs to be done if we are attaching to a process.
2194 takes a program started up outside of gdb and ``attaches'' to it.
2195 This stops it cold in its tracks and allows us to start debugging it.
2196 and wait for the trace-trap that results from attaching. */
2199 attach_command_post_wait (char *args
, int from_tty
, int async_exec
)
2202 char *full_exec_path
= NULL
;
2203 struct inferior
*inferior
;
2205 inferior
= current_inferior ();
2206 inferior
->stop_soon
= NO_STOP_QUIETLY
;
2208 /* If no exec file is yet known, try to determine it from the
2210 exec_file
= (char *) get_exec_file (0);
2213 exec_file
= target_pid_to_exec_file (PIDGET (inferior_ptid
));
2216 /* It's possible we don't have a full path, but rather just a
2217 filename. Some targets, such as HP-UX, don't provide the
2220 Attempt to qualify the filename against the source path.
2221 (If that fails, we'll just fall back on the original
2222 filename. Not much more we can do...)
2224 if (!source_full_path_of (exec_file
, &full_exec_path
))
2225 full_exec_path
= xstrdup (exec_file
);
2227 exec_file_attach (full_exec_path
, from_tty
);
2228 symbol_file_add_main (full_exec_path
, from_tty
);
2233 reopen_exec_file ();
2237 /* Take any necessary post-attaching actions for this platform. */
2238 target_post_attach (PIDGET (inferior_ptid
));
2240 post_create_inferior (¤t_target
, from_tty
);
2242 /* Install inferior's terminal modes. */
2243 target_terminal_inferior ();
2247 /* The user requested an `attach&', so be sure to leave threads
2248 that didn't get a signal running. */
2250 /* Immediatelly resume all suspended threads of this inferior,
2251 and this inferior only. This should have no effect on
2252 already running threads. If a thread has been stopped with a
2253 signal, leave it be. */
2255 proceed_after_attach (inferior
->pid
);
2258 if (inferior_thread ()->stop_signal
== TARGET_SIGNAL_0
)
2260 clear_proceed_status ();
2261 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2267 /* The user requested a plain `attach', so be sure to leave
2268 the inferior stopped. */
2270 if (target_can_async_p ())
2271 async_enable_stdin ();
2273 /* At least the current thread is already stopped. */
2275 /* In all-stop, by definition, all threads have to be already
2276 stopped at this point. In non-stop, however, although the
2277 selected thread is stopped, others may still be executing.
2278 Be sure to explicitly stop all threads of the process. This
2279 should have no effect on already stopped threads. */
2281 target_stop (pid_to_ptid (inferior
->pid
));
2283 /* Tell the user/frontend where we're stopped. */
2285 if (deprecated_attach_hook
)
2286 deprecated_attach_hook ();
2290 struct attach_command_continuation_args
2298 attach_command_continuation (void *args
)
2300 struct attach_command_continuation_args
*a
= args
;
2301 attach_command_post_wait (a
->args
, a
->from_tty
, a
->async_exec
);
2305 attach_command_continuation_free_args (void *args
)
2307 struct attach_command_continuation_args
*a
= args
;
2313 attach_command (char *args
, int from_tty
)
2316 char *full_exec_path
= NULL
;
2318 struct cleanup
*back_to
= make_cleanup (null_cleanup
, NULL
);
2320 dont_repeat (); /* Not for the faint of heart */
2322 if (gdbarch_has_global_solist (target_gdbarch
))
2323 /* Don't complain if all processes share the same symbol
2326 else if (target_has_execution
)
2328 if (query (_("A program is being debugged already. Kill it? ")))
2331 error (_("Not killed."));
2334 /* Clean up any leftovers from other runs. Some other things from
2335 this function should probably be moved into target_pre_inferior. */
2336 target_pre_inferior (from_tty
);
2338 if (non_stop
&& !target_supports_non_stop ())
2339 error (_("Cannot attach to this target in non-stop mode"));
2343 async_exec
= strip_bg_char (&args
);
2345 /* If we get a request for running in the bg but the target
2346 doesn't support it, error out. */
2347 if (async_exec
&& !target_can_async_p ())
2348 error (_("Asynchronous execution not supported on this target."));
2351 /* If we don't get a request of running in the bg, then we need
2352 to simulate synchronous (fg) execution. */
2353 if (!async_exec
&& target_can_async_p ())
2355 /* Simulate synchronous execution */
2356 async_disable_stdin ();
2357 make_cleanup ((make_cleanup_ftype
*)async_enable_stdin
, NULL
);
2360 target_attach (args
, from_tty
);
2362 /* Set up the "saved terminal modes" of the inferior
2363 based on what modes we are starting it with. */
2364 target_terminal_init ();
2366 /* Set up execution context to know that we should return from
2367 wait_for_inferior as soon as the target reports a stop. */
2368 init_wait_for_inferior ();
2369 clear_proceed_status ();
2373 /* If we find that the current thread isn't stopped, explicitly
2374 do so now, because we're going to install breakpoints and
2378 /* The user requested an `attach&'; stop just one thread. */
2379 target_stop (inferior_ptid
);
2381 /* The user requested an `attach', so stop all threads of this
2383 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid
)));
2386 /* Some system don't generate traps when attaching to inferior.
2387 E.g. Mach 3 or GNU hurd. */
2388 if (!target_attach_no_wait
)
2390 struct inferior
*inferior
= current_inferior ();
2392 /* Careful here. See comments in inferior.h. Basically some
2393 OSes don't ignore SIGSTOPs on continue requests anymore. We
2394 need a way for handle_inferior_event to reset the stop_signal
2395 variable after an attach, and this is what
2396 STOP_QUIETLY_NO_SIGSTOP is for. */
2397 inferior
->stop_soon
= STOP_QUIETLY_NO_SIGSTOP
;
2399 if (target_can_async_p ())
2401 /* sync_execution mode. Wait for stop. */
2402 struct attach_command_continuation_args
*a
;
2404 a
= xmalloc (sizeof (*a
));
2405 a
->args
= xstrdup (args
);
2406 a
->from_tty
= from_tty
;
2407 a
->async_exec
= async_exec
;
2408 add_inferior_continuation (attach_command_continuation
, a
,
2409 attach_command_continuation_free_args
);
2410 discard_cleanups (back_to
);
2414 wait_for_inferior (0);
2417 attach_command_post_wait (args
, from_tty
, async_exec
);
2418 discard_cleanups (back_to
);
2421 /* We had just found out that the target was already attached to an
2422 inferior. PTID points at a thread of this new inferior, that is
2423 the most likely to be stopped right now, but not necessarily so.
2424 The new inferior is assumed to be already added to the inferior
2425 list at this point. If LEAVE_RUNNING, then leave the threads of
2426 this inferior running, except those we've explicitly seen reported
2430 notice_new_inferior (ptid_t ptid
, int leave_running
, int from_tty
)
2432 struct cleanup
* old_chain
;
2435 old_chain
= make_cleanup (null_cleanup
, NULL
);
2437 /* If in non-stop, leave threads as running as they were. If
2438 they're stopped for some reason other than us telling it to, the
2439 target reports a signal != TARGET_SIGNAL_0. We don't try to
2440 resume threads with such a stop signal. */
2441 async_exec
= non_stop
;
2443 if (!ptid_equal (inferior_ptid
, null_ptid
))
2444 make_cleanup_restore_current_thread ();
2446 switch_to_thread (ptid
);
2448 /* When we "notice" a new inferior we need to do all the things we
2449 would normally do if we had just attached to it. */
2451 if (is_executing (inferior_ptid
))
2453 struct inferior
*inferior
= current_inferior ();
2455 /* We're going to install breakpoints, and poke at memory,
2456 ensure that the inferior is stopped for a moment while we do
2458 target_stop (inferior_ptid
);
2460 inferior
->stop_soon
= STOP_QUIETLY_REMOTE
;
2462 /* Wait for stop before proceeding. */
2463 if (target_can_async_p ())
2465 struct attach_command_continuation_args
*a
;
2467 a
= xmalloc (sizeof (*a
));
2468 a
->args
= xstrdup ("");
2469 a
->from_tty
= from_tty
;
2470 a
->async_exec
= async_exec
;
2471 add_inferior_continuation (attach_command_continuation
, a
,
2472 attach_command_continuation_free_args
);
2474 do_cleanups (old_chain
);
2478 wait_for_inferior (0);
2481 async_exec
= leave_running
;
2482 attach_command_post_wait ("" /* args */, from_tty
, async_exec
);
2484 do_cleanups (old_chain
);
2489 * takes a program previously attached to and detaches it.
2490 * The program resumes execution and will no longer stop
2491 * on signals, etc. We better not have left any breakpoints
2492 * in the program or it'll die when it hits one. For this
2493 * to work, it may be necessary for the process to have been
2494 * previously attached. It *might* work if the program was
2495 * started via the normal ptrace (PTRACE_TRACEME).
2499 detach_command (char *args
, int from_tty
)
2501 dont_repeat (); /* Not for the faint of heart. */
2503 if (ptid_equal (inferior_ptid
, null_ptid
))
2504 error (_("The program is not being run."));
2506 target_detach (args
, from_tty
);
2508 /* If the solist is global across inferiors, don't clear it when we
2509 detach from a single inferior. */
2510 if (!gdbarch_has_global_solist (target_gdbarch
))
2511 no_shared_libraries (NULL
, from_tty
);
2513 /* If we still have inferiors to debug, then don't mess with their
2515 if (!have_inferiors ())
2516 init_thread_list ();
2518 if (deprecated_detach_hook
)
2519 deprecated_detach_hook ();
2522 /* Disconnect from the current target without resuming it (leaving it
2523 waiting for a debugger).
2525 We'd better not have left any breakpoints in the program or the
2526 next debugger will get confused. Currently only supported for some
2527 remote targets, since the normal attach mechanisms don't work on
2528 stopped processes on some native platforms (e.g. GNU/Linux). */
2531 disconnect_command (char *args
, int from_tty
)
2533 dont_repeat (); /* Not for the faint of heart */
2534 target_disconnect (args
, from_tty
);
2535 no_shared_libraries (NULL
, from_tty
);
2536 init_thread_list ();
2537 if (deprecated_detach_hook
)
2538 deprecated_detach_hook ();
2542 interrupt_target_1 (int all_threads
)
2546 ptid
= minus_one_ptid
;
2548 ptid
= inferior_ptid
;
2551 /* Tag the thread as having been explicitly requested to stop, so
2552 other parts of gdb know not to resume this thread automatically,
2553 if it was stopped due to an internal event. Limit this to
2554 non-stop mode, as when debugging a multi-threaded application in
2555 all-stop mode, we will only get one stop event --- it's undefined
2556 which thread will report the event. */
2558 set_stop_requested (ptid
, 1);
2561 /* Stop the execution of the target while running in async mode, in
2562 the backgound. In all-stop, stop the whole process. In non-stop
2563 mode, stop the current thread only by default, or stop all threads
2564 if the `-a' switch is used. */
2566 /* interrupt [-a] */
2568 interrupt_target_command (char *args
, int from_tty
)
2570 if (target_can_async_p ())
2572 int all_threads
= 0;
2574 dont_repeat (); /* Not for the faint of heart */
2577 && strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
2580 if (!non_stop
&& all_threads
)
2581 error (_("-a is meaningless in all-stop mode."));
2583 interrupt_target_1 (all_threads
);
2588 print_float_info (struct ui_file
*file
,
2589 struct frame_info
*frame
, const char *args
)
2591 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2593 if (gdbarch_print_float_info_p (gdbarch
))
2594 gdbarch_print_float_info (gdbarch
, file
, frame
, args
);
2598 int printed_something
= 0;
2601 regnum
< gdbarch_num_regs (gdbarch
)
2602 + gdbarch_num_pseudo_regs (gdbarch
);
2605 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, float_reggroup
))
2607 printed_something
= 1;
2608 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2611 if (!printed_something
)
2612 fprintf_filtered (file
, "\
2613 No floating-point info available for this processor.\n");
2618 float_info (char *args
, int from_tty
)
2620 if (!target_has_registers
)
2621 error (_("The program has no registers now."));
2623 print_float_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2627 unset_command (char *args
, int from_tty
)
2629 printf_filtered (_("\
2630 \"unset\" must be followed by the name of an unset subcommand.\n"));
2631 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
2635 _initialize_infcmd (void)
2637 struct cmd_list_element
*c
= NULL
;
2639 /* add the filename of the terminal connected to inferior I/O */
2640 add_setshow_filename_cmd ("inferior-tty", class_run
,
2641 &inferior_io_terminal
, _("\
2642 Set terminal for future runs of program being debugged."), _("\
2643 Show terminal for future runs of program being debugged."), _("\
2644 Usage: set inferior-tty /dev/pts/1"), NULL
, NULL
, &setlist
, &showlist
);
2645 add_com_alias ("tty", "set inferior-tty", class_alias
, 0);
2647 add_setshow_optional_filename_cmd ("args", class_run
,
2648 &inferior_args
, _("\
2649 Set argument list to give program being debugged when it is started."), _("\
2650 Show argument list to give program being debugged when it is started."), _("\
2651 Follow this command with any number of args, to be passed to the program."),
2654 &setlist
, &showlist
);
2656 c
= add_cmd ("environment", no_class
, environment_info
, _("\
2657 The environment to give the program, or one variable's value.\n\
2658 With an argument VAR, prints the value of environment variable VAR to\n\
2659 give the program being debugged. With no arguments, prints the entire\n\
2660 environment to be given to the program."), &showlist
);
2661 set_cmd_completer (c
, noop_completer
);
2663 add_prefix_cmd ("unset", no_class
, unset_command
,
2664 _("Complement to certain \"set\" commands."),
2665 &unsetlist
, "unset ", 0, &cmdlist
);
2667 c
= add_cmd ("environment", class_run
, unset_environment_command
, _("\
2668 Cancel environment variable VAR for the program.\n\
2669 This does not affect the program until the next \"run\" command."),
2671 set_cmd_completer (c
, noop_completer
);
2673 c
= add_cmd ("environment", class_run
, set_environment_command
, _("\
2674 Set environment variable value to give the program.\n\
2675 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2676 VALUES of environment variables are uninterpreted strings.\n\
2677 This does not affect the program until the next \"run\" command."),
2679 set_cmd_completer (c
, noop_completer
);
2681 c
= add_com ("path", class_files
, path_command
, _("\
2682 Add directory DIR(s) to beginning of search path for object files.\n\
2683 $cwd in the path means the current working directory.\n\
2684 This path is equivalent to the $PATH shell variable. It is a list of\n\
2685 directories, separated by colons. These directories are searched to find\n\
2686 fully linked executable files and separately compiled object files as needed."));
2687 set_cmd_completer (c
, filename_completer
);
2689 c
= add_cmd ("paths", no_class
, path_info
, _("\
2690 Current search path for finding object files.\n\
2691 $cwd in the path means the current working directory.\n\
2692 This path is equivalent to the $PATH shell variable. It is a list of\n\
2693 directories, separated by colons. These directories are searched to find\n\
2694 fully linked executable files and separately compiled object files as needed."),
2696 set_cmd_completer (c
, noop_completer
);
2698 add_com ("kill", class_run
, kill_command
,
2699 _("Kill execution of program being debugged."));
2701 add_com ("attach", class_run
, attach_command
, _("\
2702 Attach to a process or file outside of GDB.\n\
2703 This command attaches to another target, of the same type as your last\n\
2704 \"target\" command (\"info files\" will show your target stack).\n\
2705 The command may take as argument a process id or a device file.\n\
2706 For a process id, you must have permission to send the process a signal,\n\
2707 and it must have the same effective uid as the debugger.\n\
2708 When using \"attach\" with a process id, the debugger finds the\n\
2709 program running in the process, looking first in the current working\n\
2710 directory, or (if not found there) using the source file search path\n\
2711 (see the \"directory\" command). You can also use the \"file\" command\n\
2712 to specify the program, and to load its symbol table."));
2714 add_prefix_cmd ("detach", class_run
, detach_command
, _("\
2715 Detach a process or file previously attached.\n\
2716 If a process, it is no longer traced, and it continues its execution. If\n\
2717 you were debugging a file, the file is closed and gdb no longer accesses it."),
2718 &detachlist
, "detach ", 0, &cmdlist
);
2720 add_com ("disconnect", class_run
, disconnect_command
, _("\
2721 Disconnect from a target.\n\
2722 The target will wait for another debugger to connect. Not available for\n\
2725 add_com ("signal", class_run
, signal_command
, _("\
2726 Continue program giving it signal specified by the argument.\n\
2727 An argument of \"0\" means continue program without giving it a signal."));
2729 add_com ("stepi", class_run
, stepi_command
, _("\
2730 Step one instruction exactly.\n\
2731 Argument N means do this N times (or till program stops for another reason)."));
2732 add_com_alias ("si", "stepi", class_alias
, 0);
2734 add_com ("nexti", class_run
, nexti_command
, _("\
2735 Step one instruction, but proceed through subroutine calls.\n\
2736 Argument N means do this N times (or till program stops for another reason)."));
2737 add_com_alias ("ni", "nexti", class_alias
, 0);
2739 add_com ("finish", class_run
, finish_command
, _("\
2740 Execute until selected stack frame returns.\n\
2741 Upon return, the value returned is printed and put in the value history."));
2742 add_com_alias ("fin", "finish", class_run
, 1);
2744 add_com ("next", class_run
, next_command
, _("\
2745 Step program, proceeding through subroutine calls.\n\
2746 Like the \"step\" command as long as subroutine calls do not happen;\n\
2747 when they do, the call is treated as one instruction.\n\
2748 Argument N means do this N times (or till program stops for another reason)."));
2749 add_com_alias ("n", "next", class_run
, 1);
2751 add_com_alias ("S", "next", class_run
, 1);
2753 add_com ("step", class_run
, step_command
, _("\
2754 Step program until it reaches a different source line.\n\
2755 Argument N means do this N times (or till program stops for another reason)."));
2756 add_com_alias ("s", "step", class_run
, 1);
2758 c
= add_com ("until", class_run
, until_command
, _("\
2759 Execute until the program reaches a source line greater than the current\n\
2760 or a specified location (same args as break command) within the current frame."));
2761 set_cmd_completer (c
, location_completer
);
2762 add_com_alias ("u", "until", class_run
, 1);
2764 c
= add_com ("advance", class_run
, advance_command
, _("\
2765 Continue the program up to the given location (same form as args for break command).\n\
2766 Execution will also stop upon exit from the current stack frame."));
2767 set_cmd_completer (c
, location_completer
);
2769 c
= add_com ("jump", class_run
, jump_command
, _("\
2770 Continue program being debugged at specified line or address.\n\
2771 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2772 for an address to start at."));
2773 set_cmd_completer (c
, location_completer
);
2777 c
= add_com ("go", class_run
, go_command
, _("\
2778 Usage: go <location>\n\
2779 Continue program being debugged, stopping at specified line or \n\
2781 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2782 expression for an address to start at.\n\
2783 This command is a combination of tbreak and jump."));
2784 set_cmd_completer (c
, location_completer
);
2788 add_com_alias ("g", "go", class_run
, 1);
2790 c
= add_com ("continue", class_run
, continue_command
, _("\
2791 Continue program being debugged, after signal or breakpoint.\n\
2792 If proceeding from breakpoint, a number N may be used as an argument,\n\
2793 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2794 the breakpoint won't break until the Nth time it is reached).\n\
2796 If non-stop mode is enabled, continue only the current thread,\n\
2797 otherwise all the threads in the program are continued. To \n\
2798 continue all stopped threads in non-stop mode, use the -a option.\n\
2799 Specifying -a and an ignore count simultaneously is an error."));
2800 add_com_alias ("c", "cont", class_run
, 1);
2801 add_com_alias ("fg", "cont", class_run
, 1);
2803 c
= add_com ("run", class_run
, run_command
, _("\
2804 Start debugged program. You may specify arguments to give it.\n\
2805 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2806 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2807 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2808 To cancel previous arguments and run with no arguments,\n\
2809 use \"set args\" without arguments."));
2810 set_cmd_completer (c
, filename_completer
);
2811 add_com_alias ("r", "run", class_run
, 1);
2813 add_com ("R", class_run
, run_no_args_command
,
2814 _("Start debugged program with no arguments."));
2816 c
= add_com ("start", class_run
, start_command
, _("\
2817 Run the debugged program until the beginning of the main procedure.\n\
2818 You may specify arguments to give to your program, just as with the\n\
2819 \"run\" command."));
2820 set_cmd_completer (c
, filename_completer
);
2822 c
= add_com ("interrupt", class_run
, interrupt_target_command
,
2823 _("Interrupt the execution of the debugged program.\n\
2824 If non-stop mode is enabled, interrupt only the current thread,\n\
2825 otherwise all the threads in the program are stopped. To \n\
2826 interrupt all running threads in non-stop mode, use the -a option."));
2828 add_info ("registers", nofp_registers_info
, _("\
2829 List of integer registers and their contents, for selected stack frame.\n\
2830 Register name as argument means describe only that register."));
2831 add_info_alias ("r", "registers", 1);
2834 add_com ("lr", class_info
, nofp_registers_info
, _("\
2835 List of integer registers and their contents, for selected stack frame.\n\
2836 Register name as argument means describe only that register."));
2837 add_info ("all-registers", all_registers_info
, _("\
2838 List of all registers and their contents, for selected stack frame.\n\
2839 Register name as argument means describe only that register."));
2841 add_info ("program", program_info
,
2842 _("Execution status of the program."));
2844 add_info ("float", float_info
,
2845 _("Print the status of the floating point unit\n"));
2847 add_info ("vector", vector_info
,
2848 _("Print the status of the vector unit\n"));
2850 inferior_environ
= make_environ ();
2851 init_environ (inferior_environ
);