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 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"
58 extern void disconnect_or_stop_tracing (int from_tty
);
60 /* Functions exported for general use, in inferior.h: */
62 void all_registers_info (char *, int);
64 void registers_info (char *, int);
66 void nexti_command (char *, int);
68 void stepi_command (char *, int);
70 void continue_command (char *, int);
72 void interrupt_target_command (char *args
, int from_tty
);
74 /* Local functions: */
76 static void nofp_registers_info (char *, int);
78 static void print_return_value (struct type
*func_type
,
79 struct type
*value_type
);
81 static void until_next_command (int);
83 static void until_command (char *, int);
85 static void path_info (char *, int);
87 static void path_command (char *, int);
89 static void unset_command (char *, int);
91 static void float_info (char *, int);
93 static void disconnect_command (char *, int);
95 static void unset_environment_command (char *, int);
97 static void set_environment_command (char *, int);
99 static void environment_info (char *, int);
101 static void program_info (char *, int);
103 static void finish_command (char *, int);
105 static void signal_command (char *, int);
107 static void jump_command (char *, int);
109 static void step_1 (int, int, char *);
110 static void step_once (int skip_subroutines
, int single_inst
, 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 program will be
130 stored by 'set args'. As soon as anything is stored, notice_args_set will
131 move it into per-inferior storage. Arguments are separated by spaces. Empty
132 string (pointer to '\0') means no args. */
134 static char *inferior_args_scratch
;
136 /* Scratch area where 'set inferior-tty' will store user-provided value.
137 We'll immediate copy it into per-inferior storage. */
139 static char *inferior_io_terminal_scratch
;
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
;
167 /* Accessor routines. */
169 /* Set the io terminal for the current inferior. Ownership of
170 TERMINAL_NAME is not transferred. */
173 set_inferior_io_terminal (const char *terminal_name
)
175 xfree (current_inferior ()->terminal
);
176 current_inferior ()->terminal
= terminal_name
? xstrdup (terminal_name
) : 0;
180 get_inferior_io_terminal (void)
182 return current_inferior ()->terminal
;
186 set_inferior_tty_command (char *args
, int from_tty
,
187 struct cmd_list_element
*c
)
189 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
190 Now route it to current inferior. */
191 set_inferior_io_terminal (inferior_io_terminal_scratch
);
195 show_inferior_tty_command (struct ui_file
*file
, int from_tty
,
196 struct cmd_list_element
*c
, const char *value
)
198 /* Note that we ignore the passed-in value in favor of computing it
200 fprintf_filtered (gdb_stdout
,
201 _("argument list to give program being debugged when "
202 "it is started is %s"),
203 get_inferior_io_terminal ());
207 get_inferior_args (void)
209 if (current_inferior ()->argc
!= 0)
213 n
= construct_inferior_arguments (current_inferior ()->argc
,
214 current_inferior ()->argv
);
215 set_inferior_args (n
);
219 if (current_inferior ()->args
== NULL
)
220 current_inferior ()->args
= xstrdup ("");
222 return current_inferior ()->args
;
225 /* Set the arguments for the current inferior. Ownership of
226 NEWARGS is not transferred. */
229 set_inferior_args (char *newargs
)
231 xfree (current_inferior ()->args
);
232 current_inferior ()->args
= newargs
? xstrdup (newargs
) : NULL
;
233 current_inferior ()->argc
= 0;
234 current_inferior ()->argv
= 0;
238 set_inferior_args_vector (int argc
, char **argv
)
240 current_inferior ()->argc
= argc
;
241 current_inferior ()->argv
= argv
;
244 /* Notice when `set args' is run. */
246 set_args_command (char *args
, int from_tty
, struct cmd_list_element
*c
)
248 /* CLI has assigned the user-provided value to inferior_args_scratch.
249 Now route it to current inferior. */
250 set_inferior_args (inferior_args_scratch
);
253 /* Notice when `show args' is run. */
255 show_args_command (struct ui_file
*file
, int from_tty
,
256 struct cmd_list_element
*c
, const char *value
)
258 /* Note that we ignore the passed-in value in favor of computing it
260 deprecated_show_value_hack (file
, from_tty
, c
, get_inferior_args ());
264 /* Compute command-line string given argument vector. This does the
265 same shell processing as fork_inferior. */
267 construct_inferior_arguments (int argc
, char **argv
)
271 if (STARTUP_WITH_SHELL
)
273 /* This holds all the characters considered special to the
274 typical Unix shells. We include `^' because the SunOS
275 /bin/sh treats it as a synonym for `|'. */
276 char *special
= "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
281 /* We over-compute the size. It shouldn't matter. */
282 for (i
= 0; i
< argc
; ++i
)
283 length
+= 3 * strlen (argv
[i
]) + 1 + 2 * (argv
[i
][0] == '\0');
285 result
= (char *) xmalloc (length
);
288 for (i
= 0; i
< argc
; ++i
)
293 /* Need to handle empty arguments specially. */
294 if (argv
[i
][0] == '\0')
301 for (cp
= argv
[i
]; *cp
; ++cp
)
305 /* A newline cannot be quoted with a backslash (it
306 just disappears), only by putting it inside
314 if (strchr (special
, *cp
) != NULL
)
325 /* In this case we can't handle arguments that contain spaces,
326 tabs, or newlines -- see breakup_args(). */
330 for (i
= 0; i
< argc
; ++i
)
332 char *cp
= strchr (argv
[i
], ' ');
334 cp
= strchr (argv
[i
], '\t');
336 cp
= strchr (argv
[i
], '\n');
338 error (_("can't handle command-line argument containing whitespace"));
339 length
+= strlen (argv
[i
]) + 1;
342 result
= (char *) xmalloc (length
);
344 for (i
= 0; i
< argc
; ++i
)
347 strcat (result
, " ");
348 strcat (result
, argv
[i
]);
356 /* This function detects whether or not a '&' character (indicating
357 background execution) has been added as *the last* of the arguments ARGS
358 of a command. If it has, it removes it and returns 1. Otherwise it
359 does nothing and returns 0. */
361 strip_bg_char (char **args
)
365 p
= strchr (*args
, '&');
369 if (p
== (*args
+ strlen (*args
) - 1))
371 if (strlen (*args
) > 1)
375 while (*p
== ' ' || *p
== '\t');
386 /* Common actions to take after creating any sort of inferior, by any
387 means (running, attaching, connecting, et cetera). The target
388 should be stopped. */
391 post_create_inferior (struct target_ops
*target
, int from_tty
)
393 /* Be sure we own the terminal in case write operations are performed. */
394 target_terminal_ours ();
396 /* If the target hasn't taken care of this already, do it now.
397 Targets which need to access registers during to_open,
398 to_create_inferior, or to_attach should do it earlier; but many
400 target_find_description ();
402 /* Now that we know the register layout, retrieve current PC. */
403 stop_pc
= regcache_read_pc (get_current_regcache ());
407 /* Create the hooks to handle shared library load and unload
409 #ifdef SOLIB_CREATE_INFERIOR_HOOK
410 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid
));
412 solib_create_inferior_hook (from_tty
);
416 /* If the solist is global across processes, there's no need to
418 if (exec_bfd
&& !gdbarch_has_global_solist (target_gdbarch
))
420 /* Sometimes the platform-specific hook loads initial shared
421 libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be
422 incorrectly 0 but such solib targets should be fixed anyway. If we
423 made all the inferior hook methods consistent, this call could be
424 removed. Call it only after the solib target has been initialized by
425 solib_create_inferior_hook. */
428 SOLIB_ADD (NULL
, 0, target
, auto_solib_add
);
430 solib_add (NULL
, 0, target
, auto_solib_add
);
434 /* If the user sets watchpoints before execution having started,
435 then she gets software watchpoints, because GDB can't know which
436 target will end up being pushed, or if it supports hardware
437 watchpoints or not. breakpoint_re_set takes care of promoting
438 watchpoints to hardware watchpoints if possible, however, if this
439 new inferior doesn't load shared libraries or we don't pull in
440 symbols from any other source on this target/arch,
441 breakpoint_re_set is never called. Call it now so that software
442 watchpoints get a chance to be promoted to hardware watchpoints
443 if the now pushed target supports hardware watchpoints. */
444 breakpoint_re_set ();
446 observer_notify_inferior_created (target
, from_tty
);
449 /* Kill the inferior if already running. This function is designed
450 to be called when we are about to start the execution of the program
451 from the beginning. Ask the user to confirm that he wants to restart
452 the program being debugged when FROM_TTY is non-null. */
455 kill_if_already_running (int from_tty
)
457 if (! ptid_equal (inferior_ptid
, null_ptid
) && target_has_execution
)
459 /* Bail out before killing the program if we will not be able to
461 target_require_runnable ();
464 && !query (_("The program being debugged has been started already.\n\
465 Start it from the beginning? ")))
466 error (_("Program not restarted."));
471 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
472 a temporary breakpoint at the begining of the main program before
473 running the program. */
476 run_command_1 (char *args
, int from_tty
, int tbreak_at_main
)
479 struct cleanup
*old_chain
;
484 kill_if_already_running (from_tty
);
486 init_wait_for_inferior ();
487 clear_breakpoint_hit_counts ();
489 /* Clean up any leftovers from other runs. Some other things from
490 this function should probably be moved into target_pre_inferior. */
491 target_pre_inferior (from_tty
);
493 /* The comment here used to read, "The exec file is re-read every
494 time we do a generic_mourn_inferior, so we just have to worry
495 about the symbol file." The `generic_mourn_inferior' function
496 gets called whenever the program exits. However, suppose the
497 program exits, and *then* the executable file changes? We need
498 to check again here. Since reopen_exec_file doesn't do anything
499 if the timestamp hasn't changed, I don't see the harm. */
503 /* Insert the temporary breakpoint if a location was specified. */
505 tbreak_command (main_name (), 0);
507 exec_file
= (char *) get_exec_file (0);
509 if (non_stop
&& !target_supports_non_stop ())
510 error (_("The target does not support running in non-stop mode."));
512 /* We keep symbols from add-symbol-file, on the grounds that the
513 user might want to add some symbols before running the program
514 (right?). But sometimes (dynamic loading where the user manually
515 introduces the new symbols with add-symbol-file), the code which
516 the symbols describe does not persist between runs. Currently
517 the user has to manually nuke all symbols between runs if they
518 want them to go away (PR 2207). This is probably reasonable. */
522 if (target_can_async_p ())
523 async_disable_stdin ();
527 int async_exec
= strip_bg_char (&args
);
529 /* If we get a request for running in the bg but the target
530 doesn't support it, error out. */
531 if (async_exec
&& !target_can_async_p ())
532 error (_("Asynchronous execution not supported on this target."));
534 /* If we don't get a request of running in the bg, then we need
535 to simulate synchronous (fg) execution. */
536 if (!async_exec
&& target_can_async_p ())
538 /* Simulate synchronous execution */
539 async_disable_stdin ();
542 /* If there were other args, beside '&', process them. */
544 set_inferior_args (args
);
549 ui_out_field_string (uiout
, NULL
, "Starting program");
550 ui_out_text (uiout
, ": ");
552 ui_out_field_string (uiout
, "execfile", exec_file
);
553 ui_out_spaces (uiout
, 1);
554 /* We call get_inferior_args() because we might need to compute
556 ui_out_field_string (uiout
, "infargs", get_inferior_args ());
557 ui_out_text (uiout
, "\n");
558 ui_out_flush (uiout
);
561 /* We call get_inferior_args() because we might need to compute
563 target_create_inferior (exec_file
, get_inferior_args (),
564 environ_vector (current_inferior ()->environment
), from_tty
);
566 /* We're starting off a new process. When we get out of here, in
567 non-stop mode, finish the state of all threads of that process,
568 but leave other threads alone, as they may be stopped in internal
569 events --- the frontend shouldn't see them as stopped. In
570 all-stop, always finish the state of all threads, as we may be
571 resuming more than just the new process. */
573 ptid
= pid_to_ptid (ptid_get_pid (inferior_ptid
));
575 ptid
= minus_one_ptid
;
576 old_chain
= make_cleanup (finish_thread_state_cleanup
, &ptid
);
578 /* Pass zero for FROM_TTY, because at this point the "run" command
579 has done its thing; now we are setting up the running program. */
580 post_create_inferior (¤t_target
, 0);
582 /* Start the target running. */
583 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_0
, 0);
585 /* Since there was no error, there's no need to finish the thread
587 discard_cleanups (old_chain
);
591 run_command (char *args
, int from_tty
)
593 run_command_1 (args
, from_tty
, 0);
597 run_no_args_command (char *args
, int from_tty
)
599 set_inferior_args ("");
603 /* Start the execution of the program up until the beginning of the main
607 start_command (char *args
, int from_tty
)
609 /* Some languages such as Ada need to search inside the program
610 minimal symbols for the location where to put the temporary
611 breakpoint before starting. */
612 if (!have_minimal_symbols ())
613 error (_("No symbol table loaded. Use the \"file\" command."));
615 /* Run the program until reaching the main procedure... */
616 run_command_1 (args
, from_tty
, 1);
620 proceed_thread_callback (struct thread_info
*thread
, void *arg
)
622 /* We go through all threads individually instead of compressing
623 into a single target `resume_all' request, because some threads
624 may be stopped in internal breakpoints/events, or stopped waiting
625 for its turn in the displaced stepping queue (that is, they are
626 running && !executing). The target side has no idea about why
627 the thread is stopped, so a `resume_all' command would resume too
628 much. If/when GDB gains a way to tell the target `hold this
629 thread stopped until I say otherwise', then we can optimize
631 if (!is_stopped (thread
->ptid
))
634 switch_to_thread (thread
->ptid
);
635 clear_proceed_status ();
636 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
641 ensure_valid_thread (void)
643 if (ptid_equal (inferior_ptid
, null_ptid
)
644 || is_exited (inferior_ptid
))
646 Cannot execute this command without a live selected thread."));
650 continue_1 (int all_threads
)
654 if (non_stop
&& all_threads
)
656 /* Don't error out if the current thread is running, because
657 there may be other stopped threads. */
658 struct cleanup
*old_chain
;
660 /* Backup current thread and selected frame. */
661 old_chain
= make_cleanup_restore_current_thread ();
663 iterate_over_threads (proceed_thread_callback
, NULL
);
665 /* Restore selected ptid. */
666 do_cleanups (old_chain
);
670 ensure_valid_thread ();
671 ensure_not_running ();
672 clear_proceed_status ();
673 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
677 /* continue [-a] [proceed-count] [&] */
679 continue_command (char *args
, int from_tty
)
685 /* Find out whether we must run in the background. */
687 async_exec
= strip_bg_char (&args
);
689 /* If we must run in the background, but the target can't do it,
691 if (async_exec
&& !target_can_async_p ())
692 error (_("Asynchronous execution not supported on this target."));
694 /* If we are not asked to run in the bg, then prepare to run in the
695 foreground, synchronously. */
696 if (!async_exec
&& target_can_async_p ())
698 /* Simulate synchronous execution */
699 async_disable_stdin ();
704 if (strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
707 args
+= sizeof ("-a") - 1;
713 if (!non_stop
&& all_threads
)
714 error (_("`-a' is meaningless in all-stop mode."));
716 if (args
!= NULL
&& all_threads
)
718 Can't resume all threads and specify proceed count simultaneously."));
720 /* If we have an argument left, set proceed count of breakpoint we
727 struct thread_info
*tp
;
730 tp
= find_thread_ptid (inferior_ptid
);
734 struct target_waitstatus ws
;
736 get_last_target_status (&last_ptid
, &ws
);
737 tp
= find_thread_ptid (last_ptid
);
740 bs
= tp
->stop_bpstat
;
742 while ((stat
= bpstat_num (&bs
, &num
)) != 0)
745 set_ignore_count (num
,
746 parse_and_eval_long (args
) - 1,
748 /* set_ignore_count prints a message ending with a period.
749 So print two spaces before "Continuing.". */
751 printf_filtered (" ");
755 if (!stopped
&& from_tty
)
758 ("Not stopped at any breakpoint; argument ignored.\n");
763 printf_filtered (_("Continuing.\n"));
765 continue_1 (all_threads
);
768 /* Record the starting point of a "step" or "next" command. */
771 set_step_frame (void)
773 struct symtab_and_line sal
;
775 find_frame_sal (get_current_frame (), &sal
);
776 set_step_info (get_current_frame (), sal
);
779 /* Step until outside of current statement. */
782 step_command (char *count_string
, int from_tty
)
784 step_1 (0, 0, count_string
);
787 /* Likewise, but skip over subroutine calls as if single instructions. */
790 next_command (char *count_string
, int from_tty
)
792 step_1 (1, 0, count_string
);
795 /* Likewise, but step only one instruction. */
798 stepi_command (char *count_string
, int from_tty
)
800 step_1 (0, 1, count_string
);
804 nexti_command (char *count_string
, int from_tty
)
806 step_1 (1, 1, count_string
);
810 delete_longjmp_breakpoint_cleanup (void *arg
)
812 int thread
= * (int *) arg
;
813 delete_longjmp_breakpoint (thread
);
817 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
820 struct frame_info
*frame
;
821 struct cleanup
*cleanups
= make_cleanup (null_cleanup
, NULL
);
826 ensure_valid_thread ();
827 ensure_not_running ();
830 async_exec
= strip_bg_char (&count_string
);
832 /* If we get a request for running in the bg but the target
833 doesn't support it, error out. */
834 if (async_exec
&& !target_can_async_p ())
835 error (_("Asynchronous execution not supported on this target."));
837 /* If we don't get a request of running in the bg, then we need
838 to simulate synchronous (fg) execution. */
839 if (!async_exec
&& target_can_async_p ())
841 /* Simulate synchronous execution */
842 async_disable_stdin ();
845 count
= count_string
? parse_and_eval_long (count_string
) : 1;
847 if (!single_inst
|| skip_subroutines
) /* leave si command alone */
849 if (in_thread_list (inferior_ptid
))
850 thread
= pid_to_thread_id (inferior_ptid
);
852 set_longjmp_breakpoint (thread
);
854 make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
857 /* In synchronous case, all is well; each step_once call will step once. */
858 if (!target_can_async_p ())
860 for (; count
> 0; count
--)
862 struct thread_info
*tp
;
863 step_once (skip_subroutines
, single_inst
, count
, thread
);
865 if (target_has_execution
866 && !ptid_equal (inferior_ptid
, null_ptid
))
867 tp
= inferior_thread ();
871 if (!tp
|| !tp
->stop_step
|| !tp
->step_multi
)
873 /* If we stopped for some reason that is not stepping
874 there are no further steps to make. */
881 do_cleanups (cleanups
);
885 /* In the case of an asynchronous target things get complicated;
886 do only one step for now, before returning control to the
887 event loop. Let the continuation figure out how many other
888 steps we need to do, and handle them one at the time, through
890 step_once (skip_subroutines
, single_inst
, count
, thread
);
892 /* We are running, and the continuation is installed. It will
893 disable the longjmp breakpoint as appropriate. */
894 discard_cleanups (cleanups
);
898 struct step_1_continuation_args
901 int skip_subroutines
;
906 /* Called after we are done with one step operation, to check whether
907 we need to step again, before we print the prompt and return control
908 to the user. If count is > 1, we will need to do one more call to
909 proceed(), via step_once(). Basically it is like step_once and
910 step_1_continuation are co-recursive. */
912 step_1_continuation (void *args
)
914 struct step_1_continuation_args
*a
= args
;
916 if (target_has_execution
)
918 struct thread_info
*tp
;
920 tp
= inferior_thread ();
921 if (tp
->step_multi
&& tp
->stop_step
)
923 /* There are more steps to make, and we did stop due to
924 ending a stepping range. Do another step. */
925 step_once (a
->skip_subroutines
, a
->single_inst
,
926 a
->count
- 1, a
->thread
);
932 /* We either stopped for some reason that is not stepping, or there
933 are no further steps to make. Cleanup. */
934 if (!a
->single_inst
|| a
->skip_subroutines
)
935 delete_longjmp_breakpoint (a
->thread
);
938 /* Do just one step operation. This is useful to implement the 'step
939 n' kind of commands. In case of asynchronous targets, we will have
940 to set up a continuation to be done after the target stops (after
941 this one step). For synch targets, the caller handles further
945 step_once (int skip_subroutines
, int single_inst
, int count
, int thread
)
947 struct frame_info
*frame
= get_current_frame ();
951 /* Don't assume THREAD is a valid thread id. It is set to -1 if
952 the longjmp breakpoint was not required. Use the
953 INFERIOR_PTID thread instead, which is the same thread when
955 struct thread_info
*tp
= inferior_thread ();
956 clear_proceed_status ();
963 /* Step at an inlined function behaves like "down". */
964 if (!skip_subroutines
&& !single_inst
965 && inline_skipped_frames (inferior_ptid
))
967 step_into_inline_frame (inferior_ptid
);
969 step_once (skip_subroutines
, single_inst
, count
- 1, thread
);
971 /* Pretend that we've stopped. */
976 pc
= get_frame_pc (frame
);
977 find_pc_line_pc_range (pc
,
978 &tp
->step_range_start
, &tp
->step_range_end
);
980 /* If we have no line info, switch to stepi mode. */
981 if (tp
->step_range_end
== 0 && step_stop_if_no_debug
)
982 tp
->step_range_start
= tp
->step_range_end
= 1;
983 else if (tp
->step_range_end
== 0)
986 if (find_pc_partial_function (pc
, &name
,
987 &tp
->step_range_start
,
988 &tp
->step_range_end
) == 0)
989 error (_("Cannot find bounds of current function"));
991 target_terminal_ours ();
992 printf_filtered (_("\
993 Single stepping until exit from function %s, \n\
994 which has no line number information.\n"), name
);
999 /* Say we are stepping, but stop after one insn whatever it does. */
1000 tp
->step_range_start
= tp
->step_range_end
= 1;
1001 if (!skip_subroutines
)
1003 Don't step over function calls, not even to functions lacking
1005 tp
->step_over_calls
= STEP_OVER_NONE
;
1008 if (skip_subroutines
)
1009 tp
->step_over_calls
= STEP_OVER_ALL
;
1011 tp
->step_multi
= (count
> 1);
1012 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1014 /* For async targets, register a continuation to do any
1015 additional steps. For sync targets, the caller will handle
1016 further stepping. */
1017 if (target_can_async_p ())
1019 struct step_1_continuation_args
*args
;
1021 args
= xmalloc (sizeof (*args
));
1022 args
->skip_subroutines
= skip_subroutines
;
1023 args
->single_inst
= single_inst
;
1024 args
->count
= count
;
1025 args
->thread
= thread
;
1027 add_intermediate_continuation (tp
, step_1_continuation
, args
, xfree
);
1033 /* Continue program at specified address. */
1036 jump_command (char *arg
, int from_tty
)
1038 struct gdbarch
*gdbarch
= get_current_arch ();
1040 struct symtabs_and_lines sals
;
1041 struct symtab_and_line sal
;
1047 ensure_valid_thread ();
1048 ensure_not_running ();
1050 /* Find out whether we must run in the background. */
1052 async_exec
= strip_bg_char (&arg
);
1054 /* If we must run in the background, but the target can't do it,
1056 if (async_exec
&& !target_can_async_p ())
1057 error (_("Asynchronous execution not supported on this target."));
1060 error_no_arg (_("starting address"));
1062 sals
= decode_line_spec_1 (arg
, 1);
1063 if (sals
.nelts
!= 1)
1065 error (_("Unreasonable jump request"));
1071 if (sal
.symtab
== 0 && sal
.pc
== 0)
1072 error (_("No source file has been specified."));
1074 resolve_sal_pc (&sal
); /* May error out */
1076 /* See if we are trying to jump to another function. */
1077 fn
= get_frame_function (get_current_frame ());
1078 sfn
= find_pc_function (sal
.pc
);
1079 if (fn
!= NULL
&& sfn
!= fn
)
1081 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal
.line
,
1082 SYMBOL_PRINT_NAME (fn
)))
1084 error (_("Not confirmed."));
1091 fixup_symbol_section (sfn
, 0);
1092 if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn
)) &&
1093 !section_is_mapped (SYMBOL_OBJ_SECTION (sfn
)))
1095 if (!query (_("WARNING!!! Destination is in unmapped overlay! Jump anyway? ")))
1097 error (_("Not confirmed."));
1107 printf_filtered (_("Continuing at "));
1108 fputs_filtered (paddress (gdbarch
, addr
), gdb_stdout
);
1109 printf_filtered (".\n");
1112 /* If we are not asked to run in the bg, then prepare to run in the
1113 foreground, synchronously. */
1114 if (!async_exec
&& target_can_async_p ())
1116 /* Simulate synchronous execution */
1117 async_disable_stdin ();
1120 clear_proceed_status ();
1121 proceed (addr
, TARGET_SIGNAL_0
, 0);
1125 /* Go to line or address in current procedure */
1127 go_command (char *line_no
, int from_tty
)
1129 if (line_no
== (char *) NULL
|| !*line_no
)
1130 printf_filtered (_("Usage: go <location>\n"));
1133 tbreak_command (line_no
, from_tty
);
1134 jump_command (line_no
, from_tty
);
1139 /* Continue program giving it specified signal. */
1142 signal_command (char *signum_exp
, int from_tty
)
1144 enum target_signal oursig
;
1147 dont_repeat (); /* Too dangerous. */
1149 ensure_valid_thread ();
1150 ensure_not_running ();
1152 /* Find out whether we must run in the background. */
1153 if (signum_exp
!= NULL
)
1154 async_exec
= strip_bg_char (&signum_exp
);
1156 /* If we must run in the background, but the target can't do it,
1158 if (async_exec
&& !target_can_async_p ())
1159 error (_("Asynchronous execution not supported on this target."));
1161 /* If we are not asked to run in the bg, then prepare to run in the
1162 foreground, synchronously. */
1163 if (!async_exec
&& target_can_async_p ())
1165 /* Simulate synchronous execution. */
1166 async_disable_stdin ();
1170 error_no_arg (_("signal number"));
1172 /* It would be even slicker to make signal names be valid expressions,
1173 (the type could be "enum $signal" or some such), then the user could
1174 assign them to convenience variables. */
1175 oursig
= target_signal_from_name (signum_exp
);
1177 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
1179 /* No, try numeric. */
1180 int num
= parse_and_eval_long (signum_exp
);
1183 oursig
= TARGET_SIGNAL_0
;
1185 oursig
= target_signal_from_command (num
);
1190 if (oursig
== TARGET_SIGNAL_0
)
1191 printf_filtered (_("Continuing with no signal.\n"));
1193 printf_filtered (_("Continuing with signal %s.\n"),
1194 target_signal_to_name (oursig
));
1197 clear_proceed_status ();
1198 proceed ((CORE_ADDR
) -1, oursig
, 0);
1201 /* Proceed until we reach a different source line with pc greater than
1202 our current one or exit the function. We skip calls in both cases.
1204 Note that eventually this command should probably be changed so
1205 that only source lines are printed out when we hit the breakpoint
1206 we set. This may involve changes to wait_for_inferior and the
1207 proceed status code. */
1210 until_next_command (int from_tty
)
1212 struct frame_info
*frame
;
1214 struct symbol
*func
;
1215 struct symtab_and_line sal
;
1216 struct thread_info
*tp
= inferior_thread ();
1218 clear_proceed_status ();
1221 frame
= get_current_frame ();
1223 /* Step until either exited from this function or greater
1224 than the current line (if in symbolic section) or pc (if
1227 pc
= get_frame_pc (frame
);
1228 func
= find_pc_function (pc
);
1232 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
1234 if (msymbol
== NULL
)
1235 error (_("Execution is not within a known function."));
1237 tp
->step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
1238 tp
->step_range_end
= pc
;
1242 sal
= find_pc_line (pc
, 0);
1244 tp
->step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
1245 tp
->step_range_end
= sal
.end
;
1248 tp
->step_over_calls
= STEP_OVER_ALL
;
1250 tp
->step_multi
= 0; /* Only one call to proceed */
1252 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1256 until_command (char *arg
, int from_tty
)
1260 if (!target_has_execution
)
1261 error (_("The program is not running."));
1263 /* Find out whether we must run in the background. */
1265 async_exec
= strip_bg_char (&arg
);
1267 /* If we must run in the background, but the target can't do it,
1269 if (async_exec
&& !target_can_async_p ())
1270 error (_("Asynchronous execution not supported on this target."));
1272 /* If we are not asked to run in the bg, then prepare to run in the
1273 foreground, synchronously. */
1274 if (!async_exec
&& target_can_async_p ())
1276 /* Simulate synchronous execution */
1277 async_disable_stdin ();
1281 until_break_command (arg
, from_tty
, 0);
1283 until_next_command (from_tty
);
1287 advance_command (char *arg
, int from_tty
)
1291 if (!target_has_execution
)
1292 error (_("The program is not running."));
1295 error_no_arg (_("a location"));
1297 /* Find out whether we must run in the background. */
1299 async_exec
= strip_bg_char (&arg
);
1301 /* If we must run in the background, but the target can't do it,
1303 if (async_exec
&& !target_can_async_p ())
1304 error (_("Asynchronous execution not supported on this target."));
1306 /* If we are not asked to run in the bg, then prepare to run in the
1307 foreground, synchronously. */
1308 if (!async_exec
&& target_can_async_p ())
1310 /* Simulate synchronous execution. */
1311 async_disable_stdin ();
1314 until_break_command (arg
, from_tty
, 1);
1317 /* Print the result of a function at the end of a 'finish' command. */
1320 print_return_value (struct type
*func_type
, struct type
*value_type
)
1322 struct gdbarch
*gdbarch
= get_regcache_arch (stop_registers
);
1323 struct cleanup
*old_chain
;
1324 struct ui_stream
*stb
;
1325 struct value
*value
;
1327 CHECK_TYPEDEF (value_type
);
1328 gdb_assert (TYPE_CODE (value_type
) != TYPE_CODE_VOID
);
1330 /* FIXME: 2003-09-27: When returning from a nested inferior function
1331 call, it's possible (with no help from the architecture vector)
1332 to locate and return/print a "struct return" value. This is just
1333 a more complicated case of what is already being done in in the
1334 inferior function call code. In fact, when inferior function
1335 calls are made async, this will likely be made the norm. */
1337 switch (gdbarch_return_value (gdbarch
, func_type
, value_type
,
1340 case RETURN_VALUE_REGISTER_CONVENTION
:
1341 case RETURN_VALUE_ABI_RETURNS_ADDRESS
:
1342 case RETURN_VALUE_ABI_PRESERVES_ADDRESS
:
1343 value
= allocate_value (value_type
);
1344 gdbarch_return_value (gdbarch
, func_type
, value_type
, stop_registers
,
1345 value_contents_raw (value
), NULL
);
1347 case RETURN_VALUE_STRUCT_CONVENTION
:
1351 internal_error (__FILE__
, __LINE__
, _("bad switch"));
1356 struct value_print_options opts
;
1359 stb
= ui_out_stream_new (uiout
);
1360 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
1361 ui_out_text (uiout
, "Value returned is ");
1362 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d",
1363 record_latest_value (value
));
1364 ui_out_text (uiout
, " = ");
1365 get_raw_print_options (&opts
);
1366 value_print (value
, stb
->stream
, &opts
);
1367 ui_out_field_stream (uiout
, "return-value", stb
);
1368 ui_out_text (uiout
, "\n");
1369 do_cleanups (old_chain
);
1373 ui_out_text (uiout
, "Value returned has type: ");
1374 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1375 ui_out_text (uiout
, ".");
1376 ui_out_text (uiout
, " Cannot determine contents\n");
1380 /* Stuff that needs to be done by the finish command after the target
1381 has stopped. In asynchronous mode, we wait for the target to stop
1382 in the call to poll or select in the event loop, so it is
1383 impossible to do all the stuff as part of the finish_command
1384 function itself. The only chance we have to complete this command
1385 is in fetch_inferior_event, which is called by the event loop as
1386 soon as it detects that the target has stopped. This function is
1387 called via the cmd_continuation pointer. */
1389 struct finish_command_continuation_args
1391 struct breakpoint
*breakpoint
;
1392 struct symbol
*function
;
1396 finish_command_continuation (void *arg
)
1398 struct finish_command_continuation_args
*a
= arg
;
1399 struct thread_info
*tp
= NULL
;
1402 if (!ptid_equal (inferior_ptid
, null_ptid
)
1403 && target_has_execution
1404 && is_stopped (inferior_ptid
))
1406 tp
= inferior_thread ();
1407 bs
= tp
->stop_bpstat
;
1410 if (bpstat_find_breakpoint (bs
, a
->breakpoint
) != NULL
1411 && a
->function
!= NULL
)
1413 struct type
*value_type
;
1415 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (a
->function
));
1417 internal_error (__FILE__
, __LINE__
,
1418 _("finish_command: function has no target type"));
1420 if (TYPE_CODE (value_type
) != TYPE_CODE_VOID
)
1421 print_return_value (SYMBOL_TYPE (a
->function
), value_type
);
1424 /* We suppress normal call of normal_stop observer and do it here so
1425 that the *stopped notification includes the return value. */
1426 if (bs
!= NULL
&& tp
->proceed_to_finish
)
1427 observer_notify_normal_stop (bs
, 1 /* print frame */);
1428 delete_breakpoint (a
->breakpoint
);
1432 finish_command_continuation_free_arg (void *arg
)
1437 /* finish_backward -- helper function for finish_command. */
1440 finish_backward (struct symbol
*function
)
1442 struct symtab_and_line sal
;
1443 struct thread_info
*tp
= inferior_thread ();
1444 struct breakpoint
*breakpoint
;
1445 struct cleanup
*old_chain
;
1447 CORE_ADDR func_addr
;
1450 pc
= get_frame_pc (get_current_frame ());
1452 if (find_pc_partial_function (pc
, NULL
, &func_addr
, NULL
) == 0)
1453 internal_error (__FILE__
, __LINE__
,
1454 _("Finish: couldn't find function."));
1456 sal
= find_pc_line (func_addr
, 0);
1458 /* We don't need a return value. */
1459 tp
->proceed_to_finish
= 0;
1460 /* Special case: if we're sitting at the function entry point,
1461 then all we need to do is take a reverse singlestep. We
1462 don't need to set a breakpoint, and indeed it would do us
1465 Note that this can only happen at frame #0, since there's
1466 no way that a function up the stack can have a return address
1467 that's equal to its entry point. */
1471 struct frame_info
*frame
= get_selected_frame (NULL
);
1472 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1474 /* Set breakpoint and continue. */
1476 set_momentary_breakpoint (gdbarch
, sal
,
1477 get_stack_frame_id (frame
),
1479 /* Tell the breakpoint to keep quiet. We won't be done
1480 until we've done another reverse single-step. */
1481 make_breakpoint_silent (breakpoint
);
1482 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1483 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1484 /* We will be stopped when proceed returns. */
1485 back_up
= bpstat_find_breakpoint (tp
->stop_bpstat
, breakpoint
) != NULL
;
1486 do_cleanups (old_chain
);
1492 /* If in fact we hit the step-resume breakpoint (and not
1493 some other breakpoint), then we're almost there --
1494 we just need to back up by one more single-step. */
1495 tp
->step_range_start
= tp
->step_range_end
= 1;
1496 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1501 /* finish_forward -- helper function for finish_command. */
1504 finish_forward (struct symbol
*function
, struct frame_info
*frame
)
1506 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1507 struct symtab_and_line sal
;
1508 struct thread_info
*tp
= inferior_thread ();
1509 struct breakpoint
*breakpoint
;
1510 struct cleanup
*old_chain
;
1511 struct finish_command_continuation_args
*cargs
;
1513 sal
= find_pc_line (get_frame_pc (frame
), 0);
1514 sal
.pc
= get_frame_pc (frame
);
1516 breakpoint
= set_momentary_breakpoint (gdbarch
, sal
,
1517 get_stack_frame_id (frame
),
1520 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1522 tp
->proceed_to_finish
= 1; /* We want stop_registers, please... */
1523 cargs
= xmalloc (sizeof (*cargs
));
1525 cargs
->breakpoint
= breakpoint
;
1526 cargs
->function
= function
;
1527 add_continuation (tp
, finish_command_continuation
, cargs
,
1528 finish_command_continuation_free_arg
);
1529 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1531 discard_cleanups (old_chain
);
1532 if (!target_can_async_p ())
1533 do_all_continuations ();
1536 /* "finish": Set a temporary breakpoint at the place the selected
1537 frame will return to, then continue. */
1540 finish_command (char *arg
, int from_tty
)
1542 struct frame_info
*frame
;
1543 struct symbol
*function
;
1547 /* Find out whether we must run in the background. */
1549 async_exec
= strip_bg_char (&arg
);
1551 /* If we must run in the background, but the target can't do it,
1553 if (async_exec
&& !target_can_async_p ())
1554 error (_("Asynchronous execution not supported on this target."));
1556 /* Don't try to async in reverse. */
1557 if (async_exec
&& execution_direction
== EXEC_REVERSE
)
1558 error (_("Asynchronous 'finish' not supported in reverse."));
1560 /* If we are not asked to run in the bg, then prepare to run in the
1561 foreground, synchronously. */
1562 if (!async_exec
&& target_can_async_p ())
1564 /* Simulate synchronous execution. */
1565 async_disable_stdin ();
1569 error (_("The \"finish\" command does not take any arguments."));
1570 if (!target_has_execution
)
1571 error (_("The program is not running."));
1573 frame
= get_prev_frame (get_selected_frame (_("No selected frame.")));
1575 error (_("\"finish\" not meaningful in the outermost frame."));
1577 clear_proceed_status ();
1579 /* Finishing from an inline frame is completely different. We don't
1580 try to show the "return value" - no way to locate it. So we do
1581 not need a completion. */
1582 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1585 /* Claim we are stepping in the calling frame. An empty step
1586 range means that we will stop once we aren't in a function
1587 called by that frame. We don't use the magic "1" value for
1588 step_range_end, because then infrun will think this is nexti,
1589 and not step over the rest of this inlined function call. */
1590 struct thread_info
*tp
= inferior_thread ();
1591 struct symtab_and_line empty_sal
;
1592 init_sal (&empty_sal
);
1593 set_step_info (frame
, empty_sal
);
1594 tp
->step_range_start
= tp
->step_range_end
= get_frame_pc (frame
);
1595 tp
->step_over_calls
= STEP_OVER_ALL
;
1597 /* Print info on the selected frame, including level number but not
1601 printf_filtered (_("Run till exit from "));
1602 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1605 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1609 /* Find the function we will return from. */
1611 function
= find_pc_function (get_frame_pc (get_selected_frame (NULL
)));
1613 /* Print info on the selected frame, including level number but not
1617 if (execution_direction
== EXEC_REVERSE
)
1618 printf_filtered (_("Run back to call of "));
1620 printf_filtered (_("Run till exit from "));
1622 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1625 if (execution_direction
== EXEC_REVERSE
)
1626 finish_backward (function
);
1628 finish_forward (function
, frame
);
1633 program_info (char *args
, int from_tty
)
1637 struct thread_info
*tp
;
1640 if (!target_has_execution
)
1642 printf_filtered (_("The program being debugged is not being run.\n"));
1647 ptid
= inferior_ptid
;
1650 struct target_waitstatus ws
;
1651 get_last_target_status (&ptid
, &ws
);
1654 if (ptid_equal (ptid
, null_ptid
) || is_exited (ptid
))
1655 error (_("Invalid selected thread."));
1656 else if (is_running (ptid
))
1657 error (_("Selected thread is running."));
1659 tp
= find_thread_ptid (ptid
);
1660 bs
= tp
->stop_bpstat
;
1661 stat
= bpstat_num (&bs
, &num
);
1663 target_files_info ();
1664 printf_filtered (_("Program stopped at %s.\n"),
1665 paddress (target_gdbarch
, stop_pc
));
1667 printf_filtered (_("It stopped after being stepped.\n"));
1670 /* There may be several breakpoints in the same place, so this
1671 isn't as strange as it seems. */
1676 printf_filtered (_("\
1677 It stopped at a breakpoint that has since been deleted.\n"));
1680 printf_filtered (_("It stopped at breakpoint %d.\n"), num
);
1681 stat
= bpstat_num (&bs
, &num
);
1684 else if (tp
->stop_signal
!= TARGET_SIGNAL_0
)
1686 printf_filtered (_("It stopped with signal %s, %s.\n"),
1687 target_signal_to_name (tp
->stop_signal
),
1688 target_signal_to_string (tp
->stop_signal
));
1693 printf_filtered (_("\
1694 Type \"info stack\" or \"info registers\" for more information.\n"));
1699 environment_info (char *var
, int from_tty
)
1703 char *val
= get_in_environ (current_inferior ()->environment
, var
);
1706 puts_filtered (var
);
1707 puts_filtered (" = ");
1708 puts_filtered (val
);
1709 puts_filtered ("\n");
1713 puts_filtered ("Environment variable \"");
1714 puts_filtered (var
);
1715 puts_filtered ("\" not defined.\n");
1720 char **vector
= environ_vector (current_inferior ()->environment
);
1723 puts_filtered (*vector
++);
1724 puts_filtered ("\n");
1730 set_environment_command (char *arg
, int from_tty
)
1732 char *p
, *val
, *var
;
1736 error_no_arg (_("environment variable and value"));
1738 /* Find seperation between variable name and value */
1739 p
= (char *) strchr (arg
, '=');
1740 val
= (char *) strchr (arg
, ' ');
1742 if (p
!= 0 && val
!= 0)
1744 /* We have both a space and an equals. If the space is before the
1745 equals, walk forward over the spaces til we see a nonspace
1746 (possibly the equals). */
1751 /* Now if the = is after the char following the spaces,
1752 take the char following the spaces. */
1756 else if (val
!= 0 && p
== 0)
1760 error_no_arg (_("environment variable to set"));
1762 if (p
== 0 || p
[1] == 0)
1766 p
= arg
+ strlen (arg
); /* So that savestring below will work */
1770 /* Not setting variable value to null */
1772 while (*val
== ' ' || *val
== '\t')
1776 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1779 var
= savestring (arg
, p
- arg
);
1782 printf_filtered (_("\
1783 Setting environment variable \"%s\" to null value.\n"),
1785 set_in_environ (current_inferior ()->environment
, var
, "");
1788 set_in_environ (current_inferior ()->environment
, var
, val
);
1793 unset_environment_command (char *var
, int from_tty
)
1797 /* If there is no argument, delete all environment variables.
1798 Ask for confirmation if reading from the terminal. */
1799 if (!from_tty
|| query (_("Delete all environment variables? ")))
1801 free_environ (current_inferior ()->environment
);
1802 current_inferior ()->environment
= make_environ ();
1806 unset_in_environ (current_inferior ()->environment
, var
);
1809 /* Handle the execution path (PATH variable) */
1811 static const char path_var_name
[] = "PATH";
1814 path_info (char *args
, int from_tty
)
1816 puts_filtered ("Executable and object file path: ");
1817 puts_filtered (get_in_environ (current_inferior ()->environment
, path_var_name
));
1818 puts_filtered ("\n");
1821 /* Add zero or more directories to the front of the execution path. */
1824 path_command (char *dirname
, int from_tty
)
1829 env
= get_in_environ (current_inferior ()->environment
, path_var_name
);
1830 /* Can be null if path is not set */
1833 exec_path
= xstrdup (env
);
1834 mod_path (dirname
, &exec_path
);
1835 set_in_environ (current_inferior ()->environment
, path_var_name
, exec_path
);
1838 path_info ((char *) NULL
, from_tty
);
1842 /* Print out the machine register regnum. If regnum is -1, print all
1843 registers (print_all == 1) or all non-float and non-vector
1844 registers (print_all == 0).
1846 For most machines, having all_registers_info() print the
1847 register(s) one per line is good enough. If a different format is
1848 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1849 regs), or there is an existing convention for showing all the
1850 registers, define the architecture method PRINT_REGISTERS_INFO to
1851 provide that format. */
1854 default_print_registers_info (struct gdbarch
*gdbarch
,
1855 struct ui_file
*file
,
1856 struct frame_info
*frame
,
1857 int regnum
, int print_all
)
1860 const int numregs
= gdbarch_num_regs (gdbarch
)
1861 + gdbarch_num_pseudo_regs (gdbarch
);
1862 gdb_byte buffer
[MAX_REGISTER_SIZE
];
1864 for (i
= 0; i
< numregs
; i
++)
1866 /* Decide between printing all regs, non-float / vector regs, or
1872 if (!gdbarch_register_reggroup_p (gdbarch
, i
, all_reggroup
))
1877 if (!gdbarch_register_reggroup_p (gdbarch
, i
, general_reggroup
))
1887 /* If the register name is empty, it is undefined for this
1888 processor, so don't display anything. */
1889 if (gdbarch_register_name (gdbarch
, i
) == NULL
1890 || *(gdbarch_register_name (gdbarch
, i
)) == '\0')
1893 fputs_filtered (gdbarch_register_name (gdbarch
, i
), file
);
1894 print_spaces_filtered (15 - strlen (gdbarch_register_name
1895 (gdbarch
, i
)), file
);
1897 /* Get the data in raw format. */
1898 if (! frame_register_read (frame
, i
, buffer
))
1900 fprintf_filtered (file
, "*value not available*\n");
1904 /* If virtual format is floating, print it that way, and in raw
1906 if (TYPE_CODE (register_type (gdbarch
, i
)) == TYPE_CODE_FLT
1907 || TYPE_CODE (register_type (gdbarch
, i
)) == TYPE_CODE_DECFLOAT
)
1910 struct value_print_options opts
;
1912 get_user_print_options (&opts
);
1914 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1915 file
, 0, &opts
, current_language
);
1917 fprintf_filtered (file
, "\t(raw 0x");
1918 for (j
= 0; j
< register_size (gdbarch
, i
); j
++)
1921 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
1924 idx
= register_size (gdbarch
, i
) - 1 - j
;
1925 fprintf_filtered (file
, "%02x", (unsigned char) buffer
[idx
]);
1927 fprintf_filtered (file
, ")");
1931 struct value_print_options opts
;
1933 /* Print the register in hex. */
1934 get_formatted_print_options (&opts
, 'x');
1936 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1939 /* If not a vector register, print it also according to its
1941 if (TYPE_VECTOR (register_type (gdbarch
, i
)) == 0)
1943 get_user_print_options (&opts
);
1945 fprintf_filtered (file
, "\t");
1946 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1947 file
, 0, &opts
, current_language
);
1951 fprintf_filtered (file
, "\n");
1956 registers_info (char *addr_exp
, int fpregs
)
1958 struct frame_info
*frame
;
1959 struct gdbarch
*gdbarch
;
1960 int regnum
, numregs
;
1963 if (!target_has_registers
)
1964 error (_("The program has no registers now."));
1965 frame
= get_selected_frame (NULL
);
1966 gdbarch
= get_frame_arch (frame
);
1970 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
1975 while (*addr_exp
!= '\0')
1980 /* Keep skipping leading white space. */
1981 if (isspace ((*addr_exp
)))
1987 /* Discard any leading ``$''. Check that there is something
1988 resembling a register following it. */
1989 if (addr_exp
[0] == '$')
1991 if (isspace ((*addr_exp
)) || (*addr_exp
) == '\0')
1992 error (_("Missing register name"));
1994 /* Find the start/end of this register name/num/group. */
1996 while ((*addr_exp
) != '\0' && !isspace ((*addr_exp
)))
2000 /* Figure out what we've found and display it. */
2002 /* A register name? */
2004 int regnum
= user_reg_map_name_to_regnum (gdbarch
, start
, end
- start
);
2007 /* User registers lie completely outside of the range of
2008 normal registers. Catch them early so that the target
2010 if (regnum
>= gdbarch_num_regs (gdbarch
)
2011 + gdbarch_num_pseudo_regs (gdbarch
))
2013 struct value_print_options opts
;
2014 struct value
*val
= value_of_user_reg (regnum
, frame
);
2016 printf_filtered ("%s: ", start
);
2017 get_formatted_print_options (&opts
, 'x');
2018 print_scalar_formatted (value_contents (val
),
2019 check_typedef (value_type (val
)),
2020 &opts
, 0, gdb_stdout
);
2021 printf_filtered ("\n");
2024 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2025 frame
, regnum
, fpregs
);
2030 /* A register group? */
2032 struct reggroup
*group
;
2033 for (group
= reggroup_next (gdbarch
, NULL
);
2035 group
= reggroup_next (gdbarch
, group
))
2037 /* Don't bother with a length check. Should the user
2038 enter a short register group name, go with the first
2039 group that matches. */
2040 if (strncmp (start
, reggroup_name (group
), end
- start
) == 0)
2047 regnum
< gdbarch_num_regs (gdbarch
)
2048 + gdbarch_num_pseudo_regs (gdbarch
);
2051 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
2052 gdbarch_print_registers_info (gdbarch
,
2060 /* Nothing matched. */
2061 error (_("Invalid register `%.*s'"), (int) (end
- start
), start
);
2066 all_registers_info (char *addr_exp
, int from_tty
)
2068 registers_info (addr_exp
, 1);
2072 nofp_registers_info (char *addr_exp
, int from_tty
)
2074 registers_info (addr_exp
, 0);
2078 print_vector_info (struct ui_file
*file
,
2079 struct frame_info
*frame
, const char *args
)
2081 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2083 if (gdbarch_print_vector_info_p (gdbarch
))
2084 gdbarch_print_vector_info (gdbarch
, file
, frame
, args
);
2088 int printed_something
= 0;
2091 regnum
< gdbarch_num_regs (gdbarch
)
2092 + gdbarch_num_pseudo_regs (gdbarch
);
2095 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, vector_reggroup
))
2097 printed_something
= 1;
2098 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2101 if (!printed_something
)
2102 fprintf_filtered (file
, "No vector information\n");
2107 vector_info (char *args
, int from_tty
)
2109 if (!target_has_registers
)
2110 error (_("The program has no registers now."));
2112 print_vector_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2115 /* Kill the inferior process. Make us have no inferior. */
2118 kill_command (char *arg
, int from_tty
)
2120 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2121 It should be a distinct flag that indicates that a target is active, cuz
2122 some targets don't have processes! */
2124 if (ptid_equal (inferior_ptid
, null_ptid
))
2125 error (_("The program is not being run."));
2126 if (!query (_("Kill the program being debugged? ")))
2127 error (_("Not confirmed."));
2130 /* If we still have other inferiors to debug, then don't mess with
2131 with their threads. */
2132 if (!have_inferiors ())
2134 init_thread_list (); /* Destroy thread info */
2136 /* Killing off the inferior can leave us with a core file. If
2137 so, print the state we are left in. */
2138 if (target_has_stack
)
2140 printf_filtered (_("In %s,\n"), target_longname
);
2141 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
);
2144 bfd_cache_close_all ();
2147 /* Used in `attach&' command. ARG is a point to an integer
2148 representing a process id. Proceed threads of this process iff
2149 they stopped due to debugger request, and when they did, they
2150 reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads
2151 that have been explicitly been told to stop. */
2154 proceed_after_attach_callback (struct thread_info
*thread
,
2157 int pid
= * (int *) arg
;
2159 if (ptid_get_pid (thread
->ptid
) == pid
2160 && !is_exited (thread
->ptid
)
2161 && !is_executing (thread
->ptid
)
2162 && !thread
->stop_requested
2163 && thread
->stop_signal
== TARGET_SIGNAL_0
)
2165 switch_to_thread (thread
->ptid
);
2166 clear_proceed_status ();
2167 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2174 proceed_after_attach (int pid
)
2176 /* Don't error out if the current thread is running, because
2177 there may be other stopped threads. */
2178 struct cleanup
*old_chain
;
2180 /* Backup current thread and selected frame. */
2181 old_chain
= make_cleanup_restore_current_thread ();
2183 iterate_over_threads (proceed_after_attach_callback
, &pid
);
2185 /* Restore selected ptid. */
2186 do_cleanups (old_chain
);
2191 * Should save/restore the tty state since it might be that the
2192 * program to be debugged was started on this tty and it wants
2193 * the tty in some state other than what we want. If it's running
2194 * on another terminal or without a terminal, then saving and
2195 * restoring the tty state is a harmless no-op.
2196 * This only needs to be done if we are attaching to a process.
2201 takes a program started up outside of gdb and ``attaches'' to it.
2202 This stops it cold in its tracks and allows us to start debugging it.
2203 and wait for the trace-trap that results from attaching. */
2206 attach_command_post_wait (char *args
, int from_tty
, int async_exec
)
2209 char *full_exec_path
= NULL
;
2210 struct inferior
*inferior
;
2212 inferior
= current_inferior ();
2213 inferior
->stop_soon
= NO_STOP_QUIETLY
;
2215 /* If no exec file is yet known, try to determine it from the
2217 exec_file
= (char *) get_exec_file (0);
2220 exec_file
= target_pid_to_exec_file (PIDGET (inferior_ptid
));
2223 /* It's possible we don't have a full path, but rather just a
2224 filename. Some targets, such as HP-UX, don't provide the
2227 Attempt to qualify the filename against the source path.
2228 (If that fails, we'll just fall back on the original
2229 filename. Not much more we can do...)
2231 if (!source_full_path_of (exec_file
, &full_exec_path
))
2232 full_exec_path
= xstrdup (exec_file
);
2234 exec_file_attach (full_exec_path
, from_tty
);
2235 symbol_file_add_main (full_exec_path
, from_tty
);
2240 reopen_exec_file ();
2244 /* Take any necessary post-attaching actions for this platform. */
2245 target_post_attach (PIDGET (inferior_ptid
));
2247 post_create_inferior (¤t_target
, from_tty
);
2249 /* Install inferior's terminal modes. */
2250 target_terminal_inferior ();
2254 /* The user requested an `attach&', so be sure to leave threads
2255 that didn't get a signal running. */
2257 /* Immediatelly resume all suspended threads of this inferior,
2258 and this inferior only. This should have no effect on
2259 already running threads. If a thread has been stopped with a
2260 signal, leave it be. */
2262 proceed_after_attach (inferior
->pid
);
2265 if (inferior_thread ()->stop_signal
== TARGET_SIGNAL_0
)
2267 clear_proceed_status ();
2268 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2274 /* The user requested a plain `attach', so be sure to leave
2275 the inferior stopped. */
2277 if (target_can_async_p ())
2278 async_enable_stdin ();
2280 /* At least the current thread is already stopped. */
2282 /* In all-stop, by definition, all threads have to be already
2283 stopped at this point. In non-stop, however, although the
2284 selected thread is stopped, others may still be executing.
2285 Be sure to explicitly stop all threads of the process. This
2286 should have no effect on already stopped threads. */
2288 target_stop (pid_to_ptid (inferior
->pid
));
2290 /* Tell the user/frontend where we're stopped. */
2292 if (deprecated_attach_hook
)
2293 deprecated_attach_hook ();
2297 struct attach_command_continuation_args
2305 attach_command_continuation (void *args
)
2307 struct attach_command_continuation_args
*a
= args
;
2308 attach_command_post_wait (a
->args
, a
->from_tty
, a
->async_exec
);
2312 attach_command_continuation_free_args (void *args
)
2314 struct attach_command_continuation_args
*a
= args
;
2320 attach_command (char *args
, int from_tty
)
2323 char *full_exec_path
= NULL
;
2325 struct cleanup
*back_to
= make_cleanup (null_cleanup
, NULL
);
2327 dont_repeat (); /* Not for the faint of heart */
2329 if (gdbarch_has_global_solist (target_gdbarch
))
2330 /* Don't complain if all processes share the same symbol
2333 else if (target_has_execution
)
2335 if (query (_("A program is being debugged already. Kill it? ")))
2338 error (_("Not killed."));
2341 /* Clean up any leftovers from other runs. Some other things from
2342 this function should probably be moved into target_pre_inferior. */
2343 target_pre_inferior (from_tty
);
2345 if (non_stop
&& !target_supports_non_stop ())
2346 error (_("Cannot attach to this target in non-stop mode"));
2350 async_exec
= strip_bg_char (&args
);
2352 /* If we get a request for running in the bg but the target
2353 doesn't support it, error out. */
2354 if (async_exec
&& !target_can_async_p ())
2355 error (_("Asynchronous execution not supported on this target."));
2358 /* If we don't get a request of running in the bg, then we need
2359 to simulate synchronous (fg) execution. */
2360 if (!async_exec
&& target_can_async_p ())
2362 /* Simulate synchronous execution */
2363 async_disable_stdin ();
2364 make_cleanup ((make_cleanup_ftype
*)async_enable_stdin
, NULL
);
2367 target_attach (args
, from_tty
);
2369 /* Set up the "saved terminal modes" of the inferior
2370 based on what modes we are starting it with. */
2371 target_terminal_init ();
2373 /* Set up execution context to know that we should return from
2374 wait_for_inferior as soon as the target reports a stop. */
2375 init_wait_for_inferior ();
2376 clear_proceed_status ();
2380 /* If we find that the current thread isn't stopped, explicitly
2381 do so now, because we're going to install breakpoints and
2385 /* The user requested an `attach&'; stop just one thread. */
2386 target_stop (inferior_ptid
);
2388 /* The user requested an `attach', so stop all threads of this
2390 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid
)));
2393 /* Some system don't generate traps when attaching to inferior.
2394 E.g. Mach 3 or GNU hurd. */
2395 if (!target_attach_no_wait
)
2397 struct inferior
*inferior
= current_inferior ();
2399 /* Careful here. See comments in inferior.h. Basically some
2400 OSes don't ignore SIGSTOPs on continue requests anymore. We
2401 need a way for handle_inferior_event to reset the stop_signal
2402 variable after an attach, and this is what
2403 STOP_QUIETLY_NO_SIGSTOP is for. */
2404 inferior
->stop_soon
= STOP_QUIETLY_NO_SIGSTOP
;
2406 if (target_can_async_p ())
2408 /* sync_execution mode. Wait for stop. */
2409 struct attach_command_continuation_args
*a
;
2411 a
= xmalloc (sizeof (*a
));
2412 a
->args
= xstrdup (args
);
2413 a
->from_tty
= from_tty
;
2414 a
->async_exec
= async_exec
;
2415 add_inferior_continuation (attach_command_continuation
, a
,
2416 attach_command_continuation_free_args
);
2417 discard_cleanups (back_to
);
2421 wait_for_inferior (0);
2424 attach_command_post_wait (args
, from_tty
, async_exec
);
2425 discard_cleanups (back_to
);
2428 /* We had just found out that the target was already attached to an
2429 inferior. PTID points at a thread of this new inferior, that is
2430 the most likely to be stopped right now, but not necessarily so.
2431 The new inferior is assumed to be already added to the inferior
2432 list at this point. If LEAVE_RUNNING, then leave the threads of
2433 this inferior running, except those we've explicitly seen reported
2437 notice_new_inferior (ptid_t ptid
, int leave_running
, int from_tty
)
2439 struct cleanup
* old_chain
;
2442 old_chain
= make_cleanup (null_cleanup
, NULL
);
2444 /* If in non-stop, leave threads as running as they were. If
2445 they're stopped for some reason other than us telling it to, the
2446 target reports a signal != TARGET_SIGNAL_0. We don't try to
2447 resume threads with such a stop signal. */
2448 async_exec
= non_stop
;
2450 if (!ptid_equal (inferior_ptid
, null_ptid
))
2451 make_cleanup_restore_current_thread ();
2453 switch_to_thread (ptid
);
2455 /* When we "notice" a new inferior we need to do all the things we
2456 would normally do if we had just attached to it. */
2458 if (is_executing (inferior_ptid
))
2460 struct inferior
*inferior
= current_inferior ();
2462 /* We're going to install breakpoints, and poke at memory,
2463 ensure that the inferior is stopped for a moment while we do
2465 target_stop (inferior_ptid
);
2467 inferior
->stop_soon
= STOP_QUIETLY_REMOTE
;
2469 /* Wait for stop before proceeding. */
2470 if (target_can_async_p ())
2472 struct attach_command_continuation_args
*a
;
2474 a
= xmalloc (sizeof (*a
));
2475 a
->args
= xstrdup ("");
2476 a
->from_tty
= from_tty
;
2477 a
->async_exec
= async_exec
;
2478 add_inferior_continuation (attach_command_continuation
, a
,
2479 attach_command_continuation_free_args
);
2481 do_cleanups (old_chain
);
2485 wait_for_inferior (0);
2488 async_exec
= leave_running
;
2489 attach_command_post_wait ("" /* args */, from_tty
, async_exec
);
2491 do_cleanups (old_chain
);
2496 * takes a program previously attached to and detaches it.
2497 * The program resumes execution and will no longer stop
2498 * on signals, etc. We better not have left any breakpoints
2499 * in the program or it'll die when it hits one. For this
2500 * to work, it may be necessary for the process to have been
2501 * previously attached. It *might* work if the program was
2502 * started via the normal ptrace (PTRACE_TRACEME).
2506 detach_command (char *args
, int from_tty
)
2508 dont_repeat (); /* Not for the faint of heart. */
2510 if (ptid_equal (inferior_ptid
, null_ptid
))
2511 error (_("The program is not being run."));
2513 disconnect_or_stop_tracing (from_tty
);
2515 target_detach (args
, from_tty
);
2517 /* If the solist is global across inferiors, don't clear it when we
2518 detach from a single inferior. */
2519 if (!gdbarch_has_global_solist (target_gdbarch
))
2520 no_shared_libraries (NULL
, from_tty
);
2522 /* If we still have inferiors to debug, then don't mess with their
2524 if (!have_inferiors ())
2525 init_thread_list ();
2527 if (deprecated_detach_hook
)
2528 deprecated_detach_hook ();
2531 /* Disconnect from the current target without resuming it (leaving it
2532 waiting for a debugger).
2534 We'd better not have left any breakpoints in the program or the
2535 next debugger will get confused. Currently only supported for some
2536 remote targets, since the normal attach mechanisms don't work on
2537 stopped processes on some native platforms (e.g. GNU/Linux). */
2540 disconnect_command (char *args
, int from_tty
)
2542 dont_repeat (); /* Not for the faint of heart */
2543 target_disconnect (args
, from_tty
);
2544 no_shared_libraries (NULL
, from_tty
);
2545 init_thread_list ();
2546 if (deprecated_detach_hook
)
2547 deprecated_detach_hook ();
2551 interrupt_target_1 (int all_threads
)
2555 ptid
= minus_one_ptid
;
2557 ptid
= inferior_ptid
;
2560 /* Tag the thread as having been explicitly requested to stop, so
2561 other parts of gdb know not to resume this thread automatically,
2562 if it was stopped due to an internal event. Limit this to
2563 non-stop mode, as when debugging a multi-threaded application in
2564 all-stop mode, we will only get one stop event --- it's undefined
2565 which thread will report the event. */
2567 set_stop_requested (ptid
, 1);
2570 /* Stop the execution of the target while running in async mode, in
2571 the backgound. In all-stop, stop the whole process. In non-stop
2572 mode, stop the current thread only by default, or stop all threads
2573 if the `-a' switch is used. */
2575 /* interrupt [-a] */
2577 interrupt_target_command (char *args
, int from_tty
)
2579 if (target_can_async_p ())
2581 int all_threads
= 0;
2583 dont_repeat (); /* Not for the faint of heart */
2586 && strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
2589 if (!non_stop
&& all_threads
)
2590 error (_("-a is meaningless in all-stop mode."));
2592 interrupt_target_1 (all_threads
);
2597 print_float_info (struct ui_file
*file
,
2598 struct frame_info
*frame
, const char *args
)
2600 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2602 if (gdbarch_print_float_info_p (gdbarch
))
2603 gdbarch_print_float_info (gdbarch
, file
, frame
, args
);
2607 int printed_something
= 0;
2610 regnum
< gdbarch_num_regs (gdbarch
)
2611 + gdbarch_num_pseudo_regs (gdbarch
);
2614 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, float_reggroup
))
2616 printed_something
= 1;
2617 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2620 if (!printed_something
)
2621 fprintf_filtered (file
, "\
2622 No floating-point info available for this processor.\n");
2627 float_info (char *args
, int from_tty
)
2629 if (!target_has_registers
)
2630 error (_("The program has no registers now."));
2632 print_float_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2636 unset_command (char *args
, int from_tty
)
2638 printf_filtered (_("\
2639 \"unset\" must be followed by the name of an unset subcommand.\n"));
2640 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
2644 _initialize_infcmd (void)
2646 struct cmd_list_element
*c
= NULL
;
2648 /* add the filename of the terminal connected to inferior I/O */
2649 add_setshow_filename_cmd ("inferior-tty", class_run
,
2650 &inferior_io_terminal_scratch
, _("\
2651 Set terminal for future runs of program being debugged."), _("\
2652 Show terminal for future runs of program being debugged."), _("\
2653 Usage: set inferior-tty /dev/pts/1"),
2654 set_inferior_tty_command
,
2655 show_inferior_tty_command
,
2656 &setlist
, &showlist
);
2657 add_com_alias ("tty", "set inferior-tty", class_alias
, 0);
2659 add_setshow_optional_filename_cmd ("args", class_run
,
2660 &inferior_args_scratch
, _("\
2661 Set argument list to give program being debugged when it is started."), _("\
2662 Show argument list to give program being debugged when it is started."), _("\
2663 Follow this command with any number of args, to be passed to the program."),
2666 &setlist
, &showlist
);
2668 c
= add_cmd ("environment", no_class
, environment_info
, _("\
2669 The environment to give the program, or one variable's value.\n\
2670 With an argument VAR, prints the value of environment variable VAR to\n\
2671 give the program being debugged. With no arguments, prints the entire\n\
2672 environment to be given to the program."), &showlist
);
2673 set_cmd_completer (c
, noop_completer
);
2675 add_prefix_cmd ("unset", no_class
, unset_command
,
2676 _("Complement to certain \"set\" commands."),
2677 &unsetlist
, "unset ", 0, &cmdlist
);
2679 c
= add_cmd ("environment", class_run
, unset_environment_command
, _("\
2680 Cancel environment variable VAR for the program.\n\
2681 This does not affect the program until the next \"run\" command."),
2683 set_cmd_completer (c
, noop_completer
);
2685 c
= add_cmd ("environment", class_run
, set_environment_command
, _("\
2686 Set environment variable value to give the program.\n\
2687 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2688 VALUES of environment variables are uninterpreted strings.\n\
2689 This does not affect the program until the next \"run\" command."),
2691 set_cmd_completer (c
, noop_completer
);
2693 c
= add_com ("path", class_files
, path_command
, _("\
2694 Add directory DIR(s) to beginning of search path for object files.\n\
2695 $cwd in the path means the current working directory.\n\
2696 This path is equivalent to the $PATH shell variable. It is a list of\n\
2697 directories, separated by colons. These directories are searched to find\n\
2698 fully linked executable files and separately compiled object files as needed."));
2699 set_cmd_completer (c
, filename_completer
);
2701 c
= add_cmd ("paths", no_class
, path_info
, _("\
2702 Current search path for finding object files.\n\
2703 $cwd in the path means the current working directory.\n\
2704 This path is equivalent to the $PATH shell variable. It is a list of\n\
2705 directories, separated by colons. These directories are searched to find\n\
2706 fully linked executable files and separately compiled object files as needed."),
2708 set_cmd_completer (c
, noop_completer
);
2710 add_prefix_cmd ("kill", class_run
, kill_command
,
2711 _("Kill execution of program being debugged."),
2712 &killlist
, "kill ", 0, &cmdlist
);
2714 add_com ("attach", class_run
, attach_command
, _("\
2715 Attach to a process or file outside of GDB.\n\
2716 This command attaches to another target, of the same type as your last\n\
2717 \"target\" command (\"info files\" will show your target stack).\n\
2718 The command may take as argument a process id or a device file.\n\
2719 For a process id, you must have permission to send the process a signal,\n\
2720 and it must have the same effective uid as the debugger.\n\
2721 When using \"attach\" with a process id, the debugger finds the\n\
2722 program running in the process, looking first in the current working\n\
2723 directory, or (if not found there) using the source file search path\n\
2724 (see the \"directory\" command). You can also use the \"file\" command\n\
2725 to specify the program, and to load its symbol table."));
2727 add_prefix_cmd ("detach", class_run
, detach_command
, _("\
2728 Detach a process or file previously attached.\n\
2729 If a process, it is no longer traced, and it continues its execution. If\n\
2730 you were debugging a file, the file is closed and gdb no longer accesses it."),
2731 &detachlist
, "detach ", 0, &cmdlist
);
2733 add_com ("disconnect", class_run
, disconnect_command
, _("\
2734 Disconnect from a target.\n\
2735 The target will wait for another debugger to connect. Not available for\n\
2738 add_com ("signal", class_run
, signal_command
, _("\
2739 Continue program giving it signal specified by the argument.\n\
2740 An argument of \"0\" means continue program without giving it a signal."));
2742 add_com ("stepi", class_run
, stepi_command
, _("\
2743 Step one instruction exactly.\n\
2744 Argument N means do this N times (or till program stops for another reason)."));
2745 add_com_alias ("si", "stepi", class_alias
, 0);
2747 add_com ("nexti", class_run
, nexti_command
, _("\
2748 Step one instruction, but proceed through subroutine calls.\n\
2749 Argument N means do this N times (or till program stops for another reason)."));
2750 add_com_alias ("ni", "nexti", class_alias
, 0);
2752 add_com ("finish", class_run
, finish_command
, _("\
2753 Execute until selected stack frame returns.\n\
2754 Upon return, the value returned is printed and put in the value history."));
2755 add_com_alias ("fin", "finish", class_run
, 1);
2757 add_com ("next", class_run
, next_command
, _("\
2758 Step program, proceeding through subroutine calls.\n\
2759 Like the \"step\" command as long as subroutine calls do not happen;\n\
2760 when they do, the call is treated as one instruction.\n\
2761 Argument N means do this N times (or till program stops for another reason)."));
2762 add_com_alias ("n", "next", class_run
, 1);
2764 add_com_alias ("S", "next", class_run
, 1);
2766 add_com ("step", class_run
, step_command
, _("\
2767 Step program until it reaches a different source line.\n\
2768 Argument N means do this N times (or till program stops for another reason)."));
2769 add_com_alias ("s", "step", class_run
, 1);
2771 c
= add_com ("until", class_run
, until_command
, _("\
2772 Execute until the program reaches a source line greater than the current\n\
2773 or a specified location (same args as break command) within the current frame."));
2774 set_cmd_completer (c
, location_completer
);
2775 add_com_alias ("u", "until", class_run
, 1);
2777 c
= add_com ("advance", class_run
, advance_command
, _("\
2778 Continue the program up to the given location (same form as args for break command).\n\
2779 Execution will also stop upon exit from the current stack frame."));
2780 set_cmd_completer (c
, location_completer
);
2782 c
= add_com ("jump", class_run
, jump_command
, _("\
2783 Continue program being debugged at specified line or address.\n\
2784 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2785 for an address to start at."));
2786 set_cmd_completer (c
, location_completer
);
2790 c
= add_com ("go", class_run
, go_command
, _("\
2791 Usage: go <location>\n\
2792 Continue program being debugged, stopping at specified line or \n\
2794 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2795 expression for an address to start at.\n\
2796 This command is a combination of tbreak and jump."));
2797 set_cmd_completer (c
, location_completer
);
2801 add_com_alias ("g", "go", class_run
, 1);
2803 c
= add_com ("continue", class_run
, continue_command
, _("\
2804 Continue program being debugged, after signal or breakpoint.\n\
2805 If proceeding from breakpoint, a number N may be used as an argument,\n\
2806 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2807 the breakpoint won't break until the Nth time it is reached).\n\
2809 If non-stop mode is enabled, continue only the current thread,\n\
2810 otherwise all the threads in the program are continued. To \n\
2811 continue all stopped threads in non-stop mode, use the -a option.\n\
2812 Specifying -a and an ignore count simultaneously is an error."));
2813 add_com_alias ("c", "cont", class_run
, 1);
2814 add_com_alias ("fg", "cont", class_run
, 1);
2816 c
= add_com ("run", class_run
, run_command
, _("\
2817 Start debugged program. You may specify arguments to give it.\n\
2818 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2819 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2820 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2821 To cancel previous arguments and run with no arguments,\n\
2822 use \"set args\" without arguments."));
2823 set_cmd_completer (c
, filename_completer
);
2824 add_com_alias ("r", "run", class_run
, 1);
2826 add_com ("R", class_run
, run_no_args_command
,
2827 _("Start debugged program with no arguments."));
2829 c
= add_com ("start", class_run
, start_command
, _("\
2830 Run the debugged program until the beginning of the main procedure.\n\
2831 You may specify arguments to give to your program, just as with the\n\
2832 \"run\" command."));
2833 set_cmd_completer (c
, filename_completer
);
2835 c
= add_com ("interrupt", class_run
, interrupt_target_command
,
2836 _("Interrupt the execution of the debugged program.\n\
2837 If non-stop mode is enabled, interrupt only the current thread,\n\
2838 otherwise all the threads in the program are stopped. To \n\
2839 interrupt all running threads in non-stop mode, use the -a option."));
2841 add_info ("registers", nofp_registers_info
, _("\
2842 List of integer registers and their contents, for selected stack frame.\n\
2843 Register name as argument means describe only that register."));
2844 add_info_alias ("r", "registers", 1);
2847 add_com ("lr", class_info
, nofp_registers_info
, _("\
2848 List of integer registers and their contents, for selected stack frame.\n\
2849 Register name as argument means describe only that register."));
2850 add_info ("all-registers", all_registers_info
, _("\
2851 List of all registers and their contents, for selected stack frame.\n\
2852 Register name as argument means describe only that register."));
2854 add_info ("program", program_info
,
2855 _("Execution status of the program."));
2857 add_info ("float", float_info
,
2858 _("Print the status of the floating point unit\n"));
2860 add_info ("vector", vector_info
,
2861 _("Print the status of the vector unit\n"));