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