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