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"
57 #include "tracepoint.h"
59 /* Functions exported for general use, in inferior.h: */
61 void all_registers_info (char *, int);
63 void registers_info (char *, int);
65 void nexti_command (char *, int);
67 void stepi_command (char *, int);
69 void continue_command (char *, int);
71 void interrupt_target_command (char *args
, int from_tty
);
73 /* Local functions: */
75 static void nofp_registers_info (char *, int);
77 static void print_return_value (struct type
*func_type
,
78 struct type
*value_type
);
80 static void until_next_command (int);
82 static void until_command (char *, int);
84 static void path_info (char *, int);
86 static void path_command (char *, int);
88 static void unset_command (char *, int);
90 static void float_info (char *, int);
92 static void disconnect_command (char *, int);
94 static void unset_environment_command (char *, int);
96 static void set_environment_command (char *, int);
98 static void environment_info (char *, int);
100 static void program_info (char *, int);
102 static void finish_command (char *, int);
104 static void signal_command (char *, int);
106 static void jump_command (char *, int);
108 static void step_1 (int, int, char *);
109 static void step_once (int skip_subroutines
, int single_inst
, int count
, int thread
);
111 static void next_command (char *, int);
113 static void step_command (char *, int);
115 static void run_command (char *, int);
117 static void run_no_args_command (char *args
, int from_tty
);
119 static void go_command (char *line_no
, int from_tty
);
121 static int strip_bg_char (char **);
123 void _initialize_infcmd (void);
125 #define ERROR_NO_INFERIOR \
126 if (!target_has_execution) error (_("The program is not being run."));
128 /* Scratch area where string containing arguments to give to the program will be
129 stored by 'set args'. As soon as anything is stored, notice_args_set will
130 move it into per-inferior storage. Arguments are separated by spaces. Empty
131 string (pointer to '\0') means no args. */
133 static char *inferior_args_scratch
;
135 /* Scratch area where 'set inferior-tty' will store user-provided value.
136 We'll immediate copy it into per-inferior storage. */
138 static char *inferior_io_terminal_scratch
;
140 /* Pid of our debugged inferior, or 0 if no inferior now.
141 Since various parts of infrun.c test this to see whether there is a program
142 being debugged it should be nonzero (currently 3 is used) for remote
145 ptid_t inferior_ptid
;
147 /* Address at which inferior stopped. */
151 /* Flag indicating that a command has proceeded the inferior past the
152 current breakpoint. */
154 int breakpoint_proceeded
;
156 /* Nonzero if stopped due to completion of a stack dummy routine. */
158 int stop_stack_dummy
;
160 /* Nonzero if stopped due to a random (unexpected) signal in inferior
163 int stopped_by_random_signal
;
166 /* Accessor routines. */
168 /* Set the io terminal for the current inferior. Ownership of
169 TERMINAL_NAME is not transferred. */
172 set_inferior_io_terminal (const char *terminal_name
)
174 xfree (current_inferior ()->terminal
);
175 current_inferior ()->terminal
= terminal_name
? xstrdup (terminal_name
) : 0;
179 get_inferior_io_terminal (void)
181 return current_inferior ()->terminal
;
185 set_inferior_tty_command (char *args
, int from_tty
,
186 struct cmd_list_element
*c
)
188 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
189 Now route it to current inferior. */
190 set_inferior_io_terminal (inferior_io_terminal_scratch
);
194 show_inferior_tty_command (struct ui_file
*file
, int from_tty
,
195 struct cmd_list_element
*c
, const char *value
)
197 /* Note that we ignore the passed-in value in favor of computing it
199 const char *inferior_io_terminal
= get_inferior_io_terminal ();
200 if (inferior_io_terminal
== NULL
)
201 inferior_io_terminal
= "";
202 fprintf_filtered (gdb_stdout
,
203 _("Terminal for future runs of program being debugged "
204 "is \"%s\".\n"), inferior_io_terminal
);
208 get_inferior_args (void)
210 if (current_inferior ()->argc
!= 0)
214 n
= construct_inferior_arguments (current_inferior ()->argc
,
215 current_inferior ()->argv
);
216 set_inferior_args (n
);
220 if (current_inferior ()->args
== NULL
)
221 current_inferior ()->args
= xstrdup ("");
223 return current_inferior ()->args
;
226 /* Set the arguments for the current inferior. Ownership of
227 NEWARGS is not transferred. */
230 set_inferior_args (char *newargs
)
232 xfree (current_inferior ()->args
);
233 current_inferior ()->args
= newargs
? xstrdup (newargs
) : NULL
;
234 current_inferior ()->argc
= 0;
235 current_inferior ()->argv
= 0;
239 set_inferior_args_vector (int argc
, char **argv
)
241 current_inferior ()->argc
= argc
;
242 current_inferior ()->argv
= argv
;
245 /* Notice when `set args' is run. */
247 set_args_command (char *args
, int from_tty
, struct cmd_list_element
*c
)
249 /* CLI has assigned the user-provided value to inferior_args_scratch.
250 Now route it to current inferior. */
251 set_inferior_args (inferior_args_scratch
);
254 /* Notice when `show args' is run. */
256 show_args_command (struct ui_file
*file
, int from_tty
,
257 struct cmd_list_element
*c
, const char *value
)
259 /* Note that we ignore the passed-in value in favor of computing it
261 deprecated_show_value_hack (file
, from_tty
, c
, get_inferior_args ());
265 /* Compute command-line string given argument vector. This does the
266 same shell processing as fork_inferior. */
268 construct_inferior_arguments (int argc
, char **argv
)
272 if (STARTUP_WITH_SHELL
)
274 /* This holds all the characters considered special to the
275 typical Unix shells. We include `^' because the SunOS
276 /bin/sh treats it as a synonym for `|'. */
277 char *special
= "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
282 /* We over-compute the size. It shouldn't matter. */
283 for (i
= 0; i
< argc
; ++i
)
284 length
+= 3 * strlen (argv
[i
]) + 1 + 2 * (argv
[i
][0] == '\0');
286 result
= (char *) xmalloc (length
);
289 for (i
= 0; i
< argc
; ++i
)
294 /* Need to handle empty arguments specially. */
295 if (argv
[i
][0] == '\0')
302 for (cp
= argv
[i
]; *cp
; ++cp
)
306 /* A newline cannot be quoted with a backslash (it
307 just disappears), only by putting it inside
315 if (strchr (special
, *cp
) != NULL
)
326 /* In this case we can't handle arguments that contain spaces,
327 tabs, or newlines -- see breakup_args(). */
331 for (i
= 0; i
< argc
; ++i
)
333 char *cp
= strchr (argv
[i
], ' ');
335 cp
= strchr (argv
[i
], '\t');
337 cp
= strchr (argv
[i
], '\n');
339 error (_("can't handle command-line argument containing whitespace"));
340 length
+= strlen (argv
[i
]) + 1;
343 result
= (char *) xmalloc (length
);
345 for (i
= 0; i
< argc
; ++i
)
348 strcat (result
, " ");
349 strcat (result
, argv
[i
]);
357 /* This function detects whether or not a '&' character (indicating
358 background execution) has been added as *the last* of the arguments ARGS
359 of a command. If it has, it removes it and returns 1. Otherwise it
360 does nothing and returns 0. */
362 strip_bg_char (char **args
)
366 p
= strchr (*args
, '&');
370 if (p
== (*args
+ strlen (*args
) - 1))
372 if (strlen (*args
) > 1)
376 while (*p
== ' ' || *p
== '\t');
387 /* Common actions to take after creating any sort of inferior, by any
388 means (running, attaching, connecting, et cetera). The target
389 should be stopped. */
392 post_create_inferior (struct target_ops
*target
, int from_tty
)
394 /* Be sure we own the terminal in case write operations are performed. */
395 target_terminal_ours ();
397 /* If the target hasn't taken care of this already, do it now.
398 Targets which need to access registers during to_open,
399 to_create_inferior, or to_attach should do it earlier; but many
401 target_find_description ();
403 /* Now that we know the register layout, retrieve current PC. */
404 stop_pc
= regcache_read_pc (get_current_regcache ());
408 /* Create the hooks to handle shared library load and unload
410 #ifdef SOLIB_CREATE_INFERIOR_HOOK
411 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid
));
413 solib_create_inferior_hook (from_tty
);
417 /* If the solist is global across processes, there's no need to
419 if (exec_bfd
&& !gdbarch_has_global_solist (target_gdbarch
))
421 /* Sometimes the platform-specific hook loads initial shared
422 libraries, and sometimes it doesn't. If it doesn't FROM_TTY will be
423 incorrectly 0 but such solib targets should be fixed anyway. If we
424 made all the inferior hook methods consistent, this call could be
425 removed. Call it only after the solib target has been initialized by
426 solib_create_inferior_hook. */
429 SOLIB_ADD (NULL
, 0, target
, auto_solib_add
);
431 solib_add (NULL
, 0, target
, auto_solib_add
);
435 /* If the user sets watchpoints before execution having started,
436 then she gets software watchpoints, because GDB can't know which
437 target will end up being pushed, or if it supports hardware
438 watchpoints or not. breakpoint_re_set takes care of promoting
439 watchpoints to hardware watchpoints if possible, however, if this
440 new inferior doesn't load shared libraries or we don't pull in
441 symbols from any other source on this target/arch,
442 breakpoint_re_set is never called. Call it now so that software
443 watchpoints get a chance to be promoted to hardware watchpoints
444 if the now pushed target supports hardware watchpoints. */
445 breakpoint_re_set ();
447 observer_notify_inferior_created (target
, from_tty
);
450 /* Kill the inferior if already running. This function is designed
451 to be called when we are about to start the execution of the program
452 from the beginning. Ask the user to confirm that he wants to restart
453 the program being debugged when FROM_TTY is non-null. */
456 kill_if_already_running (int from_tty
)
458 if (! ptid_equal (inferior_ptid
, null_ptid
) && target_has_execution
)
460 /* Bail out before killing the program if we will not be able to
462 target_require_runnable ();
465 && !query (_("The program being debugged has been started already.\n\
466 Start it from the beginning? ")))
467 error (_("Program not restarted."));
472 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
473 a temporary breakpoint at the begining of the main program before
474 running the program. */
477 run_command_1 (char *args
, int from_tty
, int tbreak_at_main
)
480 struct cleanup
*old_chain
;
485 kill_if_already_running (from_tty
);
487 init_wait_for_inferior ();
488 clear_breakpoint_hit_counts ();
490 /* Clean up any leftovers from other runs. Some other things from
491 this function should probably be moved into target_pre_inferior. */
492 target_pre_inferior (from_tty
);
494 /* The comment here used to read, "The exec file is re-read every
495 time we do a generic_mourn_inferior, so we just have to worry
496 about the symbol file." The `generic_mourn_inferior' function
497 gets called whenever the program exits. However, suppose the
498 program exits, and *then* the executable file changes? We need
499 to check again here. Since reopen_exec_file doesn't do anything
500 if the timestamp hasn't changed, I don't see the harm. */
504 /* Insert the temporary breakpoint if a location was specified. */
506 tbreak_command (main_name (), 0);
508 exec_file
= (char *) get_exec_file (0);
510 if (non_stop
&& !target_supports_non_stop ())
511 error (_("The target does not support running in non-stop mode."));
513 /* We keep symbols from add-symbol-file, on the grounds that the
514 user might want to add some symbols before running the program
515 (right?). But sometimes (dynamic loading where the user manually
516 introduces the new symbols with add-symbol-file), the code which
517 the symbols describe does not persist between runs. Currently
518 the user has to manually nuke all symbols between runs if they
519 want them to go away (PR 2207). This is probably reasonable. */
523 if (target_can_async_p ())
524 async_disable_stdin ();
528 int async_exec
= strip_bg_char (&args
);
530 /* If we get a request for running in the bg but the target
531 doesn't support it, error out. */
532 if (async_exec
&& !target_can_async_p ())
533 error (_("Asynchronous execution not supported on this target."));
535 /* If we don't get a request of running in the bg, then we need
536 to simulate synchronous (fg) execution. */
537 if (!async_exec
&& target_can_async_p ())
539 /* Simulate synchronous execution */
540 async_disable_stdin ();
543 /* If there were other args, beside '&', process them. */
545 set_inferior_args (args
);
550 ui_out_field_string (uiout
, NULL
, "Starting program");
551 ui_out_text (uiout
, ": ");
553 ui_out_field_string (uiout
, "execfile", exec_file
);
554 ui_out_spaces (uiout
, 1);
555 /* We call get_inferior_args() because we might need to compute
557 ui_out_field_string (uiout
, "infargs", get_inferior_args ());
558 ui_out_text (uiout
, "\n");
559 ui_out_flush (uiout
);
562 /* We call get_inferior_args() because we might need to compute
564 target_create_inferior (exec_file
, get_inferior_args (),
565 environ_vector (current_inferior ()->environment
), from_tty
);
567 /* We're starting off a new process. When we get out of here, in
568 non-stop mode, finish the state of all threads of that process,
569 but leave other threads alone, as they may be stopped in internal
570 events --- the frontend shouldn't see them as stopped. In
571 all-stop, always finish the state of all threads, as we may be
572 resuming more than just the new process. */
574 ptid
= pid_to_ptid (ptid_get_pid (inferior_ptid
));
576 ptid
= minus_one_ptid
;
577 old_chain
= make_cleanup (finish_thread_state_cleanup
, &ptid
);
579 /* Pass zero for FROM_TTY, because at this point the "run" command
580 has done its thing; now we are setting up the running program. */
581 post_create_inferior (¤t_target
, 0);
583 /* Start the target running. */
584 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_0
, 0);
586 /* Since there was no error, there's no need to finish the thread
588 discard_cleanups (old_chain
);
592 run_command (char *args
, int from_tty
)
594 run_command_1 (args
, from_tty
, 0);
598 run_no_args_command (char *args
, int from_tty
)
600 set_inferior_args ("");
604 /* Start the execution of the program up until the beginning of the main
608 start_command (char *args
, int from_tty
)
610 /* Some languages such as Ada need to search inside the program
611 minimal symbols for the location where to put the temporary
612 breakpoint before starting. */
613 if (!have_minimal_symbols ())
614 error (_("No symbol table loaded. Use the \"file\" command."));
616 /* Run the program until reaching the main procedure... */
617 run_command_1 (args
, from_tty
, 1);
621 proceed_thread_callback (struct thread_info
*thread
, void *arg
)
623 /* We go through all threads individually instead of compressing
624 into a single target `resume_all' request, because some threads
625 may be stopped in internal breakpoints/events, or stopped waiting
626 for its turn in the displaced stepping queue (that is, they are
627 running && !executing). The target side has no idea about why
628 the thread is stopped, so a `resume_all' command would resume too
629 much. If/when GDB gains a way to tell the target `hold this
630 thread stopped until I say otherwise', then we can optimize
632 if (!is_stopped (thread
->ptid
))
635 switch_to_thread (thread
->ptid
);
636 clear_proceed_status ();
637 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
642 ensure_valid_thread (void)
644 if (ptid_equal (inferior_ptid
, null_ptid
)
645 || is_exited (inferior_ptid
))
647 Cannot execute this command without a live selected thread."));
650 /* If the user is looking at trace frames, any resumption of execution
651 is likely to mix up recorded and live target data. So simply
652 disallow those commands. */
655 ensure_not_tfind_mode (void)
657 if (get_traceframe_number () >= 0)
659 Cannot execute this command while looking at trace frames."));
663 continue_1 (int all_threads
)
666 ensure_not_tfind_mode ();
668 if (non_stop
&& all_threads
)
670 /* Don't error out if the current thread is running, because
671 there may be other stopped threads. */
672 struct cleanup
*old_chain
;
674 /* Backup current thread and selected frame. */
675 old_chain
= make_cleanup_restore_current_thread ();
677 iterate_over_threads (proceed_thread_callback
, NULL
);
679 /* Restore selected ptid. */
680 do_cleanups (old_chain
);
684 ensure_valid_thread ();
685 ensure_not_running ();
686 clear_proceed_status ();
687 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
691 /* continue [-a] [proceed-count] [&] */
693 continue_command (char *args
, int from_tty
)
699 /* Find out whether we must run in the background. */
701 async_exec
= strip_bg_char (&args
);
703 /* If we must run in the background, but the target can't do it,
705 if (async_exec
&& !target_can_async_p ())
706 error (_("Asynchronous execution not supported on this target."));
708 /* If we are not asked to run in the bg, then prepare to run in the
709 foreground, synchronously. */
710 if (!async_exec
&& target_can_async_p ())
712 /* Simulate synchronous execution */
713 async_disable_stdin ();
718 if (strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
721 args
+= sizeof ("-a") - 1;
727 if (!non_stop
&& all_threads
)
728 error (_("`-a' is meaningless in all-stop mode."));
730 if (args
!= NULL
&& all_threads
)
732 Can't resume all threads and specify proceed count simultaneously."));
734 /* If we have an argument left, set proceed count of breakpoint we
741 struct thread_info
*tp
;
744 tp
= find_thread_ptid (inferior_ptid
);
748 struct target_waitstatus ws
;
750 get_last_target_status (&last_ptid
, &ws
);
751 tp
= find_thread_ptid (last_ptid
);
754 bs
= tp
->stop_bpstat
;
756 while ((stat
= bpstat_num (&bs
, &num
)) != 0)
759 set_ignore_count (num
,
760 parse_and_eval_long (args
) - 1,
762 /* set_ignore_count prints a message ending with a period.
763 So print two spaces before "Continuing.". */
765 printf_filtered (" ");
769 if (!stopped
&& from_tty
)
772 ("Not stopped at any breakpoint; argument ignored.\n");
777 printf_filtered (_("Continuing.\n"));
779 continue_1 (all_threads
);
782 /* Record the starting point of a "step" or "next" command. */
785 set_step_frame (void)
787 struct symtab_and_line sal
;
789 find_frame_sal (get_current_frame (), &sal
);
790 set_step_info (get_current_frame (), sal
);
793 /* Step until outside of current statement. */
796 step_command (char *count_string
, int from_tty
)
798 step_1 (0, 0, count_string
);
801 /* Likewise, but skip over subroutine calls as if single instructions. */
804 next_command (char *count_string
, int from_tty
)
806 step_1 (1, 0, count_string
);
809 /* Likewise, but step only one instruction. */
812 stepi_command (char *count_string
, int from_tty
)
814 step_1 (0, 1, count_string
);
818 nexti_command (char *count_string
, int from_tty
)
820 step_1 (1, 1, count_string
);
824 delete_longjmp_breakpoint_cleanup (void *arg
)
826 int thread
= * (int *) arg
;
827 delete_longjmp_breakpoint (thread
);
831 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
834 struct frame_info
*frame
;
835 struct cleanup
*cleanups
= make_cleanup (null_cleanup
, NULL
);
840 ensure_not_tfind_mode ();
841 ensure_valid_thread ();
842 ensure_not_running ();
845 async_exec
= strip_bg_char (&count_string
);
847 /* If we get a request for running in the bg but the target
848 doesn't support it, error out. */
849 if (async_exec
&& !target_can_async_p ())
850 error (_("Asynchronous execution not supported on this target."));
852 /* If we don't get a request of running in the bg, then we need
853 to simulate synchronous (fg) execution. */
854 if (!async_exec
&& target_can_async_p ())
856 /* Simulate synchronous execution */
857 async_disable_stdin ();
860 count
= count_string
? parse_and_eval_long (count_string
) : 1;
862 if (!single_inst
|| skip_subroutines
) /* leave si command alone */
864 if (in_thread_list (inferior_ptid
))
865 thread
= pid_to_thread_id (inferior_ptid
);
867 set_longjmp_breakpoint (thread
);
869 make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
872 /* In synchronous case, all is well; each step_once call will step once. */
873 if (!target_can_async_p ())
875 for (; count
> 0; count
--)
877 struct thread_info
*tp
;
878 step_once (skip_subroutines
, single_inst
, count
, thread
);
880 if (target_has_execution
881 && !ptid_equal (inferior_ptid
, null_ptid
))
882 tp
= inferior_thread ();
886 if (!tp
|| !tp
->stop_step
|| !tp
->step_multi
)
888 /* If we stopped for some reason that is not stepping
889 there are no further steps to make. */
896 do_cleanups (cleanups
);
900 /* In the case of an asynchronous target things get complicated;
901 do only one step for now, before returning control to the
902 event loop. Let the continuation figure out how many other
903 steps we need to do, and handle them one at the time, through
905 step_once (skip_subroutines
, single_inst
, count
, thread
);
907 /* We are running, and the continuation is installed. It will
908 disable the longjmp breakpoint as appropriate. */
909 discard_cleanups (cleanups
);
913 struct step_1_continuation_args
916 int skip_subroutines
;
921 /* Called after we are done with one step operation, to check whether
922 we need to step again, before we print the prompt and return control
923 to the user. If count is > 1, we will need to do one more call to
924 proceed(), via step_once(). Basically it is like step_once and
925 step_1_continuation are co-recursive. */
927 step_1_continuation (void *args
)
929 struct step_1_continuation_args
*a
= args
;
931 if (target_has_execution
)
933 struct thread_info
*tp
;
935 tp
= inferior_thread ();
936 if (tp
->step_multi
&& tp
->stop_step
)
938 /* There are more steps to make, and we did stop due to
939 ending a stepping range. Do another step. */
940 step_once (a
->skip_subroutines
, a
->single_inst
,
941 a
->count
- 1, a
->thread
);
947 /* We either stopped for some reason that is not stepping, or there
948 are no further steps to make. Cleanup. */
949 if (!a
->single_inst
|| a
->skip_subroutines
)
950 delete_longjmp_breakpoint (a
->thread
);
953 /* Do just one step operation. This is useful to implement the 'step
954 n' kind of commands. In case of asynchronous targets, we will have
955 to set up a continuation to be done after the target stops (after
956 this one step). For synch targets, the caller handles further
960 step_once (int skip_subroutines
, int single_inst
, int count
, int thread
)
962 struct frame_info
*frame
= get_current_frame ();
966 /* Don't assume THREAD is a valid thread id. It is set to -1 if
967 the longjmp breakpoint was not required. Use the
968 INFERIOR_PTID thread instead, which is the same thread when
970 struct thread_info
*tp
= inferior_thread ();
971 clear_proceed_status ();
978 /* Step at an inlined function behaves like "down". */
979 if (!skip_subroutines
&& !single_inst
980 && inline_skipped_frames (inferior_ptid
))
982 step_into_inline_frame (inferior_ptid
);
984 step_once (skip_subroutines
, single_inst
, count
- 1, thread
);
986 /* Pretend that we've stopped. */
991 pc
= get_frame_pc (frame
);
992 find_pc_line_pc_range (pc
,
993 &tp
->step_range_start
, &tp
->step_range_end
);
995 /* If we have no line info, switch to stepi mode. */
996 if (tp
->step_range_end
== 0 && step_stop_if_no_debug
)
997 tp
->step_range_start
= tp
->step_range_end
= 1;
998 else if (tp
->step_range_end
== 0)
1001 if (find_pc_partial_function (pc
, &name
,
1002 &tp
->step_range_start
,
1003 &tp
->step_range_end
) == 0)
1004 error (_("Cannot find bounds of current function"));
1006 target_terminal_ours ();
1007 printf_filtered (_("\
1008 Single stepping until exit from function %s, \n\
1009 which has no line number information.\n"), name
);
1014 /* Say we are stepping, but stop after one insn whatever it does. */
1015 tp
->step_range_start
= tp
->step_range_end
= 1;
1016 if (!skip_subroutines
)
1018 Don't step over function calls, not even to functions lacking
1020 tp
->step_over_calls
= STEP_OVER_NONE
;
1023 if (skip_subroutines
)
1024 tp
->step_over_calls
= STEP_OVER_ALL
;
1026 tp
->step_multi
= (count
> 1);
1027 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1029 /* For async targets, register a continuation to do any
1030 additional steps. For sync targets, the caller will handle
1031 further stepping. */
1032 if (target_can_async_p ())
1034 struct step_1_continuation_args
*args
;
1036 args
= xmalloc (sizeof (*args
));
1037 args
->skip_subroutines
= skip_subroutines
;
1038 args
->single_inst
= single_inst
;
1039 args
->count
= count
;
1040 args
->thread
= thread
;
1042 add_intermediate_continuation (tp
, step_1_continuation
, args
, xfree
);
1048 /* Continue program at specified address. */
1051 jump_command (char *arg
, int from_tty
)
1053 struct gdbarch
*gdbarch
= get_current_arch ();
1055 struct symtabs_and_lines sals
;
1056 struct symtab_and_line sal
;
1062 ensure_not_tfind_mode ();
1063 ensure_valid_thread ();
1064 ensure_not_running ();
1066 /* Find out whether we must run in the background. */
1068 async_exec
= strip_bg_char (&arg
);
1070 /* If we must run in the background, but the target can't do it,
1072 if (async_exec
&& !target_can_async_p ())
1073 error (_("Asynchronous execution not supported on this target."));
1076 error_no_arg (_("starting address"));
1078 sals
= decode_line_spec_1 (arg
, 1);
1079 if (sals
.nelts
!= 1)
1081 error (_("Unreasonable jump request"));
1087 if (sal
.symtab
== 0 && sal
.pc
== 0)
1088 error (_("No source file has been specified."));
1090 resolve_sal_pc (&sal
); /* May error out */
1092 /* See if we are trying to jump to another function. */
1093 fn
= get_frame_function (get_current_frame ());
1094 sfn
= find_pc_function (sal
.pc
);
1095 if (fn
!= NULL
&& sfn
!= fn
)
1097 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal
.line
,
1098 SYMBOL_PRINT_NAME (fn
)))
1100 error (_("Not confirmed."));
1107 fixup_symbol_section (sfn
, 0);
1108 if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn
)) &&
1109 !section_is_mapped (SYMBOL_OBJ_SECTION (sfn
)))
1111 if (!query (_("WARNING!!! Destination is in unmapped overlay! Jump anyway? ")))
1113 error (_("Not confirmed."));
1123 printf_filtered (_("Continuing at "));
1124 fputs_filtered (paddress (gdbarch
, addr
), gdb_stdout
);
1125 printf_filtered (".\n");
1128 /* If we are not asked to run in the bg, then prepare to run in the
1129 foreground, synchronously. */
1130 if (!async_exec
&& target_can_async_p ())
1132 /* Simulate synchronous execution */
1133 async_disable_stdin ();
1136 clear_proceed_status ();
1137 proceed (addr
, TARGET_SIGNAL_0
, 0);
1141 /* Go to line or address in current procedure */
1143 go_command (char *line_no
, int from_tty
)
1145 if (line_no
== (char *) NULL
|| !*line_no
)
1146 printf_filtered (_("Usage: go <location>\n"));
1149 tbreak_command (line_no
, from_tty
);
1150 jump_command (line_no
, from_tty
);
1155 /* Continue program giving it specified signal. */
1158 signal_command (char *signum_exp
, int from_tty
)
1160 enum target_signal oursig
;
1163 dont_repeat (); /* Too dangerous. */
1165 ensure_not_tfind_mode ();
1166 ensure_valid_thread ();
1167 ensure_not_running ();
1169 /* Find out whether we must run in the background. */
1170 if (signum_exp
!= NULL
)
1171 async_exec
= strip_bg_char (&signum_exp
);
1173 /* If we must run in the background, but the target can't do it,
1175 if (async_exec
&& !target_can_async_p ())
1176 error (_("Asynchronous execution not supported on this target."));
1178 /* If we are not asked to run in the bg, then prepare to run in the
1179 foreground, synchronously. */
1180 if (!async_exec
&& target_can_async_p ())
1182 /* Simulate synchronous execution. */
1183 async_disable_stdin ();
1187 error_no_arg (_("signal number"));
1189 /* It would be even slicker to make signal names be valid expressions,
1190 (the type could be "enum $signal" or some such), then the user could
1191 assign them to convenience variables. */
1192 oursig
= target_signal_from_name (signum_exp
);
1194 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
1196 /* No, try numeric. */
1197 int num
= parse_and_eval_long (signum_exp
);
1200 oursig
= TARGET_SIGNAL_0
;
1202 oursig
= target_signal_from_command (num
);
1207 if (oursig
== TARGET_SIGNAL_0
)
1208 printf_filtered (_("Continuing with no signal.\n"));
1210 printf_filtered (_("Continuing with signal %s.\n"),
1211 target_signal_to_name (oursig
));
1214 clear_proceed_status ();
1215 proceed ((CORE_ADDR
) -1, oursig
, 0);
1218 /* Proceed until we reach a different source line with pc greater than
1219 our current one or exit the function. We skip calls in both cases.
1221 Note that eventually this command should probably be changed so
1222 that only source lines are printed out when we hit the breakpoint
1223 we set. This may involve changes to wait_for_inferior and the
1224 proceed status code. */
1227 until_next_command (int from_tty
)
1229 struct frame_info
*frame
;
1231 struct symbol
*func
;
1232 struct symtab_and_line sal
;
1233 struct thread_info
*tp
= inferior_thread ();
1235 clear_proceed_status ();
1238 frame
= get_current_frame ();
1240 /* Step until either exited from this function or greater
1241 than the current line (if in symbolic section) or pc (if
1244 pc
= get_frame_pc (frame
);
1245 func
= find_pc_function (pc
);
1249 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
1251 if (msymbol
== NULL
)
1252 error (_("Execution is not within a known function."));
1254 tp
->step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
1255 tp
->step_range_end
= pc
;
1259 sal
= find_pc_line (pc
, 0);
1261 tp
->step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
1262 tp
->step_range_end
= sal
.end
;
1265 tp
->step_over_calls
= STEP_OVER_ALL
;
1267 tp
->step_multi
= 0; /* Only one call to proceed */
1269 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1273 until_command (char *arg
, int from_tty
)
1278 ensure_not_tfind_mode ();
1279 ensure_valid_thread ();
1280 ensure_not_running ();
1282 /* Find out whether we must run in the background. */
1284 async_exec
= strip_bg_char (&arg
);
1286 /* If we must run in the background, but the target can't do it,
1288 if (async_exec
&& !target_can_async_p ())
1289 error (_("Asynchronous execution not supported on this target."));
1291 /* If we are not asked to run in the bg, then prepare to run in the
1292 foreground, synchronously. */
1293 if (!async_exec
&& target_can_async_p ())
1295 /* Simulate synchronous execution */
1296 async_disable_stdin ();
1300 until_break_command (arg
, from_tty
, 0);
1302 until_next_command (from_tty
);
1306 advance_command (char *arg
, int from_tty
)
1311 ensure_not_tfind_mode ();
1312 ensure_valid_thread ();
1313 ensure_not_running ();
1316 error_no_arg (_("a location"));
1318 /* Find out whether we must run in the background. */
1320 async_exec
= strip_bg_char (&arg
);
1322 /* If we must run in the background, but the target can't do it,
1324 if (async_exec
&& !target_can_async_p ())
1325 error (_("Asynchronous execution not supported on this target."));
1327 /* If we are not asked to run in the bg, then prepare to run in the
1328 foreground, synchronously. */
1329 if (!async_exec
&& target_can_async_p ())
1331 /* Simulate synchronous execution. */
1332 async_disable_stdin ();
1335 until_break_command (arg
, from_tty
, 1);
1338 /* Print the result of a function at the end of a 'finish' command. */
1341 print_return_value (struct type
*func_type
, struct type
*value_type
)
1343 struct gdbarch
*gdbarch
= get_regcache_arch (stop_registers
);
1344 struct cleanup
*old_chain
;
1345 struct ui_stream
*stb
;
1346 struct value
*value
;
1348 CHECK_TYPEDEF (value_type
);
1349 gdb_assert (TYPE_CODE (value_type
) != TYPE_CODE_VOID
);
1351 /* FIXME: 2003-09-27: When returning from a nested inferior function
1352 call, it's possible (with no help from the architecture vector)
1353 to locate and return/print a "struct return" value. This is just
1354 a more complicated case of what is already being done in in the
1355 inferior function call code. In fact, when inferior function
1356 calls are made async, this will likely be made the norm. */
1358 switch (gdbarch_return_value (gdbarch
, func_type
, value_type
,
1361 case RETURN_VALUE_REGISTER_CONVENTION
:
1362 case RETURN_VALUE_ABI_RETURNS_ADDRESS
:
1363 case RETURN_VALUE_ABI_PRESERVES_ADDRESS
:
1364 value
= allocate_value (value_type
);
1365 gdbarch_return_value (gdbarch
, func_type
, value_type
, stop_registers
,
1366 value_contents_raw (value
), NULL
);
1368 case RETURN_VALUE_STRUCT_CONVENTION
:
1372 internal_error (__FILE__
, __LINE__
, _("bad switch"));
1377 struct value_print_options opts
;
1380 stb
= ui_out_stream_new (uiout
);
1381 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
1382 ui_out_text (uiout
, "Value returned is ");
1383 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d",
1384 record_latest_value (value
));
1385 ui_out_text (uiout
, " = ");
1386 get_raw_print_options (&opts
);
1387 value_print (value
, stb
->stream
, &opts
);
1388 ui_out_field_stream (uiout
, "return-value", stb
);
1389 ui_out_text (uiout
, "\n");
1390 do_cleanups (old_chain
);
1394 ui_out_text (uiout
, "Value returned has type: ");
1395 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1396 ui_out_text (uiout
, ".");
1397 ui_out_text (uiout
, " Cannot determine contents\n");
1401 /* Stuff that needs to be done by the finish command after the target
1402 has stopped. In asynchronous mode, we wait for the target to stop
1403 in the call to poll or select in the event loop, so it is
1404 impossible to do all the stuff as part of the finish_command
1405 function itself. The only chance we have to complete this command
1406 is in fetch_inferior_event, which is called by the event loop as
1407 soon as it detects that the target has stopped. This function is
1408 called via the cmd_continuation pointer. */
1410 struct finish_command_continuation_args
1412 struct breakpoint
*breakpoint
;
1413 struct symbol
*function
;
1417 finish_command_continuation (void *arg
)
1419 struct finish_command_continuation_args
*a
= arg
;
1420 struct thread_info
*tp
= NULL
;
1423 if (!ptid_equal (inferior_ptid
, null_ptid
)
1424 && target_has_execution
1425 && is_stopped (inferior_ptid
))
1427 tp
= inferior_thread ();
1428 bs
= tp
->stop_bpstat
;
1431 if (bpstat_find_breakpoint (bs
, a
->breakpoint
) != NULL
1432 && a
->function
!= NULL
)
1434 struct type
*value_type
;
1436 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (a
->function
));
1438 internal_error (__FILE__
, __LINE__
,
1439 _("finish_command: function has no target type"));
1441 if (TYPE_CODE (value_type
) != TYPE_CODE_VOID
)
1443 volatile struct gdb_exception ex
;
1445 TRY_CATCH (ex
, RETURN_MASK_ALL
)
1447 /* print_return_value can throw an exception in some
1448 circumstances. We need to catch this so that we still
1449 delete the breakpoint. */
1450 print_return_value (SYMBOL_TYPE (a
->function
), value_type
);
1453 exception_print (gdb_stdout
, ex
);
1457 /* We suppress normal call of normal_stop observer and do it here so
1458 that the *stopped notification includes the return value. */
1459 if (bs
!= NULL
&& tp
->proceed_to_finish
)
1460 observer_notify_normal_stop (bs
, 1 /* print frame */);
1461 delete_breakpoint (a
->breakpoint
);
1465 finish_command_continuation_free_arg (void *arg
)
1470 /* finish_backward -- helper function for finish_command. */
1473 finish_backward (struct symbol
*function
)
1475 struct symtab_and_line sal
;
1476 struct thread_info
*tp
= inferior_thread ();
1477 struct breakpoint
*breakpoint
;
1478 struct cleanup
*old_chain
;
1480 CORE_ADDR func_addr
;
1483 pc
= get_frame_pc (get_current_frame ());
1485 if (find_pc_partial_function (pc
, NULL
, &func_addr
, NULL
) == 0)
1486 internal_error (__FILE__
, __LINE__
,
1487 _("Finish: couldn't find function."));
1489 sal
= find_pc_line (func_addr
, 0);
1491 /* We don't need a return value. */
1492 tp
->proceed_to_finish
= 0;
1493 /* Special case: if we're sitting at the function entry point,
1494 then all we need to do is take a reverse singlestep. We
1495 don't need to set a breakpoint, and indeed it would do us
1498 Note that this can only happen at frame #0, since there's
1499 no way that a function up the stack can have a return address
1500 that's equal to its entry point. */
1504 struct frame_info
*frame
= get_selected_frame (NULL
);
1505 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1507 /* Set breakpoint and continue. */
1509 set_momentary_breakpoint (gdbarch
, sal
,
1510 get_stack_frame_id (frame
),
1512 /* Tell the breakpoint to keep quiet. We won't be done
1513 until we've done another reverse single-step. */
1514 make_breakpoint_silent (breakpoint
);
1515 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1516 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1517 /* We will be stopped when proceed returns. */
1518 back_up
= bpstat_find_breakpoint (tp
->stop_bpstat
, breakpoint
) != NULL
;
1519 do_cleanups (old_chain
);
1525 /* If in fact we hit the step-resume breakpoint (and not
1526 some other breakpoint), then we're almost there --
1527 we just need to back up by one more single-step. */
1528 tp
->step_range_start
= tp
->step_range_end
= 1;
1529 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1534 /* finish_forward -- helper function for finish_command. */
1537 finish_forward (struct symbol
*function
, struct frame_info
*frame
)
1539 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1540 struct symtab_and_line sal
;
1541 struct thread_info
*tp
= inferior_thread ();
1542 struct breakpoint
*breakpoint
;
1543 struct cleanup
*old_chain
;
1544 struct finish_command_continuation_args
*cargs
;
1546 sal
= find_pc_line (get_frame_pc (frame
), 0);
1547 sal
.pc
= get_frame_pc (frame
);
1549 breakpoint
= set_momentary_breakpoint (gdbarch
, sal
,
1550 get_stack_frame_id (frame
),
1553 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1555 tp
->proceed_to_finish
= 1; /* We want stop_registers, please... */
1556 cargs
= xmalloc (sizeof (*cargs
));
1558 cargs
->breakpoint
= breakpoint
;
1559 cargs
->function
= function
;
1560 add_continuation (tp
, finish_command_continuation
, cargs
,
1561 finish_command_continuation_free_arg
);
1562 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1564 discard_cleanups (old_chain
);
1565 if (!target_can_async_p ())
1566 do_all_continuations ();
1569 /* "finish": Set a temporary breakpoint at the place the selected
1570 frame will return to, then continue. */
1573 finish_command (char *arg
, int from_tty
)
1575 struct frame_info
*frame
;
1576 struct symbol
*function
;
1581 ensure_not_tfind_mode ();
1582 ensure_valid_thread ();
1583 ensure_not_running ();
1585 /* Find out whether we must run in the background. */
1587 async_exec
= strip_bg_char (&arg
);
1589 /* If we must run in the background, but the target can't do it,
1591 if (async_exec
&& !target_can_async_p ())
1592 error (_("Asynchronous execution not supported on this target."));
1594 /* Don't try to async in reverse. */
1595 if (async_exec
&& execution_direction
== EXEC_REVERSE
)
1596 error (_("Asynchronous 'finish' not supported in reverse."));
1598 /* If we are not asked to run in the bg, then prepare to run in the
1599 foreground, synchronously. */
1600 if (!async_exec
&& target_can_async_p ())
1602 /* Simulate synchronous execution. */
1603 async_disable_stdin ();
1607 error (_("The \"finish\" command does not take any arguments."));
1609 frame
= get_prev_frame (get_selected_frame (_("No selected frame.")));
1611 error (_("\"finish\" not meaningful in the outermost frame."));
1613 clear_proceed_status ();
1615 /* Finishing from an inline frame is completely different. We don't
1616 try to show the "return value" - no way to locate it. So we do
1617 not need a completion. */
1618 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1621 /* Claim we are stepping in the calling frame. An empty step
1622 range means that we will stop once we aren't in a function
1623 called by that frame. We don't use the magic "1" value for
1624 step_range_end, because then infrun will think this is nexti,
1625 and not step over the rest of this inlined function call. */
1626 struct thread_info
*tp
= inferior_thread ();
1627 struct symtab_and_line empty_sal
;
1628 init_sal (&empty_sal
);
1629 set_step_info (frame
, empty_sal
);
1630 tp
->step_range_start
= tp
->step_range_end
= get_frame_pc (frame
);
1631 tp
->step_over_calls
= STEP_OVER_ALL
;
1633 /* Print info on the selected frame, including level number but not
1637 printf_filtered (_("Run till exit from "));
1638 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1641 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1645 /* Find the function we will return from. */
1647 function
= find_pc_function (get_frame_pc (get_selected_frame (NULL
)));
1649 /* Print info on the selected frame, including level number but not
1653 if (execution_direction
== EXEC_REVERSE
)
1654 printf_filtered (_("Run back to call of "));
1656 printf_filtered (_("Run till exit from "));
1658 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1661 if (execution_direction
== EXEC_REVERSE
)
1662 finish_backward (function
);
1664 finish_forward (function
, frame
);
1669 program_info (char *args
, int from_tty
)
1673 struct thread_info
*tp
;
1676 if (!target_has_execution
)
1678 printf_filtered (_("The program being debugged is not being run.\n"));
1683 ptid
= inferior_ptid
;
1686 struct target_waitstatus ws
;
1687 get_last_target_status (&ptid
, &ws
);
1690 if (ptid_equal (ptid
, null_ptid
) || is_exited (ptid
))
1691 error (_("Invalid selected thread."));
1692 else if (is_running (ptid
))
1693 error (_("Selected thread is running."));
1695 tp
= find_thread_ptid (ptid
);
1696 bs
= tp
->stop_bpstat
;
1697 stat
= bpstat_num (&bs
, &num
);
1699 target_files_info ();
1700 printf_filtered (_("Program stopped at %s.\n"),
1701 paddress (target_gdbarch
, stop_pc
));
1703 printf_filtered (_("It stopped after being stepped.\n"));
1706 /* There may be several breakpoints in the same place, so this
1707 isn't as strange as it seems. */
1712 printf_filtered (_("\
1713 It stopped at a breakpoint that has since been deleted.\n"));
1716 printf_filtered (_("It stopped at breakpoint %d.\n"), num
);
1717 stat
= bpstat_num (&bs
, &num
);
1720 else if (tp
->stop_signal
!= TARGET_SIGNAL_0
)
1722 printf_filtered (_("It stopped with signal %s, %s.\n"),
1723 target_signal_to_name (tp
->stop_signal
),
1724 target_signal_to_string (tp
->stop_signal
));
1729 printf_filtered (_("\
1730 Type \"info stack\" or \"info registers\" for more information.\n"));
1735 environment_info (char *var
, int from_tty
)
1739 char *val
= get_in_environ (current_inferior ()->environment
, var
);
1742 puts_filtered (var
);
1743 puts_filtered (" = ");
1744 puts_filtered (val
);
1745 puts_filtered ("\n");
1749 puts_filtered ("Environment variable \"");
1750 puts_filtered (var
);
1751 puts_filtered ("\" not defined.\n");
1756 char **vector
= environ_vector (current_inferior ()->environment
);
1759 puts_filtered (*vector
++);
1760 puts_filtered ("\n");
1766 set_environment_command (char *arg
, int from_tty
)
1768 char *p
, *val
, *var
;
1772 error_no_arg (_("environment variable and value"));
1774 /* Find seperation between variable name and value */
1775 p
= (char *) strchr (arg
, '=');
1776 val
= (char *) strchr (arg
, ' ');
1778 if (p
!= 0 && val
!= 0)
1780 /* We have both a space and an equals. If the space is before the
1781 equals, walk forward over the spaces til we see a nonspace
1782 (possibly the equals). */
1787 /* Now if the = is after the char following the spaces,
1788 take the char following the spaces. */
1792 else if (val
!= 0 && p
== 0)
1796 error_no_arg (_("environment variable to set"));
1798 if (p
== 0 || p
[1] == 0)
1802 p
= arg
+ strlen (arg
); /* So that savestring below will work */
1806 /* Not setting variable value to null */
1808 while (*val
== ' ' || *val
== '\t')
1812 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1815 var
= savestring (arg
, p
- arg
);
1818 printf_filtered (_("\
1819 Setting environment variable \"%s\" to null value.\n"),
1821 set_in_environ (current_inferior ()->environment
, var
, "");
1824 set_in_environ (current_inferior ()->environment
, var
, val
);
1829 unset_environment_command (char *var
, int from_tty
)
1833 /* If there is no argument, delete all environment variables.
1834 Ask for confirmation if reading from the terminal. */
1835 if (!from_tty
|| query (_("Delete all environment variables? ")))
1837 free_environ (current_inferior ()->environment
);
1838 current_inferior ()->environment
= make_environ ();
1842 unset_in_environ (current_inferior ()->environment
, var
);
1845 /* Handle the execution path (PATH variable) */
1847 static const char path_var_name
[] = "PATH";
1850 path_info (char *args
, int from_tty
)
1852 puts_filtered ("Executable and object file path: ");
1853 puts_filtered (get_in_environ (current_inferior ()->environment
, path_var_name
));
1854 puts_filtered ("\n");
1857 /* Add zero or more directories to the front of the execution path. */
1860 path_command (char *dirname
, int from_tty
)
1865 env
= get_in_environ (current_inferior ()->environment
, path_var_name
);
1866 /* Can be null if path is not set */
1869 exec_path
= xstrdup (env
);
1870 mod_path (dirname
, &exec_path
);
1871 set_in_environ (current_inferior ()->environment
, path_var_name
, exec_path
);
1874 path_info ((char *) NULL
, from_tty
);
1878 /* Print out the machine register regnum. If regnum is -1, print all
1879 registers (print_all == 1) or all non-float and non-vector
1880 registers (print_all == 0).
1882 For most machines, having all_registers_info() print the
1883 register(s) one per line is good enough. If a different format is
1884 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1885 regs), or there is an existing convention for showing all the
1886 registers, define the architecture method PRINT_REGISTERS_INFO to
1887 provide that format. */
1890 default_print_registers_info (struct gdbarch
*gdbarch
,
1891 struct ui_file
*file
,
1892 struct frame_info
*frame
,
1893 int regnum
, int print_all
)
1896 const int numregs
= gdbarch_num_regs (gdbarch
)
1897 + gdbarch_num_pseudo_regs (gdbarch
);
1898 gdb_byte buffer
[MAX_REGISTER_SIZE
];
1900 for (i
= 0; i
< numregs
; i
++)
1902 /* Decide between printing all regs, non-float / vector regs, or
1908 if (!gdbarch_register_reggroup_p (gdbarch
, i
, all_reggroup
))
1913 if (!gdbarch_register_reggroup_p (gdbarch
, i
, general_reggroup
))
1923 /* If the register name is empty, it is undefined for this
1924 processor, so don't display anything. */
1925 if (gdbarch_register_name (gdbarch
, i
) == NULL
1926 || *(gdbarch_register_name (gdbarch
, i
)) == '\0')
1929 fputs_filtered (gdbarch_register_name (gdbarch
, i
), file
);
1930 print_spaces_filtered (15 - strlen (gdbarch_register_name
1931 (gdbarch
, i
)), file
);
1933 /* Get the data in raw format. */
1934 if (! frame_register_read (frame
, i
, buffer
))
1936 fprintf_filtered (file
, "*value not available*\n");
1940 /* If virtual format is floating, print it that way, and in raw
1942 if (TYPE_CODE (register_type (gdbarch
, i
)) == TYPE_CODE_FLT
1943 || TYPE_CODE (register_type (gdbarch
, i
)) == TYPE_CODE_DECFLOAT
)
1946 struct value_print_options opts
;
1948 get_user_print_options (&opts
);
1950 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1951 file
, 0, &opts
, current_language
);
1953 fprintf_filtered (file
, "\t(raw 0x");
1954 for (j
= 0; j
< register_size (gdbarch
, i
); j
++)
1957 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
1960 idx
= register_size (gdbarch
, i
) - 1 - j
;
1961 fprintf_filtered (file
, "%02x", (unsigned char) buffer
[idx
]);
1963 fprintf_filtered (file
, ")");
1967 struct value_print_options opts
;
1969 /* Print the register in hex. */
1970 get_formatted_print_options (&opts
, 'x');
1972 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1975 /* If not a vector register, print it also according to its
1977 if (TYPE_VECTOR (register_type (gdbarch
, i
)) == 0)
1979 get_user_print_options (&opts
);
1981 fprintf_filtered (file
, "\t");
1982 val_print (register_type (gdbarch
, i
), buffer
, 0, 0,
1983 file
, 0, &opts
, current_language
);
1987 fprintf_filtered (file
, "\n");
1992 registers_info (char *addr_exp
, int fpregs
)
1994 struct frame_info
*frame
;
1995 struct gdbarch
*gdbarch
;
1996 int regnum
, numregs
;
1999 if (!target_has_registers
)
2000 error (_("The program has no registers now."));
2001 frame
= get_selected_frame (NULL
);
2002 gdbarch
= get_frame_arch (frame
);
2006 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2011 while (*addr_exp
!= '\0')
2016 /* Keep skipping leading white space. */
2017 if (isspace ((*addr_exp
)))
2023 /* Discard any leading ``$''. Check that there is something
2024 resembling a register following it. */
2025 if (addr_exp
[0] == '$')
2027 if (isspace ((*addr_exp
)) || (*addr_exp
) == '\0')
2028 error (_("Missing register name"));
2030 /* Find the start/end of this register name/num/group. */
2032 while ((*addr_exp
) != '\0' && !isspace ((*addr_exp
)))
2036 /* Figure out what we've found and display it. */
2038 /* A register name? */
2040 int regnum
= user_reg_map_name_to_regnum (gdbarch
, start
, end
- start
);
2043 /* User registers lie completely outside of the range of
2044 normal registers. Catch them early so that the target
2046 if (regnum
>= gdbarch_num_regs (gdbarch
)
2047 + gdbarch_num_pseudo_regs (gdbarch
))
2049 struct value_print_options opts
;
2050 struct value
*val
= value_of_user_reg (regnum
, frame
);
2052 printf_filtered ("%s: ", start
);
2053 get_formatted_print_options (&opts
, 'x');
2054 print_scalar_formatted (value_contents (val
),
2055 check_typedef (value_type (val
)),
2056 &opts
, 0, gdb_stdout
);
2057 printf_filtered ("\n");
2060 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2061 frame
, regnum
, fpregs
);
2066 /* A register group? */
2068 struct reggroup
*group
;
2069 for (group
= reggroup_next (gdbarch
, NULL
);
2071 group
= reggroup_next (gdbarch
, group
))
2073 /* Don't bother with a length check. Should the user
2074 enter a short register group name, go with the first
2075 group that matches. */
2076 if (strncmp (start
, reggroup_name (group
), end
- start
) == 0)
2083 regnum
< gdbarch_num_regs (gdbarch
)
2084 + gdbarch_num_pseudo_regs (gdbarch
);
2087 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
2088 gdbarch_print_registers_info (gdbarch
,
2096 /* Nothing matched. */
2097 error (_("Invalid register `%.*s'"), (int) (end
- start
), start
);
2102 all_registers_info (char *addr_exp
, int from_tty
)
2104 registers_info (addr_exp
, 1);
2108 nofp_registers_info (char *addr_exp
, int from_tty
)
2110 registers_info (addr_exp
, 0);
2114 print_vector_info (struct ui_file
*file
,
2115 struct frame_info
*frame
, const char *args
)
2117 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2119 if (gdbarch_print_vector_info_p (gdbarch
))
2120 gdbarch_print_vector_info (gdbarch
, file
, frame
, args
);
2124 int printed_something
= 0;
2127 regnum
< gdbarch_num_regs (gdbarch
)
2128 + gdbarch_num_pseudo_regs (gdbarch
);
2131 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, vector_reggroup
))
2133 printed_something
= 1;
2134 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2137 if (!printed_something
)
2138 fprintf_filtered (file
, "No vector information\n");
2143 vector_info (char *args
, int from_tty
)
2145 if (!target_has_registers
)
2146 error (_("The program has no registers now."));
2148 print_vector_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2151 /* Kill the inferior process. Make us have no inferior. */
2154 kill_command (char *arg
, int from_tty
)
2156 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2157 It should be a distinct flag that indicates that a target is active, cuz
2158 some targets don't have processes! */
2160 if (ptid_equal (inferior_ptid
, null_ptid
))
2161 error (_("The program is not being run."));
2162 if (!query (_("Kill the program being debugged? ")))
2163 error (_("Not confirmed."));
2166 /* If we still have other inferiors to debug, then don't mess with
2167 with their threads. */
2168 if (!have_inferiors ())
2170 init_thread_list (); /* Destroy thread info */
2172 /* Killing off the inferior can leave us with a core file. If
2173 so, print the state we are left in. */
2174 if (target_has_stack
)
2176 printf_filtered (_("In %s,\n"), target_longname
);
2177 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
);
2180 bfd_cache_close_all ();
2183 /* Used in `attach&' command. ARG is a point to an integer
2184 representing a process id. Proceed threads of this process iff
2185 they stopped due to debugger request, and when they did, they
2186 reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads
2187 that have been explicitly been told to stop. */
2190 proceed_after_attach_callback (struct thread_info
*thread
,
2193 int pid
= * (int *) arg
;
2195 if (ptid_get_pid (thread
->ptid
) == pid
2196 && !is_exited (thread
->ptid
)
2197 && !is_executing (thread
->ptid
)
2198 && !thread
->stop_requested
2199 && thread
->stop_signal
== TARGET_SIGNAL_0
)
2201 switch_to_thread (thread
->ptid
);
2202 clear_proceed_status ();
2203 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2210 proceed_after_attach (int pid
)
2212 /* Don't error out if the current thread is running, because
2213 there may be other stopped threads. */
2214 struct cleanup
*old_chain
;
2216 /* Backup current thread and selected frame. */
2217 old_chain
= make_cleanup_restore_current_thread ();
2219 iterate_over_threads (proceed_after_attach_callback
, &pid
);
2221 /* Restore selected ptid. */
2222 do_cleanups (old_chain
);
2227 * Should save/restore the tty state since it might be that the
2228 * program to be debugged was started on this tty and it wants
2229 * the tty in some state other than what we want. If it's running
2230 * on another terminal or without a terminal, then saving and
2231 * restoring the tty state is a harmless no-op.
2232 * This only needs to be done if we are attaching to a process.
2237 takes a program started up outside of gdb and ``attaches'' to it.
2238 This stops it cold in its tracks and allows us to start debugging it.
2239 and wait for the trace-trap that results from attaching. */
2242 attach_command_post_wait (char *args
, int from_tty
, int async_exec
)
2245 char *full_exec_path
= NULL
;
2246 struct inferior
*inferior
;
2248 inferior
= current_inferior ();
2249 inferior
->stop_soon
= NO_STOP_QUIETLY
;
2251 /* If no exec file is yet known, try to determine it from the
2253 exec_file
= (char *) get_exec_file (0);
2256 exec_file
= target_pid_to_exec_file (PIDGET (inferior_ptid
));
2259 /* It's possible we don't have a full path, but rather just a
2260 filename. Some targets, such as HP-UX, don't provide the
2263 Attempt to qualify the filename against the source path.
2264 (If that fails, we'll just fall back on the original
2265 filename. Not much more we can do...)
2267 if (!source_full_path_of (exec_file
, &full_exec_path
))
2268 full_exec_path
= xstrdup (exec_file
);
2270 exec_file_attach (full_exec_path
, from_tty
);
2271 symbol_file_add_main (full_exec_path
, from_tty
);
2276 reopen_exec_file ();
2280 /* Take any necessary post-attaching actions for this platform. */
2281 target_post_attach (PIDGET (inferior_ptid
));
2283 post_create_inferior (¤t_target
, from_tty
);
2285 /* Install inferior's terminal modes. */
2286 target_terminal_inferior ();
2290 /* The user requested an `attach&', so be sure to leave threads
2291 that didn't get a signal running. */
2293 /* Immediatelly resume all suspended threads of this inferior,
2294 and this inferior only. This should have no effect on
2295 already running threads. If a thread has been stopped with a
2296 signal, leave it be. */
2298 proceed_after_attach (inferior
->pid
);
2301 if (inferior_thread ()->stop_signal
== TARGET_SIGNAL_0
)
2303 clear_proceed_status ();
2304 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2310 /* The user requested a plain `attach', so be sure to leave
2311 the inferior stopped. */
2313 if (target_can_async_p ())
2314 async_enable_stdin ();
2316 /* At least the current thread is already stopped. */
2318 /* In all-stop, by definition, all threads have to be already
2319 stopped at this point. In non-stop, however, although the
2320 selected thread is stopped, others may still be executing.
2321 Be sure to explicitly stop all threads of the process. This
2322 should have no effect on already stopped threads. */
2324 target_stop (pid_to_ptid (inferior
->pid
));
2326 /* Tell the user/frontend where we're stopped. */
2328 if (deprecated_attach_hook
)
2329 deprecated_attach_hook ();
2333 struct attach_command_continuation_args
2341 attach_command_continuation (void *args
)
2343 struct attach_command_continuation_args
*a
= args
;
2344 attach_command_post_wait (a
->args
, a
->from_tty
, a
->async_exec
);
2348 attach_command_continuation_free_args (void *args
)
2350 struct attach_command_continuation_args
*a
= args
;
2356 attach_command (char *args
, int from_tty
)
2359 char *full_exec_path
= NULL
;
2361 struct cleanup
*back_to
= make_cleanup (null_cleanup
, NULL
);
2363 dont_repeat (); /* Not for the faint of heart */
2365 if (gdbarch_has_global_solist (target_gdbarch
))
2366 /* Don't complain if all processes share the same symbol
2369 else if (target_has_execution
)
2371 if (query (_("A program is being debugged already. Kill it? ")))
2374 error (_("Not killed."));
2377 /* Clean up any leftovers from other runs. Some other things from
2378 this function should probably be moved into target_pre_inferior. */
2379 target_pre_inferior (from_tty
);
2381 if (non_stop
&& !target_supports_non_stop ())
2382 error (_("Cannot attach to this target in non-stop mode"));
2386 async_exec
= strip_bg_char (&args
);
2388 /* If we get a request for running in the bg but the target
2389 doesn't support it, error out. */
2390 if (async_exec
&& !target_can_async_p ())
2391 error (_("Asynchronous execution not supported on this target."));
2394 /* If we don't get a request of running in the bg, then we need
2395 to simulate synchronous (fg) execution. */
2396 if (!async_exec
&& target_can_async_p ())
2398 /* Simulate synchronous execution */
2399 async_disable_stdin ();
2400 make_cleanup ((make_cleanup_ftype
*)async_enable_stdin
, NULL
);
2403 target_attach (args
, from_tty
);
2405 /* Set up the "saved terminal modes" of the inferior
2406 based on what modes we are starting it with. */
2407 target_terminal_init ();
2409 /* Set up execution context to know that we should return from
2410 wait_for_inferior as soon as the target reports a stop. */
2411 init_wait_for_inferior ();
2412 clear_proceed_status ();
2416 /* If we find that the current thread isn't stopped, explicitly
2417 do so now, because we're going to install breakpoints and
2421 /* The user requested an `attach&'; stop just one thread. */
2422 target_stop (inferior_ptid
);
2424 /* The user requested an `attach', so stop all threads of this
2426 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid
)));
2429 /* Some system don't generate traps when attaching to inferior.
2430 E.g. Mach 3 or GNU hurd. */
2431 if (!target_attach_no_wait
)
2433 struct inferior
*inferior
= current_inferior ();
2435 /* Careful here. See comments in inferior.h. Basically some
2436 OSes don't ignore SIGSTOPs on continue requests anymore. We
2437 need a way for handle_inferior_event to reset the stop_signal
2438 variable after an attach, and this is what
2439 STOP_QUIETLY_NO_SIGSTOP is for. */
2440 inferior
->stop_soon
= STOP_QUIETLY_NO_SIGSTOP
;
2442 if (target_can_async_p ())
2444 /* sync_execution mode. Wait for stop. */
2445 struct attach_command_continuation_args
*a
;
2447 a
= xmalloc (sizeof (*a
));
2448 a
->args
= xstrdup (args
);
2449 a
->from_tty
= from_tty
;
2450 a
->async_exec
= async_exec
;
2451 add_inferior_continuation (attach_command_continuation
, a
,
2452 attach_command_continuation_free_args
);
2453 discard_cleanups (back_to
);
2457 wait_for_inferior (0);
2460 attach_command_post_wait (args
, from_tty
, async_exec
);
2461 discard_cleanups (back_to
);
2464 /* We had just found out that the target was already attached to an
2465 inferior. PTID points at a thread of this new inferior, that is
2466 the most likely to be stopped right now, but not necessarily so.
2467 The new inferior is assumed to be already added to the inferior
2468 list at this point. If LEAVE_RUNNING, then leave the threads of
2469 this inferior running, except those we've explicitly seen reported
2473 notice_new_inferior (ptid_t ptid
, int leave_running
, int from_tty
)
2475 struct cleanup
* old_chain
;
2478 old_chain
= make_cleanup (null_cleanup
, NULL
);
2480 /* If in non-stop, leave threads as running as they were. If
2481 they're stopped for some reason other than us telling it to, the
2482 target reports a signal != TARGET_SIGNAL_0. We don't try to
2483 resume threads with such a stop signal. */
2484 async_exec
= non_stop
;
2486 if (!ptid_equal (inferior_ptid
, null_ptid
))
2487 make_cleanup_restore_current_thread ();
2489 switch_to_thread (ptid
);
2491 /* When we "notice" a new inferior we need to do all the things we
2492 would normally do if we had just attached to it. */
2494 if (is_executing (inferior_ptid
))
2496 struct inferior
*inferior
= current_inferior ();
2498 /* We're going to install breakpoints, and poke at memory,
2499 ensure that the inferior is stopped for a moment while we do
2501 target_stop (inferior_ptid
);
2503 inferior
->stop_soon
= STOP_QUIETLY_REMOTE
;
2505 /* Wait for stop before proceeding. */
2506 if (target_can_async_p ())
2508 struct attach_command_continuation_args
*a
;
2510 a
= xmalloc (sizeof (*a
));
2511 a
->args
= xstrdup ("");
2512 a
->from_tty
= from_tty
;
2513 a
->async_exec
= async_exec
;
2514 add_inferior_continuation (attach_command_continuation
, a
,
2515 attach_command_continuation_free_args
);
2517 do_cleanups (old_chain
);
2521 wait_for_inferior (0);
2524 async_exec
= leave_running
;
2525 attach_command_post_wait ("" /* args */, from_tty
, async_exec
);
2527 do_cleanups (old_chain
);
2532 * takes a program previously attached to and detaches it.
2533 * The program resumes execution and will no longer stop
2534 * on signals, etc. We better not have left any breakpoints
2535 * in the program or it'll die when it hits one. For this
2536 * to work, it may be necessary for the process to have been
2537 * previously attached. It *might* work if the program was
2538 * started via the normal ptrace (PTRACE_TRACEME).
2542 detach_command (char *args
, int from_tty
)
2544 dont_repeat (); /* Not for the faint of heart. */
2546 if (ptid_equal (inferior_ptid
, null_ptid
))
2547 error (_("The program is not being run."));
2549 disconnect_or_stop_tracing (from_tty
);
2551 target_detach (args
, from_tty
);
2553 /* If the solist is global across inferiors, don't clear it when we
2554 detach from a single inferior. */
2555 if (!gdbarch_has_global_solist (target_gdbarch
))
2556 no_shared_libraries (NULL
, from_tty
);
2558 /* If we still have inferiors to debug, then don't mess with their
2560 if (!have_inferiors ())
2561 init_thread_list ();
2563 if (deprecated_detach_hook
)
2564 deprecated_detach_hook ();
2567 /* Disconnect from the current target without resuming it (leaving it
2568 waiting for a debugger).
2570 We'd better not have left any breakpoints in the program or the
2571 next debugger will get confused. Currently only supported for some
2572 remote targets, since the normal attach mechanisms don't work on
2573 stopped processes on some native platforms (e.g. GNU/Linux). */
2576 disconnect_command (char *args
, int from_tty
)
2578 dont_repeat (); /* Not for the faint of heart */
2579 target_disconnect (args
, from_tty
);
2580 no_shared_libraries (NULL
, from_tty
);
2581 init_thread_list ();
2582 if (deprecated_detach_hook
)
2583 deprecated_detach_hook ();
2587 interrupt_target_1 (int all_threads
)
2591 ptid
= minus_one_ptid
;
2593 ptid
= inferior_ptid
;
2596 /* Tag the thread as having been explicitly requested to stop, so
2597 other parts of gdb know not to resume this thread automatically,
2598 if it was stopped due to an internal event. Limit this to
2599 non-stop mode, as when debugging a multi-threaded application in
2600 all-stop mode, we will only get one stop event --- it's undefined
2601 which thread will report the event. */
2603 set_stop_requested (ptid
, 1);
2606 /* Stop the execution of the target while running in async mode, in
2607 the backgound. In all-stop, stop the whole process. In non-stop
2608 mode, stop the current thread only by default, or stop all threads
2609 if the `-a' switch is used. */
2611 /* interrupt [-a] */
2613 interrupt_target_command (char *args
, int from_tty
)
2615 if (target_can_async_p ())
2617 int all_threads
= 0;
2619 dont_repeat (); /* Not for the faint of heart */
2622 && strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
2625 if (!non_stop
&& all_threads
)
2626 error (_("-a is meaningless in all-stop mode."));
2628 interrupt_target_1 (all_threads
);
2633 print_float_info (struct ui_file
*file
,
2634 struct frame_info
*frame
, const char *args
)
2636 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2638 if (gdbarch_print_float_info_p (gdbarch
))
2639 gdbarch_print_float_info (gdbarch
, file
, frame
, args
);
2643 int printed_something
= 0;
2646 regnum
< gdbarch_num_regs (gdbarch
)
2647 + gdbarch_num_pseudo_regs (gdbarch
);
2650 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, float_reggroup
))
2652 printed_something
= 1;
2653 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2656 if (!printed_something
)
2657 fprintf_filtered (file
, "\
2658 No floating-point info available for this processor.\n");
2663 float_info (char *args
, int from_tty
)
2665 if (!target_has_registers
)
2666 error (_("The program has no registers now."));
2668 print_float_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2672 unset_command (char *args
, int from_tty
)
2674 printf_filtered (_("\
2675 \"unset\" must be followed by the name of an unset subcommand.\n"));
2676 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
2680 _initialize_infcmd (void)
2682 struct cmd_list_element
*c
= NULL
;
2684 /* add the filename of the terminal connected to inferior I/O */
2685 add_setshow_filename_cmd ("inferior-tty", class_run
,
2686 &inferior_io_terminal_scratch
, _("\
2687 Set terminal for future runs of program being debugged."), _("\
2688 Show terminal for future runs of program being debugged."), _("\
2689 Usage: set inferior-tty /dev/pts/1"),
2690 set_inferior_tty_command
,
2691 show_inferior_tty_command
,
2692 &setlist
, &showlist
);
2693 add_com_alias ("tty", "set inferior-tty", class_alias
, 0);
2695 add_setshow_optional_filename_cmd ("args", class_run
,
2696 &inferior_args_scratch
, _("\
2697 Set argument list to give program being debugged when it is started."), _("\
2698 Show argument list to give program being debugged when it is started."), _("\
2699 Follow this command with any number of args, to be passed to the program."),
2702 &setlist
, &showlist
);
2704 c
= add_cmd ("environment", no_class
, environment_info
, _("\
2705 The environment to give the program, or one variable's value.\n\
2706 With an argument VAR, prints the value of environment variable VAR to\n\
2707 give the program being debugged. With no arguments, prints the entire\n\
2708 environment to be given to the program."), &showlist
);
2709 set_cmd_completer (c
, noop_completer
);
2711 add_prefix_cmd ("unset", no_class
, unset_command
,
2712 _("Complement to certain \"set\" commands."),
2713 &unsetlist
, "unset ", 0, &cmdlist
);
2715 c
= add_cmd ("environment", class_run
, unset_environment_command
, _("\
2716 Cancel environment variable VAR for the program.\n\
2717 This does not affect the program until the next \"run\" command."),
2719 set_cmd_completer (c
, noop_completer
);
2721 c
= add_cmd ("environment", class_run
, set_environment_command
, _("\
2722 Set environment variable value to give the program.\n\
2723 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2724 VALUES of environment variables are uninterpreted strings.\n\
2725 This does not affect the program until the next \"run\" command."),
2727 set_cmd_completer (c
, noop_completer
);
2729 c
= add_com ("path", class_files
, path_command
, _("\
2730 Add directory DIR(s) to beginning of search path for object files.\n\
2731 $cwd in the path means the current working directory.\n\
2732 This path is equivalent to the $PATH shell variable. It is a list of\n\
2733 directories, separated by colons. These directories are searched to find\n\
2734 fully linked executable files and separately compiled object files as needed."));
2735 set_cmd_completer (c
, filename_completer
);
2737 c
= add_cmd ("paths", no_class
, path_info
, _("\
2738 Current search path for finding object files.\n\
2739 $cwd in the path means the current working directory.\n\
2740 This path is equivalent to the $PATH shell variable. It is a list of\n\
2741 directories, separated by colons. These directories are searched to find\n\
2742 fully linked executable files and separately compiled object files as needed."),
2744 set_cmd_completer (c
, noop_completer
);
2746 add_prefix_cmd ("kill", class_run
, kill_command
,
2747 _("Kill execution of program being debugged."),
2748 &killlist
, "kill ", 0, &cmdlist
);
2750 add_com ("attach", class_run
, attach_command
, _("\
2751 Attach to a process or file outside of GDB.\n\
2752 This command attaches to another target, of the same type as your last\n\
2753 \"target\" command (\"info files\" will show your target stack).\n\
2754 The command may take as argument a process id or a device file.\n\
2755 For a process id, you must have permission to send the process a signal,\n\
2756 and it must have the same effective uid as the debugger.\n\
2757 When using \"attach\" with a process id, the debugger finds the\n\
2758 program running in the process, looking first in the current working\n\
2759 directory, or (if not found there) using the source file search path\n\
2760 (see the \"directory\" command). You can also use the \"file\" command\n\
2761 to specify the program, and to load its symbol table."));
2763 add_prefix_cmd ("detach", class_run
, detach_command
, _("\
2764 Detach a process or file previously attached.\n\
2765 If a process, it is no longer traced, and it continues its execution. If\n\
2766 you were debugging a file, the file is closed and gdb no longer accesses it."),
2767 &detachlist
, "detach ", 0, &cmdlist
);
2769 add_com ("disconnect", class_run
, disconnect_command
, _("\
2770 Disconnect from a target.\n\
2771 The target will wait for another debugger to connect. Not available for\n\
2774 add_com ("signal", class_run
, signal_command
, _("\
2775 Continue program giving it signal specified by the argument.\n\
2776 An argument of \"0\" means continue program without giving it a signal."));
2778 add_com ("stepi", class_run
, stepi_command
, _("\
2779 Step one instruction exactly.\n\
2780 Argument N means do this N times (or till program stops for another reason)."));
2781 add_com_alias ("si", "stepi", class_alias
, 0);
2783 add_com ("nexti", class_run
, nexti_command
, _("\
2784 Step one instruction, but proceed through subroutine calls.\n\
2785 Argument N means do this N times (or till program stops for another reason)."));
2786 add_com_alias ("ni", "nexti", class_alias
, 0);
2788 add_com ("finish", class_run
, finish_command
, _("\
2789 Execute until selected stack frame returns.\n\
2790 Upon return, the value returned is printed and put in the value history."));
2791 add_com_alias ("fin", "finish", class_run
, 1);
2793 add_com ("next", class_run
, next_command
, _("\
2794 Step program, proceeding through subroutine calls.\n\
2795 Like the \"step\" command as long as subroutine calls do not happen;\n\
2796 when they do, the call is treated as one instruction.\n\
2797 Argument N means do this N times (or till program stops for another reason)."));
2798 add_com_alias ("n", "next", class_run
, 1);
2800 add_com_alias ("S", "next", class_run
, 1);
2802 add_com ("step", class_run
, step_command
, _("\
2803 Step program until it reaches a different source line.\n\
2804 Argument N means do this N times (or till program stops for another reason)."));
2805 add_com_alias ("s", "step", class_run
, 1);
2807 c
= add_com ("until", class_run
, until_command
, _("\
2808 Execute until the program reaches a source line greater than the current\n\
2809 or a specified location (same args as break command) within the current frame."));
2810 set_cmd_completer (c
, location_completer
);
2811 add_com_alias ("u", "until", class_run
, 1);
2813 c
= add_com ("advance", class_run
, advance_command
, _("\
2814 Continue the program up to the given location (same form as args for break command).\n\
2815 Execution will also stop upon exit from the current stack frame."));
2816 set_cmd_completer (c
, location_completer
);
2818 c
= add_com ("jump", class_run
, jump_command
, _("\
2819 Continue program being debugged at specified line or address.\n\
2820 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2821 for an address to start at."));
2822 set_cmd_completer (c
, location_completer
);
2826 c
= add_com ("go", class_run
, go_command
, _("\
2827 Usage: go <location>\n\
2828 Continue program being debugged, stopping at specified line or \n\
2830 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2831 expression for an address to start at.\n\
2832 This command is a combination of tbreak and jump."));
2833 set_cmd_completer (c
, location_completer
);
2837 add_com_alias ("g", "go", class_run
, 1);
2839 c
= add_com ("continue", class_run
, continue_command
, _("\
2840 Continue program being debugged, after signal or breakpoint.\n\
2841 If proceeding from breakpoint, a number N may be used as an argument,\n\
2842 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2843 the breakpoint won't break until the Nth time it is reached).\n\
2845 If non-stop mode is enabled, continue only the current thread,\n\
2846 otherwise all the threads in the program are continued. To \n\
2847 continue all stopped threads in non-stop mode, use the -a option.\n\
2848 Specifying -a and an ignore count simultaneously is an error."));
2849 add_com_alias ("c", "cont", class_run
, 1);
2850 add_com_alias ("fg", "cont", class_run
, 1);
2852 c
= add_com ("run", class_run
, run_command
, _("\
2853 Start debugged program. You may specify arguments to give it.\n\
2854 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2855 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2856 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2857 To cancel previous arguments and run with no arguments,\n\
2858 use \"set args\" without arguments."));
2859 set_cmd_completer (c
, filename_completer
);
2860 add_com_alias ("r", "run", class_run
, 1);
2862 add_com ("R", class_run
, run_no_args_command
,
2863 _("Start debugged program with no arguments."));
2865 c
= add_com ("start", class_run
, start_command
, _("\
2866 Run the debugged program until the beginning of the main procedure.\n\
2867 You may specify arguments to give to your program, just as with the\n\
2868 \"run\" command."));
2869 set_cmd_completer (c
, filename_completer
);
2871 c
= add_com ("interrupt", class_run
, interrupt_target_command
,
2872 _("Interrupt the execution of the debugged program.\n\
2873 If non-stop mode is enabled, interrupt only the current thread,\n\
2874 otherwise all the threads in the program are stopped. To \n\
2875 interrupt all running threads in non-stop mode, use the -a option."));
2877 add_info ("registers", nofp_registers_info
, _("\
2878 List of integer registers and their contents, for selected stack frame.\n\
2879 Register name as argument means describe only that register."));
2880 add_info_alias ("r", "registers", 1);
2883 add_com ("lr", class_info
, nofp_registers_info
, _("\
2884 List of integer registers and their contents, for selected stack frame.\n\
2885 Register name as argument means describe only that register."));
2886 add_info ("all-registers", all_registers_info
, _("\
2887 List of all registers and their contents, for selected stack frame.\n\
2888 Register name as argument means describe only that register."));
2890 add_info ("program", program_info
,
2891 _("Execution status of the program."));
2893 add_info ("float", float_info
,
2894 _("Print the status of the floating point unit\n"));
2896 add_info ("vector", vector_info
,
2897 _("Print the status of the vector unit\n"));