1 /* Memory-access and commands for "inferior" process, for GDB.
3 Copyright (C) 1986-2023 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"
27 #include "gdbsupport/environ.h"
35 #include "completer.h"
38 #include "reggroups.h"
42 #include "observable.h"
43 #include "target-descriptions.h"
44 #include "user-regs.h"
45 #include "gdbthread.h"
47 #include "inline-frame.h"
48 #include "tracepoint.h"
51 #include "thread-fsm.h"
55 #include "gdbsupport/gdb_optional.h"
57 #include "cli/cli-style.h"
58 #include "dwarf2/loc.h"
60 /* Local functions: */
62 static void until_next_command (int);
64 static void step_1 (int, int, const char *);
66 #define ERROR_NO_INFERIOR \
67 if (!target_has_execution ()) error (_("The program is not being run."));
69 /* Scratch area where string containing arguments to give to the
70 program will be stored by 'set args'. As soon as anything is
71 stored, notice_args_set will move it into per-inferior storage.
72 Arguments are separated by spaces. Empty string (pointer to '\0')
75 static std::string inferior_args_scratch
;
77 /* Scratch area where the new cwd will be stored by 'set cwd'. */
79 static std::string inferior_cwd_scratch
;
81 /* Scratch area where 'set inferior-tty' will store user-provided value.
82 We'll immediate copy it into per-inferior storage. */
84 static std::string inferior_io_terminal_scratch
;
86 /* Pid of our debugged inferior, or 0 if no inferior now.
87 Since various parts of infrun.c test this to see whether there is a program
88 being debugged it should be nonzero (currently 3 is used) for remote
93 /* Nonzero if stopped due to completion of a stack dummy routine. */
95 enum stop_stack_kind stop_stack_dummy
;
97 /* Nonzero if stopped due to a random (unexpected) signal in inferior
100 int stopped_by_random_signal
;
103 /* Whether "finish" should print the value. */
105 static bool finish_print
= true;
110 set_inferior_tty_command (const char *args
, int from_tty
,
111 struct cmd_list_element
*c
)
113 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
114 Now route it to current inferior. */
115 current_inferior ()->set_tty (inferior_io_terminal_scratch
);
119 show_inferior_tty_command (struct ui_file
*file
, int from_tty
,
120 struct cmd_list_element
*c
, const char *value
)
122 /* Note that we ignore the passed-in value in favor of computing it
124 const std::string
&inferior_tty
= current_inferior ()->tty ();
127 _("Terminal for future runs of program being debugged "
128 "is \"%s\".\n"), inferior_tty
.c_str ());
132 set_inferior_args_vector (int argc
, char **argv
)
134 gdb::array_view
<char * const> args (argv
, argc
);
135 std::string n
= construct_inferior_arguments (args
);
136 current_inferior ()->set_args (std::move (n
));
139 /* Notice when `set args' is run. */
142 set_args_command (const char *args
, int from_tty
, struct cmd_list_element
*c
)
144 /* CLI has assigned the user-provided value to inferior_args_scratch.
145 Now route it to current inferior. */
146 current_inferior ()->set_args (inferior_args_scratch
);
149 /* Notice when `show args' is run. */
152 show_args_command (struct ui_file
*file
, int from_tty
,
153 struct cmd_list_element
*c
, const char *value
)
155 /* Note that we ignore the passed-in value in favor of computing it
157 deprecated_show_value_hack (file
, from_tty
, c
,
158 current_inferior ()->args ().c_str ());
161 /* See gdbsupport/common-inferior.h. */
166 return current_inferior ()->cwd ();
169 /* Handle the 'set cwd' command. */
172 set_cwd_command (const char *args
, int from_tty
, struct cmd_list_element
*c
)
174 current_inferior ()->set_cwd (inferior_cwd_scratch
);
177 /* Handle the 'show cwd' command. */
180 show_cwd_command (struct ui_file
*file
, int from_tty
,
181 struct cmd_list_element
*c
, const char *value
)
183 const std::string
&cwd
= current_inferior ()->cwd ();
188 You have not set the inferior's current working directory.\n\
189 The inferior will inherit GDB's cwd if native debugging, or the remote\n\
190 server's cwd if remote debugging.\n"));
193 _("Current working directory that will be used "
194 "when starting the inferior is \"%s\".\n"),
199 /* This function strips the '&' character (indicating background
200 execution) that is added as *the last* of the arguments ARGS of a
201 command. A copy of the incoming ARGS without the '&' is returned,
202 unless the resulting string after stripping is empty, in which case
203 NULL is returned. *BG_CHAR_P is an output boolean that indicates
204 whether the '&' character was found. */
206 static gdb::unique_xmalloc_ptr
<char>
207 strip_bg_char (const char *args
, int *bg_char_p
)
211 if (args
== nullptr || *args
== '\0')
217 p
= args
+ strlen (args
);
221 while (p
> args
&& isspace (p
[-1]))
226 return gdb::unique_xmalloc_ptr
<char>
227 (savestring (args
, p
- args
));
229 return gdb::unique_xmalloc_ptr
<char> (nullptr);
233 return make_unique_xstrdup (args
);
236 /* Common actions to take after creating any sort of inferior, by any
237 means (running, attaching, connecting, et cetera). The target
238 should be stopped. */
241 post_create_inferior (int from_tty
)
244 /* Be sure we own the terminal in case write operations are performed. */
245 target_terminal::ours_for_output ();
247 infrun_debug_show_threads ("threads in the newly created inferior",
248 current_inferior ()->non_exited_threads ());
250 /* If the target hasn't taken care of this already, do it now.
251 Targets which need to access registers during to_open,
252 to_create_inferior, or to_attach should do it earlier; but many
254 target_find_description ();
256 /* Now that we know the register layout, retrieve current PC. But
257 if the PC is unavailable (e.g., we're opening a core file with
258 missing registers info), ignore it. */
259 thread_info
*thr
= inferior_thread ();
261 thr
->clear_stop_pc ();
264 regcache
*rc
= get_thread_regcache (thr
);
265 thr
->set_stop_pc (regcache_read_pc (rc
));
267 catch (const gdb_exception_error
&ex
)
269 if (ex
.error
!= NOT_AVAILABLE_ERROR
)
273 if (current_program_space
->exec_bfd ())
275 const unsigned solib_add_generation
276 = current_program_space
->solib_add_generation
;
278 scoped_restore restore_in_initial_library_scan
279 = make_scoped_restore (¤t_inferior ()->in_initial_library_scan
,
282 /* Create the hooks to handle shared library load and unload
284 solib_create_inferior_hook (from_tty
);
286 if (current_program_space
->solib_add_generation
== solib_add_generation
)
288 /* The platform-specific hook should load initial shared libraries,
289 but didn't. FROM_TTY will be incorrectly 0 but such solib
290 targets should be fixed anyway. Call it only after the solib
291 target has been initialized by solib_create_inferior_hook. */
294 warning (_("platform-specific solib_create_inferior_hook did "
295 "not load initial shared libraries."));
297 /* If the solist is global across processes, there's no need to
299 if (!gdbarch_has_global_solist (target_gdbarch ()))
300 solib_add (nullptr, 0, auto_solib_add
);
304 /* If the user sets watchpoints before execution having started,
305 then she gets software watchpoints, because GDB can't know which
306 target will end up being pushed, or if it supports hardware
307 watchpoints or not. breakpoint_re_set takes care of promoting
308 watchpoints to hardware watchpoints if possible, however, if this
309 new inferior doesn't load shared libraries or we don't pull in
310 symbols from any other source on this target/arch,
311 breakpoint_re_set is never called. Call it now so that software
312 watchpoints get a chance to be promoted to hardware watchpoints
313 if the now pushed target supports hardware watchpoints. */
314 breakpoint_re_set ();
316 gdb::observers::inferior_created
.notify (current_inferior ());
319 /* Kill the inferior if already running. This function is designed
320 to be called when we are about to start the execution of the program
321 from the beginning. Ask the user to confirm that he wants to restart
322 the program being debugged when FROM_TTY is non-null. */
325 kill_if_already_running (int from_tty
)
327 if (inferior_ptid
!= null_ptid
&& target_has_execution ())
329 /* Bail out before killing the program if we will not be able to
331 target_require_runnable ();
334 && !query (_("The program being debugged has been started already.\n\
335 Start it from the beginning? ")))
336 error (_("Program not restarted."));
341 /* See inferior.h. */
344 prepare_execution_command (struct target_ops
*target
, int background
)
346 /* If we get a request for running in the bg but the target
347 doesn't support it, error out. */
348 if (background
&& !target_can_async_p (target
))
349 error (_("Asynchronous execution not supported on this target."));
353 /* If we get a request for running in the fg, then we need to
354 simulate synchronous (fg) execution. Note no cleanup is
355 necessary for this. stdin is re-enabled whenever an error
356 reaches the top level. */
357 all_uis_on_sync_execution_starting ();
361 /* Determine how the new inferior will behave. */
365 /* Run program without any explicit stop during startup. */
368 /* Stop at the beginning of the program's main function. */
371 /* Stop at the first instruction of the program. */
372 RUN_STOP_AT_FIRST_INSN
375 /* Implement the "run" command. Force a stop during program start if
376 requested by RUN_HOW. */
379 run_command_1 (const char *args
, int from_tty
, enum run_how run_how
)
381 const char *exec_file
;
382 struct ui_out
*uiout
= current_uiout
;
383 struct target_ops
*run_target
;
388 scoped_disable_commit_resumed
disable_commit_resumed ("running");
390 kill_if_already_running (from_tty
);
392 init_wait_for_inferior ();
393 clear_breakpoint_hit_counts ();
395 /* Clean up any leftovers from other runs. Some other things from
396 this function should probably be moved into target_pre_inferior. */
397 target_pre_inferior (from_tty
);
399 /* The comment here used to read, "The exec file is re-read every
400 time we do a generic_mourn_inferior, so we just have to worry
401 about the symbol file." The `generic_mourn_inferior' function
402 gets called whenever the program exits. However, suppose the
403 program exits, and *then* the executable file changes? We need
404 to check again here. Since reopen_exec_file doesn't do anything
405 if the timestamp hasn't changed, I don't see the harm. */
407 reread_symbols (from_tty
);
409 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (args
, &async_exec
);
410 args
= stripped
.get ();
412 /* Do validation and preparation before possibly changing anything
415 run_target
= find_run_target ();
417 prepare_execution_command (run_target
, async_exec
);
419 if (non_stop
&& !run_target
->supports_non_stop ())
420 error (_("The target does not support running in non-stop mode."));
422 /* Done. Can now set breakpoints, change inferior args, etc. */
424 /* Insert temporary breakpoint in main function if requested. */
425 if (run_how
== RUN_STOP_AT_MAIN
)
427 /* To avoid other inferiors hitting this breakpoint, make it
428 inferior-specific using a condition. A better solution would be to
429 have proper inferior-specific breakpoint support, in the breakpoint
430 machinery. We could then avoid inserting a breakpoint in the program
431 spaces unrelated to this inferior. */
433 = ((current_language
->la_language
== language_ada
434 || current_language
->la_language
== language_pascal
435 || current_language
->la_language
== language_m2
) ? "=" : "==");
436 std::string arg
= string_printf
437 ("-qualified %s if $_inferior %s %d", main_name (), op
,
438 current_inferior ()->num
);
439 tbreak_command (arg
.c_str (), 0);
442 exec_file
= get_exec_file (0);
444 /* We keep symbols from add-symbol-file, on the grounds that the
445 user might want to add some symbols before running the program
446 (right?). But sometimes (dynamic loading where the user manually
447 introduces the new symbols with add-symbol-file), the code which
448 the symbols describe does not persist between runs. Currently
449 the user has to manually nuke all symbols between runs if they
450 want them to go away (PR 2207). This is probably reasonable. */
452 /* If there were other args, beside '&', process them. */
454 current_inferior ()->set_args (args
);
458 uiout
->field_string (nullptr, "Starting program");
461 uiout
->field_string ("execfile", exec_file
,
462 file_name_style
.style ());
464 uiout
->field_string ("infargs", current_inferior ()->args ());
469 run_target
->create_inferior (exec_file
,
470 current_inferior ()->args (),
471 current_inferior ()->environment
.envp (),
473 /* to_create_inferior should push the target, so after this point we
474 shouldn't refer to run_target again. */
475 run_target
= nullptr;
477 infrun_debug_show_threads ("immediately after create_process",
478 current_inferior ()->non_exited_threads ());
480 /* We're starting off a new process. When we get out of here, in
481 non-stop mode, finish the state of all threads of that process,
482 but leave other threads alone, as they may be stopped in internal
483 events --- the frontend shouldn't see them as stopped. In
484 all-stop, always finish the state of all threads, as we may be
485 resuming more than just the new process. */
486 process_stratum_target
*finish_target
;
490 finish_target
= current_inferior ()->process_target ();
491 finish_ptid
= ptid_t (current_inferior ()->pid
);
495 finish_target
= nullptr;
496 finish_ptid
= minus_one_ptid
;
498 scoped_finish_thread_state
finish_state (finish_target
, finish_ptid
);
500 /* Pass zero for FROM_TTY, because at this point the "run" command
501 has done its thing; now we are setting up the running program. */
502 post_create_inferior (0);
504 /* Queue a pending event so that the program stops immediately. */
505 if (run_how
== RUN_STOP_AT_FIRST_INSN
)
507 thread_info
*thr
= inferior_thread ();
508 target_waitstatus ws
;
509 ws
.set_stopped (GDB_SIGNAL_0
);
510 thr
->set_pending_waitstatus (ws
);
513 /* Start the target running. Do not use -1 continuation as it would skip
514 breakpoint right at the entry point. */
515 proceed (regcache_read_pc (get_current_regcache ()), GDB_SIGNAL_0
);
517 /* Since there was no error, there's no need to finish the thread
519 finish_state
.release ();
521 disable_commit_resumed
.reset_and_commit ();
525 run_command (const char *args
, int from_tty
)
527 run_command_1 (args
, from_tty
, RUN_NORMAL
);
530 /* Start the execution of the program up until the beginning of the main
534 start_command (const char *args
, int from_tty
)
536 /* Some languages such as Ada need to search inside the program
537 minimal symbols for the location where to put the temporary
538 breakpoint before starting. */
539 if (!have_minimal_symbols ())
540 error (_("No symbol table loaded. Use the \"file\" command."));
542 /* Run the program until reaching the main procedure... */
543 run_command_1 (args
, from_tty
, RUN_STOP_AT_MAIN
);
546 /* Start the execution of the program stopping at the first
550 starti_command (const char *args
, int from_tty
)
552 run_command_1 (args
, from_tty
, RUN_STOP_AT_FIRST_INSN
);
556 proceed_thread_callback (struct thread_info
*thread
, void *arg
)
558 /* We go through all threads individually instead of compressing
559 into a single target `resume_all' request, because some threads
560 may be stopped in internal breakpoints/events, or stopped waiting
561 for its turn in the displaced stepping queue (that is, they are
562 running && !executing). The target side has no idea about why
563 the thread is stopped, so a `resume_all' command would resume too
564 much. If/when GDB gains a way to tell the target `hold this
565 thread stopped until I say otherwise', then we can optimize
567 if (thread
->state
!= THREAD_STOPPED
)
570 if (!thread
->inf
->has_execution ())
573 switch_to_thread (thread
);
574 clear_proceed_status (0);
575 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
580 ensure_valid_thread (void)
582 if (inferior_ptid
== null_ptid
583 || inferior_thread ()->state
== THREAD_EXITED
)
584 error (_("Cannot execute this command without a live selected thread."));
587 /* If the user is looking at trace frames, any resumption of execution
588 is likely to mix up recorded and live target data. So simply
589 disallow those commands. */
592 ensure_not_tfind_mode (void)
594 if (get_traceframe_number () >= 0)
595 error (_("Cannot execute this command while looking at trace frames."));
598 /* Throw an error indicating the current thread is running. */
601 error_is_running (void)
603 error (_("Cannot execute this command while "
604 "the selected thread is running."));
607 /* Calls error_is_running if the current thread is running. */
610 ensure_not_running (void)
612 if (inferior_thread ()->state
== THREAD_RUNNING
)
617 continue_1 (int all_threads
)
620 ensure_not_tfind_mode ();
622 if (non_stop
&& all_threads
)
624 /* Don't error out if the current thread is running, because
625 there may be other stopped threads. */
627 /* Backup current thread and selected frame and restore on scope
629 scoped_restore_current_thread restore_thread
;
630 scoped_disable_commit_resumed disable_commit_resumed
631 ("continue all threads in non-stop");
633 iterate_over_threads (proceed_thread_callback
, nullptr);
635 if (current_ui
->prompt_state
== PROMPT_BLOCKED
)
637 /* If all threads in the target were already running,
638 proceed_thread_callback ends up never calling proceed,
639 and so nothing calls this to put the inferior's terminal
640 settings in effect and remove stdin from the event loop,
641 which we must when running a foreground command. E.g.:
645 <all threads are running now>
648 <no thread was resumed, but the inferior now owns the terminal>
650 target_terminal::inferior ();
653 disable_commit_resumed
.reset_and_commit ();
657 ensure_valid_thread ();
658 ensure_not_running ();
659 clear_proceed_status (0);
660 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
664 /* continue [-a] [proceed-count] [&] */
667 continue_command (const char *args
, int from_tty
)
670 bool all_threads_p
= false;
674 /* Find out whether we must run in the background. */
675 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (args
, &async_exec
);
676 args
= stripped
.get ();
680 if (startswith (args
, "-a"))
682 all_threads_p
= true;
683 args
+= sizeof ("-a") - 1;
689 if (!non_stop
&& all_threads_p
)
690 error (_("`-a' is meaningless in all-stop mode."));
692 if (args
!= nullptr && all_threads_p
)
693 error (_("Can't resume all threads and specify "
694 "proceed count simultaneously."));
696 /* If we have an argument left, set proceed count of breakpoint we
700 bpstat
*bs
= nullptr;
703 struct thread_info
*tp
;
706 tp
= inferior_thread ();
709 process_stratum_target
*last_target
;
712 get_last_target_status (&last_target
, &last_ptid
, nullptr);
713 tp
= find_thread_ptid (last_target
, last_ptid
);
716 bs
= tp
->control
.stop_bpstat
;
718 while ((stat
= bpstat_num (&bs
, &num
)) != 0)
721 set_ignore_count (num
,
722 parse_and_eval_long (args
) - 1,
724 /* set_ignore_count prints a message ending with a period.
725 So print two spaces before "Continuing.". */
731 if (!stopped
&& from_tty
)
734 ("Not stopped at any breakpoint; argument ignored.\n");
739 ensure_not_tfind_mode ();
741 if (!non_stop
|| !all_threads_p
)
743 ensure_valid_thread ();
744 ensure_not_running ();
747 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
750 gdb_printf (_("Continuing.\n"));
752 continue_1 (all_threads_p
);
755 /* Record in TP the starting point of a "step" or "next" command. */
758 set_step_frame (thread_info
*tp
)
760 /* This can be removed once this function no longer implicitly relies on the
761 inferior_ptid value. */
762 gdb_assert (inferior_ptid
== tp
->ptid
);
764 frame_info_ptr frame
= get_current_frame ();
766 symtab_and_line sal
= find_frame_sal (frame
);
767 set_step_info (tp
, frame
, sal
);
769 CORE_ADDR pc
= get_frame_pc (frame
);
770 tp
->control
.step_start_function
= find_pc_function (pc
);
773 /* Step until outside of current statement. */
776 step_command (const char *count_string
, int from_tty
)
778 step_1 (0, 0, count_string
);
781 /* Likewise, but skip over subroutine calls as if single instructions. */
784 next_command (const char *count_string
, int from_tty
)
786 step_1 (1, 0, count_string
);
789 /* Likewise, but step only one instruction. */
792 stepi_command (const char *count_string
, int from_tty
)
794 step_1 (0, 1, count_string
);
798 nexti_command (const char *count_string
, int from_tty
)
800 step_1 (1, 1, count_string
);
803 /* Data for the FSM that manages the step/next/stepi/nexti
806 struct step_command_fsm
: public thread_fsm
808 /* How many steps left in a "step N"-like command. */
811 /* If true, this is a next/nexti, otherwise a step/stepi. */
812 int skip_subroutines
;
814 /* If true, this is a stepi/nexti, otherwise a step/step. */
817 explicit step_command_fsm (struct interp
*cmd_interp
)
818 : thread_fsm (cmd_interp
)
822 void clean_up (struct thread_info
*thread
) override
;
823 bool should_stop (struct thread_info
*thread
) override
;
824 enum async_reply_reason
do_async_reply_reason () override
;
827 /* Prepare for a step/next/etc. command. Any target resource
828 allocated here is undone in the FSM's clean_up method. */
831 step_command_fsm_prepare (struct step_command_fsm
*sm
,
832 int skip_subroutines
, int single_inst
,
833 int count
, struct thread_info
*thread
)
835 sm
->skip_subroutines
= skip_subroutines
;
836 sm
->single_inst
= single_inst
;
839 /* Leave the si command alone. */
840 if (!sm
->single_inst
|| sm
->skip_subroutines
)
841 set_longjmp_breakpoint (thread
, get_frame_id (get_current_frame ()));
843 thread
->control
.stepping_command
= 1;
846 static int prepare_one_step (thread_info
*, struct step_command_fsm
*sm
);
849 step_1 (int skip_subroutines
, int single_inst
, const char *count_string
)
853 struct thread_info
*thr
;
854 struct step_command_fsm
*step_sm
;
857 ensure_not_tfind_mode ();
858 ensure_valid_thread ();
859 ensure_not_running ();
861 gdb::unique_xmalloc_ptr
<char> stripped
862 = strip_bg_char (count_string
, &async_exec
);
863 count_string
= stripped
.get ();
865 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
867 count
= count_string
? parse_and_eval_long (count_string
) : 1;
869 clear_proceed_status (1);
871 /* Setup the execution command state machine to handle all the COUNT
873 thr
= inferior_thread ();
874 step_sm
= new step_command_fsm (command_interp ());
875 thr
->set_thread_fsm (std::unique_ptr
<thread_fsm
> (step_sm
));
877 step_command_fsm_prepare (step_sm
, skip_subroutines
,
878 single_inst
, count
, thr
);
880 /* Do only one step for now, before returning control to the event
881 loop. Let the continuation figure out how many other steps we
882 need to do, and handle them one at the time, through
884 if (!prepare_one_step (thr
, step_sm
))
885 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
890 /* Stepped into an inline frame. Pretend that we've
892 thr
->thread_fsm ()->clean_up (thr
);
893 proceeded
= normal_stop ();
895 inferior_event_handler (INF_EXEC_COMPLETE
);
896 all_uis_check_sync_execution_done ();
900 /* Implementation of the 'should_stop' FSM method for stepping
901 commands. Called after we are done with one step operation, to
902 check whether we need to step again, before we print the prompt and
903 return control to the user. If count is > 1, returns false, as we
904 will need to keep going. */
907 step_command_fsm::should_stop (struct thread_info
*tp
)
909 if (tp
->control
.stop_step
)
911 /* There are more steps to make, and we did stop due to
912 ending a stepping range. Do another step. */
914 return prepare_one_step (tp
, this);
922 /* Implementation of the 'clean_up' FSM method for stepping commands. */
925 step_command_fsm::clean_up (struct thread_info
*thread
)
927 if (!single_inst
|| skip_subroutines
)
928 delete_longjmp_breakpoint (thread
->global_num
);
931 /* Implementation of the 'async_reply_reason' FSM method for stepping
934 enum async_reply_reason
935 step_command_fsm::do_async_reply_reason ()
937 return EXEC_ASYNC_END_STEPPING_RANGE
;
940 /* Prepare for one step in "step N". The actual target resumption is
941 done by the caller. Return true if we're done and should thus
942 report a stop to the user. Returns false if the target needs to be
946 prepare_one_step (thread_info
*tp
, struct step_command_fsm
*sm
)
948 /* This can be removed once this function no longer implicitly relies on the
949 inferior_ptid value. */
950 gdb_assert (inferior_ptid
== tp
->ptid
);
954 frame_info_ptr frame
= get_current_frame ();
958 if (!sm
->single_inst
)
962 /* Step at an inlined function behaves like "down". */
963 if (!sm
->skip_subroutines
964 && inline_skipped_frames (tp
))
967 const char *fn
= nullptr;
971 /* Pretend that we've ran. */
972 resume_ptid
= user_visible_resume_ptid (1);
973 set_running (tp
->inf
->process_target (), resume_ptid
, true);
975 step_into_inline_frame (tp
);
977 frame
= get_current_frame ();
978 sal
= find_frame_sal (frame
);
979 sym
= get_frame_function (frame
);
982 fn
= sym
->print_name ();
985 || !function_name_is_marked_for_skip (fn
, sal
))
988 return prepare_one_step (tp
, sm
);
992 pc
= get_frame_pc (frame
);
993 find_pc_line_pc_range (pc
,
994 &tp
->control
.step_range_start
,
995 &tp
->control
.step_range_end
);
997 /* There's a problem in gcc (PR gcc/98780) that causes missing line
998 table entries, which results in a too large stepping range.
999 Use inlined_subroutine info to make the range more narrow. */
1000 if (inline_skipped_frames (tp
) > 0)
1002 symbol
*sym
= inline_skipped_symbol (tp
);
1003 if (sym
->aclass () == LOC_BLOCK
)
1005 const block
*block
= sym
->value_block ();
1006 if (block
->end () < tp
->control
.step_range_end
)
1007 tp
->control
.step_range_end
= block
->end ();
1011 tp
->control
.may_range_step
= 1;
1013 /* If we have no line info, switch to stepi mode. */
1014 if (tp
->control
.step_range_end
== 0 && step_stop_if_no_debug
)
1016 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1017 tp
->control
.may_range_step
= 0;
1019 else if (tp
->control
.step_range_end
== 0)
1023 if (find_pc_partial_function (pc
, &name
,
1024 &tp
->control
.step_range_start
,
1025 &tp
->control
.step_range_end
) == 0)
1026 error (_("Cannot find bounds of current function"));
1028 target_terminal::ours_for_output ();
1029 gdb_printf (_("Single stepping until exit from function %s,"
1030 "\nwhich has no line number information.\n"),
1036 /* Say we are stepping, but stop after one insn whatever it does. */
1037 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1038 if (!sm
->skip_subroutines
)
1040 Don't step over function calls, not even to functions lacking
1042 tp
->control
.step_over_calls
= STEP_OVER_NONE
;
1045 if (sm
->skip_subroutines
)
1046 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1052 sm
->set_finished ();
1057 /* Continue program at specified address. */
1060 jump_command (const char *arg
, int from_tty
)
1062 struct gdbarch
*gdbarch
= get_current_arch ();
1069 ensure_not_tfind_mode ();
1070 ensure_valid_thread ();
1071 ensure_not_running ();
1073 /* Find out whether we must run in the background. */
1074 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (arg
, &async_exec
);
1075 arg
= stripped
.get ();
1077 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
1080 error_no_arg (_("starting address"));
1082 std::vector
<symtab_and_line
> sals
1083 = decode_line_with_last_displayed (arg
, DECODE_LINE_FUNFIRSTLINE
);
1084 if (sals
.size () != 1)
1085 error (_("Unreasonable jump request"));
1087 symtab_and_line
&sal
= sals
[0];
1089 if (sal
.symtab
== 0 && sal
.pc
== 0)
1090 error (_("No source file has been specified."));
1092 resolve_sal_pc (&sal
); /* May error out. */
1094 /* See if we are trying to jump to another function. */
1095 fn
= get_frame_function (get_current_frame ());
1096 sfn
= find_pc_function (sal
.pc
);
1097 if (fn
!= nullptr && sfn
!= fn
)
1099 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal
.line
,
1102 error (_("Not confirmed."));
1109 struct obj_section
*section
;
1111 fixup_symbol_section (sfn
, 0);
1112 section
= sfn
->obj_section (sfn
->objfile ());
1113 if (section_is_overlay (section
)
1114 && !section_is_mapped (section
))
1116 if (!query (_("WARNING!!! Destination is in "
1117 "unmapped overlay! Jump anyway? ")))
1119 error (_("Not confirmed."));
1129 gdb_printf (_("Continuing at "));
1130 gdb_puts (paddress (gdbarch
, addr
));
1134 clear_proceed_status (0);
1135 proceed (addr
, GDB_SIGNAL_0
);
1138 /* Continue program giving it specified signal. */
1141 signal_command (const char *signum_exp
, int from_tty
)
1143 enum gdb_signal oursig
;
1146 dont_repeat (); /* Too dangerous. */
1148 ensure_not_tfind_mode ();
1149 ensure_valid_thread ();
1150 ensure_not_running ();
1152 /* Find out whether we must run in the background. */
1153 gdb::unique_xmalloc_ptr
<char> stripped
1154 = strip_bg_char (signum_exp
, &async_exec
);
1155 signum_exp
= stripped
.get ();
1157 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
1160 error_no_arg (_("signal number"));
1162 /* It would be even slicker to make signal names be valid expressions,
1163 (the type could be "enum $signal" or some such), then the user could
1164 assign them to convenience variables. */
1165 oursig
= gdb_signal_from_name (signum_exp
);
1167 if (oursig
== GDB_SIGNAL_UNKNOWN
)
1169 /* No, try numeric. */
1170 int num
= parse_and_eval_long (signum_exp
);
1173 oursig
= GDB_SIGNAL_0
;
1175 oursig
= gdb_signal_from_command (num
);
1178 /* Look for threads other than the current that this command ends up
1179 resuming too (due to schedlock off), and warn if they'll get a
1180 signal delivered. "signal 0" is used to suppress a previous
1181 signal, but if the current thread is no longer the one that got
1182 the signal, then the user is potentially suppressing the signal
1183 of the wrong thread. */
1186 int must_confirm
= 0;
1188 /* This indicates what will be resumed. Either a single thread,
1189 a whole process, or all threads of all processes. */
1190 ptid_t resume_ptid
= user_visible_resume_ptid (0);
1191 process_stratum_target
*resume_target
1192 = user_visible_resume_target (resume_ptid
);
1194 thread_info
*current
= inferior_thread ();
1196 for (thread_info
*tp
: all_non_exited_threads (resume_target
, resume_ptid
))
1201 if (tp
->stop_signal () != GDB_SIGNAL_0
1202 && signal_pass_state (tp
->stop_signal ()))
1205 gdb_printf (_("Note:\n"));
1206 gdb_printf (_(" Thread %s previously stopped with signal %s, %s.\n"),
1207 print_thread_id (tp
),
1208 gdb_signal_to_name (tp
->stop_signal ()),
1209 gdb_signal_to_string (tp
->stop_signal ()));
1215 && !query (_("Continuing thread %s (the current thread) with specified signal will\n"
1216 "still deliver the signals noted above to their respective threads.\n"
1217 "Continue anyway? "),
1218 print_thread_id (inferior_thread ())))
1219 error (_("Not confirmed."));
1224 if (oursig
== GDB_SIGNAL_0
)
1225 gdb_printf (_("Continuing with no signal.\n"));
1227 gdb_printf (_("Continuing with signal %s.\n"),
1228 gdb_signal_to_name (oursig
));
1231 clear_proceed_status (0);
1232 proceed ((CORE_ADDR
) -1, oursig
);
1235 /* Queue a signal to be delivered to the current thread. */
1238 queue_signal_command (const char *signum_exp
, int from_tty
)
1240 enum gdb_signal oursig
;
1241 struct thread_info
*tp
;
1244 ensure_not_tfind_mode ();
1245 ensure_valid_thread ();
1246 ensure_not_running ();
1248 if (signum_exp
== nullptr)
1249 error_no_arg (_("signal number"));
1251 /* It would be even slicker to make signal names be valid expressions,
1252 (the type could be "enum $signal" or some such), then the user could
1253 assign them to convenience variables. */
1254 oursig
= gdb_signal_from_name (signum_exp
);
1256 if (oursig
== GDB_SIGNAL_UNKNOWN
)
1258 /* No, try numeric. */
1259 int num
= parse_and_eval_long (signum_exp
);
1262 oursig
= GDB_SIGNAL_0
;
1264 oursig
= gdb_signal_from_command (num
);
1267 if (oursig
!= GDB_SIGNAL_0
1268 && !signal_pass_state (oursig
))
1269 error (_("Signal handling set to not pass this signal to the program."));
1271 tp
= inferior_thread ();
1272 tp
->set_stop_signal (oursig
);
1275 /* Data for the FSM that manages the until (with no argument)
1278 struct until_next_fsm
: public thread_fsm
1280 /* The thread that as current when the command was executed. */
1283 until_next_fsm (struct interp
*cmd_interp
, int thread
)
1284 : thread_fsm (cmd_interp
),
1289 bool should_stop (struct thread_info
*thread
) override
;
1290 void clean_up (struct thread_info
*thread
) override
;
1291 enum async_reply_reason
do_async_reply_reason () override
;
1294 /* Implementation of the 'should_stop' FSM method for the until (with
1298 until_next_fsm::should_stop (struct thread_info
*tp
)
1300 if (tp
->control
.stop_step
)
1306 /* Implementation of the 'clean_up' FSM method for the until (with no
1310 until_next_fsm::clean_up (struct thread_info
*thread
)
1312 delete_longjmp_breakpoint (thread
->global_num
);
1315 /* Implementation of the 'async_reply_reason' FSM method for the until
1316 (with no arg) command. */
1318 enum async_reply_reason
1319 until_next_fsm::do_async_reply_reason ()
1321 return EXEC_ASYNC_END_STEPPING_RANGE
;
1324 /* Proceed until we reach a different source line with pc greater than
1325 our current one or exit the function. We skip calls in both cases.
1327 Note that eventually this command should probably be changed so
1328 that only source lines are printed out when we hit the breakpoint
1329 we set. This may involve changes to wait_for_inferior and the
1330 proceed status code. */
1333 until_next_command (int from_tty
)
1335 frame_info_ptr frame
;
1337 struct symbol
*func
;
1338 struct symtab_and_line sal
;
1339 struct thread_info
*tp
= inferior_thread ();
1340 int thread
= tp
->global_num
;
1341 struct until_next_fsm
*sm
;
1343 clear_proceed_status (0);
1344 set_step_frame (tp
);
1346 frame
= get_current_frame ();
1348 /* Step until either exited from this function or greater
1349 than the current line (if in symbolic section) or pc (if
1352 pc
= get_frame_pc (frame
);
1353 func
= find_pc_function (pc
);
1357 struct bound_minimal_symbol msymbol
= lookup_minimal_symbol_by_pc (pc
);
1359 if (msymbol
.minsym
== nullptr)
1360 error (_("Execution is not within a known function."));
1362 tp
->control
.step_range_start
= msymbol
.value_address ();
1363 /* The upper-bound of step_range is exclusive. In order to make PC
1364 within the range, set the step_range_end with PC + 1. */
1365 tp
->control
.step_range_end
= pc
+ 1;
1369 sal
= find_pc_line (pc
, 0);
1371 tp
->control
.step_range_start
= func
->value_block ()->entry_pc ();
1372 tp
->control
.step_range_end
= sal
.end
;
1374 /* By setting the step_range_end based on the current pc, we are
1375 assuming that the last line table entry for any given source line
1376 will have is_stmt set to true. This is not necessarily the case,
1377 there may be additional entries for the same source line with
1378 is_stmt set false. Consider the following code:
1380 for (int i = 0; i < 10; i++)
1383 Clang-13, will generate multiple line table entries at the end of
1384 the loop all associated with the 'for' line. The first of these
1385 entries is marked is_stmt true, but the other entries are is_stmt
1388 If we only use the values in SAL, then our stepping range may not
1389 extend to the end of the loop. The until command will reach the
1390 end of the range, find a non is_stmt instruction, and step to the
1391 next is_stmt instruction. This stopping point, however, will be
1392 inside the loop, which is not what we wanted.
1394 Instead, we now check any subsequent line table entries to see if
1395 they are for the same line. If they are, and they are marked
1396 is_stmt false, then we extend the end of our stepping range.
1398 When we finish this process the end of the stepping range will
1399 point either to a line with a different line number, or, will
1400 point at an address for the same line number that is marked as a
1403 struct symtab_and_line final_sal
1404 = find_pc_line (tp
->control
.step_range_end
, 0);
1406 while (final_sal
.line
== sal
.line
&& final_sal
.symtab
== sal
.symtab
1407 && !final_sal
.is_stmt
)
1409 tp
->control
.step_range_end
= final_sal
.end
;
1410 final_sal
= find_pc_line (final_sal
.end
, 0);
1413 tp
->control
.may_range_step
= 1;
1415 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1417 set_longjmp_breakpoint (tp
, get_frame_id (frame
));
1418 delete_longjmp_breakpoint_cleanup
lj_deleter (thread
);
1420 sm
= new until_next_fsm (command_interp (), tp
->global_num
);
1421 tp
->set_thread_fsm (std::unique_ptr
<thread_fsm
> (sm
));
1422 lj_deleter
.release ();
1424 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1428 until_command (const char *arg
, int from_tty
)
1433 ensure_not_tfind_mode ();
1434 ensure_valid_thread ();
1435 ensure_not_running ();
1437 /* Find out whether we must run in the background. */
1438 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (arg
, &async_exec
);
1439 arg
= stripped
.get ();
1441 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
1444 until_break_command (arg
, from_tty
, 0);
1446 until_next_command (from_tty
);
1450 advance_command (const char *arg
, int from_tty
)
1455 ensure_not_tfind_mode ();
1456 ensure_valid_thread ();
1457 ensure_not_running ();
1460 error_no_arg (_("a location"));
1462 /* Find out whether we must run in the background. */
1463 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (arg
, &async_exec
);
1464 arg
= stripped
.get ();
1466 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
1468 until_break_command (arg
, from_tty
, 1);
1471 /* See inferior.h. */
1474 get_return_value (struct symbol
*func_symbol
, struct value
*function
)
1476 regcache
*stop_regs
= get_current_regcache ();
1477 struct gdbarch
*gdbarch
= stop_regs
->arch ();
1478 struct value
*value
;
1480 struct type
*value_type
1481 = check_typedef (func_symbol
->type ()->target_type ());
1482 gdb_assert (value_type
->code () != TYPE_CODE_VOID
);
1484 if (is_nocall_function (check_typedef (::value_type (function
))))
1486 warning (_("Function '%s' does not follow the target calling "
1487 "convention, cannot determine its returned value."),
1488 func_symbol
->print_name ());
1493 /* FIXME: 2003-09-27: When returning from a nested inferior function
1494 call, it's possible (with no help from the architecture vector)
1495 to locate and return/print a "struct return" value. This is just
1496 a more complicated case of what is already being done in the
1497 inferior function call code. In fact, when inferior function
1498 calls are made async, this will likely be made the norm. */
1500 switch (gdbarch_return_value (gdbarch
, function
, value_type
,
1501 nullptr, nullptr, nullptr))
1503 case RETURN_VALUE_REGISTER_CONVENTION
:
1504 case RETURN_VALUE_ABI_RETURNS_ADDRESS
:
1505 case RETURN_VALUE_ABI_PRESERVES_ADDRESS
:
1506 value
= allocate_value (value_type
);
1507 gdbarch_return_value (gdbarch
, function
, value_type
, stop_regs
,
1508 value_contents_raw (value
).data (), nullptr);
1510 case RETURN_VALUE_STRUCT_CONVENTION
:
1514 internal_error (_("bad switch"));
1520 /* The captured function return value/type and its position in the
1523 struct return_value_info
1525 /* The captured return value. May be NULL if we weren't able to
1526 retrieve it. See get_return_value. */
1527 struct value
*value
;
1529 /* The return type. In some cases, we'll not be able extract the
1530 return value, but we always know the type. */
1533 /* If we captured a value, this is the value history index. */
1534 int value_history_index
;
1537 /* Helper for print_return_value. */
1540 print_return_value_1 (struct ui_out
*uiout
, struct return_value_info
*rv
)
1542 if (rv
->value
!= nullptr)
1545 uiout
->text ("Value returned is ");
1546 uiout
->field_fmt ("gdb-result-var", "$%d",
1547 rv
->value_history_index
);
1548 uiout
->text (" = ");
1552 struct value_print_options opts
;
1553 get_user_print_options (&opts
);
1556 value_print (rv
->value
, &stb
, &opts
);
1557 uiout
->field_stream ("return-value", stb
);
1560 uiout
->field_string ("return-value", _("<not displayed>"),
1561 metadata_style
.style ());
1566 std::string type_name
= type_to_string (rv
->type
);
1567 uiout
->text ("Value returned has type: ");
1568 uiout
->field_string ("return-type", type_name
);
1570 uiout
->text (" Cannot determine contents\n");
1574 /* Print the result of a function at the end of a 'finish' command.
1575 RV points at an object representing the captured return value/type
1576 and its position in the value history. */
1579 print_return_value (struct ui_out
*uiout
, struct return_value_info
*rv
)
1581 if (rv
->type
== nullptr
1582 || check_typedef (rv
->type
)->code () == TYPE_CODE_VOID
)
1587 /* print_return_value_1 can throw an exception in some
1588 circumstances. We need to catch this so that we still
1589 delete the breakpoint. */
1590 print_return_value_1 (uiout
, rv
);
1592 catch (const gdb_exception
&ex
)
1594 exception_print (gdb_stdout
, ex
);
1598 /* Data for the FSM that manages the finish command. */
1600 struct finish_command_fsm
: public thread_fsm
1602 /* The momentary breakpoint set at the function's return address in
1604 breakpoint_up breakpoint
;
1606 /* The function that we're stepping out of. */
1607 struct symbol
*function
= nullptr;
1609 /* If the FSM finishes successfully, this stores the function's
1611 struct return_value_info return_value_info
{};
1613 /* If the current function uses the "struct return convention",
1614 this holds the address at which the value being returned will
1615 be stored, or zero if that address could not be determined or
1616 the "struct return convention" is not being used. */
1617 CORE_ADDR return_buf
;
1619 explicit finish_command_fsm (struct interp
*cmd_interp
)
1620 : thread_fsm (cmd_interp
)
1624 bool should_stop (struct thread_info
*thread
) override
;
1625 void clean_up (struct thread_info
*thread
) override
;
1626 struct return_value_info
*return_value () override
;
1627 enum async_reply_reason
do_async_reply_reason () override
;
1630 /* Implementation of the 'should_stop' FSM method for the finish
1631 commands. Detects whether the thread stepped out of the function
1632 successfully, and if so, captures the function's return value and
1633 marks the FSM finished. */
1636 finish_command_fsm::should_stop (struct thread_info
*tp
)
1638 struct return_value_info
*rv
= &return_value_info
;
1640 if (function
!= nullptr
1641 && bpstat_find_breakpoint (tp
->control
.stop_bpstat
,
1642 breakpoint
.get ()) != nullptr)
1647 rv
->type
= function
->type ()->target_type ();
1648 if (rv
->type
== nullptr)
1649 internal_error (_("finish_command: function has no target type"));
1651 if (check_typedef (rv
->type
)->code () != TYPE_CODE_VOID
)
1655 func
= read_var_value (function
, nullptr, get_current_frame ());
1657 if (return_buf
!= 0)
1658 /* Retrieve return value from the buffer where it was saved. */
1659 rv
->value
= value_at (rv
->type
, return_buf
);
1661 rv
->value
= get_return_value (function
, func
);
1663 if (rv
->value
!= nullptr)
1664 rv
->value_history_index
= record_latest_value (rv
->value
);
1667 else if (tp
->control
.stop_step
)
1669 /* Finishing from an inline frame, or reverse finishing. In
1670 either case, there's no way to retrieve the return value. */
1677 /* Implementation of the 'clean_up' FSM method for the finish
1681 finish_command_fsm::clean_up (struct thread_info
*thread
)
1683 breakpoint
.reset ();
1684 delete_longjmp_breakpoint (thread
->global_num
);
1687 /* Implementation of the 'return_value' FSM method for the finish
1690 struct return_value_info
*
1691 finish_command_fsm::return_value ()
1693 return &return_value_info
;
1696 /* Implementation of the 'async_reply_reason' FSM method for the
1699 enum async_reply_reason
1700 finish_command_fsm::do_async_reply_reason ()
1702 if (execution_direction
== EXEC_REVERSE
)
1703 return EXEC_ASYNC_END_STEPPING_RANGE
;
1705 return EXEC_ASYNC_FUNCTION_FINISHED
;
1708 /* finish_backward -- helper function for finish_command. */
1711 finish_backward (struct finish_command_fsm
*sm
)
1713 struct symtab_and_line sal
;
1714 struct thread_info
*tp
= inferior_thread ();
1716 CORE_ADDR func_addr
;
1718 pc
= get_frame_pc (get_current_frame ());
1720 if (find_pc_partial_function (pc
, nullptr, &func_addr
, nullptr) == 0)
1721 error (_("Cannot find bounds of current function"));
1723 sal
= find_pc_line (func_addr
, 0);
1725 tp
->control
.proceed_to_finish
= 1;
1726 /* Special case: if we're sitting at the function entry point,
1727 then all we need to do is take a reverse singlestep. We
1728 don't need to set a breakpoint, and indeed it would do us
1731 Note that this can only happen at frame #0, since there's
1732 no way that a function up the stack can have a return address
1733 that's equal to its entry point. */
1737 frame_info_ptr frame
= get_selected_frame (nullptr);
1738 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1740 /* Set a step-resume at the function's entry point. Once that's
1741 hit, we'll do one more step backwards. */
1742 symtab_and_line sr_sal
;
1744 sr_sal
.pspace
= get_frame_program_space (frame
);
1745 insert_step_resume_breakpoint_at_sal (gdbarch
,
1746 sr_sal
, null_frame_id
);
1748 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1752 /* We're almost there -- we just need to back up by one more
1754 tp
->control
.step_range_start
= tp
->control
.step_range_end
= 1;
1755 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1759 /* finish_forward -- helper function for finish_command. FRAME is the
1760 frame that called the function we're about to step out of. */
1763 finish_forward (struct finish_command_fsm
*sm
, frame_info_ptr frame
)
1765 struct frame_id frame_id
= get_frame_id (frame
);
1766 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
1767 struct symtab_and_line sal
;
1768 struct thread_info
*tp
= inferior_thread ();
1770 sal
= find_pc_line (get_frame_pc (frame
), 0);
1771 sal
.pc
= get_frame_pc (frame
);
1773 sm
->breakpoint
= set_momentary_breakpoint (gdbarch
, sal
,
1774 get_stack_frame_id (frame
),
1777 /* set_momentary_breakpoint invalidates FRAME. */
1780 set_longjmp_breakpoint (tp
, frame_id
);
1782 /* We want to print return value, please... */
1783 tp
->control
.proceed_to_finish
= 1;
1785 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1788 /* Skip frames for "finish". */
1790 static frame_info_ptr
1791 skip_finish_frames (frame_info_ptr frame
)
1793 frame_info_ptr start
;
1799 frame
= skip_tailcall_frames (frame
);
1800 if (frame
== nullptr)
1803 frame
= skip_unwritable_frames (frame
);
1804 if (frame
== nullptr)
1807 while (start
!= frame
);
1812 /* "finish": Set a temporary breakpoint at the place the selected
1813 frame will return to, then continue. */
1816 finish_command (const char *arg
, int from_tty
)
1818 frame_info_ptr frame
;
1820 struct finish_command_fsm
*sm
;
1821 struct thread_info
*tp
;
1824 ensure_not_tfind_mode ();
1825 ensure_valid_thread ();
1826 ensure_not_running ();
1828 /* Find out whether we must run in the background. */
1829 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (arg
, &async_exec
);
1830 arg
= stripped
.get ();
1832 prepare_execution_command (current_inferior ()->top_target (), async_exec
);
1835 error (_("The \"finish\" command does not take any arguments."));
1837 frame
= get_prev_frame (get_selected_frame (_("No selected frame.")));
1839 error (_("\"finish\" not meaningful in the outermost frame."));
1840 frame
.prepare_reinflate ();
1842 clear_proceed_status (0);
1844 tp
= inferior_thread ();
1846 sm
= new finish_command_fsm (command_interp ());
1848 tp
->set_thread_fsm (std::unique_ptr
<thread_fsm
> (sm
));
1850 /* Finishing from an inline frame is completely different. We don't
1851 try to show the "return value" - no way to locate it. */
1852 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1855 /* Claim we are stepping in the calling frame. An empty step
1856 range means that we will stop once we aren't in a function
1857 called by that frame. We don't use the magic "1" value for
1858 step_range_end, because then infrun will think this is nexti,
1859 and not step over the rest of this inlined function call. */
1860 set_step_info (tp
, frame
, {});
1861 tp
->control
.step_range_start
= get_frame_pc (frame
);
1862 tp
->control
.step_range_end
= tp
->control
.step_range_start
;
1863 tp
->control
.step_over_calls
= STEP_OVER_ALL
;
1865 /* Print info on the selected frame, including level number but not
1869 gdb_printf (_("Run till exit from "));
1870 print_stack_frame (get_selected_frame (nullptr), 1, LOCATION
, 0);
1873 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
1877 /* Find the function we will return from. */
1878 frame_info_ptr callee_frame
= get_selected_frame (nullptr);
1879 sm
->function
= find_pc_function (get_frame_pc (callee_frame
));
1880 sm
->return_buf
= 0; /* Initialize buffer address is not available. */
1882 /* Determine the return convention. If it is RETURN_VALUE_STRUCT_CONVENTION,
1883 attempt to determine the address of the return buffer. */
1884 if (sm
->function
!= nullptr)
1886 enum return_value_convention return_value
;
1887 struct gdbarch
*gdbarch
= get_frame_arch (callee_frame
);
1889 struct type
* val_type
1890 = check_typedef (sm
->function
->type ()->target_type ());
1892 return_value
= gdbarch_return_value (gdbarch
,
1893 read_var_value (sm
->function
, nullptr,
1895 val_type
, nullptr, nullptr, nullptr);
1897 if (return_value
== RETURN_VALUE_STRUCT_CONVENTION
1898 && val_type
->code () != TYPE_CODE_VOID
)
1899 sm
->return_buf
= gdbarch_get_return_buf_addr (gdbarch
, val_type
,
1903 /* Print info on the selected frame, including level number but not
1907 if (execution_direction
== EXEC_REVERSE
)
1908 gdb_printf (_("Run back to call of "));
1911 if (sm
->function
!= nullptr && TYPE_NO_RETURN (sm
->function
->type ())
1912 && !query (_("warning: Function %s does not return normally.\n"
1913 "Try to finish anyway? "),
1914 sm
->function
->print_name ()))
1915 error (_("Not confirmed."));
1916 gdb_printf (_("Run till exit from "));
1919 print_stack_frame (callee_frame
, 1, LOCATION
, 0);
1923 if (execution_direction
== EXEC_REVERSE
)
1924 finish_backward (sm
);
1927 frame
= skip_finish_frames (frame
);
1929 if (frame
== nullptr)
1930 error (_("Cannot find the caller frame."));
1932 finish_forward (sm
, frame
);
1938 info_program_command (const char *args
, int from_tty
)
1943 process_stratum_target
*proc_target
;
1945 if (!target_has_execution ())
1947 gdb_printf (_("The program being debugged is not being run.\n"));
1953 ptid
= inferior_ptid
;
1954 proc_target
= current_inferior ()->process_target ();
1957 get_last_target_status (&proc_target
, &ptid
, nullptr);
1959 if (ptid
== null_ptid
|| ptid
== minus_one_ptid
)
1960 error (_("No selected thread."));
1962 thread_info
*tp
= find_thread_ptid (proc_target
, ptid
);
1964 if (tp
->state
== THREAD_EXITED
)
1965 error (_("Invalid selected thread."));
1966 else if (tp
->state
== THREAD_RUNNING
)
1967 error (_("Selected thread is running."));
1969 bs
= tp
->control
.stop_bpstat
;
1970 stat
= bpstat_num (&bs
, &num
);
1972 target_files_info ();
1973 gdb_printf (_("Program stopped at %s.\n"),
1974 paddress (target_gdbarch (), tp
->stop_pc ()));
1975 if (tp
->control
.stop_step
)
1976 gdb_printf (_("It stopped after being stepped.\n"));
1979 /* There may be several breakpoints in the same place, so this
1980 isn't as strange as it seems. */
1985 gdb_printf (_("It stopped at a breakpoint "
1986 "that has since been deleted.\n"));
1989 gdb_printf (_("It stopped at breakpoint %d.\n"), num
);
1990 stat
= bpstat_num (&bs
, &num
);
1993 else if (tp
->stop_signal () != GDB_SIGNAL_0
)
1995 gdb_printf (_("It stopped with signal %s, %s.\n"),
1996 gdb_signal_to_name (tp
->stop_signal ()),
1997 gdb_signal_to_string (tp
->stop_signal ()));
2002 gdb_printf (_("Type \"info stack\" or \"info "
2003 "registers\" for more information.\n"));
2008 environment_info (const char *var
, int from_tty
)
2012 const char *val
= current_inferior ()->environment
.get (var
);
2023 gdb_puts ("Environment variable \"");
2025 gdb_puts ("\" not defined.\n");
2030 char **envp
= current_inferior ()->environment
.envp ();
2032 for (int idx
= 0; envp
[idx
] != nullptr; ++idx
)
2034 gdb_puts (envp
[idx
]);
2041 set_environment_command (const char *arg
, int from_tty
)
2043 const char *p
, *val
;
2047 error_no_arg (_("environment variable and value"));
2049 /* Find separation between variable name and value. */
2050 p
= (char *) strchr (arg
, '=');
2051 val
= (char *) strchr (arg
, ' ');
2053 if (p
!= 0 && val
!= 0)
2055 /* We have both a space and an equals. If the space is before the
2056 equals, walk forward over the spaces til we see a nonspace
2057 (possibly the equals). */
2062 /* Now if the = is after the char following the spaces,
2063 take the char following the spaces. */
2067 else if (val
!= 0 && p
== 0)
2071 error_no_arg (_("environment variable to set"));
2073 if (p
== 0 || p
[1] == 0)
2077 p
= arg
+ strlen (arg
); /* So that savestring below will work. */
2081 /* Not setting variable value to null. */
2083 while (*val
== ' ' || *val
== '\t')
2087 while (p
!= arg
&& (p
[-1] == ' ' || p
[-1] == '\t'))
2090 std::string
var (arg
, p
- arg
);
2093 gdb_printf (_("Setting environment variable "
2094 "\"%s\" to null value.\n"),
2096 current_inferior ()->environment
.set (var
.c_str (), "");
2099 current_inferior ()->environment
.set (var
.c_str (), val
);
2103 unset_environment_command (const char *var
, int from_tty
)
2107 /* If there is no argument, delete all environment variables.
2108 Ask for confirmation if reading from the terminal. */
2109 if (!from_tty
|| query (_("Delete all environment variables? ")))
2110 current_inferior ()->environment
.clear ();
2113 current_inferior ()->environment
.unset (var
);
2116 /* Handle the execution path (PATH variable). */
2118 static const char path_var_name
[] = "PATH";
2121 path_info (const char *args
, int from_tty
)
2123 gdb_puts ("Executable and object file path: ");
2124 gdb_puts (current_inferior ()->environment
.get (path_var_name
));
2128 /* Add zero or more directories to the front of the execution path. */
2131 path_command (const char *dirname
, int from_tty
)
2136 env
= current_inferior ()->environment
.get (path_var_name
);
2137 /* Can be null if path is not set. */
2140 std::string exec_path
= env
;
2141 mod_path (dirname
, exec_path
);
2142 current_inferior ()->environment
.set (path_var_name
, exec_path
.c_str ());
2144 path_info (nullptr, from_tty
);
2149 pad_to_column (string_file
&stream
, int col
)
2151 /* At least one space must be printed to separate columns. */
2153 const int size
= stream
.size ();
2155 stream
.puts (n_spaces (col
- size
));
2158 /* Print out the register NAME with value VAL, to FILE, in the default
2162 default_print_one_register_info (struct ui_file
*file
,
2166 struct type
*regtype
= value_type (val
);
2167 int print_raw_format
;
2168 string_file format_stream
;
2171 value_column_1
= 15,
2172 /* Give enough room for "0x", 16 hex digits and two spaces in
2173 preceding column. */
2174 value_column_2
= value_column_1
+ 2 + 16 + 2,
2177 format_stream
.puts (name
);
2178 pad_to_column (format_stream
, value_column_1
);
2180 print_raw_format
= (value_entirely_available (val
)
2181 && !value_optimized_out (val
));
2183 /* If virtual format is floating, print it that way, and in raw
2185 if (regtype
->code () == TYPE_CODE_FLT
2186 || regtype
->code () == TYPE_CODE_DECFLOAT
)
2188 struct value_print_options opts
;
2189 const gdb_byte
*valaddr
= value_contents_for_printing (val
).data ();
2190 enum bfd_endian byte_order
= type_byte_order (regtype
);
2192 get_user_print_options (&opts
);
2193 opts
.deref_ref
= true;
2195 common_val_print (val
, &format_stream
, 0, &opts
, current_language
);
2197 if (print_raw_format
)
2199 pad_to_column (format_stream
, value_column_2
);
2200 format_stream
.puts ("(raw ");
2201 print_hex_chars (&format_stream
, valaddr
, regtype
->length (),
2203 format_stream
.putc (')');
2208 struct value_print_options opts
;
2210 /* Print the register in hex. */
2211 get_formatted_print_options (&opts
, 'x');
2212 opts
.deref_ref
= true;
2213 common_val_print (val
, &format_stream
, 0, &opts
, current_language
);
2214 /* If not a vector register, print it also according to its
2216 if (print_raw_format
&& regtype
->is_vector () == 0)
2218 pad_to_column (format_stream
, value_column_2
);
2219 get_user_print_options (&opts
);
2220 opts
.deref_ref
= true;
2221 common_val_print (val
, &format_stream
, 0, &opts
, current_language
);
2225 gdb_puts (format_stream
.c_str (), file
);
2226 gdb_printf (file
, "\n");
2229 /* Print out the machine register regnum. If regnum is -1, print all
2230 registers (print_all == 1) or all non-float and non-vector
2231 registers (print_all == 0).
2233 For most machines, having all_registers_info() print the
2234 register(s) one per line is good enough. If a different format is
2235 required, (eg, for MIPS or Pyramid 90x, which both have lots of
2236 regs), or there is an existing convention for showing all the
2237 registers, define the architecture method PRINT_REGISTERS_INFO to
2238 provide that format. */
2241 default_print_registers_info (struct gdbarch
*gdbarch
,
2242 struct ui_file
*file
,
2243 frame_info_ptr frame
,
2244 int regnum
, int print_all
)
2247 const int numregs
= gdbarch_num_cooked_regs (gdbarch
);
2249 for (i
= 0; i
< numregs
; i
++)
2251 /* Decide between printing all regs, non-float / vector regs, or
2257 if (!gdbarch_register_reggroup_p (gdbarch
, i
, all_reggroup
))
2262 if (!gdbarch_register_reggroup_p (gdbarch
, i
, general_reggroup
))
2272 /* If the register name is empty, it is undefined for this
2273 processor, so don't display anything. */
2274 if (*(gdbarch_register_name (gdbarch
, i
)) == '\0')
2277 default_print_one_register_info (file
,
2278 gdbarch_register_name (gdbarch
, i
),
2279 value_of_register (i
, frame
));
2284 registers_info (const char *addr_exp
, int fpregs
)
2286 frame_info_ptr frame
;
2287 struct gdbarch
*gdbarch
;
2289 if (!target_has_registers ())
2290 error (_("The program has no registers now."));
2291 frame
= get_selected_frame (nullptr);
2292 gdbarch
= get_frame_arch (frame
);
2296 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2301 while (*addr_exp
!= '\0')
2306 /* Skip leading white space. */
2307 addr_exp
= skip_spaces (addr_exp
);
2309 /* Discard any leading ``$''. Check that there is something
2310 resembling a register following it. */
2311 if (addr_exp
[0] == '$')
2313 if (isspace ((*addr_exp
)) || (*addr_exp
) == '\0')
2314 error (_("Missing register name"));
2316 /* Find the start/end of this register name/num/group. */
2318 while ((*addr_exp
) != '\0' && !isspace ((*addr_exp
)))
2322 /* Figure out what we've found and display it. */
2324 /* A register name? */
2326 int regnum
= user_reg_map_name_to_regnum (gdbarch
, start
, end
- start
);
2330 /* User registers lie completely outside of the range of
2331 normal registers. Catch them early so that the target
2333 if (regnum
>= gdbarch_num_cooked_regs (gdbarch
))
2335 struct value
*regval
= value_of_user_reg (regnum
, frame
);
2336 const char *regname
= user_reg_map_regnum_to_name (gdbarch
,
2339 /* Print in the same fashion
2340 gdbarch_print_registers_info's default
2341 implementation prints. */
2342 default_print_one_register_info (gdb_stdout
,
2347 gdbarch_print_registers_info (gdbarch
, gdb_stdout
,
2348 frame
, regnum
, fpregs
);
2353 /* A register group? */
2355 const struct reggroup
*group
= nullptr;
2356 for (const struct reggroup
*g
: gdbarch_reggroups (gdbarch
))
2358 /* Don't bother with a length check. Should the user
2359 enter a short register group name, go with the first
2360 group that matches. */
2361 if (strncmp (start
, g
->name (), end
- start
) == 0)
2367 if (group
!= nullptr)
2372 regnum
< gdbarch_num_cooked_regs (gdbarch
);
2375 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, group
))
2376 gdbarch_print_registers_info (gdbarch
,
2384 /* Nothing matched. */
2385 error (_("Invalid register `%.*s'"), (int) (end
- start
), start
);
2390 info_all_registers_command (const char *addr_exp
, int from_tty
)
2392 registers_info (addr_exp
, 1);
2396 info_registers_command (const char *addr_exp
, int from_tty
)
2398 registers_info (addr_exp
, 0);
2402 print_vector_info (struct ui_file
*file
,
2403 frame_info_ptr frame
, const char *args
)
2405 struct gdbarch
*gdbarch
= get_frame_arch (frame
);
2407 if (gdbarch_print_vector_info_p (gdbarch
))
2408 gdbarch_print_vector_info (gdbarch
, file
, frame
, args
);
2412 int printed_something
= 0;
2414 for (regnum
= 0; regnum
< gdbarch_num_cooked_regs (gdbarch
); regnum
++)
2416 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, vector_reggroup
))
2418 printed_something
= 1;
2419 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2422 if (!printed_something
)
2423 gdb_printf (file
, "No vector information\n");
2428 info_vector_command (const char *args
, int from_tty
)
2430 if (!target_has_registers ())
2431 error (_("The program has no registers now."));
2433 print_vector_info (gdb_stdout
, get_selected_frame (nullptr), args
);
2436 /* Kill the inferior process. Make us have no inferior. */
2439 kill_command (const char *arg
, int from_tty
)
2441 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2442 It should be a distinct flag that indicates that a target is active, cuz
2443 some targets don't have processes! */
2445 if (inferior_ptid
== null_ptid
)
2446 error (_("The program is not being run."));
2447 if (!query (_("Kill the program being debugged? ")))
2448 error (_("Not confirmed."));
2450 int pid
= current_inferior ()->pid
;
2451 /* Save the pid as a string before killing the inferior, since that
2452 may unpush the current target, and we need the string after. */
2453 std::string pid_str
= target_pid_to_str (ptid_t (pid
));
2454 int infnum
= current_inferior ()->num
;
2457 bfd_cache_close_all ();
2459 if (print_inferior_events
)
2460 gdb_printf (_("[Inferior %d (%s) killed]\n"),
2461 infnum
, pid_str
.c_str ());
2464 /* Used in `attach&' command. Proceed threads of inferior INF iff
2465 they stopped due to debugger request, and when they did, they
2466 reported a clean stop (GDB_SIGNAL_0). Do not proceed threads that
2467 have been explicitly been told to stop. */
2470 proceed_after_attach (inferior
*inf
)
2472 /* Don't error out if the current thread is running, because
2473 there may be other stopped threads. */
2475 /* Backup current thread and selected frame. */
2476 scoped_restore_current_thread restore_thread
;
2478 for (thread_info
*thread
: inf
->non_exited_threads ())
2479 if (!thread
->executing ()
2480 && !thread
->stop_requested
2481 && thread
->stop_signal () == GDB_SIGNAL_0
)
2483 switch_to_thread (thread
);
2484 clear_proceed_status (0);
2485 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
2489 /* See inferior.h. */
2492 setup_inferior (int from_tty
)
2494 struct inferior
*inferior
;
2496 inferior
= current_inferior ();
2497 inferior
->needs_setup
= false;
2499 /* If no exec file is yet known, try to determine it from the
2501 if (get_exec_file (0) == nullptr)
2502 exec_file_locate_attach (inferior_ptid
.pid (), 1, from_tty
);
2505 reopen_exec_file ();
2506 reread_symbols (from_tty
);
2509 /* Take any necessary post-attaching actions for this platform. */
2510 target_post_attach (inferior_ptid
.pid ());
2512 post_create_inferior (from_tty
);
2515 /* What to do after the first program stops after attaching. */
2516 enum attach_post_wait_mode
2518 /* Do nothing. Leaves threads as they are. */
2519 ATTACH_POST_WAIT_NOTHING
,
2521 /* Re-resume threads that are marked running. */
2522 ATTACH_POST_WAIT_RESUME
,
2524 /* Stop all threads. */
2525 ATTACH_POST_WAIT_STOP
,
2528 /* Called after we've attached to a process and we've seen it stop for
2529 the first time. Resume, stop, or don't touch the threads according
2533 attach_post_wait (int from_tty
, enum attach_post_wait_mode mode
)
2535 struct inferior
*inferior
;
2537 inferior
= current_inferior ();
2538 inferior
->control
.stop_soon
= NO_STOP_QUIETLY
;
2540 if (inferior
->needs_setup
)
2541 setup_inferior (from_tty
);
2543 if (mode
== ATTACH_POST_WAIT_RESUME
)
2545 /* The user requested an `attach&', so be sure to leave threads
2546 that didn't get a signal running. */
2548 /* Immediately resume all suspended threads of this inferior,
2549 and this inferior only. This should have no effect on
2550 already running threads. If a thread has been stopped with a
2551 signal, leave it be. */
2553 proceed_after_attach (inferior
);
2556 if (inferior_thread ()->stop_signal () == GDB_SIGNAL_0
)
2558 clear_proceed_status (0);
2559 proceed ((CORE_ADDR
) -1, GDB_SIGNAL_DEFAULT
);
2563 else if (mode
== ATTACH_POST_WAIT_STOP
)
2565 /* The user requested a plain `attach', so be sure to leave
2566 the inferior stopped. */
2568 /* At least the current thread is already stopped. */
2570 /* In all-stop, by definition, all threads have to be already
2571 stopped at this point. In non-stop, however, although the
2572 selected thread is stopped, others may still be executing.
2573 Be sure to explicitly stop all threads of the process. This
2574 should have no effect on already stopped threads. */
2576 target_stop (ptid_t (inferior
->pid
));
2577 else if (target_is_non_stop_p ())
2579 struct thread_info
*lowest
= inferior_thread ();
2581 stop_all_threads ("attaching");
2583 /* It's not defined which thread will report the attach
2584 stop. For consistency, always select the thread with
2585 lowest GDB number, which should be the main thread, if it
2587 for (thread_info
*thread
: current_inferior ()->non_exited_threads ())
2588 if (thread
->inf
->num
< lowest
->inf
->num
2589 || thread
->per_inf_num
< lowest
->per_inf_num
)
2592 switch_to_thread (lowest
);
2595 /* Tell the user/frontend where we're stopped. */
2597 if (deprecated_attach_hook
)
2598 deprecated_attach_hook ();
2602 /* "attach" command entry point. Takes a program started up outside
2603 of gdb and ``attaches'' to it. This stops it cold in its tracks
2604 and allows us to start debugging it. */
2607 attach_command (const char *args
, int from_tty
)
2610 struct target_ops
*attach_target
;
2611 struct inferior
*inferior
= current_inferior ();
2612 enum attach_post_wait_mode mode
;
2614 dont_repeat (); /* Not for the faint of heart */
2616 scoped_disable_commit_resumed
disable_commit_resumed ("attaching");
2618 if (gdbarch_has_global_solist (target_gdbarch ()))
2619 /* Don't complain if all processes share the same symbol
2622 else if (target_has_execution ())
2624 if (query (_("A program is being debugged already. Kill it? ")))
2627 error (_("Not killed."));
2630 /* Clean up any leftovers from other runs. Some other things from
2631 this function should probably be moved into target_pre_inferior. */
2632 target_pre_inferior (from_tty
);
2634 gdb::unique_xmalloc_ptr
<char> stripped
= strip_bg_char (args
, &async_exec
);
2635 args
= stripped
.get ();
2637 attach_target
= find_attach_target ();
2639 prepare_execution_command (attach_target
, async_exec
);
2641 if (non_stop
&& !attach_target
->supports_non_stop ())
2642 error (_("Cannot attach to this target in non-stop mode"));
2644 attach_target
->attach (args
, from_tty
);
2645 /* to_attach should push the target, so after this point we
2646 shouldn't refer to attach_target again. */
2647 attach_target
= nullptr;
2649 infrun_debug_show_threads ("immediately after attach",
2650 current_inferior ()->non_exited_threads ());
2652 /* Enable async mode if it is supported by the target. */
2653 if (target_can_async_p ())
2654 target_async (true);
2656 /* Set up the "saved terminal modes" of the inferior
2657 based on what modes we are starting it with. */
2658 target_terminal::init ();
2660 /* Install inferior's terminal modes. This may look like a no-op,
2661 as we've just saved them above, however, this does more than
2662 restore terminal settings:
2664 - installs a SIGINT handler that forwards SIGINT to the inferior.
2665 Otherwise a Ctrl-C pressed just while waiting for the initial
2666 stop would end up as a spurious Quit.
2668 - removes stdin from the event loop, which we need if attaching
2669 in the foreground, otherwise on targets that report an initial
2670 stop on attach (which are most) we'd process input/commands
2671 while we're in the event loop waiting for that stop. That is,
2672 before the attach continuation runs and the command is really
2674 target_terminal::inferior ();
2676 /* Set up execution context to know that we should return from
2677 wait_for_inferior as soon as the target reports a stop. */
2678 init_wait_for_inferior ();
2680 inferior
->needs_setup
= true;
2682 if (target_is_non_stop_p ())
2684 /* If we find that the current thread isn't stopped, explicitly
2685 do so now, because we're going to install breakpoints and
2689 /* The user requested an `attach&'; stop just one thread. */
2690 target_stop (inferior_ptid
);
2692 /* The user requested an `attach', so stop all threads of this
2694 target_stop (ptid_t (inferior_ptid
.pid ()));
2697 /* Check for exec file mismatch, and let the user solve it. */
2698 validate_exec_file (from_tty
);
2700 mode
= async_exec
? ATTACH_POST_WAIT_RESUME
: ATTACH_POST_WAIT_STOP
;
2702 /* Some system don't generate traps when attaching to inferior.
2703 E.g. Mach 3 or GNU hurd. */
2704 if (!target_attach_no_wait ())
2706 /* Careful here. See comments in inferior.h. Basically some
2707 OSes don't ignore SIGSTOPs on continue requests anymore. We
2708 need a way for handle_inferior_event to reset the stop_signal
2709 variable after an attach, and this is what
2710 STOP_QUIETLY_NO_SIGSTOP is for. */
2711 inferior
->control
.stop_soon
= STOP_QUIETLY_NO_SIGSTOP
;
2713 /* Wait for stop. */
2714 inferior
->add_continuation ([=] ()
2716 attach_post_wait (from_tty
, mode
);
2719 /* Let infrun consider waiting for events out of this
2721 inferior
->process_target ()->threads_executing
= true;
2723 if (!target_is_async_p ())
2724 mark_infrun_async_event_handler ();
2728 attach_post_wait (from_tty
, mode
);
2730 disable_commit_resumed
.reset_and_commit ();
2733 /* We had just found out that the target was already attached to an
2734 inferior. PTID points at a thread of this new inferior, that is
2735 the most likely to be stopped right now, but not necessarily so.
2736 The new inferior is assumed to be already added to the inferior
2737 list at this point. If LEAVE_RUNNING, then leave the threads of
2738 this inferior running, except those we've explicitly seen reported
2742 notice_new_inferior (thread_info
*thr
, bool leave_running
, int from_tty
)
2744 enum attach_post_wait_mode mode
2745 = leave_running
? ATTACH_POST_WAIT_RESUME
: ATTACH_POST_WAIT_NOTHING
;
2747 gdb::optional
<scoped_restore_current_thread
> restore_thread
;
2749 if (inferior_ptid
!= null_ptid
)
2750 restore_thread
.emplace ();
2752 /* Avoid reading registers -- we haven't fetched the target
2754 switch_to_thread_no_regs (thr
);
2756 /* When we "notice" a new inferior we need to do all the things we
2757 would normally do if we had just attached to it. */
2759 if (thr
->executing ())
2761 struct inferior
*inferior
= current_inferior ();
2763 /* We're going to install breakpoints, and poke at memory,
2764 ensure that the inferior is stopped for a moment while we do
2766 target_stop (inferior_ptid
);
2768 inferior
->control
.stop_soon
= STOP_QUIETLY_REMOTE
;
2770 /* Wait for stop before proceeding. */
2771 inferior
->add_continuation ([=] ()
2773 attach_post_wait (from_tty
, mode
);
2779 attach_post_wait (from_tty
, mode
);
2784 * takes a program previously attached to and detaches it.
2785 * The program resumes execution and will no longer stop
2786 * on signals, etc. We better not have left any breakpoints
2787 * in the program or it'll die when it hits one. For this
2788 * to work, it may be necessary for the process to have been
2789 * previously attached. It *might* work if the program was
2790 * started via the normal ptrace (PTRACE_TRACEME).
2794 detach_command (const char *args
, int from_tty
)
2796 dont_repeat (); /* Not for the faint of heart. */
2798 if (inferior_ptid
== null_ptid
)
2799 error (_("The program is not being run."));
2801 scoped_disable_commit_resumed
disable_commit_resumed ("detaching");
2803 query_if_trace_running (from_tty
);
2805 disconnect_tracing ();
2807 /* Hold a strong reference to the target while (maybe)
2808 detaching the parent. Otherwise detaching could close the
2811 = target_ops_ref::new_reference (current_inferior ()->process_target ());
2813 /* Save this before detaching, since detaching may unpush the
2814 process_stratum target. */
2815 bool was_non_stop_p
= target_is_non_stop_p ();
2817 target_detach (current_inferior (), from_tty
);
2819 /* The current inferior process was just detached successfully. Get
2820 rid of breakpoints that no longer make sense. Note we don't do
2821 this within target_detach because that is also used when
2822 following child forks, and in that case we will want to transfer
2823 breakpoints to the child, not delete them. */
2824 breakpoint_init_inferior (inf_exited
);
2826 /* If the solist is global across inferiors, don't clear it when we
2827 detach from a single inferior. */
2828 if (!gdbarch_has_global_solist (target_gdbarch ()))
2829 no_shared_libraries (nullptr, from_tty
);
2831 if (deprecated_detach_hook
)
2832 deprecated_detach_hook ();
2834 if (!was_non_stop_p
)
2835 restart_after_all_stop_detach (as_process_stratum_target (target_ref
.get ()));
2837 disable_commit_resumed
.reset_and_commit ();
2840 /* Disconnect from the current target without resuming it (leaving it
2841 waiting for a debugger).
2843 We'd better not have left any breakpoints in the program or the
2844 next debugger will get confused. Currently only supported for some
2845 remote targets, since the normal attach mechanisms don't work on
2846 stopped processes on some native platforms (e.g. GNU/Linux). */
2849 disconnect_command (const char *args
, int from_tty
)
2851 dont_repeat (); /* Not for the faint of heart. */
2852 query_if_trace_running (from_tty
);
2853 disconnect_tracing ();
2854 target_disconnect (args
, from_tty
);
2855 no_shared_libraries (nullptr, from_tty
);
2856 init_thread_list ();
2857 if (deprecated_detach_hook
)
2858 deprecated_detach_hook ();
2861 /* Stop PTID in the current target, and tag the PTID threads as having
2862 been explicitly requested to stop. PTID can be a thread, a
2863 process, or minus_one_ptid, meaning all threads of all inferiors of
2864 the current target. */
2867 stop_current_target_threads_ns (ptid_t ptid
)
2871 /* Tag the thread as having been explicitly requested to stop, so
2872 other parts of gdb know not to resume this thread automatically,
2873 if it was stopped due to an internal event. Limit this to
2874 non-stop mode, as when debugging a multi-threaded application in
2875 all-stop mode, we will only get one stop event --- it's undefined
2876 which thread will report the event. */
2877 set_stop_requested (current_inferior ()->process_target (),
2881 /* See inferior.h. */
2884 interrupt_target_1 (bool all_threads
)
2886 scoped_disable_commit_resumed
disable_commit_resumed ("interrupting");
2892 scoped_restore_current_thread restore_thread
;
2894 for (inferior
*inf
: all_inferiors ())
2896 switch_to_inferior_no_thread (inf
);
2897 stop_current_target_threads_ns (minus_one_ptid
);
2901 stop_current_target_threads_ns (inferior_ptid
);
2904 target_interrupt ();
2906 disable_commit_resumed
.reset_and_commit ();
2910 Stop the execution of the target while running in async mode, in
2911 the background. In all-stop, stop the whole process. In non-stop
2912 mode, stop the current thread only by default, or stop all threads
2913 if the `-a' switch is used. */
2916 interrupt_command (const char *args
, int from_tty
)
2918 if (target_can_async_p ())
2920 int all_threads
= 0;
2922 dont_repeat (); /* Not for the faint of heart. */
2925 && startswith (args
, "-a"))
2928 interrupt_target_1 (all_threads
);
2932 /* See inferior.h. */
2935 default_print_float_info (struct gdbarch
*gdbarch
, struct ui_file
*file
,
2936 frame_info_ptr frame
, const char *args
)
2939 int printed_something
= 0;
2941 for (regnum
= 0; regnum
< gdbarch_num_cooked_regs (gdbarch
); regnum
++)
2943 if (gdbarch_register_reggroup_p (gdbarch
, regnum
, float_reggroup
))
2945 printed_something
= 1;
2946 gdbarch_print_registers_info (gdbarch
, file
, frame
, regnum
, 1);
2949 if (!printed_something
)
2950 gdb_printf (file
, "No floating-point info "
2951 "available for this processor.\n");
2955 info_float_command (const char *args
, int from_tty
)
2957 frame_info_ptr frame
;
2959 if (!target_has_registers ())
2960 error (_("The program has no registers now."));
2962 frame
= get_selected_frame (nullptr);
2963 gdbarch_print_float_info (get_frame_arch (frame
), gdb_stdout
, frame
, args
);
2966 /* Implement `info proc' family of commands. */
2969 info_proc_cmd_1 (const char *args
, enum info_proc_what what
, int from_tty
)
2971 struct gdbarch
*gdbarch
= get_current_arch ();
2973 if (!target_info_proc (args
, what
))
2975 if (gdbarch_info_proc_p (gdbarch
))
2976 gdbarch_info_proc (gdbarch
, args
, what
);
2978 error (_("Not supported on this target."));
2982 /* Implement `info proc' when given without any further parameters. */
2985 info_proc_cmd (const char *args
, int from_tty
)
2987 info_proc_cmd_1 (args
, IP_MINIMAL
, from_tty
);
2990 /* Implement `info proc mappings'. */
2993 info_proc_cmd_mappings (const char *args
, int from_tty
)
2995 info_proc_cmd_1 (args
, IP_MAPPINGS
, from_tty
);
2998 /* Implement `info proc stat'. */
3001 info_proc_cmd_stat (const char *args
, int from_tty
)
3003 info_proc_cmd_1 (args
, IP_STAT
, from_tty
);
3006 /* Implement `info proc status'. */
3009 info_proc_cmd_status (const char *args
, int from_tty
)
3011 info_proc_cmd_1 (args
, IP_STATUS
, from_tty
);
3014 /* Implement `info proc cwd'. */
3017 info_proc_cmd_cwd (const char *args
, int from_tty
)
3019 info_proc_cmd_1 (args
, IP_CWD
, from_tty
);
3022 /* Implement `info proc cmdline'. */
3025 info_proc_cmd_cmdline (const char *args
, int from_tty
)
3027 info_proc_cmd_1 (args
, IP_CMDLINE
, from_tty
);
3030 /* Implement `info proc exe'. */
3033 info_proc_cmd_exe (const char *args
, int from_tty
)
3035 info_proc_cmd_1 (args
, IP_EXE
, from_tty
);
3038 /* Implement `info proc files'. */
3041 info_proc_cmd_files (const char *args
, int from_tty
)
3043 info_proc_cmd_1 (args
, IP_FILES
, from_tty
);
3046 /* Implement `info proc all'. */
3049 info_proc_cmd_all (const char *args
, int from_tty
)
3051 info_proc_cmd_1 (args
, IP_ALL
, from_tty
);
3054 /* Implement `show print finish'. */
3057 show_print_finish (struct ui_file
*file
, int from_tty
,
3058 struct cmd_list_element
*c
,
3061 gdb_printf (file
, _("\
3062 Printing of return value after `finish' is %s.\n"),
3067 /* This help string is used for the run, start, and starti commands.
3068 It is defined as a macro to prevent duplication. */
3070 #define RUN_ARGS_HELP \
3071 "You may specify arguments to give it.\n\
3072 Args may include \"*\", or \"[...]\"; they are expanded using the\n\
3073 shell that will start the program (specified by the \"$SHELL\" environment\n\
3074 variable). Input and output redirection with \">\", \"<\", or \">>\"\n\
3075 are also allowed.\n\
3077 With no arguments, uses arguments last specified (with \"run\" or \n\
3078 \"set args\"). To cancel previous arguments and run with no arguments,\n\
3079 use \"set args\" without arguments.\n\
3081 To start the inferior without using a shell, use \"set startup-with-shell off\"."
3083 void _initialize_infcmd ();
3085 _initialize_infcmd ()
3087 static struct cmd_list_element
*info_proc_cmdlist
;
3088 struct cmd_list_element
*c
= nullptr;
3089 const char *cmd_name
;
3091 /* Add the filename of the terminal connected to inferior I/O. */
3092 add_setshow_optional_filename_cmd ("inferior-tty", class_run
,
3093 &inferior_io_terminal_scratch
, _("\
3094 Set terminal for future runs of program being debugged."), _("\
3095 Show terminal for future runs of program being debugged."), _("\
3096 Usage: set inferior-tty [TTY]\n\n\
3097 If TTY is omitted, the default behavior of using the same terminal as GDB\n\
3099 set_inferior_tty_command
,
3100 show_inferior_tty_command
,
3101 &setlist
, &showlist
);
3102 cmd_name
= "inferior-tty";
3103 c
= lookup_cmd (&cmd_name
, setlist
, "", nullptr, -1, 1);
3104 gdb_assert (c
!= nullptr);
3105 add_alias_cmd ("tty", c
, class_run
, 0, &cmdlist
);
3108 add_setshow_string_noescape_cmd (cmd_name
, class_run
,
3109 &inferior_args_scratch
, _("\
3110 Set argument list to give program being debugged when it is started."), _("\
3111 Show argument list to give program being debugged when it is started."), _("\
3112 Follow this command with any number of args, to be passed to the program."),
3115 &setlist
, &showlist
);
3116 c
= lookup_cmd (&cmd_name
, setlist
, "", nullptr, -1, 1);
3117 gdb_assert (c
!= nullptr);
3118 set_cmd_completer (c
, filename_completer
);
3121 add_setshow_string_noescape_cmd (cmd_name
, class_run
,
3122 &inferior_cwd_scratch
, _("\
3123 Set the current working directory to be used when the inferior is started.\n\
3124 Changing this setting does not have any effect on inferiors that are\n\
3127 Show the current working directory that is used when the inferior is started."),
3129 Use this command to change the current working directory that will be used\n\
3130 when the inferior is started. This setting does not affect GDB's current\n\
3131 working directory."),
3134 &setlist
, &showlist
);
3135 c
= lookup_cmd (&cmd_name
, setlist
, "", nullptr, -1, 1);
3136 gdb_assert (c
!= nullptr);
3137 set_cmd_completer (c
, filename_completer
);
3139 c
= add_cmd ("environment", no_class
, environment_info
, _("\
3140 The environment to give the program, or one variable's value.\n\
3141 With an argument VAR, prints the value of environment variable VAR to\n\
3142 give the program being debugged. With no arguments, prints the entire\n\
3143 environment to be given to the program."), &showlist
);
3144 set_cmd_completer (c
, noop_completer
);
3146 add_basic_prefix_cmd ("unset", no_class
,
3147 _("Complement to certain \"set\" commands."),
3148 &unsetlist
, 0, &cmdlist
);
3150 c
= add_cmd ("environment", class_run
, unset_environment_command
, _("\
3151 Cancel environment variable VAR for the program.\n\
3152 This does not affect the program until the next \"run\" command."),
3154 set_cmd_completer (c
, noop_completer
);
3156 c
= add_cmd ("environment", class_run
, set_environment_command
, _("\
3157 Set environment variable value to give the program.\n\
3158 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
3159 VALUES of environment variables are uninterpreted strings.\n\
3160 This does not affect the program until the next \"run\" command."),
3162 set_cmd_completer (c
, noop_completer
);
3164 c
= add_com ("path", class_files
, path_command
, _("\
3165 Add directory DIR(s) to beginning of search path for object files.\n\
3166 $cwd in the path means the current working directory.\n\
3167 This path is equivalent to the $PATH shell variable. It is a list of\n\
3168 directories, separated by colons. These directories are searched to find\n\
3169 fully linked executable files and separately compiled object files as \
3171 set_cmd_completer (c
, filename_completer
);
3173 c
= add_cmd ("paths", no_class
, path_info
, _("\
3174 Current search path for finding object files.\n\
3175 $cwd in the path means the current working directory.\n\
3176 This path is equivalent to the $PATH shell variable. It is a list of\n\
3177 directories, separated by colons. These directories are searched to find\n\
3178 fully linked executable files and separately compiled object files as \
3181 set_cmd_completer (c
, noop_completer
);
3183 add_prefix_cmd ("kill", class_run
, kill_command
,
3184 _("Kill execution of program being debugged."),
3185 &killlist
, 0, &cmdlist
);
3187 add_com ("attach", class_run
, attach_command
, _("\
3188 Attach to a process or file outside of GDB.\n\
3189 This command attaches to another target, of the same type as your last\n\
3190 \"target\" command (\"info files\" will show your target stack).\n\
3191 The command may take as argument a process id or a device file.\n\
3192 For a process id, you must have permission to send the process a signal,\n\
3193 and it must have the same effective uid as the debugger.\n\
3194 When using \"attach\" with a process id, the debugger finds the\n\
3195 program running in the process, looking first in the current working\n\
3196 directory, or (if not found there) using the source file search path\n\
3197 (see the \"directory\" command). You can also use the \"file\" command\n\
3198 to specify the program, and to load its symbol table."));
3200 add_prefix_cmd ("detach", class_run
, detach_command
, _("\
3201 Detach a process or file previously attached.\n\
3202 If a process, it is no longer traced, and it continues its execution. If\n\
3203 you were debugging a file, the file is closed and gdb no longer accesses it."),
3204 &detachlist
, 0, &cmdlist
);
3206 add_com ("disconnect", class_run
, disconnect_command
, _("\
3207 Disconnect from a target.\n\
3208 The target will wait for another debugger to connect. Not available for\n\
3211 c
= add_com ("signal", class_run
, signal_command
, _("\
3212 Continue program with the specified signal.\n\
3213 Usage: signal SIGNAL\n\
3214 The SIGNAL argument is processed the same as the handle command.\n\
3216 An argument of \"0\" means continue the program without sending it a signal.\n\
3217 This is useful in cases where the program stopped because of a signal,\n\
3218 and you want to resume the program while discarding the signal.\n\
3220 In a multi-threaded program the signal is delivered to, or discarded from,\n\
3221 the current thread only."));
3222 set_cmd_completer (c
, signal_completer
);
3224 c
= add_com ("queue-signal", class_run
, queue_signal_command
, _("\
3225 Queue a signal to be delivered to the current thread when it is resumed.\n\
3226 Usage: queue-signal SIGNAL\n\
3227 The SIGNAL argument is processed the same as the handle command.\n\
3228 It is an error if the handling state of SIGNAL is \"nopass\".\n\
3230 An argument of \"0\" means remove any currently queued signal from\n\
3231 the current thread. This is useful in cases where the program stopped\n\
3232 because of a signal, and you want to resume it while discarding the signal.\n\
3234 In a multi-threaded program the signal is queued with, or discarded from,\n\
3235 the current thread only."));
3236 set_cmd_completer (c
, signal_completer
);
3238 cmd_list_element
*stepi_cmd
3239 = add_com ("stepi", class_run
, stepi_command
, _("\
3240 Step one instruction exactly.\n\
3242 Argument N means step N times (or till program stops for another \
3244 add_com_alias ("si", stepi_cmd
, class_run
, 0);
3246 cmd_list_element
*nexti_cmd
3247 = add_com ("nexti", class_run
, nexti_command
, _("\
3248 Step one instruction, but proceed through subroutine calls.\n\
3250 Argument N means step N times (or till program stops for another \
3252 add_com_alias ("ni", nexti_cmd
, class_run
, 0);
3254 cmd_list_element
*finish_cmd
3255 = add_com ("finish", class_run
, finish_command
, _("\
3256 Execute until selected stack frame returns.\n\
3258 Upon return, the value returned is printed and put in the value history."));
3259 add_com_alias ("fin", finish_cmd
, class_run
, 1);
3261 cmd_list_element
*next_cmd
3262 = add_com ("next", class_run
, next_command
, _("\
3263 Step program, proceeding through subroutine calls.\n\
3265 Unlike \"step\", if the current source line calls a subroutine,\n\
3266 this command does not enter the subroutine, but instead steps over\n\
3267 the call, in effect treating it as a single source line."));
3268 add_com_alias ("n", next_cmd
, class_run
, 1);
3270 cmd_list_element
*step_cmd
3271 = add_com ("step", class_run
, step_command
, _("\
3272 Step program until it reaches a different source line.\n\
3274 Argument N means step N times (or till program stops for another \
3276 add_com_alias ("s", step_cmd
, class_run
, 1);
3278 cmd_list_element
*until_cmd
3279 = add_com ("until", class_run
, until_command
, _("\
3280 Execute until past the current line or past a LOCATION.\n\
3281 Execute until the program reaches a source line greater than the current\n\
3282 or a specified location (same args as break command) within the current \
3284 set_cmd_completer (until_cmd
, location_completer
);
3285 add_com_alias ("u", until_cmd
, class_run
, 1);
3287 c
= add_com ("advance", class_run
, advance_command
, _("\
3288 Continue the program up to the given location (same form as args for break \
3290 Execution will also stop upon exit from the current stack frame."));
3291 set_cmd_completer (c
, location_completer
);
3293 cmd_list_element
*jump_cmd
3294 = add_com ("jump", class_run
, jump_command
, _("\
3295 Continue program being debugged at specified line or address.\n\
3296 Usage: jump LOCATION\n\
3297 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
3298 for an address to start at."));
3299 set_cmd_completer (jump_cmd
, location_completer
);
3300 add_com_alias ("j", jump_cmd
, class_run
, 1);
3302 cmd_list_element
*continue_cmd
3303 = add_com ("continue", class_run
, continue_command
, _("\
3304 Continue program being debugged, after signal or breakpoint.\n\
3305 Usage: continue [N]\n\
3306 If proceeding from breakpoint, a number N may be used as an argument,\n\
3307 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
3308 the breakpoint won't break until the Nth time it is reached).\n\
3310 If non-stop mode is enabled, continue only the current thread,\n\
3311 otherwise all the threads in the program are continued. To \n\
3312 continue all stopped threads in non-stop mode, use the -a option.\n\
3313 Specifying -a and an ignore count simultaneously is an error."));
3314 add_com_alias ("c", continue_cmd
, class_run
, 1);
3315 add_com_alias ("fg", continue_cmd
, class_run
, 1);
3317 cmd_list_element
*run_cmd
3318 = add_com ("run", class_run
, run_command
, _("\
3319 Start debugged program.\n"
3321 set_cmd_completer (run_cmd
, filename_completer
);
3322 add_com_alias ("r", run_cmd
, class_run
, 1);
3324 c
= add_com ("start", class_run
, start_command
, _("\
3325 Start the debugged program stopping at the beginning of the main procedure.\n"
3327 set_cmd_completer (c
, filename_completer
);
3329 c
= add_com ("starti", class_run
, starti_command
, _("\
3330 Start the debugged program stopping at the first instruction.\n"
3332 set_cmd_completer (c
, filename_completer
);
3334 add_com ("interrupt", class_run
, interrupt_command
,
3335 _("Interrupt the execution of the debugged program.\n\
3336 If non-stop mode is enabled, interrupt only the current thread,\n\
3337 otherwise all the threads in the program are stopped. To \n\
3338 interrupt all running threads in non-stop mode, use the -a option."));
3340 cmd_list_element
*info_registers_cmd
3341 = add_info ("registers", info_registers_command
, _("\
3342 List of integer registers and their contents, for selected stack frame.\n\
3343 One or more register names as argument means describe the given registers.\n\
3344 One or more register group names as argument means describe the registers\n\
3345 in the named register groups."));
3346 add_info_alias ("r", info_registers_cmd
, 1);
3347 set_cmd_completer (info_registers_cmd
, reg_or_group_completer
);
3349 c
= add_info ("all-registers", info_all_registers_command
, _("\
3350 List of all registers and their contents, for selected stack frame.\n\
3351 One or more register names as argument means describe the given registers.\n\
3352 One or more register group names as argument means describe the registers\n\
3353 in the named register groups."));
3354 set_cmd_completer (c
, reg_or_group_completer
);
3356 add_info ("program", info_program_command
,
3357 _("Execution status of the program."));
3359 add_info ("float", info_float_command
,
3360 _("Print the status of the floating point unit."));
3362 add_info ("vector", info_vector_command
,
3363 _("Print the status of the vector unit."));
3365 add_prefix_cmd ("proc", class_info
, info_proc_cmd
,
3367 Show additional information about a process.\n\
3368 Specify any process id, or use the program being debugged by default."),
3370 1/*allow-unknown*/, &infolist
);
3372 add_cmd ("mappings", class_info
, info_proc_cmd_mappings
, _("\
3373 List memory regions mapped by the specified process."),
3374 &info_proc_cmdlist
);
3376 add_cmd ("stat", class_info
, info_proc_cmd_stat
, _("\
3377 List process info from /proc/PID/stat."),
3378 &info_proc_cmdlist
);
3380 add_cmd ("status", class_info
, info_proc_cmd_status
, _("\
3381 List process info from /proc/PID/status."),
3382 &info_proc_cmdlist
);
3384 add_cmd ("cwd", class_info
, info_proc_cmd_cwd
, _("\
3385 List current working directory of the specified process."),
3386 &info_proc_cmdlist
);
3388 add_cmd ("cmdline", class_info
, info_proc_cmd_cmdline
, _("\
3389 List command line arguments of the specified process."),
3390 &info_proc_cmdlist
);
3392 add_cmd ("exe", class_info
, info_proc_cmd_exe
, _("\
3393 List absolute filename for executable of the specified process."),
3394 &info_proc_cmdlist
);
3396 add_cmd ("files", class_info
, info_proc_cmd_files
, _("\
3397 List files opened by the specified process."),
3398 &info_proc_cmdlist
);
3400 add_cmd ("all", class_info
, info_proc_cmd_all
, _("\
3401 List all available info about the specified process."),
3402 &info_proc_cmdlist
);
3404 add_setshow_boolean_cmd ("finish", class_support
,
3406 Set whether `finish' prints the return value."), _("\
3407 Show whether `finish' prints the return value."), nullptr,
3410 &setprintlist
, &showprintlist
);