1 /* Memory-access and commands for "inferior" process, for GDB.
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "arch-utils.h"
25 #include "gdb_string.h"
39 #include "completer.h"
41 #include "event-top.h"
42 #include "parser-defs.h"
44 #include "reggroups.h"
48 #include "gdb_assert.h"
50 #include "target-descriptions.h"
51 #include "user-regs.h"
52 #include "exceptions.h"
53 #include "cli/cli-decode.h"
54 #include "gdbthread.h"
56 #include "inline-frame.h"
57 #include "tracepoint.h"
59 #include "continuations.h"
62 /* Functions exported for general use, in inferior.h: */
64 void all_registers_info (char *, int);
66 void registers_info (char *, int);
68 void nexti_command (char *, int);
70 void stepi_command (char *, int);
72 void continue_command (char *, int);
74 void interrupt_target_command (char *args
, int from_tty
);
76 /* Local functions: */
78 static void nofp_registers_info (char *, int);
80 static void print_return_value (struct type
*func_type
,
81 struct type
*value_type
);
83 static void until_next_command (int);
85 static void until_command (char *, int);
87 static void path_info (char *, int);
89 static void path_command (char *, int);
91 static void unset_command (char *, int);
93 static void float_info (char *, int);
95 static void disconnect_command (char *, int);
97 static void unset_environment_command (char *, int);
99 static void set_environment_command (char *, int);
101 static void environment_info (char *, int);
103 static void program_info (char *, int);
105 static void finish_command (char *, int);
107 static void signal_command (char *, int);
109 static void jump_command (char *, int);
111 static void step_1 (int, int, char *);
112 static void step_once (int skip_subroutines
, int single_inst
,
113 int count
, int thread
);
115 static void next_command (char *, int);
117 static void step_command (char *, int);
119 static void run_command (char *, int);
121 static void run_no_args_command (char *args
, int from_tty
);
123 static void go_command (char *line_no
, int from_tty
);
125 static int strip_bg_char (char **);
127 void _initialize_infcmd (void);
129 #define ERROR_NO_INFERIOR \
130 if (!target_has_execution) error (_("The program is not being run."));
132 /* Scratch area where string containing arguments to give to the
133 program will be stored by 'set args'. As soon as anything is
134 stored, notice_args_set will move it into per-inferior storage.
135 Arguments are separated by spaces. Empty string (pointer to '\0')
138 static char *inferior_args_scratch
;
140 /* Scratch area where 'set inferior-tty' will store user-provided value.
141 We'll immediate copy it into per-inferior storage. */
143 static char *inferior_io_terminal_scratch
;
145 /* Pid of our debugged inferior, or 0 if no inferior now.
146 Since various parts of infrun.c test this to see whether there is a program
147 being debugged it should be nonzero (currently 3 is used) for remote
150 ptid_t inferior_ptid
;
152 /* Address at which inferior stopped. */
156 /* Flag indicating that a command has proceeded the inferior past the
157 current breakpoint. */
159 int breakpoint_proceeded
;
161 /* Nonzero if stopped due to completion of a stack dummy routine. */
163 enum stop_stack_kind stop_stack_dummy
;
165 /* Nonzero if stopped due to a random (unexpected) signal in inferior
168 int stopped_by_random_signal
;
171 /* Accessor routines. */
173 /* Set the io terminal for the current inferior. Ownership of
174 TERMINAL_NAME is not transferred. */
177 set_inferior_io_terminal (const char *terminal_name
)
179 xfree (current_inferior ()->terminal
);
180 current_inferior ()->terminal
= terminal_name
? xstrdup (terminal_name
) : 0;
184 get_inferior_io_terminal (void)
186 return current_inferior ()->terminal
;
190 set_inferior_tty_command (char *args
, int from_tty
,
191 struct cmd_list_element
*c
)
193 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
194 Now route it to current inferior. */
195 set_inferior_io_terminal (inferior_io_terminal_scratch
);
199 show_inferior_tty_command (struct ui_file
*file
, int from_tty
,
200 struct cmd_list_element
*c
, const char *value
)
202 /* Note that we ignore the passed-in value in favor of computing it
204 const char *inferior_io_terminal
= get_inferior_io_terminal ();
206 if (inferior_io_terminal
== NULL
)
207 inferior_io_terminal
= "";
208 fprintf_filtered (gdb_stdout
,
209 _("Terminal for future runs of program being debugged "
210 "is \"%s\".\n"), inferior_io_terminal
);
214 get_inferior_args (void)
216 if (current_inferior ()->argc
!= 0)
220 n
= construct_inferior_arguments (current_inferior ()->argc
,
221 current_inferior ()->argv
);
222 set_inferior_args (n
);
226 if (current_inferior ()->args
== NULL
)
227 current_inferior ()->args
= xstrdup ("");
229 return current_inferior ()->args
;
232 /* Set the arguments for the current inferior. Ownership of
233 NEWARGS is not transferred. */
236 set_inferior_args (char *newargs
)
238 xfree (current_inferior ()->args
);
239 current_inferior ()->args
= newargs
? xstrdup (newargs
) : NULL
;
240 current_inferior ()->argc
= 0;
241 current_inferior ()->argv
= 0;
245 set_inferior_args_vector (int argc
, char **argv
)
247 current_inferior ()->argc
= argc
;
248 current_inferior ()->argv
= argv
;
251 /* Notice when `set args' is run. */
253 set_args_command (char *args
, int from_tty
, struct cmd_list_element
*c
)
255 /* CLI has assigned the user-provided value to inferior_args_scratch.
256 Now route it to current inferior. */
257 set_inferior_args (inferior_args_scratch
);
260 /* Notice when `show args' is run. */
262 show_args_command (struct ui_file
*file
, int from_tty
,
263 struct cmd_list_element
*c
, const char *value
)
265 /* Note that we ignore the passed-in value in favor of computing it
267 deprecated_show_value_hack (file
, from_tty
, c
, get_inferior_args ());
271 /* Compute command-line string given argument vector. This does the
272 same shell processing as fork_inferior. */
274 construct_inferior_arguments (int argc
, char **argv
)
278 if (STARTUP_WITH_SHELL
)
280 /* This holds all the characters considered special to the
281 typical Unix shells. We include `^' because the SunOS
282 /bin/sh treats it as a synonym for `|'. */
283 char *special
= "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
288 /* We over-compute the size. It shouldn't matter. */
289 for (i
= 0; i
< argc
; ++i
)
290 length
+= 3 * strlen (argv
[i
]) + 1 + 2 * (argv
[i
][0] == '\0');
292 result
= (char *) xmalloc (length
);
295 for (i
= 0; i
< argc
; ++i
)
300 /* Need to handle empty arguments specially. */
301 if (argv
[i
][0] == '\0')
308 for (cp
= argv
[i
]; *cp
; ++cp
)
312 /* A newline cannot be quoted with a backslash (it
313 just disappears), only by putting it inside
321 if (strchr (special
, *cp
) != NULL
)
332 /* In this case we can't handle arguments that contain spaces,
333 tabs, or newlines -- see breakup_args(). */
337 for (i
= 0; i
< argc
; ++i
)
339 char *cp
= strchr (argv
[i
], ' ');
341 cp
= strchr (argv
[i
], '\t');
343 cp
= strchr (argv
[i
], '\n');
345 error (_("can't handle command-line "
346 "argument containing whitespace"));
347 length
+= strlen (argv
[i
]) + 1;
350 result
= (char *) xmalloc (length
);
352 for (i
= 0; i
< argc
; ++i
)
355 strcat (result
, " ");
356 strcat (result
, argv
[i
]);
364 /* This function detects whether or not a '&' character (indicating
365 background execution) has been added as *the last* of the arguments ARGS
366 of a command. If it has, it removes it and returns 1. Otherwise it
367 does nothing and returns 0. */
369 strip_bg_char (char **args
)
373 p
= strchr (*args
, '&');
377 if (p
== (*args
+ strlen (*args
) - 1))
379 if (strlen (*args
) > 1)
383 while (*p
== ' ' || *p
== '\t');
394 /* Common actions to take after creating any sort of inferior, by any
395 means (running, attaching, connecting, et cetera). The target
396 should be stopped. */
399 post_create_inferior (struct target_ops
*target
, int from_tty
)
401 volatile struct gdb_exception ex
;
403 /* Be sure we own the terminal in case write operations are performed. */
404 target_terminal_ours ();
406 /* If the target hasn't taken care of this already, do it now.
407 Targets which need to access registers during to_open,
408 to_create_inferior, or to_attach should do it earlier; but many
410 target_find_description ();
412 /* Now that we know the register layout, retrieve current PC. But
413 if the PC is unavailable (e.g., we're opening a core file with
414 missing registers info), ignore it. */
416 TRY_CATCH (ex
, RETURN_MASK_ERROR
)
418 stop_pc
= regcache_read_pc (get_current_regcache ());
420 if (ex
.reason
< 0 && ex
.error
!= NOT_AVAILABLE_ERROR
)
421 throw_exception (ex
);
425 const unsigned solib_add_generation
426 = current_program_space
->solib_add_generation
;
428 /* Create the hooks to handle shared library load and unload
430 #ifdef SOLIB_CREATE_INFERIOR_HOOK
431 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid
));
433 solib_create_inferior_hook (from_tty
);
436 if (current_program_space
->solib_add_generation
== solib_add_generation
)
438 /* The platform-specific hook should load initial shared libraries,
439 but didn't. FROM_TTY will be incorrectly 0 but such solib
440 targets should be fixed anyway. Call it only after the solib
441 target has been initialized by solib_create_inferior_hook. */
444 warning (_("platform-specific solib_create_inferior_hook did "
445 "not load initial shared libraries."));
447 /* If the solist is global across processes, there's no need to
449 if (!gdbarch_has_global_solist (target_gdbarch
))
452 SOLIB_ADD (NULL
, 0, target
, auto_solib_add
);
454 solib_add (NULL
, 0, target
, auto_solib_add
);
460 /* If the user sets watchpoints before execution having started,
461 then she gets software watchpoints, because GDB can't know which
462 target will end up being pushed, or if it supports hardware
463 watchpoints or not. breakpoint_re_set takes care of promoting
464 watchpoints to hardware watchpoints if possible, however, if this
465 new inferior doesn't load shared libraries or we don't pull in
466 symbols from any other source on this target/arch,
467 breakpoint_re_set is never called. Call it now so that software
468 watchpoints get a chance to be promoted to hardware watchpoints
469 if the now pushed target supports hardware watchpoints. */
470 breakpoint_re_set ();
472 observer_notify_inferior_created (target
, from_tty
);
475 /* Kill the inferior if already running. This function is designed
476 to be called when we are about to start the execution of the program
477 from the beginning. Ask the user to confirm that he wants to restart
478 the program being debugged when FROM_TTY is non-null. */
481 kill_if_already_running (int from_tty
)
483 if (! ptid_equal (inferior_ptid
, null_ptid
) && target_has_execution
)
485 /* Bail out before killing the program if we will not be able to
487 target_require_runnable ();
490 && !query (_("The program being debugged has been started already.\n\
491 Start it from the beginning? ")))
492 error (_("Program not restarted."));
497 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
498 a temporary breakpoint at the begining of the main program before
499 running the program. */
502 run_command_1 (char *args
, int from_tty
, int tbreak_at_main
)
505 struct cleanup
*old_chain
;
507 struct ui_out
*uiout
= current_uiout
;
511 kill_if_already_running (from_tty
);
513 init_wait_for_inferior ();
514 clear_breakpoint_hit_counts ();
516 /* Clean up any leftovers from other runs. Some other things from
517 this function should probably be moved into target_pre_inferior. */
518 target_pre_inferior (from_tty
);
520 /* The comment here used to read, "The exec file is re-read every
521 time we do a generic_mourn_inferior, so we just have to worry
522 about the symbol file." The `generic_mourn_inferior' function
523 gets called whenever the program exits. However, suppose the
524 program exits, and *then* the executable file changes? We need
525 to check again here. Since reopen_exec_file doesn't do anything
526 if the timestamp hasn't changed, I don't see the harm. */
530 /* Insert the temporary breakpoint if a location was specified. */
532 tbreak_command (main_name (), 0);
534 exec_file
= (char *) get_exec_file (0);
536 if (non_stop
&& !target_supports_non_stop ())
537 error (_("The target does not support running in non-stop mode."));
539 /* We keep symbols from add-symbol-file, on the grounds that the
540 user might want to add some symbols before running the program
541 (right?). But sometimes (dynamic loading where the user manually
542 introduces the new symbols with add-symbol-file), the code which
543 the symbols describe does not persist between runs. Currently
544 the user has to manually nuke all symbols between runs if they
545 want them to go away (PR 2207). This is probably reasonable. */
549 if (target_can_async_p ())
550 async_disable_stdin ();
554 int async_exec
= strip_bg_char (&args
);
556 /* If we get a request for running in the bg but the target
557 doesn't support it, error out. */
558 if (async_exec
&& !target_can_async_p ())
559 error (_("Asynchronous execution not supported on this target."));
561 /* If we don't get a request of running in the bg, then we need
562 to simulate synchronous (fg) execution. */
563 if (!async_exec
&& target_can_async_p ())
565 /* Simulate synchronous execution. */
566 async_disable_stdin ();
569 /* If there were other args, beside '&', process them. */
571 set_inferior_args (args
);
576 ui_out_field_string (uiout
, NULL
, "Starting program");
577 ui_out_text (uiout
, ": ");
579 ui_out_field_string (uiout
, "execfile", exec_file
);
580 ui_out_spaces (uiout
, 1);
581 /* We call get_inferior_args() because we might need to compute
583 ui_out_field_string (uiout
, "infargs", get_inferior_args ());
584 ui_out_text (uiout
, "\n");
585 ui_out_flush (uiout
);
588 /* We call get_inferior_args() because we might need to compute
590 target_create_inferior (exec_file
, get_inferior_args (),
591 environ_vector (current_inferior ()->environment
),
594 /* We're starting off a new process. When we get out of here, in
595 non-stop mode, finish the state of all threads of that process,
596 but leave other threads alone, as they may be stopped in internal
597 events --- the frontend shouldn't see them as stopped. In
598 all-stop, always finish the state of all threads, as we may be
599 resuming more than just the new process. */
601 ptid
= pid_to_ptid (ptid_get_pid (inferior_ptid
));
603 ptid
= minus_one_ptid
;
604 old_chain
= make_cleanup (finish_thread_state_cleanup
, &ptid
);
606 /* Pass zero for FROM_TTY, because at this point the "run" command
607 has done its thing; now we are setting up the running program. */
608 post_create_inferior (¤t_target
, 0);
610 /* Start the target running. Do not use -1 continuation as it would skip
611 breakpoint right at the entry point. */
612 proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0
, 0);
614 /* Since there was no error, there's no need to finish the thread
616 discard_cleanups (old_chain
);
620 run_command (char *args
, int from_tty
)
622 run_command_1 (args
, from_tty
, 0);
626 run_no_args_command (char *args
, int from_tty
)
628 set_inferior_args ("");
632 /* Start the execution of the program up until the beginning of the main
636 start_command (char *args
, int from_tty
)
638 /* Some languages such as Ada need to search inside the program
639 minimal symbols for the location where to put the temporary
640 breakpoint before starting. */
641 if (!have_minimal_symbols ())
642 error (_("No symbol table loaded. Use the \"file\" command."));
644 /* Run the program until reaching the main procedure... */
645 run_command_1 (args
, from_tty
, 1);
649 proceed_thread_callback (struct thread_info
*thread
, void *arg
)
651 /* We go through all threads individually instead of compressing
652 into a single target `resume_all' request, because some threads
653 may be stopped in internal breakpoints/events, or stopped waiting
654 for its turn in the displaced stepping queue (that is, they are
655 running && !executing). The target side has no idea about why
656 the thread is stopped, so a `resume_all' command would resume too
657 much. If/when GDB gains a way to tell the target `hold this
658 thread stopped until I say otherwise', then we can optimize
660 if (!is_stopped (thread
->ptid
))
663 switch_to_thread (thread
->ptid
);
664 clear_proceed_status ();
665 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
670 ensure_valid_thread (void)
672 if (ptid_equal (inferior_ptid
, null_ptid
)
673 || is_exited (inferior_ptid
))
674 error (_("Cannot execute this command without a live selected thread."));
677 /* If the user is looking at trace frames, any resumption of execution
678 is likely to mix up recorded and live target data. So simply
679 disallow those commands. */
682 ensure_not_tfind_mode (void)
684 if (get_traceframe_number () >= 0)
685 error (_("Cannot execute this command while looking at trace frames."));
689 continue_1 (int all_threads
)
692 ensure_not_tfind_mode ();
694 if (non_stop
&& all_threads
)
696 /* Don't error out if the current thread is running, because
697 there may be other stopped threads. */
698 struct cleanup
*old_chain
;
700 /* Backup current thread and selected frame. */
701 old_chain
= make_cleanup_restore_current_thread ();
703 iterate_over_threads (proceed_thread_callback
, NULL
);
705 /* Restore selected ptid. */
706 do_cleanups (old_chain
);
710 ensure_valid_thread ();
711 ensure_not_running ();
712 clear_proceed_status ();
713 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
717 /* continue [-a] [proceed-count] [&] */
719 continue_command (char *args
, int from_tty
)
725 /* Find out whether we must run in the background. */
727 async_exec
= strip_bg_char (&args
);
729 /* If we must run in the background, but the target can't do it,
731 if (async_exec
&& !target_can_async_p ())
732 error (_("Asynchronous execution not supported on this target."));
734 /* If we are not asked to run in the bg, then prepare to run in the
735 foreground, synchronously. */
736 if (!async_exec
&& target_can_async_p ())
738 /* Simulate synchronous execution. */
739 async_disable_stdin ();
744 if (strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
747 args
+= sizeof ("-a") - 1;
753 if (!non_stop
&& all_threads
)
754 error (_("`-a' is meaningless in all-stop mode."));
756 if (args
!= NULL
&& all_threads
)
757 error (_("Can't resume all threads and specify "
758 "proceed count simultaneously."));
760 /* If we have an argument left, set proceed count of breakpoint we
767 struct thread_info
*tp
;
770 tp
= find_thread_ptid (inferior_ptid
);
774 struct target_waitstatus ws
;
776 get_last_target_status (&last_ptid
, &ws
);
777 tp
= find_thread_ptid (last_ptid
);
780 bs
= tp
->control
.stop_bpstat
;
782 while ((stat
= bpstat_num (&bs
, &num
)) != 0)
785 set_ignore_count (num
,
786 parse_and_eval_long (args
) - 1,
788 /* set_ignore_count prints a message ending with a period.
789 So print two spaces before "Continuing.". */
791 printf_filtered (" ");
795 if (!stopped
&& from_tty
)
798 ("Not stopped at any breakpoint; argument ignored.\n");
803 printf_filtered (_("Continuing.\n"));
805 continue_1 (all_threads
);
808 /* Record the starting point of a "step" or "next" command. */
811 set_step_frame (void)
813 struct symtab_and_line sal
;
815 find_frame_sal (get_current_frame (), &sal
);
816 set_step_info (get_current_frame (), sal
);
819 /* Step until outside of current statement. */
822 step_command (char *count_string
, int from_tty
)
824 step_1 (0, 0, count_string
);
827 /* Likewise, but skip over subroutine calls as if single instructions. */
830 next_command (char *count_string
, int from_tty
)
832 step_1 (1, 0, count_string
);
835 /* Likewise, but step only one instruction. */
838 stepi_command (char *count_string
, int from_tty
)
840 step_1 (0, 1, count_string
);
844 nexti_command (char *count_string
, int from_tty
)
846 step_1 (1, 1, count_string
);
850 delete_longjmp_breakpoint_cleanup (void *arg
)
852 int thread
= * (int *) arg
;
853 delete_longjmp_breakpoint (thread
);
857 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
860 struct cleanup
*cleanups
= make_cleanup (null_cleanup
, NULL
);
865 ensure_not_tfind_mode ();
866 ensure_valid_thread ();
867 ensure_not_running ();
870 async_exec
= strip_bg_char (&count_string
);
872 /* If we get a request for running in the bg but the target
873 doesn't support it, error out. */
874 if (async_exec
&& !target_can_async_p ())
875 error (_("Asynchronous execution not supported on this target."));
877 /* If we don't get a request of running in the bg, then we need
878 to simulate synchronous (fg) execution. */
879 if (!async_exec
&& target_can_async_p ())
881 /* Simulate synchronous execution. */
882 async_disable_stdin ();
885 count
= count_string
? parse_and_eval_long (count_string
) : 1;
887 if (!single_inst
|| skip_subroutines
) /* Leave si command alone. */
889 struct thread_info
*tp
= inferior_thread ();
891 if (in_thread_list (inferior_ptid
))
892 thread
= pid_to_thread_id (inferior_ptid
);
894 set_longjmp_breakpoint (tp
, get_frame_id (get_current_frame ()));
896 make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
899 /* In synchronous case, all is well; each step_once call will step once. */
900 if (!target_can_async_p ())
902 for (; count
> 0; count
--)
904 step_once (skip_subroutines
, single_inst
, count
, thread
);
906 if (!target_has_execution
)
910 struct thread_info
*tp
= inferior_thread ();
912 if (!tp
->control
.stop_step
|| !tp
->step_multi
)
914 /* If we stopped for some reason that is not stepping
915 there are no further steps to make. */
922 do_cleanups (cleanups
);
926 /* In the case of an asynchronous target things get complicated;
927 do only one step for now, before returning control to the
928 event loop. Let the continuation figure out how many other
929 steps we need to do, and handle them one at the time, through
931 step_once (skip_subroutines
, single_inst
, count
, thread
);
933 /* We are running, and the continuation is installed. It will
934 disable the longjmp breakpoint as appropriate. */
935 discard_cleanups (cleanups
);
939 struct step_1_continuation_args
942 int skip_subroutines
;
947 /* Called after we are done with one step operation, to check whether
948 we need to step again, before we print the prompt and return control
949 to the user. If count is > 1, we will need to do one more call to
950 proceed(), via step_once(). Basically it is like step_once and
951 step_1_continuation are co-recursive. */
953 step_1_continuation (void *args
, int err
)
955 struct step_1_continuation_args
*a
= args
;
957 if (target_has_execution
)
959 struct thread_info
*tp
;
961 tp
= inferior_thread ();
963 && tp
->step_multi
&& tp
->control
.stop_step
)
965 /* There are more steps to make, and we did stop due to
966 ending a stepping range. Do another step. */
967 step_once (a
->skip_subroutines
, a
->single_inst
,
968 a
->count
- 1, a
->thread
);
974 /* We either hit an error, or stopped for some reason that is
975 not stepping, or there are no further steps to make.
977 if (!a
->single_inst
|| a
->skip_subroutines
)
978 delete_longjmp_breakpoint (a
->thread
);
981 /* Do just one step operation. This is useful to implement the 'step
982 n' kind of commands. In case of asynchronous targets, we will have
983 to set up a continuation to be done after the target stops (after
984 this one step). For synch targets, the caller handles further
988 step_once (int skip_subroutines
, int single_inst
, int count
, int thread
)
990 struct frame_info
*frame
= get_current_frame ();
994 /* Don't assume THREAD is a valid thread id. It is set to -1 if
995 the longjmp breakpoint was not required. Use the
996 INFERIOR_PTID thread instead, which is the same thread when
998 struct thread_info
*tp
= inferior_thread ();
1000 clear_proceed_status ();
1007 /* Step at an inlined function behaves like "down". */
1008 if (!skip_subroutines
&& !single_inst
1009 && inline_skipped_frames (inferior_ptid
))
1013 /* Pretend that we've ran. */
1014 resume_ptid
= user_visible_resume_ptid (1);
1015 set_running (resume_ptid
, 1);
1017 step_into_inline_frame (inferior_ptid
);
1019 step_once (skip_subroutines
, single_inst
, count
- 1, thread
);
1022 /* Pretend that we've stopped. */
1025 if (target_can_async_p ())
1026 inferior_event_handler (INF_EXEC_COMPLETE
, NULL
);
1031 pc
= get_frame_pc (frame
);
1032 find_pc_line_pc_range (pc
,
1033 &tp
->control
.step_range_start
,
1034 &tp
->control
.step_range_end
);
1036 /* If we have no line info, switch to stepi mode. */
1037 if (tp
->control
.step_range_end
== 0 && step_stop_if_no_debug
)
1038 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1039 else if (tp
->control
.step_range_end
== 0)
1043 if (find_pc_partial_function (pc
, &name
,
1044 &tp
->control
.step_range_start
,
1045 &tp
->control
.step_range_end
) == 0)
1046 error (_("Cannot find bounds of current function"));
1048 target_terminal_ours ();
1049 printf_filtered (_("Single stepping until exit from function %s,"
1050 "\nwhich has no line number information.\n"),
1056 /* Say we are stepping, but stop after one insn whatever it does. */
1057 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1058 if (!skip_subroutines
)
1060 Don't step over function calls, not even to functions lacking
1062 tp
->control
.step_over_calls
= STEP_OVER_NONE
;
1065 if (skip_subroutines
)
1066 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1068 tp
->step_multi
= (count
> 1);
1069 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1071 /* For async targets, register a continuation to do any
1072 additional steps. For sync targets, the caller will handle
1073 further stepping. */
1074 if (target_can_async_p ())
1076 struct step_1_continuation_args
*args
;
1078 args
= xmalloc (sizeof (*args
));
1079 args
->skip_subroutines
= skip_subroutines
;
1080 args
->single_inst
= single_inst
;
1081 args
->count
= count
;
1082 args
->thread
= thread
;
1084 add_intermediate_continuation (tp
, step_1_continuation
, args
, xfree
);
1090 /* Continue program at specified address. */
1093 jump_command (char *arg
, int from_tty
)
1095 struct gdbarch
*gdbarch
= get_current_arch ();
1097 struct symtabs_and_lines sals
;
1098 struct symtab_and_line sal
;
1104 ensure_not_tfind_mode ();
1105 ensure_valid_thread ();
1106 ensure_not_running ();
1108 /* Find out whether we must run in the background. */
1110 async_exec
= strip_bg_char (&arg
);
1112 /* If we must run in the background, but the target can't do it,
1114 if (async_exec
&& !target_can_async_p ())
1115 error (_("Asynchronous execution not supported on this target."));
1118 error_no_arg (_("starting address"));
1120 sals
= decode_line_spec_1 (arg
, DECODE_LINE_FUNFIRSTLINE
);
1121 if (sals
.nelts
!= 1)
1123 error (_("Unreasonable jump request"));
1129 if (sal
.symtab
== 0 && sal
.pc
== 0)
1130 error (_("No source file has been specified."));
1132 resolve_sal_pc (&sal
); /* May error out. */
1134 /* See if we are trying to jump to another function. */
1135 fn
= get_frame_function (get_current_frame ());
1136 sfn
= find_pc_function (sal
.pc
);
1137 if (fn
!= NULL
&& sfn
!= fn
)
1139 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal
.line
,
1140 SYMBOL_PRINT_NAME (fn
)))
1142 error (_("Not confirmed."));
1149 fixup_symbol_section (sfn
, 0);
1150 if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn
)) &&
1151 !section_is_mapped (SYMBOL_OBJ_SECTION (sfn
)))
1153 if (!query (_("WARNING!!! Destination is in "
1154 "unmapped overlay! Jump anyway? ")))
1156 error (_("Not confirmed."));
1166 printf_filtered (_("Continuing at "));
1167 fputs_filtered (paddress (gdbarch
, addr
), gdb_stdout
);
1168 printf_filtered (".\n");
1171 /* If we are not asked to run in the bg, then prepare to run in the
1172 foreground, synchronously. */
1173 if (!async_exec
&& target_can_async_p ())
1175 /* Simulate synchronous execution. */
1176 async_disable_stdin ();
1179 clear_proceed_status ();
1180 proceed (addr
, TARGET_SIGNAL_0
, 0);
1184 /* Go to line or address in current procedure. */
1186 go_command (char *line_no
, int from_tty
)
1188 if (line_no
== (char *) NULL
|| !*line_no
)
1189 printf_filtered (_("Usage: go <location>\n"));
1192 tbreak_command (line_no
, from_tty
);
1193 jump_command (line_no
, from_tty
);
1198 /* Continue program giving it specified signal. */
1201 signal_command (char *signum_exp
, int from_tty
)
1203 enum target_signal oursig
;
1206 dont_repeat (); /* Too dangerous. */
1208 ensure_not_tfind_mode ();
1209 ensure_valid_thread ();
1210 ensure_not_running ();
1212 /* Find out whether we must run in the background. */
1213 if (signum_exp
!= NULL
)
1214 async_exec
= strip_bg_char (&signum_exp
);
1216 /* If we must run in the background, but the target can't do it,
1218 if (async_exec
&& !target_can_async_p ())
1219 error (_("Asynchronous execution not supported on this target."));
1221 /* If we are not asked to run in the bg, then prepare to run in the
1222 foreground, synchronously. */
1223 if (!async_exec
&& target_can_async_p ())
1225 /* Simulate synchronous execution. */
1226 async_disable_stdin ();
1230 error_no_arg (_("signal number"));
1232 /* It would be even slicker to make signal names be valid expressions,
1233 (the type could be "enum $signal" or some such), then the user could
1234 assign them to convenience variables. */
1235 oursig
= target_signal_from_name (signum_exp
);
1237 if (oursig
== TARGET_SIGNAL_UNKNOWN
)
1239 /* No, try numeric. */
1240 int num
= parse_and_eval_long (signum_exp
);
1243 oursig
= TARGET_SIGNAL_0
;
1245 oursig
= target_signal_from_command (num
);
1250 if (oursig
== TARGET_SIGNAL_0
)
1251 printf_filtered (_("Continuing with no signal.\n"));
1253 printf_filtered (_("Continuing with signal %s.\n"),
1254 target_signal_to_name (oursig
));
1257 clear_proceed_status ();
1258 proceed ((CORE_ADDR
) -1, oursig
, 0);
1261 /* Continuation args to be passed to the "until" command
1263 struct until_next_continuation_args
1265 /* The thread that was current when the command was executed. */
1269 /* A continuation callback for until_next_command. */
1272 until_next_continuation (void *arg
, int err
)
1274 struct until_next_continuation_args
*a
= arg
;
1276 delete_longjmp_breakpoint (a
->thread
);
1279 /* Proceed until we reach a different source line with pc greater than
1280 our current one or exit the function. We skip calls in both cases.
1282 Note that eventually this command should probably be changed so
1283 that only source lines are printed out when we hit the breakpoint
1284 we set. This may involve changes to wait_for_inferior and the
1285 proceed status code. */
1288 until_next_command (int from_tty
)
1290 struct frame_info
*frame
;
1292 struct symbol
*func
;
1293 struct symtab_and_line sal
;
1294 struct thread_info
*tp
= inferior_thread ();
1295 int thread
= tp
->num
;
1296 struct cleanup
*old_chain
;
1298 clear_proceed_status ();
1301 frame
= get_current_frame ();
1303 /* Step until either exited from this function or greater
1304 than the current line (if in symbolic section) or pc (if
1307 pc
= get_frame_pc (frame
);
1308 func
= find_pc_function (pc
);
1312 struct minimal_symbol
*msymbol
= lookup_minimal_symbol_by_pc (pc
);
1314 if (msymbol
== NULL
)
1315 error (_("Execution is not within a known function."));
1317 tp
->control
.step_range_start
= SYMBOL_VALUE_ADDRESS (msymbol
);
1318 tp
->control
.step_range_end
= pc
;
1322 sal
= find_pc_line (pc
, 0);
1324 tp
->control
.step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
1325 tp
->control
.step_range_end
= sal
.end
;
1328 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1330 tp
->step_multi
= 0; /* Only one call to proceed */
1332 set_longjmp_breakpoint (tp
, get_frame_id (frame
));
1333 old_chain
= make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
1335 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1337 if (target_can_async_p () && is_running (inferior_ptid
))
1339 struct until_next_continuation_args
*cont_args
;
1341 discard_cleanups (old_chain
);
1342 cont_args
= XNEW (struct until_next_continuation_args
);
1343 cont_args
->thread
= inferior_thread ()->num
;
1345 add_continuation (tp
, until_next_continuation
, cont_args
, xfree
);
1348 do_cleanups (old_chain
);
1352 until_command (char *arg
, int from_tty
)
1357 ensure_not_tfind_mode ();
1358 ensure_valid_thread ();
1359 ensure_not_running ();
1361 /* Find out whether we must run in the background. */
1363 async_exec
= strip_bg_char (&arg
);
1365 /* If we must run in the background, but the target can't do it,
1367 if (async_exec
&& !target_can_async_p ())
1368 error (_("Asynchronous execution not supported on this target."));
1370 /* If we are not asked to run in the bg, then prepare to run in the
1371 foreground, synchronously. */
1372 if (!async_exec
&& target_can_async_p ())
1374 /* Simulate synchronous execution. */
1375 async_disable_stdin ();
1379 until_break_command (arg
, from_tty
, 0);
1381 until_next_command (from_tty
);
1385 advance_command (char *arg
, int from_tty
)
1390 ensure_not_tfind_mode ();
1391 ensure_valid_thread ();
1392 ensure_not_running ();
1395 error_no_arg (_("a location"));
1397 /* Find out whether we must run in the background. */
1399 async_exec
= strip_bg_char (&arg
);
1401 /* If we must run in the background, but the target can't do it,
1403 if (async_exec
&& !target_can_async_p ())
1404 error (_("Asynchronous execution not supported on this target."));
1406 /* If we are not asked to run in the bg, then prepare to run in the
1407 foreground, synchronously. */
1408 if (!async_exec
&& target_can_async_p ())
1410 /* Simulate synchronous execution. */
1411 async_disable_stdin ();
1414 until_break_command (arg
, from_tty
, 1);
1417 /* Print the result of a function at the end of a 'finish' command. */
1420 print_return_value (struct type
*func_type
, struct type
*value_type
)
1422 struct gdbarch
*gdbarch
= get_regcache_arch (stop_registers
);
1423 struct cleanup
*old_chain
;
1424 struct ui_stream
*stb
;
1425 struct value
*value
;
1426 struct ui_out
*uiout
= current_uiout
;
1428 CHECK_TYPEDEF (value_type
);
1429 gdb_assert (TYPE_CODE (value_type
) != TYPE_CODE_VOID
);
1431 /* FIXME: 2003-09-27: When returning from a nested inferior function
1432 call, it's possible (with no help from the architecture vector)
1433 to locate and return/print a "struct return" value. This is just
1434 a more complicated case of what is already being done in the
1435 inferior function call code. In fact, when inferior function
1436 calls are made async, this will likely be made the norm. */
1438 switch (gdbarch_return_value (gdbarch
, func_type
, value_type
,
1441 case RETURN_VALUE_REGISTER_CONVENTION
:
1442 case RETURN_VALUE_ABI_RETURNS_ADDRESS
:
1443 case RETURN_VALUE_ABI_PRESERVES_ADDRESS
:
1444 value
= allocate_value (value_type
);
1445 gdbarch_return_value (gdbarch
, func_type
, value_type
, stop_registers
,
1446 value_contents_raw (value
), NULL
);
1448 case RETURN_VALUE_STRUCT_CONVENTION
:
1452 internal_error (__FILE__
, __LINE__
, _("bad switch"));
1457 struct value_print_options opts
;
1460 stb
= ui_out_stream_new (uiout
);
1461 old_chain
= make_cleanup_ui_out_stream_delete (stb
);
1462 ui_out_text (uiout
, "Value returned is ");
1463 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d",
1464 record_latest_value (value
));
1465 ui_out_text (uiout
, " = ");
1466 get_raw_print_options (&opts
);
1467 value_print (value
, stb
->stream
, &opts
);
1468 ui_out_field_stream (uiout
, "return-value", stb
);
1469 ui_out_text (uiout
, "\n");
1470 do_cleanups (old_chain
);
1474 ui_out_text (uiout
, "Value returned has type: ");
1475 ui_out_field_string (uiout
, "return-type", TYPE_NAME (value_type
));
1476 ui_out_text (uiout
, ".");
1477 ui_out_text (uiout
, " Cannot determine contents\n");
1481 /* Stuff that needs to be done by the finish command after the target
1482 has stopped. In asynchronous mode, we wait for the target to stop
1483 in the call to poll or select in the event loop, so it is
1484 impossible to do all the stuff as part of the finish_command
1485 function itself. The only chance we have to complete this command
1486 is in fetch_inferior_event, which is called by the event loop as
1487 soon as it detects that the target has stopped. */
1489 struct finish_command_continuation_args
1491 /* The thread that as current when the command was executed. */
1493 struct breakpoint
*breakpoint
;
1494 struct symbol
*function
;
1498 finish_command_continuation (void *arg
, int err
)
1500 struct finish_command_continuation_args
*a
= arg
;
1504 struct thread_info
*tp
= NULL
;
1507 if (!ptid_equal (inferior_ptid
, null_ptid
)
1508 && target_has_execution
1509 && is_stopped (inferior_ptid
))
1511 tp
= inferior_thread ();
1512 bs
= tp
->control
.stop_bpstat
;
1515 if (bpstat_find_breakpoint (bs
, a
->breakpoint
) != NULL
1516 && a
->function
!= NULL
)
1518 struct type
*value_type
;
1520 value_type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (a
->function
));
1522 internal_error (__FILE__
, __LINE__
,
1523 _("finish_command: function has no target type"));
1525 if (TYPE_CODE (value_type
) != TYPE_CODE_VOID
)
1527 volatile struct gdb_exception ex
;
1529 TRY_CATCH (ex
, RETURN_MASK_ALL
)
1531 /* print_return_value can throw an exception in some
1532 circumstances. We need to catch this so that we still
1533 delete the breakpoint. */
1534 print_return_value (SYMBOL_TYPE (a
->function
), value_type
);
1537 exception_print (gdb_stdout
, ex
);
1541 /* We suppress normal call of normal_stop observer and do it
1542 here so that the *stopped notification includes the return
1544 if (bs
!= NULL
&& tp
->control
.proceed_to_finish
)
1545 observer_notify_normal_stop (bs
, 1 /* print frame */);
1548 delete_breakpoint (a
->breakpoint
);
1549 delete_longjmp_breakpoint (a
->thread
);
1553 finish_command_continuation_free_arg (void *arg
)
1558 /* finish_backward -- helper function for finish_command. */
1561 finish_backward (struct symbol
*function
)
1563 struct symtab_and_line sal
;
1564 struct thread_info
*tp
= inferior_thread ();
1566 CORE_ADDR func_addr
;
1568 pc
= get_frame_pc (get_current_frame ());
1570 if (find_pc_partial_function (pc
, NULL
, &func_addr
, NULL
) == 0)
1571 internal_error (__FILE__
, __LINE__
,
1572 _("Finish: couldn't find function."));
1574 sal
= find_pc_line (func_addr
, 0);
1576 tp
->control
.proceed_to_finish
= 1;
1577 /* Special case: if we're sitting at the function entry point,
1578 then all we need to do is take a reverse singlestep. We
1579 don't need to set a breakpoint, and indeed it would do us
1582 Note that this can only happen at frame #0, since there's
1583 no way that a function up the stack can have a return address
1584 that's equal to its entry point. */
1588 struct frame_info
*frame
= get_selected_frame (NULL
);
1589 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1590 struct symtab_and_line sr_sal
;
1592 /* Set a step-resume at the function's entry point. Once that's
1593 hit, we'll do one more step backwards. */
1596 sr_sal
.pspace
= get_frame_program_space (frame
);
1597 insert_step_resume_breakpoint_at_sal (gdbarch
,
1598 sr_sal
, null_frame_id
);
1600 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1604 /* We're almost there -- we just need to back up by one more
1606 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1607 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1611 /* finish_forward -- helper function for finish_command. */
1614 finish_forward (struct symbol
*function
, struct frame_info
*frame
)
1616 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1617 struct symtab_and_line sal
;
1618 struct thread_info
*tp
= inferior_thread ();
1619 struct breakpoint
*breakpoint
;
1620 struct cleanup
*old_chain
;
1621 struct finish_command_continuation_args
*cargs
;
1622 int thread
= tp
->num
;
1624 sal
= find_pc_line (get_frame_pc (frame
), 0);
1625 sal
.pc
= get_frame_pc (frame
);
1627 breakpoint
= set_momentary_breakpoint (gdbarch
, sal
,
1628 get_stack_frame_id (frame
),
1631 old_chain
= make_cleanup_delete_breakpoint (breakpoint
);
1633 set_longjmp_breakpoint (tp
, get_frame_id (frame
));
1634 make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
1636 /* We want stop_registers, please... */
1637 tp
->control
.proceed_to_finish
= 1;
1638 cargs
= xmalloc (sizeof (*cargs
));
1640 cargs
->thread
= thread
;
1641 cargs
->breakpoint
= breakpoint
;
1642 cargs
->function
= function
;
1643 add_continuation (tp
, finish_command_continuation
, cargs
,
1644 finish_command_continuation_free_arg
);
1645 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
1647 discard_cleanups (old_chain
);
1648 if (!target_can_async_p ())
1649 do_all_continuations (0);
1652 /* "finish": Set a temporary breakpoint at the place the selected
1653 frame will return to, then continue. */
1656 finish_command (char *arg
, int from_tty
)
1658 struct frame_info
*frame
;
1659 struct symbol
*function
;
1664 ensure_not_tfind_mode ();
1665 ensure_valid_thread ();
1666 ensure_not_running ();
1668 /* Find out whether we must run in the background. */
1670 async_exec
= strip_bg_char (&arg
);
1672 /* If we must run in the background, but the target can't do it,
1674 if (async_exec
&& !target_can_async_p ())
1675 error (_("Asynchronous execution not supported on this target."));
1677 /* If we are not asked to run in the bg, then prepare to run in the
1678 foreground, synchronously. */
1679 if (!async_exec
&& target_can_async_p ())
1681 /* Simulate synchronous execution. */
1682 async_disable_stdin ();
1686 error (_("The \"finish\" command does not take any arguments."));
1688 frame
= get_prev_frame (get_selected_frame (_("No selected frame.")));
1690 error (_("\"finish\" not meaningful in the outermost frame."));
1692 clear_proceed_status ();
1694 /* Finishing from an inline frame is completely different. We don't
1695 try to show the "return value" - no way to locate it. So we do
1696 not need a completion. */
1697 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1700 /* Claim we are stepping in the calling frame. An empty step
1701 range means that we will stop once we aren't in a function
1702 called by that frame. We don't use the magic "1" value for
1703 step_range_end, because then infrun will think this is nexti,
1704 and not step over the rest of this inlined function call. */
1705 struct thread_info
*tp
= inferior_thread ();
1706 struct symtab_and_line empty_sal
;
1708 init_sal (&empty_sal
);
1709 set_step_info (frame
, empty_sal
);
1710 tp
->control
.step_range_start
= get_frame_pc (frame
);
1711 tp
->control
.step_range_end
= tp
->control
.step_range_start
;
1712 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1714 /* Print info on the selected frame, including level number but not
1718 printf_filtered (_("Run till exit from "));
1719 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1722 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 1);
1726 /* Find the function we will return from. */
1728 function
= find_pc_function (get_frame_pc (get_selected_frame (NULL
)));
1730 /* Print info on the selected frame, including level number but not
1734 if (execution_direction
== EXEC_REVERSE
)
1735 printf_filtered (_("Run back to call of "));
1737 printf_filtered (_("Run till exit from "));
1739 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
);
1742 if (execution_direction
== EXEC_REVERSE
)
1743 finish_backward (function
);
1745 finish_forward (function
, frame
);
1750 program_info (char *args
, int from_tty
)
1754 struct thread_info
*tp
;
1757 if (!target_has_execution
)
1759 printf_filtered (_("The program being debugged is not being run.\n"));
1764 ptid
= inferior_ptid
;
1767 struct target_waitstatus ws
;
1769 get_last_target_status (&ptid
, &ws
);
1772 if (ptid_equal (ptid
, null_ptid
) || is_exited (ptid
))
1773 error (_("Invalid selected thread."));
1774 else if (is_running (ptid
))
1775 error (_("Selected thread is running."));
1777 tp
= find_thread_ptid (ptid
);
1778 bs
= tp
->control
.stop_bpstat
;
1779 stat
= bpstat_num (&bs
, &num
);
1781 target_files_info ();
1782 printf_filtered (_("Program stopped at %s.\n"),
1783 paddress (target_gdbarch
, stop_pc
));
1784 if (tp
->control
.stop_step
)
1785 printf_filtered (_("It stopped after being stepped.\n"));
1788 /* There may be several breakpoints in the same place, so this
1789 isn't as strange as it seems. */
1794 printf_filtered (_("It stopped at a breakpoint "
1795 "that has since been deleted.\n"));
1798 printf_filtered (_("It stopped at breakpoint %d.\n"), num
);
1799 stat
= bpstat_num (&bs
, &num
);
1802 else if (tp
->suspend
.stop_signal
!= TARGET_SIGNAL_0
)
1804 printf_filtered (_("It stopped with signal %s, %s.\n"),
1805 target_signal_to_name (tp
->suspend
.stop_signal
),
1806 target_signal_to_string (tp
->suspend
.stop_signal
));
1811 printf_filtered (_("Type \"info stack\" or \"info "
1812 "registers\" for more information.\n"));
1817 environment_info (char *var
, int from_tty
)
1821 char *val
= get_in_environ (current_inferior ()->environment
, var
);
1825 puts_filtered (var
);
1826 puts_filtered (" = ");
1827 puts_filtered (val
);
1828 puts_filtered ("\n");
1832 puts_filtered ("Environment variable \"");
1833 puts_filtered (var
);
1834 puts_filtered ("\" not defined.\n");
1839 char **vector
= environ_vector (current_inferior ()->environment
);
1843 puts_filtered (*vector
++);
1844 puts_filtered ("\n");
1850 set_environment_command (char *arg
, int from_tty
)
1852 char *p
, *val
, *var
;
1856 error_no_arg (_("environment variable and value"));
1858 /* Find seperation between variable name and value. */
1859 p
= (char *) strchr (arg
, '=');
1860 val
= (char *) strchr (arg
, ' ');
1862 if (p
!= 0 && val
!= 0)
1864 /* We have both a space and an equals. If the space is before the
1865 equals, walk forward over the spaces til we see a nonspace
1866 (possibly the equals). */
1871 /* Now if the = is after the char following the spaces,
1872 take the char following the spaces. */
1876 else if (val
!= 0 && p
== 0)
1880 error_no_arg (_("environment variable to set"));
1882 if (p
== 0 || p
[1] == 0)
1886 p
= arg
+ strlen (arg
); /* So that savestring below will work. */
1890 /* Not setting variable value to null. */
1892 while (*val
== ' ' || *val
== '\t')
1896 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
1899 var
= savestring (arg
, p
- arg
);
1902 printf_filtered (_("Setting environment variable "
1903 "\"%s\" to null value.\n"),
1905 set_in_environ (current_inferior ()->environment
, var
, "");
1908 set_in_environ (current_inferior ()->environment
, var
, val
);
1913 unset_environment_command (char *var
, int from_tty
)
1917 /* If there is no argument, delete all environment variables.
1918 Ask for confirmation if reading from the terminal. */
1919 if (!from_tty
|| query (_("Delete all environment variables? ")))
1921 free_environ (current_inferior ()->environment
);
1922 current_inferior ()->environment
= make_environ ();
1926 unset_in_environ (current_inferior ()->environment
, var
);
1929 /* Handle the execution path (PATH variable). */
1931 static const char path_var_name
[] = "PATH";
1934 path_info (char *args
, int from_tty
)
1936 puts_filtered ("Executable and object file path: ");
1937 puts_filtered (get_in_environ (current_inferior ()->environment
,
1939 puts_filtered ("\n");
1942 /* Add zero or more directories to the front of the execution path. */
1945 path_command (char *dirname
, int from_tty
)
1951 env
= get_in_environ (current_inferior ()->environment
, path_var_name
);
1952 /* Can be null if path is not set. */
1955 exec_path
= xstrdup (env
);
1956 mod_path (dirname
, &exec_path
);
1957 set_in_environ (current_inferior ()->environment
, path_var_name
, exec_path
);
1960 path_info ((char *) NULL
, from_tty
);
1964 /* Print out the machine register regnum. If regnum is -1, print all
1965 registers (print_all == 1) or all non-float and non-vector
1966 registers (print_all == 0).
1968 For most machines, having all_registers_info() print the
1969 register(s) one per line is good enough. If a different format is
1970 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1971 regs), or there is an existing convention for showing all the
1972 registers, define the architecture method PRINT_REGISTERS_INFO to
1973 provide that format. */
1976 default_print_registers_info (struct gdbarch
*gdbarch
,
1977 struct ui_file
*file
,
1978 struct frame_info
*frame
,
1979 int regnum
, int print_all
)
1982 const int numregs
= gdbarch_num_regs (gdbarch
)
1983 + gdbarch_num_pseudo_regs (gdbarch
);
1985 for (i
= 0; i
< numregs
; i
++)
1987 struct type
*regtype
;
1990 /* Decide between printing all regs, non-float / vector regs, or
1996 if (!gdbarch_register_reggroup_p (gdbarch
, i
, all_reggroup
))
2001 if (!gdbarch_register_reggroup_p (gdbarch
, i
, general_reggroup
))
2011 /* If the register name is empty, it is undefined for this
2012 processor, so don't display anything. */
2013 if (gdbarch_register_name (gdbarch
, i
) == NULL
2014 || *(gdbarch_register_name (gdbarch
, i
)) == '\0')
2017 fputs_filtered (gdbarch_register_name (gdbarch
, i
), file
);
2018 print_spaces_filtered (15 - strlen (gdbarch_register_name
2019 (gdbarch
, i
)), file
);
2021 regtype
= register_type (gdbarch
, i
);
2022 val
= allocate_value (regtype
);
2024 /* Get the data in raw format. */
2025 if (! frame_register_read (frame
, i
, value_contents_raw (val
)))
2027 fprintf_filtered (file
, "*value not available*\n");
2031 /* If virtual format is floating, print it that way, and in raw
2033 if (TYPE_CODE (regtype
) == TYPE_CODE_FLT
2034 || TYPE_CODE (regtype
) == TYPE_CODE_DECFLOAT
)
2037 struct value_print_options opts
;
2038 const gdb_byte
*valaddr
= value_contents_for_printing (val
);
2040 get_user_print_options (&opts
);
2044 value_contents_for_printing (val
),
2045 value_embedded_offset (val
), 0,
2046 file
, 0, val
, &opts
, current_language
);
2048 fprintf_filtered (file
, "\t(raw 0x");
2049 for (j
= 0; j
< register_size (gdbarch
, i
); j
++)
2053 if (gdbarch_byte_order (gdbarch
) == BFD_ENDIAN_BIG
)
2056 idx
= register_size (gdbarch
, i
) - 1 - j
;
2057 fprintf_filtered (file
, "%02x", (unsigned char) valaddr
[idx
]);
2059 fprintf_filtered (file
, ")");
2063 struct value_print_options opts
;
2065 /* Print the register in hex. */
2066 get_formatted_print_options (&opts
, 'x');
2069 value_contents_for_printing (val
),
2070 value_embedded_offset (val
), 0,
2071 file
, 0, val
, &opts
, current_language
);
2072 /* If not a vector register, print it also according to its
2074 if (TYPE_VECTOR (regtype
) == 0)
2076 get_user_print_options (&opts
);
2078 fprintf_filtered (file
, "\t");
2080 value_contents_for_printing (val
),
2081 value_embedded_offset (val
), 0,
2082 file
, 0, val
, &opts
, current_language
);
2086 fprintf_filtered (file
, "\n");
2091 registers_info (char *addr_exp
, int fpregs
)
2093 struct frame_info
*frame
;
2094 struct gdbarch
*gdbarch
;
2096 if (!target_has_registers
)
2097 error (_("The program has no registers now."));
2098 frame
= get_selected_frame (NULL
);
2099 gdbarch
= get_frame_arch (frame
);
2103 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2108 while (*addr_exp
!= '\0')
2113 /* Keep skipping leading white space. */
2114 if (isspace ((*addr_exp
)))
2120 /* Discard any leading ``$''. Check that there is something
2121 resembling a register following it. */
2122 if (addr_exp
[0] == '$')
2124 if (isspace ((*addr_exp
)) || (*addr_exp
) == '\0')
2125 error (_("Missing register name"));
2127 /* Find the start/end of this register name/num/group. */
2129 while ((*addr_exp
) != '\0' && !isspace ((*addr_exp
)))
2133 /* Figure out what we've found and display it. */
2135 /* A register name? */
2137 int regnum
= user_reg_map_name_to_regnum (gdbarch
, start
, end
- start
);
2141 /* User registers lie completely outside of the range of
2142 normal registers. Catch them early so that the target
2144 if (regnum
>= gdbarch_num_regs (gdbarch
)
2145 + gdbarch_num_pseudo_regs (gdbarch
))
2147 struct value_print_options opts
;
2148 struct value
*val
= value_of_user_reg (regnum
, frame
);
2150 printf_filtered ("%s: ", start
);
2151 get_formatted_print_options (&opts
, 'x');
2152 val_print_scalar_formatted (check_typedef (value_type (val
)),
2153 value_contents_for_printing (val
),
2154 value_embedded_offset (val
),
2156 &opts
, 0, gdb_stdout
);
2157 printf_filtered ("\n");
2160 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2161 frame
, regnum
, fpregs
);
2166 /* A register group? */
2168 struct reggroup
*group
;
2170 for (group
= reggroup_next (gdbarch
, NULL
);
2172 group
= reggroup_next (gdbarch
, group
))
2174 /* Don't bother with a length check. Should the user
2175 enter a short register group name, go with the first
2176 group that matches. */
2177 if (strncmp (start
, reggroup_name (group
), end
- start
) == 0)
2185 regnum
< gdbarch_num_regs (gdbarch
)
2186 + gdbarch_num_pseudo_regs (gdbarch
);
2189 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
2190 gdbarch_print_registers_info (gdbarch
,
2198 /* Nothing matched. */
2199 error (_("Invalid register `%.*s'"), (int) (end
- start
), start
);
2204 all_registers_info (char *addr_exp
, int from_tty
)
2206 registers_info (addr_exp
, 1);
2210 nofp_registers_info (char *addr_exp
, int from_tty
)
2212 registers_info (addr_exp
, 0);
2216 print_vector_info (struct ui_file
*file
,
2217 struct frame_info
*frame
, const char *args
)
2219 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2221 if (gdbarch_print_vector_info_p (gdbarch
))
2222 gdbarch_print_vector_info (gdbarch
, file
, frame
, args
);
2226 int printed_something
= 0;
2229 regnum
< gdbarch_num_regs (gdbarch
)
2230 + gdbarch_num_pseudo_regs (gdbarch
);
2233 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, vector_reggroup
))
2235 printed_something
= 1;
2236 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2239 if (!printed_something
)
2240 fprintf_filtered (file
, "No vector information\n");
2245 vector_info (char *args
, int from_tty
)
2247 if (!target_has_registers
)
2248 error (_("The program has no registers now."));
2250 print_vector_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2253 /* Kill the inferior process. Make us have no inferior. */
2256 kill_command (char *arg
, int from_tty
)
2258 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2259 It should be a distinct flag that indicates that a target is active, cuz
2260 some targets don't have processes! */
2262 if (ptid_equal (inferior_ptid
, null_ptid
))
2263 error (_("The program is not being run."));
2264 if (!query (_("Kill the program being debugged? ")))
2265 error (_("Not confirmed."));
2268 /* If we still have other inferiors to debug, then don't mess with
2269 with their threads. */
2270 if (!have_inferiors ())
2272 init_thread_list (); /* Destroy thread info. */
2274 /* Killing off the inferior can leave us with a core file. If
2275 so, print the state we are left in. */
2276 if (target_has_stack
)
2278 printf_filtered (_("In %s,\n"), target_longname
);
2279 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
);
2282 bfd_cache_close_all ();
2285 /* Used in `attach&' command. ARG is a point to an integer
2286 representing a process id. Proceed threads of this process iff
2287 they stopped due to debugger request, and when they did, they
2288 reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads
2289 that have been explicitly been told to stop. */
2292 proceed_after_attach_callback (struct thread_info
*thread
,
2295 int pid
= * (int *) arg
;
2297 if (ptid_get_pid (thread
->ptid
) == pid
2298 && !is_exited (thread
->ptid
)
2299 && !is_executing (thread
->ptid
)
2300 && !thread
->stop_requested
2301 && thread
->suspend
.stop_signal
== TARGET_SIGNAL_0
)
2303 switch_to_thread (thread
->ptid
);
2304 clear_proceed_status ();
2305 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2312 proceed_after_attach (int pid
)
2314 /* Don't error out if the current thread is running, because
2315 there may be other stopped threads. */
2316 struct cleanup
*old_chain
;
2318 /* Backup current thread and selected frame. */
2319 old_chain
= make_cleanup_restore_current_thread ();
2321 iterate_over_threads (proceed_after_attach_callback
, &pid
);
2323 /* Restore selected ptid. */
2324 do_cleanups (old_chain
);
2329 * Should save/restore the tty state since it might be that the
2330 * program to be debugged was started on this tty and it wants
2331 * the tty in some state other than what we want. If it's running
2332 * on another terminal or without a terminal, then saving and
2333 * restoring the tty state is a harmless no-op.
2334 * This only needs to be done if we are attaching to a process.
2337 /* attach_command --
2338 takes a program started up outside of gdb and ``attaches'' to it.
2339 This stops it cold in its tracks and allows us to start debugging it.
2340 and wait for the trace-trap that results from attaching. */
2343 attach_command_post_wait (char *args
, int from_tty
, int async_exec
)
2346 char *full_exec_path
= NULL
;
2347 struct inferior
*inferior
;
2349 inferior
= current_inferior ();
2350 inferior
->control
.stop_soon
= NO_STOP_QUIETLY
;
2352 /* If no exec file is yet known, try to determine it from the
2354 exec_file
= (char *) get_exec_file (0);
2357 exec_file
= target_pid_to_exec_file (PIDGET (inferior_ptid
));
2360 /* It's possible we don't have a full path, but rather just a
2361 filename. Some targets, such as HP-UX, don't provide the
2364 Attempt to qualify the filename against the source path.
2365 (If that fails, we'll just fall back on the original
2366 filename. Not much more we can do...) */
2368 if (!source_full_path_of (exec_file
, &full_exec_path
))
2369 full_exec_path
= xstrdup (exec_file
);
2371 exec_file_attach (full_exec_path
, from_tty
);
2372 symbol_file_add_main (full_exec_path
, from_tty
);
2377 reopen_exec_file ();
2381 /* Take any necessary post-attaching actions for this platform. */
2382 target_post_attach (PIDGET (inferior_ptid
));
2384 post_create_inferior (¤t_target
, from_tty
);
2386 /* Install inferior's terminal modes. */
2387 target_terminal_inferior ();
2391 /* The user requested an `attach&', so be sure to leave threads
2392 that didn't get a signal running. */
2394 /* Immediatelly resume all suspended threads of this inferior,
2395 and this inferior only. This should have no effect on
2396 already running threads. If a thread has been stopped with a
2397 signal, leave it be. */
2399 proceed_after_attach (inferior
->pid
);
2402 if (inferior_thread ()->suspend
.stop_signal
== TARGET_SIGNAL_0
)
2404 clear_proceed_status ();
2405 proceed ((CORE_ADDR
) -1, TARGET_SIGNAL_DEFAULT
, 0);
2411 /* The user requested a plain `attach', so be sure to leave
2412 the inferior stopped. */
2414 if (target_can_async_p ())
2415 async_enable_stdin ();
2417 /* At least the current thread is already stopped. */
2419 /* In all-stop, by definition, all threads have to be already
2420 stopped at this point. In non-stop, however, although the
2421 selected thread is stopped, others may still be executing.
2422 Be sure to explicitly stop all threads of the process. This
2423 should have no effect on already stopped threads. */
2425 target_stop (pid_to_ptid (inferior
->pid
));
2427 /* Tell the user/frontend where we're stopped. */
2429 if (deprecated_attach_hook
)
2430 deprecated_attach_hook ();
2434 struct attach_command_continuation_args
2442 attach_command_continuation (void *args
, int err
)
2444 struct attach_command_continuation_args
*a
= args
;
2449 attach_command_post_wait (a
->args
, a
->from_tty
, a
->async_exec
);
2453 attach_command_continuation_free_args (void *args
)
2455 struct attach_command_continuation_args
*a
= args
;
2462 attach_command (char *args
, int from_tty
)
2465 struct cleanup
*back_to
= make_cleanup (null_cleanup
, NULL
);
2467 dont_repeat (); /* Not for the faint of heart */
2469 if (gdbarch_has_global_solist (target_gdbarch
))
2470 /* Don't complain if all processes share the same symbol
2473 else if (target_has_execution
)
2475 if (query (_("A program is being debugged already. Kill it? ")))
2478 error (_("Not killed."));
2481 /* Clean up any leftovers from other runs. Some other things from
2482 this function should probably be moved into target_pre_inferior. */
2483 target_pre_inferior (from_tty
);
2485 if (non_stop
&& !target_supports_non_stop ())
2486 error (_("Cannot attach to this target in non-stop mode"));
2490 async_exec
= strip_bg_char (&args
);
2492 /* If we get a request for running in the bg but the target
2493 doesn't support it, error out. */
2494 if (async_exec
&& !target_can_async_p ())
2495 error (_("Asynchronous execution not supported on this target."));
2498 /* If we don't get a request of running in the bg, then we need
2499 to simulate synchronous (fg) execution. */
2500 if (!async_exec
&& target_can_async_p ())
2502 /* Simulate synchronous execution. */
2503 async_disable_stdin ();
2504 make_cleanup ((make_cleanup_ftype
*)async_enable_stdin
, NULL
);
2507 target_attach (args
, from_tty
);
2509 /* Set up the "saved terminal modes" of the inferior
2510 based on what modes we are starting it with. */
2511 target_terminal_init ();
2513 /* Set up execution context to know that we should return from
2514 wait_for_inferior as soon as the target reports a stop. */
2515 init_wait_for_inferior ();
2516 clear_proceed_status ();
2520 /* If we find that the current thread isn't stopped, explicitly
2521 do so now, because we're going to install breakpoints and
2525 /* The user requested an `attach&'; stop just one thread. */
2526 target_stop (inferior_ptid
);
2528 /* The user requested an `attach', so stop all threads of this
2530 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid
)));
2533 /* Some system don't generate traps when attaching to inferior.
2534 E.g. Mach 3 or GNU hurd. */
2535 if (!target_attach_no_wait
)
2537 struct inferior
*inferior
= current_inferior ();
2539 /* Careful here. See comments in inferior.h. Basically some
2540 OSes don't ignore SIGSTOPs on continue requests anymore. We
2541 need a way for handle_inferior_event to reset the stop_signal
2542 variable after an attach, and this is what
2543 STOP_QUIETLY_NO_SIGSTOP is for. */
2544 inferior
->control
.stop_soon
= STOP_QUIETLY_NO_SIGSTOP
;
2546 if (target_can_async_p ())
2548 /* sync_execution mode. Wait for stop. */
2549 struct attach_command_continuation_args
*a
;
2551 a
= xmalloc (sizeof (*a
));
2552 a
->args
= xstrdup (args
);
2553 a
->from_tty
= from_tty
;
2554 a
->async_exec
= async_exec
;
2555 add_inferior_continuation (attach_command_continuation
, a
,
2556 attach_command_continuation_free_args
);
2557 discard_cleanups (back_to
);
2561 wait_for_inferior ();
2564 attach_command_post_wait (args
, from_tty
, async_exec
);
2565 discard_cleanups (back_to
);
2568 /* We had just found out that the target was already attached to an
2569 inferior. PTID points at a thread of this new inferior, that is
2570 the most likely to be stopped right now, but not necessarily so.
2571 The new inferior is assumed to be already added to the inferior
2572 list at this point. If LEAVE_RUNNING, then leave the threads of
2573 this inferior running, except those we've explicitly seen reported
2577 notice_new_inferior (ptid_t ptid
, int leave_running
, int from_tty
)
2579 struct cleanup
* old_chain
;
2582 old_chain
= make_cleanup (null_cleanup
, NULL
);
2584 /* If in non-stop, leave threads as running as they were. If
2585 they're stopped for some reason other than us telling it to, the
2586 target reports a signal != TARGET_SIGNAL_0. We don't try to
2587 resume threads with such a stop signal. */
2588 async_exec
= non_stop
;
2590 if (!ptid_equal (inferior_ptid
, null_ptid
))
2591 make_cleanup_restore_current_thread ();
2593 switch_to_thread (ptid
);
2595 /* When we "notice" a new inferior we need to do all the things we
2596 would normally do if we had just attached to it. */
2598 if (is_executing (inferior_ptid
))
2600 struct inferior
*inferior
= current_inferior ();
2602 /* We're going to install breakpoints, and poke at memory,
2603 ensure that the inferior is stopped for a moment while we do
2605 target_stop (inferior_ptid
);
2607 inferior
->control
.stop_soon
= STOP_QUIETLY_REMOTE
;
2609 /* Wait for stop before proceeding. */
2610 if (target_can_async_p ())
2612 struct attach_command_continuation_args
*a
;
2614 a
= xmalloc (sizeof (*a
));
2615 a
->args
= xstrdup ("");
2616 a
->from_tty
= from_tty
;
2617 a
->async_exec
= async_exec
;
2618 add_inferior_continuation (attach_command_continuation
, a
,
2619 attach_command_continuation_free_args
);
2621 do_cleanups (old_chain
);
2625 wait_for_inferior ();
2628 async_exec
= leave_running
;
2629 attach_command_post_wait ("" /* args */, from_tty
, async_exec
);
2631 do_cleanups (old_chain
);
2636 * takes a program previously attached to and detaches it.
2637 * The program resumes execution and will no longer stop
2638 * on signals, etc. We better not have left any breakpoints
2639 * in the program or it'll die when it hits one. For this
2640 * to work, it may be necessary for the process to have been
2641 * previously attached. It *might* work if the program was
2642 * started via the normal ptrace (PTRACE_TRACEME).
2646 detach_command (char *args
, int from_tty
)
2648 dont_repeat (); /* Not for the faint of heart. */
2650 if (ptid_equal (inferior_ptid
, null_ptid
))
2651 error (_("The program is not being run."));
2653 disconnect_tracing (from_tty
);
2655 target_detach (args
, from_tty
);
2657 /* If the solist is global across inferiors, don't clear it when we
2658 detach from a single inferior. */
2659 if (!gdbarch_has_global_solist (target_gdbarch
))
2660 no_shared_libraries (NULL
, from_tty
);
2662 /* If we still have inferiors to debug, then don't mess with their
2664 if (!have_inferiors ())
2665 init_thread_list ();
2667 if (deprecated_detach_hook
)
2668 deprecated_detach_hook ();
2671 /* Disconnect from the current target without resuming it (leaving it
2672 waiting for a debugger).
2674 We'd better not have left any breakpoints in the program or the
2675 next debugger will get confused. Currently only supported for some
2676 remote targets, since the normal attach mechanisms don't work on
2677 stopped processes on some native platforms (e.g. GNU/Linux). */
2680 disconnect_command (char *args
, int from_tty
)
2682 dont_repeat (); /* Not for the faint of heart. */
2683 disconnect_tracing (from_tty
);
2684 target_disconnect (args
, from_tty
);
2685 no_shared_libraries (NULL
, from_tty
);
2686 init_thread_list ();
2687 if (deprecated_detach_hook
)
2688 deprecated_detach_hook ();
2692 interrupt_target_1 (int all_threads
)
2697 ptid
= minus_one_ptid
;
2699 ptid
= inferior_ptid
;
2702 /* Tag the thread as having been explicitly requested to stop, so
2703 other parts of gdb know not to resume this thread automatically,
2704 if it was stopped due to an internal event. Limit this to
2705 non-stop mode, as when debugging a multi-threaded application in
2706 all-stop mode, we will only get one stop event --- it's undefined
2707 which thread will report the event. */
2709 set_stop_requested (ptid
, 1);
2712 /* Stop the execution of the target while running in async mode, in
2713 the backgound. In all-stop, stop the whole process. In non-stop
2714 mode, stop the current thread only by default, or stop all threads
2715 if the `-a' switch is used. */
2717 /* interrupt [-a] */
2719 interrupt_target_command (char *args
, int from_tty
)
2721 if (target_can_async_p ())
2723 int all_threads
= 0;
2725 dont_repeat (); /* Not for the faint of heart. */
2728 && strncmp (args
, "-a", sizeof ("-a") - 1) == 0)
2731 if (!non_stop
&& all_threads
)
2732 error (_("-a is meaningless in all-stop mode."));
2734 interrupt_target_1 (all_threads
);
2739 print_float_info (struct ui_file
*file
,
2740 struct frame_info
*frame
, const char *args
)
2742 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2744 if (gdbarch_print_float_info_p (gdbarch
))
2745 gdbarch_print_float_info (gdbarch
, file
, frame
, args
);
2749 int printed_something
= 0;
2752 regnum
< gdbarch_num_regs (gdbarch
)
2753 + gdbarch_num_pseudo_regs (gdbarch
);
2756 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, float_reggroup
))
2758 printed_something
= 1;
2759 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2762 if (!printed_something
)
2763 fprintf_filtered (file
, "No floating-point info "
2764 "available for this processor.\n");
2769 float_info (char *args
, int from_tty
)
2771 if (!target_has_registers
)
2772 error (_("The program has no registers now."));
2774 print_float_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2778 unset_command (char *args
, int from_tty
)
2780 printf_filtered (_("\"unset\" must be followed by the "
2781 "name of an unset subcommand.\n"));
2782 help_list (unsetlist
, "unset ", -1, gdb_stdout
);
2786 _initialize_infcmd (void)
2788 struct cmd_list_element
*c
= NULL
;
2790 /* Add the filename of the terminal connected to inferior I/O. */
2791 add_setshow_filename_cmd ("inferior-tty", class_run
,
2792 &inferior_io_terminal_scratch
, _("\
2793 Set terminal for future runs of program being debugged."), _("\
2794 Show terminal for future runs of program being debugged."), _("\
2795 Usage: set inferior-tty /dev/pts/1"),
2796 set_inferior_tty_command
,
2797 show_inferior_tty_command
,
2798 &setlist
, &showlist
);
2799 add_com_alias ("tty", "set inferior-tty", class_alias
, 0);
2801 add_setshow_optional_filename_cmd ("args", class_run
,
2802 &inferior_args_scratch
, _("\
2803 Set argument list to give program being debugged when it is started."), _("\
2804 Show argument list to give program being debugged when it is started."), _("\
2805 Follow this command with any number of args, to be passed to the program."),
2808 &setlist
, &showlist
);
2810 c
= add_cmd ("environment", no_class
, environment_info
, _("\
2811 The environment to give the program, or one variable's value.\n\
2812 With an argument VAR, prints the value of environment variable VAR to\n\
2813 give the program being debugged. With no arguments, prints the entire\n\
2814 environment to be given to the program."), &showlist
);
2815 set_cmd_completer (c
, noop_completer
);
2817 add_prefix_cmd ("unset", no_class
, unset_command
,
2818 _("Complement to certain \"set\" commands."),
2819 &unsetlist
, "unset ", 0, &cmdlist
);
2821 c
= add_cmd ("environment", class_run
, unset_environment_command
, _("\
2822 Cancel environment variable VAR for the program.\n\
2823 This does not affect the program until the next \"run\" command."),
2825 set_cmd_completer (c
, noop_completer
);
2827 c
= add_cmd ("environment", class_run
, set_environment_command
, _("\
2828 Set environment variable value to give the program.\n\
2829 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2830 VALUES of environment variables are uninterpreted strings.\n\
2831 This does not affect the program until the next \"run\" command."),
2833 set_cmd_completer (c
, noop_completer
);
2835 c
= add_com ("path", class_files
, path_command
, _("\
2836 Add directory DIR(s) to beginning of search path for object files.\n\
2837 $cwd in the path means the current working directory.\n\
2838 This path is equivalent to the $PATH shell variable. It is a list of\n\
2839 directories, separated by colons. These directories are searched to find\n\
2840 fully linked executable files and separately compiled object files as \
2842 set_cmd_completer (c
, filename_completer
);
2844 c
= add_cmd ("paths", no_class
, path_info
, _("\
2845 Current search path for finding object files.\n\
2846 $cwd in the path means the current working directory.\n\
2847 This path is equivalent to the $PATH shell variable. It is a list of\n\
2848 directories, separated by colons. These directories are searched to find\n\
2849 fully linked executable files and separately compiled object files as \
2852 set_cmd_completer (c
, noop_completer
);
2854 add_prefix_cmd ("kill", class_run
, kill_command
,
2855 _("Kill execution of program being debugged."),
2856 &killlist
, "kill ", 0, &cmdlist
);
2858 add_com ("attach", class_run
, attach_command
, _("\
2859 Attach to a process or file outside of GDB.\n\
2860 This command attaches to another target, of the same type as your last\n\
2861 \"target\" command (\"info files\" will show your target stack).\n\
2862 The command may take as argument a process id or a device file.\n\
2863 For a process id, you must have permission to send the process a signal,\n\
2864 and it must have the same effective uid as the debugger.\n\
2865 When using \"attach\" with a process id, the debugger finds the\n\
2866 program running in the process, looking first in the current working\n\
2867 directory, or (if not found there) using the source file search path\n\
2868 (see the \"directory\" command). You can also use the \"file\" command\n\
2869 to specify the program, and to load its symbol table."));
2871 add_prefix_cmd ("detach", class_run
, detach_command
, _("\
2872 Detach a process or file previously attached.\n\
2873 If a process, it is no longer traced, and it continues its execution. If\n\
2874 you were debugging a file, the file is closed and gdb no longer accesses it."),
2875 &detachlist
, "detach ", 0, &cmdlist
);
2877 add_com ("disconnect", class_run
, disconnect_command
, _("\
2878 Disconnect from a target.\n\
2879 The target will wait for another debugger to connect. Not available for\n\
2882 add_com ("signal", class_run
, signal_command
, _("\
2883 Continue program giving it signal specified by the argument.\n\
2884 An argument of \"0\" means continue program without giving it a signal."));
2886 add_com ("stepi", class_run
, stepi_command
, _("\
2887 Step one instruction exactly.\n\
2888 Argument N means do this N times (or till program stops for another \
2890 add_com_alias ("si", "stepi", class_alias
, 0);
2892 add_com ("nexti", class_run
, nexti_command
, _("\
2893 Step one instruction, but proceed through subroutine calls.\n\
2894 Argument N means do this N times (or till program stops for another \
2896 add_com_alias ("ni", "nexti", class_alias
, 0);
2898 add_com ("finish", class_run
, finish_command
, _("\
2899 Execute until selected stack frame returns.\n\
2900 Upon return, the value returned is printed and put in the value history."));
2901 add_com_alias ("fin", "finish", class_run
, 1);
2903 add_com ("next", class_run
, next_command
, _("\
2904 Step program, proceeding through subroutine calls.\n\
2905 Like the \"step\" command as long as subroutine calls do not happen;\n\
2906 when they do, the call is treated as one instruction.\n\
2907 Argument N means do this N times (or till program stops for another \
2909 add_com_alias ("n", "next", class_run
, 1);
2911 add_com_alias ("S", "next", class_run
, 1);
2913 add_com ("step", class_run
, step_command
, _("\
2914 Step program until it reaches a different source line.\n\
2915 Argument N means do this N times (or till program stops for another \
2917 add_com_alias ("s", "step", class_run
, 1);
2919 c
= add_com ("until", class_run
, until_command
, _("\
2920 Execute until the program reaches a source line greater than the current\n\
2921 or a specified location (same args as break command) within the current \
2923 set_cmd_completer (c
, location_completer
);
2924 add_com_alias ("u", "until", class_run
, 1);
2926 c
= add_com ("advance", class_run
, advance_command
, _("\
2927 Continue the program up to the given location (same form as args for break \
2929 Execution will also stop upon exit from the current stack frame."));
2930 set_cmd_completer (c
, location_completer
);
2932 c
= add_com ("jump", class_run
, jump_command
, _("\
2933 Continue program being debugged at specified line or address.\n\
2934 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2935 for an address to start at."));
2936 set_cmd_completer (c
, location_completer
);
2940 c
= add_com ("go", class_run
, go_command
, _("\
2941 Usage: go <location>\n\
2942 Continue program being debugged, stopping at specified line or \n\
2944 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2945 expression for an address to start at.\n\
2946 This command is a combination of tbreak and jump."));
2947 set_cmd_completer (c
, location_completer
);
2951 add_com_alias ("g", "go", class_run
, 1);
2953 add_com ("continue", class_run
, continue_command
, _("\
2954 Continue program being debugged, after signal or breakpoint.\n\
2955 If proceeding from breakpoint, a number N may be used as an argument,\n\
2956 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2957 the breakpoint won't break until the Nth time it is reached).\n\
2959 If non-stop mode is enabled, continue only the current thread,\n\
2960 otherwise all the threads in the program are continued. To \n\
2961 continue all stopped threads in non-stop mode, use the -a option.\n\
2962 Specifying -a and an ignore count simultaneously is an error."));
2963 add_com_alias ("c", "cont", class_run
, 1);
2964 add_com_alias ("fg", "cont", class_run
, 1);
2966 c
= add_com ("run", class_run
, run_command
, _("\
2967 Start debugged program. You may specify arguments to give it.\n\
2968 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2969 Input and output redirection with \">\", \"<\", or \">>\" are also \
2971 With no arguments, uses arguments last specified (with \"run\" \
2972 or \"set args\").\n\
2973 To cancel previous arguments and run with no arguments,\n\
2974 use \"set args\" without arguments."));
2975 set_cmd_completer (c
, filename_completer
);
2976 add_com_alias ("r", "run", class_run
, 1);
2978 add_com ("R", class_run
, run_no_args_command
,
2979 _("Start debugged program with no arguments."));
2981 c
= add_com ("start", class_run
, start_command
, _("\
2982 Run the debugged program until the beginning of the main procedure.\n\
2983 You may specify arguments to give to your program, just as with the\n\
2984 \"run\" command."));
2985 set_cmd_completer (c
, filename_completer
);
2987 add_com ("interrupt", class_run
, interrupt_target_command
,
2988 _("Interrupt the execution of the debugged program.\n\
2989 If non-stop mode is enabled, interrupt only the current thread,\n\
2990 otherwise all the threads in the program are stopped. To \n\
2991 interrupt all running threads in non-stop mode, use the -a option."));
2993 add_info ("registers", nofp_registers_info
, _("\
2994 List of integer registers and their contents, for selected stack frame.\n\
2995 Register name as argument means describe only that register."));
2996 add_info_alias ("r", "registers", 1);
2999 add_com ("lr", class_info
, nofp_registers_info
, _("\
3000 List of integer registers and their contents, for selected stack frame.\n\
3001 Register name as argument means describe only that register."));
3002 add_info ("all-registers", all_registers_info
, _("\
3003 List of all registers and their contents, for selected stack frame.\n\
3004 Register name as argument means describe only that register."));
3006 add_info ("program", program_info
,
3007 _("Execution status of the program."));
3009 add_info ("float", float_info
,
3010 _("Print the status of the floating point unit\n"));
3012 add_info ("vector", vector_info
,
3013 _("Print the status of the vector unit\n"));