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