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