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