1 /* Memory-access and commands for "inferior" process, for GDB.
3 Copyright (C) 1986-2016 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 #include "arch-utils.h"
36 #include "completer.h"
38 #include "event-top.h"
39 #include "parser-defs.h"
41 #include "reggroups.h"
46 #include "target-descriptions.h"
47 #include "user-regs.h"
48 #include "cli/cli-decode.h"
49 #include "gdbthread.h"
51 #include "inline-frame.h"
52 #include "tracepoint.h"
54 #include "continuations.h"
56 #include "cli/cli-utils.h"
58 #include "thread-fsm.h"
62 /* Local functions: */
64 static void nofp_registers_info (char *, int);
66 static void until_next_command (int);
68 static void until_command (char *, int);
70 static void path_info (char *, int);
72 static void path_command (char *, int);
74 static void unset_command (char *, int);
76 static void float_info (char *, int);
78 static void disconnect_command (char *, int);
80 static void unset_environment_command (char *, int);
82 static void set_environment_command (char *, int);
84 static void environment_info (char *, int);
86 static void program_info (char *, int);
88 static void finish_command (char *, int);
90 static void signal_command (char *, int);
92 static void jump_command (char *, int);
94 static void step_1 (int, int, char *);
96 static void next_command (char *, int);
98 static void step_command (char *, int);
100 static void run_command (char *, int);
102 void _initialize_infcmd (void);
104 #define ERROR_NO_INFERIOR \
105 if (!target_has_execution) error (_("The program is not being run."));
107 /* Scratch area where string containing arguments to give to the
108 program will be stored by 'set args'. As soon as anything is
109 stored, notice_args_set will move it into per-inferior storage.
110 Arguments are separated by spaces. Empty string (pointer to '\0')
113 static char *inferior_args_scratch
;
115 /* Scratch area where 'set inferior-tty' will store user-provided value.
116 We'll immediate copy it into per-inferior storage. */
118 static char *inferior_io_terminal_scratch
;
120 /* Pid of our debugged inferior, or 0 if no inferior now.
121 Since various parts of infrun.c test this to see whether there is a program
122 being debugged it should be nonzero (currently 3 is used) for remote
125 ptid_t inferior_ptid
;
127 /* Address at which inferior stopped. */
131 /* Nonzero if stopped due to completion of a stack dummy routine. */
133 enum stop_stack_kind stop_stack_dummy
;
135 /* Nonzero if stopped due to a random (unexpected) signal in inferior
138 int stopped_by_random_signal
;
140 /* See inferior.h. */
142 int startup_with_shell
= 1;
145 /* Accessor routines. */
147 /* Set the io terminal for the current inferior. Ownership of
148 TERMINAL_NAME is not transferred. */
151 set_inferior_io_terminal (const char *terminal_name
)
153 xfree (current_inferior ()->terminal
);
154 current_inferior ()->terminal
= terminal_name
? xstrdup (terminal_name
) : 0;
158 get_inferior_io_terminal (void)
160 return current_inferior ()->terminal
;
164 set_inferior_tty_command (char *args
, int from_tty
,
165 struct cmd_list_element
*c
)
167 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
168 Now route it to current inferior. */
169 set_inferior_io_terminal (inferior_io_terminal_scratch
);
173 show_inferior_tty_command (struct ui_file
*file
, int from_tty
,
174 struct cmd_list_element
*c
, const char *value
)
176 /* Note that we ignore the passed-in value in favor of computing it
178 const char *inferior_io_terminal
= get_inferior_io_terminal ();
180 if (inferior_io_terminal
== NULL
)
181 inferior_io_terminal
= "";
182 fprintf_filtered (gdb_stdout
,
183 _("Terminal for future runs of program being debugged "
184 "is \"%s\".\n"), inferior_io_terminal
);
188 get_inferior_args (void)
190 if (current_inferior ()->argc
!= 0)
194 n
= construct_inferior_arguments (current_inferior ()->argc
,
195 current_inferior ()->argv
);
196 set_inferior_args (n
);
200 if (current_inferior ()->args
== NULL
)
201 current_inferior ()->args
= xstrdup ("");
203 return current_inferior ()->args
;
206 /* Set the arguments for the current inferior. Ownership of
207 NEWARGS is not transferred. */
210 set_inferior_args (char *newargs
)
212 xfree (current_inferior ()->args
);
213 current_inferior ()->args
= newargs
? xstrdup (newargs
) : NULL
;
214 current_inferior ()->argc
= 0;
215 current_inferior ()->argv
= 0;
219 set_inferior_args_vector (int argc
, char **argv
)
221 current_inferior ()->argc
= argc
;
222 current_inferior ()->argv
= argv
;
225 /* Notice when `set args' is run. */
228 set_args_command (char *args
, int from_tty
, struct cmd_list_element
*c
)
230 /* CLI has assigned the user-provided value to inferior_args_scratch.
231 Now route it to current inferior. */
232 set_inferior_args (inferior_args_scratch
);
235 /* Notice when `show args' is run. */
238 show_args_command (struct ui_file
*file
, int from_tty
,
239 struct cmd_list_element
*c
, const char *value
)
241 /* Note that we ignore the passed-in value in favor of computing it
243 deprecated_show_value_hack (file
, from_tty
, c
, get_inferior_args ());
247 /* Compute command-line string given argument vector. This does the
248 same shell processing as fork_inferior. */
251 construct_inferior_arguments (int argc
, char **argv
)
255 if (startup_with_shell
)
258 /* This holds all the characters considered special to the
260 char *special
= "\"!&*|[]{}<>?`~^=;, \t\n";
261 const char quote
= '"';
263 /* This holds all the characters considered special to the
264 typical Unix shells. We include `^' because the SunOS
265 /bin/sh treats it as a synonym for `|'. */
266 char *special
= "\"!#$&*()\\|[]{}<>?'`~^; \t\n";
267 const char quote
= '\'';
273 /* We over-compute the size. It shouldn't matter. */
274 for (i
= 0; i
< argc
; ++i
)
275 length
+= 3 * strlen (argv
[i
]) + 1 + 2 * (argv
[i
][0] == '\0');
277 result
= (char *) xmalloc (length
);
280 for (i
= 0; i
< argc
; ++i
)
285 /* Need to handle empty arguments specially. */
286 if (argv
[i
][0] == '\0')
296 if (strpbrk (argv
[i
], special
))
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
318 if (strchr (special
, *cp
) != NULL
)
334 /* In this case we can't handle arguments that contain spaces,
335 tabs, or newlines -- see breakup_args(). */
339 for (i
= 0; i
< argc
; ++i
)
341 char *cp
= strchr (argv
[i
], ' ');
343 cp
= strchr (argv
[i
], '\t');
345 cp
= strchr (argv
[i
], '\n');
347 error (_("can't handle command-line "
348 "argument containing whitespace"));
349 length
+= strlen (argv
[i
]) + 1;
352 result
= (char *) xmalloc (length
);
354 for (i
= 0; i
< argc
; ++i
)
357 strcat (result
, " ");
358 strcat (result
, argv
[i
]);
366 /* This function strips the '&' character (indicating background
367 execution) that is added as *the last* of the arguments ARGS of a
368 command. A copy of the incoming ARGS without the '&' is returned,
369 unless the resulting string after stripping is empty, in which case
370 NULL is returned. *BG_CHAR_P is an output boolean that indicates
371 whether the '&' character was found. */
374 strip_bg_char (const char *args
, int *bg_char_p
)
378 if (args
== NULL
|| *args
== '\0')
384 p
= args
+ strlen (args
);
388 while (p
> args
&& isspace (p
[-1]))
393 return savestring (args
, p
- args
);
399 return xstrdup (args
);
402 /* Common actions to take after creating any sort of inferior, by any
403 means (running, attaching, connecting, et cetera). The target
404 should be stopped. */
407 post_create_inferior (struct target_ops
*target
, int from_tty
)
410 /* Be sure we own the terminal in case write operations are performed. */
411 target_terminal_ours_for_output ();
413 /* If the target hasn't taken care of this already, do it now.
414 Targets which need to access registers during to_open,
415 to_create_inferior, or to_attach should do it earlier; but many
417 target_find_description ();
419 /* Now that we know the register layout, retrieve current PC. But
420 if the PC is unavailable (e.g., we're opening a core file with
421 missing registers info), ignore it. */
425 stop_pc
= regcache_read_pc (get_current_regcache ());
427 CATCH (ex
, RETURN_MASK_ERROR
)
429 if (ex
.error
!= NOT_AVAILABLE_ERROR
)
430 throw_exception (ex
);
436 const unsigned solib_add_generation
437 = current_program_space
->solib_add_generation
;
439 /* Create the hooks to handle shared library load and unload
441 solib_create_inferior_hook (from_tty
);
443 if (current_program_space
->solib_add_generation
== solib_add_generation
)
445 /* The platform-specific hook should load initial shared libraries,
446 but didn't. FROM_TTY will be incorrectly 0 but such solib
447 targets should be fixed anyway. Call it only after the solib
448 target has been initialized by solib_create_inferior_hook. */
451 warning (_("platform-specific solib_create_inferior_hook did "
452 "not load initial shared libraries."));
454 /* If the solist is global across processes, there's no need to
456 if (!gdbarch_has_global_solist (target_gdbarch ()))
457 solib_add (NULL
, 0, target
, auto_solib_add
);
461 /* If the user sets watchpoints before execution having started,
462 then she gets software watchpoints, because GDB can't know which
463 target will end up being pushed, or if it supports hardware
464 watchpoints or not. breakpoint_re_set takes care of promoting
465 watchpoints to hardware watchpoints if possible, however, if this
466 new inferior doesn't load shared libraries or we don't pull in
467 symbols from any other source on this target/arch,
468 breakpoint_re_set is never called. Call it now so that software
469 watchpoints get a chance to be promoted to hardware watchpoints
470 if the now pushed target supports hardware watchpoints. */
471 breakpoint_re_set ();
473 observer_notify_inferior_created (target
, from_tty
);
476 /* Kill the inferior if already running. This function is designed
477 to be called when we are about to start the execution of the program
478 from the beginning. Ask the user to confirm that he wants to restart
479 the program being debugged when FROM_TTY is non-null. */
482 kill_if_already_running (int from_tty
)
484 if (! ptid_equal (inferior_ptid
, null_ptid
) && target_has_execution
)
486 /* Bail out before killing the program if we will not be able to
488 target_require_runnable ();
491 && !query (_("The program being debugged has been started already.\n\
492 Start it from the beginning? ")))
493 error (_("Program not restarted."));
498 /* See inferior.h. */
501 prepare_execution_command (struct target_ops
*target
, int background
)
503 /* If we get a request for running in the bg but the target
504 doesn't support it, error out. */
505 if (background
&& !target
->to_can_async_p (target
))
506 error (_("Asynchronous execution not supported on this target."));
510 /* If we get a request for running in the fg, then we need to
511 simulate synchronous (fg) execution. Note no cleanup is
512 necessary for this. stdin is re-enabled whenever an error
513 reaches the top level. */
514 all_uis_on_sync_execution_starting ();
518 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
519 a temporary breakpoint at the begining of the main program before
520 running the program. */
523 run_command_1 (char *args
, int from_tty
, int tbreak_at_main
)
526 struct cleanup
*old_chain
;
528 struct ui_out
*uiout
= current_uiout
;
529 struct target_ops
*run_target
;
531 struct cleanup
*args_chain
;
535 kill_if_already_running (from_tty
);
537 init_wait_for_inferior ();
538 clear_breakpoint_hit_counts ();
540 /* Clean up any leftovers from other runs. Some other things from
541 this function should probably be moved into target_pre_inferior. */
542 target_pre_inferior (from_tty
);
544 /* The comment here used to read, "The exec file is re-read every
545 time we do a generic_mourn_inferior, so we just have to worry
546 about the symbol file." The `generic_mourn_inferior' function
547 gets called whenever the program exits. However, suppose the
548 program exits, and *then* the executable file changes? We need
549 to check again here. Since reopen_exec_file doesn't do anything
550 if the timestamp hasn't changed, I don't see the harm. */
554 args
= strip_bg_char (args
, &async_exec
);
555 args_chain
= make_cleanup (xfree
, args
);
557 /* Do validation and preparation before possibly changing anything
560 run_target
= find_run_target ();
562 prepare_execution_command (run_target
, async_exec
);
564 if (non_stop
&& !run_target
->to_supports_non_stop (run_target
))
565 error (_("The target does not support running in non-stop mode."));
567 /* Done. Can now set breakpoints, change inferior args, etc. */
569 /* Insert the temporary breakpoint if a location was specified. */
571 tbreak_command (main_name (), 0);
573 exec_file
= (char *) get_exec_file (0);
575 /* We keep symbols from add-symbol-file, on the grounds that the
576 user might want to add some symbols before running the program
577 (right?). But sometimes (dynamic loading where the user manually
578 introduces the new symbols with add-symbol-file), the code which
579 the symbols describe does not persist between runs. Currently
580 the user has to manually nuke all symbols between runs if they
581 want them to go away (PR 2207). This is probably reasonable. */
583 /* If there were other args, beside '&', process them. */
585 set_inferior_args (args
);
589 ui_out_field_string (uiout
, NULL
, "Starting program");
590 ui_out_text (uiout
, ": ");
592 ui_out_field_string (uiout
, "execfile", exec_file
);
593 ui_out_spaces (uiout
, 1);
594 /* We call get_inferior_args() because we might need to compute
596 ui_out_field_string (uiout
, "infargs", get_inferior_args ());
597 ui_out_text (uiout
, "\n");
598 ui_out_flush (uiout
);
601 /* Done with ARGS. */
602 do_cleanups (args_chain
);
604 /* We call get_inferior_args() because we might need to compute
606 run_target
->to_create_inferior (run_target
, exec_file
, get_inferior_args (),
607 environ_vector (current_inferior ()->environment
),
609 /* to_create_inferior should push the target, so after this point we
610 shouldn't refer to run_target again. */
613 /* We're starting off a new process. When we get out of here, in
614 non-stop mode, finish the state of all threads of that process,
615 but leave other threads alone, as they may be stopped in internal
616 events --- the frontend shouldn't see them as stopped. In
617 all-stop, always finish the state of all threads, as we may be
618 resuming more than just the new process. */
620 ptid
= pid_to_ptid (ptid_get_pid (inferior_ptid
));
622 ptid
= minus_one_ptid
;
623 old_chain
= make_cleanup (finish_thread_state_cleanup
, &ptid
);
625 /* Pass zero for FROM_TTY, because at this point the "run" command
626 has done its thing; now we are setting up the running program. */
627 post_create_inferior (¤t_target
, 0);
629 /* Start the target running. Do not use -1 continuation as it would skip
630 breakpoint right at the entry point. */
631 proceed (regcache_read_pc (get_current_regcache ()), GDB_SIGNAL_0
);
633 /* Since there was no error, there's no need to finish the thread
635 discard_cleanups (old_chain
);
639 run_command (char *args
, int from_tty
)
641 run_command_1 (args
, from_tty
, 0);
644 /* Start the execution of the program up until the beginning of the main
648 start_command (char *args
, int from_tty
)
650 /* Some languages such as Ada need to search inside the program
651 minimal symbols for the location where to put the temporary
652 breakpoint before starting. */
653 if (!have_minimal_symbols ())
654 error (_("No symbol table loaded. Use the \"file\" command."));
656 /* Run the program until reaching the main procedure... */
657 run_command_1 (args
, from_tty
, 1);
661 proceed_thread_callback (struct thread_info
*thread
, void *arg
)
663 /* We go through all threads individually instead of compressing
664 into a single target `resume_all' request, because some threads
665 may be stopped in internal breakpoints/events, or stopped waiting
666 for its turn in the displaced stepping queue (that is, they are
667 running && !executing). The target side has no idea about why
668 the thread is stopped, so a `resume_all' command would resume too
669 much. If/when GDB gains a way to tell the target `hold this
670 thread stopped until I say otherwise', then we can optimize
672 if (!is_stopped (thread
->ptid
))
675 switch_to_thread (thread
->ptid
);
676 clear_proceed_status (0);
677 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
682 ensure_valid_thread (void)
684 if (ptid_equal (inferior_ptid
, null_ptid
)
685 || is_exited (inferior_ptid
))
686 error (_("Cannot execute this command without a live selected thread."));
689 /* If the user is looking at trace frames, any resumption of execution
690 is likely to mix up recorded and live target data. So simply
691 disallow those commands. */
694 ensure_not_tfind_mode (void)
696 if (get_traceframe_number () >= 0)
697 error (_("Cannot execute this command while looking at trace frames."));
700 /* Throw an error indicating the current thread is running. */
703 error_is_running (void)
705 error (_("Cannot execute this command while "
706 "the selected thread is running."));
709 /* Calls error_is_running if the current thread is running. */
712 ensure_not_running (void)
714 if (is_running (inferior_ptid
))
719 continue_1 (int all_threads
)
722 ensure_not_tfind_mode ();
724 if (non_stop
&& all_threads
)
726 /* Don't error out if the current thread is running, because
727 there may be other stopped threads. */
728 struct cleanup
*old_chain
;
730 /* Backup current thread and selected frame. */
731 old_chain
= make_cleanup_restore_current_thread ();
733 iterate_over_threads (proceed_thread_callback
, NULL
);
735 if (current_ui
->prompt_state
== PROMPT_BLOCKED
)
737 /* If all threads in the target were already running,
738 proceed_thread_callback ends up never calling proceed,
739 and so nothing calls this to put the inferior's terminal
740 settings in effect and remove stdin from the event loop,
741 which we must when running a foreground command. E.g.:
745 <all threads are running now>
748 <no thread was resumed, but the inferior now owns the terminal>
750 target_terminal_inferior ();
753 /* Restore selected ptid. */
754 do_cleanups (old_chain
);
758 ensure_valid_thread ();
759 ensure_not_running ();
760 clear_proceed_status (0);
761 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
765 /* continue [-a] [proceed-count] [&] */
768 continue_command (char *args
, int from_tty
)
772 struct cleanup
*args_chain
;
776 /* Find out whether we must run in the background. */
777 args
= strip_bg_char (args
, &async_exec
);
778 args_chain
= make_cleanup (xfree
, args
);
782 if (startswith (args
, "-a"))
785 args
+= sizeof ("-a") - 1;
791 if (!non_stop
&& all_threads
)
792 error (_("`-a' is meaningless in all-stop mode."));
794 if (args
!= NULL
&& all_threads
)
795 error (_("Can't resume all threads and specify "
796 "proceed count simultaneously."));
798 /* If we have an argument left, set proceed count of breakpoint we
805 struct thread_info
*tp
;
808 tp
= find_thread_ptid (inferior_ptid
);
812 struct target_waitstatus ws
;
814 get_last_target_status (&last_ptid
, &ws
);
815 tp
= find_thread_ptid (last_ptid
);
818 bs
= tp
->control
.stop_bpstat
;
820 while ((stat
= bpstat_num (&bs
, &num
)) != 0)
823 set_ignore_count (num
,
824 parse_and_eval_long (args
) - 1,
826 /* set_ignore_count prints a message ending with a period.
827 So print two spaces before "Continuing.". */
829 printf_filtered (" ");
833 if (!stopped
&& from_tty
)
836 ("Not stopped at any breakpoint; argument ignored.\n");
840 /* Done with ARGS. */
841 do_cleanups (args_chain
);
844 ensure_not_tfind_mode ();
846 if (!non_stop
|| !all_threads
)
848 ensure_valid_thread ();
849 ensure_not_running ();
852 prepare_execution_command (¤t_target
, async_exec
);
855 printf_filtered (_("Continuing.\n"));
857 continue_1 (all_threads
);
860 /* Record the starting point of a "step" or "next" command. */
863 set_step_frame (void)
865 struct symtab_and_line sal
;
867 struct frame_info
*frame
= get_current_frame ();
868 struct thread_info
*tp
= inferior_thread ();
870 find_frame_sal (frame
, &sal
);
871 set_step_info (frame
, sal
);
872 pc
= get_frame_pc (frame
);
873 tp
->control
.step_start_function
= find_pc_function (pc
);
876 /* Step until outside of current statement. */
879 step_command (char *count_string
, int from_tty
)
881 step_1 (0, 0, count_string
);
884 /* Likewise, but skip over subroutine calls as if single instructions. */
887 next_command (char *count_string
, int from_tty
)
889 step_1 (1, 0, count_string
);
892 /* Likewise, but step only one instruction. */
895 stepi_command (char *count_string
, int from_tty
)
897 step_1 (0, 1, count_string
);
901 nexti_command (char *count_string
, int from_tty
)
903 step_1 (1, 1, count_string
);
907 delete_longjmp_breakpoint_cleanup (void *arg
)
909 int thread
= * (int *) arg
;
910 delete_longjmp_breakpoint (thread
);
913 /* Data for the FSM that manages the step/next/stepi/nexti
916 struct step_command_fsm
918 /* The base class. */
919 struct thread_fsm thread_fsm
;
921 /* How many steps left in a "step N"-like command. */
924 /* If true, this is a next/nexti, otherwise a step/stepi. */
925 int skip_subroutines
;
927 /* If true, this is a stepi/nexti, otherwise a step/step. */
931 static void step_command_fsm_clean_up (struct thread_fsm
*self
,
932 struct thread_info
*thread
);
933 static int step_command_fsm_should_stop (struct thread_fsm
*self
,
934 struct thread_info
*thread
);
935 static enum async_reply_reason
936 step_command_fsm_async_reply_reason (struct thread_fsm
*self
);
938 /* step_command_fsm's vtable. */
940 static struct thread_fsm_ops step_command_fsm_ops
=
943 step_command_fsm_clean_up
,
944 step_command_fsm_should_stop
,
945 NULL
, /* return_value */
946 step_command_fsm_async_reply_reason
,
949 /* Allocate a new step_command_fsm. */
951 static struct step_command_fsm
*
952 new_step_command_fsm (struct interp
*cmd_interp
)
954 struct step_command_fsm
*sm
;
956 sm
= XCNEW (struct step_command_fsm
);
957 thread_fsm_ctor (&sm
->thread_fsm
, &step_command_fsm_ops
, cmd_interp
);
962 /* Prepare for a step/next/etc. command. Any target resource
963 allocated here is undone in the FSM's clean_up method. */
966 step_command_fsm_prepare (struct step_command_fsm
*sm
,
967 int skip_subroutines
, int single_inst
,
968 int count
, struct thread_info
*thread
)
970 sm
->skip_subroutines
= skip_subroutines
;
971 sm
->single_inst
= single_inst
;
974 /* Leave the si command alone. */
975 if (!sm
->single_inst
|| sm
->skip_subroutines
)
976 set_longjmp_breakpoint (thread
, get_frame_id (get_current_frame ()));
978 thread
->control
.stepping_command
= 1;
981 static int prepare_one_step (struct step_command_fsm
*sm
);
984 step_1 (int skip_subroutines
, int single_inst
, char *count_string
)
988 struct cleanup
*args_chain
;
989 struct thread_info
*thr
;
990 struct step_command_fsm
*step_sm
;
993 ensure_not_tfind_mode ();
994 ensure_valid_thread ();
995 ensure_not_running ();
997 count_string
= strip_bg_char (count_string
, &async_exec
);
998 args_chain
= make_cleanup (xfree
, count_string
);
1000 prepare_execution_command (¤t_target
, async_exec
);
1002 count
= count_string
? parse_and_eval_long (count_string
) : 1;
1004 /* Done with ARGS. */
1005 do_cleanups (args_chain
);
1007 clear_proceed_status (1);
1009 /* Setup the execution command state machine to handle all the COUNT
1011 thr
= inferior_thread ();
1012 step_sm
= new_step_command_fsm (command_interp ());
1013 thr
->thread_fsm
= &step_sm
->thread_fsm
;
1015 step_command_fsm_prepare (step_sm
, skip_subroutines
,
1016 single_inst
, count
, thr
);
1018 /* Do only one step for now, before returning control to the event
1019 loop. Let the continuation figure out how many other steps we
1020 need to do, and handle them one at the time, through
1022 if (!prepare_one_step (step_sm
))
1023 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1028 /* Stepped into an inline frame. Pretend that we've
1030 thread_fsm_clean_up (thr
->thread_fsm
, thr
);
1031 proceeded
= normal_stop ();
1033 inferior_event_handler (INF_EXEC_COMPLETE
, NULL
);
1034 all_uis_check_sync_execution_done ();
1038 /* Implementation of the 'should_stop' FSM method for stepping
1039 commands. Called after we are done with one step operation, to
1040 check whether we need to step again, before we print the prompt and
1041 return control to the user. If count is > 1, returns false, as we
1042 will need to keep going. */
1045 step_command_fsm_should_stop (struct thread_fsm
*self
, struct thread_info
*tp
)
1047 struct step_command_fsm
*sm
= (struct step_command_fsm
*) self
;
1049 if (tp
->control
.stop_step
)
1051 /* There are more steps to make, and we did stop due to
1052 ending a stepping range. Do another step. */
1053 if (--sm
->count
> 0)
1054 return prepare_one_step (sm
);
1056 thread_fsm_set_finished (self
);
1062 /* Implementation of the 'clean_up' FSM method for stepping commands. */
1065 step_command_fsm_clean_up (struct thread_fsm
*self
, struct thread_info
*thread
)
1067 struct step_command_fsm
*sm
= (struct step_command_fsm
*) self
;
1069 if (!sm
->single_inst
|| sm
->skip_subroutines
)
1070 delete_longjmp_breakpoint (thread
->global_num
);
1073 /* Implementation of the 'async_reply_reason' FSM method for stepping
1076 static enum async_reply_reason
1077 step_command_fsm_async_reply_reason (struct thread_fsm
*self
)
1079 return EXEC_ASYNC_END_STEPPING_RANGE
;
1082 /* Prepare for one step in "step N". The actual target resumption is
1083 done by the caller. Return true if we're done and should thus
1084 report a stop to the user. Returns false if the target needs to be
1088 prepare_one_step (struct step_command_fsm
*sm
)
1092 struct frame_info
*frame
= get_current_frame ();
1094 /* Don't assume THREAD is a valid thread id. It is set to -1 if
1095 the longjmp breakpoint was not required. Use the
1096 INFERIOR_PTID thread instead, which is the same thread when
1098 struct thread_info
*tp
= inferior_thread ();
1102 if (!sm
->single_inst
)
1106 /* Step at an inlined function behaves like "down". */
1107 if (!sm
->skip_subroutines
1108 && inline_skipped_frames (inferior_ptid
))
1112 /* Pretend that we've ran. */
1113 resume_ptid
= user_visible_resume_ptid (1);
1114 set_running (resume_ptid
, 1);
1116 step_into_inline_frame (inferior_ptid
);
1118 return prepare_one_step (sm
);
1121 pc
= get_frame_pc (frame
);
1122 find_pc_line_pc_range (pc
,
1123 &tp
->control
.step_range_start
,
1124 &tp
->control
.step_range_end
);
1126 tp
->control
.may_range_step
= 1;
1128 /* If we have no line info, switch to stepi mode. */
1129 if (tp
->control
.step_range_end
== 0 && step_stop_if_no_debug
)
1131 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1132 tp
->control
.may_range_step
= 0;
1134 else if (tp
->control
.step_range_end
== 0)
1138 if (find_pc_partial_function (pc
, &name
,
1139 &tp
->control
.step_range_start
,
1140 &tp
->control
.step_range_end
) == 0)
1141 error (_("Cannot find bounds of current function"));
1143 target_terminal_ours_for_output ();
1144 printf_filtered (_("Single stepping until exit from function %s,"
1145 "\nwhich has no line number information.\n"),
1151 /* Say we are stepping, but stop after one insn whatever it does. */
1152 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1153 if (!sm
->skip_subroutines
)
1155 Don't step over function calls, not even to functions lacking
1157 tp
->control
.step_over_calls
= STEP_OVER_NONE
;
1160 if (sm
->skip_subroutines
)
1161 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1167 thread_fsm_set_finished (&sm
->thread_fsm
);
1172 /* Continue program at specified address. */
1175 jump_command (char *arg
, int from_tty
)
1177 struct gdbarch
*gdbarch
= get_current_arch ();
1179 struct symtabs_and_lines sals
;
1180 struct symtab_and_line sal
;
1184 struct cleanup
*args_chain
;
1187 ensure_not_tfind_mode ();
1188 ensure_valid_thread ();
1189 ensure_not_running ();
1191 /* Find out whether we must run in the background. */
1192 arg
= strip_bg_char (arg
, &async_exec
);
1193 args_chain
= make_cleanup (xfree
, arg
);
1195 prepare_execution_command (¤t_target
, async_exec
);
1198 error_no_arg (_("starting address"));
1200 sals
= decode_line_with_last_displayed (arg
, DECODE_LINE_FUNFIRSTLINE
);
1201 if (sals
.nelts
!= 1)
1203 error (_("Unreasonable jump request"));
1209 /* Done with ARGS. */
1210 do_cleanups (args_chain
);
1212 if (sal
.symtab
== 0 && sal
.pc
== 0)
1213 error (_("No source file has been specified."));
1215 resolve_sal_pc (&sal
); /* May error out. */
1217 /* See if we are trying to jump to another function. */
1218 fn
= get_frame_function (get_current_frame ());
1219 sfn
= find_pc_function (sal
.pc
);
1220 if (fn
!= NULL
&& sfn
!= fn
)
1222 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal
.line
,
1223 SYMBOL_PRINT_NAME (fn
)))
1225 error (_("Not confirmed."));
1232 struct obj_section
*section
;
1234 fixup_symbol_section (sfn
, 0);
1235 section
= SYMBOL_OBJ_SECTION (symbol_objfile (sfn
), sfn
);
1236 if (section_is_overlay (section
)
1237 && !section_is_mapped (section
))
1239 if (!query (_("WARNING!!! Destination is in "
1240 "unmapped overlay! Jump anyway? ")))
1242 error (_("Not confirmed."));
1252 printf_filtered (_("Continuing at "));
1253 fputs_filtered (paddress (gdbarch
, addr
), gdb_stdout
);
1254 printf_filtered (".\n");
1257 clear_proceed_status (0);
1258 proceed (addr
, GDB_SIGNAL_0
);
1261 /* Continue program giving it specified signal. */
1264 signal_command (char *signum_exp
, int from_tty
)
1266 enum gdb_signal oursig
;
1268 struct cleanup
*args_chain
;
1270 dont_repeat (); /* Too dangerous. */
1272 ensure_not_tfind_mode ();
1273 ensure_valid_thread ();
1274 ensure_not_running ();
1276 /* Find out whether we must run in the background. */
1277 signum_exp
= strip_bg_char (signum_exp
, &async_exec
);
1278 args_chain
= make_cleanup (xfree
, signum_exp
);
1280 prepare_execution_command (¤t_target
, async_exec
);
1283 error_no_arg (_("signal number"));
1285 /* It would be even slicker to make signal names be valid expressions,
1286 (the type could be "enum $signal" or some such), then the user could
1287 assign them to convenience variables. */
1288 oursig
= gdb_signal_from_name (signum_exp
);
1290 if (oursig
== GDB_SIGNAL_UNKNOWN
)
1292 /* No, try numeric. */
1293 int num
= parse_and_eval_long (signum_exp
);
1296 oursig
= GDB_SIGNAL_0
;
1298 oursig
= gdb_signal_from_command (num
);
1301 do_cleanups (args_chain
);
1303 /* Look for threads other than the current that this command ends up
1304 resuming too (due to schedlock off), and warn if they'll get a
1305 signal delivered. "signal 0" is used to suppress a previous
1306 signal, but if the current thread is no longer the one that got
1307 the signal, then the user is potentially suppressing the signal
1308 of the wrong thread. */
1311 struct thread_info
*tp
;
1313 int must_confirm
= 0;
1315 /* This indicates what will be resumed. Either a single thread,
1316 a whole process, or all threads of all processes. */
1317 resume_ptid
= user_visible_resume_ptid (0);
1319 ALL_NON_EXITED_THREADS (tp
)
1321 if (ptid_equal (tp
->ptid
, inferior_ptid
))
1323 if (!ptid_match (tp
->ptid
, resume_ptid
))
1326 if (tp
->suspend
.stop_signal
!= GDB_SIGNAL_0
1327 && signal_pass_state (tp
->suspend
.stop_signal
))
1330 printf_unfiltered (_("Note:\n"));
1331 printf_unfiltered (_(" Thread %s previously stopped with signal %s, %s.\n"),
1332 print_thread_id (tp
),
1333 gdb_signal_to_name (tp
->suspend
.stop_signal
),
1334 gdb_signal_to_string (tp
->suspend
.stop_signal
));
1340 && !query (_("Continuing thread %s (the current thread) with specified signal will\n"
1341 "still deliver the signals noted above to their respective threads.\n"
1342 "Continue anyway? "),
1343 print_thread_id (inferior_thread ())))
1344 error (_("Not confirmed."));
1349 if (oursig
== GDB_SIGNAL_0
)
1350 printf_filtered (_("Continuing with no signal.\n"));
1352 printf_filtered (_("Continuing with signal %s.\n"),
1353 gdb_signal_to_name (oursig
));
1356 clear_proceed_status (0);
1357 proceed ((CORE_ADDR
) -1, oursig
);
1360 /* Queue a signal to be delivered to the current thread. */
1363 queue_signal_command (char *signum_exp
, int from_tty
)
1365 enum gdb_signal oursig
;
1366 struct thread_info
*tp
;
1369 ensure_not_tfind_mode ();
1370 ensure_valid_thread ();
1371 ensure_not_running ();
1373 if (signum_exp
== NULL
)
1374 error_no_arg (_("signal number"));
1376 /* It would be even slicker to make signal names be valid expressions,
1377 (the type could be "enum $signal" or some such), then the user could
1378 assign them to convenience variables. */
1379 oursig
= gdb_signal_from_name (signum_exp
);
1381 if (oursig
== GDB_SIGNAL_UNKNOWN
)
1383 /* No, try numeric. */
1384 int num
= parse_and_eval_long (signum_exp
);
1387 oursig
= GDB_SIGNAL_0
;
1389 oursig
= gdb_signal_from_command (num
);
1392 if (oursig
!= GDB_SIGNAL_0
1393 && !signal_pass_state (oursig
))
1394 error (_("Signal handling set to not pass this signal to the program."));
1396 tp
= inferior_thread ();
1397 tp
->suspend
.stop_signal
= oursig
;
1400 /* Data for the FSM that manages the until (with no argument)
1403 struct until_next_fsm
1405 /* The base class. */
1406 struct thread_fsm thread_fsm
;
1408 /* The thread that as current when the command was executed. */
1412 static int until_next_fsm_should_stop (struct thread_fsm
*self
,
1413 struct thread_info
*thread
);
1414 static void until_next_fsm_clean_up (struct thread_fsm
*self
,
1415 struct thread_info
*thread
);
1416 static enum async_reply_reason
1417 until_next_fsm_async_reply_reason (struct thread_fsm
*self
);
1419 /* until_next_fsm's vtable. */
1421 static struct thread_fsm_ops until_next_fsm_ops
=
1424 until_next_fsm_clean_up
,
1425 until_next_fsm_should_stop
,
1426 NULL
, /* return_value */
1427 until_next_fsm_async_reply_reason
,
1430 /* Allocate a new until_next_fsm. */
1432 static struct until_next_fsm
*
1433 new_until_next_fsm (struct interp
*cmd_interp
, int thread
)
1435 struct until_next_fsm
*sm
;
1437 sm
= XCNEW (struct until_next_fsm
);
1438 thread_fsm_ctor (&sm
->thread_fsm
, &until_next_fsm_ops
, cmd_interp
);
1440 sm
->thread
= thread
;
1445 /* Implementation of the 'should_stop' FSM method for the until (with
1449 until_next_fsm_should_stop (struct thread_fsm
*self
,
1450 struct thread_info
*tp
)
1452 if (tp
->control
.stop_step
)
1453 thread_fsm_set_finished (self
);
1458 /* Implementation of the 'clean_up' FSM method for the until (with no
1462 until_next_fsm_clean_up (struct thread_fsm
*self
, struct thread_info
*thread
)
1464 struct until_next_fsm
*sm
= (struct until_next_fsm
*) self
;
1466 delete_longjmp_breakpoint (thread
->global_num
);
1469 /* Implementation of the 'async_reply_reason' FSM method for the until
1470 (with no arg) command. */
1472 static enum async_reply_reason
1473 until_next_fsm_async_reply_reason (struct thread_fsm
*self
)
1475 return EXEC_ASYNC_END_STEPPING_RANGE
;
1478 /* Proceed until we reach a different source line with pc greater than
1479 our current one or exit the function. We skip calls in both cases.
1481 Note that eventually this command should probably be changed so
1482 that only source lines are printed out when we hit the breakpoint
1483 we set. This may involve changes to wait_for_inferior and the
1484 proceed status code. */
1487 until_next_command (int from_tty
)
1489 struct frame_info
*frame
;
1491 struct symbol
*func
;
1492 struct symtab_and_line sal
;
1493 struct thread_info
*tp
= inferior_thread ();
1494 int thread
= tp
->global_num
;
1495 struct cleanup
*old_chain
;
1496 struct until_next_fsm
*sm
;
1498 clear_proceed_status (0);
1501 frame
= get_current_frame ();
1503 /* Step until either exited from this function or greater
1504 than the current line (if in symbolic section) or pc (if
1507 pc
= get_frame_pc (frame
);
1508 func
= find_pc_function (pc
);
1512 struct bound_minimal_symbol msymbol
= lookup_minimal_symbol_by_pc (pc
);
1514 if (msymbol
.minsym
== NULL
)
1515 error (_("Execution is not within a known function."));
1517 tp
->control
.step_range_start
= BMSYMBOL_VALUE_ADDRESS (msymbol
);
1518 /* The upper-bound of step_range is exclusive. In order to make PC
1519 within the range, set the step_range_end with PC + 1. */
1520 tp
->control
.step_range_end
= pc
+ 1;
1524 sal
= find_pc_line (pc
, 0);
1526 tp
->control
.step_range_start
= BLOCK_START (SYMBOL_BLOCK_VALUE (func
));
1527 tp
->control
.step_range_end
= sal
.end
;
1529 tp
->control
.may_range_step
= 1;
1531 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1533 set_longjmp_breakpoint (tp
, get_frame_id (frame
));
1534 old_chain
= make_cleanup (delete_longjmp_breakpoint_cleanup
, &thread
);
1536 sm
= new_until_next_fsm (command_interp (), tp
->global_num
);
1537 tp
->thread_fsm
= &sm
->thread_fsm
;
1538 discard_cleanups (old_chain
);
1540 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1544 until_command (char *arg
, int from_tty
)
1547 struct cleanup
*args_chain
;
1550 ensure_not_tfind_mode ();
1551 ensure_valid_thread ();
1552 ensure_not_running ();
1554 /* Find out whether we must run in the background. */
1555 arg
= strip_bg_char (arg
, &async_exec
);
1556 args_chain
= make_cleanup (xfree
, arg
);
1558 prepare_execution_command (¤t_target
, async_exec
);
1561 until_break_command (arg
, from_tty
, 0);
1563 until_next_command (from_tty
);
1565 /* Done with ARGS. */
1566 do_cleanups (args_chain
);
1570 advance_command (char *arg
, int from_tty
)
1573 struct cleanup
*args_chain
;
1576 ensure_not_tfind_mode ();
1577 ensure_valid_thread ();
1578 ensure_not_running ();
1581 error_no_arg (_("a location"));
1583 /* Find out whether we must run in the background. */
1584 arg
= strip_bg_char (arg
, &async_exec
);
1585 args_chain
= make_cleanup (xfree
, arg
);
1587 prepare_execution_command (¤t_target
, async_exec
);
1589 until_break_command (arg
, from_tty
, 1);
1591 /* Done with ARGS. */
1592 do_cleanups (args_chain
);
1595 /* Return the value of the result of a function at the end of a 'finish'
1596 command/BP. DTOR_DATA (if not NULL) can represent inferior registers
1597 right after an inferior call has finished. */
1600 get_return_value (struct value
*function
, struct type
*value_type
)
1602 struct regcache
*stop_regs
;
1603 struct gdbarch
*gdbarch
;
1604 struct value
*value
;
1605 struct cleanup
*cleanup
;
1607 stop_regs
= regcache_dup (get_current_regcache ());
1608 cleanup
= make_cleanup_regcache_xfree (stop_regs
);
1610 gdbarch
= get_regcache_arch (stop_regs
);
1612 value_type
= check_typedef (value_type
);
1613 gdb_assert (TYPE_CODE (value_type
) != TYPE_CODE_VOID
);
1615 /* FIXME: 2003-09-27: When returning from a nested inferior function
1616 call, it's possible (with no help from the architecture vector)
1617 to locate and return/print a "struct return" value. This is just
1618 a more complicated case of what is already being done in the
1619 inferior function call code. In fact, when inferior function
1620 calls are made async, this will likely be made the norm. */
1622 switch (gdbarch_return_value (gdbarch
, function
, value_type
,
1625 case RETURN_VALUE_REGISTER_CONVENTION
:
1626 case RETURN_VALUE_ABI_RETURNS_ADDRESS
:
1627 case RETURN_VALUE_ABI_PRESERVES_ADDRESS
:
1628 value
= allocate_value (value_type
);
1629 gdbarch_return_value (gdbarch
, function
, value_type
, stop_regs
,
1630 value_contents_raw (value
), NULL
);
1632 case RETURN_VALUE_STRUCT_CONVENTION
:
1636 internal_error (__FILE__
, __LINE__
, _("bad switch"));
1639 do_cleanups (cleanup
);
1644 /* The captured function return value/type and its position in the
1647 struct return_value_info
1649 /* The captured return value. May be NULL if we weren't able to
1650 retrieve it. See get_return_value. */
1651 struct value
*value
;
1653 /* The return type. In some cases, we'll not be able extract the
1654 return value, but we always know the type. */
1657 /* If we captured a value, this is the value history index. */
1658 int value_history_index
;
1661 /* Helper for print_return_value. */
1664 print_return_value_1 (struct ui_out
*uiout
, struct return_value_info
*rv
)
1666 if (rv
->value
!= NULL
)
1668 struct value_print_options opts
;
1669 struct ui_file
*stb
;
1670 struct cleanup
*old_chain
;
1673 stb
= mem_fileopen ();
1674 old_chain
= make_cleanup_ui_file_delete (stb
);
1675 ui_out_text (uiout
, "Value returned is ");
1676 ui_out_field_fmt (uiout
, "gdb-result-var", "$%d",
1677 rv
->value_history_index
);
1678 ui_out_text (uiout
, " = ");
1679 get_no_prettyformat_print_options (&opts
);
1680 value_print (rv
->value
, stb
, &opts
);
1681 ui_out_field_stream (uiout
, "return-value", stb
);
1682 ui_out_text (uiout
, "\n");
1683 do_cleanups (old_chain
);
1687 struct cleanup
*oldchain
;
1690 type_name
= type_to_string (rv
->type
);
1691 oldchain
= make_cleanup (xfree
, type_name
);
1692 ui_out_text (uiout
, "Value returned has type: ");
1693 ui_out_field_string (uiout
, "return-type", type_name
);
1694 ui_out_text (uiout
, ".");
1695 ui_out_text (uiout
, " Cannot determine contents\n");
1696 do_cleanups (oldchain
);
1700 /* Print the result of a function at the end of a 'finish' command.
1701 RV points at an object representing the captured return value/type
1702 and its position in the value history. */
1705 print_return_value (struct ui_out
*uiout
, struct return_value_info
*rv
)
1707 if (rv
->type
== NULL
|| TYPE_CODE (rv
->type
) == TYPE_CODE_VOID
)
1712 /* print_return_value_1 can throw an exception in some
1713 circumstances. We need to catch this so that we still
1714 delete the breakpoint. */
1715 print_return_value_1 (uiout
, rv
);
1717 CATCH (ex
, RETURN_MASK_ALL
)
1719 exception_print (gdb_stdout
, ex
);
1724 /* Data for the FSM that manages the finish command. */
1726 struct finish_command_fsm
1728 /* The base class. */
1729 struct thread_fsm thread_fsm
;
1731 /* The momentary breakpoint set at the function's return address in
1733 struct breakpoint
*breakpoint
;
1735 /* The function that we're stepping out of. */
1736 struct symbol
*function
;
1738 /* If the FSM finishes successfully, this stores the function's
1740 struct return_value_info return_value
;
1743 static int finish_command_fsm_should_stop (struct thread_fsm
*self
,
1744 struct thread_info
*thread
);
1745 static void finish_command_fsm_clean_up (struct thread_fsm
*self
,
1746 struct thread_info
*thread
);
1747 static struct return_value_info
*
1748 finish_command_fsm_return_value (struct thread_fsm
*self
);
1749 static enum async_reply_reason
1750 finish_command_fsm_async_reply_reason (struct thread_fsm
*self
);
1752 /* finish_command_fsm's vtable. */
1754 static struct thread_fsm_ops finish_command_fsm_ops
=
1757 finish_command_fsm_clean_up
,
1758 finish_command_fsm_should_stop
,
1759 finish_command_fsm_return_value
,
1760 finish_command_fsm_async_reply_reason
,
1761 NULL
, /* should_notify_stop */
1764 /* Allocate a new finish_command_fsm. */
1766 static struct finish_command_fsm
*
1767 new_finish_command_fsm (struct interp
*cmd_interp
)
1769 struct finish_command_fsm
*sm
;
1771 sm
= XCNEW (struct finish_command_fsm
);
1772 thread_fsm_ctor (&sm
->thread_fsm
, &finish_command_fsm_ops
, cmd_interp
);
1777 /* Implementation of the 'should_stop' FSM method for the finish
1778 commands. Detects whether the thread stepped out of the function
1779 successfully, and if so, captures the function's return value and
1780 marks the FSM finished. */
1783 finish_command_fsm_should_stop (struct thread_fsm
*self
,
1784 struct thread_info
*tp
)
1786 struct finish_command_fsm
*f
= (struct finish_command_fsm
*) self
;
1787 struct return_value_info
*rv
= &f
->return_value
;
1789 if (f
->function
!= NULL
1790 && bpstat_find_breakpoint (tp
->control
.stop_bpstat
,
1791 f
->breakpoint
) != NULL
)
1794 thread_fsm_set_finished (self
);
1796 rv
->type
= TYPE_TARGET_TYPE (SYMBOL_TYPE (f
->function
));
1797 if (rv
->type
== NULL
)
1798 internal_error (__FILE__
, __LINE__
,
1799 _("finish_command: function has no target type"));
1801 if (TYPE_CODE (rv
->type
) != TYPE_CODE_VOID
)
1805 func
= read_var_value (f
->function
, NULL
, get_current_frame ());
1806 rv
->value
= get_return_value (func
, rv
->type
);
1807 if (rv
->value
!= NULL
)
1808 rv
->value_history_index
= record_latest_value (rv
->value
);
1811 else if (tp
->control
.stop_step
)
1813 /* Finishing from an inline frame, or reverse finishing. In
1814 either case, there's no way to retrieve the return value. */
1815 thread_fsm_set_finished (self
);
1821 /* Implementation of the 'clean_up' FSM method for the finish
1825 finish_command_fsm_clean_up (struct thread_fsm
*self
,
1826 struct thread_info
*thread
)
1828 struct finish_command_fsm
*f
= (struct finish_command_fsm
*) self
;
1830 if (f
->breakpoint
!= NULL
)
1832 delete_breakpoint (f
->breakpoint
);
1833 f
->breakpoint
= NULL
;
1835 delete_longjmp_breakpoint (thread
->global_num
);
1838 /* Implementation of the 'return_value' FSM method for the finish
1841 static struct return_value_info
*
1842 finish_command_fsm_return_value (struct thread_fsm
*self
)
1844 struct finish_command_fsm
*f
= (struct finish_command_fsm
*) self
;
1846 return &f
->return_value
;
1849 /* Implementation of the 'async_reply_reason' FSM method for the
1852 static enum async_reply_reason
1853 finish_command_fsm_async_reply_reason (struct thread_fsm
*self
)
1855 if (execution_direction
== EXEC_REVERSE
)
1856 return EXEC_ASYNC_END_STEPPING_RANGE
;
1858 return EXEC_ASYNC_FUNCTION_FINISHED
;
1861 /* finish_backward -- helper function for finish_command. */
1864 finish_backward (struct finish_command_fsm
*sm
)
1866 struct symtab_and_line sal
;
1867 struct thread_info
*tp
= inferior_thread ();
1869 CORE_ADDR func_addr
;
1871 pc
= get_frame_pc (get_current_frame ());
1873 if (find_pc_partial_function (pc
, NULL
, &func_addr
, NULL
) == 0)
1874 error (_("Cannot find bounds of current function"));
1876 sal
= find_pc_line (func_addr
, 0);
1878 tp
->control
.proceed_to_finish
= 1;
1879 /* Special case: if we're sitting at the function entry point,
1880 then all we need to do is take a reverse singlestep. We
1881 don't need to set a breakpoint, and indeed it would do us
1884 Note that this can only happen at frame #0, since there's
1885 no way that a function up the stack can have a return address
1886 that's equal to its entry point. */
1890 struct frame_info
*frame
= get_selected_frame (NULL
);
1891 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1892 struct symtab_and_line sr_sal
;
1894 /* Set a step-resume at the function's entry point. Once that's
1895 hit, we'll do one more step backwards. */
1898 sr_sal
.pspace
= get_frame_program_space (frame
);
1899 insert_step_resume_breakpoint_at_sal (gdbarch
,
1900 sr_sal
, null_frame_id
);
1902 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1906 /* We're almost there -- we just need to back up by one more
1908 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1909 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1913 /* finish_forward -- helper function for finish_command. FRAME is the
1914 frame that called the function we're about to step out of. */
1917 finish_forward (struct finish_command_fsm
*sm
, struct frame_info
*frame
)
1919 struct frame_id frame_id
= get_frame_id (frame
);
1920 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1921 struct symtab_and_line sal
;
1922 struct thread_info
*tp
= inferior_thread ();
1924 sal
= find_pc_line (get_frame_pc (frame
), 0);
1925 sal
.pc
= get_frame_pc (frame
);
1927 sm
->breakpoint
= set_momentary_breakpoint (gdbarch
, sal
,
1928 get_stack_frame_id (frame
),
1931 /* set_momentary_breakpoint invalidates FRAME. */
1934 set_longjmp_breakpoint (tp
, frame_id
);
1936 /* We want to print return value, please... */
1937 tp
->control
.proceed_to_finish
= 1;
1939 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1942 /* Skip frames for "finish". */
1944 static struct frame_info
*
1945 skip_finish_frames (struct frame_info
*frame
)
1947 struct frame_info
*start
;
1953 frame
= skip_tailcall_frames (frame
);
1957 frame
= skip_unwritable_frames (frame
);
1961 while (start
!= frame
);
1966 /* "finish": Set a temporary breakpoint at the place the selected
1967 frame will return to, then continue. */
1970 finish_command (char *arg
, int from_tty
)
1972 struct frame_info
*frame
;
1974 struct cleanup
*args_chain
;
1975 struct finish_command_fsm
*sm
;
1976 struct thread_info
*tp
;
1979 ensure_not_tfind_mode ();
1980 ensure_valid_thread ();
1981 ensure_not_running ();
1983 /* Find out whether we must run in the background. */
1984 arg
= strip_bg_char (arg
, &async_exec
);
1985 args_chain
= make_cleanup (xfree
, arg
);
1987 prepare_execution_command (¤t_target
, async_exec
);
1990 error (_("The \"finish\" command does not take any arguments."));
1992 /* Done with ARGS. */
1993 do_cleanups (args_chain
);
1995 frame
= get_prev_frame (get_selected_frame (_("No selected frame.")));
1997 error (_("\"finish\" not meaningful in the outermost frame."));
1999 clear_proceed_status (0);
2001 tp
= inferior_thread ();
2003 sm
= new_finish_command_fsm (command_interp ());
2005 tp
->thread_fsm
= &sm
->thread_fsm
;
2007 /* Finishing from an inline frame is completely different. We don't
2008 try to show the "return value" - no way to locate it. */
2009 if (get_frame_type (get_selected_frame (_("No selected frame.")))
2012 /* Claim we are stepping in the calling frame. An empty step
2013 range means that we will stop once we aren't in a function
2014 called by that frame. We don't use the magic "1" value for
2015 step_range_end, because then infrun will think this is nexti,
2016 and not step over the rest of this inlined function call. */
2017 struct symtab_and_line empty_sal
;
2019 init_sal (&empty_sal
);
2020 set_step_info (frame
, empty_sal
);
2021 tp
->control
.step_range_start
= get_frame_pc (frame
);
2022 tp
->control
.step_range_end
= tp
->control
.step_range_start
;
2023 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
2025 /* Print info on the selected frame, including level number but not
2029 printf_filtered (_("Run till exit from "));
2030 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
, 0);
2033 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
2037 /* Find the function we will return from. */
2039 sm
->function
= find_pc_function (get_frame_pc (get_selected_frame (NULL
)));
2041 /* Print info on the selected frame, including level number but not
2045 if (execution_direction
== EXEC_REVERSE
)
2046 printf_filtered (_("Run back to call of "));
2049 if (sm
->function
!= NULL
&& TYPE_NO_RETURN (sm
->function
->type
)
2050 && !query (_("warning: Function %s does not return normally.\n"
2051 "Try to finish anyway? "),
2052 SYMBOL_PRINT_NAME (sm
->function
)))
2053 error (_("Not confirmed."));
2054 printf_filtered (_("Run till exit from "));
2057 print_stack_frame (get_selected_frame (NULL
), 1, LOCATION
, 0);
2060 if (execution_direction
== EXEC_REVERSE
)
2061 finish_backward (sm
);
2064 frame
= skip_finish_frames (frame
);
2067 error (_("Cannot find the caller frame."));
2069 finish_forward (sm
, frame
);
2075 program_info (char *args
, int from_tty
)
2079 struct thread_info
*tp
;
2082 if (!target_has_execution
)
2084 printf_filtered (_("The program being debugged is not being run.\n"));
2089 ptid
= inferior_ptid
;
2092 struct target_waitstatus ws
;
2094 get_last_target_status (&ptid
, &ws
);
2097 if (ptid_equal (ptid
, null_ptid
) || is_exited (ptid
))
2098 error (_("Invalid selected thread."));
2099 else if (is_running (ptid
))
2100 error (_("Selected thread is running."));
2102 tp
= find_thread_ptid (ptid
);
2103 bs
= tp
->control
.stop_bpstat
;
2104 stat
= bpstat_num (&bs
, &num
);
2106 target_files_info ();
2107 printf_filtered (_("Program stopped at %s.\n"),
2108 paddress (target_gdbarch (), stop_pc
));
2109 if (tp
->control
.stop_step
)
2110 printf_filtered (_("It stopped after being stepped.\n"));
2113 /* There may be several breakpoints in the same place, so this
2114 isn't as strange as it seems. */
2119 printf_filtered (_("It stopped at a breakpoint "
2120 "that has since been deleted.\n"));
2123 printf_filtered (_("It stopped at breakpoint %d.\n"), num
);
2124 stat
= bpstat_num (&bs
, &num
);
2127 else if (tp
->suspend
.stop_signal
!= GDB_SIGNAL_0
)
2129 printf_filtered (_("It stopped with signal %s, %s.\n"),
2130 gdb_signal_to_name (tp
->suspend
.stop_signal
),
2131 gdb_signal_to_string (tp
->suspend
.stop_signal
));
2136 printf_filtered (_("Type \"info stack\" or \"info "
2137 "registers\" for more information.\n"));
2142 environment_info (char *var
, int from_tty
)
2146 char *val
= get_in_environ (current_inferior ()->environment
, var
);
2150 puts_filtered (var
);
2151 puts_filtered (" = ");
2152 puts_filtered (val
);
2153 puts_filtered ("\n");
2157 puts_filtered ("Environment variable \"");
2158 puts_filtered (var
);
2159 puts_filtered ("\" not defined.\n");
2164 char **vector
= environ_vector (current_inferior ()->environment
);
2168 puts_filtered (*vector
++);
2169 puts_filtered ("\n");
2175 set_environment_command (char *arg
, int from_tty
)
2177 char *p
, *val
, *var
;
2181 error_no_arg (_("environment variable and value"));
2183 /* Find seperation between variable name and value. */
2184 p
= (char *) strchr (arg
, '=');
2185 val
= (char *) strchr (arg
, ' ');
2187 if (p
!= 0 && val
!= 0)
2189 /* We have both a space and an equals. If the space is before the
2190 equals, walk forward over the spaces til we see a nonspace
2191 (possibly the equals). */
2196 /* Now if the = is after the char following the spaces,
2197 take the char following the spaces. */
2201 else if (val
!= 0 && p
== 0)
2205 error_no_arg (_("environment variable to set"));
2207 if (p
== 0 || p
[1] == 0)
2211 p
= arg
+ strlen (arg
); /* So that savestring below will work. */
2215 /* Not setting variable value to null. */
2217 while (*val
== ' ' || *val
== '\t')
2221 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
2224 var
= savestring (arg
, p
- arg
);
2227 printf_filtered (_("Setting environment variable "
2228 "\"%s\" to null value.\n"),
2230 set_in_environ (current_inferior ()->environment
, var
, "");
2233 set_in_environ (current_inferior ()->environment
, var
, val
);
2238 unset_environment_command (char *var
, int from_tty
)
2242 /* If there is no argument, delete all environment variables.
2243 Ask for confirmation if reading from the terminal. */
2244 if (!from_tty
|| query (_("Delete all environment variables? ")))
2246 free_environ (current_inferior ()->environment
);
2247 current_inferior ()->environment
= make_environ ();
2251 unset_in_environ (current_inferior ()->environment
, var
);
2254 /* Handle the execution path (PATH variable). */
2256 static const char path_var_name
[] = "PATH";
2259 path_info (char *args
, int from_tty
)
2261 puts_filtered ("Executable and object file path: ");
2262 puts_filtered (get_in_environ (current_inferior ()->environment
,
2264 puts_filtered ("\n");
2267 /* Add zero or more directories to the front of the execution path. */
2270 path_command (char *dirname
, int from_tty
)
2276 env
= get_in_environ (current_inferior ()->environment
, path_var_name
);
2277 /* Can be null if path is not set. */
2280 exec_path
= xstrdup (env
);
2281 mod_path (dirname
, &exec_path
);
2282 set_in_environ (current_inferior ()->environment
, path_var_name
, exec_path
);
2285 path_info ((char *) NULL
, from_tty
);
2289 /* Print out the register NAME with value VAL, to FILE, in the default
2293 default_print_one_register_info (struct ui_file
*file
,
2297 struct type
*regtype
= value_type (val
);
2298 int print_raw_format
;
2300 fputs_filtered (name
, file
);
2301 print_spaces_filtered (15 - strlen (name
), file
);
2303 print_raw_format
= (value_entirely_available (val
)
2304 && !value_optimized_out (val
));
2306 /* If virtual format is floating, print it that way, and in raw
2308 if (TYPE_CODE (regtype
) == TYPE_CODE_FLT
2309 || TYPE_CODE (regtype
) == TYPE_CODE_DECFLOAT
)
2311 struct value_print_options opts
;
2312 const gdb_byte
*valaddr
= value_contents_for_printing (val
);
2313 enum bfd_endian byte_order
= gdbarch_byte_order (get_type_arch (regtype
));
2315 get_user_print_options (&opts
);
2319 value_contents_for_printing (val
),
2320 value_embedded_offset (val
), 0,
2321 file
, 0, val
, &opts
, current_language
);
2323 if (print_raw_format
)
2325 fprintf_filtered (file
, "\t(raw ");
2326 print_hex_chars (file
, valaddr
, TYPE_LENGTH (regtype
), byte_order
);
2327 fprintf_filtered (file
, ")");
2332 struct value_print_options opts
;
2334 /* Print the register in hex. */
2335 get_formatted_print_options (&opts
, 'x');
2338 value_contents_for_printing (val
),
2339 value_embedded_offset (val
), 0,
2340 file
, 0, val
, &opts
, current_language
);
2341 /* If not a vector register, print it also according to its
2343 if (print_raw_format
&& TYPE_VECTOR (regtype
) == 0)
2345 get_user_print_options (&opts
);
2347 fprintf_filtered (file
, "\t");
2349 value_contents_for_printing (val
),
2350 value_embedded_offset (val
), 0,
2351 file
, 0, val
, &opts
, current_language
);
2355 fprintf_filtered (file
, "\n");
2358 /* Print out the machine register regnum. If regnum is -1, print all
2359 registers (print_all == 1) or all non-float and non-vector
2360 registers (print_all == 0).
2362 For most machines, having all_registers_info() print the
2363 register(s) one per line is good enough. If a different format is
2364 required, (eg, for MIPS or Pyramid 90x, which both have lots of
2365 regs), or there is an existing convention for showing all the
2366 registers, define the architecture method PRINT_REGISTERS_INFO to
2367 provide that format. */
2370 default_print_registers_info (struct gdbarch
*gdbarch
,
2371 struct ui_file
*file
,
2372 struct frame_info
*frame
,
2373 int regnum
, int print_all
)
2376 const int numregs
= gdbarch_num_regs (gdbarch
)
2377 + gdbarch_num_pseudo_regs (gdbarch
);
2379 for (i
= 0; i
< numregs
; i
++)
2381 /* Decide between printing all regs, non-float / vector regs, or
2387 if (!gdbarch_register_reggroup_p (gdbarch
, i
, all_reggroup
))
2392 if (!gdbarch_register_reggroup_p (gdbarch
, i
, general_reggroup
))
2402 /* If the register name is empty, it is undefined for this
2403 processor, so don't display anything. */
2404 if (gdbarch_register_name (gdbarch
, i
) == NULL
2405 || *(gdbarch_register_name (gdbarch
, i
)) == '\0')
2408 default_print_one_register_info (file
,
2409 gdbarch_register_name (gdbarch
, i
),
2410 value_of_register (i
, frame
));
2415 registers_info (char *addr_exp
, int fpregs
)
2417 struct frame_info
*frame
;
2418 struct gdbarch
*gdbarch
;
2420 if (!target_has_registers
)
2421 error (_("The program has no registers now."));
2422 frame
= get_selected_frame (NULL
);
2423 gdbarch
= get_frame_arch (frame
);
2427 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2432 while (*addr_exp
!= '\0')
2437 /* Skip leading white space. */
2438 addr_exp
= skip_spaces (addr_exp
);
2440 /* Discard any leading ``$''. Check that there is something
2441 resembling a register following it. */
2442 if (addr_exp
[0] == '$')
2444 if (isspace ((*addr_exp
)) || (*addr_exp
) == '\0')
2445 error (_("Missing register name"));
2447 /* Find the start/end of this register name/num/group. */
2449 while ((*addr_exp
) != '\0' && !isspace ((*addr_exp
)))
2453 /* Figure out what we've found and display it. */
2455 /* A register name? */
2457 int regnum
= user_reg_map_name_to_regnum (gdbarch
, start
, end
- start
);
2461 /* User registers lie completely outside of the range of
2462 normal registers. Catch them early so that the target
2464 if (regnum
>= gdbarch_num_regs (gdbarch
)
2465 + gdbarch_num_pseudo_regs (gdbarch
))
2467 struct value
*regval
= value_of_user_reg (regnum
, frame
);
2468 const char *regname
= user_reg_map_regnum_to_name (gdbarch
,
2471 /* Print in the same fashion
2472 gdbarch_print_registers_info's default
2473 implementation prints. */
2474 default_print_one_register_info (gdb_stdout
,
2479 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2480 frame
, regnum
, fpregs
);
2485 /* A register group? */
2487 struct reggroup
*group
;
2489 for (group
= reggroup_next (gdbarch
, NULL
);
2491 group
= reggroup_next (gdbarch
, group
))
2493 /* Don't bother with a length check. Should the user
2494 enter a short register group name, go with the first
2495 group that matches. */
2496 if (strncmp (start
, reggroup_name (group
), end
- start
) == 0)
2504 regnum
< gdbarch_num_regs (gdbarch
)
2505 + gdbarch_num_pseudo_regs (gdbarch
);
2508 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
2509 gdbarch_print_registers_info (gdbarch
,
2517 /* Nothing matched. */
2518 error (_("Invalid register `%.*s'"), (int) (end
- start
), start
);
2523 all_registers_info (char *addr_exp
, int from_tty
)
2525 registers_info (addr_exp
, 1);
2529 nofp_registers_info (char *addr_exp
, int from_tty
)
2531 registers_info (addr_exp
, 0);
2535 print_vector_info (struct ui_file
*file
,
2536 struct frame_info
*frame
, const char *args
)
2538 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2540 if (gdbarch_print_vector_info_p (gdbarch
))
2541 gdbarch_print_vector_info (gdbarch
, file
, frame
, args
);
2545 int printed_something
= 0;
2548 regnum
< gdbarch_num_regs (gdbarch
)
2549 + gdbarch_num_pseudo_regs (gdbarch
);
2552 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, vector_reggroup
))
2554 printed_something
= 1;
2555 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2558 if (!printed_something
)
2559 fprintf_filtered (file
, "No vector information\n");
2564 vector_info (char *args
, int from_tty
)
2566 if (!target_has_registers
)
2567 error (_("The program has no registers now."));
2569 print_vector_info (gdb_stdout
, get_selected_frame (NULL
), args
);
2572 /* Kill the inferior process. Make us have no inferior. */
2575 kill_command (char *arg
, int from_tty
)
2577 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2578 It should be a distinct flag that indicates that a target is active, cuz
2579 some targets don't have processes! */
2581 if (ptid_equal (inferior_ptid
, null_ptid
))
2582 error (_("The program is not being run."));
2583 if (!query (_("Kill the program being debugged? ")))
2584 error (_("Not confirmed."));
2587 /* If we still have other inferiors to debug, then don't mess with
2588 with their threads. */
2589 if (!have_inferiors ())
2591 init_thread_list (); /* Destroy thread info. */
2593 /* Killing off the inferior can leave us with a core file. If
2594 so, print the state we are left in. */
2595 if (target_has_stack
)
2597 printf_filtered (_("In %s,\n"), target_longname
);
2598 print_stack_frame (get_selected_frame (NULL
), 1, SRC_AND_LOC
, 1);
2601 bfd_cache_close_all ();
2604 /* Used in `attach&' command. ARG is a point to an integer
2605 representing a process id. Proceed threads of this process iff
2606 they stopped due to debugger request, and when they did, they
2607 reported a clean stop (GDB_SIGNAL_0). Do not proceed threads
2608 that have been explicitly been told to stop. */
2611 proceed_after_attach_callback (struct thread_info
*thread
,
2614 int pid
= * (int *) arg
;
2616 if (ptid_get_pid (thread
->ptid
) == pid
2617 && !is_exited (thread
->ptid
)
2618 && !is_executing (thread
->ptid
)
2619 && !thread
->stop_requested
2620 && thread
->suspend
.stop_signal
== GDB_SIGNAL_0
)
2622 switch_to_thread (thread
->ptid
);
2623 clear_proceed_status (0);
2624 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
2631 proceed_after_attach (int pid
)
2633 /* Don't error out if the current thread is running, because
2634 there may be other stopped threads. */
2635 struct cleanup
*old_chain
;
2637 /* Backup current thread and selected frame. */
2638 old_chain
= make_cleanup_restore_current_thread ();
2640 iterate_over_threads (proceed_after_attach_callback
, &pid
);
2642 /* Restore selected ptid. */
2643 do_cleanups (old_chain
);
2646 /* See inferior.h. */
2649 setup_inferior (int from_tty
)
2651 struct inferior
*inferior
;
2653 inferior
= current_inferior ();
2654 inferior
->needs_setup
= 0;
2656 /* If no exec file is yet known, try to determine it from the
2658 if (get_exec_file (0) == NULL
)
2659 exec_file_locate_attach (ptid_get_pid (inferior_ptid
), from_tty
);
2662 reopen_exec_file ();
2666 /* Take any necessary post-attaching actions for this platform. */
2667 target_post_attach (ptid_get_pid (inferior_ptid
));
2669 post_create_inferior (¤t_target
, from_tty
);
2672 /* What to do after the first program stops after attaching. */
2673 enum attach_post_wait_mode
2675 /* Do nothing. Leaves threads as they are. */
2676 ATTACH_POST_WAIT_NOTHING
,
2678 /* Re-resume threads that are marked running. */
2679 ATTACH_POST_WAIT_RESUME
,
2681 /* Stop all threads. */
2682 ATTACH_POST_WAIT_STOP
,
2685 /* Called after we've attached to a process and we've seen it stop for
2686 the first time. If ASYNC_EXEC is true, re-resume threads that
2687 should be running. Else if ATTACH, */
2690 attach_post_wait (char *args
, int from_tty
, enum attach_post_wait_mode mode
)
2692 struct inferior
*inferior
;
2694 inferior
= current_inferior ();
2695 inferior
->control
.stop_soon
= NO_STOP_QUIETLY
;
2697 if (inferior
->needs_setup
)
2698 setup_inferior (from_tty
);
2700 if (mode
== ATTACH_POST_WAIT_RESUME
)
2702 /* The user requested an `attach&', so be sure to leave threads
2703 that didn't get a signal running. */
2705 /* Immediatelly resume all suspended threads of this inferior,
2706 and this inferior only. This should have no effect on
2707 already running threads. If a thread has been stopped with a
2708 signal, leave it be. */
2710 proceed_after_attach (inferior
->pid
);
2713 if (inferior_thread ()->suspend
.stop_signal
== GDB_SIGNAL_0
)
2715 clear_proceed_status (0);
2716 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
2720 else if (mode
== ATTACH_POST_WAIT_STOP
)
2722 /* The user requested a plain `attach', so be sure to leave
2723 the inferior stopped. */
2725 /* At least the current thread is already stopped. */
2727 /* In all-stop, by definition, all threads have to be already
2728 stopped at this point. In non-stop, however, although the
2729 selected thread is stopped, others may still be executing.
2730 Be sure to explicitly stop all threads of the process. This
2731 should have no effect on already stopped threads. */
2733 target_stop (pid_to_ptid (inferior
->pid
));
2734 else if (target_is_non_stop_p ())
2736 struct thread_info
*thread
;
2737 struct thread_info
*lowest
= inferior_thread ();
2738 int pid
= current_inferior ()->pid
;
2740 stop_all_threads ();
2742 /* It's not defined which thread will report the attach
2743 stop. For consistency, always select the thread with
2744 lowest GDB number, which should be the main thread, if it
2746 ALL_NON_EXITED_THREADS (thread
)
2748 if (ptid_get_pid (thread
->ptid
) == pid
)
2750 if (thread
->inf
->num
< lowest
->inf
->num
2751 || thread
->per_inf_num
< lowest
->per_inf_num
)
2756 switch_to_thread (lowest
->ptid
);
2759 /* Tell the user/frontend where we're stopped. */
2761 if (deprecated_attach_hook
)
2762 deprecated_attach_hook ();
2766 struct attach_command_continuation_args
2770 enum attach_post_wait_mode mode
;
2774 attach_command_continuation (void *args
, int err
)
2776 struct attach_command_continuation_args
*a
2777 = (struct attach_command_continuation_args
*) args
;
2782 attach_post_wait (a
->args
, a
->from_tty
, a
->mode
);
2786 attach_command_continuation_free_args (void *args
)
2788 struct attach_command_continuation_args
*a
2789 = (struct attach_command_continuation_args
*) args
;
2795 /* "attach" command entry point. Takes a program started up outside
2796 of gdb and ``attaches'' to it. This stops it cold in its tracks
2797 and allows us to start debugging it. */
2800 attach_command (char *args
, int from_tty
)
2803 struct cleanup
*args_chain
;
2804 struct target_ops
*attach_target
;
2805 struct inferior
*inferior
= current_inferior ();
2806 enum attach_post_wait_mode mode
;
2808 dont_repeat (); /* Not for the faint of heart */
2810 if (gdbarch_has_global_solist (target_gdbarch ()))
2811 /* Don't complain if all processes share the same symbol
2814 else if (target_has_execution
)
2816 if (query (_("A program is being debugged already. Kill it? ")))
2819 error (_("Not killed."));
2822 /* Clean up any leftovers from other runs. Some other things from
2823 this function should probably be moved into target_pre_inferior. */
2824 target_pre_inferior (from_tty
);
2826 args
= strip_bg_char (args
, &async_exec
);
2827 args_chain
= make_cleanup (xfree
, args
);
2829 attach_target
= find_attach_target ();
2831 prepare_execution_command (attach_target
, async_exec
);
2833 if (non_stop
&& !attach_target
->to_supports_non_stop (attach_target
))
2834 error (_("Cannot attach to this target in non-stop mode"));
2836 attach_target
->to_attach (attach_target
, args
, from_tty
);
2837 /* to_attach should push the target, so after this point we
2838 shouldn't refer to attach_target again. */
2839 attach_target
= NULL
;
2841 /* Set up the "saved terminal modes" of the inferior
2842 based on what modes we are starting it with. */
2843 target_terminal_init ();
2845 /* Install inferior's terminal modes. This may look like a no-op,
2846 as we've just saved them above, however, this does more than
2847 restore terminal settings:
2849 - installs a SIGINT handler that forwards SIGINT to the inferior.
2850 Otherwise a Ctrl-C pressed just while waiting for the initial
2851 stop would end up as a spurious Quit.
2853 - removes stdin from the event loop, which we need if attaching
2854 in the foreground, otherwise on targets that report an initial
2855 stop on attach (which are most) we'd process input/commands
2856 while we're in the event loop waiting for that stop. That is,
2857 before the attach continuation runs and the command is really
2859 target_terminal_inferior ();
2861 /* Set up execution context to know that we should return from
2862 wait_for_inferior as soon as the target reports a stop. */
2863 init_wait_for_inferior ();
2864 clear_proceed_status (0);
2866 inferior
->needs_setup
= 1;
2868 if (target_is_non_stop_p ())
2870 /* If we find that the current thread isn't stopped, explicitly
2871 do so now, because we're going to install breakpoints and
2875 /* The user requested an `attach&'; stop just one thread. */
2876 target_stop (inferior_ptid
);
2878 /* The user requested an `attach', so stop all threads of this
2880 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid
)));
2883 mode
= async_exec
? ATTACH_POST_WAIT_RESUME
: ATTACH_POST_WAIT_STOP
;
2885 /* Some system don't generate traps when attaching to inferior.
2886 E.g. Mach 3 or GNU hurd. */
2887 if (!target_attach_no_wait
)
2889 struct attach_command_continuation_args
*a
;
2891 /* Careful here. See comments in inferior.h. Basically some
2892 OSes don't ignore SIGSTOPs on continue requests anymore. We
2893 need a way for handle_inferior_event to reset the stop_signal
2894 variable after an attach, and this is what
2895 STOP_QUIETLY_NO_SIGSTOP is for. */
2896 inferior
->control
.stop_soon
= STOP_QUIETLY_NO_SIGSTOP
;
2898 /* Wait for stop. */
2899 a
= XNEW (struct attach_command_continuation_args
);
2900 a
->args
= xstrdup (args
);
2901 a
->from_tty
= from_tty
;
2903 add_inferior_continuation (attach_command_continuation
, a
,
2904 attach_command_continuation_free_args
);
2905 /* Done with ARGS. */
2906 do_cleanups (args_chain
);
2908 if (!target_is_async_p ())
2909 mark_infrun_async_event_handler ();
2913 /* Done with ARGS. */
2914 do_cleanups (args_chain
);
2916 attach_post_wait (args
, from_tty
, mode
);
2919 /* We had just found out that the target was already attached to an
2920 inferior. PTID points at a thread of this new inferior, that is
2921 the most likely to be stopped right now, but not necessarily so.
2922 The new inferior is assumed to be already added to the inferior
2923 list at this point. If LEAVE_RUNNING, then leave the threads of
2924 this inferior running, except those we've explicitly seen reported
2928 notice_new_inferior (ptid_t ptid
, int leave_running
, int from_tty
)
2930 struct cleanup
* old_chain
;
2931 enum attach_post_wait_mode mode
;
2933 old_chain
= make_cleanup (null_cleanup
, NULL
);
2935 mode
= leave_running
? ATTACH_POST_WAIT_RESUME
: ATTACH_POST_WAIT_NOTHING
;
2937 if (!ptid_equal (inferior_ptid
, null_ptid
))
2938 make_cleanup_restore_current_thread ();
2940 /* Avoid reading registers -- we haven't fetched the target
2942 switch_to_thread_no_regs (find_thread_ptid (ptid
));
2944 /* When we "notice" a new inferior we need to do all the things we
2945 would normally do if we had just attached to it. */
2947 if (is_executing (inferior_ptid
))
2949 struct attach_command_continuation_args
*a
;
2950 struct inferior
*inferior
= current_inferior ();
2952 /* We're going to install breakpoints, and poke at memory,
2953 ensure that the inferior is stopped for a moment while we do
2955 target_stop (inferior_ptid
);
2957 inferior
->control
.stop_soon
= STOP_QUIETLY_REMOTE
;
2959 /* Wait for stop before proceeding. */
2960 a
= XNEW (struct attach_command_continuation_args
);
2961 a
->args
= xstrdup ("");
2962 a
->from_tty
= from_tty
;
2964 add_inferior_continuation (attach_command_continuation
, a
,
2965 attach_command_continuation_free_args
);
2967 do_cleanups (old_chain
);
2971 attach_post_wait ("" /* args */, from_tty
, mode
);
2973 do_cleanups (old_chain
);
2978 * takes a program previously attached to and detaches it.
2979 * The program resumes execution and will no longer stop
2980 * on signals, etc. We better not have left any breakpoints
2981 * in the program or it'll die when it hits one. For this
2982 * to work, it may be necessary for the process to have been
2983 * previously attached. It *might* work if the program was
2984 * started via the normal ptrace (PTRACE_TRACEME).
2988 detach_command (char *args
, int from_tty
)
2990 dont_repeat (); /* Not for the faint of heart. */
2992 if (ptid_equal (inferior_ptid
, null_ptid
))
2993 error (_("The program is not being run."));
2995 query_if_trace_running (from_tty
);
2997 disconnect_tracing ();
2999 target_detach (args
, from_tty
);
3001 /* If the solist is global across inferiors, don't clear it when we
3002 detach from a single inferior. */
3003 if (!gdbarch_has_global_solist (target_gdbarch ()))
3004 no_shared_libraries (NULL
, from_tty
);
3006 /* If we still have inferiors to debug, then don't mess with their
3008 if (!have_inferiors ())
3009 init_thread_list ();
3011 if (deprecated_detach_hook
)
3012 deprecated_detach_hook ();
3015 /* Disconnect from the current target without resuming it (leaving it
3016 waiting for a debugger).
3018 We'd better not have left any breakpoints in the program or the
3019 next debugger will get confused. Currently only supported for some
3020 remote targets, since the normal attach mechanisms don't work on
3021 stopped processes on some native platforms (e.g. GNU/Linux). */
3024 disconnect_command (char *args
, int from_tty
)
3026 dont_repeat (); /* Not for the faint of heart. */
3027 query_if_trace_running (from_tty
);
3028 disconnect_tracing ();
3029 target_disconnect (args
, from_tty
);
3030 no_shared_libraries (NULL
, from_tty
);
3031 init_thread_list ();
3032 if (deprecated_detach_hook
)
3033 deprecated_detach_hook ();
3037 interrupt_target_1 (int all_threads
)
3042 ptid
= minus_one_ptid
;
3044 ptid
= inferior_ptid
;
3049 target_interrupt (ptid
);
3051 /* Tag the thread as having been explicitly requested to stop, so
3052 other parts of gdb know not to resume this thread automatically,
3053 if it was stopped due to an internal event. Limit this to
3054 non-stop mode, as when debugging a multi-threaded application in
3055 all-stop mode, we will only get one stop event --- it's undefined
3056 which thread will report the event. */
3058 set_stop_requested (ptid
, 1);
3062 Stop the execution of the target while running in async mode, in
3063 the backgound. In all-stop, stop the whole process. In non-stop
3064 mode, stop the current thread only by default, or stop all threads
3065 if the `-a' switch is used. */
3068 interrupt_command (char *args
, int from_tty
)
3070 if (target_can_async_p ())
3072 int all_threads
= 0;
3074 dont_repeat (); /* Not for the faint of heart. */
3077 && startswith (args
, "-a"))
3080 if (!non_stop
&& all_threads
)
3081 error (_("-a is meaningless in all-stop mode."));
3083 interrupt_target_1 (all_threads
);
3087 /* See inferior.h. */
3090 default_print_float_info (struct gdbarch
*gdbarch
, struct ui_file
*file
,
3091 struct frame_info
*frame
, const char *args
)
3094 int printed_something
= 0;
3097 regnum
< gdbarch_num_regs (gdbarch
)
3098 + gdbarch_num_pseudo_regs (gdbarch
);
3101 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, float_reggroup
))
3103 printed_something
= 1;
3104 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
3107 if (!printed_something
)
3108 fprintf_filtered (file
, "No floating-point info "
3109 "available for this processor.\n");
3113 float_info (char *args
, int from_tty
)
3115 struct frame_info
*frame
;
3117 if (!target_has_registers
)
3118 error (_("The program has no registers now."));
3120 frame
= get_selected_frame (NULL
);
3121 gdbarch_print_float_info (get_frame_arch (frame
), gdb_stdout
, frame
, args
);
3125 unset_command (char *args
, int from_tty
)
3127 printf_filtered (_("\"unset\" must be followed by the "
3128 "name of an unset subcommand.\n"));
3129 help_list (unsetlist
, "unset ", all_commands
, gdb_stdout
);
3132 /* Implement `info proc' family of commands. */
3135 info_proc_cmd_1 (char *args
, enum info_proc_what what
, int from_tty
)
3137 struct gdbarch
*gdbarch
= get_current_arch ();
3139 if (!target_info_proc (args
, what
))
3141 if (gdbarch_info_proc_p (gdbarch
))
3142 gdbarch_info_proc (gdbarch
, args
, what
);
3144 error (_("Not supported on this target."));
3148 /* Implement `info proc' when given without any futher parameters. */
3151 info_proc_cmd (char *args
, int from_tty
)
3153 info_proc_cmd_1 (args
, IP_MINIMAL
, from_tty
);
3156 /* Implement `info proc mappings'. */
3159 info_proc_cmd_mappings (char *args
, int from_tty
)
3161 info_proc_cmd_1 (args
, IP_MAPPINGS
, from_tty
);
3164 /* Implement `info proc stat'. */
3167 info_proc_cmd_stat (char *args
, int from_tty
)
3169 info_proc_cmd_1 (args
, IP_STAT
, from_tty
);
3172 /* Implement `info proc status'. */
3175 info_proc_cmd_status (char *args
, int from_tty
)
3177 info_proc_cmd_1 (args
, IP_STATUS
, from_tty
);
3180 /* Implement `info proc cwd'. */
3183 info_proc_cmd_cwd (char *args
, int from_tty
)
3185 info_proc_cmd_1 (args
, IP_CWD
, from_tty
);
3188 /* Implement `info proc cmdline'. */
3191 info_proc_cmd_cmdline (char *args
, int from_tty
)
3193 info_proc_cmd_1 (args
, IP_CMDLINE
, from_tty
);
3196 /* Implement `info proc exe'. */
3199 info_proc_cmd_exe (char *args
, int from_tty
)
3201 info_proc_cmd_1 (args
, IP_EXE
, from_tty
);
3204 /* Implement `info proc all'. */
3207 info_proc_cmd_all (char *args
, int from_tty
)
3209 info_proc_cmd_1 (args
, IP_ALL
, from_tty
);
3213 _initialize_infcmd (void)
3215 static struct cmd_list_element
*info_proc_cmdlist
;
3216 struct cmd_list_element
*c
= NULL
;
3217 const char *cmd_name
;
3219 /* Add the filename of the terminal connected to inferior I/O. */
3220 add_setshow_filename_cmd ("inferior-tty", class_run
,
3221 &inferior_io_terminal_scratch
, _("\
3222 Set terminal for future runs of program being debugged."), _("\
3223 Show terminal for future runs of program being debugged."), _("\
3224 Usage: set inferior-tty /dev/pts/1"),
3225 set_inferior_tty_command
,
3226 show_inferior_tty_command
,
3227 &setlist
, &showlist
);
3228 add_com_alias ("tty", "set inferior-tty", class_alias
, 0);
3231 add_setshow_string_noescape_cmd (cmd_name
, class_run
,
3232 &inferior_args_scratch
, _("\
3233 Set argument list to give program being debugged when it is started."), _("\
3234 Show argument list to give program being debugged when it is started."), _("\
3235 Follow this command with any number of args, to be passed to the program."),
3238 &setlist
, &showlist
);
3239 c
= lookup_cmd (&cmd_name
, setlist
, "", -1, 1);
3240 gdb_assert (c
!= NULL
);
3241 set_cmd_completer (c
, filename_completer
);
3243 c
= add_cmd ("environment", no_class
, environment_info
, _("\
3244 The environment to give the program, or one variable's value.\n\
3245 With an argument VAR, prints the value of environment variable VAR to\n\
3246 give the program being debugged. With no arguments, prints the entire\n\
3247 environment to be given to the program."), &showlist
);
3248 set_cmd_completer (c
, noop_completer
);
3250 add_prefix_cmd ("unset", no_class
, unset_command
,
3251 _("Complement to certain \"set\" commands."),
3252 &unsetlist
, "unset ", 0, &cmdlist
);
3254 c
= add_cmd ("environment", class_run
, unset_environment_command
, _("\
3255 Cancel environment variable VAR for the program.\n\
3256 This does not affect the program until the next \"run\" command."),
3258 set_cmd_completer (c
, noop_completer
);
3260 c
= add_cmd ("environment", class_run
, set_environment_command
, _("\
3261 Set environment variable value to give the program.\n\
3262 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
3263 VALUES of environment variables are uninterpreted strings.\n\
3264 This does not affect the program until the next \"run\" command."),
3266 set_cmd_completer (c
, noop_completer
);
3268 c
= add_com ("path", class_files
, path_command
, _("\
3269 Add directory DIR(s) to beginning of search path for object files.\n\
3270 $cwd in the path means the current working directory.\n\
3271 This path is equivalent to the $PATH shell variable. It is a list of\n\
3272 directories, separated by colons. These directories are searched to find\n\
3273 fully linked executable files and separately compiled object files as \
3275 set_cmd_completer (c
, filename_completer
);
3277 c
= add_cmd ("paths", no_class
, path_info
, _("\
3278 Current search path for finding object files.\n\
3279 $cwd in the path means the current working directory.\n\
3280 This path is equivalent to the $PATH shell variable. It is a list of\n\
3281 directories, separated by colons. These directories are searched to find\n\
3282 fully linked executable files and separately compiled object files as \
3285 set_cmd_completer (c
, noop_completer
);
3287 add_prefix_cmd ("kill", class_run
, kill_command
,
3288 _("Kill execution of program being debugged."),
3289 &killlist
, "kill ", 0, &cmdlist
);
3291 add_com ("attach", class_run
, attach_command
, _("\
3292 Attach to a process or file outside of GDB.\n\
3293 This command attaches to another target, of the same type as your last\n\
3294 \"target\" command (\"info files\" will show your target stack).\n\
3295 The command may take as argument a process id or a device file.\n\
3296 For a process id, you must have permission to send the process a signal,\n\
3297 and it must have the same effective uid as the debugger.\n\
3298 When using \"attach\" with a process id, the debugger finds the\n\
3299 program running in the process, looking first in the current working\n\
3300 directory, or (if not found there) using the source file search path\n\
3301 (see the \"directory\" command). You can also use the \"file\" command\n\
3302 to specify the program, and to load its symbol table."));
3304 add_prefix_cmd ("detach", class_run
, detach_command
, _("\
3305 Detach a process or file previously attached.\n\
3306 If a process, it is no longer traced, and it continues its execution. If\n\
3307 you were debugging a file, the file is closed and gdb no longer accesses it."),
3308 &detachlist
, "detach ", 0, &cmdlist
);
3310 add_com ("disconnect", class_run
, disconnect_command
, _("\
3311 Disconnect from a target.\n\
3312 The target will wait for another debugger to connect. Not available for\n\
3315 c
= add_com ("signal", class_run
, signal_command
, _("\
3316 Continue program with the specified signal.\n\
3317 Usage: signal SIGNAL\n\
3318 The SIGNAL argument is processed the same as the handle command.\n\
3320 An argument of \"0\" means continue the program without sending it a signal.\n\
3321 This is useful in cases where the program stopped because of a signal,\n\
3322 and you want to resume the program while discarding the signal.\n\
3324 In a multi-threaded program the signal is delivered to, or discarded from,\n\
3325 the current thread only."));
3326 set_cmd_completer (c
, signal_completer
);
3328 c
= add_com ("queue-signal", class_run
, queue_signal_command
, _("\
3329 Queue a signal to be delivered to the current thread when it is resumed.\n\
3330 Usage: queue-signal SIGNAL\n\
3331 The SIGNAL argument is processed the same as the handle command.\n\
3332 It is an error if the handling state of SIGNAL is \"nopass\".\n\
3334 An argument of \"0\" means remove any currently queued signal from\n\
3335 the current thread. This is useful in cases where the program stopped\n\
3336 because of a signal, and you want to resume it while discarding the signal.\n\
3338 In a multi-threaded program the signal is queued with, or discarded from,\n\
3339 the current thread only."));
3340 set_cmd_completer (c
, signal_completer
);
3342 add_com ("stepi", class_run
, stepi_command
, _("\
3343 Step one instruction exactly.\n\
3345 Argument N means step N times (or till program stops for another \
3347 add_com_alias ("si", "stepi", class_alias
, 0);
3349 add_com ("nexti", class_run
, nexti_command
, _("\
3350 Step one instruction, but proceed through subroutine calls.\n\
3352 Argument N means step N times (or till program stops for another \
3354 add_com_alias ("ni", "nexti", class_alias
, 0);
3356 add_com ("finish", class_run
, finish_command
, _("\
3357 Execute until selected stack frame returns.\n\
3359 Upon return, the value returned is printed and put in the value history."));
3360 add_com_alias ("fin", "finish", class_run
, 1);
3362 add_com ("next", class_run
, next_command
, _("\
3363 Step program, proceeding through subroutine calls.\n\
3365 Unlike \"step\", if the current source line calls a subroutine,\n\
3366 this command does not enter the subroutine, but instead steps over\n\
3367 the call, in effect treating it as a single source line."));
3368 add_com_alias ("n", "next", class_run
, 1);
3370 add_com ("step", class_run
, step_command
, _("\
3371 Step program until it reaches a different source line.\n\
3373 Argument N means step N times (or till program stops for another \
3375 add_com_alias ("s", "step", class_run
, 1);
3377 c
= add_com ("until", class_run
, until_command
, _("\
3378 Execute until the program reaches a source line greater than the current\n\
3379 or a specified location (same args as break command) within the current \
3381 set_cmd_completer (c
, location_completer
);
3382 add_com_alias ("u", "until", class_run
, 1);
3384 c
= add_com ("advance", class_run
, advance_command
, _("\
3385 Continue the program up to the given location (same form as args for break \
3387 Execution will also stop upon exit from the current stack frame."));
3388 set_cmd_completer (c
, location_completer
);
3390 c
= add_com ("jump", class_run
, jump_command
, _("\
3391 Continue program being debugged at specified line or address.\n\
3392 Usage: jump <location>\n\
3393 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
3394 for an address to start at."));
3395 set_cmd_completer (c
, location_completer
);
3396 add_com_alias ("j", "jump", class_run
, 1);
3398 add_com ("continue", class_run
, continue_command
, _("\
3399 Continue program being debugged, after signal or breakpoint.\n\
3400 Usage: continue [N]\n\
3401 If proceeding from breakpoint, a number N may be used as an argument,\n\
3402 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
3403 the breakpoint won't break until the Nth time it is reached).\n\
3405 If non-stop mode is enabled, continue only the current thread,\n\
3406 otherwise all the threads in the program are continued. To \n\
3407 continue all stopped threads in non-stop mode, use the -a option.\n\
3408 Specifying -a and an ignore count simultaneously is an error."));
3409 add_com_alias ("c", "cont", class_run
, 1);
3410 add_com_alias ("fg", "cont", class_run
, 1);
3412 c
= add_com ("run", class_run
, run_command
, _("\
3413 Start debugged program. You may specify arguments to give it.\n\
3414 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
3415 Input and output redirection with \">\", \"<\", or \">>\" are also \
3417 With no arguments, uses arguments last specified (with \"run\" \
3418 or \"set args\").\n\
3419 To cancel previous arguments and run with no arguments,\n\
3420 use \"set args\" without arguments."));
3421 set_cmd_completer (c
, filename_completer
);
3422 add_com_alias ("r", "run", class_run
, 1);
3424 c
= add_com ("start", class_run
, start_command
, _("\
3425 Run the debugged program until the beginning of the main procedure.\n\
3426 You may specify arguments to give to your program, just as with the\n\
3427 \"run\" command."));
3428 set_cmd_completer (c
, filename_completer
);
3430 add_com ("interrupt", class_run
, interrupt_command
,
3431 _("Interrupt the execution of the debugged program.\n\
3432 If non-stop mode is enabled, interrupt only the current thread,\n\
3433 otherwise all the threads in the program are stopped. To \n\
3434 interrupt all running threads in non-stop mode, use the -a option."));
3436 c
= add_info ("registers", nofp_registers_info
, _("\
3437 List of integer registers and their contents, for selected stack frame.\n\
3438 Register name as argument means describe only that register."));
3439 add_info_alias ("r", "registers", 1);
3440 set_cmd_completer (c
, reg_or_group_completer
);
3442 c
= add_info ("all-registers", all_registers_info
, _("\
3443 List of all registers and their contents, for selected stack frame.\n\
3444 Register name as argument means describe only that register."));
3445 set_cmd_completer (c
, reg_or_group_completer
);
3447 add_info ("program", program_info
,
3448 _("Execution status of the program."));
3450 add_info ("float", float_info
,
3451 _("Print the status of the floating point unit\n"));
3453 add_info ("vector", vector_info
,
3454 _("Print the status of the vector unit\n"));
3456 add_prefix_cmd ("proc", class_info
, info_proc_cmd
,
3458 Show /proc process information about any running process.\n\
3459 Specify any process id, or use the program being debugged by default."),
3460 &info_proc_cmdlist
, "info proc ",
3461 1/*allow-unknown*/, &infolist
);
3463 add_cmd ("mappings", class_info
, info_proc_cmd_mappings
, _("\
3464 List of mapped memory regions."),
3465 &info_proc_cmdlist
);
3467 add_cmd ("stat", class_info
, info_proc_cmd_stat
, _("\
3468 List process info from /proc/PID/stat."),
3469 &info_proc_cmdlist
);
3471 add_cmd ("status", class_info
, info_proc_cmd_status
, _("\
3472 List process info from /proc/PID/status."),
3473 &info_proc_cmdlist
);
3475 add_cmd ("cwd", class_info
, info_proc_cmd_cwd
, _("\
3476 List current working directory of the process."),
3477 &info_proc_cmdlist
);
3479 add_cmd ("cmdline", class_info
, info_proc_cmd_cmdline
, _("\
3480 List command line arguments of the process."),
3481 &info_proc_cmdlist
);
3483 add_cmd ("exe", class_info
, info_proc_cmd_exe
, _("\
3484 List absolute filename for executable of the process."),
3485 &info_proc_cmdlist
);
3487 add_cmd ("all", class_info
, info_proc_cmd_all
, _("\
3488 List all available /proc info."),
3489 &info_proc_cmdlist
);