]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/infcmd.c
* infcmd.c (attach_command_post_wait)
[thirdparty/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 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 <signal.h>
24 #include "gdb_string.h"
25 #include "symtab.h"
26 #include "gdbtypes.h"
27 #include "frame.h"
28 #include "inferior.h"
29 #include "environ.h"
30 #include "value.h"
31 #include "gdbcmd.h"
32 #include "symfile.h"
33 #include "gdbcore.h"
34 #include "target.h"
35 #include "language.h"
36 #include "symfile.h"
37 #include "objfiles.h"
38 #include "completer.h"
39 #include "ui-out.h"
40 #include "event-top.h"
41 #include "parser-defs.h"
42 #include "regcache.h"
43 #include "reggroups.h"
44 #include "block.h"
45 #include "solib.h"
46 #include <ctype.h>
47 #include "gdb_assert.h"
48 #include "observer.h"
49 #include "target-descriptions.h"
50 #include "user-regs.h"
51 #include "exceptions.h"
52
53 /* Functions exported for general use, in inferior.h: */
54
55 void all_registers_info (char *, int);
56
57 void registers_info (char *, int);
58
59 void nexti_command (char *, int);
60
61 void stepi_command (char *, int);
62
63 void continue_command (char *, int);
64
65 void interrupt_target_command (char *args, int from_tty);
66
67 /* Local functions: */
68
69 static void nofp_registers_info (char *, int);
70
71 static void print_return_value (struct type *value_type);
72
73 static void finish_command_continuation (struct continuation_arg *);
74
75 static void until_next_command (int);
76
77 static void until_command (char *, int);
78
79 static void path_info (char *, int);
80
81 static void path_command (char *, int);
82
83 static void unset_command (char *, int);
84
85 static void float_info (char *, int);
86
87 static void detach_command (char *, int);
88
89 static void disconnect_command (char *, int);
90
91 static void unset_environment_command (char *, int);
92
93 static void set_environment_command (char *, int);
94
95 static void environment_info (char *, int);
96
97 static void program_info (char *, int);
98
99 static void finish_command (char *, int);
100
101 static void signal_command (char *, int);
102
103 static void jump_command (char *, int);
104
105 static void step_1 (int, int, char *);
106 static void step_once (int skip_subroutines, int single_inst, int count);
107 static void step_1_continuation (struct continuation_arg *arg);
108
109 static void next_command (char *, int);
110
111 static void step_command (char *, int);
112
113 static void run_command (char *, int);
114
115 static void run_no_args_command (char *args, int from_tty);
116
117 static void go_command (char *line_no, int from_tty);
118
119 static int strip_bg_char (char **);
120
121 void _initialize_infcmd (void);
122
123 #define GO_USAGE "Usage: go <location>\n"
124
125 #define ERROR_NO_INFERIOR \
126 if (!target_has_execution) error (_("The program is not being run."));
127
128 /* String containing arguments to give to the program, separated by spaces.
129 Empty string (pointer to '\0') means no args. */
130
131 static char *inferior_args;
132
133 /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
134 then we must compute INFERIOR_ARGS from this (via the target). */
135
136 static int inferior_argc;
137 static char **inferior_argv;
138
139 /* File name for default use for standard in/out in the inferior. */
140
141 static char *inferior_io_terminal;
142
143 /* Pid of our debugged inferior, or 0 if no inferior now.
144 Since various parts of infrun.c test this to see whether there is a program
145 being debugged it should be nonzero (currently 3 is used) for remote
146 debugging. */
147
148 ptid_t inferior_ptid;
149
150 /* Last signal that the inferior received (why it stopped). */
151
152 enum target_signal stop_signal;
153
154 /* Address at which inferior stopped. */
155
156 CORE_ADDR stop_pc;
157
158 /* Chain containing status of breakpoint(s) that we have stopped at. */
159
160 bpstat stop_bpstat;
161
162 /* Flag indicating that a command has proceeded the inferior past the
163 current breakpoint. */
164
165 int breakpoint_proceeded;
166
167 /* Nonzero if stopped due to a step command. */
168
169 int stop_step;
170
171 /* Nonzero if stopped due to completion of a stack dummy routine. */
172
173 int stop_stack_dummy;
174
175 /* Nonzero if stopped due to a random (unexpected) signal in inferior
176 process. */
177
178 int stopped_by_random_signal;
179
180 /* Range to single step within.
181 If this is nonzero, respond to a single-step signal
182 by continuing to step if the pc is in this range. */
183
184 CORE_ADDR step_range_start; /* Inclusive */
185 CORE_ADDR step_range_end; /* Exclusive */
186
187 /* Stack frame address as of when stepping command was issued.
188 This is how we know when we step into a subroutine call,
189 and how to set the frame for the breakpoint used to step out. */
190
191 struct frame_id step_frame_id;
192
193 enum step_over_calls_kind step_over_calls;
194
195 /* If stepping, nonzero means step count is > 1
196 so don't print frame next time inferior stops
197 if it stops due to stepping. */
198
199 int step_multi;
200
201 /* Environment to use for running inferior,
202 in format described in environ.h. */
203
204 struct gdb_environ *inferior_environ;
205 \f
206 /* Accessor routines. */
207
208 void
209 set_inferior_io_terminal (const char *terminal_name)
210 {
211 if (inferior_io_terminal)
212 xfree (inferior_io_terminal);
213
214 if (!terminal_name)
215 inferior_io_terminal = NULL;
216 else
217 inferior_io_terminal = savestring (terminal_name, strlen (terminal_name));
218 }
219
220 const char *
221 get_inferior_io_terminal (void)
222 {
223 return inferior_io_terminal;
224 }
225
226 char *
227 get_inferior_args (void)
228 {
229 if (inferior_argc != 0)
230 {
231 char *n, *old;
232
233 n = gdbarch_construct_inferior_arguments (current_gdbarch,
234 inferior_argc, inferior_argv);
235 old = set_inferior_args (n);
236 xfree (old);
237 }
238
239 if (inferior_args == NULL)
240 inferior_args = xstrdup ("");
241
242 return inferior_args;
243 }
244
245 char *
246 set_inferior_args (char *newargs)
247 {
248 char *saved_args = inferior_args;
249
250 inferior_args = newargs;
251 inferior_argc = 0;
252 inferior_argv = 0;
253
254 return saved_args;
255 }
256
257 void
258 set_inferior_args_vector (int argc, char **argv)
259 {
260 inferior_argc = argc;
261 inferior_argv = argv;
262 }
263
264 /* Notice when `set args' is run. */
265 static void
266 notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
267 {
268 inferior_argc = 0;
269 inferior_argv = 0;
270 }
271
272 /* Notice when `show args' is run. */
273 static void
274 notice_args_read (struct ui_file *file, int from_tty,
275 struct cmd_list_element *c, const char *value)
276 {
277 /* Note that we ignore the passed-in value in favor of computing it
278 directly. */
279 deprecated_show_value_hack (file, from_tty, c, get_inferior_args ());
280 }
281
282 \f
283 /* Compute command-line string given argument vector. This does the
284 same shell processing as fork_inferior. */
285 char *
286 construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
287 {
288 char *result;
289
290 if (STARTUP_WITH_SHELL)
291 {
292 /* This holds all the characters considered special to the
293 typical Unix shells. We include `^' because the SunOS
294 /bin/sh treats it as a synonym for `|'. */
295 char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
296 int i;
297 int length = 0;
298 char *out, *cp;
299
300 /* We over-compute the size. It shouldn't matter. */
301 for (i = 0; i < argc; ++i)
302 length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
303
304 result = (char *) xmalloc (length);
305 out = result;
306
307 for (i = 0; i < argc; ++i)
308 {
309 if (i > 0)
310 *out++ = ' ';
311
312 /* Need to handle empty arguments specially. */
313 if (argv[i][0] == '\0')
314 {
315 *out++ = '\'';
316 *out++ = '\'';
317 }
318 else
319 {
320 for (cp = argv[i]; *cp; ++cp)
321 {
322 if (strchr (special, *cp) != NULL)
323 *out++ = '\\';
324 *out++ = *cp;
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 argument containing whitespace"));
346 length += strlen (argv[i]) + 1;
347 }
348
349 result = (char *) xmalloc (length);
350 result[0] = '\0';
351 for (i = 0; i < argc; ++i)
352 {
353 if (i > 0)
354 strcat (result, " ");
355 strcat (result, argv[i]);
356 }
357 }
358
359 return result;
360 }
361 \f
362
363 /* This function detects whether or not a '&' character (indicating
364 background execution) has been added as *the last* of the arguments ARGS
365 of a command. If it has, it removes it and returns 1. Otherwise it
366 does nothing and returns 0. */
367 static int
368 strip_bg_char (char **args)
369 {
370 char *p = NULL;
371
372 p = strchr (*args, '&');
373
374 if (p)
375 {
376 if (p == (*args + strlen (*args) - 1))
377 {
378 if (strlen (*args) > 1)
379 {
380 do
381 p--;
382 while (*p == ' ' || *p == '\t');
383 *(p + 1) = '\0';
384 }
385 else
386 *args = 0;
387 return 1;
388 }
389 }
390 return 0;
391 }
392
393 void
394 tty_command (char *file, int from_tty)
395 {
396 if (file == 0)
397 error_no_arg (_("terminal name for running target process"));
398
399 set_inferior_io_terminal (file);
400 }
401
402 /* Common actions to take after creating any sort of inferior, by any
403 means (running, attaching, connecting, et cetera). The target
404 should be stopped. */
405
406 void
407 post_create_inferior (struct target_ops *target, int from_tty)
408 {
409 /* Be sure we own the terminal in case write operations are performed. */
410 target_terminal_ours ();
411
412 /* If the target hasn't taken care of this already, do it now.
413 Targets which need to access registers during to_open,
414 to_create_inferior, or to_attach should do it earlier; but many
415 don't need to. */
416 target_find_description ();
417
418 if (exec_bfd)
419 {
420 /* Sometimes the platform-specific hook loads initial shared
421 libraries, and sometimes it doesn't. Try to do so first, so
422 that we can add them with the correct value for FROM_TTY.
423 If we made all the inferior hook methods consistent,
424 this call could be removed. */
425 #ifdef SOLIB_ADD
426 SOLIB_ADD (NULL, from_tty, target, auto_solib_add);
427 #else
428 solib_add (NULL, from_tty, target, auto_solib_add);
429 #endif
430
431 /* Create the hooks to handle shared library load and unload
432 events. */
433 #ifdef SOLIB_CREATE_INFERIOR_HOOK
434 SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
435 #else
436 solib_create_inferior_hook ();
437 #endif
438 }
439
440 observer_notify_inferior_created (target, from_tty);
441 }
442
443 /* Kill the inferior if already running. This function is designed
444 to be called when we are about to start the execution of the program
445 from the beginning. Ask the user to confirm that he wants to restart
446 the program being debugged when FROM_TTY is non-null. */
447
448 static void
449 kill_if_already_running (int from_tty)
450 {
451 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
452 {
453 /* Bail out before killing the program if we will not be able to
454 restart it. */
455 target_require_runnable ();
456
457 if (from_tty
458 && !query ("The program being debugged has been started already.\n\
459 Start it from the beginning? "))
460 error (_("Program not restarted."));
461 target_kill ();
462 no_shared_libraries (NULL, from_tty);
463 init_wait_for_inferior ();
464 }
465 }
466
467 /* Implement the "run" command. If TBREAK_AT_MAIN is set, then insert
468 a temporary breakpoint at the begining of the main program before
469 running the program. */
470
471 static void
472 run_command_1 (char *args, int from_tty, int tbreak_at_main)
473 {
474 char *exec_file;
475
476 dont_repeat ();
477
478 kill_if_already_running (from_tty);
479 clear_breakpoint_hit_counts ();
480
481 /* Clean up any leftovers from other runs. Some other things from
482 this function should probably be moved into target_pre_inferior. */
483 target_pre_inferior (from_tty);
484
485 /* Purge old solib objfiles. */
486 objfile_purge_solibs ();
487
488 clear_solib ();
489
490 /* The comment here used to read, "The exec file is re-read every
491 time we do a generic_mourn_inferior, so we just have to worry
492 about the symbol file." The `generic_mourn_inferior' function
493 gets called whenever the program exits. However, suppose the
494 program exits, and *then* the executable file changes? We need
495 to check again here. Since reopen_exec_file doesn't do anything
496 if the timestamp hasn't changed, I don't see the harm. */
497 reopen_exec_file ();
498 reread_symbols ();
499
500 /* Insert the temporary breakpoint if a location was specified. */
501 if (tbreak_at_main)
502 tbreak_command (main_name (), 0);
503
504 exec_file = (char *) get_exec_file (0);
505
506 /* We keep symbols from add-symbol-file, on the grounds that the
507 user might want to add some symbols before running the program
508 (right?). But sometimes (dynamic loading where the user manually
509 introduces the new symbols with add-symbol-file), the code which
510 the symbols describe does not persist between runs. Currently
511 the user has to manually nuke all symbols between runs if they
512 want them to go away (PR 2207). This is probably reasonable. */
513
514 if (!args)
515 {
516 if (target_can_async_p ())
517 async_disable_stdin ();
518 }
519 else
520 {
521 int async_exec = strip_bg_char (&args);
522
523 /* If we get a request for running in the bg but the target
524 doesn't support it, error out. */
525 if (async_exec && !target_can_async_p ())
526 error (_("Asynchronous execution not supported on this target."));
527
528 /* If we don't get a request of running in the bg, then we need
529 to simulate synchronous (fg) execution. */
530 if (!async_exec && target_can_async_p ())
531 {
532 /* Simulate synchronous execution */
533 async_disable_stdin ();
534 }
535
536 /* If there were other args, beside '&', process them. */
537 if (args)
538 {
539 char *old_args = set_inferior_args (xstrdup (args));
540 xfree (old_args);
541 }
542 }
543
544 if (from_tty)
545 {
546 ui_out_field_string (uiout, NULL, "Starting program");
547 ui_out_text (uiout, ": ");
548 if (exec_file)
549 ui_out_field_string (uiout, "execfile", exec_file);
550 ui_out_spaces (uiout, 1);
551 /* We call get_inferior_args() because we might need to compute
552 the value now. */
553 ui_out_field_string (uiout, "infargs", get_inferior_args ());
554 ui_out_text (uiout, "\n");
555 ui_out_flush (uiout);
556 }
557
558 /* We call get_inferior_args() because we might need to compute
559 the value now. */
560 target_create_inferior (exec_file, get_inferior_args (),
561 environ_vector (inferior_environ), from_tty);
562
563 /* Pass zero for FROM_TTY, because at this point the "run" command
564 has done its thing; now we are setting up the running program. */
565 post_create_inferior (&current_target, 0);
566
567 /* Start the target running. */
568 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
569 }
570
571
572 static void
573 run_command (char *args, int from_tty)
574 {
575 run_command_1 (args, from_tty, 0);
576 }
577
578 static void
579 run_no_args_command (char *args, int from_tty)
580 {
581 char *old_args = set_inferior_args (xstrdup (""));
582 xfree (old_args);
583 }
584 \f
585
586 /* Start the execution of the program up until the beginning of the main
587 program. */
588
589 static void
590 start_command (char *args, int from_tty)
591 {
592 /* Some languages such as Ada need to search inside the program
593 minimal symbols for the location where to put the temporary
594 breakpoint before starting. */
595 if (!have_minimal_symbols ())
596 error (_("No symbol table loaded. Use the \"file\" command."));
597
598 /* Run the program until reaching the main procedure... */
599 run_command_1 (args, from_tty, 1);
600 }
601
602 void
603 continue_command (char *proc_count_exp, int from_tty)
604 {
605 int async_exec = 0;
606 ERROR_NO_INFERIOR;
607
608 /* Find out whether we must run in the background. */
609 if (proc_count_exp != NULL)
610 async_exec = strip_bg_char (&proc_count_exp);
611
612 /* If we must run in the background, but the target can't do it,
613 error out. */
614 if (async_exec && !target_can_async_p ())
615 error (_("Asynchronous execution not supported on this target."));
616
617 /* If we are not asked to run in the bg, then prepare to run in the
618 foreground, synchronously. */
619 if (!async_exec && target_can_async_p ())
620 {
621 /* Simulate synchronous execution */
622 async_disable_stdin ();
623 }
624
625 /* If have argument (besides '&'), set proceed count of breakpoint
626 we stopped at. */
627 if (proc_count_exp != NULL)
628 {
629 bpstat bs = stop_bpstat;
630 int num, stat;
631 int stopped = 0;
632
633 while ((stat = bpstat_num (&bs, &num)) != 0)
634 if (stat > 0)
635 {
636 set_ignore_count (num,
637 parse_and_eval_long (proc_count_exp) - 1,
638 from_tty);
639 /* set_ignore_count prints a message ending with a period.
640 So print two spaces before "Continuing.". */
641 if (from_tty)
642 printf_filtered (" ");
643 stopped = 1;
644 }
645
646 if (!stopped && from_tty)
647 {
648 printf_filtered
649 ("Not stopped at any breakpoint; argument ignored.\n");
650 }
651 }
652
653 if (from_tty)
654 printf_filtered (_("Continuing.\n"));
655
656 clear_proceed_status ();
657
658 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
659 }
660 \f
661 /* Step until outside of current statement. */
662
663 static void
664 step_command (char *count_string, int from_tty)
665 {
666 step_1 (0, 0, count_string);
667 }
668
669 /* Likewise, but skip over subroutine calls as if single instructions. */
670
671 static void
672 next_command (char *count_string, int from_tty)
673 {
674 step_1 (1, 0, count_string);
675 }
676
677 /* Likewise, but step only one instruction. */
678
679 void
680 stepi_command (char *count_string, int from_tty)
681 {
682 step_1 (0, 1, count_string);
683 }
684
685 void
686 nexti_command (char *count_string, int from_tty)
687 {
688 step_1 (1, 1, count_string);
689 }
690
691 static void
692 disable_longjmp_breakpoint_cleanup (void *ignore)
693 {
694 disable_longjmp_breakpoint ();
695 }
696
697 static void
698 step_1 (int skip_subroutines, int single_inst, char *count_string)
699 {
700 int count = 1;
701 struct frame_info *frame;
702 struct cleanup *cleanups = 0;
703 int async_exec = 0;
704
705 ERROR_NO_INFERIOR;
706
707 if (count_string)
708 async_exec = strip_bg_char (&count_string);
709
710 /* If we get a request for running in the bg but the target
711 doesn't support it, error out. */
712 if (async_exec && !target_can_async_p ())
713 error (_("Asynchronous execution not supported on this target."));
714
715 /* If we don't get a request of running in the bg, then we need
716 to simulate synchronous (fg) execution. */
717 if (!async_exec && target_can_async_p ())
718 {
719 /* Simulate synchronous execution */
720 async_disable_stdin ();
721 }
722
723 count = count_string ? parse_and_eval_long (count_string) : 1;
724
725 if (!single_inst || skip_subroutines) /* leave si command alone */
726 {
727 enable_longjmp_breakpoint ();
728 if (!target_can_async_p ())
729 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
730 else
731 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
732 }
733
734 /* In synchronous case, all is well, just use the regular for loop. */
735 if (!target_can_async_p ())
736 {
737 for (; count > 0; count--)
738 {
739 clear_proceed_status ();
740
741 frame = get_current_frame ();
742 if (!frame) /* Avoid coredump here. Why tho? */
743 error (_("No current frame"));
744 step_frame_id = get_frame_id (frame);
745
746 if (!single_inst)
747 {
748 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
749 if (step_range_end == 0)
750 {
751 char *name;
752 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
753 &step_range_end) == 0)
754 error (_("Cannot find bounds of current function"));
755
756 target_terminal_ours ();
757 printf_filtered (_("\
758 Single stepping until exit from function %s, \n\
759 which has no line number information.\n"), name);
760 }
761 }
762 else
763 {
764 /* Say we are stepping, but stop after one insn whatever it does. */
765 step_range_start = step_range_end = 1;
766 if (!skip_subroutines)
767 /* It is stepi.
768 Don't step over function calls, not even to functions lacking
769 line numbers. */
770 step_over_calls = STEP_OVER_NONE;
771 }
772
773 if (skip_subroutines)
774 step_over_calls = STEP_OVER_ALL;
775
776 step_multi = (count > 1);
777 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
778
779 if (!stop_step)
780 break;
781 }
782
783 if (!single_inst || skip_subroutines)
784 do_cleanups (cleanups);
785 return;
786 }
787 /* In case of asynchronous target things get complicated, do only
788 one step for now, before returning control to the event loop. Let
789 the continuation figure out how many other steps we need to do,
790 and handle them one at the time, through step_once(). */
791 else
792 {
793 if (target_can_async_p ())
794 step_once (skip_subroutines, single_inst, count);
795 }
796 }
797
798 /* Called after we are done with one step operation, to check whether
799 we need to step again, before we print the prompt and return control
800 to the user. If count is > 1, we will need to do one more call to
801 proceed(), via step_once(). Basically it is like step_once and
802 step_1_continuation are co-recursive. */
803 static void
804 step_1_continuation (struct continuation_arg *arg)
805 {
806 int count;
807 int skip_subroutines;
808 int single_inst;
809
810 skip_subroutines = arg->data.integer;
811 single_inst = arg->next->data.integer;
812 count = arg->next->next->data.integer;
813
814 if (stop_step)
815 step_once (skip_subroutines, single_inst, count - 1);
816 else
817 if (!single_inst || skip_subroutines)
818 do_exec_cleanups (ALL_CLEANUPS);
819 }
820
821 /* Do just one step operation. If count >1 we will have to set up a
822 continuation to be done after the target stops (after this one
823 step). This is useful to implement the 'step n' kind of commands, in
824 case of asynchronous targets. We had to split step_1 into two parts,
825 one to be done before proceed() and one afterwards. This function is
826 called in case of step n with n>1, after the first step operation has
827 been completed.*/
828 static void
829 step_once (int skip_subroutines, int single_inst, int count)
830 {
831 struct continuation_arg *arg1;
832 struct continuation_arg *arg2;
833 struct continuation_arg *arg3;
834 struct frame_info *frame;
835
836 if (count > 0)
837 {
838 clear_proceed_status ();
839
840 frame = get_current_frame ();
841 if (!frame) /* Avoid coredump here. Why tho? */
842 error (_("No current frame"));
843 step_frame_id = get_frame_id (frame);
844
845 if (!single_inst)
846 {
847 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
848
849 /* If we have no line info, switch to stepi mode. */
850 if (step_range_end == 0 && step_stop_if_no_debug)
851 {
852 step_range_start = step_range_end = 1;
853 }
854 else if (step_range_end == 0)
855 {
856 char *name;
857 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
858 &step_range_end) == 0)
859 error (_("Cannot find bounds of current function"));
860
861 target_terminal_ours ();
862 printf_filtered (_("\
863 Single stepping until exit from function %s, \n\
864 which has no line number information.\n"), name);
865 }
866 }
867 else
868 {
869 /* Say we are stepping, but stop after one insn whatever it does. */
870 step_range_start = step_range_end = 1;
871 if (!skip_subroutines)
872 /* It is stepi.
873 Don't step over function calls, not even to functions lacking
874 line numbers. */
875 step_over_calls = STEP_OVER_NONE;
876 }
877
878 if (skip_subroutines)
879 step_over_calls = STEP_OVER_ALL;
880
881 step_multi = (count > 1);
882 arg1 =
883 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
884 arg2 =
885 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
886 arg3 =
887 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
888 arg1->next = arg2;
889 arg1->data.integer = skip_subroutines;
890 arg2->next = arg3;
891 arg2->data.integer = single_inst;
892 arg3->next = NULL;
893 arg3->data.integer = count;
894 add_intermediate_continuation (step_1_continuation, arg1);
895 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
896 }
897 }
898
899 \f
900 /* Continue program at specified address. */
901
902 static void
903 jump_command (char *arg, int from_tty)
904 {
905 CORE_ADDR addr;
906 struct symtabs_and_lines sals;
907 struct symtab_and_line sal;
908 struct symbol *fn;
909 struct symbol *sfn;
910 int async_exec = 0;
911
912 ERROR_NO_INFERIOR;
913
914 /* Find out whether we must run in the background. */
915 if (arg != NULL)
916 async_exec = strip_bg_char (&arg);
917
918 /* If we must run in the background, but the target can't do it,
919 error out. */
920 if (async_exec && !target_can_async_p ())
921 error (_("Asynchronous execution not supported on this target."));
922
923 if (!arg)
924 error_no_arg (_("starting address"));
925
926 sals = decode_line_spec_1 (arg, 1);
927 if (sals.nelts != 1)
928 {
929 error (_("Unreasonable jump request"));
930 }
931
932 sal = sals.sals[0];
933 xfree (sals.sals);
934
935 if (sal.symtab == 0 && sal.pc == 0)
936 error (_("No source file has been specified."));
937
938 resolve_sal_pc (&sal); /* May error out */
939
940 /* See if we are trying to jump to another function. */
941 fn = get_frame_function (get_current_frame ());
942 sfn = find_pc_function (sal.pc);
943 if (fn != NULL && sfn != fn)
944 {
945 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
946 SYMBOL_PRINT_NAME (fn)))
947 {
948 error (_("Not confirmed."));
949 /* NOTREACHED */
950 }
951 }
952
953 if (sfn != NULL)
954 {
955 fixup_symbol_section (sfn, 0);
956 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
957 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
958 {
959 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
960 {
961 error (_("Not confirmed."));
962 /* NOTREACHED */
963 }
964 }
965 }
966
967 addr = sal.pc;
968
969 if (from_tty)
970 {
971 printf_filtered (_("Continuing at "));
972 fputs_filtered (paddress (addr), gdb_stdout);
973 printf_filtered (".\n");
974 }
975
976 /* If we are not asked to run in the bg, then prepare to run in the
977 foreground, synchronously. */
978 if (!async_exec && target_can_async_p ())
979 {
980 /* Simulate synchronous execution */
981 async_disable_stdin ();
982 }
983
984 clear_proceed_status ();
985 proceed (addr, TARGET_SIGNAL_0, 0);
986 }
987 \f
988
989 /* Go to line or address in current procedure */
990 static void
991 go_command (char *line_no, int from_tty)
992 {
993 if (line_no == (char *) NULL || !*line_no)
994 printf_filtered (GO_USAGE);
995 else
996 {
997 tbreak_command (line_no, from_tty);
998 jump_command (line_no, from_tty);
999 }
1000 }
1001 \f
1002
1003 /* Continue program giving it specified signal. */
1004
1005 static void
1006 signal_command (char *signum_exp, int from_tty)
1007 {
1008 enum target_signal oursig;
1009 int async_exec = 0;
1010
1011 dont_repeat (); /* Too dangerous. */
1012 ERROR_NO_INFERIOR;
1013
1014 /* Find out whether we must run in the background. */
1015 if (signum_exp != NULL)
1016 async_exec = strip_bg_char (&signum_exp);
1017
1018 /* If we must run in the background, but the target can't do it,
1019 error out. */
1020 if (async_exec && !target_can_async_p ())
1021 error (_("Asynchronous execution not supported on this target."));
1022
1023 /* If we are not asked to run in the bg, then prepare to run in the
1024 foreground, synchronously. */
1025 if (!async_exec && target_can_async_p ())
1026 {
1027 /* Simulate synchronous execution. */
1028 async_disable_stdin ();
1029 }
1030
1031 if (!signum_exp)
1032 error_no_arg (_("signal number"));
1033
1034 /* It would be even slicker to make signal names be valid expressions,
1035 (the type could be "enum $signal" or some such), then the user could
1036 assign them to convenience variables. */
1037 oursig = target_signal_from_name (signum_exp);
1038
1039 if (oursig == TARGET_SIGNAL_UNKNOWN)
1040 {
1041 /* No, try numeric. */
1042 int num = parse_and_eval_long (signum_exp);
1043
1044 if (num == 0)
1045 oursig = TARGET_SIGNAL_0;
1046 else
1047 oursig = target_signal_from_command (num);
1048 }
1049
1050 if (from_tty)
1051 {
1052 if (oursig == TARGET_SIGNAL_0)
1053 printf_filtered (_("Continuing with no signal.\n"));
1054 else
1055 printf_filtered (_("Continuing with signal %s.\n"),
1056 target_signal_to_name (oursig));
1057 }
1058
1059 clear_proceed_status ();
1060 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
1061 FIXME: Neither should "signal foo" but when I tried passing
1062 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
1063 tried to track down yet. */
1064 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
1065 }
1066
1067 /* Proceed until we reach a different source line with pc greater than
1068 our current one or exit the function. We skip calls in both cases.
1069
1070 Note that eventually this command should probably be changed so
1071 that only source lines are printed out when we hit the breakpoint
1072 we set. This may involve changes to wait_for_inferior and the
1073 proceed status code. */
1074
1075 static void
1076 until_next_command (int from_tty)
1077 {
1078 struct frame_info *frame;
1079 CORE_ADDR pc;
1080 struct symbol *func;
1081 struct symtab_and_line sal;
1082
1083 clear_proceed_status ();
1084
1085 frame = get_current_frame ();
1086
1087 /* Step until either exited from this function or greater
1088 than the current line (if in symbolic section) or pc (if
1089 not). */
1090
1091 pc = read_pc ();
1092 func = find_pc_function (pc);
1093
1094 if (!func)
1095 {
1096 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1097
1098 if (msymbol == NULL)
1099 error (_("Execution is not within a known function."));
1100
1101 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1102 step_range_end = pc;
1103 }
1104 else
1105 {
1106 sal = find_pc_line (pc, 0);
1107
1108 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1109 step_range_end = sal.end;
1110 }
1111
1112 step_over_calls = STEP_OVER_ALL;
1113 step_frame_id = get_frame_id (frame);
1114
1115 step_multi = 0; /* Only one call to proceed */
1116
1117 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1118 }
1119
1120 static void
1121 until_command (char *arg, int from_tty)
1122 {
1123 int async_exec = 0;
1124
1125 if (!target_has_execution)
1126 error (_("The program is not running."));
1127
1128 /* Find out whether we must run in the background. */
1129 if (arg != NULL)
1130 async_exec = strip_bg_char (&arg);
1131
1132 /* If we must run in the background, but the target can't do it,
1133 error out. */
1134 if (async_exec && !target_can_async_p ())
1135 error (_("Asynchronous execution not supported on this target."));
1136
1137 /* If we are not asked to run in the bg, then prepare to run in the
1138 foreground, synchronously. */
1139 if (!async_exec && target_can_async_p ())
1140 {
1141 /* Simulate synchronous execution */
1142 async_disable_stdin ();
1143 }
1144
1145 if (arg)
1146 until_break_command (arg, from_tty, 0);
1147 else
1148 until_next_command (from_tty);
1149 }
1150
1151 static void
1152 advance_command (char *arg, int from_tty)
1153 {
1154 int async_exec = 0;
1155
1156 if (!target_has_execution)
1157 error (_("The program is not running."));
1158
1159 if (arg == NULL)
1160 error_no_arg (_("a location"));
1161
1162 /* Find out whether we must run in the background. */
1163 if (arg != NULL)
1164 async_exec = strip_bg_char (&arg);
1165
1166 /* If we must run in the background, but the target can't do it,
1167 error out. */
1168 if (async_exec && !target_can_async_p ())
1169 error (_("Asynchronous execution not supported on this target."));
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 until_break_command (arg, from_tty, 1);
1180 }
1181 \f
1182 /* Print the result of a function at the end of a 'finish' command. */
1183
1184 static void
1185 print_return_value (struct type *value_type)
1186 {
1187 struct gdbarch *gdbarch = current_gdbarch;
1188 struct cleanup *old_chain;
1189 struct ui_stream *stb;
1190 struct value *value;
1191
1192 CHECK_TYPEDEF (value_type);
1193 gdb_assert (TYPE_CODE (value_type) != TYPE_CODE_VOID);
1194
1195 /* FIXME: 2003-09-27: When returning from a nested inferior function
1196 call, it's possible (with no help from the architecture vector)
1197 to locate and return/print a "struct return" value. This is just
1198 a more complicated case of what is already being done in in the
1199 inferior function call code. In fact, when inferior function
1200 calls are made async, this will likely be made the norm. */
1201
1202 switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))
1203 {
1204 case RETURN_VALUE_REGISTER_CONVENTION:
1205 case RETURN_VALUE_ABI_RETURNS_ADDRESS:
1206 case RETURN_VALUE_ABI_PRESERVES_ADDRESS:
1207 value = allocate_value (value_type);
1208 gdbarch_return_value (gdbarch, value_type, stop_registers,
1209 value_contents_raw (value), NULL);
1210 break;
1211 case RETURN_VALUE_STRUCT_CONVENTION:
1212 value = NULL;
1213 break;
1214 default:
1215 internal_error (__FILE__, __LINE__, _("bad switch"));
1216 }
1217
1218 if (value)
1219 {
1220 /* Print it. */
1221 stb = ui_out_stream_new (uiout);
1222 old_chain = make_cleanup_ui_out_stream_delete (stb);
1223 ui_out_text (uiout, "Value returned is ");
1224 ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
1225 record_latest_value (value));
1226 ui_out_text (uiout, " = ");
1227 value_print (value, stb->stream, 0, Val_no_prettyprint);
1228 ui_out_field_stream (uiout, "return-value", stb);
1229 ui_out_text (uiout, "\n");
1230 do_cleanups (old_chain);
1231 }
1232 else
1233 {
1234 ui_out_text (uiout, "Value returned has type: ");
1235 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1236 ui_out_text (uiout, ".");
1237 ui_out_text (uiout, " Cannot determine contents\n");
1238 }
1239 }
1240
1241 /* Stuff that needs to be done by the finish command after the target
1242 has stopped. In asynchronous mode, we wait for the target to stop
1243 in the call to poll or select in the event loop, so it is
1244 impossible to do all the stuff as part of the finish_command
1245 function itself. The only chance we have to complete this command
1246 is in fetch_inferior_event, which is called by the event loop as
1247 soon as it detects that the target has stopped. This function is
1248 called via the cmd_continuation pointer. */
1249
1250 static void
1251 finish_command_continuation (struct continuation_arg *arg)
1252 {
1253 struct symbol *function;
1254 struct breakpoint *breakpoint;
1255 struct cleanup *cleanups;
1256
1257 breakpoint = (struct breakpoint *) arg->data.pointer;
1258 function = (struct symbol *) arg->next->data.pointer;
1259 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1260
1261 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1262 && function != NULL)
1263 {
1264 struct type *value_type;
1265
1266 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1267 if (!value_type)
1268 internal_error (__FILE__, __LINE__,
1269 _("finish_command: function has no target type"));
1270
1271 if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
1272 print_return_value (value_type);
1273 }
1274
1275 do_exec_cleanups (cleanups);
1276 }
1277
1278 /* "finish": Set a temporary breakpoint at the place the selected
1279 frame will return to, then continue. */
1280
1281 static void
1282 finish_command (char *arg, int from_tty)
1283 {
1284 struct symtab_and_line sal;
1285 struct frame_info *frame;
1286 struct symbol *function;
1287 struct breakpoint *breakpoint;
1288 struct cleanup *old_chain;
1289 struct continuation_arg *arg1, *arg2, *arg3;
1290
1291 int async_exec = 0;
1292
1293 /* Find out whether we must run in the background. */
1294 if (arg != NULL)
1295 async_exec = strip_bg_char (&arg);
1296
1297 /* If we must run in the background, but the target can't do it,
1298 error out. */
1299 if (async_exec && !target_can_async_p ())
1300 error (_("Asynchronous execution not supported on this target."));
1301
1302 /* If we are not asked to run in the bg, then prepare to run in the
1303 foreground, synchronously. */
1304 if (!async_exec && target_can_async_p ())
1305 {
1306 /* Simulate synchronous execution. */
1307 async_disable_stdin ();
1308 }
1309
1310 if (arg)
1311 error (_("The \"finish\" command does not take any arguments."));
1312 if (!target_has_execution)
1313 error (_("The program is not running."));
1314
1315 frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
1316 if (frame == 0)
1317 error (_("\"finish\" not meaningful in the outermost frame."));
1318
1319 clear_proceed_status ();
1320
1321 sal = find_pc_line (get_frame_pc (frame), 0);
1322 sal.pc = get_frame_pc (frame);
1323
1324 breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish);
1325
1326 if (!target_can_async_p ())
1327 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1328 else
1329 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1330
1331 /* Find the function we will return from. */
1332
1333 function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
1334
1335 /* Print info on the selected frame, including level number but not
1336 source. */
1337 if (from_tty)
1338 {
1339 printf_filtered (_("Run till exit from "));
1340 print_stack_frame (get_selected_frame (NULL), 1, LOCATION);
1341 }
1342
1343 proceed_to_finish = 1; /* We want stop_registers, please... */
1344 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1345
1346 /* If running asynchronously and the target support asynchronous
1347 execution, set things up for the rest of the finish command to be
1348 completed later on, when gdb has detected that the target has
1349 stopped, in fetch_inferior_event.
1350 Setup it only after proceed, so that if proceed throws, we don't
1351 set continuation. */
1352 if (target_can_async_p ())
1353 {
1354 arg1 =
1355 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1356 arg2 =
1357 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1358 arg3 =
1359 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1360 arg1->next = arg2;
1361 arg2->next = arg3;
1362 arg3->next = NULL;
1363 arg1->data.pointer = breakpoint;
1364 arg2->data.pointer = function;
1365 arg3->data.pointer = old_chain;
1366 add_continuation (finish_command_continuation, arg1);
1367 }
1368
1369 /* Do this only if not running asynchronously or if the target
1370 cannot do async execution. Otherwise, complete this command when
1371 the target actually stops, in fetch_inferior_event. */
1372 if (!target_can_async_p ())
1373 {
1374 /* Did we stop at our breakpoint? */
1375 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1376 && function != NULL)
1377 {
1378 struct type *value_type;
1379
1380 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1381 if (!value_type)
1382 internal_error (__FILE__, __LINE__,
1383 _("finish_command: function has no target type"));
1384
1385 if (TYPE_CODE (value_type) != TYPE_CODE_VOID)
1386 print_return_value (value_type);
1387 }
1388
1389 do_cleanups (old_chain);
1390 }
1391 }
1392 \f
1393
1394 static void
1395 program_info (char *args, int from_tty)
1396 {
1397 bpstat bs = stop_bpstat;
1398 int num;
1399 int stat = bpstat_num (&bs, &num);
1400
1401 if (!target_has_execution)
1402 {
1403 printf_filtered (_("The program being debugged is not being run.\n"));
1404 return;
1405 }
1406
1407 target_files_info ();
1408 printf_filtered (_("Program stopped at %s.\n"),
1409 hex_string ((unsigned long) stop_pc));
1410 if (stop_step)
1411 printf_filtered (_("It stopped after being stepped.\n"));
1412 else if (stat != 0)
1413 {
1414 /* There may be several breakpoints in the same place, so this
1415 isn't as strange as it seems. */
1416 while (stat != 0)
1417 {
1418 if (stat < 0)
1419 {
1420 printf_filtered (_("\
1421 It stopped at a breakpoint that has since been deleted.\n"));
1422 }
1423 else
1424 printf_filtered (_("It stopped at breakpoint %d.\n"), num);
1425 stat = bpstat_num (&bs, &num);
1426 }
1427 }
1428 else if (stop_signal != TARGET_SIGNAL_0)
1429 {
1430 printf_filtered (_("It stopped with signal %s, %s.\n"),
1431 target_signal_to_name (stop_signal),
1432 target_signal_to_string (stop_signal));
1433 }
1434
1435 if (!from_tty)
1436 {
1437 printf_filtered (_("\
1438 Type \"info stack\" or \"info registers\" for more information.\n"));
1439 }
1440 }
1441 \f
1442 static void
1443 environment_info (char *var, int from_tty)
1444 {
1445 if (var)
1446 {
1447 char *val = get_in_environ (inferior_environ, var);
1448 if (val)
1449 {
1450 puts_filtered (var);
1451 puts_filtered (" = ");
1452 puts_filtered (val);
1453 puts_filtered ("\n");
1454 }
1455 else
1456 {
1457 puts_filtered ("Environment variable \"");
1458 puts_filtered (var);
1459 puts_filtered ("\" not defined.\n");
1460 }
1461 }
1462 else
1463 {
1464 char **vector = environ_vector (inferior_environ);
1465 while (*vector)
1466 {
1467 puts_filtered (*vector++);
1468 puts_filtered ("\n");
1469 }
1470 }
1471 }
1472
1473 static void
1474 set_environment_command (char *arg, int from_tty)
1475 {
1476 char *p, *val, *var;
1477 int nullset = 0;
1478
1479 if (arg == 0)
1480 error_no_arg (_("environment variable and value"));
1481
1482 /* Find seperation between variable name and value */
1483 p = (char *) strchr (arg, '=');
1484 val = (char *) strchr (arg, ' ');
1485
1486 if (p != 0 && val != 0)
1487 {
1488 /* We have both a space and an equals. If the space is before the
1489 equals, walk forward over the spaces til we see a nonspace
1490 (possibly the equals). */
1491 if (p > val)
1492 while (*val == ' ')
1493 val++;
1494
1495 /* Now if the = is after the char following the spaces,
1496 take the char following the spaces. */
1497 if (p > val)
1498 p = val - 1;
1499 }
1500 else if (val != 0 && p == 0)
1501 p = val;
1502
1503 if (p == arg)
1504 error_no_arg (_("environment variable to set"));
1505
1506 if (p == 0 || p[1] == 0)
1507 {
1508 nullset = 1;
1509 if (p == 0)
1510 p = arg + strlen (arg); /* So that savestring below will work */
1511 }
1512 else
1513 {
1514 /* Not setting variable value to null */
1515 val = p + 1;
1516 while (*val == ' ' || *val == '\t')
1517 val++;
1518 }
1519
1520 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1521 p--;
1522
1523 var = savestring (arg, p - arg);
1524 if (nullset)
1525 {
1526 printf_filtered (_("\
1527 Setting environment variable \"%s\" to null value.\n"),
1528 var);
1529 set_in_environ (inferior_environ, var, "");
1530 }
1531 else
1532 set_in_environ (inferior_environ, var, val);
1533 xfree (var);
1534 }
1535
1536 static void
1537 unset_environment_command (char *var, int from_tty)
1538 {
1539 if (var == 0)
1540 {
1541 /* If there is no argument, delete all environment variables.
1542 Ask for confirmation if reading from the terminal. */
1543 if (!from_tty || query (_("Delete all environment variables? ")))
1544 {
1545 free_environ (inferior_environ);
1546 inferior_environ = make_environ ();
1547 }
1548 }
1549 else
1550 unset_in_environ (inferior_environ, var);
1551 }
1552
1553 /* Handle the execution path (PATH variable) */
1554
1555 static const char path_var_name[] = "PATH";
1556
1557 static void
1558 path_info (char *args, int from_tty)
1559 {
1560 puts_filtered ("Executable and object file path: ");
1561 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1562 puts_filtered ("\n");
1563 }
1564
1565 /* Add zero or more directories to the front of the execution path. */
1566
1567 static void
1568 path_command (char *dirname, int from_tty)
1569 {
1570 char *exec_path;
1571 char *env;
1572 dont_repeat ();
1573 env = get_in_environ (inferior_environ, path_var_name);
1574 /* Can be null if path is not set */
1575 if (!env)
1576 env = "";
1577 exec_path = xstrdup (env);
1578 mod_path (dirname, &exec_path);
1579 set_in_environ (inferior_environ, path_var_name, exec_path);
1580 xfree (exec_path);
1581 if (from_tty)
1582 path_info ((char *) NULL, from_tty);
1583 }
1584 \f
1585
1586 /* Print out the machine register regnum. If regnum is -1, print all
1587 registers (print_all == 1) or all non-float and non-vector
1588 registers (print_all == 0).
1589
1590 For most machines, having all_registers_info() print the
1591 register(s) one per line is good enough. If a different format is
1592 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1593 regs), or there is an existing convention for showing all the
1594 registers, define the architecture method PRINT_REGISTERS_INFO to
1595 provide that format. */
1596
1597 void
1598 default_print_registers_info (struct gdbarch *gdbarch,
1599 struct ui_file *file,
1600 struct frame_info *frame,
1601 int regnum, int print_all)
1602 {
1603 int i;
1604 const int numregs = gdbarch_num_regs (gdbarch)
1605 + gdbarch_num_pseudo_regs (gdbarch);
1606 gdb_byte buffer[MAX_REGISTER_SIZE];
1607
1608 for (i = 0; i < numregs; i++)
1609 {
1610 /* Decide between printing all regs, non-float / vector regs, or
1611 specific reg. */
1612 if (regnum == -1)
1613 {
1614 if (print_all)
1615 {
1616 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1617 continue;
1618 }
1619 else
1620 {
1621 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1622 continue;
1623 }
1624 }
1625 else
1626 {
1627 if (i != regnum)
1628 continue;
1629 }
1630
1631 /* If the register name is empty, it is undefined for this
1632 processor, so don't display anything. */
1633 if (gdbarch_register_name (gdbarch, i) == NULL
1634 || *(gdbarch_register_name (gdbarch, i)) == '\0')
1635 continue;
1636
1637 fputs_filtered (gdbarch_register_name (gdbarch, i), file);
1638 print_spaces_filtered (15 - strlen (gdbarch_register_name
1639 (gdbarch, i)), file);
1640
1641 /* Get the data in raw format. */
1642 if (! frame_register_read (frame, i, buffer))
1643 {
1644 fprintf_filtered (file, "*value not available*\n");
1645 continue;
1646 }
1647
1648 /* If virtual format is floating, print it that way, and in raw
1649 hex. */
1650 if (TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_FLT
1651 || TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_DECFLOAT)
1652 {
1653 int j;
1654
1655 val_print (register_type (gdbarch, i), buffer, 0, 0,
1656 file, 0, 1, 0, Val_pretty_default);
1657
1658 fprintf_filtered (file, "\t(raw 0x");
1659 for (j = 0; j < register_size (gdbarch, i); j++)
1660 {
1661 int idx;
1662 if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
1663 idx = j;
1664 else
1665 idx = register_size (gdbarch, i) - 1 - j;
1666 fprintf_filtered (file, "%02x", (unsigned char) buffer[idx]);
1667 }
1668 fprintf_filtered (file, ")");
1669 }
1670 else
1671 {
1672 /* Print the register in hex. */
1673 val_print (register_type (gdbarch, i), buffer, 0, 0,
1674 file, 'x', 1, 0, Val_pretty_default);
1675 /* If not a vector register, print it also according to its
1676 natural format. */
1677 if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
1678 {
1679 fprintf_filtered (file, "\t");
1680 val_print (register_type (gdbarch, i), buffer, 0, 0,
1681 file, 0, 1, 0, Val_pretty_default);
1682 }
1683 }
1684
1685 fprintf_filtered (file, "\n");
1686 }
1687 }
1688
1689 void
1690 registers_info (char *addr_exp, int fpregs)
1691 {
1692 struct frame_info *frame;
1693 struct gdbarch *gdbarch;
1694 int regnum, numregs;
1695 char *end;
1696
1697 if (!target_has_registers)
1698 error (_("The program has no registers now."));
1699 frame = get_selected_frame (NULL);
1700 gdbarch = get_frame_arch (frame);
1701
1702 if (!addr_exp)
1703 {
1704 gdbarch_print_registers_info (gdbarch, gdb_stdout,
1705 frame, -1, fpregs);
1706 return;
1707 }
1708
1709 while (*addr_exp != '\0')
1710 {
1711 char *start;
1712 const char *end;
1713
1714 /* Keep skipping leading white space. */
1715 if (isspace ((*addr_exp)))
1716 {
1717 addr_exp++;
1718 continue;
1719 }
1720
1721 /* Discard any leading ``$''. Check that there is something
1722 resembling a register following it. */
1723 if (addr_exp[0] == '$')
1724 addr_exp++;
1725 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1726 error (_("Missing register name"));
1727
1728 /* Find the start/end of this register name/num/group. */
1729 start = addr_exp;
1730 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1731 addr_exp++;
1732 end = addr_exp;
1733
1734 /* Figure out what we've found and display it. */
1735
1736 /* A register name? */
1737 {
1738 int regnum = frame_map_name_to_regnum (frame, start, end - start);
1739 if (regnum >= 0)
1740 {
1741 /* User registers lie completely outside of the range of
1742 normal registers. Catch them early so that the target
1743 never sees them. */
1744 if (regnum >= gdbarch_num_regs (gdbarch)
1745 + gdbarch_num_pseudo_regs (gdbarch))
1746 {
1747 struct value *val = value_of_user_reg (regnum, frame);
1748
1749 printf_filtered ("%s: ", start);
1750 print_scalar_formatted (value_contents (val),
1751 check_typedef (value_type (val)),
1752 'x', 0, gdb_stdout);
1753 printf_filtered ("\n");
1754 }
1755 else
1756 gdbarch_print_registers_info (gdbarch, gdb_stdout,
1757 frame, regnum, fpregs);
1758 continue;
1759 }
1760 }
1761
1762 /* A register number? (how portable is this one?). */
1763 {
1764 char *endptr;
1765 int regnum = strtol (start, &endptr, 0);
1766 if (endptr == end
1767 && regnum >= 0
1768 && regnum < gdbarch_num_regs (gdbarch)
1769 + gdbarch_num_pseudo_regs (gdbarch))
1770 {
1771 gdbarch_print_registers_info (gdbarch, gdb_stdout,
1772 frame, regnum, fpregs);
1773 continue;
1774 }
1775 }
1776
1777 /* A register group? */
1778 {
1779 struct reggroup *group;
1780 for (group = reggroup_next (gdbarch, NULL);
1781 group != NULL;
1782 group = reggroup_next (gdbarch, group))
1783 {
1784 /* Don't bother with a length check. Should the user
1785 enter a short register group name, go with the first
1786 group that matches. */
1787 if (strncmp (start, reggroup_name (group), end - start) == 0)
1788 break;
1789 }
1790 if (group != NULL)
1791 {
1792 int regnum;
1793 for (regnum = 0;
1794 regnum < gdbarch_num_regs (gdbarch)
1795 + gdbarch_num_pseudo_regs (gdbarch);
1796 regnum++)
1797 {
1798 if (gdbarch_register_reggroup_p (gdbarch, regnum, group))
1799 gdbarch_print_registers_info (gdbarch,
1800 gdb_stdout, frame,
1801 regnum, fpregs);
1802 }
1803 continue;
1804 }
1805 }
1806
1807 /* Nothing matched. */
1808 error (_("Invalid register `%.*s'"), (int) (end - start), start);
1809 }
1810 }
1811
1812 void
1813 all_registers_info (char *addr_exp, int from_tty)
1814 {
1815 registers_info (addr_exp, 1);
1816 }
1817
1818 static void
1819 nofp_registers_info (char *addr_exp, int from_tty)
1820 {
1821 registers_info (addr_exp, 0);
1822 }
1823
1824 static void
1825 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
1826 struct frame_info *frame, const char *args)
1827 {
1828 if (gdbarch_print_vector_info_p (gdbarch))
1829 gdbarch_print_vector_info (gdbarch, file, frame, args);
1830 else
1831 {
1832 int regnum;
1833 int printed_something = 0;
1834
1835 for (regnum = 0;
1836 regnum < gdbarch_num_regs (gdbarch)
1837 + gdbarch_num_pseudo_regs (gdbarch);
1838 regnum++)
1839 {
1840 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
1841 {
1842 printed_something = 1;
1843 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1844 }
1845 }
1846 if (!printed_something)
1847 fprintf_filtered (file, "No vector information\n");
1848 }
1849 }
1850
1851 static void
1852 vector_info (char *args, int from_tty)
1853 {
1854 if (!target_has_registers)
1855 error (_("The program has no registers now."));
1856
1857 print_vector_info (current_gdbarch, gdb_stdout,
1858 get_selected_frame (NULL), args);
1859 }
1860 \f
1861
1862 /*
1863 * TODO:
1864 * Should save/restore the tty state since it might be that the
1865 * program to be debugged was started on this tty and it wants
1866 * the tty in some state other than what we want. If it's running
1867 * on another terminal or without a terminal, then saving and
1868 * restoring the tty state is a harmless no-op.
1869 * This only needs to be done if we are attaching to a process.
1870 */
1871
1872 /*
1873 attach_command --
1874 takes a program started up outside of gdb and ``attaches'' to it.
1875 This stops it cold in its tracks and allows us to start debugging it.
1876 and wait for the trace-trap that results from attaching. */
1877
1878 static void
1879 attach_command_post_wait (char *args, int from_tty, int async_exec)
1880 {
1881 char *exec_file;
1882 char *full_exec_path = NULL;
1883
1884 stop_soon = NO_STOP_QUIETLY;
1885
1886 /* If no exec file is yet known, try to determine it from the
1887 process itself. */
1888 exec_file = (char *) get_exec_file (0);
1889 if (!exec_file)
1890 {
1891 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
1892 if (exec_file)
1893 {
1894 /* It's possible we don't have a full path, but rather just a
1895 filename. Some targets, such as HP-UX, don't provide the
1896 full path, sigh.
1897
1898 Attempt to qualify the filename against the source path.
1899 (If that fails, we'll just fall back on the original
1900 filename. Not much more we can do...)
1901 */
1902 if (!source_full_path_of (exec_file, &full_exec_path))
1903 full_exec_path = savestring (exec_file, strlen (exec_file));
1904
1905 exec_file_attach (full_exec_path, from_tty);
1906 symbol_file_add_main (full_exec_path, from_tty);
1907 }
1908 }
1909 else
1910 {
1911 reopen_exec_file ();
1912 reread_symbols ();
1913 }
1914
1915 /* Take any necessary post-attaching actions for this platform. */
1916 target_post_attach (PIDGET (inferior_ptid));
1917
1918 post_create_inferior (&current_target, from_tty);
1919
1920 /* Install inferior's terminal modes. */
1921 target_terminal_inferior ();
1922
1923 if (async_exec)
1924 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_0, 0);
1925 else
1926 {
1927 if (target_can_async_p ())
1928 async_enable_stdin ();
1929 normal_stop ();
1930 if (deprecated_attach_hook)
1931 deprecated_attach_hook ();
1932 }
1933 }
1934
1935 static void
1936 attach_command_continuation (struct continuation_arg *arg)
1937 {
1938 char *args;
1939 int from_tty;
1940 int async_exec;
1941
1942 args = (char *) arg->data.pointer;
1943 from_tty = arg->next->data.integer;
1944 async_exec = arg->next->next->data.integer;
1945
1946 attach_command_post_wait (args, from_tty, async_exec);
1947 }
1948
1949 void
1950 attach_command (char *args, int from_tty)
1951 {
1952 char *exec_file;
1953 char *full_exec_path = NULL;
1954 int async_exec = 0;
1955
1956 dont_repeat (); /* Not for the faint of heart */
1957
1958 if (target_has_execution)
1959 {
1960 if (query ("A program is being debugged already. Kill it? "))
1961 target_kill ();
1962 else
1963 error (_("Not killed."));
1964 }
1965
1966 /* Clean up any leftovers from other runs. Some other things from
1967 this function should probably be moved into target_pre_inferior. */
1968 target_pre_inferior (from_tty);
1969
1970 /* Clear out solib state. Otherwise the solib state of the previous
1971 inferior might have survived and is entirely wrong for the new
1972 target. This has been observed on GNU/Linux using glibc 2.3. How
1973 to reproduce:
1974
1975 bash$ ./foo&
1976 [1] 4711
1977 bash$ ./foo&
1978 [1] 4712
1979 bash$ gdb ./foo
1980 [...]
1981 (gdb) attach 4711
1982 (gdb) detach
1983 (gdb) attach 4712
1984 Cannot access memory at address 0xdeadbeef
1985 */
1986 clear_solib ();
1987
1988 if (args)
1989 {
1990 async_exec = strip_bg_char (&args);
1991
1992 /* If we get a request for running in the bg but the target
1993 doesn't support it, error out. */
1994 if (async_exec && !target_can_async_p ())
1995 error (_("Asynchronous execution not supported on this target."));
1996 }
1997
1998 /* If we don't get a request of running in the bg, then we need
1999 to simulate synchronous (fg) execution. */
2000 if (!async_exec && target_can_async_p ())
2001 {
2002 /* Simulate synchronous execution */
2003 async_disable_stdin ();
2004 }
2005
2006 target_attach (args, from_tty);
2007
2008 /* Set up the "saved terminal modes" of the inferior
2009 based on what modes we are starting it with. */
2010 target_terminal_init ();
2011
2012 /* Set up execution context to know that we should return from
2013 wait_for_inferior as soon as the target reports a stop. */
2014 init_wait_for_inferior ();
2015 clear_proceed_status ();
2016
2017 /* No traps are generated when attaching to inferior under Mach 3
2018 or GNU hurd. */
2019 #ifndef ATTACH_NO_WAIT
2020 /* Careful here. See comments in inferior.h. Basically some OSes
2021 don't ignore SIGSTOPs on continue requests anymore. We need a
2022 way for handle_inferior_event to reset the stop_signal variable
2023 after an attach, and this is what STOP_QUIETLY_NO_SIGSTOP is for. */
2024 stop_soon = STOP_QUIETLY_NO_SIGSTOP;
2025
2026 if (target_can_async_p ())
2027 {
2028 /* sync_execution mode. Wait for stop. */
2029 struct continuation_arg *arg1, *arg2, *arg3;
2030
2031 arg1 =
2032 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
2033 arg2 =
2034 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
2035 arg3 =
2036 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
2037 arg1->next = arg2;
2038 arg2->next = arg3;
2039 arg3->next = NULL;
2040 arg1->data.pointer = args;
2041 arg2->data.integer = from_tty;
2042 arg3->data.integer = async_exec;
2043 add_continuation (attach_command_continuation, arg1);
2044 return;
2045 }
2046
2047 wait_for_inferior (0);
2048 #endif
2049
2050 attach_command_post_wait (args, from_tty, async_exec);
2051 }
2052
2053 /*
2054 * detach_command --
2055 * takes a program previously attached to and detaches it.
2056 * The program resumes execution and will no longer stop
2057 * on signals, etc. We better not have left any breakpoints
2058 * in the program or it'll die when it hits one. For this
2059 * to work, it may be necessary for the process to have been
2060 * previously attached. It *might* work if the program was
2061 * started via the normal ptrace (PTRACE_TRACEME).
2062 */
2063
2064 static void
2065 detach_command (char *args, int from_tty)
2066 {
2067 dont_repeat (); /* Not for the faint of heart. */
2068 target_detach (args, from_tty);
2069 no_shared_libraries (NULL, from_tty);
2070 if (deprecated_detach_hook)
2071 deprecated_detach_hook ();
2072 }
2073
2074 /* Disconnect from the current target without resuming it (leaving it
2075 waiting for a debugger).
2076
2077 We'd better not have left any breakpoints in the program or the
2078 next debugger will get confused. Currently only supported for some
2079 remote targets, since the normal attach mechanisms don't work on
2080 stopped processes on some native platforms (e.g. GNU/Linux). */
2081
2082 static void
2083 disconnect_command (char *args, int from_tty)
2084 {
2085 dont_repeat (); /* Not for the faint of heart */
2086 target_disconnect (args, from_tty);
2087 no_shared_libraries (NULL, from_tty);
2088 if (deprecated_detach_hook)
2089 deprecated_detach_hook ();
2090 }
2091
2092 /* Stop the execution of the target while running in async mode, in
2093 the backgound. */
2094 void
2095 interrupt_target_command (char *args, int from_tty)
2096 {
2097 if (target_can_async_p ())
2098 {
2099 dont_repeat (); /* Not for the faint of heart */
2100 target_stop ();
2101 }
2102 }
2103
2104 static void
2105 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
2106 struct frame_info *frame, const char *args)
2107 {
2108 if (gdbarch_print_float_info_p (gdbarch))
2109 gdbarch_print_float_info (gdbarch, file, frame, args);
2110 else
2111 {
2112 int regnum;
2113 int printed_something = 0;
2114
2115 for (regnum = 0;
2116 regnum < gdbarch_num_regs (gdbarch)
2117 + gdbarch_num_pseudo_regs (gdbarch);
2118 regnum++)
2119 {
2120 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
2121 {
2122 printed_something = 1;
2123 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
2124 }
2125 }
2126 if (!printed_something)
2127 fprintf_filtered (file, "\
2128 No floating-point info available for this processor.\n");
2129 }
2130 }
2131
2132 static void
2133 float_info (char *args, int from_tty)
2134 {
2135 if (!target_has_registers)
2136 error (_("The program has no registers now."));
2137
2138 print_float_info (current_gdbarch, gdb_stdout,
2139 get_selected_frame (NULL), args);
2140 }
2141 \f
2142 static void
2143 unset_command (char *args, int from_tty)
2144 {
2145 printf_filtered (_("\
2146 \"unset\" must be followed by the name of an unset subcommand.\n"));
2147 help_list (unsetlist, "unset ", -1, gdb_stdout);
2148 }
2149
2150 void
2151 _initialize_infcmd (void)
2152 {
2153 struct cmd_list_element *c = NULL;
2154
2155 /* add the filename of the terminal connected to inferior I/O */
2156 add_setshow_filename_cmd ("inferior-tty", class_run,
2157 &inferior_io_terminal, _("\
2158 Set terminal for future runs of program being debugged."), _("\
2159 Show terminal for future runs of program being debugged."), _("\
2160 Usage: set inferior-tty /dev/pts/1"), NULL, NULL, &setlist, &showlist);
2161 add_com_alias ("tty", "set inferior-tty", class_alias, 0);
2162
2163 add_setshow_optional_filename_cmd ("args", class_run,
2164 &inferior_args, _("\
2165 Set argument list to give program being debugged when it is started."), _("\
2166 Show argument list to give program being debugged when it is started."), _("\
2167 Follow this command with any number of args, to be passed to the program."),
2168 notice_args_set,
2169 notice_args_read,
2170 &setlist, &showlist);
2171
2172 c = add_cmd ("environment", no_class, environment_info, _("\
2173 The environment to give the program, or one variable's value.\n\
2174 With an argument VAR, prints the value of environment variable VAR to\n\
2175 give the program being debugged. With no arguments, prints the entire\n\
2176 environment to be given to the program."), &showlist);
2177 set_cmd_completer (c, noop_completer);
2178
2179 add_prefix_cmd ("unset", no_class, unset_command,
2180 _("Complement to certain \"set\" commands."),
2181 &unsetlist, "unset ", 0, &cmdlist);
2182
2183 c = add_cmd ("environment", class_run, unset_environment_command, _("\
2184 Cancel environment variable VAR for the program.\n\
2185 This does not affect the program until the next \"run\" command."),
2186 &unsetlist);
2187 set_cmd_completer (c, noop_completer);
2188
2189 c = add_cmd ("environment", class_run, set_environment_command, _("\
2190 Set environment variable value to give the program.\n\
2191 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2192 VALUES of environment variables are uninterpreted strings.\n\
2193 This does not affect the program until the next \"run\" command."),
2194 &setlist);
2195 set_cmd_completer (c, noop_completer);
2196
2197 c = add_com ("path", class_files, path_command, _("\
2198 Add directory DIR(s) to beginning of search path for object files.\n\
2199 $cwd in the path means the current working directory.\n\
2200 This path is equivalent to the $PATH shell variable. It is a list of\n\
2201 directories, separated by colons. These directories are searched to find\n\
2202 fully linked executable files and separately compiled object files as needed."));
2203 set_cmd_completer (c, filename_completer);
2204
2205 c = add_cmd ("paths", no_class, path_info, _("\
2206 Current search path for finding object files.\n\
2207 $cwd in the path means the current working directory.\n\
2208 This path is equivalent to the $PATH shell variable. It is a list of\n\
2209 directories, separated by colons. These directories are searched to find\n\
2210 fully linked executable files and separately compiled object files as needed."),
2211 &showlist);
2212 set_cmd_completer (c, noop_completer);
2213
2214 add_com ("attach", class_run, attach_command, _("\
2215 Attach to a process or file outside of GDB.\n\
2216 This command attaches to another target, of the same type as your last\n\
2217 \"target\" command (\"info files\" will show your target stack).\n\
2218 The command may take as argument a process id or a device file.\n\
2219 For a process id, you must have permission to send the process a signal,\n\
2220 and it must have the same effective uid as the debugger.\n\
2221 When using \"attach\" with a process id, the debugger finds the\n\
2222 program running in the process, looking first in the current working\n\
2223 directory, or (if not found there) using the source file search path\n\
2224 (see the \"directory\" command). You can also use the \"file\" command\n\
2225 to specify the program, and to load its symbol table."));
2226
2227 add_prefix_cmd ("detach", class_run, detach_command, _("\
2228 Detach a process or file previously attached.\n\
2229 If a process, it is no longer traced, and it continues its execution. If\n\
2230 you were debugging a file, the file is closed and gdb no longer accesses it."),
2231 &detachlist, "detach ", 0, &cmdlist);
2232
2233 add_com ("disconnect", class_run, disconnect_command, _("\
2234 Disconnect from a target.\n\
2235 The target will wait for another debugger to connect. Not available for\n\
2236 all targets."));
2237
2238 add_com ("signal", class_run, signal_command, _("\
2239 Continue program giving it signal specified by the argument.\n\
2240 An argument of \"0\" means continue program without giving it a signal."));
2241
2242 add_com ("stepi", class_run, stepi_command, _("\
2243 Step one instruction exactly.\n\
2244 Argument N means do this N times (or till program stops for another reason)."));
2245 add_com_alias ("si", "stepi", class_alias, 0);
2246
2247 add_com ("nexti", class_run, nexti_command, _("\
2248 Step one instruction, but proceed through subroutine calls.\n\
2249 Argument N means do this N times (or till program stops for another reason)."));
2250 add_com_alias ("ni", "nexti", class_alias, 0);
2251
2252 add_com ("finish", class_run, finish_command, _("\
2253 Execute until selected stack frame returns.\n\
2254 Upon return, the value returned is printed and put in the value history."));
2255
2256 add_com ("next", class_run, next_command, _("\
2257 Step program, proceeding through subroutine calls.\n\
2258 Like the \"step\" command as long as subroutine calls do not happen;\n\
2259 when they do, the call is treated as one instruction.\n\
2260 Argument N means do this N times (or till program stops for another reason)."));
2261 add_com_alias ("n", "next", class_run, 1);
2262 if (xdb_commands)
2263 add_com_alias ("S", "next", class_run, 1);
2264
2265 add_com ("step", class_run, step_command, _("\
2266 Step program until it reaches a different source line.\n\
2267 Argument N means do this N times (or till program stops for another reason)."));
2268 add_com_alias ("s", "step", class_run, 1);
2269
2270 c = add_com ("until", class_run, until_command, _("\
2271 Execute until the program reaches a source line greater than the current\n\
2272 or a specified location (same args as break command) within the current frame."));
2273 set_cmd_completer (c, location_completer);
2274 add_com_alias ("u", "until", class_run, 1);
2275
2276 c = add_com ("advance", class_run, advance_command, _("\
2277 Continue the program up to the given location (same form as args for break command).\n\
2278 Execution will also stop upon exit from the current stack frame."));
2279 set_cmd_completer (c, location_completer);
2280
2281 c = add_com ("jump", class_run, jump_command, _("\
2282 Continue program being debugged at specified line or address.\n\
2283 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2284 for an address to start at."));
2285 set_cmd_completer (c, location_completer);
2286
2287 if (xdb_commands)
2288 {
2289 c = add_com ("go", class_run, go_command, _("\
2290 Usage: go <location>\n\
2291 Continue program being debugged, stopping at specified line or \n\
2292 address.\n\
2293 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2294 expression for an address to start at.\n\
2295 This command is a combination of tbreak and jump."));
2296 set_cmd_completer (c, location_completer);
2297 }
2298
2299 if (xdb_commands)
2300 add_com_alias ("g", "go", class_run, 1);
2301
2302 add_com ("continue", class_run, continue_command, _("\
2303 Continue program being debugged, after signal or breakpoint.\n\
2304 If proceeding from breakpoint, a number N may be used as an argument,\n\
2305 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2306 the breakpoint won't break until the Nth time it is reached)."));
2307 add_com_alias ("c", "cont", class_run, 1);
2308 add_com_alias ("fg", "cont", class_run, 1);
2309
2310 c = add_com ("run", class_run, run_command, _("\
2311 Start debugged program. You may specify arguments to give it.\n\
2312 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2313 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2314 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2315 To cancel previous arguments and run with no arguments,\n\
2316 use \"set args\" without arguments."));
2317 set_cmd_completer (c, filename_completer);
2318 add_com_alias ("r", "run", class_run, 1);
2319 if (xdb_commands)
2320 add_com ("R", class_run, run_no_args_command,
2321 _("Start debugged program with no arguments."));
2322
2323 c = add_com ("start", class_run, start_command, _("\
2324 Run the debugged program until the beginning of the main procedure.\n\
2325 You may specify arguments to give to your program, just as with the\n\
2326 \"run\" command."));
2327 set_cmd_completer (c, filename_completer);
2328
2329 add_com ("interrupt", class_run, interrupt_target_command,
2330 _("Interrupt the execution of the debugged program."));
2331
2332 add_info ("registers", nofp_registers_info, _("\
2333 List of integer registers and their contents, for selected stack frame.\n\
2334 Register name as argument means describe only that register."));
2335 add_info_alias ("r", "registers", 1);
2336
2337 if (xdb_commands)
2338 add_com ("lr", class_info, nofp_registers_info, _("\
2339 List of integer registers and their contents, for selected stack frame.\n\
2340 Register name as argument means describe only that register."));
2341 add_info ("all-registers", all_registers_info, _("\
2342 List of all registers and their contents, for selected stack frame.\n\
2343 Register name as argument means describe only that register."));
2344
2345 add_info ("program", program_info,
2346 _("Execution status of the program."));
2347
2348 add_info ("float", float_info,
2349 _("Print the status of the floating point unit\n"));
2350
2351 add_info ("vector", vector_info,
2352 _("Print the status of the vector unit\n"));
2353
2354 inferior_environ = make_environ ();
2355 init_environ (inferior_environ);
2356 }