GDB (xrefs)
Loading...
Searching...
No Matches
infcmd.c
Go to the documentation of this file.
1/* Memory-access and commands for "inferior" process, for GDB.
2
3 Copyright (C) 1986-2023 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20#include "defs.h"
21#include "arch-utils.h"
22#include "symtab.h"
23#include "gdbtypes.h"
24#include "frame.h"
25#include "inferior.h"
26#include "infrun.h"
27#include "gdbsupport/environ.h"
28#include "value.h"
29#include "gdbcmd.h"
30#include "symfile.h"
31#include "gdbcore.h"
32#include "target.h"
33#include "language.h"
34#include "objfiles.h"
35#include "completer.h"
36#include "ui-out.h"
37#include "regcache.h"
38#include "reggroups.h"
39#include "block.h"
40#include "solib.h"
41#include <ctype.h>
42#include "observable.h"
43#include "target-descriptions.h"
44#include "user-regs.h"
45#include "gdbthread.h"
46#include "valprint.h"
47#include "inline-frame.h"
48#include "tracepoint.h"
49#include "inf-loop.h"
50#include "linespec.h"
51#include "thread-fsm.h"
52#include "ui.h"
53#include "interps.h"
54#include "skip.h"
55#include "gdbsupport/gdb_optional.h"
56#include "source.h"
57#include "cli/cli-style.h"
58#include "dwarf2/loc.h"
59
60/* Local functions: */
61
62static void until_next_command (int);
63
64static void step_1 (int, int, const char *);
65
66#define ERROR_NO_INFERIOR \
67 if (!target_has_execution ()) error (_("The program is not being run."));
68
69/* Pid of our debugged inferior, or 0 if no inferior now.
70 Since various parts of infrun.c test this to see whether there is a program
71 being debugged it should be nonzero (currently 3 is used) for remote
72 debugging. */
73
75
76/* Nonzero if stopped due to completion of a stack dummy routine. */
77
79
80/* Nonzero if stopped due to a random (unexpected) signal in inferior
81 process. */
82
84
85
86/* Whether "finish" should print the value. */
87
88static bool finish_print = true;
89
90
91
92/* Store the new value passed to 'set inferior-tty'. */
93
94static void
95set_tty_value (const std::string &tty)
96{
97 current_inferior ()->set_tty (tty);
98}
99
100/* Get the current 'inferior-tty' value. */
101
102static const std::string &
104{
105 return current_inferior ()->tty ();
106}
107
108/* Implement 'show inferior-tty' command. */
109
110static void
111show_inferior_tty_command (struct ui_file *file, int from_tty,
112 struct cmd_list_element *c, const char *value)
113{
114 /* Note that we ignore the passed-in value in favor of computing it
115 directly. */
116 const std::string &inferior_tty = current_inferior ()->tty ();
117
118 gdb_printf (file,
119 _("Terminal for future runs of program being debugged "
120 "is \"%s\".\n"), inferior_tty.c_str ());
121}
122
123/* Store the new value passed to 'set args'. */
124
125static void
126set_args_value (const std::string &args)
127{
128 current_inferior ()->set_args (args);
129}
130
131/* Return the value for 'show args' to display. */
132
133static const std::string &
135{
136 return current_inferior ()->args ();
137}
138
139/* Callback to implement 'show args' command. */
140
141static void
142show_args_command (struct ui_file *file, int from_tty,
143 struct cmd_list_element *c, const char *value)
144{
145 /* Ignore the passed in value, pull the argument directly from the
146 inferior. However, these should always be the same. */
147 gdb_printf (file, _("\
148Argument list to give program being debugged when it is started is \"%s\".\n"),
149 current_inferior ()->args ().c_str ());
150}
151
152/* See gdbsupport/common-inferior.h. */
153
154const std::string &
156{
157 return current_inferior ()->cwd ();
158}
159
160/* Store the new value passed to 'set cwd'. */
161
162static void
163set_cwd_value (const std::string &args)
164{
165 current_inferior ()->set_cwd (args);
166}
167
168/* Handle the 'show cwd' command. */
169
170static void
171show_cwd_command (struct ui_file *file, int from_tty,
172 struct cmd_list_element *c, const char *value)
173{
174 const std::string &cwd = current_inferior ()->cwd ();
175
176 if (cwd.empty ())
177 gdb_printf (file,
178 _("\
179You have not set the inferior's current working directory.\n\
180The inferior will inherit GDB's cwd if native debugging, or the remote\n\
181server's cwd if remote debugging.\n"));
182 else
183 gdb_printf (file,
184 _("Current working directory that will be used "
185 "when starting the inferior is \"%s\".\n"),
186 cwd.c_str ());
187}
188
189
190/* This function strips the '&' character (indicating background
191 execution) that is added as *the last* of the arguments ARGS of a
192 command. A copy of the incoming ARGS without the '&' is returned,
193 unless the resulting string after stripping is empty, in which case
194 NULL is returned. *BG_CHAR_P is an output boolean that indicates
195 whether the '&' character was found. */
196
197static gdb::unique_xmalloc_ptr<char>
198strip_bg_char (const char *args, int *bg_char_p)
199{
200 const char *p;
201
202 if (args == nullptr || *args == '\0')
203 {
204 *bg_char_p = 0;
205 return nullptr;
206 }
207
208 p = args + strlen (args);
209 if (p[-1] == '&')
210 {
211 p--;
212 while (p > args && isspace (p[-1]))
213 p--;
214
215 *bg_char_p = 1;
216 if (p != args)
217 return gdb::unique_xmalloc_ptr<char>
218 (savestring (args, p - args));
219 else
220 return gdb::unique_xmalloc_ptr<char> (nullptr);
221 }
222
223 *bg_char_p = 0;
224 return make_unique_xstrdup (args);
225}
226
227/* Common actions to take after creating any sort of inferior, by any
228 means (running, attaching, connecting, et cetera). The target
229 should be stopped. */
230
231void
233{
234
235 /* Be sure we own the terminal in case write operations are performed. */
237
238 infrun_debug_show_threads ("threads in the newly created inferior",
239 current_inferior ()->non_exited_threads ());
240
241 /* If the target hasn't taken care of this already, do it now.
242 Targets which need to access registers during to_open,
243 to_create_inferior, or to_attach should do it earlier; but many
244 don't need to. */
246
247 /* Now that we know the register layout, retrieve current PC. But
248 if the PC is unavailable (e.g., we're opening a core file with
249 missing registers info), ignore it. */
251
252 thr->clear_stop_pc ();
253 try
254 {
255 regcache *rc = get_thread_regcache (thr);
256 thr->set_stop_pc (regcache_read_pc (rc));
257 }
258 catch (const gdb_exception_error &ex)
259 {
260 if (ex.error != NOT_AVAILABLE_ERROR)
261 throw;
262 }
263
265 {
266 const unsigned solib_add_generation
268
269 scoped_restore restore_in_initial_library_scan
270 = make_scoped_restore (&current_inferior ()->in_initial_library_scan,
271 true);
272
273 /* Create the hooks to handle shared library load and unload
274 events. */
276
277 if (current_program_space->solib_add_generation == solib_add_generation)
278 {
279 /* The platform-specific hook should load initial shared libraries,
280 but didn't. FROM_TTY will be incorrectly 0 but such solib
281 targets should be fixed anyway. Call it only after the solib
282 target has been initialized by solib_create_inferior_hook. */
283
284 if (info_verbose)
285 warning (_("platform-specific solib_create_inferior_hook did "
286 "not load initial shared libraries."));
287
288 /* If the solist is global across processes, there's no need to
289 refetch it here. */
291 solib_add (nullptr, 0, auto_solib_add);
292 }
293 }
294
295 /* If the user sets watchpoints before execution having started,
296 then she gets software watchpoints, because GDB can't know which
297 target will end up being pushed, or if it supports hardware
298 watchpoints or not. breakpoint_re_set takes care of promoting
299 watchpoints to hardware watchpoints if possible, however, if this
300 new inferior doesn't load shared libraries or we don't pull in
301 symbols from any other source on this target/arch,
302 breakpoint_re_set is never called. Call it now so that software
303 watchpoints get a chance to be promoted to hardware watchpoints
304 if the now pushed target supports hardware watchpoints. */
306
308}
309
310/* Kill the inferior if already running. This function is designed
311 to be called when we are about to start the execution of the program
312 from the beginning. Ask the user to confirm that he wants to restart
313 the program being debugged when FROM_TTY is non-null. */
314
315static void
317{
318 if (inferior_ptid != null_ptid && target_has_execution ())
319 {
320 /* Bail out before killing the program if we will not be able to
321 restart it. */
323
324 if (from_tty
325 && !query (_("The program being debugged has been started already.\n\
326Start it from the beginning? ")))
327 error (_("Program not restarted."));
328 target_kill ();
329 }
330}
331
332/* See inferior.h. */
333
334void
335prepare_execution_command (struct target_ops *target, int background)
336{
337 /* If we get a request for running in the bg but the target
338 doesn't support it, error out. */
339 if (background && !target_can_async_p (target))
340 error (_("Asynchronous execution not supported on this target."));
341
342 if (!background)
343 {
344 /* If we get a request for running in the fg, then we need to
345 simulate synchronous (fg) execution. Note no cleanup is
346 necessary for this. stdin is re-enabled whenever an error
347 reaches the top level. */
349 }
350}
351
352/* Determine how the new inferior will behave. */
353
355 {
356 /* Run program without any explicit stop during startup. */
358
359 /* Stop at the beginning of the program's main function. */
361
362 /* Stop at the first instruction of the program. */
364 };
365
366/* Implement the "run" command. Force a stop during program start if
367 requested by RUN_HOW. */
368
369static void
370run_command_1 (const char *args, int from_tty, enum run_how run_how)
371{
372 const char *exec_file;
373 struct ui_out *uiout = current_uiout;
374 struct target_ops *run_target;
375 int async_exec;
376
377 dont_repeat ();
378
379 scoped_disable_commit_resumed disable_commit_resumed ("running");
380
381 kill_if_already_running (from_tty);
382
385
386 /* Clean up any leftovers from other runs. Some other things from
387 this function should probably be moved into target_pre_inferior. */
388 target_pre_inferior (from_tty);
389
390 /* The comment here used to read, "The exec file is re-read every
391 time we do a generic_mourn_inferior, so we just have to worry
392 about the symbol file." The `generic_mourn_inferior' function
393 gets called whenever the program exits. However, suppose the
394 program exits, and *then* the executable file changes? We need
395 to check again here. Since reopen_exec_file doesn't do anything
396 if the timestamp hasn't changed, I don't see the harm. */
398 reread_symbols (from_tty);
399
400 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (args, &async_exec);
401 args = stripped.get ();
402
403 /* Do validation and preparation before possibly changing anything
404 in the inferior. */
405
406 run_target = find_run_target ();
407
408 prepare_execution_command (run_target, async_exec);
409
410 if (non_stop && !run_target->supports_non_stop ())
411 error (_("The target does not support running in non-stop mode."));
412
413 /* Done. Can now set breakpoints, change inferior args, etc. */
414
415 /* Insert temporary breakpoint in main function if requested. */
417 {
418 /* To avoid other inferiors hitting this breakpoint, make it
419 inferior-specific. */
420 std::string arg = string_printf ("-qualified %s inferior %d",
421 main_name (),
422 current_inferior ()->num);
423 tbreak_command (arg.c_str (), 0);
424 }
425
426 exec_file = get_exec_file (0);
427
428 /* We keep symbols from add-symbol-file, on the grounds that the
429 user might want to add some symbols before running the program
430 (right?). But sometimes (dynamic loading where the user manually
431 introduces the new symbols with add-symbol-file), the code which
432 the symbols describe does not persist between runs. Currently
433 the user has to manually nuke all symbols between runs if they
434 want them to go away (PR 2207). This is probably reasonable. */
435
436 /* If there were other args, beside '&', process them. */
437 if (args != nullptr)
438 current_inferior ()->set_args (args);
439
440 if (from_tty)
441 {
442 uiout->field_string (nullptr, "Starting program");
443 uiout->text (": ");
444 if (exec_file)
445 uiout->field_string ("execfile", exec_file,
447 uiout->spaces (1);
448 uiout->field_string ("infargs", current_inferior ()->args ());
449 uiout->text ("\n");
450 uiout->flush ();
451 }
452
453 run_target->create_inferior (exec_file,
454 current_inferior ()->args (),
455 current_inferior ()->environment.envp (),
456 from_tty);
457 /* to_create_inferior should push the target, so after this point we
458 shouldn't refer to run_target again. */
459 run_target = nullptr;
460
461 infrun_debug_show_threads ("immediately after create_process",
462 current_inferior ()->non_exited_threads ());
463
464 /* We're starting off a new process. When we get out of here, in
465 non-stop mode, finish the state of all threads of that process,
466 but leave other threads alone, as they may be stopped in internal
467 events --- the frontend shouldn't see them as stopped. In
468 all-stop, always finish the state of all threads, as we may be
469 resuming more than just the new process. */
470 process_stratum_target *finish_target;
471 ptid_t finish_ptid;
472 if (non_stop)
473 {
474 finish_target = current_inferior ()->process_target ();
475 finish_ptid = ptid_t (current_inferior ()->pid);
476 }
477 else
478 {
479 finish_target = nullptr;
480 finish_ptid = minus_one_ptid;
481 }
482 scoped_finish_thread_state finish_state (finish_target, finish_ptid);
483
484 /* Pass zero for FROM_TTY, because at this point the "run" command
485 has done its thing; now we are setting up the running program. */
487
488 /* Queue a pending event so that the program stops immediately. */
490 {
493 ws.set_stopped (GDB_SIGNAL_0);
494 thr->set_pending_waitstatus (ws);
495 }
496
497 /* Start the target running. Do not use -1 continuation as it would skip
498 breakpoint right at the entry point. */
499 proceed (regcache_read_pc (get_current_regcache ()), GDB_SIGNAL_0);
500
501 /* Since there was no error, there's no need to finish the thread
502 states here. */
503 finish_state.release ();
504
505 disable_commit_resumed.reset_and_commit ();
506}
507
508static void
509run_command (const char *args, int from_tty)
510{
511 run_command_1 (args, from_tty, RUN_NORMAL);
512}
513
514/* Start the execution of the program up until the beginning of the main
515 program. */
516
517static void
518start_command (const char *args, int from_tty)
519{
520 /* Some languages such as Ada need to search inside the program
521 minimal symbols for the location where to put the temporary
522 breakpoint before starting. */
523 if (!have_minimal_symbols ())
524 error (_("No symbol table loaded. Use the \"file\" command."));
525
526 /* Run the program until reaching the main procedure... */
527 run_command_1 (args, from_tty, RUN_STOP_AT_MAIN);
528}
529
530/* Start the execution of the program stopping at the first
531 instruction. */
532
533static void
534starti_command (const char *args, int from_tty)
535{
536 run_command_1 (args, from_tty, RUN_STOP_AT_FIRST_INSN);
537}
538
539static int
540proceed_thread_callback (struct thread_info *thread, void *arg)
541{
542 /* We go through all threads individually instead of compressing
543 into a single target `resume_all' request, because some threads
544 may be stopped in internal breakpoints/events, or stopped waiting
545 for its turn in the displaced stepping queue (that is, they are
546 running && !executing). The target side has no idea about why
547 the thread is stopped, so a `resume_all' command would resume too
548 much. If/when GDB gains a way to tell the target `hold this
549 thread stopped until I say otherwise', then we can optimize
550 this. */
551 if (thread->state != THREAD_STOPPED)
552 return 0;
553
554 if (!thread->inf->has_execution ())
555 return 0;
556
557 switch_to_thread (thread);
559 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
560 return 0;
561}
562
563static void
565{
566 if (inferior_ptid == null_ptid
567 || inferior_thread ()->state == THREAD_EXITED)
568 error (_("Cannot execute this command without a live selected thread."));
569}
570
571/* If the user is looking at trace frames, any resumption of execution
572 is likely to mix up recorded and live target data. So simply
573 disallow those commands. */
574
575static void
577{
578 if (get_traceframe_number () >= 0)
579 error (_("Cannot execute this command while looking at trace frames."));
580}
581
582/* Throw an error indicating the current thread is running. */
583
584static void
586{
587 error (_("Cannot execute this command while "
588 "the selected thread is running."));
589}
590
591/* Calls error_is_running if the current thread is running. */
592
593static void
595{
596 if (inferior_thread ()->state == THREAD_RUNNING)
598}
599
600void
602{
605
606 if (non_stop && all_threads)
607 {
608 /* Don't error out if the current thread is running, because
609 there may be other stopped threads. */
610
611 /* Backup current thread and selected frame and restore on scope
612 exit. */
613 scoped_restore_current_thread restore_thread;
614 scoped_disable_commit_resumed disable_commit_resumed
615 ("continue all threads in non-stop");
616
618
620 {
621 /* If all threads in the target were already running,
622 proceed_thread_callback ends up never calling proceed,
623 and so nothing calls this to put the inferior's terminal
624 settings in effect and remove stdin from the event loop,
625 which we must when running a foreground command. E.g.:
626
627 (gdb) c -a&
628 Continuing.
629 <all threads are running now>
630 (gdb) c -a
631 Continuing.
632 <no thread was resumed, but the inferior now owns the terminal>
633 */
635 }
636
637 disable_commit_resumed.reset_and_commit ();
638 }
639 else
640 {
644 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
645 }
646}
647
648/* continue [-a] [proceed-count] [&] */
649
650static void
651continue_command (const char *args, int from_tty)
652{
653 int async_exec;
654 bool all_threads_p = false;
655
657
658 /* Find out whether we must run in the background. */
659 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (args, &async_exec);
660 args = stripped.get ();
661
662 if (args != nullptr)
663 {
664 if (startswith (args, "-a"))
665 {
666 all_threads_p = true;
667 args += sizeof ("-a") - 1;
668 if (*args == '\0')
669 args = nullptr;
670 }
671 }
672
673 if (!non_stop && all_threads_p)
674 error (_("`-a' is meaningless in all-stop mode."));
675
676 if (args != nullptr && all_threads_p)
677 error (_("Can't resume all threads and specify "
678 "proceed count simultaneously."));
679
680 /* If we have an argument left, set proceed count of breakpoint we
681 stopped at. */
682 if (args != nullptr)
683 {
684 bpstat *bs = nullptr;
685 int num, stat;
686 int stopped = 0;
687 struct thread_info *tp;
688
689 if (non_stop)
690 tp = inferior_thread ();
691 else
692 {
693 process_stratum_target *last_target;
694 ptid_t last_ptid;
695
696 get_last_target_status (&last_target, &last_ptid, nullptr);
697 tp = last_target->find_thread (last_ptid);
698 }
699 if (tp != nullptr)
700 bs = tp->control.stop_bpstat;
701
702 while ((stat = bpstat_num (&bs, &num)) != 0)
703 if (stat > 0)
704 {
705 set_ignore_count (num,
706 parse_and_eval_long (args) - 1,
707 from_tty);
708 /* set_ignore_count prints a message ending with a period.
709 So print two spaces before "Continuing.". */
710 if (from_tty)
711 gdb_printf (" ");
712 stopped = 1;
713 }
714
715 if (!stopped && from_tty)
716 {
718 ("Not stopped at any breakpoint; argument ignored.\n");
719 }
720 }
721
723
724 if (!non_stop || !all_threads_p)
725 {
728 }
729
730 prepare_execution_command (current_inferior ()->top_target (), async_exec);
731
732 if (from_tty)
733 gdb_printf (_("Continuing.\n"));
734
735 continue_1 (all_threads_p);
736}
737
738/* Record in TP the starting point of a "step" or "next" command. */
739
740static void
742{
743 /* This can be removed once this function no longer implicitly relies on the
744 inferior_ptid value. */
745 gdb_assert (inferior_ptid == tp->ptid);
746
748
749 symtab_and_line sal = find_frame_sal (frame);
750 set_step_info (tp, frame, sal);
751
752 CORE_ADDR pc = get_frame_pc (frame);
754}
755
756/* Step until outside of current statement. */
757
758static void
759step_command (const char *count_string, int from_tty)
760{
761 step_1 (0, 0, count_string);
762}
763
764/* Likewise, but skip over subroutine calls as if single instructions. */
765
766static void
767next_command (const char *count_string, int from_tty)
768{
769 step_1 (1, 0, count_string);
770}
771
772/* Likewise, but step only one instruction. */
773
774static void
775stepi_command (const char *count_string, int from_tty)
776{
777 step_1 (0, 1, count_string);
778}
779
780static void
781nexti_command (const char *count_string, int from_tty)
782{
783 step_1 (1, 1, count_string);
784}
785
786/* Data for the FSM that manages the step/next/stepi/nexti
787 commands. */
788
790{
791 /* How many steps left in a "step N"-like command. */
792 int count;
793
794 /* If true, this is a next/nexti, otherwise a step/stepi. */
796
797 /* If true, this is a stepi/nexti, otherwise a step/step. */
799
800 explicit step_command_fsm (struct interp *cmd_interp)
801 : thread_fsm (cmd_interp)
802 {
803 }
804
805 void clean_up (struct thread_info *thread) override;
806 bool should_stop (struct thread_info *thread) override;
808};
809
810/* Prepare for a step/next/etc. command. Any target resource
811 allocated here is undone in the FSM's clean_up method. */
812
813static void
815 int skip_subroutines, int single_inst,
816 int count, struct thread_info *thread)
817{
818 sm->skip_subroutines = skip_subroutines;
819 sm->single_inst = single_inst;
820 sm->count = count;
821
822 /* Leave the si command alone. */
823 if (!sm->single_inst || sm->skip_subroutines)
825
826 thread->control.stepping_command = 1;
827}
828
829static int prepare_one_step (thread_info *, struct step_command_fsm *sm);
830
831static void
832step_1 (int skip_subroutines, int single_inst, const char *count_string)
833{
834 int count;
835 int async_exec;
836 struct thread_info *thr;
837 struct step_command_fsm *step_sm;
838
843
844 gdb::unique_xmalloc_ptr<char> stripped
845 = strip_bg_char (count_string, &async_exec);
846 count_string = stripped.get ();
847
848 prepare_execution_command (current_inferior ()->top_target (), async_exec);
849
850 count = count_string ? parse_and_eval_long (count_string) : 1;
851
853
854 /* Setup the execution command state machine to handle all the COUNT
855 steps. */
856 thr = inferior_thread ();
857 step_sm = new step_command_fsm (command_interp ());
858 thr->set_thread_fsm (std::unique_ptr<thread_fsm> (step_sm));
859
861 single_inst, count, thr);
862
863 /* Do only one step for now, before returning control to the event
864 loop. Let the continuation figure out how many other steps we
865 need to do, and handle them one at the time, through
866 step_once. */
867 if (!prepare_one_step (thr, step_sm))
868 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
869 else
870 {
871 /* Stepped into an inline frame. Pretend that we've
872 stopped. */
873 thr->thread_fsm ()->clean_up (thr);
874 bool proceeded = normal_stop ();
875 if (!proceeded)
878 }
879}
880
881/* Implementation of the 'should_stop' FSM method for stepping
882 commands. Called after we are done with one step operation, to
883 check whether we need to step again, before we print the prompt and
884 return control to the user. If count is > 1, returns false, as we
885 will need to keep going. */
886
887bool
889{
890 if (tp->control.stop_step)
891 {
892 /* There are more steps to make, and we did stop due to
893 ending a stepping range. Do another step. */
894 if (--count > 0)
895 return prepare_one_step (tp, this);
896
897 set_finished ();
898 }
899
900 return true;
901}
902
903/* Implementation of the 'clean_up' FSM method for stepping commands. */
904
905void
911
912/* Implementation of the 'async_reply_reason' FSM method for stepping
913 commands. */
914
920
921/* Prepare for one step in "step N". The actual target resumption is
922 done by the caller. Return true if we're done and should thus
923 report a stop to the user. Returns false if the target needs to be
924 resumed. */
925
926static int
928{
929 /* This can be removed once this function no longer implicitly relies on the
930 inferior_ptid value. */
931 gdb_assert (inferior_ptid == tp->ptid);
932
933 if (sm->count > 0)
934 {
936
937 set_step_frame (tp);
938
939 if (!sm->single_inst)
940 {
941 CORE_ADDR pc;
942
943 /* Step at an inlined function behaves like "down". */
944 if (!sm->skip_subroutines
945 && inline_skipped_frames (tp))
946 {
947 ptid_t resume_ptid;
948 const char *fn = nullptr;
949 symtab_and_line sal;
950 struct symbol *sym;
951
952 /* Pretend that we've ran. */
953 resume_ptid = user_visible_resume_ptid (1);
954 set_running (tp->inf->process_target (), resume_ptid, true);
955
957
958 frame = get_current_frame ();
959 sal = find_frame_sal (frame);
960 sym = get_frame_function (frame);
961
962 if (sym != nullptr)
963 fn = sym->print_name ();
964
965 if (sal.line == 0
967 {
968 sm->count--;
969 return prepare_one_step (tp, sm);
970 }
971 }
972
973 pc = get_frame_pc (frame);
977
978 /* There's a problem in gcc (PR gcc/98780) that causes missing line
979 table entries, which results in a too large stepping range.
980 Use inlined_subroutine info to make the range more narrow. */
981 if (inline_skipped_frames (tp) > 0)
982 {
983 symbol *sym = inline_skipped_symbol (tp);
984 if (sym->aclass () == LOC_BLOCK)
985 {
986 const block *block = sym->value_block ();
987 if (block->end () < tp->control.step_range_end)
989 }
990 }
991
992 tp->control.may_range_step = 1;
993
994 /* If we have no line info, switch to stepi mode. */
996 {
998 tp->control.may_range_step = 0;
999 }
1000 else if (tp->control.step_range_end == 0)
1001 {
1002 const char *name;
1003
1006 &tp->control.step_range_end) == 0)
1007 error (_("Cannot find bounds of current function"));
1008
1010 gdb_printf (_("Single stepping until exit from function %s,"
1011 "\nwhich has no line number information.\n"),
1012 name);
1013 }
1014 }
1015 else
1016 {
1017 /* Say we are stepping, but stop after one insn whatever it does. */
1019 if (!sm->skip_subroutines)
1020 /* It is stepi.
1021 Don't step over function calls, not even to functions lacking
1022 line numbers. */
1024 }
1025
1026 if (sm->skip_subroutines)
1028
1029 return 0;
1030 }
1031
1032 /* Done. */
1033 sm->set_finished ();
1034 return 1;
1035}
1036
1037
1038/* Continue program at specified address. */
1039
1040static void
1041jump_command (const char *arg, int from_tty)
1042{
1043 struct gdbarch *gdbarch = get_current_arch ();
1044 CORE_ADDR addr;
1045 struct symbol *fn;
1046 struct symbol *sfn;
1047 int async_exec;
1048
1053
1054 /* Find out whether we must run in the background. */
1055 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
1056 arg = stripped.get ();
1057
1058 prepare_execution_command (current_inferior ()->top_target (), async_exec);
1059
1060 if (!arg)
1061 error_no_arg (_("starting address"));
1062
1063 std::vector<symtab_and_line> sals
1065 if (sals.size () != 1)
1066 {
1067 /* If multiple sal-objects were found, try dropping those that aren't
1068 from the current symtab. */
1070 sals.erase (std::remove_if (sals.begin (), sals.end (),
1071 [&] (const symtab_and_line &sal)
1072 {
1073 return sal.symtab != cursal.symtab;
1074 }), sals.end ());
1075 if (sals.size () != 1)
1076 error (_("Jump request is ambiguous: "
1077 "does not resolve to a single address"));
1078 }
1079
1080 symtab_and_line &sal = sals[0];
1081
1082 if (sal.symtab == 0 && sal.pc == 0)
1083 error (_("No source file has been specified."));
1084
1085 resolve_sal_pc (&sal); /* May error out. */
1086
1087 /* See if we are trying to jump to another function. */
1091 if (fn != nullptr && sfn != fn)
1092 {
1093 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line,
1094 fn->print_name ()))
1095 {
1096 error (_("Not confirmed."));
1097 /* NOTREACHED */
1098 }
1099 }
1100
1101 if (sfn != nullptr)
1102 {
1103 struct obj_section *section;
1104
1105 section = sfn->obj_section (sfn->objfile ());
1106 if (section_is_overlay (section)
1107 && !section_is_mapped (section))
1108 {
1109 if (!query (_("WARNING!!! Destination is in "
1110 "unmapped overlay! Jump anyway? ")))
1111 {
1112 error (_("Not confirmed."));
1113 /* NOTREACHED */
1114 }
1115 }
1116 }
1117
1118 addr = sal.pc;
1119
1120 if (from_tty)
1121 {
1122 gdb_printf (_("Continuing at "));
1124 gdb_printf (".\n");
1125 }
1126
1128 proceed (addr, GDB_SIGNAL_0);
1129}
1130
1131/* Continue program giving it specified signal. */
1132
1133static void
1134signal_command (const char *signum_exp, int from_tty)
1135{
1136 enum gdb_signal oursig;
1137 int async_exec;
1138
1139 dont_repeat (); /* Too dangerous. */
1144
1145 /* Find out whether we must run in the background. */
1146 gdb::unique_xmalloc_ptr<char> stripped
1147 = strip_bg_char (signum_exp, &async_exec);
1148 signum_exp = stripped.get ();
1149
1150 prepare_execution_command (current_inferior ()->top_target (), async_exec);
1151
1152 if (!signum_exp)
1153 error_no_arg (_("signal number"));
1154
1155 /* It would be even slicker to make signal names be valid expressions,
1156 (the type could be "enum $signal" or some such), then the user could
1157 assign them to convenience variables. */
1158 oursig = gdb_signal_from_name (signum_exp);
1159
1160 if (oursig == GDB_SIGNAL_UNKNOWN)
1161 {
1162 /* No, try numeric. */
1163 int num = parse_and_eval_long (signum_exp);
1164
1165 if (num == 0)
1166 oursig = GDB_SIGNAL_0;
1167 else
1168 oursig = gdb_signal_from_command (num);
1169 }
1170
1171 /* Look for threads other than the current that this command ends up
1172 resuming too (due to schedlock off), and warn if they'll get a
1173 signal delivered. "signal 0" is used to suppress a previous
1174 signal, but if the current thread is no longer the one that got
1175 the signal, then the user is potentially suppressing the signal
1176 of the wrong thread. */
1177 if (!non_stop)
1178 {
1179 int must_confirm = 0;
1180
1181 /* This indicates what will be resumed. Either a single thread,
1182 a whole process, or all threads of all processes. */
1183 ptid_t resume_ptid = user_visible_resume_ptid (0);
1184 process_stratum_target *resume_target
1185 = user_visible_resume_target (resume_ptid);
1186
1187 thread_info *current = inferior_thread ();
1188
1189 for (thread_info *tp : all_non_exited_threads (resume_target, resume_ptid))
1190 {
1191 if (tp == current)
1192 continue;
1193
1194 if (tp->stop_signal () != GDB_SIGNAL_0
1195 && signal_pass_state (tp->stop_signal ()))
1196 {
1197 if (!must_confirm)
1198 gdb_printf (_("Note:\n"));
1199 gdb_printf (_(" Thread %s previously stopped with signal %s, %s.\n"),
1200 print_thread_id (tp),
1201 gdb_signal_to_name (tp->stop_signal ()),
1202 gdb_signal_to_string (tp->stop_signal ()));
1203 must_confirm = 1;
1204 }
1205 }
1206
1207 if (must_confirm
1208 && !query (_("Continuing thread %s (the current thread) with specified signal will\n"
1209 "still deliver the signals noted above to their respective threads.\n"
1210 "Continue anyway? "),
1212 error (_("Not confirmed."));
1213 }
1214
1215 if (from_tty)
1216 {
1217 if (oursig == GDB_SIGNAL_0)
1218 gdb_printf (_("Continuing with no signal.\n"));
1219 else
1220 gdb_printf (_("Continuing with signal %s.\n"),
1221 gdb_signal_to_name (oursig));
1222 }
1223
1225 proceed ((CORE_ADDR) -1, oursig);
1226}
1227
1228/* Queue a signal to be delivered to the current thread. */
1229
1230static void
1231queue_signal_command (const char *signum_exp, int from_tty)
1232{
1233 enum gdb_signal oursig;
1234 struct thread_info *tp;
1235
1240
1241 if (signum_exp == nullptr)
1242 error_no_arg (_("signal number"));
1243
1244 /* It would be even slicker to make signal names be valid expressions,
1245 (the type could be "enum $signal" or some such), then the user could
1246 assign them to convenience variables. */
1247 oursig = gdb_signal_from_name (signum_exp);
1248
1249 if (oursig == GDB_SIGNAL_UNKNOWN)
1250 {
1251 /* No, try numeric. */
1252 int num = parse_and_eval_long (signum_exp);
1253
1254 if (num == 0)
1255 oursig = GDB_SIGNAL_0;
1256 else
1257 oursig = gdb_signal_from_command (num);
1258 }
1259
1260 if (oursig != GDB_SIGNAL_0
1261 && !signal_pass_state (oursig))
1262 error (_("Signal handling set to not pass this signal to the program."));
1263
1264 tp = inferior_thread ();
1265 tp->set_stop_signal (oursig);
1266}
1267
1268/* Data for the FSM that manages the until (with no argument)
1269 command. */
1270
1272{
1273 /* The thread that as current when the command was executed. */
1275
1276 until_next_fsm (struct interp *cmd_interp, int thread)
1277 : thread_fsm (cmd_interp),
1278 thread (thread)
1279 {
1280 }
1281
1282 bool should_stop (struct thread_info *thread) override;
1283 void clean_up (struct thread_info *thread) override;
1285};
1286
1287/* Implementation of the 'should_stop' FSM method for the until (with
1288 no arg) command. */
1289
1290bool
1292{
1293 if (tp->control.stop_step)
1294 set_finished ();
1295
1296 return true;
1297}
1298
1299/* Implementation of the 'clean_up' FSM method for the until (with no
1300 arg) command. */
1301
1302void
1304{
1305 delete_longjmp_breakpoint (thread->global_num);
1306}
1307
1308/* Implementation of the 'async_reply_reason' FSM method for the until
1309 (with no arg) command. */
1310
1316
1317/* Proceed until we reach a different source line with pc greater than
1318 our current one or exit the function. We skip calls in both cases.
1319
1320 Note that eventually this command should probably be changed so
1321 that only source lines are printed out when we hit the breakpoint
1322 we set. This may involve changes to wait_for_inferior and the
1323 proceed status code. */
1324
1325static void
1327{
1328 frame_info_ptr frame;
1329 CORE_ADDR pc;
1330 struct symbol *func;
1331 struct symtab_and_line sal;
1332 struct thread_info *tp = inferior_thread ();
1333 int thread = tp->global_num;
1334 struct until_next_fsm *sm;
1335
1337 set_step_frame (tp);
1338
1339 frame = get_current_frame ();
1340
1341 /* Step until either exited from this function or greater
1342 than the current line (if in symbolic section) or pc (if
1343 not). */
1344
1345 pc = get_frame_pc (frame);
1346 func = find_pc_function (pc);
1347
1348 if (!func)
1349 {
1351
1352 if (msymbol.minsym == nullptr)
1353 error (_("Execution is not within a known function."));
1354
1355 tp->control.step_range_start = msymbol.value_address ();
1356 /* The upper-bound of step_range is exclusive. In order to make PC
1357 within the range, set the step_range_end with PC + 1. */
1358 tp->control.step_range_end = pc + 1;
1359 }
1360 else
1361 {
1362 sal = find_pc_line (pc, 0);
1363
1364 tp->control.step_range_start = func->value_block ()->entry_pc ();
1365 tp->control.step_range_end = sal.end;
1366
1367 /* By setting the step_range_end based on the current pc, we are
1368 assuming that the last line table entry for any given source line
1369 will have is_stmt set to true. This is not necessarily the case,
1370 there may be additional entries for the same source line with
1371 is_stmt set false. Consider the following code:
1372
1373 for (int i = 0; i < 10; i++)
1374 loop_body ();
1375
1376 Clang-13, will generate multiple line table entries at the end of
1377 the loop all associated with the 'for' line. The first of these
1378 entries is marked is_stmt true, but the other entries are is_stmt
1379 false.
1380
1381 If we only use the values in SAL, then our stepping range may not
1382 extend to the end of the loop. The until command will reach the
1383 end of the range, find a non is_stmt instruction, and step to the
1384 next is_stmt instruction. This stopping point, however, will be
1385 inside the loop, which is not what we wanted.
1386
1387 Instead, we now check any subsequent line table entries to see if
1388 they are for the same line. If they are, and they are marked
1389 is_stmt false, then we extend the end of our stepping range.
1390
1391 When we finish this process the end of the stepping range will
1392 point either to a line with a different line number, or, will
1393 point at an address for the same line number that is marked as a
1394 statement. */
1395
1396 struct symtab_and_line final_sal
1398
1399 while (final_sal.line == sal.line && final_sal.symtab == sal.symtab
1400 && !final_sal.is_stmt)
1401 {
1402 tp->control.step_range_end = final_sal.end;
1403 final_sal = find_pc_line (final_sal.end, 0);
1404 }
1405 }
1406 tp->control.may_range_step = 1;
1407
1409
1411 delete_longjmp_breakpoint_cleanup lj_deleter (thread);
1412
1413 sm = new until_next_fsm (command_interp (), tp->global_num);
1414 tp->set_thread_fsm (std::unique_ptr<thread_fsm> (sm));
1415 lj_deleter.release ();
1416
1417 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
1418}
1419
1420static void
1421until_command (const char *arg, int from_tty)
1422{
1423 int async_exec;
1424
1429
1430 /* Find out whether we must run in the background. */
1431 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
1432 arg = stripped.get ();
1433
1434 prepare_execution_command (current_inferior ()->top_target (), async_exec);
1435
1436 if (arg)
1437 until_break_command (arg, from_tty, 0);
1438 else
1439 until_next_command (from_tty);
1440}
1441
1442static void
1443advance_command (const char *arg, int from_tty)
1444{
1445 int async_exec;
1446
1451
1452 if (arg == nullptr)
1453 error_no_arg (_("a location"));
1454
1455 /* Find out whether we must run in the background. */
1456 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
1457 arg = stripped.get ();
1458
1459 prepare_execution_command (current_inferior ()->top_target (), async_exec);
1460
1461 until_break_command (arg, from_tty, 1);
1462}
1463
1464/* See inferior.h. */
1465
1466struct value *
1467get_return_value (struct symbol *func_symbol, struct value *function)
1468{
1469 regcache *stop_regs = get_current_regcache ();
1470 struct gdbarch *gdbarch = stop_regs->arch ();
1471 struct value *value;
1472
1473 struct type *value_type
1474 = check_typedef (func_symbol->type ()->target_type ());
1475 gdb_assert (value_type->code () != TYPE_CODE_VOID);
1476
1477 if (is_nocall_function (check_typedef (function->type ())))
1478 {
1479 warning (_("Function '%s' does not follow the target calling "
1480 "convention, cannot determine its returned value."),
1481 func_symbol->print_name ());
1482
1483 return nullptr;
1484 }
1485
1486 /* FIXME: 2003-09-27: When returning from a nested inferior function
1487 call, it's possible (with no help from the architecture vector)
1488 to locate and return/print a "struct return" value. This is just
1489 a more complicated case of what is already being done in the
1490 inferior function call code. In fact, when inferior function
1491 calls are made async, this will likely be made the norm. */
1492
1493 switch (gdbarch_return_value_as_value (gdbarch, function, value_type,
1494 nullptr, nullptr, nullptr))
1495 {
1499 gdbarch_return_value_as_value (gdbarch, function, value_type, stop_regs,
1500 &value, nullptr);
1501 break;
1503 value = nullptr;
1504 break;
1505 default:
1506 internal_error (_("bad switch"));
1507 }
1508
1509 return value;
1510}
1511
1512/* The captured function return value/type and its position in the
1513 value history. */
1514
1516{
1517 /* The captured return value. May be NULL if we weren't able to
1518 retrieve it. See get_return_value. */
1519 struct value *value;
1520
1521 /* The return type. In some cases, we'll not be able extract the
1522 return value, but we always know the type. */
1523 struct type *type;
1524
1525 /* If we captured a value, this is the value history index. */
1527};
1528
1529/* Helper for print_return_value. */
1530
1531static void
1533{
1534 if (rv->value != nullptr)
1535 {
1536 /* Print it. */
1537 uiout->text ("Value returned is ");
1538 uiout->field_fmt ("gdb-result-var", "$%d",
1540 uiout->text (" = ");
1541
1542 if (finish_print)
1543 {
1544 struct value_print_options opts;
1545 get_user_print_options (&opts);
1546
1547 string_file stb;
1548 value_print (rv->value, &stb, &opts);
1549 uiout->field_stream ("return-value", stb);
1550 }
1551 else
1552 uiout->field_string ("return-value", _("<not displayed>"),
1554 uiout->text ("\n");
1555 }
1556 else
1557 {
1558 std::string type_name = type_to_string (rv->type);
1559 uiout->text ("Value returned has type: ");
1560 uiout->field_string ("return-type", type_name);
1561 uiout->text (".");
1562 uiout->text (" Cannot determine contents\n");
1563 }
1564}
1565
1566/* Print the result of a function at the end of a 'finish' command.
1567 RV points at an object representing the captured return value/type
1568 and its position in the value history. */
1569
1570void
1572{
1573 if (rv->type == nullptr
1574 || check_typedef (rv->type)->code () == TYPE_CODE_VOID)
1575 return;
1576
1577 try
1578 {
1579 /* print_return_value_1 can throw an exception in some
1580 circumstances. We need to catch this so that we still
1581 delete the breakpoint. */
1582 print_return_value_1 (uiout, rv);
1583 }
1584 catch (const gdb_exception_error &ex)
1585 {
1587 }
1588}
1589
1590/* Data for the FSM that manages the finish command. */
1591
1593{
1594 /* The momentary breakpoint set at the function's return address in
1595 the caller. */
1597
1598 /* The function that we're stepping out of. */
1599 struct symbol *function = nullptr;
1600
1601 /* If the FSM finishes successfully, this stores the function's
1602 return value. */
1604
1605 /* If the current function uses the "struct return convention",
1606 this holds the address at which the value being returned will
1607 be stored, or zero if that address could not be determined or
1608 the "struct return convention" is not being used. */
1609 CORE_ADDR return_buf;
1610
1611 explicit finish_command_fsm (struct interp *cmd_interp)
1612 : thread_fsm (cmd_interp)
1613 {
1614 }
1615
1616 bool should_stop (struct thread_info *thread) override;
1617 void clean_up (struct thread_info *thread) override;
1618 struct return_value_info *return_value () override;
1620};
1621
1622/* Implementation of the 'should_stop' FSM method for the finish
1623 commands. Detects whether the thread stepped out of the function
1624 successfully, and if so, captures the function's return value and
1625 marks the FSM finished. */
1626
1627bool
1629{
1631
1632 if (function != nullptr
1634 breakpoint.get ()) != nullptr)
1635 {
1636 /* We're done. */
1637 set_finished ();
1638
1639 rv->type = function->type ()->target_type ();
1640 if (rv->type == nullptr)
1641 internal_error (_("finish_command: function has no target type"));
1642
1643 if (check_typedef (rv->type)->code () != TYPE_CODE_VOID)
1644 {
1645 struct value *func;
1646
1648
1649 if (return_buf != 0)
1650 /* Retrieve return value from the buffer where it was saved. */
1651 rv->value = value_at (rv->type, return_buf);
1652 else
1653 rv->value = get_return_value (function, func);
1654
1655 if (rv->value != nullptr)
1656 rv->value_history_index = rv->value->record_latest ();
1657 }
1658 }
1659 else if (tp->control.stop_step)
1660 {
1661 /* Finishing from an inline frame, or reverse finishing. In
1662 either case, there's no way to retrieve the return value. */
1663 set_finished ();
1664 }
1665
1666 return true;
1667}
1668
1669/* Implementation of the 'clean_up' FSM method for the finish
1670 commands. */
1671
1672void
1674{
1675 breakpoint.reset ();
1677}
1678
1679/* Implementation of the 'return_value' FSM method for the finish
1680 commands. */
1681
1682struct return_value_info *
1687
1688/* Implementation of the 'async_reply_reason' FSM method for the
1689 finish commands. */
1690
1699
1700/* finish_backward -- helper function for finish_command. */
1701
1702static void
1704{
1705 struct symtab_and_line sal;
1706 struct thread_info *tp = inferior_thread ();
1707 CORE_ADDR pc;
1708 CORE_ADDR func_addr;
1709 CORE_ADDR alt_entry_point;
1710 CORE_ADDR entry_point;
1711 frame_info_ptr frame = get_selected_frame (nullptr);
1712 struct gdbarch *gdbarch = get_frame_arch (frame);
1713
1715
1716 if (find_pc_partial_function (pc, nullptr, &func_addr, nullptr) == 0)
1717 error (_("Cannot find bounds of current function"));
1718
1719 sal = find_pc_line (func_addr, 0);
1720 alt_entry_point = sal.pc;
1721 entry_point = alt_entry_point;
1722
1724 /* Some architectures, like PowerPC use local and global entry points.
1725 There is only one Entry Point (GEP = LEP) for other architectures.
1726 The GEP is an alternate entry point. The LEP is the normal entry point.
1727 The value of entry_point was initialized to the alternate entry point
1728 (GEP). It will be adjusted to the normal entry point if the function
1729 has two entry points. */
1730 entry_point = gdbarch_skip_entrypoint (gdbarch, sal.pc);
1731
1732 tp->control.proceed_to_finish = 1;
1733 /* Special case: if we're sitting at the function entry point,
1734 then all we need to do is take a reverse singlestep. We
1735 don't need to set a breakpoint, and indeed it would do us
1736 no good to do so.
1737
1738 Note that this can only happen at frame #0, since there's
1739 no way that a function up the stack can have a return address
1740 that's equal to its entry point. */
1741
1742 if ((pc < alt_entry_point) || (pc > entry_point))
1743 {
1744 /* We are in the body of the function. Set a breakpoint to go back to
1745 the normal entry point. */
1746 symtab_and_line sr_sal;
1747 sr_sal.pc = entry_point;
1748 sr_sal.pspace = get_frame_program_space (frame);
1750 sr_sal, null_frame_id);
1751
1752 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
1753 }
1754 else
1755 {
1756 /* We are either at one of the entry points or between the entry points.
1757 If we are not at the alt_entry point, go back to the alt_entry_point
1758 If we at the normal entry point step back one instruction, when we
1759 stop we will determine if we entered via the entry point or the
1760 alternate entry point. If we are at the alternate entry point,
1761 single step back to the function call. */
1763 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
1764 }
1765}
1766
1767/* finish_forward -- helper function for finish_command. FRAME is the
1768 frame that called the function we're about to step out of. */
1769
1770static void
1772{
1773 struct frame_id frame_id = get_frame_id (frame);
1774 struct gdbarch *gdbarch = get_frame_arch (frame);
1775 struct symtab_and_line sal;
1776 struct thread_info *tp = inferior_thread ();
1777
1778 sal = find_pc_line (get_frame_pc (frame), 0);
1779 sal.pc = get_frame_pc (frame);
1780
1782 get_stack_frame_id (frame),
1783 bp_finish);
1784
1785 /* set_momentary_breakpoint invalidates FRAME. */
1786 frame = nullptr;
1787
1789
1790 /* We want to print return value, please... */
1791 tp->control.proceed_to_finish = 1;
1792
1793 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
1794}
1795
1796/* Skip frames for "finish". */
1797
1798static frame_info_ptr
1800{
1801 frame_info_ptr start;
1802
1803 do
1804 {
1805 start = frame;
1806
1807 frame = skip_tailcall_frames (frame);
1808 if (frame == nullptr)
1809 break;
1810
1811 frame = skip_unwritable_frames (frame);
1812 if (frame == nullptr)
1813 break;
1814 }
1815 while (start != frame);
1816
1817 return frame;
1818}
1819
1820/* "finish": Set a temporary breakpoint at the place the selected
1821 frame will return to, then continue. */
1822
1823static void
1824finish_command (const char *arg, int from_tty)
1825{
1826 frame_info_ptr frame;
1827 int async_exec;
1828 struct finish_command_fsm *sm;
1829 struct thread_info *tp;
1830
1835
1836 /* Find out whether we must run in the background. */
1837 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (arg, &async_exec);
1838 arg = stripped.get ();
1839
1840 prepare_execution_command (current_inferior ()->top_target (), async_exec);
1841
1842 if (arg)
1843 error (_("The \"finish\" command does not take any arguments."));
1844
1845 frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
1846 if (frame == 0)
1847 error (_("\"finish\" not meaningful in the outermost frame."));
1848
1850
1851 tp = inferior_thread ();
1852
1853 sm = new finish_command_fsm (command_interp ());
1854
1855 tp->set_thread_fsm (std::unique_ptr<thread_fsm> (sm));
1856
1857 /* Finishing from an inline frame is completely different. We don't
1858 try to show the "return value" - no way to locate it. */
1859 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1860 == INLINE_FRAME)
1861 {
1862 /* Claim we are stepping in the calling frame. An empty step
1863 range means that we will stop once we aren't in a function
1864 called by that frame. We don't use the magic "1" value for
1865 step_range_end, because then infrun will think this is nexti,
1866 and not step over the rest of this inlined function call. */
1867 set_step_info (tp, frame, {});
1871
1872 /* Print info on the selected frame, including level number but not
1873 source. */
1874 if (from_tty)
1875 {
1876 gdb_printf (_("Run till exit from "));
1878 }
1879
1880 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
1881 return;
1882 }
1883
1884 /* Find the function we will return from. */
1885 frame_info_ptr callee_frame = get_selected_frame (nullptr);
1886 sm->function = find_pc_function (get_frame_pc (callee_frame));
1887 sm->return_buf = 0; /* Initialize buffer address is not available. */
1888
1889 /* Determine the return convention. If it is RETURN_VALUE_STRUCT_CONVENTION,
1890 attempt to determine the address of the return buffer. */
1891 if (sm->function != nullptr)
1892 {
1893 enum return_value_convention return_value;
1894 struct gdbarch *gdbarch = get_frame_arch (callee_frame);
1895
1896 struct type * val_type
1897 = check_typedef (sm->function->type ()->target_type ());
1898
1899 return_value
1901 read_var_value (sm->function, nullptr,
1902 callee_frame),
1903 val_type, nullptr, nullptr, nullptr);
1904
1905 if (return_value == RETURN_VALUE_STRUCT_CONVENTION
1906 && val_type->code () != TYPE_CODE_VOID)
1908 callee_frame);
1909 }
1910
1911 /* Print info on the selected frame, including level number but not
1912 source. */
1913 if (from_tty)
1914 {
1916 gdb_printf (_("Run back to call of "));
1917 else
1918 {
1919 if (sm->function != nullptr && TYPE_NO_RETURN (sm->function->type ())
1920 && !query (_("warning: Function %s does not return normally.\n"
1921 "Try to finish anyway? "),
1922 sm->function->print_name ()))
1923 error (_("Not confirmed."));
1924 gdb_printf (_("Run till exit from "));
1925 }
1926
1927 print_stack_frame (callee_frame, 1, LOCATION, 0);
1928 }
1929
1931 finish_backward (sm);
1932 else
1933 {
1934 frame = skip_finish_frames (frame);
1935
1936 if (frame == nullptr)
1937 error (_("Cannot find the caller frame."));
1938
1939 finish_forward (sm, frame);
1940 }
1941}
1942
1943
1944static void
1945info_program_command (const char *args, int from_tty)
1946{
1947 scoped_restore_current_thread restore_thread;
1948
1949 thread_info *tp;
1950
1951 /* In non-stop, since every thread is controlled individually, we'll
1952 show execution info about the current thread. In all-stop, we'll
1953 show execution info about the last stop. */
1954
1955 if (non_stop)
1956 {
1957 if (!target_has_execution ())
1958 {
1959 gdb_printf (_("The program being debugged is not being run.\n"));
1960 return;
1961 }
1962
1963 if (inferior_ptid == null_ptid)
1964 error (_("No selected thread."));
1965
1966 tp = inferior_thread ();
1967
1968 gdb_printf (_("Selected thread %s (%s).\n"),
1969 print_thread_id (tp),
1970 target_pid_to_str (tp->ptid).c_str ());
1971
1972 if (tp->state == THREAD_EXITED)
1973 {
1974 gdb_printf (_("Selected thread has exited.\n"));
1975 return;
1976 }
1977 else if (tp->state == THREAD_RUNNING)
1978 {
1979 gdb_printf (_("Selected thread is running.\n"));
1980 return;
1981 }
1982 }
1983 else
1984 {
1985 tp = get_previous_thread ();
1986
1987 if (tp == nullptr)
1988 {
1989 gdb_printf (_("The program being debugged is not being run.\n"));
1990 return;
1991 }
1992
1993 switch_to_thread (tp);
1994
1995 gdb_printf (_("Last stopped for thread %s (%s).\n"),
1996 print_thread_id (tp),
1997 target_pid_to_str (tp->ptid).c_str ());
1998
1999 if (tp->state == THREAD_EXITED)
2000 {
2001 gdb_printf (_("Thread has since exited.\n"));
2002 return;
2003 }
2004
2005 if (tp->state == THREAD_RUNNING)
2006 {
2007 gdb_printf (_("Thread is now running.\n"));
2008 return;
2009 }
2010 }
2011
2012 int num;
2013 bpstat *bs = tp->control.stop_bpstat;
2014 int stat = bpstat_num (&bs, &num);
2015
2017 gdb_printf (_("Program stopped at %s.\n"),
2018 paddress (target_gdbarch (), tp->stop_pc ()));
2019 if (tp->control.stop_step)
2020 gdb_printf (_("It stopped after being stepped.\n"));
2021 else if (stat != 0)
2022 {
2023 /* There may be several breakpoints in the same place, so this
2024 isn't as strange as it seems. */
2025 while (stat != 0)
2026 {
2027 if (stat < 0)
2028 {
2029 gdb_printf (_("It stopped at a breakpoint "
2030 "that has since been deleted.\n"));
2031 }
2032 else
2033 gdb_printf (_("It stopped at breakpoint %d.\n"), num);
2034 stat = bpstat_num (&bs, &num);
2035 }
2036 }
2037 else if (tp->stop_signal () != GDB_SIGNAL_0)
2038 {
2039 gdb_printf (_("It stopped with signal %s, %s.\n"),
2040 gdb_signal_to_name (tp->stop_signal ()),
2041 gdb_signal_to_string (tp->stop_signal ()));
2042 }
2043
2044 if (from_tty)
2045 {
2046 gdb_printf (_("Type \"info stack\" or \"info "
2047 "registers\" for more information.\n"));
2048 }
2049}
2050
2051static void
2052environment_info (const char *var, int from_tty)
2053{
2054 if (var)
2055 {
2056 const char *val = current_inferior ()->environment.get (var);
2057
2058 if (val)
2059 {
2060 gdb_puts (var);
2061 gdb_puts (" = ");
2062 gdb_puts (val);
2063 gdb_puts ("\n");
2064 }
2065 else
2066 {
2067 gdb_puts ("Environment variable \"");
2068 gdb_puts (var);
2069 gdb_puts ("\" not defined.\n");
2070 }
2071 }
2072 else
2073 {
2074 char **envp = current_inferior ()->environment.envp ();
2075
2076 for (int idx = 0; envp[idx] != nullptr; ++idx)
2077 {
2078 gdb_puts (envp[idx]);
2079 gdb_puts ("\n");
2080 }
2081 }
2082}
2083
2084static void
2085set_environment_command (const char *arg, int from_tty)
2086{
2087 const char *p, *val;
2088 int nullset = 0;
2089
2090 if (arg == 0)
2091 error_no_arg (_("environment variable and value"));
2092
2093 /* Find separation between variable name and value. */
2094 p = (char *) strchr (arg, '=');
2095 val = (char *) strchr (arg, ' ');
2096
2097 if (p != 0 && val != 0)
2098 {
2099 /* We have both a space and an equals. If the space is before the
2100 equals, walk forward over the spaces til we see a nonspace
2101 (possibly the equals). */
2102 if (p > val)
2103 while (*val == ' ')
2104 val++;
2105
2106 /* Now if the = is after the char following the spaces,
2107 take the char following the spaces. */
2108 if (p > val)
2109 p = val - 1;
2110 }
2111 else if (val != 0 && p == 0)
2112 p = val;
2113
2114 if (p == arg)
2115 error_no_arg (_("environment variable to set"));
2116
2117 if (p == 0 || p[1] == 0)
2118 {
2119 nullset = 1;
2120 if (p == 0)
2121 p = arg + strlen (arg); /* So that savestring below will work. */
2122 }
2123 else
2124 {
2125 /* Not setting variable value to null. */
2126 val = p + 1;
2127 while (*val == ' ' || *val == '\t')
2128 val++;
2129 }
2130
2131 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
2132 p--;
2133
2134 std::string var (arg, p - arg);
2135 if (nullset)
2136 {
2137 gdb_printf (_("Setting environment variable "
2138 "\"%s\" to null value.\n"),
2139 var.c_str ());
2140 current_inferior ()->environment.set (var.c_str (), "");
2141 }
2142 else
2143 current_inferior ()->environment.set (var.c_str (), val);
2144}
2145
2146static void
2147unset_environment_command (const char *var, int from_tty)
2148{
2149 if (var == 0)
2150 {
2151 /* If there is no argument, delete all environment variables.
2152 Ask for confirmation if reading from the terminal. */
2153 if (!from_tty || query (_("Delete all environment variables? ")))
2154 current_inferior ()->environment.clear ();
2155 }
2156 else
2157 current_inferior ()->environment.unset (var);
2158}
2159
2160/* Handle the execution path (PATH variable). */
2161
2162static const char path_var_name[] = "PATH";
2163
2164static void
2165path_info (const char *args, int from_tty)
2166{
2167 gdb_puts ("Executable and object file path: ");
2168 gdb_puts (current_inferior ()->environment.get (path_var_name));
2169 gdb_puts ("\n");
2170}
2171
2172/* Add zero or more directories to the front of the execution path. */
2173
2174static void
2175path_command (const char *dirname, int from_tty)
2176{
2177 const char *env;
2178
2179 dont_repeat ();
2181 /* Can be null if path is not set. */
2182 if (!env)
2183 env = "";
2184 std::string exec_path = env;
2185 mod_path (dirname, exec_path);
2186 current_inferior ()->environment.set (path_var_name, exec_path.c_str ());
2187 if (from_tty)
2188 path_info (nullptr, from_tty);
2189}
2190
2191
2192static void
2193pad_to_column (string_file &stream, int col)
2194{
2195 /* At least one space must be printed to separate columns. */
2196 stream.putc (' ');
2197 const int size = stream.size ();
2198 if (size < col)
2199 stream.puts (n_spaces (col - size));
2200}
2201
2202/* Print out the register NAME with value VAL, to FILE, in the default
2203 fashion. */
2204
2205static void
2207 const char *name,
2208 struct value *val)
2209{
2210 struct type *regtype = val->type ();
2211 int print_raw_format;
2212 string_file format_stream;
2213 enum tab_stops
2214 {
2215 value_column_1 = 15,
2216 /* Give enough room for "0x", 16 hex digits and two spaces in
2217 preceding column. */
2218 value_column_2 = value_column_1 + 2 + 16 + 2,
2219 };
2220
2221 format_stream.puts (name);
2222 pad_to_column (format_stream, value_column_1);
2223
2224 print_raw_format = (val->entirely_available ()
2225 && !val->optimized_out ());
2226
2227 /* If virtual format is floating, print it that way, and in raw
2228 hex. */
2229 if (regtype->code () == TYPE_CODE_FLT
2230 || regtype->code () == TYPE_CODE_DECFLOAT)
2231 {
2232 struct value_print_options opts;
2233 const gdb_byte *valaddr = val->contents_for_printing ().data ();
2234 enum bfd_endian byte_order = type_byte_order (regtype);
2235
2236 get_user_print_options (&opts);
2237 opts.deref_ref = true;
2238
2239 common_val_print (val, &format_stream, 0, &opts, current_language);
2240
2241 if (print_raw_format)
2242 {
2243 pad_to_column (format_stream, value_column_2);
2244 format_stream.puts ("(raw ");
2245 print_hex_chars (&format_stream, valaddr, regtype->length (),
2246 byte_order, true);
2247 format_stream.putc (')');
2248 }
2249 }
2250 else
2251 {
2252 struct value_print_options opts;
2253
2254 /* Print the register in hex. */
2255 get_formatted_print_options (&opts, 'x');
2256 opts.deref_ref = true;
2257 common_val_print (val, &format_stream, 0, &opts, current_language);
2258 /* If not a vector register, print it also according to its
2259 natural format. */
2260 if (print_raw_format && regtype->is_vector () == 0)
2261 {
2262 pad_to_column (format_stream, value_column_2);
2263 get_user_print_options (&opts);
2264 opts.deref_ref = true;
2265 common_val_print (val, &format_stream, 0, &opts, current_language);
2266 }
2267 }
2268
2269 gdb_puts (format_stream.c_str (), file);
2270 gdb_printf (file, "\n");
2271}
2272
2273/* Print out the machine register regnum. If regnum is -1, print all
2274 registers (print_all == 1) or all non-float and non-vector
2275 registers (print_all == 0).
2276
2277 For most machines, having all_registers_info() print the
2278 register(s) one per line is good enough. If a different format is
2279 required, (eg, for MIPS or Pyramid 90x, which both have lots of
2280 regs), or there is an existing convention for showing all the
2281 registers, define the architecture method PRINT_REGISTERS_INFO to
2282 provide that format. */
2283
2284void
2286 struct ui_file *file,
2287 frame_info_ptr frame,
2288 int regnum, int print_all)
2289{
2290 int i;
2291 const int numregs = gdbarch_num_cooked_regs (gdbarch);
2292
2293 for (i = 0; i < numregs; i++)
2294 {
2295 /* Decide between printing all regs, non-float / vector regs, or
2296 specific reg. */
2297 if (regnum == -1)
2298 {
2299 if (print_all)
2300 {
2302 continue;
2303 }
2304 else
2305 {
2307 continue;
2308 }
2309 }
2310 else
2311 {
2312 if (i != regnum)
2313 continue;
2314 }
2315
2316 /* If the register name is empty, it is undefined for this
2317 processor, so don't display anything. */
2318 if (*(gdbarch_register_name (gdbarch, i)) == '\0')
2319 continue;
2320
2323 value_of_register (i, frame));
2324 }
2325}
2326
2327void
2328registers_info (const char *addr_exp, int fpregs)
2329{
2330 frame_info_ptr frame;
2331 struct gdbarch *gdbarch;
2332
2333 if (!target_has_registers ())
2334 error (_("The program has no registers now."));
2335 frame = get_selected_frame (nullptr);
2336 gdbarch = get_frame_arch (frame);
2337
2338 if (!addr_exp)
2339 {
2341 frame, -1, fpregs);
2342 return;
2343 }
2344
2345 while (*addr_exp != '\0')
2346 {
2347 const char *start;
2348 const char *end;
2349
2350 /* Skip leading white space. */
2351 addr_exp = skip_spaces (addr_exp);
2352
2353 /* Discard any leading ``$''. Check that there is something
2354 resembling a register following it. */
2355 if (addr_exp[0] == '$')
2356 addr_exp++;
2357 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
2358 error (_("Missing register name"));
2359
2360 /* Find the start/end of this register name/num/group. */
2361 start = addr_exp;
2362 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
2363 addr_exp++;
2364 end = addr_exp;
2365
2366 /* Figure out what we've found and display it. */
2367
2368 /* A register name? */
2369 {
2370 int regnum = user_reg_map_name_to_regnum (gdbarch, start, end - start);
2371
2372 if (regnum >= 0)
2373 {
2374 /* User registers lie completely outside of the range of
2375 normal registers. Catch them early so that the target
2376 never sees them. */
2378 {
2379 struct value *regval = value_of_user_reg (regnum, frame);
2380 const char *regname = user_reg_map_regnum_to_name (gdbarch,
2381 regnum);
2382
2383 /* Print in the same fashion
2384 gdbarch_print_registers_info's default
2385 implementation prints. */
2387 regname,
2388 regval);
2389 }
2390 else
2392 frame, regnum, fpregs);
2393 continue;
2394 }
2395 }
2396
2397 /* A register group? */
2398 {
2399 const struct reggroup *group = nullptr;
2400 for (const struct reggroup *g : gdbarch_reggroups (gdbarch))
2401 {
2402 /* Don't bother with a length check. Should the user
2403 enter a short register group name, go with the first
2404 group that matches. */
2405 if (strncmp (start, g->name (), end - start) == 0)
2406 {
2407 group = g;
2408 break;
2409 }
2410 }
2411 if (group != nullptr)
2412 {
2413 int regnum;
2414
2415 for (regnum = 0;
2417 regnum++)
2418 {
2421 gdb_stdout, frame,
2422 regnum, fpregs);
2423 }
2424 continue;
2425 }
2426 }
2427
2428 /* Nothing matched. */
2429 error (_("Invalid register `%.*s'"), (int) (end - start), start);
2430 }
2431}
2432
2433static void
2434info_all_registers_command (const char *addr_exp, int from_tty)
2435{
2436 registers_info (addr_exp, 1);
2437}
2438
2439static void
2440info_registers_command (const char *addr_exp, int from_tty)
2441{
2442 registers_info (addr_exp, 0);
2443}
2444
2445static void
2447 frame_info_ptr frame, const char *args)
2448{
2449 struct gdbarch *gdbarch = get_frame_arch (frame);
2450
2452 gdbarch_print_vector_info (gdbarch, file, frame, args);
2453 else
2454 {
2455 int regnum;
2456 int printed_something = 0;
2457
2459 {
2461 {
2462 printed_something = 1;
2463 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2464 }
2465 }
2466 if (!printed_something)
2467 gdb_printf (file, "No vector information\n");
2468 }
2469}
2470
2471static void
2472info_vector_command (const char *args, int from_tty)
2473{
2474 if (!target_has_registers ())
2475 error (_("The program has no registers now."));
2476
2478}
2479
2480/* Kill the inferior process. Make us have no inferior. */
2481
2482static void
2483kill_command (const char *arg, int from_tty)
2484{
2485 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2486 It should be a distinct flag that indicates that a target is active, cuz
2487 some targets don't have processes! */
2488
2489 if (inferior_ptid == null_ptid)
2490 error (_("The program is not being run."));
2491 if (!query (_("Kill the program being debugged? ")))
2492 error (_("Not confirmed."));
2493
2494 int pid = current_inferior ()->pid;
2495 /* Save the pid as a string before killing the inferior, since that
2496 may unpush the current target, and we need the string after. */
2497 std::string pid_str = target_pid_to_str (ptid_t (pid));
2498 int infnum = current_inferior ()->num;
2499
2500 target_kill ();
2501 bfd_cache_close_all ();
2502
2504
2506 gdb_printf (_("[Inferior %d (%s) killed]\n"),
2507 infnum, pid_str.c_str ());
2508}
2509
2510/* Used in `attach&' command. Proceed threads of inferior INF iff
2511 they stopped due to debugger request, and when they did, they
2512 reported a clean stop (GDB_SIGNAL_0). Do not proceed threads that
2513 have been explicitly been told to stop. */
2514
2515static void
2517{
2518 /* Don't error out if the current thread is running, because
2519 there may be other stopped threads. */
2520
2521 /* Backup current thread and selected frame. */
2522 scoped_restore_current_thread restore_thread;
2523
2524 for (thread_info *thread : inf->non_exited_threads ())
2525 if (!thread->executing ()
2526 && !thread->stop_requested
2527 && thread->stop_signal () == GDB_SIGNAL_0)
2528 {
2529 switch_to_thread (thread);
2531 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
2532 }
2533}
2534
2535/* See inferior.h. */
2536
2537void
2538setup_inferior (int from_tty)
2539{
2540 struct inferior *inferior;
2541
2543 inferior->needs_setup = false;
2544
2545 /* If no exec file is yet known, try to determine it from the
2546 process itself. */
2547 if (get_exec_file (0) == nullptr)
2548 exec_file_locate_attach (inferior_ptid.pid (), 1, from_tty);
2549 else
2550 {
2552 reread_symbols (from_tty);
2553 }
2554
2555 /* Take any necessary post-attaching actions for this platform. */
2557
2558 post_create_inferior (from_tty);
2559}
2560
2561/* What to do after the first program stops after attaching. */
2563{
2564 /* Do nothing. Leaves threads as they are. */
2566
2567 /* Re-resume threads that are marked running. */
2569
2570 /* Stop all threads. */
2572};
2573
2574/* Called after we've attached to a process and we've seen it stop for
2575 the first time. Resume, stop, or don't touch the threads according
2576 to MODE. */
2577
2578static void
2580{
2581 struct inferior *inferior;
2582
2585
2586 if (inferior->needs_setup)
2587 setup_inferior (from_tty);
2588
2589 if (mode == ATTACH_POST_WAIT_RESUME)
2590 {
2591 /* The user requested an `attach&', so be sure to leave threads
2592 that didn't get a signal running. */
2593
2594 /* Immediately resume all suspended threads of this inferior,
2595 and this inferior only. This should have no effect on
2596 already running threads. If a thread has been stopped with a
2597 signal, leave it be. */
2598 if (non_stop)
2600 else
2601 {
2602 if (inferior_thread ()->stop_signal () == GDB_SIGNAL_0)
2603 {
2605 proceed ((CORE_ADDR) -1, GDB_SIGNAL_DEFAULT);
2606 }
2607 }
2608 }
2609 else if (mode == ATTACH_POST_WAIT_STOP)
2610 {
2611 /* The user requested a plain `attach', so be sure to leave
2612 the inferior stopped. */
2613
2614 /* At least the current thread is already stopped. */
2615
2616 /* In all-stop, by definition, all threads have to be already
2617 stopped at this point. In non-stop, however, although the
2618 selected thread is stopped, others may still be executing.
2619 Be sure to explicitly stop all threads of the process. This
2620 should have no effect on already stopped threads. */
2621 if (non_stop)
2622 target_stop (ptid_t (inferior->pid));
2623 else if (target_is_non_stop_p ())
2624 {
2625 struct thread_info *lowest = inferior_thread ();
2626
2627 stop_all_threads ("attaching");
2628
2629 /* It's not defined which thread will report the attach
2630 stop. For consistency, always select the thread with
2631 lowest GDB number, which should be the main thread, if it
2632 still exists. */
2633 for (thread_info *thread : current_inferior ()->non_exited_threads ())
2634 if (thread->inf->num < lowest->inf->num
2635 || thread->per_inf_num < lowest->per_inf_num)
2636 lowest = thread;
2637
2638 switch_to_thread (lowest);
2639 }
2640
2641 /* Tell the user/frontend where we're stopped. */
2642 normal_stop ();
2645 }
2646}
2647
2648/* "attach" command entry point. Takes a program started up outside
2649 of gdb and ``attaches'' to it. This stops it cold in its tracks
2650 and allows us to start debugging it. */
2651
2652void
2653attach_command (const char *args, int from_tty)
2654{
2655 int async_exec;
2656 struct target_ops *attach_target;
2657 struct inferior *inferior = current_inferior ();
2658 enum attach_post_wait_mode mode;
2659
2660 dont_repeat (); /* Not for the faint of heart */
2661
2662 scoped_disable_commit_resumed disable_commit_resumed ("attaching");
2663
2665 /* Don't complain if all processes share the same symbol
2666 space. */
2667 ;
2668 else if (target_has_execution ())
2669 {
2670 if (query (_("A program is being debugged already. Kill it? ")))
2671 target_kill ();
2672 else
2673 error (_("Not killed."));
2674 }
2675
2676 /* Clean up any leftovers from other runs. Some other things from
2677 this function should probably be moved into target_pre_inferior. */
2678 target_pre_inferior (from_tty);
2679
2680 gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (args, &async_exec);
2681 args = stripped.get ();
2682
2683 attach_target = find_attach_target ();
2684
2685 prepare_execution_command (attach_target, async_exec);
2686
2687 if (non_stop && !attach_target->supports_non_stop ())
2688 error (_("Cannot attach to this target in non-stop mode"));
2689
2690 attach_target->attach (args, from_tty);
2691 /* to_attach should push the target, so after this point we
2692 shouldn't refer to attach_target again. */
2693 attach_target = nullptr;
2694
2695 infrun_debug_show_threads ("immediately after attach",
2697
2698 /* Enable async mode if it is supported by the target. */
2699 if (target_can_async_p ())
2700 target_async (true);
2701
2702 /* Set up the "saved terminal modes" of the inferior
2703 based on what modes we are starting it with. */
2705
2706 /* Install inferior's terminal modes. This may look like a no-op,
2707 as we've just saved them above, however, this does more than
2708 restore terminal settings:
2709
2710 - installs a SIGINT handler that forwards SIGINT to the inferior.
2711 Otherwise a Ctrl-C pressed just while waiting for the initial
2712 stop would end up as a spurious Quit.
2713
2714 - removes stdin from the event loop, which we need if attaching
2715 in the foreground, otherwise on targets that report an initial
2716 stop on attach (which are most) we'd process input/commands
2717 while we're in the event loop waiting for that stop. That is,
2718 before the attach continuation runs and the command is really
2719 finished. */
2721
2722 /* Set up execution context to know that we should return from
2723 wait_for_inferior as soon as the target reports a stop. */
2725
2726 inferior->needs_setup = true;
2727
2728 if (target_is_non_stop_p ())
2729 {
2730 /* If we find that the current thread isn't stopped, explicitly
2731 do so now, because we're going to install breakpoints and
2732 poke at memory. */
2733
2734 if (async_exec)
2735 /* The user requested an `attach&'; stop just one thread. */
2737 else
2738 /* The user requested an `attach', so stop all threads of this
2739 inferior. */
2740 target_stop (ptid_t (inferior_ptid.pid ()));
2741 }
2742
2743 /* Check for exec file mismatch, and let the user solve it. */
2744 validate_exec_file (from_tty);
2745
2746 mode = async_exec ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_STOP;
2747
2748 /* Some system don't generate traps when attaching to inferior.
2749 E.g. Mach 3 or GNU hurd. */
2750 if (!target_attach_no_wait ())
2751 {
2752 /* Careful here. See comments in inferior.h. Basically some
2753 OSes don't ignore SIGSTOPs on continue requests anymore. We
2754 need a way for handle_inferior_event to reset the stop_signal
2755 variable after an attach, and this is what
2756 STOP_QUIETLY_NO_SIGSTOP is for. */
2758
2759 /* Wait for stop. */
2760 inferior->add_continuation ([=] ()
2761 {
2762 attach_post_wait (from_tty, mode);
2763 });
2764
2765 /* Let infrun consider waiting for events out of this
2766 target. */
2768
2769 if (!target_is_async_p ())
2771 return;
2772 }
2773 else
2774 attach_post_wait (from_tty, mode);
2775
2776 disable_commit_resumed.reset_and_commit ();
2777}
2778
2779/* We had just found out that the target was already attached to an
2780 inferior. PTID points at a thread of this new inferior, that is
2781 the most likely to be stopped right now, but not necessarily so.
2782 The new inferior is assumed to be already added to the inferior
2783 list at this point. If LEAVE_RUNNING, then leave the threads of
2784 this inferior running, except those we've explicitly seen reported
2785 as stopped. */
2786
2787void
2788notice_new_inferior (thread_info *thr, bool leave_running, int from_tty)
2789{
2790 enum attach_post_wait_mode mode
2792
2793 gdb::optional<scoped_restore_current_thread> restore_thread;
2794
2795 if (inferior_ptid != null_ptid)
2796 restore_thread.emplace ();
2797
2798 /* Avoid reading registers -- we haven't fetched the target
2799 description yet. */
2801
2802 /* When we "notice" a new inferior we need to do all the things we
2803 would normally do if we had just attached to it. */
2804
2805 if (thr->executing ())
2806 {
2807 struct inferior *inferior = current_inferior ();
2808
2809 /* We're going to install breakpoints, and poke at memory,
2810 ensure that the inferior is stopped for a moment while we do
2811 that. */
2813
2815
2816 /* Wait for stop before proceeding. */
2817 inferior->add_continuation ([=] ()
2818 {
2819 attach_post_wait (from_tty, mode);
2820 });
2821
2822 return;
2823 }
2824
2825 attach_post_wait (from_tty, mode);
2826}
2827
2828/*
2829 * detach_command --
2830 * takes a program previously attached to and detaches it.
2831 * The program resumes execution and will no longer stop
2832 * on signals, etc. We better not have left any breakpoints
2833 * in the program or it'll die when it hits one. For this
2834 * to work, it may be necessary for the process to have been
2835 * previously attached. It *might* work if the program was
2836 * started via the normal ptrace (PTRACE_TRACEME).
2837 */
2838
2839void
2840detach_command (const char *args, int from_tty)
2841{
2842 dont_repeat (); /* Not for the faint of heart. */
2843
2844 if (inferior_ptid == null_ptid)
2845 error (_("The program is not being run."));
2846
2847 scoped_disable_commit_resumed disable_commit_resumed ("detaching");
2848
2849 query_if_trace_running (from_tty);
2850
2852
2853 /* Hold a strong reference to the target while (maybe)
2854 detaching the parent. Otherwise detaching could close the
2855 target. */
2856 auto target_ref
2857 = target_ops_ref::new_reference (current_inferior ()->process_target ());
2858
2859 /* Save this before detaching, since detaching may unpush the
2860 process_stratum target. */
2861 bool was_non_stop_p = target_is_non_stop_p ();
2862
2863 target_detach (current_inferior (), from_tty);
2864
2866
2867 /* The current inferior process was just detached successfully. Get
2868 rid of breakpoints that no longer make sense. Note we don't do
2869 this within target_detach because that is also used when
2870 following child forks, and in that case we will want to transfer
2871 breakpoints to the child, not delete them. */
2873
2874 /* If the solist is global across inferiors, don't clear it when we
2875 detach from a single inferior. */
2877 no_shared_libraries (nullptr, from_tty);
2878
2881
2882 if (!was_non_stop_p)
2884
2885 disable_commit_resumed.reset_and_commit ();
2886}
2887
2888/* Disconnect from the current target without resuming it (leaving it
2889 waiting for a debugger).
2890
2891 We'd better not have left any breakpoints in the program or the
2892 next debugger will get confused. Currently only supported for some
2893 remote targets, since the normal attach mechanisms don't work on
2894 stopped processes on some native platforms (e.g. GNU/Linux). */
2895
2896static void
2897disconnect_command (const char *args, int from_tty)
2898{
2899 dont_repeat (); /* Not for the faint of heart. */
2900 query_if_trace_running (from_tty);
2902 target_disconnect (args, from_tty);
2903 no_shared_libraries (nullptr, from_tty);
2908}
2909
2910/* Stop PTID in the current target, and tag the PTID threads as having
2911 been explicitly requested to stop. PTID can be a thread, a
2912 process, or minus_one_ptid, meaning all threads of all inferiors of
2913 the current target. */
2914
2915static void
2917{
2918 target_stop (ptid);
2919
2920 /* Tag the thread as having been explicitly requested to stop, so
2921 other parts of gdb know not to resume this thread automatically,
2922 if it was stopped due to an internal event. Limit this to
2923 non-stop mode, as when debugging a multi-threaded application in
2924 all-stop mode, we will only get one stop event --- it's undefined
2925 which thread will report the event. */
2927 ptid, 1);
2928}
2929
2930/* See inferior.h. */
2931
2932void
2934{
2935 scoped_disable_commit_resumed disable_commit_resumed ("interrupting");
2936
2937 if (non_stop)
2938 {
2939 if (all_threads)
2940 {
2941 scoped_restore_current_thread restore_thread;
2942
2943 for (inferior *inf : all_inferiors ())
2944 {
2946 stop_current_target_threads_ns (minus_one_ptid);
2947 }
2948 }
2949 else
2951 }
2952 else
2954
2955 disable_commit_resumed.reset_and_commit ();
2956}
2957
2958/* interrupt [-a]
2959 Stop the execution of the target while running in async mode, in
2960 the background. In all-stop, stop the whole process. In non-stop
2961 mode, stop the current thread only by default, or stop all threads
2962 if the `-a' switch is used. */
2963
2964static void
2965interrupt_command (const char *args, int from_tty)
2966{
2967 if (target_can_async_p ())
2968 {
2969 int all_threads = 0;
2970
2971 dont_repeat (); /* Not for the faint of heart. */
2972
2973 if (args != nullptr
2974 && startswith (args, "-a"))
2975 all_threads = 1;
2976
2978 }
2979}
2980
2981/* See inferior.h. */
2982
2983void
2985 frame_info_ptr frame, const char *args)
2986{
2987 int regnum;
2988 int printed_something = 0;
2989
2991 {
2993 {
2994 printed_something = 1;
2995 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2996 }
2997 }
2998 if (!printed_something)
2999 gdb_printf (file, "No floating-point info "
3000 "available for this processor.\n");
3001}
3002
3003static void
3004info_float_command (const char *args, int from_tty)
3005{
3006 frame_info_ptr frame;
3007
3008 if (!target_has_registers ())
3009 error (_("The program has no registers now."));
3010
3011 frame = get_selected_frame (nullptr);
3013}
3014
3015/* Implement `info proc' family of commands. */
3016
3017static void
3018info_proc_cmd_1 (const char *args, enum info_proc_what what, int from_tty)
3019{
3020 struct gdbarch *gdbarch = get_current_arch ();
3021
3022 if (!target_info_proc (args, what))
3023 {
3025 gdbarch_info_proc (gdbarch, args, what);
3026 else
3027 error (_("Not supported on this target."));
3028 }
3029}
3030
3031/* Implement `info proc' when given without any further parameters. */
3032
3033static void
3034info_proc_cmd (const char *args, int from_tty)
3035{
3036 info_proc_cmd_1 (args, IP_MINIMAL, from_tty);
3037}
3038
3039/* Implement `info proc mappings'. */
3040
3041static void
3042info_proc_cmd_mappings (const char *args, int from_tty)
3043{
3044 info_proc_cmd_1 (args, IP_MAPPINGS, from_tty);
3045}
3046
3047/* Implement `info proc stat'. */
3048
3049static void
3050info_proc_cmd_stat (const char *args, int from_tty)
3051{
3052 info_proc_cmd_1 (args, IP_STAT, from_tty);
3053}
3054
3055/* Implement `info proc status'. */
3056
3057static void
3058info_proc_cmd_status (const char *args, int from_tty)
3059{
3060 info_proc_cmd_1 (args, IP_STATUS, from_tty);
3061}
3062
3063/* Implement `info proc cwd'. */
3064
3065static void
3066info_proc_cmd_cwd (const char *args, int from_tty)
3067{
3068 info_proc_cmd_1 (args, IP_CWD, from_tty);
3069}
3070
3071/* Implement `info proc cmdline'. */
3072
3073static void
3074info_proc_cmd_cmdline (const char *args, int from_tty)
3075{
3076 info_proc_cmd_1 (args, IP_CMDLINE, from_tty);
3077}
3078
3079/* Implement `info proc exe'. */
3080
3081static void
3082info_proc_cmd_exe (const char *args, int from_tty)
3083{
3084 info_proc_cmd_1 (args, IP_EXE, from_tty);
3085}
3086
3087/* Implement `info proc files'. */
3088
3089static void
3090info_proc_cmd_files (const char *args, int from_tty)
3091{
3092 info_proc_cmd_1 (args, IP_FILES, from_tty);
3093}
3094
3095/* Implement `info proc all'. */
3096
3097static void
3098info_proc_cmd_all (const char *args, int from_tty)
3099{
3100 info_proc_cmd_1 (args, IP_ALL, from_tty);
3101}
3102
3103/* Implement `show print finish'. */
3104
3105static void
3106show_print_finish (struct ui_file *file, int from_tty,
3107 struct cmd_list_element *c,
3108 const char *value)
3109{
3110 gdb_printf (file, _("\
3111Printing of return value after `finish' is %s.\n"),
3112 value);
3113}
3114
3115
3116/* This help string is used for the run, start, and starti commands.
3117 It is defined as a macro to prevent duplication. */
3118
3119#define RUN_ARGS_HELP \
3120"You may specify arguments to give it.\n\
3121Args may include \"*\", or \"[...]\"; they are expanded using the\n\
3122shell that will start the program (specified by the \"$SHELL\" environment\n\
3123variable). Input and output redirection with \">\", \"<\", or \">>\"\n\
3124are also allowed.\n\
3125\n\
3126With no arguments, uses arguments last specified (with \"run\" or \n\
3127\"set args\"). To cancel previous arguments and run with no arguments,\n\
3128use \"set args\" without arguments.\n\
3129\n\
3130To start the inferior without using a shell, use \"set startup-with-shell off\"."
3131
3132void _initialize_infcmd ();
3133void
3135{
3136 static struct cmd_list_element *info_proc_cmdlist;
3137 struct cmd_list_element *c = nullptr;
3138
3139 /* Add the filename of the terminal connected to inferior I/O. */
3140 auto tty_set_show
3141 = add_setshow_optional_filename_cmd ("inferior-tty", class_run, _("\
3142Set terminal for future runs of program being debugged."), _(" \
3143Show terminal for future runs of program being debugged."), _(" \
3144Usage: set inferior-tty [TTY]\n\n \
3145If TTY is omitted, the default behavior of using the same terminal as GDB\n \
3146is restored."),
3150 &setlist, &showlist);
3151 add_alias_cmd ("tty", tty_set_show.set, class_run, 0, &cmdlist);
3152
3153 auto args_set_show
3155Set argument list to give program being debugged when it is started."), _("\
3156Show argument list to give program being debugged when it is started."), _("\
3157Follow this command with any number of args, to be passed to the program."),
3161 &setlist, &showlist);
3162 set_cmd_completer (args_set_show.set, filename_completer);
3163
3164 auto cwd_set_show
3166Set the current working directory to be used when the inferior is started.\n \
3167Changing this setting does not have any effect on inferiors that are\n \
3168already running."),
3169 _("\
3170Show the current working directory that is used when the inferior is started."),
3171 _("\
3172Use this command to change the current working directory that will be used\n\
3173when the inferior is started. This setting does not affect GDB's current\n\
3174working directory."),
3177 &setlist, &showlist);
3178 set_cmd_completer (cwd_set_show.set, filename_completer);
3179
3180 c = add_cmd ("environment", no_class, environment_info, _("\
3181The environment to give the program, or one variable's value.\n\
3182With an argument VAR, prints the value of environment variable VAR to\n\
3183give the program being debugged. With no arguments, prints the entire\n\
3184environment to be given to the program."), &showlist);
3186
3188 _("Complement to certain \"set\" commands."),
3189 &unsetlist, 0, &cmdlist);
3190
3191 c = add_cmd ("environment", class_run, unset_environment_command, _("\
3192Cancel environment variable VAR for the program.\n\
3193This does not affect the program until the next \"run\" command."),
3194 &unsetlist);
3196
3197 c = add_cmd ("environment", class_run, set_environment_command, _("\
3198Set environment variable value to give the program.\n\
3199Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
3200VALUES of environment variables are uninterpreted strings.\n\
3201This does not affect the program until the next \"run\" command."),
3202 &setlist);
3204
3205 c = add_com ("path", class_files, path_command, _("\
3206Add directory DIR(s) to beginning of search path for object files.\n\
3207$cwd in the path means the current working directory.\n\
3208This path is equivalent to the $PATH shell variable. It is a list of\n\
3209directories, separated by colons. These directories are searched to find\n\
3210fully linked executable files and separately compiled object files as \
3211needed."));
3213
3214 c = add_cmd ("paths", no_class, path_info, _("\
3215Current search path for finding object files.\n\
3216$cwd in the path means the current working directory.\n\
3217This path is equivalent to the $PATH shell variable. It is a list of\n\
3218directories, separated by colons. These directories are searched to find\n\
3219fully linked executable files and separately compiled object files as \
3220needed."),
3221 &showlist);
3223
3225 _("Kill execution of program being debugged."),
3226 &killlist, 0, &cmdlist);
3227
3228 add_com ("attach", class_run, attach_command, _("\
3229Attach to a process or file outside of GDB.\n\
3230This command attaches to another target, of the same type as your last\n\
3231\"target\" command (\"info files\" will show your target stack).\n\
3232The command may take as argument a process id or a device file.\n\
3233For a process id, you must have permission to send the process a signal,\n\
3234and it must have the same effective uid as the debugger.\n\
3235When using \"attach\" with a process id, the debugger finds the\n\
3236program running in the process, looking first in the current working\n\
3237directory, or (if not found there) using the source file search path\n\
3238(see the \"directory\" command). You can also use the \"file\" command\n\
3239to specify the program, and to load its symbol table."));
3240
3241 add_prefix_cmd ("detach", class_run, detach_command, _("\
3242Detach a process or file previously attached.\n\
3243If a process, it is no longer traced, and it continues its execution. If\n\
3244you were debugging a file, the file is closed and gdb no longer accesses it."),
3245 &detachlist, 0, &cmdlist);
3246
3247 add_com ("disconnect", class_run, disconnect_command, _("\
3248Disconnect from a target.\n\
3249The target will wait for another debugger to connect. Not available for\n\
3250all targets."));
3251
3252 c = add_com ("signal", class_run, signal_command, _("\
3253Continue program with the specified signal.\n\
3254Usage: signal SIGNAL\n\
3255The SIGNAL argument is processed the same as the handle command.\n\
3256\n\
3257An argument of \"0\" means continue the program without sending it a signal.\n\
3258This is useful in cases where the program stopped because of a signal,\n\
3259and you want to resume the program while discarding the signal.\n\
3260\n\
3261In a multi-threaded program the signal is delivered to, or discarded from,\n\
3262the current thread only."));
3264
3265 c = add_com ("queue-signal", class_run, queue_signal_command, _("\
3266Queue a signal to be delivered to the current thread when it is resumed.\n\
3267Usage: queue-signal SIGNAL\n\
3268The SIGNAL argument is processed the same as the handle command.\n\
3269It is an error if the handling state of SIGNAL is \"nopass\".\n\
3270\n\
3271An argument of \"0\" means remove any currently queued signal from\n\
3272the current thread. This is useful in cases where the program stopped\n\
3273because of a signal, and you want to resume it while discarding the signal.\n\
3274\n\
3275In a multi-threaded program the signal is queued with, or discarded from,\n\
3276the current thread only."));
3278
3279 cmd_list_element *stepi_cmd
3280 = add_com ("stepi", class_run, stepi_command, _("\
3281Step one instruction exactly.\n\
3282Usage: stepi [N]\n\
3283Argument N means step N times (or till program stops for another \
3284reason)."));
3285 add_com_alias ("si", stepi_cmd, class_run, 0);
3286
3287 cmd_list_element *nexti_cmd
3288 = add_com ("nexti", class_run, nexti_command, _("\
3289Step one instruction, but proceed through subroutine calls.\n\
3290Usage: nexti [N]\n\
3291Argument N means step N times (or till program stops for another \
3292reason)."));
3293 add_com_alias ("ni", nexti_cmd, class_run, 0);
3294
3295 cmd_list_element *finish_cmd
3296 = add_com ("finish", class_run, finish_command, _("\
3297Execute until selected stack frame returns.\n\
3298Usage: finish\n\
3299Upon return, the value returned is printed and put in the value history."));
3300 add_com_alias ("fin", finish_cmd, class_run, 1);
3301
3303 = add_com ("next", class_run, next_command, _("\
3304Step program, proceeding through subroutine calls.\n\
3305Usage: next [N]\n\
3306Unlike \"step\", if the current source line calls a subroutine,\n\
3307this command does not enter the subroutine, but instead steps over\n\
3308the call, in effect treating it as a single source line."));
3309 add_com_alias ("n", next_cmd, class_run, 1);
3310
3311 cmd_list_element *step_cmd
3312 = add_com ("step", class_run, step_command, _("\
3313Step program until it reaches a different source line.\n\
3314Usage: step [N]\n\
3315Argument N means step N times (or till program stops for another \
3316reason)."));
3317 add_com_alias ("s", step_cmd, class_run, 1);
3318
3319 cmd_list_element *until_cmd
3320 = add_com ("until", class_run, until_command, _("\
3321Execute until past the current line or past a LOCATION.\n\
3322Execute until the program reaches a source line greater than the current\n\
3323or a specified location (same args as break command) within the current \
3324frame."));
3326 add_com_alias ("u", until_cmd, class_run, 1);
3327
3328 c = add_com ("advance", class_run, advance_command, _("\
3329Continue the program up to the given location (same form as args for break \
3330command).\n\
3331Execution will also stop upon exit from the current stack frame."));
3333
3334 cmd_list_element *jump_cmd
3335 = add_com ("jump", class_run, jump_command, _("\
3336Continue program being debugged at specified line or address.\n\
3337Usage: jump LOCATION\n\
3338Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
3339for an address to start at."));
3341 add_com_alias ("j", jump_cmd, class_run, 1);
3342
3343 cmd_list_element *continue_cmd
3344 = add_com ("continue", class_run, continue_command, _("\
3345Continue program being debugged, after signal or breakpoint.\n\
3346Usage: continue [N]\n\
3347If proceeding from breakpoint, a number N may be used as an argument,\n\
3348which means to set the ignore count of that breakpoint to N - 1 (so that\n\
3349the breakpoint won't break until the Nth time it is reached).\n\
3350\n\
3351If non-stop mode is enabled, continue only the current thread,\n\
3352otherwise all the threads in the program are continued. To \n\
3353continue all stopped threads in non-stop mode, use the -a option.\n\
3354Specifying -a and an ignore count simultaneously is an error."));
3355 add_com_alias ("c", continue_cmd, class_run, 1);
3356 add_com_alias ("fg", continue_cmd, class_run, 1);
3357
3358 cmd_list_element *run_cmd
3359 = add_com ("run", class_run, run_command, _("\
3360Start debugged program.\n"
3363 add_com_alias ("r", run_cmd, class_run, 1);
3364
3365 c = add_com ("start", class_run, start_command, _("\
3366Start the debugged program stopping at the beginning of the main procedure.\n"
3369
3370 c = add_com ("starti", class_run, starti_command, _("\
3371Start the debugged program stopping at the first instruction.\n"
3374
3375 add_com ("interrupt", class_run, interrupt_command,
3376 _("Interrupt the execution of the debugged program.\n\
3377If non-stop mode is enabled, interrupt only the current thread,\n\
3378otherwise all the threads in the program are stopped. To \n\
3379interrupt all running threads in non-stop mode, use the -a option."));
3380
3381 cmd_list_element *info_registers_cmd
3382 = add_info ("registers", info_registers_command, _("\
3383List of integer registers and their contents, for selected stack frame.\n\
3384One or more register names as argument means describe the given registers.\n\
3385One or more register group names as argument means describe the registers\n\
3386in the named register groups."));
3387 add_info_alias ("r", info_registers_cmd, 1);
3388 set_cmd_completer (info_registers_cmd, reg_or_group_completer);
3389
3390 c = add_info ("all-registers", info_all_registers_command, _("\
3391List of all registers and their contents, for selected stack frame.\n\
3392One or more register names as argument means describe the given registers.\n\
3393One or more register group names as argument means describe the registers\n\
3394in the named register groups."));
3396
3397 add_info ("program", info_program_command,
3398 _("Execution status of the program."));
3399
3400 add_info ("float", info_float_command,
3401 _("Print the status of the floating point unit."));
3402
3403 add_info ("vector", info_vector_command,
3404 _("Print the status of the vector unit."));
3405
3407 _("\
3408Show additional information about a process.\n\
3409Specify any process id, or use the program being debugged by default."),
3410 &info_proc_cmdlist,
3411 1/*allow-unknown*/, &infolist);
3412
3413 add_cmd ("mappings", class_info, info_proc_cmd_mappings, _("\
3414List memory regions mapped by the specified process."),
3415 &info_proc_cmdlist);
3416
3417 add_cmd ("stat", class_info, info_proc_cmd_stat, _("\
3418List process info from /proc/PID/stat."),
3419 &info_proc_cmdlist);
3420
3421 add_cmd ("status", class_info, info_proc_cmd_status, _("\
3422List process info from /proc/PID/status."),
3423 &info_proc_cmdlist);
3424
3425 add_cmd ("cwd", class_info, info_proc_cmd_cwd, _("\
3426List current working directory of the specified process."),
3427 &info_proc_cmdlist);
3428
3429 add_cmd ("cmdline", class_info, info_proc_cmd_cmdline, _("\
3430List command line arguments of the specified process."),
3431 &info_proc_cmdlist);
3432
3433 add_cmd ("exe", class_info, info_proc_cmd_exe, _("\
3434List absolute filename for executable of the specified process."),
3435 &info_proc_cmdlist);
3436
3437 add_cmd ("files", class_info, info_proc_cmd_files, _("\
3438List files opened by the specified process."),
3439 &info_proc_cmdlist);
3440
3441 add_cmd ("all", class_info, info_proc_cmd_all, _("\
3442List all available info about the specified process."),
3443 &info_proc_cmdlist);
3444
3446 &finish_print, _("\
3447Set whether `finish' prints the return value."), _("\
3448Show whether `finish' prints the return value."), nullptr,
3449 nullptr,
3452}
int regnum
const char *const name
struct gdbarch * get_current_arch(void)
Definition arch-utils.c:846
struct gdbarch * target_gdbarch(void)
struct symbol * find_pc_function(CORE_ADDR pc)
Definition blockframe.c:150
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
Definition blockframe.c:373
struct symbol * get_frame_function(frame_info_ptr frame)
Definition blockframe.c:118
struct symbol * find_pc_sect_containing_function(CORE_ADDR pc, struct obj_section *section)
Definition blockframe.c:158
void breakpoint_re_set(void)
void breakpoint_init_inferior(enum inf_context context)
void until_break_command(const char *arg, int from_tty, int anywhere)
int bpstat_num(bpstat **bsp, int *num)
void resolve_sal_pc(struct symtab_and_line *sal)
bpstat * bpstat_find_breakpoint(bpstat *bsp, struct breakpoint *breakpoint)
void set_ignore_count(int bptnum, int count, int from_tty)
void tbreak_command(const char *arg, int from_tty)
void clear_breakpoint_hit_counts(void)
Definition breakpoint.c:876
breakpoint_up set_momentary_breakpoint(struct gdbarch *gdbarch, struct symtab_and_line sal, struct frame_id frame_id, enum bptype type)
void delete_longjmp_breakpoint(int thread)
static int next_cmd
void set_longjmp_breakpoint(struct thread_info *tp, struct frame_id frame)
@ bp_finish
Definition breakpoint.h:90
@ inf_exited
std::unique_ptr< struct breakpoint, breakpoint_deleter > breakpoint_up
stop_stack_kind
ui_file_style style() const
Definition cli-style.c:169
inferior_control_state control
Definition inferior.h:570
int pid
Definition inferior.h:561
void set_args(std::string args)
Definition inferior.h:522
gdb_environ environment
Definition inferior.h:590
const std::string & cwd() const
Definition inferior.h:550
bool has_execution()
Definition inferior.h:456
struct process_stratum_target * process_target()
Definition inferior.h:449
bool needs_setup
Definition inferior.h:621
const std::string & args() const
Definition inferior.h:533
void add_continuation(std::function< void()> &&cont)
Definition inferior.c:177
const std::string & tty()
Definition inferior.c:163
inf_non_exited_threads_range non_exited_threads()
Definition inferior.h:481
void set_tty(std::string terminal_name)
Definition inferior.c:157
void set_cwd(std::string cwd)
Definition inferior.h:541
inferior(int pid)
Definition inferior.c:85
int num
Definition inferior.h:557
thread_info * find_thread(ptid_t ptid)
gdbarch * arch() const
Definition regcache.c:231
size_t size() const
Definition ui-file.h:223
const char * c_str() const
Definition ui-file.h:222
static void inferior()
Definition target.c:952
static void init()
Definition target.c:942
static void ours_for_output()
Definition target.c:1088
void set_pending_waitstatus(const target_waitstatus &ws)
Definition thread.c:408
CORE_ADDR stop_pc() const
Definition gdbthread.h:364
void set_thread_fsm(std::unique_ptr< struct thread_fsm > fsm)
Definition gdbthread.h:470
void clear_stop_pc()
Definition gdbthread.h:379
enum thread_state state
Definition gdbthread.h:339
int per_inf_num
Definition gdbthread.h:298
ptid_t ptid
Definition gdbthread.h:259
gdb_signal stop_signal() const
Definition gdbthread.h:424
struct thread_fsm * thread_fsm() const
Definition gdbthread.h:452
bool executing() const
Definition gdbthread.h:319
struct inferior * inf
Definition gdbthread.h:301
void set_stop_pc(CORE_ADDR stop_pc)
Definition gdbthread.h:372
void set_stop_signal(gdb_signal sig)
Definition gdbthread.h:431
thread_control_state control
Definition gdbthread.h:343
virtual void puts(const char *str)
Definition ui-file.h:76
void putc(int c)
Definition ui-file.c:64
void void void spaces(int numspaces)
Definition ui-out.c:560
void field_string(const char *fldname, const char *string, const ui_file_style &style=ui_file_style())
Definition ui-out.c:511
void field_fmt(const char *fldname, const char *format,...) ATTRIBUTE_PRINTF(3
Definition ui-out.c:525
void text(const char *string)
Definition ui-out.c:566
void field_stream(const char *fldname, string_file &stream, const ui_file_style &style=ui_file_style())
Definition ui-out.c:486
void flush()
Definition ui-out.c:791
struct cmd_list_element * showlist
Definition cli-cmds.c:127
struct cmd_list_element * showprintlist
Definition cli-cmds.c:163
struct cmd_list_element * infolist
Definition cli-cmds.c:91
void error_no_arg(const char *why)
Definition cli-cmds.c:206
struct cmd_list_element * cmdlist
Definition cli-cmds.c:87
struct cmd_list_element * setprintlist
Definition cli-cmds.c:161
struct cmd_list_element * setlist
Definition cli-cmds.c:119
struct cmd_list_element * detachlist
Definition cli-cmds.c:111
struct cmd_list_element * killlist
Definition cli-cmds.c:115
struct cmd_list_element * unsetlist
Definition cli-cmds.c:123
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:233
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
set_show_commands add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition cli-decode.c:117
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
Definition cli-decode.c:357
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:809
cmd_list_element * add_info_alias(const char *name, cmd_list_element *target, int abbrev_flag)
set_show_commands add_setshow_string_noescape_cmd(const char *name, enum command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:953
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
Definition cli-decode.c:391
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
cli_style_option file_name_style
cli_style_option metadata_style
void dont_repeat()
Definition top.c:696
@ class_support
Definition command.h:58
@ class_run
Definition command.h:54
@ class_files
Definition command.h:57
@ no_class
Definition command.h:53
@ class_info
Definition command.h:59
void signal_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition completer.c:1756
void noop_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *prefix)
Definition completer.c:195
void location_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *)
Definition completer.c:927
void reg_or_group_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition completer.c:1834
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition completer.c:204
void reopen_exec_file(void)
Definition corefile.c:106
const char * get_exec_file(int err)
Definition corefile.c:150
bool info_verbose
Definition top.c:1941
void(* deprecated_detach_hook)(void)
Definition top.c:246
void(* deprecated_attach_hook)(void)
Definition top.c:245
info_proc_what
Definition defs.h:380
@ IP_CMDLINE
Definition defs.h:394
@ IP_EXE
Definition defs.h:397
@ IP_ALL
Definition defs.h:406
@ IP_FILES
Definition defs.h:403
@ IP_MAPPINGS
Definition defs.h:385
@ IP_STATUS
Definition defs.h:388
@ IP_MINIMAL
Definition defs.h:382
@ IP_CWD
Definition defs.h:400
@ IP_STAT
Definition defs.h:391
return_value_convention
Definition defs.h:257
@ RETURN_VALUE_ABI_RETURNS_ADDRESS
Definition defs.h:273
@ RETURN_VALUE_REGISTER_CONVENTION
Definition defs.h:260
@ RETURN_VALUE_STRUCT_CONVENTION
Definition defs.h:267
@ RETURN_VALUE_ABI_PRESERVES_ADDRESS
Definition defs.h:279
LONGEST parse_and_eval_long(const char *exp)
Definition eval.c:62
void exception_print(struct ui_file *file, const struct gdb_exception &e)
Definition exceptions.c:106
void exec_file_locate_attach(int pid, int defer_bp_reset, int from_tty)
Definition exec.c:314
void validate_exec_file(int from_tty)
Definition exec.c:213
struct value * value_of_register(int regnum, frame_info_ptr frame)
Definition findvar.c:253
struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame)
Definition findvar.c:739
const struct frame_id null_frame_id
Definition frame.c:688
struct program_space * get_frame_program_space(frame_info_ptr frame)
Definition frame.c:2965
frame_info_ptr skip_unwritable_frames(frame_info_ptr frame)
Definition frame.c:552
CORE_ADDR get_frame_pc(frame_info_ptr frame)
Definition frame.c:2712
struct frame_id get_stack_frame_id(frame_info_ptr next_frame)
Definition frame.c:662
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
Definition frame.c:3027
enum frame_type get_frame_type(frame_info_ptr frame)
Definition frame.c:2955
frame_info_ptr get_selected_frame(const char *message)
Definition frame.c:1888
frame_info_ptr get_current_frame(void)
Definition frame.c:1670
frame_info_ptr skip_tailcall_frames(frame_info_ptr frame)
Definition frame.c:567
struct frame_id get_frame_id(frame_info_ptr fi)
Definition frame.c:631
frame_info_ptr get_prev_frame(frame_info_ptr this_frame)
Definition frame.c:2614
symtab_and_line find_frame_sal(frame_info_ptr frame)
Definition frame.c:2821
@ LOCATION
Definition frame.h:809
@ INLINE_FRAME
Definition frame.h:193
void print_stack_frame(frame_info_ptr, int print_level, enum print_what print_what, int set_current_sal)
Definition stack.c:353
enum return_value_convention gdbarch_return_value_as_value(struct gdbarch *gdbarch, struct value *function, struct type *valtype, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf)
Definition gdbarch.c:2610
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
Definition gdbarch.c:2173
void gdbarch_print_registers_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int all)
Definition gdbarch.c:2327
bool gdbarch_skip_entrypoint_p(struct gdbarch *gdbarch)
Definition gdbarch.c:2736
bool gdbarch_print_vector_info_p(struct gdbarch *gdbarch)
Definition gdbarch.c:2361
CORE_ADDR gdbarch_skip_entrypoint(struct gdbarch *gdbarch, CORE_ADDR ip)
Definition gdbarch.c:2743
void gdbarch_print_float_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args)
Definition gdbarch.c:2344
bool gdbarch_info_proc_p(struct gdbarch *gdbarch)
Definition gdbarch.c:5024
int gdbarch_has_global_solist(struct gdbarch *gdbarch)
Definition gdbarch.c:4854
int gdbarch_register_reggroup_p(struct gdbarch *gdbarch, int regnum, const struct reggroup *reggroup)
Definition gdbarch.c:3670
void gdbarch_print_vector_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args)
Definition gdbarch.c:2368
CORE_ADDR gdbarch_get_return_buf_addr(struct gdbarch *gdbarch, struct type *val_type, frame_info_ptr cur_frame)
Definition gdbarch.c:2627
void gdbarch_info_proc(struct gdbarch *gdbarch, const char *args, enum info_proc_what what)
Definition gdbarch.c:5031
static int gdbarch_num_cooked_regs(gdbarch *arch)
Definition gdbarch.h:390
all_matching_threads_range all_threads(process_stratum_target *proc_target=nullptr, ptid_t filter_ptid=minus_one_ptid)
Definition gdbthread.h:742
void switch_to_thread_no_regs(struct thread_info *thread)
Definition thread.c:1328
all_non_exited_threads_range all_non_exited_threads(process_stratum_target *proc_target=nullptr, ptid_t filter_ptid=minus_one_ptid)
Definition gdbthread.h:753
@ THREAD_STOPPED
Definition gdbthread.h:72
@ THREAD_RUNNING
Definition gdbthread.h:75
@ THREAD_EXITED
Definition gdbthread.h:79
void set_stop_requested(process_stratum_target *targ, ptid_t ptid, bool stop)
Definition thread.c:931
struct thread_info * inferior_thread(void)
Definition thread.c:85
void switch_to_thread(struct thread_info *thr)
Definition thread.c:1360
void set_running(process_stratum_target *targ, ptid_t ptid, bool running)
Definition thread.c:891
struct thread_info * iterate_over_threads(thread_callback_func, void *)
Definition thread.c:584
FORWARD_SCOPE_EXIT(finish_thread_state) scoped_finish_thread_state
Definition gdbthread.h:836
@ STEP_OVER_NONE
Definition gdbthread.h:88
@ STEP_OVER_ALL
Definition gdbthread.h:89
const char * print_thread_id(struct thread_info *thr)
Definition thread.c:1470
void init_thread_list(void)
Definition thread.c:257
enum bfd_endian type_byte_order(const struct type *type)
Definition gdbtypes.c:3900
bool is_nocall_function(const struct type *type)
Definition gdbtypes.c:3920
struct type * check_typedef(struct type *type)
Definition gdbtypes.c:2966
#define TYPE_NO_RETURN(thistype)
Definition gdbtypes.h:1944
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
Definition gnu-nat.c:1791
size_t size
Definition go32-nat.c:239
void inferior_event_handler(enum inferior_event_type event_type)
Definition inf-loop.c:37
static void set_tty_value(const std::string &tty)
Definition infcmd.c:95
static void signal_command(const char *signum_exp, int from_tty)
Definition infcmd.c:1134
void attach_command(const char *args, int from_tty)
Definition infcmd.c:2653
static void path_command(const char *dirname, int from_tty)
Definition infcmd.c:2175
static void info_vector_command(const char *args, int from_tty)
Definition infcmd.c:2472
static void show_inferior_tty_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition infcmd.c:111
static void finish_command(const char *arg, int from_tty)
Definition infcmd.c:1824
static void kill_if_already_running(int from_tty)
Definition infcmd.c:316
static void pad_to_column(string_file &stream, int col)
Definition infcmd.c:2193
void continue_1(int all_threads)
Definition infcmd.c:601
static void finish_backward(struct finish_command_fsm *sm)
Definition infcmd.c:1703
static void interrupt_command(const char *args, int from_tty)
Definition infcmd.c:2965
static void set_step_frame(thread_info *tp)
Definition infcmd.c:741
static void set_args_value(const std::string &args)
Definition infcmd.c:126
static bool finish_print
Definition infcmd.c:88
static void info_proc_cmd_status(const char *args, int from_tty)
Definition infcmd.c:3058
static void info_proc_cmd_1(const char *args, enum info_proc_what what, int from_tty)
Definition infcmd.c:3018
static void set_environment_command(const char *arg, int from_tty)
Definition infcmd.c:2085
static const std::string & get_args_value()
Definition infcmd.c:134
static void stop_current_target_threads_ns(ptid_t ptid)
Definition infcmd.c:2916
static void show_print_finish(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition infcmd.c:3106
void prepare_execution_command(struct target_ops *target, int background)
Definition infcmd.c:335
static void environment_info(const char *var, int from_tty)
Definition infcmd.c:2052
static void step_command(const char *count_string, int from_tty)
Definition infcmd.c:759
static void ensure_not_tfind_mode(void)
Definition infcmd.c:576
static void info_float_command(const char *args, int from_tty)
Definition infcmd.c:3004
static void print_return_value_1(struct ui_out *uiout, struct return_value_info *rv)
Definition infcmd.c:1532
ptid_t inferior_ptid
Definition infcmd.c:74
static void disconnect_command(const char *args, int from_tty)
Definition infcmd.c:2897
static void stepi_command(const char *count_string, int from_tty)
Definition infcmd.c:775
static void run_command_1(const char *args, int from_tty, enum run_how run_how)
Definition infcmd.c:370
static void set_cwd_value(const std::string &args)
Definition infcmd.c:163
static void info_proc_cmd_cwd(const char *args, int from_tty)
Definition infcmd.c:3066
static void nexti_command(const char *count_string, int from_tty)
Definition infcmd.c:781
static const std::string & get_tty_value()
Definition infcmd.c:103
static frame_info_ptr skip_finish_frames(frame_info_ptr frame)
Definition infcmd.c:1799
void default_print_registers_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, int regnum, int print_all)
Definition infcmd.c:2285
static void unset_environment_command(const char *var, int from_tty)
Definition infcmd.c:2147
static void attach_post_wait(int from_tty, enum attach_post_wait_mode mode)
Definition infcmd.c:2579
attach_post_wait_mode
Definition infcmd.c:2563
@ ATTACH_POST_WAIT_RESUME
Definition infcmd.c:2568
@ ATTACH_POST_WAIT_NOTHING
Definition infcmd.c:2565
@ ATTACH_POST_WAIT_STOP
Definition infcmd.c:2571
static void step_command_fsm_prepare(struct step_command_fsm *sm, int skip_subroutines, int single_inst, int count, struct thread_info *thread)
Definition infcmd.c:814
static void info_proc_cmd_stat(const char *args, int from_tty)
Definition infcmd.c:3050
void detach_command(const char *args, int from_tty)
Definition infcmd.c:2840
static void until_next_command(int)
Definition infcmd.c:1326
static void info_proc_cmd_mappings(const char *args, int from_tty)
Definition infcmd.c:3042
static void ensure_valid_thread(void)
Definition infcmd.c:564
static void queue_signal_command(const char *signum_exp, int from_tty)
Definition infcmd.c:1231
static void info_proc_cmd_exe(const char *args, int from_tty)
Definition infcmd.c:3082
#define ERROR_NO_INFERIOR
Definition infcmd.c:66
static void info_proc_cmd(const char *args, int from_tty)
Definition infcmd.c:3034
static void starti_command(const char *args, int from_tty)
Definition infcmd.c:534
static void info_all_registers_command(const char *addr_exp, int from_tty)
Definition infcmd.c:2434
void _initialize_infcmd()
Definition infcmd.c:3134
static void continue_command(const char *args, int from_tty)
Definition infcmd.c:651
static gdb::unique_xmalloc_ptr< char > strip_bg_char(const char *args, int *bg_char_p)
Definition infcmd.c:198
static void advance_command(const char *arg, int from_tty)
Definition infcmd.c:1443
static void info_registers_command(const char *addr_exp, int from_tty)
Definition infcmd.c:2440
void interrupt_target_1(bool all_threads)
Definition infcmd.c:2933
void registers_info(const char *addr_exp, int fpregs)
Definition infcmd.c:2328
struct value * get_return_value(struct symbol *func_symbol, struct value *function)
Definition infcmd.c:1467
static void error_is_running(void)
Definition infcmd.c:585
int stopped_by_random_signal
Definition infcmd.c:83
static void show_args_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition infcmd.c:142
static void start_command(const char *args, int from_tty)
Definition infcmd.c:518
static void run_command(const char *args, int from_tty)
Definition infcmd.c:509
run_how
Definition infcmd.c:355
@ RUN_NORMAL
Definition infcmd.c:357
@ RUN_STOP_AT_MAIN
Definition infcmd.c:360
@ RUN_STOP_AT_FIRST_INSN
Definition infcmd.c:363
static void default_print_one_register_info(struct ui_file *file, const char *name, struct value *val)
Definition infcmd.c:2206
static void finish_forward(struct finish_command_fsm *sm, frame_info_ptr frame)
Definition infcmd.c:1771
const std::string & get_inferior_cwd()
Definition infcmd.c:155
static void info_program_command(const char *args, int from_tty)
Definition infcmd.c:1945
static void info_proc_cmd_files(const char *args, int from_tty)
Definition infcmd.c:3090
static void info_proc_cmd_all(const char *args, int from_tty)
Definition infcmd.c:3098
static int prepare_one_step(thread_info *, struct step_command_fsm *sm)
Definition infcmd.c:927
static int proceed_thread_callback(struct thread_info *thread, void *arg)
Definition infcmd.c:540
static void next_command(const char *count_string, int from_tty)
Definition infcmd.c:767
static void jump_command(const char *arg, int from_tty)
Definition infcmd.c:1041
void setup_inferior(int from_tty)
Definition infcmd.c:2538
void notice_new_inferior(thread_info *thr, bool leave_running, int from_tty)
Definition infcmd.c:2788
enum stop_stack_kind stop_stack_dummy
Definition infcmd.c:78
static void path_info(const char *args, int from_tty)
Definition infcmd.c:2165
void default_print_float_info(struct gdbarch *gdbarch, struct ui_file *file, frame_info_ptr frame, const char *args)
Definition infcmd.c:2984
void post_create_inferior(int from_tty)
Definition infcmd.c:232
static void step_1(int, int, const char *)
Definition infcmd.c:832
static void info_proc_cmd_cmdline(const char *args, int from_tty)
Definition infcmd.c:3074
static void until_command(const char *arg, int from_tty)
Definition infcmd.c:1421
void print_return_value(struct ui_out *uiout, struct return_value_info *rv)
Definition infcmd.c:1571
#define RUN_ARGS_HELP
Definition infcmd.c:3119
static void proceed_after_attach(inferior *inf)
Definition infcmd.c:2516
static void print_vector_info(struct ui_file *file, frame_info_ptr frame, const char *args)
Definition infcmd.c:2446
static void ensure_not_running(void)
Definition infcmd.c:594
static const char path_var_name[]
Definition infcmd.c:2162
static void show_cwd_command(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition infcmd.c:171
static void kill_command(const char *arg, int from_tty)
Definition infcmd.c:2483
bool print_inferior_events
Definition inferior.c:47
struct inferior * current_inferior(void)
Definition inferior.c:55
void switch_to_inferior_no_thread(inferior *inf)
Definition inferior.c:712
all_inferiors_range all_inferiors(process_stratum_target *proc_target=nullptr)
Definition inferior.h:821
@ NO_STOP_QUIETLY
Definition inferior.h:294
@ STOP_QUIETLY_REMOTE
Definition inferior.h:296
@ STOP_QUIETLY_NO_SIGSTOP
Definition inferior.h:297
FORWARD_SCOPE_EXIT(delete_longjmp_breakpoint) delete_longjmp_breakpoint_cleanup
Definition inferior.h:232
void set_step_info(thread_info *tp, frame_info_ptr frame, struct symtab_and_line sal)
Definition infrun.c:4575
void insert_step_resume_breakpoint_at_sal(struct gdbarch *gdbarch, struct symtab_and_line sr_sal, struct frame_id sr_id)
Definition infrun.c:8204
void mark_infrun_async_event_handler(void)
Definition infrun.c:139
bool normal_stop()
Definition infrun.c:8899
bool step_stop_if_no_debug
Definition infrun.c:147
thread_info * get_previous_thread()
Definition infrun.c:175
process_stratum_target * user_visible_resume_target(ptid_t resume_ptid)
Definition infrun.c:2313
void restart_after_all_stop_detach(process_stratum_target *proc_target)
Definition infrun.c:7911
void clear_proceed_status(int step)
Definition infrun.c:2924
enum exec_direction_kind execution_direction
Definition infrun.c:9768
bool non_stop
Definition infrun.c:226
void update_previous_thread()
Definition infrun.c:164
int signal_pass_state(int signo)
Definition infrun.c:9097
void all_uis_on_sync_execution_starting(void)
Definition infrun.c:4304
enum gdb_signal gdb_signal_from_command(int num)
Definition infrun.c:9381
void all_uis_check_sync_execution_done(void)
Definition infrun.c:4293
void stop_all_threads(const char *reason, inferior *inf)
Definition infrun.c:5315
void init_wait_for_inferior(void)
Definition infrun.c:3639
void get_last_target_status(process_stratum_target **target, ptid_t *ptid, target_waitstatus *status)
Definition infrun.c:4621
void proceed(CORE_ADDR addr, enum gdb_signal siggnal)
Definition infrun.c:3395
ptid_t user_visible_resume_ptid(int step)
Definition infrun.c:2271
@ EXEC_REVERSE
Definition infrun.h:114
static void infrun_debug_show_threads(const char *title, ThreadRange threads)
Definition infrun.h:61
int inline_skipped_frames(thread_info *thread)
void step_into_inline_frame(thread_info *thread)
struct symbol * inline_skipped_symbol(thread_info *thread)
struct interp * command_interp(void)
Definition interps.c:247
const struct language_defn * current_language
Definition language.c:82
std::vector< symtab_and_line > decode_line_with_current_source(const char *string, int flags)
Definition linespec.c:3211
@ DECODE_LINE_FUNFIRSTLINE
Definition linespec.h:30
async_reply_reason
Definition mi-common.h:26
@ EXEC_ASYNC_FUNCTION_FINISHED
Definition mi-common.h:31
@ EXEC_ASYNC_END_STEPPING_RANGE
Definition mi-common.h:34
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
Definition minsyms.c:996
observable< inferior * > inferior_created
int have_minimal_symbols(void)
Definition objfiles.c:812
static process_stratum_target * as_process_stratum_target(target_ops *target)
struct program_space * current_program_space
Definition progspace.c:40
int value
Definition py-param.c:79
CORE_ADDR regcache_read_pc(struct regcache *regcache)
Definition regcache.c:1333
struct regcache * get_current_regcache(void)
Definition regcache.c:429
struct regcache * get_thread_regcache(process_stratum_target *target, ptid_t ptid)
Definition regcache.c:400
const reggroup *const general_reggroup
Definition reggroups.c:251
const reggroup *const float_reggroup
Definition reggroups.c:252
const reggroup *const all_reggroup
Definition reggroups.c:255
const std::vector< const reggroup * > & gdbarch_reggroups(struct gdbarch *gdbarch)
Definition reggroups.c:136
const reggroup *const vector_reggroup
Definition reggroups.c:254
void(* func)(remote_target *remote, char *)
bool function_name_is_marked_for_skip(const char *function_name, const symtab_and_line &function_sal)
Definition skip.c:614
void solib_create_inferior_hook(int from_tty)
Definition solib.c:1252
void solib_add(const char *pattern, int from_tty, int readsyms)
Definition solib.c:990
void no_shared_libraries(const char *ignored, int from_tty)
Definition solib.c:1284
struct symtab_and_line get_current_source_symtab_and_line(void)
Definition source.c:239
void mod_path(const char *dirname, std::string &which_path)
Definition source.c:477
Definition block.h:109
CORE_ADDR end() const
Definition block.h:119
CORE_ADDR value_address() const
Definition minsyms.h:41
struct minimal_symbol * minsym
Definition minsyms.h:49
breakpoint_up breakpoint
Definition infcmd.c:1596
CORE_ADDR return_buf
Definition infcmd.c:1609
enum async_reply_reason do_async_reply_reason() override
Definition infcmd.c:1692
void clean_up(struct thread_info *thread) override
Definition infcmd.c:1673
struct symbol * function
Definition infcmd.c:1599
struct return_value_info * return_value() override
Definition infcmd.c:1683
bool should_stop(struct thread_info *thread) override
Definition infcmd.c:1628
finish_command_fsm(struct interp *cmd_interp)
Definition infcmd.c:1611
const char * print_name() const
Definition symtab.h:475
struct obj_section * obj_section(const struct objfile *objfile) const
Definition symtab.c:1117
Definition gnu-nat.c:153
enum stop_kind stop_soon
Definition inferior.h:326
CORE_ADDR addr() const
Definition objfiles.h:385
unsigned int solib_add_generation
Definition progspace.h:367
bfd * exec_bfd() const
Definition progspace.h:268
int value_history_index
Definition infcmd.c:1526
struct type * type
Definition infcmd.c:1523
struct value * value
Definition infcmd.c:1519
step_command_fsm(struct interp *cmd_interp)
Definition infcmd.c:800
void clean_up(struct thread_info *thread) override
Definition infcmd.c:906
int skip_subroutines
Definition infcmd.c:795
bool should_stop(struct thread_info *thread) override
Definition infcmd.c:888
enum async_reply_reason do_async_reply_reason() override
Definition infcmd.c:916
const block * value_block() const
Definition symtab.h:1549
address_class aclass() const
Definition symtab.h:1274
struct type * type() const
Definition symtab.h:1331
struct objfile * objfile() const
Definition symtab.c:6482
struct symtab * symtab
Definition symtab.h:2328
CORE_ADDR pc
Definition symtab.h:2337
CORE_ADDR end
Definition symtab.h:2338
struct program_space * pspace
Definition symtab.h:2326
virtual void create_inferior(const char *, const std::string &, char **, int)
Definition target.c:3070
virtual bool supports_non_stop() TARGET_DEFAULT_RETURN(false)
virtual void attach(const char *, int)
Definition target.c:3058
target_waitstatus & set_stopped(gdb_signal sig)
Definition waitstatus.h:230
CORE_ADDR step_range_start
Definition gdbthread.h:124
CORE_ADDR step_range_end
Definition gdbthread.h:125
enum step_over_calls_kind step_over_calls
Definition gdbthread.h:161
struct symbol * step_start_function
Definition gdbthread.h:128
virtual void clean_up(struct thread_info *thread)
Definition thread-fsm.h:48
void set_finished()
Definition thread-fsm.h:82
struct type * target_type() const
Definition gdbtypes.h:1037
type_code code() const
Definition gdbtypes.h:956
ULONGEST length() const
Definition gdbtypes.h:983
bool is_vector() const
Definition gdbtypes.h:1186
enum prompt_state prompt_state
Definition ui.h:136
enum async_reply_reason do_async_reply_reason() override
Definition infcmd.c:1312
until_next_fsm(struct interp *cmd_interp, int thread)
Definition infcmd.c:1276
bool should_stop(struct thread_info *thread) override
Definition infcmd.c:1291
void clean_up(struct thread_info *thread) override
Definition infcmd.c:1303
Definition value.h:130
bool entirely_available()
Definition value.c:209
struct type * type() const
Definition value.h:180
bool optimized_out()
Definition value.c:1279
gdb::array_view< const gdb_byte > contents_for_printing()
Definition value.c:1100
int section_is_mapped(struct obj_section *osect)
Definition symfile.c:3019
bool auto_solib_add
Definition symfile.c:149
void reread_symbols(int from_tty)
Definition symfile.c:2457
struct obj_section * find_pc_mapped_section(CORE_ADDR pc)
Definition symfile.c:3203
int section_is_overlay(struct obj_section *section)
Definition symfile.c:2983
bool find_pc_line_pc_range(CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endptr)
Definition symtab.c:3587
const char * main_name()
Definition symtab.c:6322
struct symtab_and_line find_pc_line(CORE_ADDR pc, int notcurrent)
Definition symtab.c:3295
@ LOC_BLOCK
Definition symtab.h:1028
void target_find_description(void)
struct target_ops * find_run_target(void)
Definition target.c:2930
void target_require_runnable(void)
Definition target.c:2822
void target_post_attach(int pid)
Definition target.c:232
bool target_is_async_p()
Definition target.c:402
struct target_ops * find_attach_target(void)
Definition target.c:2912
void target_pre_inferior(int from_tty)
Definition target.c:2449
void target_async(bool enable)
Definition target.c:4337
void target_interrupt()
Definition target.c:3798
void target_detach(inferior *inf, int from_tty)
Definition target.c:2531
bool target_can_async_p()
Definition target.c:384
void target_kill(void)
Definition target.c:913
bool target_has_execution(inferior *inf)
Definition target.c:201
void target_disconnect(const char *args, int from_tty)
Definition target.c:2573
int target_has_registers()
Definition target.c:189
bool target_attach_no_wait()
Definition target.c:224
void target_stop(ptid_t ptid)
Definition target.c:3782
bool target_is_non_stop_p()
Definition target.c:4394
std::string target_pid_to_str(ptid_t ptid)
Definition target.c:2623
int target_info_proc(const char *args, enum info_proc_what what)
Definition target.c:2954
void target_files_info()
Definition target.c:298
@ INF_EXEC_COMPLETE
Definition target.h:136
void disconnect_tracing(void)
int get_traceframe_number(void)
void query_if_trace_running(int from_tty)
std::string type_to_string(struct type *type)
Definition typeprint.c:399
#define current_uiout
Definition ui-out.h:40
struct ui * current_ui
Definition ui.c:35
@ PROMPT_BLOCKED
Definition ui.h:35
const char * user_reg_map_regnum_to_name(struct gdbarch *gdbarch, int regnum)
Definition user-regs.c:187
int user_reg_map_name_to_regnum(struct gdbarch *gdbarch, const char *name, int len)
Definition user-regs.c:132
struct value * value_of_user_reg(int regnum, frame_info_ptr frame)
Definition user-regs.c:206
int query(const char *ctlstr,...)
Definition utils.c:943
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
Definition utils.c:3166
const char * n_spaces(int n)
Definition utils.c:1947
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
void gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1809
#define gdb_stdout
Definition utils.h:182
struct value * value_at(struct type *type, CORE_ADDR addr)
Definition valops.c:1015
void get_formatted_print_options(struct value_print_options *opts, char format)
Definition valprint.c:152
void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options)
Definition valprint.c:1191
void get_user_print_options(struct value_print_options *opts)
Definition valprint.c:135
void print_hex_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad)
Definition valprint.c:1841
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
Definition valprint.c:1033