the "ambiguous linespec" series
[deliverable/binutils-gdb.git] / gdb / infcmd.c
1 /* Memory-access and commands for "inferior" process, for GDB.
2
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
4 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
5 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23 #include "arch-utils.h"
24 #include <signal.h>
25 #include "gdb_string.h"
26 #include "symtab.h"
27 #include "gdbtypes.h"
28 #include "frame.h"
29 #include "inferior.h"
30 #include "environ.h"
31 #include "value.h"
32 #include "gdbcmd.h"
33 #include "symfile.h"
34 #include "gdbcore.h"
35 #include "target.h"
36 #include "language.h"
37 #include "symfile.h"
38 #include "objfiles.h"
39 #include "completer.h"
40 #include "ui-out.h"
41 #include "event-top.h"
42 #include "parser-defs.h"
43 #include "regcache.h"
44 #include "reggroups.h"
45 #include "block.h"
46 #include "solib.h"
47 #include <ctype.h>
48 #include "gdb_assert.h"
49 #include "observer.h"
50 #include "target-descriptions.h"
51 #include "user-regs.h"
52 #include "exceptions.h"
53 #include "cli/cli-decode.h"
54 #include "gdbthread.h"
55 #include "valprint.h"
56 #include "inline-frame.h"
57 #include "tracepoint.h"
58 #include "inf-loop.h"
59 #include "continuations.h"
60 #include "linespec.h"
61
62 /* Functions exported for general use, in inferior.h: */
63
64 void all_registers_info (char *, int);
65
66 void registers_info (char *, int);
67
68 void nexti_command (char *, int);
69
70 void stepi_command (char *, int);
71
72 void continue_command (char *, int);
73
74 void interrupt_target_command (char *args, int from_tty);
75
76 /* Local functions: */
77
78 static void nofp_registers_info (char *, int);
79
80 static void print_return_value (struct type *func_type,
81 struct type *value_type);
82
83 static void until_next_command (int);
84
85 static void until_command (char *, int);
86
87 static void path_info (char *, int);
88
89 static void path_command (char *, int);
90
91 static void unset_command (char *, int);
92
93 static void float_info (char *, int);
94
95 static void disconnect_command (char *, int);
96
97 static void unset_environment_command (char *, int);
98
99 static void set_environment_command (char *, int);
100
101 static void environment_info (char *, int);
102
103 static void program_info (char *, int);
104
105 static void finish_command (char *, int);
106
107 static void signal_command (char *, int);
108
109 static void jump_command (char *, int);
110
111 static void step_1 (int, int, char *);
112 static void step_once (int skip_subroutines, int single_inst,
113 int count, int thread);
114
115 static void next_command (char *, int);
116
117 static void step_command (char *, int);
118
119 static void run_command (char *, int);
120
121 static void run_no_args_command (char *args, int from_tty);
122
123 static void go_command (char *line_no, int from_tty);
124
125 static int strip_bg_char (char **);
126
127 void _initialize_infcmd (void);
128
129 #define ERROR_NO_INFERIOR \
130 if (!target_has_execution) error (_("The program is not being run."));
131
132 /* Scratch area where string containing arguments to give to the
133 program will be stored by 'set args'. As soon as anything is
134 stored, notice_args_set will move it into per-inferior storage.
135 Arguments are separated by spaces. Empty string (pointer to '\0')
136 means no args. */
137
138 static char *inferior_args_scratch;
139
140 /* Scratch area where 'set inferior-tty' will store user-provided value.
141 We'll immediate copy it into per-inferior storage. */
142
143 static char *inferior_io_terminal_scratch;
144
145 /* Pid of our debugged inferior, or 0 if no inferior now.
146 Since various parts of infrun.c test this to see whether there is a program
147 being debugged it should be nonzero (currently 3 is used) for remote
148 debugging. */
149
150 ptid_t inferior_ptid;
151
152 /* Address at which inferior stopped. */
153
154 CORE_ADDR stop_pc;
155
156 /* Flag indicating that a command has proceeded the inferior past the
157 current breakpoint. */
158
159 int breakpoint_proceeded;
160
161 /* Nonzero if stopped due to completion of a stack dummy routine. */
162
163 enum stop_stack_kind stop_stack_dummy;
164
165 /* Nonzero if stopped due to a random (unexpected) signal in inferior
166 process. */
167
168 int stopped_by_random_signal;
169
170 \f
171 /* Accessor routines. */
172
173 /* Set the io terminal for the current inferior. Ownership of
174 TERMINAL_NAME is not transferred. */
175
176 void
177 set_inferior_io_terminal (const char *terminal_name)
178 {
179 xfree (current_inferior ()->terminal);
180 current_inferior ()->terminal = terminal_name ? xstrdup (terminal_name) : 0;
181 }
182
183 const char *
184 get_inferior_io_terminal (void)
185 {
186 return current_inferior ()->terminal;
187 }
188
189 static void
190 set_inferior_tty_command (char *args, int from_tty,
191 struct cmd_list_element *c)
192 {
193 /* CLI has assigned the user-provided value to inferior_io_terminal_scratch.
194 Now route it to current inferior. */
195 set_inferior_io_terminal (inferior_io_terminal_scratch);
196 }
197
198 static void
199 show_inferior_tty_command (struct ui_file *file, int from_tty,
200 struct cmd_list_element *c, const char *value)
201 {
202 /* Note that we ignore the passed-in value in favor of computing it
203 directly. */
204 const char *inferior_io_terminal = get_inferior_io_terminal ();
205
206 if (inferior_io_terminal == NULL)
207 inferior_io_terminal = "";
208 fprintf_filtered (gdb_stdout,
209 _("Terminal for future runs of program being debugged "
210 "is \"%s\".\n"), inferior_io_terminal);
211 }
212
213 char *
214 get_inferior_args (void)
215 {
216 if (current_inferior ()->argc != 0)
217 {
218 char *n;
219
220 n = construct_inferior_arguments (current_inferior ()->argc,
221 current_inferior ()->argv);
222 set_inferior_args (n);
223 xfree (n);
224 }
225
226 if (current_inferior ()->args == NULL)
227 current_inferior ()->args = xstrdup ("");
228
229 return current_inferior ()->args;
230 }
231
232 /* Set the arguments for the current inferior. Ownership of
233 NEWARGS is not transferred. */
234
235 void
236 set_inferior_args (char *newargs)
237 {
238 xfree (current_inferior ()->args);
239 current_inferior ()->args = newargs ? xstrdup (newargs) : NULL;
240 current_inferior ()->argc = 0;
241 current_inferior ()->argv = 0;
242 }
243
244 void
245 set_inferior_args_vector (int argc, char **argv)
246 {
247 current_inferior ()->argc = argc;
248 current_inferior ()->argv = argv;
249 }
250
251 /* Notice when `set args' is run. */
252 static void
253 set_args_command (char *args, int from_tty, struct cmd_list_element *c)
254 {
255 /* CLI has assigned the user-provided value to inferior_args_scratch.
256 Now route it to current inferior. */
257 set_inferior_args (inferior_args_scratch);
258 }
259
260 /* Notice when `show args' is run. */
261 static void
262 show_args_command (struct ui_file *file, int from_tty,
263 struct cmd_list_element *c, const char *value)
264 {
265 /* Note that we ignore the passed-in value in favor of computing it
266 directly. */
267 deprecated_show_value_hack (file, from_tty, c, get_inferior_args ());
268 }
269
270 \f
271 /* Compute command-line string given argument vector. This does the
272 same shell processing as fork_inferior. */
273 char *
274 construct_inferior_arguments (int argc, char **argv)
275 {
276 char *result;
277
278 if (STARTUP_WITH_SHELL)
279 {
280 /* This holds all the characters considered special to the
281 typical Unix shells. We include `^' because the SunOS
282 /bin/sh treats it as a synonym for `|'. */
283 char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
284 int i;
285 int length = 0;
286 char *out, *cp;
287
288 /* We over-compute the size. It shouldn't matter. */
289 for (i = 0; i < argc; ++i)
290 length += 3 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
291
292 result = (char *) xmalloc (length);
293 out = result;
294
295 for (i = 0; i < argc; ++i)
296 {
297 if (i > 0)
298 *out++ = ' ';
299
300 /* Need to handle empty arguments specially. */
301 if (argv[i][0] == '\0')
302 {
303 *out++ = '\'';
304 *out++ = '\'';
305 }
306 else
307 {
308 for (cp = argv[i]; *cp; ++cp)
309 {
310 if (*cp == '\n')
311 {
312 /* A newline cannot be quoted with a backslash (it
313 just disappears), only by putting it inside
314 quotes. */
315 *out++ = '\'';
316 *out++ = '\n';
317 *out++ = '\'';
318 }
319 else
320 {
321 if (strchr (special, *cp) != NULL)
322 *out++ = '\\';
323 *out++ = *cp;
324 }
325 }
326 }
327 }
328 *out = '\0';
329 }
330 else
331 {
332 /* In this case we can't handle arguments that contain spaces,
333 tabs, or newlines -- see breakup_args(). */
334 int i;
335 int length = 0;
336
337 for (i = 0; i < argc; ++i)
338 {
339 char *cp = strchr (argv[i], ' ');
340 if (cp == NULL)
341 cp = strchr (argv[i], '\t');
342 if (cp == NULL)
343 cp = strchr (argv[i], '\n');
344 if (cp != NULL)
345 error (_("can't handle command-line "
346 "argument containing whitespace"));
347 length += strlen (argv[i]) + 1;
348 }
349
350 result = (char *) xmalloc (length);
351 result[0] = '\0';
352 for (i = 0; i < argc; ++i)
353 {
354 if (i > 0)
355 strcat (result, " ");
356 strcat (result, argv[i]);
357 }
358 }
359
360 return result;
361 }
362 \f
363
364 /* This function detects whether or not a '&' character (indicating
365 background execution) has been added as *the last* of the arguments ARGS
366 of a command. If it has, it removes it and returns 1. Otherwise it
367 does nothing and returns 0. */
368 static int
369 strip_bg_char (char **args)
370 {
371 char *p = NULL;
372
373 p = strchr (*args, '&');
374
375 if (p)
376 {
377 if (p == (*args + strlen (*args) - 1))
378 {
379 if (strlen (*args) > 1)
380 {
381 do
382 p--;
383 while (*p == ' ' || *p == '\t');
384 *(p + 1) = '\0';
385 }
386 else
387 *args = 0;
388 return 1;
389 }
390 }
391 return 0;
392 }
393
394 /* Common actions to take after creating any sort of inferior, by any
395 means (running, attaching, connecting, et cetera). The target
396 should be stopped. */
397
398 void
399 post_create_inferior (struct target_ops *target, int from_tty)
400 {
401 volatile struct gdb_exception ex;
402
403 /* Be sure we own the terminal in case write operations are performed. */
404 target_terminal_ours ();
405
406 /* If the target hasn't taken care of this already, do it now.
407 Targets which need to access registers during to_open,
408 to_create_inferior, or to_attach should do it earlier; but many
409 don't need to. */
410 target_find_description ();
411
412 /* Now that we know the register layout, retrieve current PC. But
413 if the PC is unavailable (e.g., we're opening a core file with
414 missing registers info), ignore it. */
415 stop_pc = 0;
416 TRY_CATCH (ex, RETURN_MASK_ERROR)
417 {
418 stop_pc = regcache_read_pc (get_current_regcache ());
419 }
420 if (ex.reason < 0 && ex.error != NOT_AVAILABLE_ERROR)
421 throw_exception (ex);
422
423 if (exec_bfd)
424 {
425 const unsigned solib_add_generation
426 = current_program_space->solib_add_generation;
427
428 /* Create the hooks to handle shared library load and unload
429 events. */
430 #ifdef SOLIB_CREATE_INFERIOR_HOOK
431 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
432 #else
433 solib_create_inferior_hook (from_tty);
434 #endif
435
436 if (current_program_space->solib_add_generation == solib_add_generation)
437 {
438 /* The platform-specific hook should load initial shared libraries,
439 but didn't. FROM_TTY will be incorrectly 0 but such solib
440 targets should be fixed anyway. Call it only after the solib
441 target has been initialized by solib_create_inferior_hook. */
442
443 if (info_verbose)
444 warning (_("platform-specific solib_create_inferior_hook did "
445 "not load initial shared libraries."));
446
447 /* If the solist is global across processes, there's no need to
448 refetch it here. */
449 if (!gdbarch_has_global_solist (target_gdbarch))
450 {
451 #ifdef SOLIB_ADD
452 SOLIB_ADD (NULL, 0, target, auto_solib_add);
453 #else
454 solib_add (NULL, 0, target, auto_solib_add);
455 #endif
456 }
457 }
458 }
459
460 /* If the user sets watchpoints before execution having started,
461 then she gets software watchpoints, because GDB can't know which
462 target will end up being pushed, or if it supports hardware
463 watchpoints or not. breakpoint_re_set takes care of promoting
464 watchpoints to hardware watchpoints if possible, however, if this
465 new inferior doesn't load shared libraries or we don't pull in
466 symbols from any other source on this target/arch,
467 breakpoint_re_set is never called. Call it now so that software
468 watchpoints get a chance to be promoted to hardware watchpoints
469 if the now pushed target supports hardware watchpoints. */
470 breakpoint_re_set ();
471
472 observer_notify_inferior_created (target, from_tty);
473 }
474
475 /* Kill the inferior if already running. This function is designed
476 to be called when we are about to start the execution of the program
477 from the beginning. Ask the user to confirm that he wants to restart
478 the program being debugged when FROM_TTY is non-null. */
479
480 static void
481 kill_if_already_running (int from_tty)
482 {
483 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
484 {
485 /* Bail out before killing the program if we will not be able to
486 restart it. */
487 target_require_runnable ();
488
489 if (from_tty
490 && !query (_("The program being debugged has been started already.\n\
491 Start it from the beginning? ")))
492 error (_("Program not restarted."));
493 target_kill ();
494 }
495 }
496
497 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
498 a temporary breakpoint at the begining of the main program before
499 running the program. */
500
501 static void
502 run_command_1 (char *args, int from_tty, int tbreak_at_main)
503 {
504 char *exec_file;
505 struct cleanup *old_chain;
506 ptid_t ptid;
507 struct ui_out *uiout = current_uiout;
508
509 dont_repeat ();
510
511 kill_if_already_running (from_tty);
512
513 init_wait_for_inferior ();
514 clear_breakpoint_hit_counts ();
515
516 /* Clean up any leftovers from other runs. Some other things from
517 this function should probably be moved into target_pre_inferior. */
518 target_pre_inferior (from_tty);
519
520 /* The comment here used to read, "The exec file is re-read every
521 time we do a generic_mourn_inferior, so we just have to worry
522 about the symbol file." The `generic_mourn_inferior' function
523 gets called whenever the program exits. However, suppose the
524 program exits, and *then* the executable file changes? We need
525 to check again here. Since reopen_exec_file doesn't do anything
526 if the timestamp hasn't changed, I don't see the harm. */
527 reopen_exec_file ();
528 reread_symbols ();
529
530 /* Insert the temporary breakpoint if a location was specified. */
531 if (tbreak_at_main)
532 tbreak_command (main_name (), 0);
533
534 exec_file = (char *) get_exec_file (0);
535
536 if (non_stop && !target_supports_non_stop ())
537 error (_("The target does not support running in non-stop mode."));
538
539 /* We keep symbols from add-symbol-file, on the grounds that the
540 user might want to add some symbols before running the program
541 (right?). But sometimes (dynamic loading where the user manually
542 introduces the new symbols with add-symbol-file), the code which
543 the symbols describe does not persist between runs. Currently
544 the user has to manually nuke all symbols between runs if they
545 want them to go away (PR 2207). This is probably reasonable. */
546
547 if (!args)
548 {
549 if (target_can_async_p ())
550 async_disable_stdin ();
551 }
552 else
553 {
554 int async_exec = strip_bg_char (&args);
555
556 /* If we get a request for running in the bg but the target
557 doesn't support it, error out. */
558 if (async_exec && !target_can_async_p ())
559 error (_("Asynchronous execution not supported on this target."));
560
561 /* If we don't get a request of running in the bg, then we need
562 to simulate synchronous (fg) execution. */
563 if (!async_exec && target_can_async_p ())
564 {
565 /* Simulate synchronous execution. */
566 async_disable_stdin ();
567 }
568
569 /* If there were other args, beside '&', process them. */
570 if (args)
571 set_inferior_args (args);
572 }
573
574 if (from_tty)
575 {
576 ui_out_field_string (uiout, NULL, "Starting program");
577 ui_out_text (uiout, ": ");
578 if (exec_file)
579 ui_out_field_string (uiout, "execfile", exec_file);
580 ui_out_spaces (uiout, 1);
581 /* We call get_inferior_args() because we might need to compute
582 the value now. */
583 ui_out_field_string (uiout, "infargs", get_inferior_args ());
584 ui_out_text (uiout, "\n");
585 ui_out_flush (uiout);
586 }
587
588 /* We call get_inferior_args() because we might need to compute
589 the value now. */
590 target_create_inferior (exec_file, get_inferior_args (),
591 environ_vector (current_inferior ()->environment),
592 from_tty);
593
594 /* We're starting off a new process. When we get out of here, in
595 non-stop mode, finish the state of all threads of that process,
596 but leave other threads alone, as they may be stopped in internal
597 events --- the frontend shouldn't see them as stopped. In
598 all-stop, always finish the state of all threads, as we may be
599 resuming more than just the new process. */
600 if (non_stop)
601 ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
602 else
603 ptid = minus_one_ptid;
604 old_chain = make_cleanup (finish_thread_state_cleanup, &ptid);
605
606 /* Pass zero for FROM_TTY, because at this point the "run" command
607 has done its thing; now we are setting up the running program. */
608 post_create_inferior (&current_target, 0);
609
610 /* Start the target running. Do not use -1 continuation as it would skip
611 breakpoint right at the entry point. */
612 proceed (regcache_read_pc (get_current_regcache ()), TARGET_SIGNAL_0, 0);
613
614 /* Since there was no error, there's no need to finish the thread
615 states here. */
616 discard_cleanups (old_chain);
617 }
618
619 static void
620 run_command (char *args, int from_tty)
621 {
622 run_command_1 (args, from_tty, 0);
623 }
624
625 static void
626 run_no_args_command (char *args, int from_tty)
627 {
628 set_inferior_args ("");
629 }
630 \f
631
632 /* Start the execution of the program up until the beginning of the main
633 program. */
634
635 static void
636 start_command (char *args, int from_tty)
637 {
638 /* Some languages such as Ada need to search inside the program
639 minimal symbols for the location where to put the temporary
640 breakpoint before starting. */
641 if (!have_minimal_symbols ())
642 error (_("No symbol table loaded. Use the \"file\" command."));
643
644 /* Run the program until reaching the main procedure... */
645 run_command_1 (args, from_tty, 1);
646 }
647
648 static int
649 proceed_thread_callback (struct thread_info *thread, void *arg)
650 {
651 /* We go through all threads individually instead of compressing
652 into a single target `resume_all' request, because some threads
653 may be stopped in internal breakpoints/events, or stopped waiting
654 for its turn in the displaced stepping queue (that is, they are
655 running && !executing). The target side has no idea about why
656 the thread is stopped, so a `resume_all' command would resume too
657 much. If/when GDB gains a way to tell the target `hold this
658 thread stopped until I say otherwise', then we can optimize
659 this. */
660 if (!is_stopped (thread->ptid))
661 return 0;
662
663 switch_to_thread (thread->ptid);
664 clear_proceed_status ();
665 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
666 return 0;
667 }
668
669 void
670 ensure_valid_thread (void)
671 {
672 if (ptid_equal (inferior_ptid, null_ptid)
673 || is_exited (inferior_ptid))
674 error (_("Cannot execute this command without a live selected thread."));
675 }
676
677 /* If the user is looking at trace frames, any resumption of execution
678 is likely to mix up recorded and live target data. So simply
679 disallow those commands. */
680
681 void
682 ensure_not_tfind_mode (void)
683 {
684 if (get_traceframe_number () >= 0)
685 error (_("Cannot execute this command while looking at trace frames."));
686 }
687
688 void
689 continue_1 (int all_threads)
690 {
691 ERROR_NO_INFERIOR;
692 ensure_not_tfind_mode ();
693
694 if (non_stop && all_threads)
695 {
696 /* Don't error out if the current thread is running, because
697 there may be other stopped threads. */
698 struct cleanup *old_chain;
699
700 /* Backup current thread and selected frame. */
701 old_chain = make_cleanup_restore_current_thread ();
702
703 iterate_over_threads (proceed_thread_callback, NULL);
704
705 /* Restore selected ptid. */
706 do_cleanups (old_chain);
707 }
708 else
709 {
710 ensure_valid_thread ();
711 ensure_not_running ();
712 clear_proceed_status ();
713 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
714 }
715 }
716
717 /* continue [-a] [proceed-count] [&] */
718 void
719 continue_command (char *args, int from_tty)
720 {
721 int async_exec = 0;
722 int all_threads = 0;
723 ERROR_NO_INFERIOR;
724
725 /* Find out whether we must run in the background. */
726 if (args != NULL)
727 async_exec = strip_bg_char (&args);
728
729 /* If we must run in the background, but the target can't do it,
730 error out. */
731 if (async_exec && !target_can_async_p ())
732 error (_("Asynchronous execution not supported on this target."));
733
734 /* If we are not asked to run in the bg, then prepare to run in the
735 foreground, synchronously. */
736 if (!async_exec && target_can_async_p ())
737 {
738 /* Simulate synchronous execution. */
739 async_disable_stdin ();
740 }
741
742 if (args != NULL)
743 {
744 if (strncmp (args, "-a", sizeof ("-a") - 1) == 0)
745 {
746 all_threads = 1;
747 args += sizeof ("-a") - 1;
748 if (*args == '\0')
749 args = NULL;
750 }
751 }
752
753 if (!non_stop && all_threads)
754 error (_("`-a' is meaningless in all-stop mode."));
755
756 if (args != NULL && all_threads)
757 error (_("Can't resume all threads and specify "
758 "proceed count simultaneously."));
759
760 /* If we have an argument left, set proceed count of breakpoint we
761 stopped at. */
762 if (args != NULL)
763 {
764 bpstat bs = NULL;
765 int num, stat;
766 int stopped = 0;
767 struct thread_info *tp;
768
769 if (non_stop)
770 tp = find_thread_ptid (inferior_ptid);
771 else
772 {
773 ptid_t last_ptid;
774 struct target_waitstatus ws;
775
776 get_last_target_status (&last_ptid, &ws);
777 tp = find_thread_ptid (last_ptid);
778 }
779 if (tp != NULL)
780 bs = tp->control.stop_bpstat;
781
782 while ((stat = bpstat_num (&bs, &num)) != 0)
783 if (stat > 0)
784 {
785 set_ignore_count (num,
786 parse_and_eval_long (args) - 1,
787 from_tty);
788 /* set_ignore_count prints a message ending with a period.
789 So print two spaces before "Continuing.". */
790 if (from_tty)
791 printf_filtered (" ");
792 stopped = 1;
793 }
794
795 if (!stopped && from_tty)
796 {
797 printf_filtered
798 ("Not stopped at any breakpoint; argument ignored.\n");
799 }
800 }
801
802 if (from_tty)
803 printf_filtered (_("Continuing.\n"));
804
805 continue_1 (all_threads);
806 }
807 \f
808 /* Record the starting point of a "step" or "next" command. */
809
810 static void
811 set_step_frame (void)
812 {
813 struct symtab_and_line sal;
814
815 find_frame_sal (get_current_frame (), &sal);
816 set_step_info (get_current_frame (), sal);
817 }
818
819 /* Step until outside of current statement. */
820
821 static void
822 step_command (char *count_string, int from_tty)
823 {
824 step_1 (0, 0, count_string);
825 }
826
827 /* Likewise, but skip over subroutine calls as if single instructions. */
828
829 static void
830 next_command (char *count_string, int from_tty)
831 {
832 step_1 (1, 0, count_string);
833 }
834
835 /* Likewise, but step only one instruction. */
836
837 void
838 stepi_command (char *count_string, int from_tty)
839 {
840 step_1 (0, 1, count_string);
841 }
842
843 void
844 nexti_command (char *count_string, int from_tty)
845 {
846 step_1 (1, 1, count_string);
847 }
848
849 void
850 delete_longjmp_breakpoint_cleanup (void *arg)
851 {
852 int thread = * (int *) arg;
853 delete_longjmp_breakpoint (thread);
854 }
855
856 static void
857 step_1 (int skip_subroutines, int single_inst, char *count_string)
858 {
859 int count = 1;
860 struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
861 int async_exec = 0;
862 int thread = -1;
863
864 ERROR_NO_INFERIOR;
865 ensure_not_tfind_mode ();
866 ensure_valid_thread ();
867 ensure_not_running ();
868
869 if (count_string)
870 async_exec = strip_bg_char (&count_string);
871
872 /* If we get a request for running in the bg but the target
873 doesn't support it, error out. */
874 if (async_exec && !target_can_async_p ())
875 error (_("Asynchronous execution not supported on this target."));
876
877 /* If we don't get a request of running in the bg, then we need
878 to simulate synchronous (fg) execution. */
879 if (!async_exec && target_can_async_p ())
880 {
881 /* Simulate synchronous execution. */
882 async_disable_stdin ();
883 }
884
885 count = count_string ? parse_and_eval_long (count_string) : 1;
886
887 if (!single_inst || skip_subroutines) /* Leave si command alone. */
888 {
889 struct thread_info *tp = inferior_thread ();
890
891 if (in_thread_list (inferior_ptid))
892 thread = pid_to_thread_id (inferior_ptid);
893
894 set_longjmp_breakpoint (tp, get_frame_id (get_current_frame ()));
895
896 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
897 }
898
899 /* In synchronous case, all is well; each step_once call will step once. */
900 if (!target_can_async_p ())
901 {
902 for (; count > 0; count--)
903 {
904 step_once (skip_subroutines, single_inst, count, thread);
905
906 if (!target_has_execution)
907 break;
908 else
909 {
910 struct thread_info *tp = inferior_thread ();
911
912 if (!tp->control.stop_step || !tp->step_multi)
913 {
914 /* If we stopped for some reason that is not stepping
915 there are no further steps to make. */
916 tp->step_multi = 0;
917 break;
918 }
919 }
920 }
921
922 do_cleanups (cleanups);
923 }
924 else
925 {
926 /* In the case of an asynchronous target things get complicated;
927 do only one step for now, before returning control to the
928 event loop. Let the continuation figure out how many other
929 steps we need to do, and handle them one at the time, through
930 step_once. */
931 step_once (skip_subroutines, single_inst, count, thread);
932
933 /* We are running, and the continuation is installed. It will
934 disable the longjmp breakpoint as appropriate. */
935 discard_cleanups (cleanups);
936 }
937 }
938
939 struct step_1_continuation_args
940 {
941 int count;
942 int skip_subroutines;
943 int single_inst;
944 int thread;
945 };
946
947 /* Called after we are done with one step operation, to check whether
948 we need to step again, before we print the prompt and return control
949 to the user. If count is > 1, we will need to do one more call to
950 proceed(), via step_once(). Basically it is like step_once and
951 step_1_continuation are co-recursive. */
952 static void
953 step_1_continuation (void *args, int err)
954 {
955 struct step_1_continuation_args *a = args;
956
957 if (target_has_execution)
958 {
959 struct thread_info *tp;
960
961 tp = inferior_thread ();
962 if (!err
963 && tp->step_multi && tp->control.stop_step)
964 {
965 /* There are more steps to make, and we did stop due to
966 ending a stepping range. Do another step. */
967 step_once (a->skip_subroutines, a->single_inst,
968 a->count - 1, a->thread);
969 return;
970 }
971 tp->step_multi = 0;
972 }
973
974 /* We either hit an error, or stopped for some reason that is
975 not stepping, or there are no further steps to make.
976 Cleanup. */
977 if (!a->single_inst || a->skip_subroutines)
978 delete_longjmp_breakpoint (a->thread);
979 }
980
981 /* Do just one step operation. This is useful to implement the 'step
982 n' kind of commands. In case of asynchronous targets, we will have
983 to set up a continuation to be done after the target stops (after
984 this one step). For synch targets, the caller handles further
985 stepping. */
986
987 static void
988 step_once (int skip_subroutines, int single_inst, int count, int thread)
989 {
990 struct frame_info *frame = get_current_frame ();
991
992 if (count > 0)
993 {
994 /* Don't assume THREAD is a valid thread id. It is set to -1 if
995 the longjmp breakpoint was not required. Use the
996 INFERIOR_PTID thread instead, which is the same thread when
997 THREAD is set. */
998 struct thread_info *tp = inferior_thread ();
999
1000 clear_proceed_status ();
1001 set_step_frame ();
1002
1003 if (!single_inst)
1004 {
1005 CORE_ADDR pc;
1006
1007 /* Step at an inlined function behaves like "down". */
1008 if (!skip_subroutines && !single_inst
1009 && inline_skipped_frames (inferior_ptid))
1010 {
1011 ptid_t resume_ptid;
1012
1013 /* Pretend that we've ran. */
1014 resume_ptid = user_visible_resume_ptid (1);
1015 set_running (resume_ptid, 1);
1016
1017 step_into_inline_frame (inferior_ptid);
1018 if (count > 1)
1019 step_once (skip_subroutines, single_inst, count - 1, thread);
1020 else
1021 {
1022 /* Pretend that we've stopped. */
1023 normal_stop ();
1024
1025 if (target_can_async_p ())
1026 inferior_event_handler (INF_EXEC_COMPLETE, NULL);
1027 }
1028 return;
1029 }
1030
1031 pc = get_frame_pc (frame);
1032 find_pc_line_pc_range (pc,
1033 &tp->control.step_range_start,
1034 &tp->control.step_range_end);
1035
1036 /* If we have no line info, switch to stepi mode. */
1037 if (tp->control.step_range_end == 0 && step_stop_if_no_debug)
1038 tp->control.step_range_start = tp->control.step_range_end = 1;
1039 else if (tp->control.step_range_end == 0)
1040 {
1041 char *name;
1042
1043 if (find_pc_partial_function (pc, &name,
1044 &tp->control.step_range_start,
1045 &tp->control.step_range_end) == 0)
1046 error (_("Cannot find bounds of current function"));
1047
1048 target_terminal_ours ();
1049 printf_filtered (_("Single stepping until exit from function %s,"
1050 "\nwhich has no line number information.\n"),
1051 name);
1052 }
1053 }
1054 else
1055 {
1056 /* Say we are stepping, but stop after one insn whatever it does. */
1057 tp->control.step_range_start = tp->control.step_range_end = 1;
1058 if (!skip_subroutines)
1059 /* It is stepi.
1060 Don't step over function calls, not even to functions lacking
1061 line numbers. */
1062 tp->control.step_over_calls = STEP_OVER_NONE;
1063 }
1064
1065 if (skip_subroutines)
1066 tp->control.step_over_calls = STEP_OVER_ALL;
1067
1068 tp->step_multi = (count > 1);
1069 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1070
1071 /* For async targets, register a continuation to do any
1072 additional steps. For sync targets, the caller will handle
1073 further stepping. */
1074 if (target_can_async_p ())
1075 {
1076 struct step_1_continuation_args *args;
1077
1078 args = xmalloc (sizeof (*args));
1079 args->skip_subroutines = skip_subroutines;
1080 args->single_inst = single_inst;
1081 args->count = count;
1082 args->thread = thread;
1083
1084 add_intermediate_continuation (tp, step_1_continuation, args, xfree);
1085 }
1086 }
1087 }
1088
1089 \f
1090 /* Continue program at specified address. */
1091
1092 static void
1093 jump_command (char *arg, int from_tty)
1094 {
1095 struct gdbarch *gdbarch = get_current_arch ();
1096 CORE_ADDR addr;
1097 struct symtabs_and_lines sals;
1098 struct symtab_and_line sal;
1099 struct symbol *fn;
1100 struct symbol *sfn;
1101 int async_exec = 0;
1102
1103 ERROR_NO_INFERIOR;
1104 ensure_not_tfind_mode ();
1105 ensure_valid_thread ();
1106 ensure_not_running ();
1107
1108 /* Find out whether we must run in the background. */
1109 if (arg != NULL)
1110 async_exec = strip_bg_char (&arg);
1111
1112 /* If we must run in the background, but the target can't do it,
1113 error out. */
1114 if (async_exec && !target_can_async_p ())
1115 error (_("Asynchronous execution not supported on this target."));
1116
1117 if (!arg)
1118 error_no_arg (_("starting address"));
1119
1120 sals = decode_line_spec_1 (arg, DECODE_LINE_FUNFIRSTLINE);
1121 if (sals.nelts != 1)
1122 {
1123 error (_("Unreasonable jump request"));
1124 }
1125
1126 sal = sals.sals[0];
1127 xfree (sals.sals);
1128
1129 if (sal.symtab == 0 && sal.pc == 0)
1130 error (_("No source file has been specified."));
1131
1132 resolve_sal_pc (&sal); /* May error out. */
1133
1134 /* See if we are trying to jump to another function. */
1135 fn = get_frame_function (get_current_frame ());
1136 sfn = find_pc_function (sal.pc);
1137 if (fn != NULL && sfn != fn)
1138 {
1139 if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line,
1140 SYMBOL_PRINT_NAME (fn)))
1141 {
1142 error (_("Not confirmed."));
1143 /* NOTREACHED */
1144 }
1145 }
1146
1147 if (sfn != NULL)
1148 {
1149 fixup_symbol_section (sfn, 0);
1150 if (section_is_overlay (SYMBOL_OBJ_SECTION (sfn)) &&
1151 !section_is_mapped (SYMBOL_OBJ_SECTION (sfn)))
1152 {
1153 if (!query (_("WARNING!!! Destination is in "
1154 "unmapped overlay! Jump anyway? ")))
1155 {
1156 error (_("Not confirmed."));
1157 /* NOTREACHED */
1158 }
1159 }
1160 }
1161
1162 addr = sal.pc;
1163
1164 if (from_tty)
1165 {
1166 printf_filtered (_("Continuing at "));
1167 fputs_filtered (paddress (gdbarch, addr), gdb_stdout);
1168 printf_filtered (".\n");
1169 }
1170
1171 /* If we are not asked to run in the bg, then prepare to run in the
1172 foreground, synchronously. */
1173 if (!async_exec && target_can_async_p ())
1174 {
1175 /* Simulate synchronous execution. */
1176 async_disable_stdin ();
1177 }
1178
1179 clear_proceed_status ();
1180 proceed (addr, TARGET_SIGNAL_0, 0);
1181 }
1182 \f
1183
1184 /* Go to line or address in current procedure. */
1185 static void
1186 go_command (char *line_no, int from_tty)
1187 {
1188 if (line_no == (char *) NULL || !*line_no)
1189 printf_filtered (_("Usage: go <location>\n"));
1190 else
1191 {
1192 tbreak_command (line_no, from_tty);
1193 jump_command (line_no, from_tty);
1194 }
1195 }
1196 \f
1197
1198 /* Continue program giving it specified signal. */
1199
1200 static void
1201 signal_command (char *signum_exp, int from_tty)
1202 {
1203 enum target_signal oursig;
1204 int async_exec = 0;
1205
1206 dont_repeat (); /* Too dangerous. */
1207 ERROR_NO_INFERIOR;
1208 ensure_not_tfind_mode ();
1209 ensure_valid_thread ();
1210 ensure_not_running ();
1211
1212 /* Find out whether we must run in the background. */
1213 if (signum_exp != NULL)
1214 async_exec = strip_bg_char (&signum_exp);
1215
1216 /* If we must run in the background, but the target can't do it,
1217 error out. */
1218 if (async_exec && !target_can_async_p ())
1219 error (_("Asynchronous execution not supported on this target."));
1220
1221 /* If we are not asked to run in the bg, then prepare to run in the
1222 foreground, synchronously. */
1223 if (!async_exec && target_can_async_p ())
1224 {
1225 /* Simulate synchronous execution. */
1226 async_disable_stdin ();
1227 }
1228
1229 if (!signum_exp)
1230 error_no_arg (_("signal number"));
1231
1232 /* It would be even slicker to make signal names be valid expressions,
1233 (the type could be "enum $signal" or some such), then the user could
1234 assign them to convenience variables. */
1235 oursig = target_signal_from_name (signum_exp);
1236
1237 if (oursig == TARGET_SIGNAL_UNKNOWN)
1238 {
1239 /* No, try numeric. */
1240 int num = parse_and_eval_long (signum_exp);
1241
1242 if (num == 0)
1243 oursig = TARGET_SIGNAL_0;
1244 else
1245 oursig = target_signal_from_command (num);
1246 }
1247
1248 if (from_tty)
1249 {
1250 if (oursig == TARGET_SIGNAL_0)
1251 printf_filtered (_("Continuing with no signal.\n"));
1252 else
1253 printf_filtered (_("Continuing with signal %s.\n"),
1254 target_signal_to_name (oursig));
1255 }
1256
1257 clear_proceed_status ();
1258 proceed ((CORE_ADDR) -1, oursig, 0);
1259 }
1260
1261 /* Continuation args to be passed to the "until" command
1262 continuation. */
1263 struct until_next_continuation_args
1264 {
1265 /* The thread that was current when the command was executed. */
1266 int thread;
1267 };
1268
1269 /* A continuation callback for until_next_command. */
1270
1271 static void
1272 until_next_continuation (void *arg, int err)
1273 {
1274 struct until_next_continuation_args *a = arg;
1275
1276 delete_longjmp_breakpoint (a->thread);
1277 }
1278
1279 /* Proceed until we reach a different source line with pc greater than
1280 our current one or exit the function. We skip calls in both cases.
1281
1282 Note that eventually this command should probably be changed so
1283 that only source lines are printed out when we hit the breakpoint
1284 we set. This may involve changes to wait_for_inferior and the
1285 proceed status code. */
1286
1287 static void
1288 until_next_command (int from_tty)
1289 {
1290 struct frame_info *frame;
1291 CORE_ADDR pc;
1292 struct symbol *func;
1293 struct symtab_and_line sal;
1294 struct thread_info *tp = inferior_thread ();
1295 int thread = tp->num;
1296 struct cleanup *old_chain;
1297
1298 clear_proceed_status ();
1299 set_step_frame ();
1300
1301 frame = get_current_frame ();
1302
1303 /* Step until either exited from this function or greater
1304 than the current line (if in symbolic section) or pc (if
1305 not). */
1306
1307 pc = get_frame_pc (frame);
1308 func = find_pc_function (pc);
1309
1310 if (!func)
1311 {
1312 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1313
1314 if (msymbol == NULL)
1315 error (_("Execution is not within a known function."));
1316
1317 tp->control.step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1318 tp->control.step_range_end = pc;
1319 }
1320 else
1321 {
1322 sal = find_pc_line (pc, 0);
1323
1324 tp->control.step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1325 tp->control.step_range_end = sal.end;
1326 }
1327
1328 tp->control.step_over_calls = STEP_OVER_ALL;
1329
1330 tp->step_multi = 0; /* Only one call to proceed */
1331
1332 set_longjmp_breakpoint (tp, get_frame_id (frame));
1333 old_chain = make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
1334
1335 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1336
1337 if (target_can_async_p () && is_running (inferior_ptid))
1338 {
1339 struct until_next_continuation_args *cont_args;
1340
1341 discard_cleanups (old_chain);
1342 cont_args = XNEW (struct until_next_continuation_args);
1343 cont_args->thread = inferior_thread ()->num;
1344
1345 add_continuation (tp, until_next_continuation, cont_args, xfree);
1346 }
1347 else
1348 do_cleanups (old_chain);
1349 }
1350
1351 static void
1352 until_command (char *arg, int from_tty)
1353 {
1354 int async_exec = 0;
1355
1356 ERROR_NO_INFERIOR;
1357 ensure_not_tfind_mode ();
1358 ensure_valid_thread ();
1359 ensure_not_running ();
1360
1361 /* Find out whether we must run in the background. */
1362 if (arg != NULL)
1363 async_exec = strip_bg_char (&arg);
1364
1365 /* If we must run in the background, but the target can't do it,
1366 error out. */
1367 if (async_exec && !target_can_async_p ())
1368 error (_("Asynchronous execution not supported on this target."));
1369
1370 /* If we are not asked to run in the bg, then prepare to run in the
1371 foreground, synchronously. */
1372 if (!async_exec && target_can_async_p ())
1373 {
1374 /* Simulate synchronous execution. */
1375 async_disable_stdin ();
1376 }
1377
1378 if (arg)
1379 until_break_command (arg, from_tty, 0);
1380 else
1381 until_next_command (from_tty);
1382 }
1383
1384 static void
1385 advance_command (char *arg, int from_tty)
1386 {
1387 int async_exec = 0;
1388
1389 ERROR_NO_INFERIOR;
1390 ensure_not_tfind_mode ();
1391 ensure_valid_thread ();
1392 ensure_not_running ();
1393
1394 if (arg == NULL)
1395 error_no_arg (_("a location"));
1396
1397 /* Find out whether we must run in the background. */
1398 if (arg != NULL)
1399 async_exec = strip_bg_char (&arg);
1400
1401 /* If we must run in the background, but the target can't do it,
1402 error out. */
1403 if (async_exec && !target_can_async_p ())
1404 error (_("Asynchronous execution not supported on this target."));
1405
1406 /* If we are not asked to run in the bg, then prepare to run in the
1407 foreground, synchronously. */
1408 if (!async_exec && target_can_async_p ())
1409 {
1410 /* Simulate synchronous execution. */
1411 async_disable_stdin ();
1412 }
1413
1414 until_break_command (arg, from_tty, 1);
1415 }
1416 \f
1417 /* Print the result of a function at the end of a 'finish' command. */
1418
1419 static void
1420 print_return_value (struct type *func_type, struct type *value_type)
1421 {
1422 struct gdbarch *gdbarch = get_regcache_arch (stop_registers);
1423 struct cleanup *old_chain;
1424 struct ui_stream *stb;
1425 struct value *value;
1426 struct ui_out *uiout = current_uiout;
1427
1428 CHECK_TYPEDEF (value_type);
1429 gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
1430
1431 /* FIXME: 2003-09-27: When returning from a nested inferior function
1432 call, it's possible (with no help from the architecture vector)
1433 to locate and return/print a "struct return" value. This is just
1434 a more complicated case of what is already being done in the
1435 inferior function call code. In fact, when inferior function
1436 calls are made async, this will likely be made the norm. */
1437
1438 switch (gdbarch_return_value (gdbarch, func_type, value_type,
1439 NULL, NULL, NULL))
1440 {
1441 case RETURN_VALUE_REGISTER_CONVENTION:
1442 case RETURN_VALUE_ABI_RETURNS_ADDRESS:
1443 case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
1444 value = allocate_value (value_type);
1445 gdbarch_return_value (gdbarch, func_type, value_type, stop_registers,
1446 value_contents_raw (value), NULL);
1447 break;
1448 case RETURN_VALUE_STRUCT_CONVENTION:
1449 value = NULL;
1450 break;
1451 default:
1452 internal_error (__FILE__, __LINE__, _("bad switch"));
1453 }
1454
1455 if (value)
1456 {
1457 struct value_print_options opts;
1458
1459 /* Print it. */
1460 stb = ui_out_stream_new (uiout);
1461 old_chain = make_cleanup_ui_out_stream_delete (stb);
1462 ui_out_text (uiout, "Value returned is ");
1463 ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
1464 record_latest_value (value));
1465 ui_out_text (uiout, " = ");
1466 get_raw_print_options (&opts);
1467 value_print (value, stb->stream, &opts);
1468 ui_out_field_stream (uiout, "return-value", stb);
1469 ui_out_text (uiout, "\n");
1470 do_cleanups (old_chain);
1471 }
1472 else
1473 {
1474 ui_out_text (uiout, "Value returned has type: ");
1475 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1476 ui_out_text (uiout, ".");
1477 ui_out_text (uiout, " Cannot determine contents\n");
1478 }
1479 }
1480
1481 /* Stuff that needs to be done by the finish command after the target
1482 has stopped. In asynchronous mode, we wait for the target to stop
1483 in the call to poll or select in the event loop, so it is
1484 impossible to do all the stuff as part of the finish_command
1485 function itself. The only chance we have to complete this command
1486 is in fetch_inferior_event, which is called by the event loop as
1487 soon as it detects that the target has stopped. */
1488
1489 struct finish_command_continuation_args
1490 {
1491 /* The thread that as current when the command was executed. */
1492 int thread;
1493 struct breakpoint *breakpoint;
1494 struct symbol *function;
1495 };
1496
1497 static void
1498 finish_command_continuation (void *arg, int err)
1499 {
1500 struct finish_command_continuation_args *a = arg;
1501
1502 if (!err)
1503 {
1504 struct thread_info *tp = NULL;
1505 bpstat bs = NULL;
1506
1507 if (!ptid_equal (inferior_ptid, null_ptid)
1508 && target_has_execution
1509 && is_stopped (inferior_ptid))
1510 {
1511 tp = inferior_thread ();
1512 bs = tp->control.stop_bpstat;
1513 }
1514
1515 if (bpstat_find_breakpoint (bs, a->breakpoint) != NULL
1516 && a->function != NULL)
1517 {
1518 struct type *value_type;
1519
1520 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (a->function));
1521 if (!value_type)
1522 internal_error (__FILE__, __LINE__,
1523 _("finish_command: function has no target type"));
1524
1525 if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
1526 {
1527 volatile struct gdb_exception ex;
1528
1529 TRY_CATCH (ex, RETURN_MASK_ALL)
1530 {
1531 /* print_return_value can throw an exception in some
1532 circumstances. We need to catch this so that we still
1533 delete the breakpoint. */
1534 print_return_value (SYMBOL_TYPE (a->function), value_type);
1535 }
1536 if (ex.reason < 0)
1537 exception_print (gdb_stdout, ex);
1538 }
1539 }
1540
1541 /* We suppress normal call of normal_stop observer and do it
1542 here so that the *stopped notification includes the return
1543 value. */
1544 if (bs != NULL && tp->control.proceed_to_finish)
1545 observer_notify_normal_stop (bs, 1 /* print frame */);
1546 }
1547
1548 delete_breakpoint (a->breakpoint);
1549 delete_longjmp_breakpoint (a->thread);
1550 }
1551
1552 static void
1553 finish_command_continuation_free_arg (void *arg)
1554 {
1555 xfree (arg);
1556 }
1557
1558 /* finish_backward -- helper function for finish_command. */
1559
1560 static void
1561 finish_backward (struct symbol *function)
1562 {
1563 struct symtab_and_line sal;
1564 struct thread_info *tp = inferior_thread ();
1565 CORE_ADDR pc;
1566 CORE_ADDR func_addr;
1567
1568 pc = get_frame_pc (get_current_frame ());
1569
1570 if (find_pc_partial_function (pc, NULL, &func_addr, NULL) == 0)
1571 internal_error (__FILE__, __LINE__,
1572 _("Finish: couldn't find function."));
1573
1574 sal = find_pc_line (func_addr, 0);
1575
1576 tp->control.proceed_to_finish = 1;
1577 /* Special case: if we're sitting at the function entry point,
1578 then all we need to do is take a reverse singlestep. We
1579 don't need to set a breakpoint, and indeed it would do us
1580 no good to do so.
1581
1582 Note that this can only happen at frame #0, since there's
1583 no way that a function up the stack can have a return address
1584 that's equal to its entry point. */
1585
1586 if (sal.pc != pc)
1587 {
1588 struct frame_info *frame = get_selected_frame (NULL);
1589 struct gdbarch *gdbarch = get_frame_arch (frame);
1590 struct symtab_and_line sr_sal;
1591
1592 /* Set a step-resume at the function's entry point. Once that's
1593 hit, we'll do one more step backwards. */
1594 init_sal (&sr_sal);
1595 sr_sal.pc = sal.pc;
1596 sr_sal.pspace = get_frame_program_space (frame);
1597 insert_step_resume_breakpoint_at_sal (gdbarch,
1598 sr_sal, null_frame_id);
1599
1600 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1601 }
1602 else
1603 {
1604 /* We're almost there -- we just need to back up by one more
1605 single-step. */
1606 tp->control.step_range_start = tp->control.step_range_end = 1;
1607 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1608 }
1609 }
1610
1611 /* finish_forward -- helper function for finish_command. */
1612
1613 static void
1614 finish_forward (struct symbol *function, struct frame_info *frame)
1615 {
1616 struct gdbarch *gdbarch = get_frame_arch (frame);
1617 struct symtab_and_line sal;
1618 struct thread_info *tp = inferior_thread ();
1619 struct breakpoint *breakpoint;
1620 struct cleanup *old_chain;
1621 struct finish_command_continuation_args *cargs;
1622 int thread = tp->num;
1623
1624 sal = find_pc_line (get_frame_pc (frame), 0);
1625 sal.pc = get_frame_pc (frame);
1626
1627 breakpoint = set_momentary_breakpoint (gdbarch, sal,
1628 get_stack_frame_id (frame),
1629 bp_finish);
1630
1631 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1632
1633 set_longjmp_breakpoint (tp, get_frame_id (frame));
1634 make_cleanup (delete_longjmp_breakpoint_cleanup, &thread);
1635
1636 /* We want stop_registers, please... */
1637 tp->control.proceed_to_finish = 1;
1638 cargs = xmalloc (sizeof (*cargs));
1639
1640 cargs->thread = thread;
1641 cargs->breakpoint = breakpoint;
1642 cargs->function = function;
1643 add_continuation (tp, finish_command_continuation, cargs,
1644 finish_command_continuation_free_arg);
1645 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1646
1647 discard_cleanups (old_chain);
1648 if (!target_can_async_p ())
1649 do_all_continuations (0);
1650 }
1651
1652 /* "finish": Set a temporary breakpoint at the place the selected
1653 frame will return to, then continue. */
1654
1655 static void
1656 finish_command (char *arg, int from_tty)
1657 {
1658 struct frame_info *frame;
1659 struct symbol *function;
1660
1661 int async_exec = 0;
1662
1663 ERROR_NO_INFERIOR;
1664 ensure_not_tfind_mode ();
1665 ensure_valid_thread ();
1666 ensure_not_running ();
1667
1668 /* Find out whether we must run in the background. */
1669 if (arg != NULL)
1670 async_exec = strip_bg_char (&arg);
1671
1672 /* If we must run in the background, but the target can't do it,
1673 error out. */
1674 if (async_exec && !target_can_async_p ())
1675 error (_("Asynchronous execution not supported on this target."));
1676
1677 /* If we are not asked to run in the bg, then prepare to run in the
1678 foreground, synchronously. */
1679 if (!async_exec && target_can_async_p ())
1680 {
1681 /* Simulate synchronous execution. */
1682 async_disable_stdin ();
1683 }
1684
1685 if (arg)
1686 error (_("The \"finish\" command does not take any arguments."));
1687
1688 frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
1689 if (frame == 0)
1690 error (_("\"finish\" not meaningful in the outermost frame."));
1691
1692 clear_proceed_status ();
1693
1694 /* Finishing from an inline frame is completely different. We don't
1695 try to show the "return value" - no way to locate it. So we do
1696 not need a completion. */
1697 if (get_frame_type (get_selected_frame (_("No selected frame.")))
1698 == INLINE_FRAME)
1699 {
1700 /* Claim we are stepping in the calling frame. An empty step
1701 range means that we will stop once we aren't in a function
1702 called by that frame. We don't use the magic "1" value for
1703 step_range_end, because then infrun will think this is nexti,
1704 and not step over the rest of this inlined function call. */
1705 struct thread_info *tp = inferior_thread ();
1706 struct symtab_and_line empty_sal;
1707
1708 init_sal (&empty_sal);
1709 set_step_info (frame, empty_sal);
1710 tp->control.step_range_start = get_frame_pc (frame);
1711 tp->control.step_range_end = tp->control.step_range_start;
1712 tp->control.step_over_calls = STEP_OVER_ALL;
1713
1714 /* Print info on the selected frame, including level number but not
1715 source. */
1716 if (from_tty)
1717 {
1718 printf_filtered (_("Run till exit from "));
1719 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1720 }
1721
1722 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1723 return;
1724 }
1725
1726 /* Find the function we will return from. */
1727
1728 function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
1729
1730 /* Print info on the selected frame, including level number but not
1731 source. */
1732 if (from_tty)
1733 {
1734 if (execution_direction == EXEC_REVERSE)
1735 printf_filtered (_("Run back to call of "));
1736 else
1737 printf_filtered (_("Run till exit from "));
1738
1739 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1740 }
1741
1742 if (execution_direction == EXEC_REVERSE)
1743 finish_backward (function);
1744 else
1745 finish_forward (function, frame);
1746 }
1747 \f
1748
1749 static void
1750 program_info (char *args, int from_tty)
1751 {
1752 bpstat bs;
1753 int num, stat;
1754 struct thread_info *tp;
1755 ptid_t ptid;
1756
1757 if (!target_has_execution)
1758 {
1759 printf_filtered (_("The program being debugged is not being run.\n"));
1760 return;
1761 }
1762
1763 if (non_stop)
1764 ptid = inferior_ptid;
1765 else
1766 {
1767 struct target_waitstatus ws;
1768
1769 get_last_target_status (&ptid, &ws);
1770 }
1771
1772 if (ptid_equal (ptid, null_ptid) || is_exited (ptid))
1773 error (_("Invalid selected thread."));
1774 else if (is_running (ptid))
1775 error (_("Selected thread is running."));
1776
1777 tp = find_thread_ptid (ptid);
1778 bs = tp->control.stop_bpstat;
1779 stat = bpstat_num (&bs, &num);
1780
1781 target_files_info ();
1782 printf_filtered (_("Program stopped at %s.\n"),
1783 paddress (target_gdbarch, stop_pc));
1784 if (tp->control.stop_step)
1785 printf_filtered (_("It stopped after being stepped.\n"));
1786 else if (stat != 0)
1787 {
1788 /* There may be several breakpoints in the same place, so this
1789 isn't as strange as it seems. */
1790 while (stat != 0)
1791 {
1792 if (stat < 0)
1793 {
1794 printf_filtered (_("It stopped at a breakpoint "
1795 "that has since been deleted.\n"));
1796 }
1797 else
1798 printf_filtered (_("It stopped at breakpoint %d.\n"), num);
1799 stat = bpstat_num (&bs, &num);
1800 }
1801 }
1802 else if (tp->suspend.stop_signal != TARGET_SIGNAL_0)
1803 {
1804 printf_filtered (_("It stopped with signal %s, %s.\n"),
1805 target_signal_to_name (tp->suspend.stop_signal),
1806 target_signal_to_string (tp->suspend.stop_signal));
1807 }
1808
1809 if (!from_tty)
1810 {
1811 printf_filtered (_("Type \"info stack\" or \"info "
1812 "registers\" for more information.\n"));
1813 }
1814 }
1815 \f
1816 static void
1817 environment_info (char *var, int from_tty)
1818 {
1819 if (var)
1820 {
1821 char *val = get_in_environ (current_inferior ()->environment, var);
1822
1823 if (val)
1824 {
1825 puts_filtered (var);
1826 puts_filtered (" = ");
1827 puts_filtered (val);
1828 puts_filtered ("\n");
1829 }
1830 else
1831 {
1832 puts_filtered ("Environment variable \"");
1833 puts_filtered (var);
1834 puts_filtered ("\" not defined.\n");
1835 }
1836 }
1837 else
1838 {
1839 char **vector = environ_vector (current_inferior ()->environment);
1840
1841 while (*vector)
1842 {
1843 puts_filtered (*vector++);
1844 puts_filtered ("\n");
1845 }
1846 }
1847 }
1848
1849 static void
1850 set_environment_command (char *arg, int from_tty)
1851 {
1852 char *p, *val, *var;
1853 int nullset = 0;
1854
1855 if (arg == 0)
1856 error_no_arg (_("environment variable and value"));
1857
1858 /* Find seperation between variable name and value. */
1859 p = (char *) strchr (arg, '=');
1860 val = (char *) strchr (arg, ' ');
1861
1862 if (p != 0 && val != 0)
1863 {
1864 /* We have both a space and an equals. If the space is before the
1865 equals, walk forward over the spaces til we see a nonspace
1866 (possibly the equals). */
1867 if (p > val)
1868 while (*val == ' ')
1869 val++;
1870
1871 /* Now if the = is after the char following the spaces,
1872 take the char following the spaces. */
1873 if (p > val)
1874 p = val - 1;
1875 }
1876 else if (val != 0 && p == 0)
1877 p = val;
1878
1879 if (p == arg)
1880 error_no_arg (_("environment variable to set"));
1881
1882 if (p == 0 || p[1] == 0)
1883 {
1884 nullset = 1;
1885 if (p == 0)
1886 p = arg + strlen (arg); /* So that savestring below will work. */
1887 }
1888 else
1889 {
1890 /* Not setting variable value to null. */
1891 val = p + 1;
1892 while (*val == ' ' || *val == '\t')
1893 val++;
1894 }
1895
1896 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1897 p--;
1898
1899 var = savestring (arg, p - arg);
1900 if (nullset)
1901 {
1902 printf_filtered (_("Setting environment variable "
1903 "\"%s\" to null value.\n"),
1904 var);
1905 set_in_environ (current_inferior ()->environment, var, "");
1906 }
1907 else
1908 set_in_environ (current_inferior ()->environment, var, val);
1909 xfree (var);
1910 }
1911
1912 static void
1913 unset_environment_command (char *var, int from_tty)
1914 {
1915 if (var == 0)
1916 {
1917 /* If there is no argument, delete all environment variables.
1918 Ask for confirmation if reading from the terminal. */
1919 if (!from_tty || query (_("Delete all environment variables? ")))
1920 {
1921 free_environ (current_inferior ()->environment);
1922 current_inferior ()->environment = make_environ ();
1923 }
1924 }
1925 else
1926 unset_in_environ (current_inferior ()->environment, var);
1927 }
1928
1929 /* Handle the execution path (PATH variable). */
1930
1931 static const char path_var_name[] = "PATH";
1932
1933 static void
1934 path_info (char *args, int from_tty)
1935 {
1936 puts_filtered ("Executable and object file path: ");
1937 puts_filtered (get_in_environ (current_inferior ()->environment,
1938 path_var_name));
1939 puts_filtered ("\n");
1940 }
1941
1942 /* Add zero or more directories to the front of the execution path. */
1943
1944 static void
1945 path_command (char *dirname, int from_tty)
1946 {
1947 char *exec_path;
1948 char *env;
1949
1950 dont_repeat ();
1951 env = get_in_environ (current_inferior ()->environment, path_var_name);
1952 /* Can be null if path is not set. */
1953 if (!env)
1954 env = "";
1955 exec_path = xstrdup (env);
1956 mod_path (dirname, &exec_path);
1957 set_in_environ (current_inferior ()->environment, path_var_name, exec_path);
1958 xfree (exec_path);
1959 if (from_tty)
1960 path_info ((char *) NULL, from_tty);
1961 }
1962 \f
1963
1964 /* Print out the machine register regnum. If regnum is -1, print all
1965 registers (print_all == 1) or all non-float and non-vector
1966 registers (print_all == 0).
1967
1968 For most machines, having all_registers_info() print the
1969 register(s) one per line is good enough. If a different format is
1970 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1971 regs), or there is an existing convention for showing all the
1972 registers, define the architecture method PRINT_REGISTERS_INFO to
1973 provide that format. */
1974
1975 void
1976 default_print_registers_info (struct gdbarch *gdbarch,
1977 struct ui_file *file,
1978 struct frame_info *frame,
1979 int regnum, int print_all)
1980 {
1981 int i;
1982 const int numregs = gdbarch_num_regs (gdbarch)
1983 + gdbarch_num_pseudo_regs (gdbarch);
1984
1985 for (i = 0; i < numregs; i++)
1986 {
1987 struct type *regtype;
1988 struct value *val;
1989
1990 /* Decide between printing all regs, non-float / vector regs, or
1991 specific reg. */
1992 if (regnum == -1)
1993 {
1994 if (print_all)
1995 {
1996 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1997 continue;
1998 }
1999 else
2000 {
2001 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
2002 continue;
2003 }
2004 }
2005 else
2006 {
2007 if (i != regnum)
2008 continue;
2009 }
2010
2011 /* If the register name is empty, it is undefined for this
2012 processor, so don't display anything. */
2013 if (gdbarch_register_name (gdbarch, i) == NULL
2014 || *(gdbarch_register_name (gdbarch, i)) == '\0')
2015 continue;
2016
2017 fputs_filtered (gdbarch_register_name (gdbarch, i), file);
2018 print_spaces_filtered (15 - strlen (gdbarch_register_name
2019 (gdbarch, i)), file);
2020
2021 regtype = register_type (gdbarch, i);
2022 val = allocate_value (regtype);
2023
2024 /* Get the data in raw format. */
2025 if (! frame_register_read (frame, i, value_contents_raw (val)))
2026 {
2027 fprintf_filtered (file, "*value not available*\n");
2028 continue;
2029 }
2030
2031 /* If virtual format is floating, print it that way, and in raw
2032 hex. */
2033 if (TYPE_CODE (regtype) == TYPE_CODE_FLT
2034 || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT)
2035 {
2036 int j;
2037 struct value_print_options opts;
2038 const gdb_byte *valaddr = value_contents_for_printing (val);
2039
2040 get_user_print_options (&opts);
2041 opts.deref_ref = 1;
2042
2043 val_print (regtype,
2044 value_contents_for_printing (val),
2045 value_embedded_offset (val), 0,
2046 file, 0, val, &opts, current_language);
2047
2048 fprintf_filtered (file, "\t(raw 0x");
2049 for (j = 0; j < register_size (gdbarch, i); j++)
2050 {
2051 int idx;
2052
2053 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
2054 idx = j;
2055 else
2056 idx = register_size (gdbarch, i) - 1 - j;
2057 fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]);
2058 }
2059 fprintf_filtered (file, ")");
2060 }
2061 else
2062 {
2063 struct value_print_options opts;
2064
2065 /* Print the register in hex. */
2066 get_formatted_print_options (&opts, 'x');
2067 opts.deref_ref = 1;
2068 val_print (regtype,
2069 value_contents_for_printing (val),
2070 value_embedded_offset (val), 0,
2071 file, 0, val, &opts, current_language);
2072 /* If not a vector register, print it also according to its
2073 natural format. */
2074 if (TYPE_VECTOR (regtype) == 0)
2075 {
2076 get_user_print_options (&opts);
2077 opts.deref_ref = 1;
2078 fprintf_filtered (file, "\t");
2079 val_print (regtype,
2080 value_contents_for_printing (val),
2081 value_embedded_offset (val), 0,
2082 file, 0, val, &opts, current_language);
2083 }
2084 }
2085
2086 fprintf_filtered (file, "\n");
2087 }
2088 }
2089
2090 void
2091 registers_info (char *addr_exp, int fpregs)
2092 {
2093 struct frame_info *frame;
2094 struct gdbarch *gdbarch;
2095
2096 if (!target_has_registers)
2097 error (_("The program has no registers now."));
2098 frame = get_selected_frame (NULL);
2099 gdbarch = get_frame_arch (frame);
2100
2101 if (!addr_exp)
2102 {
2103 gdbarch_print_registers_info (gdbarch, gdb_stdout,
2104 frame, -1, fpregs);
2105 return;
2106 }
2107
2108 while (*addr_exp != '\0')
2109 {
2110 char *start;
2111 const char *end;
2112
2113 /* Keep skipping leading white space. */
2114 if (isspace ((*addr_exp)))
2115 {
2116 addr_exp++;
2117 continue;
2118 }
2119
2120 /* Discard any leading ``$''. Check that there is something
2121 resembling a register following it. */
2122 if (addr_exp[0] == '$')
2123 addr_exp++;
2124 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
2125 error (_("Missing register name"));
2126
2127 /* Find the start/end of this register name/num/group. */
2128 start = addr_exp;
2129 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
2130 addr_exp++;
2131 end = addr_exp;
2132
2133 /* Figure out what we've found and display it. */
2134
2135 /* A register name? */
2136 {
2137 int regnum = user_reg_map_name_to_regnum (gdbarch, start, end - start);
2138
2139 if (regnum >= 0)
2140 {
2141 /* User registers lie completely outside of the range of
2142 normal registers. Catch them early so that the target
2143 never sees them. */
2144 if (regnum >= gdbarch_num_regs (gdbarch)
2145 + gdbarch_num_pseudo_regs (gdbarch))
2146 {
2147 struct value_print_options opts;
2148 struct value *val = value_of_user_reg (regnum, frame);
2149
2150 printf_filtered ("%s: ", start);
2151 get_formatted_print_options (&opts, 'x');
2152 val_print_scalar_formatted (check_typedef (value_type (val)),
2153 value_contents_for_printing (val),
2154 value_embedded_offset (val),
2155 val,
2156 &opts, 0, gdb_stdout);
2157 printf_filtered ("\n");
2158 }
2159 else
2160 gdbarch_print_registers_info (gdbarch, gdb_stdout,
2161 frame, regnum, fpregs);
2162 continue;
2163 }
2164 }
2165
2166 /* A register group? */
2167 {
2168 struct reggroup *group;
2169
2170 for (group = reggroup_next (gdbarch, NULL);
2171 group != NULL;
2172 group = reggroup_next (gdbarch, group))
2173 {
2174 /* Don't bother with a length check. Should the user
2175 enter a short register group name, go with the first
2176 group that matches. */
2177 if (strncmp (start, reggroup_name (group), end - start) == 0)
2178 break;
2179 }
2180 if (group != NULL)
2181 {
2182 int regnum;
2183
2184 for (regnum = 0;
2185 regnum < gdbarch_num_regs (gdbarch)
2186 + gdbarch_num_pseudo_regs (gdbarch);
2187 regnum++)
2188 {
2189 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
2190 gdbarch_print_registers_info (gdbarch,
2191 gdb_stdout, frame,
2192 regnum, fpregs);
2193 }
2194 continue;
2195 }
2196 }
2197
2198 /* Nothing matched. */
2199 error (_("Invalid register `%.*s'"), (int) (end - start), start);
2200 }
2201 }
2202
2203 void
2204 all_registers_info (char *addr_exp, int from_tty)
2205 {
2206 registers_info (addr_exp, 1);
2207 }
2208
2209 static void
2210 nofp_registers_info (char *addr_exp, int from_tty)
2211 {
2212 registers_info (addr_exp, 0);
2213 }
2214
2215 static void
2216 print_vector_info (struct ui_file *file,
2217 struct frame_info *frame, const char *args)
2218 {
2219 struct gdbarch *gdbarch = get_frame_arch (frame);
2220
2221 if (gdbarch_print_vector_info_p (gdbarch))
2222 gdbarch_print_vector_info (gdbarch, file, frame, args);
2223 else
2224 {
2225 int regnum;
2226 int printed_something = 0;
2227
2228 for (regnum = 0;
2229 regnum < gdbarch_num_regs (gdbarch)
2230 + gdbarch_num_pseudo_regs (gdbarch);
2231 regnum++)
2232 {
2233 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
2234 {
2235 printed_something = 1;
2236 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2237 }
2238 }
2239 if (!printed_something)
2240 fprintf_filtered (file, "No vector information\n");
2241 }
2242 }
2243
2244 static void
2245 vector_info (char *args, int from_tty)
2246 {
2247 if (!target_has_registers)
2248 error (_("The program has no registers now."));
2249
2250 print_vector_info (gdb_stdout, get_selected_frame (NULL), args);
2251 }
2252 \f
2253 /* Kill the inferior process. Make us have no inferior. */
2254
2255 static void
2256 kill_command (char *arg, int from_tty)
2257 {
2258 /* FIXME: This should not really be inferior_ptid (or target_has_execution).
2259 It should be a distinct flag that indicates that a target is active, cuz
2260 some targets don't have processes! */
2261
2262 if (ptid_equal (inferior_ptid, null_ptid))
2263 error (_("The program is not being run."));
2264 if (!query (_("Kill the program being debugged? ")))
2265 error (_("Not confirmed."));
2266 target_kill ();
2267
2268 /* If we still have other inferiors to debug, then don't mess with
2269 with their threads. */
2270 if (!have_inferiors ())
2271 {
2272 init_thread_list (); /* Destroy thread info. */
2273
2274 /* Killing off the inferior can leave us with a core file. If
2275 so, print the state we are left in. */
2276 if (target_has_stack)
2277 {
2278 printf_filtered (_("In %s,\n"), target_longname);
2279 print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
2280 }
2281 }
2282 bfd_cache_close_all ();
2283 }
2284
2285 /* Used in `attach&' command. ARG is a point to an integer
2286 representing a process id. Proceed threads of this process iff
2287 they stopped due to debugger request, and when they did, they
2288 reported a clean stop (TARGET_SIGNAL_0). Do not proceed threads
2289 that have been explicitly been told to stop. */
2290
2291 static int
2292 proceed_after_attach_callback (struct thread_info *thread,
2293 void *arg)
2294 {
2295 int pid = * (int *) arg;
2296
2297 if (ptid_get_pid (thread->ptid) == pid
2298 && !is_exited (thread->ptid)
2299 && !is_executing (thread->ptid)
2300 && !thread->stop_requested
2301 && thread->suspend.stop_signal == TARGET_SIGNAL_0)
2302 {
2303 switch_to_thread (thread->ptid);
2304 clear_proceed_status ();
2305 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
2306 }
2307
2308 return 0;
2309 }
2310
2311 static void
2312 proceed_after_attach (int pid)
2313 {
2314 /* Don't error out if the current thread is running, because
2315 there may be other stopped threads. */
2316 struct cleanup *old_chain;
2317
2318 /* Backup current thread and selected frame. */
2319 old_chain = make_cleanup_restore_current_thread ();
2320
2321 iterate_over_threads (proceed_after_attach_callback, &pid);
2322
2323 /* Restore selected ptid. */
2324 do_cleanups (old_chain);
2325 }
2326
2327 /*
2328 * TODO:
2329 * Should save/restore the tty state since it might be that the
2330 * program to be debugged was started on this tty and it wants
2331 * the tty in some state other than what we want. If it's running
2332 * on another terminal or without a terminal, then saving and
2333 * restoring the tty state is a harmless no-op.
2334 * This only needs to be done if we are attaching to a process.
2335 */
2336
2337 /* attach_command --
2338 takes a program started up outside of gdb and ``attaches'' to it.
2339 This stops it cold in its tracks and allows us to start debugging it.
2340 and wait for the trace-trap that results from attaching. */
2341
2342 static void
2343 attach_command_post_wait (char *args, int from_tty, int async_exec)
2344 {
2345 char *exec_file;
2346 char *full_exec_path = NULL;
2347 struct inferior *inferior;
2348
2349 inferior = current_inferior ();
2350 inferior->control.stop_soon = NO_STOP_QUIETLY;
2351
2352 /* If no exec file is yet known, try to determine it from the
2353 process itself. */
2354 exec_file = (char *) get_exec_file (0);
2355 if (!exec_file)
2356 {
2357 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
2358 if (exec_file)
2359 {
2360 /* It's possible we don't have a full path, but rather just a
2361 filename. Some targets, such as HP-UX, don't provide the
2362 full path, sigh.
2363
2364 Attempt to qualify the filename against the source path.
2365 (If that fails, we'll just fall back on the original
2366 filename. Not much more we can do...) */
2367
2368 if (!source_full_path_of (exec_file, &full_exec_path))
2369 full_exec_path = xstrdup (exec_file);
2370
2371 exec_file_attach (full_exec_path, from_tty);
2372 symbol_file_add_main (full_exec_path, from_tty);
2373 }
2374 }
2375 else
2376 {
2377 reopen_exec_file ();
2378 reread_symbols ();
2379 }
2380
2381 /* Take any necessary post-attaching actions for this platform. */
2382 target_post_attach (PIDGET (inferior_ptid));
2383
2384 post_create_inferior (&current_target, from_tty);
2385
2386 /* Install inferior's terminal modes. */
2387 target_terminal_inferior ();
2388
2389 if (async_exec)
2390 {
2391 /* The user requested an `attach&', so be sure to leave threads
2392 that didn't get a signal running. */
2393
2394 /* Immediatelly resume all suspended threads of this inferior,
2395 and this inferior only. This should have no effect on
2396 already running threads. If a thread has been stopped with a
2397 signal, leave it be. */
2398 if (non_stop)
2399 proceed_after_attach (inferior->pid);
2400 else
2401 {
2402 if (inferior_thread ()->suspend.stop_signal == TARGET_SIGNAL_0)
2403 {
2404 clear_proceed_status ();
2405 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
2406 }
2407 }
2408 }
2409 else
2410 {
2411 /* The user requested a plain `attach', so be sure to leave
2412 the inferior stopped. */
2413
2414 if (target_can_async_p ())
2415 async_enable_stdin ();
2416
2417 /* At least the current thread is already stopped. */
2418
2419 /* In all-stop, by definition, all threads have to be already
2420 stopped at this point. In non-stop, however, although the
2421 selected thread is stopped, others may still be executing.
2422 Be sure to explicitly stop all threads of the process. This
2423 should have no effect on already stopped threads. */
2424 if (non_stop)
2425 target_stop (pid_to_ptid (inferior->pid));
2426
2427 /* Tell the user/frontend where we're stopped. */
2428 normal_stop ();
2429 if (deprecated_attach_hook)
2430 deprecated_attach_hook ();
2431 }
2432 }
2433
2434 struct attach_command_continuation_args
2435 {
2436 char *args;
2437 int from_tty;
2438 int async_exec;
2439 };
2440
2441 static void
2442 attach_command_continuation (void *args, int err)
2443 {
2444 struct attach_command_continuation_args *a = args;
2445
2446 if (err)
2447 return;
2448
2449 attach_command_post_wait (a->args, a->from_tty, a->async_exec);
2450 }
2451
2452 static void
2453 attach_command_continuation_free_args (void *args)
2454 {
2455 struct attach_command_continuation_args *a = args;
2456
2457 xfree (a->args);
2458 xfree (a);
2459 }
2460
2461 void
2462 attach_command (char *args, int from_tty)
2463 {
2464 int async_exec = 0;
2465 struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
2466
2467 dont_repeat (); /* Not for the faint of heart */
2468
2469 if (gdbarch_has_global_solist (target_gdbarch))
2470 /* Don't complain if all processes share the same symbol
2471 space. */
2472 ;
2473 else if (target_has_execution)
2474 {
2475 if (query (_("A program is being debugged already. Kill it? ")))
2476 target_kill ();
2477 else
2478 error (_("Not killed."));
2479 }
2480
2481 /* Clean up any leftovers from other runs. Some other things from
2482 this function should probably be moved into target_pre_inferior. */
2483 target_pre_inferior (from_tty);
2484
2485 if (non_stop && !target_supports_non_stop ())
2486 error (_("Cannot attach to this target in non-stop mode"));
2487
2488 if (args)
2489 {
2490 async_exec = strip_bg_char (&args);
2491
2492 /* If we get a request for running in the bg but the target
2493 doesn't support it, error out. */
2494 if (async_exec && !target_can_async_p ())
2495 error (_("Asynchronous execution not supported on this target."));
2496 }
2497
2498 /* If we don't get a request of running in the bg, then we need
2499 to simulate synchronous (fg) execution. */
2500 if (!async_exec && target_can_async_p ())
2501 {
2502 /* Simulate synchronous execution. */
2503 async_disable_stdin ();
2504 make_cleanup ((make_cleanup_ftype *)async_enable_stdin, NULL);
2505 }
2506
2507 target_attach (args, from_tty);
2508
2509 /* Set up the "saved terminal modes" of the inferior
2510 based on what modes we are starting it with. */
2511 target_terminal_init ();
2512
2513 /* Set up execution context to know that we should return from
2514 wait_for_inferior as soon as the target reports a stop. */
2515 init_wait_for_inferior ();
2516 clear_proceed_status ();
2517
2518 if (non_stop)
2519 {
2520 /* If we find that the current thread isn't stopped, explicitly
2521 do so now, because we're going to install breakpoints and
2522 poke at memory. */
2523
2524 if (async_exec)
2525 /* The user requested an `attach&'; stop just one thread. */
2526 target_stop (inferior_ptid);
2527 else
2528 /* The user requested an `attach', so stop all threads of this
2529 inferior. */
2530 target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid)));
2531 }
2532
2533 /* Some system don't generate traps when attaching to inferior.
2534 E.g. Mach 3 or GNU hurd. */
2535 if (!target_attach_no_wait)
2536 {
2537 struct inferior *inferior = current_inferior ();
2538
2539 /* Careful here. See comments in inferior.h. Basically some
2540 OSes don't ignore SIGSTOPs on continue requests anymore. We
2541 need a way for handle_inferior_event to reset the stop_signal
2542 variable after an attach, and this is what
2543 STOP_QUIETLY_NO_SIGSTOP is for. */
2544 inferior->control.stop_soon = STOP_QUIETLY_NO_SIGSTOP;
2545
2546 if (target_can_async_p ())
2547 {
2548 /* sync_execution mode. Wait for stop. */
2549 struct attach_command_continuation_args *a;
2550
2551 a = xmalloc (sizeof (*a));
2552 a->args = xstrdup (args);
2553 a->from_tty = from_tty;
2554 a->async_exec = async_exec;
2555 add_inferior_continuation (attach_command_continuation, a,
2556 attach_command_continuation_free_args);
2557 discard_cleanups (back_to);
2558 return;
2559 }
2560
2561 wait_for_inferior ();
2562 }
2563
2564 attach_command_post_wait (args, from_tty, async_exec);
2565 discard_cleanups (back_to);
2566 }
2567
2568 /* We had just found out that the target was already attached to an
2569 inferior. PTID points at a thread of this new inferior, that is
2570 the most likely to be stopped right now, but not necessarily so.
2571 The new inferior is assumed to be already added to the inferior
2572 list at this point. If LEAVE_RUNNING, then leave the threads of
2573 this inferior running, except those we've explicitly seen reported
2574 as stopped. */
2575
2576 void
2577 notice_new_inferior (ptid_t ptid, int leave_running, int from_tty)
2578 {
2579 struct cleanup* old_chain;
2580 int async_exec;
2581
2582 old_chain = make_cleanup (null_cleanup, NULL);
2583
2584 /* If in non-stop, leave threads as running as they were. If
2585 they're stopped for some reason other than us telling it to, the
2586 target reports a signal != TARGET_SIGNAL_0. We don't try to
2587 resume threads with such a stop signal. */
2588 async_exec = non_stop;
2589
2590 if (!ptid_equal (inferior_ptid, null_ptid))
2591 make_cleanup_restore_current_thread ();
2592
2593 switch_to_thread (ptid);
2594
2595 /* When we "notice" a new inferior we need to do all the things we
2596 would normally do if we had just attached to it. */
2597
2598 if (is_executing (inferior_ptid))
2599 {
2600 struct inferior *inferior = current_inferior ();
2601
2602 /* We're going to install breakpoints, and poke at memory,
2603 ensure that the inferior is stopped for a moment while we do
2604 that. */
2605 target_stop (inferior_ptid);
2606
2607 inferior->control.stop_soon = STOP_QUIETLY_REMOTE;
2608
2609 /* Wait for stop before proceeding. */
2610 if (target_can_async_p ())
2611 {
2612 struct attach_command_continuation_args *a;
2613
2614 a = xmalloc (sizeof (*a));
2615 a->args = xstrdup ("");
2616 a->from_tty = from_tty;
2617 a->async_exec = async_exec;
2618 add_inferior_continuation (attach_command_continuation, a,
2619 attach_command_continuation_free_args);
2620
2621 do_cleanups (old_chain);
2622 return;
2623 }
2624 else
2625 wait_for_inferior ();
2626 }
2627
2628 async_exec = leave_running;
2629 attach_command_post_wait ("" /* args */, from_tty, async_exec);
2630
2631 do_cleanups (old_chain);
2632 }
2633
2634 /*
2635 * detach_command --
2636 * takes a program previously attached to and detaches it.
2637 * The program resumes execution and will no longer stop
2638 * on signals, etc. We better not have left any breakpoints
2639 * in the program or it'll die when it hits one. For this
2640 * to work, it may be necessary for the process to have been
2641 * previously attached. It *might* work if the program was
2642 * started via the normal ptrace (PTRACE_TRACEME).
2643 */
2644
2645 void
2646 detach_command (char *args, int from_tty)
2647 {
2648 dont_repeat (); /* Not for the faint of heart. */
2649
2650 if (ptid_equal (inferior_ptid, null_ptid))
2651 error (_("The program is not being run."));
2652
2653 disconnect_tracing (from_tty);
2654
2655 target_detach (args, from_tty);
2656
2657 /* If the solist is global across inferiors, don't clear it when we
2658 detach from a single inferior. */
2659 if (!gdbarch_has_global_solist (target_gdbarch))
2660 no_shared_libraries (NULL, from_tty);
2661
2662 /* If we still have inferiors to debug, then don't mess with their
2663 threads. */
2664 if (!have_inferiors ())
2665 init_thread_list ();
2666
2667 if (deprecated_detach_hook)
2668 deprecated_detach_hook ();
2669 }
2670
2671 /* Disconnect from the current target without resuming it (leaving it
2672 waiting for a debugger).
2673
2674 We'd better not have left any breakpoints in the program or the
2675 next debugger will get confused. Currently only supported for some
2676 remote targets, since the normal attach mechanisms don't work on
2677 stopped processes on some native platforms (e.g. GNU/Linux). */
2678
2679 static void
2680 disconnect_command (char *args, int from_tty)
2681 {
2682 dont_repeat (); /* Not for the faint of heart. */
2683 disconnect_tracing (from_tty);
2684 target_disconnect (args, from_tty);
2685 no_shared_libraries (NULL, from_tty);
2686 init_thread_list ();
2687 if (deprecated_detach_hook)
2688 deprecated_detach_hook ();
2689 }
2690
2691 void
2692 interrupt_target_1 (int all_threads)
2693 {
2694 ptid_t ptid;
2695
2696 if (all_threads)
2697 ptid = minus_one_ptid;
2698 else
2699 ptid = inferior_ptid;
2700 target_stop (ptid);
2701
2702 /* Tag the thread as having been explicitly requested to stop, so
2703 other parts of gdb know not to resume this thread automatically,
2704 if it was stopped due to an internal event. Limit this to
2705 non-stop mode, as when debugging a multi-threaded application in
2706 all-stop mode, we will only get one stop event --- it's undefined
2707 which thread will report the event. */
2708 if (non_stop)
2709 set_stop_requested (ptid, 1);
2710 }
2711
2712 /* Stop the execution of the target while running in async mode, in
2713 the backgound. In all-stop, stop the whole process. In non-stop
2714 mode, stop the current thread only by default, or stop all threads
2715 if the `-a' switch is used. */
2716
2717 /* interrupt [-a] */
2718 void
2719 interrupt_target_command (char *args, int from_tty)
2720 {
2721 if (target_can_async_p ())
2722 {
2723 int all_threads = 0;
2724
2725 dont_repeat (); /* Not for the faint of heart. */
2726
2727 if (args != NULL
2728 && strncmp (args, "-a", sizeof ("-a") - 1) == 0)
2729 all_threads = 1;
2730
2731 if (!non_stop && all_threads)
2732 error (_("-a is meaningless in all-stop mode."));
2733
2734 interrupt_target_1 (all_threads);
2735 }
2736 }
2737
2738 static void
2739 print_float_info (struct ui_file *file,
2740 struct frame_info *frame, const char *args)
2741 {
2742 struct gdbarch *gdbarch = get_frame_arch (frame);
2743
2744 if (gdbarch_print_float_info_p (gdbarch))
2745 gdbarch_print_float_info (gdbarch, file, frame, args);
2746 else
2747 {
2748 int regnum;
2749 int printed_something = 0;
2750
2751 for (regnum = 0;
2752 regnum < gdbarch_num_regs (gdbarch)
2753 + gdbarch_num_pseudo_regs (gdbarch);
2754 regnum++)
2755 {
2756 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
2757 {
2758 printed_something = 1;
2759 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2760 }
2761 }
2762 if (!printed_something)
2763 fprintf_filtered (file, "No floating-point info "
2764 "available for this processor.\n");
2765 }
2766 }
2767
2768 static void
2769 float_info (char *args, int from_tty)
2770 {
2771 if (!target_has_registers)
2772 error (_("The program has no registers now."));
2773
2774 print_float_info (gdb_stdout, get_selected_frame (NULL), args);
2775 }
2776 \f
2777 static void
2778 unset_command (char *args, int from_tty)
2779 {
2780 printf_filtered (_("\"unset\" must be followed by the "
2781 "name of an unset subcommand.\n"));
2782 help_list (unsetlist, "unset ", -1, gdb_stdout);
2783 }
2784
2785 void
2786 _initialize_infcmd (void)
2787 {
2788 struct cmd_list_element *c = NULL;
2789
2790 /* Add the filename of the terminal connected to inferior I/O. */
2791 add_setshow_filename_cmd ("inferior-tty", class_run,
2792 &inferior_io_terminal_scratch, _("\
2793 Set terminal for future runs of program being debugged."), _("\
2794 Show terminal for future runs of program being debugged."), _("\
2795 Usage: set inferior-tty /dev/pts/1"),
2796 set_inferior_tty_command,
2797 show_inferior_tty_command,
2798 &setlist, &showlist);
2799 add_com_alias ("tty", "set inferior-tty", class_alias, 0);
2800
2801 add_setshow_optional_filename_cmd ("args", class_run,
2802 &inferior_args_scratch, _("\
2803 Set argument list to give program being debugged when it is started."), _("\
2804 Show argument list to give program being debugged when it is started."), _("\
2805 Follow this command with any number of args, to be passed to the program."),
2806 set_args_command,
2807 show_args_command,
2808 &setlist, &showlist);
2809
2810 c = add_cmd ("environment", no_class, environment_info, _("\
2811 The environment to give the program, or one variable's value.\n\
2812 With an argument VAR, prints the value of environment variable VAR to\n\
2813 give the program being debugged. With no arguments, prints the entire\n\
2814 environment to be given to the program."), &showlist);
2815 set_cmd_completer (c, noop_completer);
2816
2817 add_prefix_cmd ("unset", no_class, unset_command,
2818 _("Complement to certain \"set\" commands."),
2819 &unsetlist, "unset ", 0, &cmdlist);
2820
2821 c = add_cmd ("environment", class_run, unset_environment_command, _("\
2822 Cancel environment variable VAR for the program.\n\
2823 This does not affect the program until the next \"run\" command."),
2824 &unsetlist);
2825 set_cmd_completer (c, noop_completer);
2826
2827 c = add_cmd ("environment", class_run, set_environment_command, _("\
2828 Set environment variable value to give the program.\n\
2829 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2830 VALUES of environment variables are uninterpreted strings.\n\
2831 This does not affect the program until the next \"run\" command."),
2832 &setlist);
2833 set_cmd_completer (c, noop_completer);
2834
2835 c = add_com ("path", class_files, path_command, _("\
2836 Add directory DIR(s) to beginning of search path for object files.\n\
2837 $cwd in the path means the current working directory.\n\
2838 This path is equivalent to the $PATH shell variable. It is a list of\n\
2839 directories, separated by colons. These directories are searched to find\n\
2840 fully linked executable files and separately compiled object files as \
2841 needed."));
2842 set_cmd_completer (c, filename_completer);
2843
2844 c = add_cmd ("paths", no_class, path_info, _("\
2845 Current search path for finding object files.\n\
2846 $cwd in the path means the current working directory.\n\
2847 This path is equivalent to the $PATH shell variable. It is a list of\n\
2848 directories, separated by colons. These directories are searched to find\n\
2849 fully linked executable files and separately compiled object files as \
2850 needed."),
2851 &showlist);
2852 set_cmd_completer (c, noop_completer);
2853
2854 add_prefix_cmd ("kill", class_run, kill_command,
2855 _("Kill execution of program being debugged."),
2856 &killlist, "kill ", 0, &cmdlist);
2857
2858 add_com ("attach", class_run, attach_command, _("\
2859 Attach to a process or file outside of GDB.\n\
2860 This command attaches to another target, of the same type as your last\n\
2861 \"target\" command (\"info files\" will show your target stack).\n\
2862 The command may take as argument a process id or a device file.\n\
2863 For a process id, you must have permission to send the process a signal,\n\
2864 and it must have the same effective uid as the debugger.\n\
2865 When using \"attach\" with a process id, the debugger finds the\n\
2866 program running in the process, looking first in the current working\n\
2867 directory, or (if not found there) using the source file search path\n\
2868 (see the \"directory\" command). You can also use the \"file\" command\n\
2869 to specify the program, and to load its symbol table."));
2870
2871 add_prefix_cmd ("detach", class_run, detach_command, _("\
2872 Detach a process or file previously attached.\n\
2873 If a process, it is no longer traced, and it continues its execution. If\n\
2874 you were debugging a file, the file is closed and gdb no longer accesses it."),
2875 &detachlist, "detach ", 0, &cmdlist);
2876
2877 add_com ("disconnect", class_run, disconnect_command, _("\
2878 Disconnect from a target.\n\
2879 The target will wait for another debugger to connect. Not available for\n\
2880 all targets."));
2881
2882 add_com ("signal", class_run, signal_command, _("\
2883 Continue program giving it signal specified by the argument.\n\
2884 An argument of \"0\" means continue program without giving it a signal."));
2885
2886 add_com ("stepi", class_run, stepi_command, _("\
2887 Step one instruction exactly.\n\
2888 Argument N means do this N times (or till program stops for another \
2889 reason)."));
2890 add_com_alias ("si", "stepi", class_alias, 0);
2891
2892 add_com ("nexti", class_run, nexti_command, _("\
2893 Step one instruction, but proceed through subroutine calls.\n\
2894 Argument N means do this N times (or till program stops for another \
2895 reason)."));
2896 add_com_alias ("ni", "nexti", class_alias, 0);
2897
2898 add_com ("finish", class_run, finish_command, _("\
2899 Execute until selected stack frame returns.\n\
2900 Upon return, the value returned is printed and put in the value history."));
2901 add_com_alias ("fin", "finish", class_run, 1);
2902
2903 add_com ("next", class_run, next_command, _("\
2904 Step program, proceeding through subroutine calls.\n\
2905 Like the \"step\" command as long as subroutine calls do not happen;\n\
2906 when they do, the call is treated as one instruction.\n\
2907 Argument N means do this N times (or till program stops for another \
2908 reason)."));
2909 add_com_alias ("n", "next", class_run, 1);
2910 if (xdb_commands)
2911 add_com_alias ("S", "next", class_run, 1);
2912
2913 add_com ("step", class_run, step_command, _("\
2914 Step program until it reaches a different source line.\n\
2915 Argument N means do this N times (or till program stops for another \
2916 reason)."));
2917 add_com_alias ("s", "step", class_run, 1);
2918
2919 c = add_com ("until", class_run, until_command, _("\
2920 Execute until the program reaches a source line greater than the current\n\
2921 or a specified location (same args as break command) within the current \
2922 frame."));
2923 set_cmd_completer (c, location_completer);
2924 add_com_alias ("u", "until", class_run, 1);
2925
2926 c = add_com ("advance", class_run, advance_command, _("\
2927 Continue the program up to the given location (same form as args for break \
2928 command).\n\
2929 Execution will also stop upon exit from the current stack frame."));
2930 set_cmd_completer (c, location_completer);
2931
2932 c = add_com ("jump", class_run, jump_command, _("\
2933 Continue program being debugged at specified line or address.\n\
2934 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2935 for an address to start at."));
2936 set_cmd_completer (c, location_completer);
2937
2938 if (xdb_commands)
2939 {
2940 c = add_com ("go", class_run, go_command, _("\
2941 Usage: go <location>\n\
2942 Continue program being debugged, stopping at specified line or \n\
2943 address.\n\
2944 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2945 expression for an address to start at.\n\
2946 This command is a combination of tbreak and jump."));
2947 set_cmd_completer (c, location_completer);
2948 }
2949
2950 if (xdb_commands)
2951 add_com_alias ("g", "go", class_run, 1);
2952
2953 add_com ("continue", class_run, continue_command, _("\
2954 Continue program being debugged, after signal or breakpoint.\n\
2955 If proceeding from breakpoint, a number N may be used as an argument,\n\
2956 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2957 the breakpoint won't break until the Nth time it is reached).\n\
2958 \n\
2959 If non-stop mode is enabled, continue only the current thread,\n\
2960 otherwise all the threads in the program are continued. To \n\
2961 continue all stopped threads in non-stop mode, use the -a option.\n\
2962 Specifying -a and an ignore count simultaneously is an error."));
2963 add_com_alias ("c", "cont", class_run, 1);
2964 add_com_alias ("fg", "cont", class_run, 1);
2965
2966 c = add_com ("run", class_run, run_command, _("\
2967 Start debugged program. You may specify arguments to give it.\n\
2968 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2969 Input and output redirection with \">\", \"<\", or \">>\" are also \
2970 allowed.\n\n\
2971 With no arguments, uses arguments last specified (with \"run\" \
2972 or \"set args\").\n\
2973 To cancel previous arguments and run with no arguments,\n\
2974 use \"set args\" without arguments."));
2975 set_cmd_completer (c, filename_completer);
2976 add_com_alias ("r", "run", class_run, 1);
2977 if (xdb_commands)
2978 add_com ("R", class_run, run_no_args_command,
2979 _("Start debugged program with no arguments."));
2980
2981 c = add_com ("start", class_run, start_command, _("\
2982 Run the debugged program until the beginning of the main procedure.\n\
2983 You may specify arguments to give to your program, just as with the\n\
2984 \"run\" command."));
2985 set_cmd_completer (c, filename_completer);
2986
2987 add_com ("interrupt", class_run, interrupt_target_command,
2988 _("Interrupt the execution of the debugged program.\n\
2989 If non-stop mode is enabled, interrupt only the current thread,\n\
2990 otherwise all the threads in the program are stopped. To \n\
2991 interrupt all running threads in non-stop mode, use the -a option."));
2992
2993 add_info ("registers", nofp_registers_info, _("\
2994 List of integer registers and their contents, for selected stack frame.\n\
2995 Register name as argument means describe only that register."));
2996 add_info_alias ("r", "registers", 1);
2997
2998 if (xdb_commands)
2999 add_com ("lr", class_info, nofp_registers_info, _("\
3000 List of integer registers and their contents, for selected stack frame.\n\
3001 Register name as argument means describe only that register."));
3002 add_info ("all-registers", all_registers_info, _("\
3003 List of all registers and their contents, for selected stack frame.\n\
3004 Register name as argument means describe only that register."));
3005
3006 add_info ("program", program_info,
3007 _("Execution status of the program."));
3008
3009 add_info ("float", float_info,
3010 _("Print the status of the floating point unit\n"));
3011
3012 add_info ("vector", vector_info,
3013 _("Print the status of the vector unit\n"));
3014 }
This page took 0.138876 seconds and 4 git commands to generate.