Merge from vendor branch GCC:
[dragonfly.git] / contrib / gdb / gdb / infcmd.c
1 /* Memory-access and commands for "inferior" process, for GDB.
2    Copyright 1986, 87, 88, 89, 91, 92, 95, 96, 1998 
3    Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21 #include "defs.h"
22 #include <signal.h>
23 #include "gdb_string.h"
24 #include "symtab.h"
25 #include "gdbtypes.h"
26 #include "frame.h"
27 #include "inferior.h"
28 #include "environ.h"
29 #include "value.h"
30 #include "gdbcmd.h"
31 #include "gdbcore.h"
32 #include "target.h"
33 #include "language.h"
34 #include "symfile.h"
35 #include "objfiles.h"
36
37 /* Functions exported for general use: */
38
39 void nofp_registers_info PARAMS ((char *, int));
40
41 void all_registers_info PARAMS ((char *, int));
42
43 void registers_info PARAMS ((char *, int));
44
45 /* Local functions: */
46
47 void continue_command PARAMS ((char *, int));
48
49 static void until_next_command PARAMS ((int));
50
51 static void until_command PARAMS ((char *, int));
52
53 static void path_info PARAMS ((char *, int));
54
55 static void path_command PARAMS ((char *, int));
56
57 static void unset_command PARAMS ((char *, int));
58
59 static void float_info PARAMS ((char *, int));
60
61 static void detach_command PARAMS ((char *, int));
62
63 #if !defined (DO_REGISTERS_INFO)
64 static void do_registers_info PARAMS ((int, int));
65 #endif
66
67 static void unset_environment_command PARAMS ((char *, int));
68
69 static void set_environment_command PARAMS ((char *, int));
70
71 static void environment_info PARAMS ((char *, int));
72
73 static void program_info PARAMS ((char *, int));
74
75 static void finish_command PARAMS ((char *, int));
76
77 static void signal_command PARAMS ((char *, int));
78
79 static void jump_command PARAMS ((char *, int));
80
81 static void step_1 PARAMS ((int, int, char *));
82
83 void nexti_command PARAMS ((char *, int));
84
85 void stepi_command PARAMS ((char *, int));
86
87 static void next_command PARAMS ((char *, int));
88
89 static void step_command PARAMS ((char *, int));
90
91 static void run_command PARAMS ((char *, int));
92
93 void _initialize_infcmd PARAMS ((void));
94
95 #define GO_USAGE   "Usage: go <location>\n"
96
97 #ifdef CALL_DUMMY_BREAKPOINT_OFFSET
98 static void breakpoint_auto_delete_contents PARAMS ((PTR));
99 #endif
100
101 #define ERROR_NO_INFERIOR \
102    if (!target_has_execution) error ("The program is not being run.");
103
104 /* String containing arguments to give to the program, separated by spaces.
105    Empty string (pointer to '\0') means no args.  */
106
107 static char *inferior_args;
108
109 /* File name for default use for standard in/out in the inferior.  */
110
111 char *inferior_io_terminal;
112
113 /* Pid of our debugged inferior, or 0 if no inferior now.
114    Since various parts of infrun.c test this to see whether there is a program
115    being debugged it should be nonzero (currently 3 is used) for remote
116    debugging.  */
117
118 int inferior_pid;
119
120 /* Last signal that the inferior received (why it stopped).  */
121
122 enum target_signal stop_signal;
123
124 /* Address at which inferior stopped.  */
125
126 CORE_ADDR stop_pc;
127
128 /* Chain containing status of breakpoint(s) that we have stopped at.  */
129
130 bpstat stop_bpstat;
131
132 /* Flag indicating that a command has proceeded the inferior past the
133    current breakpoint.  */
134
135 int breakpoint_proceeded;
136
137 /* Nonzero if stopped due to a step command.  */
138
139 int stop_step;
140
141 /* Nonzero if stopped due to completion of a stack dummy routine.  */
142
143 int stop_stack_dummy;
144
145 /* Nonzero if stopped due to a random (unexpected) signal in inferior
146    process.  */
147
148 int stopped_by_random_signal;
149
150 /* Range to single step within.
151    If this is nonzero, respond to a single-step signal
152    by continuing to step if the pc is in this range.  */
153
154 CORE_ADDR step_range_start; /* Inclusive */
155 CORE_ADDR step_range_end; /* Exclusive */
156
157 /* Stack frame address as of when stepping command was issued.
158    This is how we know when we step into a subroutine call,
159    and how to set the frame for the breakpoint used to step out.  */
160
161 CORE_ADDR step_frame_address;
162
163 /* Our notion of the current stack pointer.  */
164
165 CORE_ADDR step_sp;
166
167 /* 1 means step over all subroutine calls.
168    0 means don't step over calls (used by stepi).
169    -1 means step over calls to undebuggable functions.  */
170
171 int step_over_calls;
172
173 /* If stepping, nonzero means step count is > 1
174    so don't print frame next time inferior stops
175    if it stops due to stepping.  */
176
177 int step_multi;
178
179 /* Environment to use for running inferior,
180    in format described in environ.h.  */
181
182 struct environ *inferior_environ;
183
184 \f
185 /* ARGSUSED */
186 void
187 tty_command (file, from_tty)
188      char *file;
189      int from_tty;
190 {
191   if (file == 0)
192     error_no_arg ("terminal name for running target process");
193
194   inferior_io_terminal = savestring (file, strlen (file));
195 }
196
197 static void
198 run_command (args, from_tty)
199      char *args;
200      int from_tty;
201 {
202   char *exec_file;
203
204   dont_repeat ();
205
206   if (inferior_pid != 0 && target_has_execution)
207     {
208       if (
209           !query ("The program being debugged has been started already.\n\
210 Start it from the beginning? "))
211         error ("Program not restarted.");
212       target_kill ();
213 #if defined(SOLIB_RESTART)
214       SOLIB_RESTART ();
215 #endif
216       init_wait_for_inferior ();
217     }
218
219   clear_breakpoint_hit_counts ();
220
221   exec_file = (char *) get_exec_file (0);
222
223   /* Purge old solib objfiles. */
224   objfile_purge_solibs ();
225
226   do_run_cleanups (NULL);
227
228   /* The exec file is re-read every time we do a generic_mourn_inferior, so
229      we just have to worry about the symbol file.  */
230   reread_symbols ();
231
232   /* We keep symbols from add-symbol-file, on the grounds that the
233      user might want to add some symbols before running the program
234      (right?).  But sometimes (dynamic loading where the user manually
235      introduces the new symbols with add-symbol-file), the code which
236      the symbols describe does not persist between runs.  Currently
237      the user has to manually nuke all symbols between runs if they
238      want them to go away (PR 2207).  This is probably reasonable.  */
239
240   if (args)
241     {
242       char *cmd;
243       cmd = concat ("set args ", args, NULL);
244       make_cleanup (free, cmd);
245       execute_command (cmd, from_tty);
246     }
247
248   if (from_tty)
249     {
250       puts_filtered("Starting program: ");
251       if (exec_file)
252         puts_filtered(exec_file);
253       puts_filtered(" ");
254       puts_filtered(inferior_args);
255       puts_filtered("\n");
256       gdb_flush (gdb_stdout);
257     }
258
259   target_create_inferior (exec_file, inferior_args,
260                           environ_vector (inferior_environ));
261 }
262
263
264 static void
265 run_no_args_command (args, from_tty)
266      char *args;
267      int from_tty;
268 {
269   execute_command("set args", from_tty);
270   run_command((char *)NULL, from_tty);
271 }
272
273 \f
274 void
275 continue_command (proc_count_exp, from_tty)
276      char *proc_count_exp;
277      int from_tty;
278 {
279   ERROR_NO_INFERIOR;
280
281   /* If have argument, set proceed count of breakpoint we stopped at.  */
282
283   if (proc_count_exp != NULL)
284     {
285       bpstat bs = stop_bpstat;
286       int num = bpstat_num (&bs);
287       if (num == 0 && from_tty)
288         {
289           printf_filtered
290             ("Not stopped at any breakpoint; argument ignored.\n");
291         }
292       while (num != 0)
293         {
294           set_ignore_count (num,
295                             parse_and_eval_address (proc_count_exp) - 1,
296                             from_tty);
297           /* set_ignore_count prints a message ending with a period.
298              So print two spaces before "Continuing.".  */
299           if (from_tty)
300             printf_filtered ("  ");
301           num = bpstat_num (&bs);
302         }
303     }
304
305   if (from_tty)
306     printf_filtered ("Continuing.\n");
307
308   clear_proceed_status ();
309
310   proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
311 }
312 \f
313 /* Step until outside of current statement.  */
314
315 /* ARGSUSED */
316 static void
317 step_command (count_string, from_tty)
318      char *count_string;
319      int from_tty;
320 {
321   step_1 (0, 0, count_string);
322 }
323
324 /* Likewise, but skip over subroutine calls as if single instructions.  */
325
326 /* ARGSUSED */
327 static void
328 next_command (count_string, from_tty)
329      char *count_string;
330      int from_tty;
331 {
332   step_1 (1, 0, count_string);
333 }
334
335 /* Likewise, but step only one instruction.  */
336
337 /* ARGSUSED */
338 void
339 stepi_command (count_string, from_tty)
340      char *count_string;
341      int from_tty;
342 {
343   step_1 (0, 1, count_string);
344 }
345
346 /* ARGSUSED */
347 void
348 nexti_command (count_string, from_tty)
349      char *count_string;
350      int from_tty;
351 {
352   step_1 (1, 1, count_string);
353 }
354
355 static void
356 step_1 (skip_subroutines, single_inst, count_string)
357      int skip_subroutines;
358      int single_inst;
359      char *count_string;
360 {
361   register int count = 1;
362   struct frame_info *frame;
363   struct cleanup *cleanups = 0;
364
365   ERROR_NO_INFERIOR;
366   count = count_string ? parse_and_eval_address (count_string) : 1;
367
368   if (!single_inst || skip_subroutines) /* leave si command alone */
369     {
370       enable_longjmp_breakpoint();
371       cleanups = make_cleanup ((make_cleanup_func) disable_longjmp_breakpoint, 
372                                0);
373     }
374
375   for (; count > 0; count--)
376     {
377       clear_proceed_status ();
378
379       frame = get_current_frame ();
380       if (!frame)                       /* Avoid coredump here.  Why tho? */
381         error ("No current frame");
382       step_frame_address = FRAME_FP (frame);
383       step_sp = read_sp ();
384
385       if (! single_inst)
386         {
387           find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
388           if (step_range_end == 0)
389             {
390               char *name;
391               if (find_pc_partial_function (stop_pc, &name, &step_range_start,
392                                             &step_range_end) == 0)
393                 error ("Cannot find bounds of current function");
394
395               target_terminal_ours ();
396               printf_filtered ("\
397 Single stepping until exit from function %s, \n\
398 which has no line number information.\n", name);
399             }
400         }
401       else
402         {
403           /* Say we are stepping, but stop after one insn whatever it does.  */
404           step_range_start = step_range_end = 1;
405           if (!skip_subroutines)
406             /* It is stepi.
407                Don't step over function calls, not even to functions lacking
408                line numbers.  */
409             step_over_calls = 0;
410         }
411
412       if (skip_subroutines)
413         step_over_calls = 1;
414
415       step_multi = (count > 1);
416       proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
417       if (! stop_step)
418         break;
419
420       /* FIXME: On nexti, this may have already been done (when we hit the
421          step resume break, I think).  Probably this should be moved to
422          wait_for_inferior (near the top).  */
423 #if defined (SHIFT_INST_REGS)
424       SHIFT_INST_REGS();
425 #endif
426     }
427
428   if (!single_inst || skip_subroutines)
429     do_cleanups(cleanups);
430 }
431 \f
432 /* Continue program at specified address.  */
433
434 static void
435 jump_command (arg, from_tty)
436      char *arg;
437      int from_tty;
438 {
439   register CORE_ADDR addr;
440   struct symtabs_and_lines sals;
441   struct symtab_and_line sal;
442   struct symbol *fn;
443   struct symbol *sfn;
444
445   ERROR_NO_INFERIOR;
446
447   if (!arg)
448     error_no_arg ("starting address");
449
450   sals = decode_line_spec_1 (arg, 1);
451   if (sals.nelts != 1)
452     {
453       error ("Unreasonable jump request");
454     }
455
456   sal = sals.sals[0];
457   free ((PTR)sals.sals);
458
459   if (sal.symtab == 0 && sal.pc == 0)
460     error ("No source file has been specified.");
461
462   resolve_sal_pc (&sal);                        /* May error out */
463
464   /* See if we are trying to jump to another function. */
465   fn = get_frame_function (get_current_frame ());
466   sfn = find_pc_function (sal.pc);
467   if (fn != NULL && sfn != fn)
468     {
469       if (!query ("Line %d is not in `%s'.  Jump anyway? ", sal.line,
470                   SYMBOL_SOURCE_NAME (fn)))
471         {
472           error ("Not confirmed.");
473           /* NOTREACHED */
474         }
475     }
476
477   if (sfn != NULL) 
478     {
479       fixup_symbol_section (sfn, 0);
480       if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) && 
481           !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
482         {
483           if (!query ("WARNING!!!  Destination is in unmapped overlay!  Jump anyway? "))
484             {
485               error ("Not confirmed.");
486               /* NOTREACHED */
487             }
488         }
489     }
490
491
492   addr = sal.pc;
493
494   if (from_tty)
495     {
496       printf_filtered ("Continuing at ");
497       print_address_numeric (addr, 1, gdb_stdout);
498       printf_filtered (".\n");
499     }
500
501   clear_proceed_status ();
502   proceed (addr, TARGET_SIGNAL_0, 0);
503 }
504
505 \f
506 /* Go to line or address in current procedure */
507 static void
508 go_command(line_no, from_tty)
509      char *line_no;
510      int from_tty;
511 {
512   if (line_no == (char *)NULL || !*line_no)
513     printf_filtered(GO_USAGE);
514   else
515     {
516       tbreak_command(line_no, from_tty);
517       jump_command(line_no, from_tty);
518     }
519 }
520
521 \f
522 /* Continue program giving it specified signal.  */
523
524 static void
525 signal_command (signum_exp, from_tty)
526      char *signum_exp;
527      int from_tty;
528 {
529   enum target_signal oursig;
530
531   dont_repeat ();               /* Too dangerous.  */
532   ERROR_NO_INFERIOR;
533
534   if (!signum_exp)
535     error_no_arg ("signal number");
536
537   /* It would be even slicker to make signal names be valid expressions,
538      (the type could be "enum $signal" or some such), then the user could
539      assign them to convenience variables.  */
540   oursig = target_signal_from_name (signum_exp);
541
542   if (oursig == TARGET_SIGNAL_UNKNOWN)
543     {
544       /* No, try numeric.  */
545       int num = parse_and_eval_address (signum_exp);
546
547       if (num == 0)
548         oursig = TARGET_SIGNAL_0;
549       else
550         oursig = target_signal_from_command (num);
551     }
552
553   if (from_tty)
554     {
555       if (oursig == TARGET_SIGNAL_0)
556         printf_filtered ("Continuing with no signal.\n");
557       else
558         printf_filtered ("Continuing with signal %s.\n",
559                          target_signal_to_name (oursig));
560     }
561
562   clear_proceed_status ();
563   /* "signal 0" should not get stuck if we are stopped at a breakpoint.
564      FIXME: Neither should "signal foo" but when I tried passing
565      (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
566      tried to track down yet.  */
567   proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
568 }
569
570 /* Call breakpoint_auto_delete on the current contents of the bpstat
571    pointed to by arg (which is really a bpstat *).  */
572
573 #ifdef CALL_DUMMY_BREAKPOINT_OFFSET
574
575 static void
576 breakpoint_auto_delete_contents (arg)
577      PTR arg;
578 {
579   breakpoint_auto_delete (*(bpstat *)arg);
580 }
581
582 #endif  /* CALL_DUMMY_BREAKPOINT_OFFSET */
583
584 /* Execute a "stack dummy", a piece of code stored in the stack
585    by the debugger to be executed in the inferior.
586
587    To call: first, do PUSH_DUMMY_FRAME.
588    Then push the contents of the dummy.  It should end with a breakpoint insn.
589    Then call here, passing address at which to start the dummy.
590
591    The contents of all registers are saved before the dummy frame is popped
592    and copied into the buffer BUFFER.
593
594    The dummy's frame is automatically popped whenever that break is hit.
595    If that is the first time the program stops, run_stack_dummy
596    returns to its caller with that frame already gone and returns 0.
597    Otherwise, run_stack-dummy returns 1 (the frame will eventually be popped
598    when we do hit that breakpoint).  */
599
600 /* DEBUG HOOK:  4 => return instead of letting the stack dummy run.  */
601
602 static int stack_dummy_testing = 0;
603
604 int
605 run_stack_dummy (addr, buffer)
606      CORE_ADDR addr;
607      char buffer[REGISTER_BYTES];
608 {
609   struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
610
611   /* Now proceed, having reached the desired place.  */
612   clear_proceed_status ();
613   if (stack_dummy_testing & 4)
614     {
615       POP_FRAME;
616       return(0);
617     }
618 #ifdef CALL_DUMMY_BREAKPOINT_OFFSET
619   {
620     struct breakpoint *bpt;
621     struct symtab_and_line sal;
622
623     INIT_SAL (&sal);    /* initialize to zeroes */
624 #if CALL_DUMMY_LOCATION != AT_ENTRY_POINT
625     sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET;
626 #else
627     sal.pc = CALL_DUMMY_ADDRESS ();
628 #endif
629     sal.section = find_pc_overlay (sal.pc);
630
631     /* Set up a FRAME for the dummy frame so we can pass it to
632        set_momentary_breakpoint.  We need to give the breakpoint a
633        frame in case there is only one copy of the dummy (e.g.
634        CALL_DUMMY_LOCATION == AFTER_TEXT_END).  */
635     flush_cached_frames ();
636     set_current_frame (create_new_frame (read_fp (), sal.pc));
637
638     /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
639        a breakpoint instruction.  If not, the call dummy already has the
640        breakpoint instruction in it.
641
642        addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
643        so we need to subtract the CALL_DUMMY_START_OFFSET.  */
644     bpt = set_momentary_breakpoint (sal,
645                                     get_current_frame (),
646                                     bp_call_dummy);
647     bpt->disposition = del;
648
649     /* If all error()s out of proceed ended up calling normal_stop (and
650        perhaps they should; it already does in the special case of error
651        out of resume()), then we wouldn't need this.  */
652     make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
653   }
654 #endif /* CALL_DUMMY_BREAKPOINT_OFFSET.  */
655
656   disable_watchpoints_before_interactive_call_start ();
657   proceed_to_finish = 1;        /* We want stop_registers, please... */
658   proceed (addr, TARGET_SIGNAL_0, 0);
659   enable_watchpoints_after_interactive_call_stop ();
660
661   discard_cleanups (old_cleanups);
662
663   if (!stop_stack_dummy)
664     return 1;
665
666   /* On return, the stack dummy has been popped already.  */
667
668   memcpy (buffer, stop_registers, sizeof stop_registers);
669   return 0;
670 }
671 \f
672 /* Proceed until we reach a different source line with pc greater than
673    our current one or exit the function.  We skip calls in both cases.
674
675    Note that eventually this command should probably be changed so
676    that only source lines are printed out when we hit the breakpoint
677    we set.  This may involve changes to wait_for_inferior and the
678    proceed status code.  */
679
680 /* ARGSUSED */
681 static void
682 until_next_command (from_tty)
683      int from_tty;
684 {
685   struct frame_info *frame;
686   CORE_ADDR pc;
687   struct symbol *func;
688   struct symtab_and_line sal;
689  
690   clear_proceed_status ();
691
692   frame = get_current_frame ();
693
694   /* Step until either exited from this function or greater
695      than the current line (if in symbolic section) or pc (if
696      not). */
697
698   pc = read_pc ();
699   func = find_pc_function (pc);
700   
701   if (!func)
702     {
703       struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
704       
705       if (msymbol == NULL)
706         error ("Execution is not within a known function.");
707       
708       step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
709       step_range_end = pc;
710     }
711   else
712     {
713       sal = find_pc_line (pc, 0);
714       
715       step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
716       step_range_end = sal.end;
717     }
718   
719   step_over_calls = 1;
720   step_frame_address = FRAME_FP (frame);
721   step_sp = read_sp ();
722
723   step_multi = 0;               /* Only one call to proceed */
724   
725   proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
726 }
727
728 static void 
729 until_command (arg, from_tty)
730      char *arg;
731      int from_tty;
732 {
733   if (!target_has_execution)
734     error ("The program is not running.");
735   if (arg)
736     until_break_command (arg, from_tty);
737   else
738     until_next_command (from_tty);
739 }
740 \f
741 /* "finish": Set a temporary breakpoint at the place
742    the selected frame will return to, then continue.  */
743
744 static void
745 finish_command (arg, from_tty)
746      char *arg;
747      int from_tty;
748 {
749   struct symtab_and_line sal;
750   register struct frame_info *frame;
751   register struct symbol *function;
752   struct breakpoint *breakpoint;
753   struct cleanup *old_chain;
754
755   if (arg)
756     error ("The \"finish\" command does not take any arguments.");
757   if (!target_has_execution)
758     error ("The program is not running.");
759   if (selected_frame == NULL)
760     error ("No selected frame.");
761
762   frame = get_prev_frame (selected_frame);
763   if (frame == 0)
764     error ("\"finish\" not meaningful in the outermost frame.");
765
766   clear_proceed_status ();
767
768   sal = find_pc_line (frame->pc, 0);
769   sal.pc = frame->pc;
770
771   breakpoint = set_momentary_breakpoint (sal, frame, bp_finish);
772
773   old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint);
774
775   /* Find the function we will return from.  */
776
777   function = find_pc_function (selected_frame->pc);
778
779   /* Print info on the selected frame, including level number
780      but not source.  */
781   if (from_tty)
782     {
783       printf_filtered ("Run till exit from ");
784       print_stack_frame (selected_frame, selected_frame_level, 0);
785     }
786
787   proceed_to_finish = 1;                /* We want stop_registers, please... */
788   proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
789
790   /* Did we stop at our breakpoint? */
791   if (bpstat_find_breakpoint(stop_bpstat, breakpoint) != NULL
792       && function != 0)
793     {
794       struct type *value_type;
795       register value_ptr val;
796       CORE_ADDR funcaddr;
797       int struct_return;
798
799       value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
800       if (!value_type)
801         fatal ("internal: finish_command: function has no target type");
802       
803       if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
804         return;
805
806       funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
807
808       struct_return = using_struct_return (value_of_variable (function, NULL),
809
810                                    funcaddr,
811                                    check_typedef (value_type),
812                 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
813
814       if (!struct_return)
815       {
816         val = value_being_returned (value_type, stop_registers, struct_return);
817         printf_filtered ("Value returned is $%d = ", record_latest_value (val));
818         value_print (val, gdb_stdout, 0, Val_no_prettyprint);
819         printf_filtered ("\n");
820       }
821       else
822       {
823        /* elz: we cannot determine the contents of the structure because
824           it is on the stack, and we don't know where, since we did not
825           initiate the call, as opposed to the call_function_by_hand case */
826 #ifdef VALUE_RETURNED_FROM_STACK
827           val = 0;
828           printf_filtered ("Value returned has type: %s.", 
829                            TYPE_NAME (value_type));
830           printf_filtered (" Cannot determine contents\n");
831 #else
832           val = value_being_returned (value_type, stop_registers, 
833                                       struct_return);
834           printf_filtered ("Value returned is $%d = ", 
835                            record_latest_value (val));
836           value_print (val, gdb_stdout, 0, Val_no_prettyprint);
837           printf_filtered ("\n");
838 #endif
839        
840       }
841     }
842   do_cleanups(old_chain);
843 }
844 \f
845 /* ARGSUSED */
846 static void
847 program_info (args, from_tty)
848     char *args;
849     int from_tty;
850 {
851   bpstat bs = stop_bpstat;
852   int num = bpstat_num (&bs);
853   
854   if (!target_has_execution)
855     {
856       printf_filtered ("The program being debugged is not being run.\n");
857       return;
858     }
859
860   target_files_info ();
861   printf_filtered ("Program stopped at %s.\n",
862                    local_hex_string((unsigned long) stop_pc));
863   if (stop_step)
864     printf_filtered ("It stopped after being stepped.\n");
865   else if (num != 0)
866     {
867       /* There may be several breakpoints in the same place, so this
868          isn't as strange as it seems.  */
869       while (num != 0)
870         {
871           if (num < 0)
872             {
873               printf_filtered ("It stopped at a breakpoint that has ");
874               printf_filtered ("since been deleted.\n");
875             }
876           else
877             printf_filtered ("It stopped at breakpoint %d.\n", num);
878           num = bpstat_num (&bs);
879         }
880     }
881   else if (stop_signal != TARGET_SIGNAL_0)
882     {
883       printf_filtered ("It stopped with signal %s, %s.\n",
884                        target_signal_to_name (stop_signal),
885                        target_signal_to_string (stop_signal));
886     }
887
888   if (!from_tty)
889     {
890       printf_filtered ("Type \"info stack\" or \"info registers\" ");
891       printf_filtered ("for more information.\n");
892     }
893 }
894 \f
895 static void
896 environment_info (var, from_tty)
897      char *var;
898      int from_tty;
899 {
900   if (var)
901     {
902       register char *val = get_in_environ (inferior_environ, var);
903       if (val)
904         {
905           puts_filtered (var);
906           puts_filtered (" = ");
907           puts_filtered (val);
908           puts_filtered ("\n");
909         }
910       else
911         {
912           puts_filtered ("Environment variable \"");
913           puts_filtered (var);
914           puts_filtered ("\" not defined.\n");
915         }
916     }
917   else
918     {
919       register char **vector = environ_vector (inferior_environ);
920       while (*vector)
921         {
922           puts_filtered (*vector++);
923           puts_filtered ("\n");
924         }
925     }
926 }
927
928 static void
929 set_environment_command (arg, from_tty)
930      char *arg;
931      int from_tty;
932 {
933   register char *p, *val, *var;
934   int nullset = 0;
935
936   if (arg == 0)
937     error_no_arg ("environment variable and value");
938
939   /* Find seperation between variable name and value */
940   p = (char *) strchr (arg, '=');
941   val = (char *) strchr (arg, ' ');
942
943   if (p != 0 && val != 0)
944     {
945       /* We have both a space and an equals.  If the space is before the
946          equals, walk forward over the spaces til we see a nonspace 
947          (possibly the equals). */
948       if (p > val)
949         while (*val == ' ')
950           val++;
951
952       /* Now if the = is after the char following the spaces,
953          take the char following the spaces.  */
954       if (p > val)
955         p = val - 1;
956     }
957   else if (val != 0 && p == 0)
958     p = val;
959
960   if (p == arg)
961     error_no_arg ("environment variable to set");
962
963   if (p == 0 || p[1] == 0)
964     {
965       nullset = 1;
966       if (p == 0)
967         p = arg + strlen (arg); /* So that savestring below will work */
968     }
969   else
970     {
971       /* Not setting variable value to null */
972       val = p + 1;
973       while (*val == ' ' || *val == '\t')
974         val++;
975     }
976
977   while (p != arg && (p[-1] == ' ' || p[-1] == '\t')) p--;
978
979   var = savestring (arg, p - arg);
980   if (nullset)
981     {
982       printf_filtered ("Setting environment variable ");
983       printf_filtered ("\"%s\" to null value.\n", var);
984       set_in_environ (inferior_environ, var, "");
985     }
986   else
987     set_in_environ (inferior_environ, var, val);
988   free (var);
989 }
990
991 static void
992 unset_environment_command (var, from_tty)
993      char *var;
994      int from_tty;
995 {
996   if (var == 0)
997     {
998       /* If there is no argument, delete all environment variables.
999          Ask for confirmation if reading from the terminal.  */
1000       if (!from_tty || query ("Delete all environment variables? "))
1001         {
1002           free_environ (inferior_environ);
1003           inferior_environ = make_environ ();
1004         }
1005     }
1006   else
1007     unset_in_environ (inferior_environ, var);
1008 }
1009
1010 /* Handle the execution path (PATH variable) */
1011
1012 static const char path_var_name[] = "PATH";
1013
1014 /* ARGSUSED */
1015 static void
1016 path_info (args, from_tty)
1017      char *args;
1018      int from_tty;
1019 {
1020   puts_filtered ("Executable and object file path: ");
1021   puts_filtered (get_in_environ (inferior_environ, path_var_name));
1022   puts_filtered ("\n");
1023 }
1024
1025 /* Add zero or more directories to the front of the execution path.  */
1026
1027 static void
1028 path_command (dirname, from_tty)
1029      char *dirname;
1030      int from_tty;
1031 {
1032   char *exec_path;
1033   char *env;
1034   dont_repeat ();
1035   env = get_in_environ (inferior_environ, path_var_name);
1036   /* Can be null if path is not set */
1037   if (!env)
1038     env = "";
1039   exec_path = strsave (env);
1040   mod_path (dirname, &exec_path);
1041   set_in_environ (inferior_environ, path_var_name, exec_path);
1042   free (exec_path);
1043   if (from_tty)
1044     path_info ((char *)NULL, from_tty);
1045 }
1046
1047 \f
1048 #ifdef REGISTER_NAMES
1049 char *gdb_register_names[] = REGISTER_NAMES;
1050 #endif
1051 /* Print out the machine register regnum. If regnum is -1,
1052    print all registers (fpregs == 1) or all non-float registers
1053    (fpregs == 0).
1054
1055    For most machines, having all_registers_info() print the
1056    register(s) one per line is good enough. If a different format
1057    is required, (eg, for MIPS or Pyramid 90x, which both have
1058    lots of regs), or there is an existing convention for showing
1059    all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
1060    to provide that format.  */  
1061
1062 #if !defined (DO_REGISTERS_INFO)
1063
1064 #define DO_REGISTERS_INFO(regnum, fp) do_registers_info(regnum, fp)
1065
1066 static void
1067 do_registers_info (regnum, fpregs)
1068      int regnum;
1069      int fpregs;
1070 {
1071   register int i;
1072   int numregs = ARCH_NUM_REGS;
1073
1074   for (i = 0; i < numregs; i++)
1075     {
1076       char raw_buffer[MAX_REGISTER_RAW_SIZE];
1077       char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
1078
1079       /* Decide between printing all regs, nonfloat regs, or specific reg.  */
1080       if (regnum == -1) {
1081         if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !fpregs)
1082           continue;
1083       } else {
1084         if (i != regnum)
1085           continue;
1086       }
1087
1088       /* If the register name is empty, it is undefined for this
1089          processor, so don't display anything.  */
1090       if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1091         continue;
1092
1093       fputs_filtered (REGISTER_NAME (i), gdb_stdout);
1094       print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), gdb_stdout);
1095
1096       /* Get the data in raw format.  */
1097       if (read_relative_register_raw_bytes (i, raw_buffer))
1098         {
1099           printf_filtered ("*value not available*\n");
1100           continue;
1101         }
1102
1103       /* Convert raw data to virtual format if necessary.  */
1104 #ifdef REGISTER_CONVERTIBLE
1105       if (REGISTER_CONVERTIBLE (i))
1106         {
1107           REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
1108                                        raw_buffer, virtual_buffer);
1109         }
1110       else
1111 #endif
1112         memcpy (virtual_buffer, raw_buffer,
1113                 REGISTER_VIRTUAL_SIZE (i));
1114
1115       /* If virtual format is floating, print it that way, and in raw hex.  */
1116       if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
1117         {
1118           register int j;
1119
1120 #ifdef INVALID_FLOAT
1121           if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
1122             printf_filtered ("<invalid float>");
1123           else
1124 #endif
1125             val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1126                        gdb_stdout, 0, 1, 0, Val_pretty_default);
1127
1128           printf_filtered ("\t(raw 0x");
1129           for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
1130             {
1131               register int idx = TARGET_BYTE_ORDER == BIG_ENDIAN ? j
1132                 : REGISTER_RAW_SIZE (i) - 1 - j;
1133               printf_filtered ("%02x", (unsigned char)raw_buffer[idx]);
1134             }
1135           printf_filtered (")");
1136         }
1137
1138 /* FIXME!  val_print probably can handle all of these cases now...  */
1139
1140       /* Else if virtual format is too long for printf,
1141          print in hex a byte at a time.  */
1142       else if (REGISTER_VIRTUAL_SIZE (i) > (int) sizeof (long))
1143         {
1144           register int j;
1145           printf_filtered ("0x");
1146           for (j = 0; j < REGISTER_VIRTUAL_SIZE (i); j++)
1147             printf_filtered ("%02x", (unsigned char)virtual_buffer[j]);
1148         }
1149       /* Else print as integer in hex and in decimal.  */
1150       else
1151         {
1152           val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1153                      gdb_stdout, 'x', 1, 0, Val_pretty_default);
1154           printf_filtered ("\t");
1155           val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1156                      gdb_stdout,   0, 1, 0, Val_pretty_default);
1157         }
1158
1159       /* The SPARC wants to print even-numbered float regs as doubles
1160          in addition to printing them as floats.  */
1161 #ifdef PRINT_REGISTER_HOOK
1162       PRINT_REGISTER_HOOK (i);
1163 #endif
1164
1165       printf_filtered ("\n");
1166     }
1167 }
1168 #endif /* no DO_REGISTERS_INFO.  */
1169
1170 extern int target_map_name_to_register PARAMS ((char *, int));
1171
1172 void
1173 registers_info (addr_exp, fpregs)
1174      char *addr_exp;
1175      int fpregs;
1176 {
1177   int regnum, numregs;
1178   register char *end;
1179
1180   if (!target_has_registers)
1181     error ("The program has no registers now.");
1182   if (selected_frame == NULL)
1183     error ("No selected frame.");
1184
1185   if (!addr_exp)
1186     {
1187       DO_REGISTERS_INFO(-1, fpregs);
1188       return;
1189     }
1190
1191   do
1192     {      
1193       if (addr_exp[0] == '$')
1194         addr_exp++;
1195       end = addr_exp;
1196       while (*end != '\0' && *end != ' ' && *end != '\t')
1197         ++end;
1198       numregs = ARCH_NUM_REGS;
1199
1200       regnum = target_map_name_to_register (addr_exp, end - addr_exp);
1201       if (regnum >= 0) 
1202         goto found;
1203
1204       regnum = numregs;
1205
1206       if (*addr_exp >= '0' && *addr_exp <= '9')
1207         regnum = atoi (addr_exp);               /* Take a number */
1208       if (regnum >= numregs)            /* Bad name, or bad number */
1209         error ("%.*s: invalid register", end - addr_exp, addr_exp);
1210
1211 found:
1212       DO_REGISTERS_INFO(regnum, fpregs);
1213
1214       addr_exp = end;
1215       while (*addr_exp == ' ' || *addr_exp == '\t')
1216         ++addr_exp;
1217     } while (*addr_exp != '\0');
1218 }
1219
1220 void
1221 all_registers_info (addr_exp, from_tty)
1222      char *addr_exp;
1223      int from_tty;
1224 {
1225   registers_info (addr_exp, 1);
1226 }
1227
1228 void
1229 nofp_registers_info (addr_exp, from_tty)
1230      char *addr_exp;
1231      int from_tty;
1232 {
1233   registers_info (addr_exp, 0);
1234 }
1235
1236 \f
1237 /*
1238  * TODO:
1239  * Should save/restore the tty state since it might be that the
1240  * program to be debugged was started on this tty and it wants
1241  * the tty in some state other than what we want.  If it's running
1242  * on another terminal or without a terminal, then saving and
1243  * restoring the tty state is a harmless no-op.
1244  * This only needs to be done if we are attaching to a process.
1245  */
1246
1247 /*
1248    attach_command --
1249    takes a program started up outside of gdb and ``attaches'' to it.
1250    This stops it cold in its tracks and allows us to start debugging it.
1251    and wait for the trace-trap that results from attaching.  */
1252
1253 void
1254 attach_command (args, from_tty)
1255      char *args;
1256      int from_tty;
1257 {
1258 #ifdef SOLIB_ADD
1259   extern int auto_solib_add;
1260 #endif
1261
1262   char *  exec_file;
1263   char *  full_exec_path = NULL;
1264
1265   dont_repeat ();                       /* Not for the faint of heart */
1266
1267   if (target_has_execution)
1268     {
1269       if (query ("A program is being debugged already.  Kill it? "))
1270         target_kill ();
1271       else
1272         error ("Not killed.");
1273     }
1274
1275   target_attach (args, from_tty);
1276
1277   /* Set up the "saved terminal modes" of the inferior
1278      based on what modes we are starting it with.  */
1279   target_terminal_init ();
1280
1281   /* Install inferior's terminal modes.  */
1282   target_terminal_inferior ();
1283
1284   /* Set up execution context to know that we should return from
1285      wait_for_inferior as soon as the target reports a stop.  */
1286   init_wait_for_inferior ();
1287   clear_proceed_status ();
1288   stop_soon_quietly = 1;
1289
1290   /* No traps are generated when attaching to inferior under Mach 3
1291      or GNU hurd.  */
1292 #ifndef ATTACH_NO_WAIT
1293   wait_for_inferior ();
1294 #endif
1295
1296   /*
1297    * If no exec file is yet known, try to determine it from the
1298    * process itself.
1299    */
1300   exec_file = (char *) get_exec_file (0);
1301   if (! exec_file) {
1302     exec_file = target_pid_to_exec_file (inferior_pid);
1303     if (exec_file) {
1304      /* It's possible we don't have a full path, but rather just a
1305          filename.  Some targets, such as HP-UX, don't provide the
1306          full path, sigh.
1307
1308          Attempt to qualify the filename against the source path.
1309          (If that fails, we'll just fall back on the original
1310          filename.  Not much more we can do...)
1311          */
1312       if (!source_full_path_of (exec_file, &full_exec_path))
1313         full_exec_path = savestring (exec_file, strlen (exec_file));
1314
1315       exec_file_attach (full_exec_path, from_tty);
1316       symbol_file_command (full_exec_path, from_tty);
1317     }
1318   }
1319
1320 #ifdef SOLIB_ADD
1321   if (auto_solib_add)
1322     {
1323       /* Add shared library symbols from the newly attached process, if any.  */
1324       SOLIB_ADD ((char *)0, from_tty, &current_target);
1325       re_enable_breakpoints_in_shlibs ();
1326     }
1327 #endif
1328
1329   /* Take any necessary post-attaching actions for this platform.
1330      */
1331   target_post_attach (inferior_pid);
1332
1333   normal_stop ();
1334 }
1335
1336 /*
1337  * detach_command --
1338  * takes a program previously attached to and detaches it.
1339  * The program resumes execution and will no longer stop
1340  * on signals, etc.  We better not have left any breakpoints
1341  * in the program or it'll die when it hits one.  For this
1342  * to work, it may be necessary for the process to have been
1343  * previously attached.  It *might* work if the program was
1344  * started via the normal ptrace (PTRACE_TRACEME).
1345  */
1346
1347 static void
1348 detach_command (args, from_tty)
1349      char *args;
1350      int from_tty;
1351 {
1352   dont_repeat ();                       /* Not for the faint of heart */
1353   target_detach (args, from_tty);
1354 #if defined(SOLIB_RESTART)
1355   SOLIB_RESTART ();
1356 #endif
1357 }
1358
1359 /* ARGSUSED */
1360 static void
1361 float_info (addr_exp, from_tty)
1362      char *addr_exp;
1363      int from_tty;
1364 {
1365 #ifdef FLOAT_INFO
1366   FLOAT_INFO;
1367 #else
1368   printf_filtered ("No floating point info available for this processor.\n");
1369 #endif
1370 }
1371 \f
1372 /* ARGSUSED */
1373 static void
1374 unset_command (args, from_tty)
1375      char *args;
1376      int from_tty;
1377 {
1378   printf_filtered ("\"unset\" must be followed by the name of ");
1379   printf_filtered ("an unset subcommand.\n");
1380   help_list (unsetlist, "unset ", -1, gdb_stdout);
1381 }
1382
1383 void
1384 _initialize_infcmd ()
1385 {
1386   struct cmd_list_element *c;
1387   
1388   add_com ("tty", class_run, tty_command,
1389            "Set terminal for future runs of program being debugged.");
1390
1391   add_show_from_set
1392     (add_set_cmd ("args", class_run, var_string_noescape, 
1393                   (char *)&inferior_args,
1394 "Set argument list to give program being debugged when it is started.\n\
1395 Follow this command with any number of args, to be passed to the program.",
1396                   &setlist),
1397      &showlist);
1398
1399   c = add_cmd
1400     ("environment", no_class, environment_info,
1401      "The environment to give the program, or one variable's value.\n\
1402 With an argument VAR, prints the value of environment variable VAR to\n\
1403 give the program being debugged.  With no arguments, prints the entire\n\
1404 environment to be given to the program.", &showlist);
1405   c->completer = noop_completer;
1406
1407   add_prefix_cmd ("unset", no_class, unset_command,
1408                   "Complement to certain \"set\" commands",
1409                   &unsetlist, "unset ", 0, &cmdlist);
1410   
1411   c = add_cmd ("environment", class_run, unset_environment_command,
1412               "Cancel environment variable VAR for the program.\n\
1413 This does not affect the program until the next \"run\" command.",
1414            &unsetlist);
1415   c->completer = noop_completer;
1416
1417   c = add_cmd ("environment", class_run, set_environment_command,
1418                "Set environment variable value to give the program.\n\
1419 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
1420 VALUES of environment variables are uninterpreted strings.\n\
1421 This does not affect the program until the next \"run\" command.",
1422            &setlist);
1423   c->completer = noop_completer;
1424  
1425   add_com ("path", class_files, path_command,
1426        "Add directory DIR(s) to beginning of search path for object files.\n\
1427 $cwd in the path means the current working directory.\n\
1428 This path is equivalent to the $PATH shell variable.  It is a list of\n\
1429 directories, separated by colons.  These directories are searched to find\n\
1430 fully linked executable files and separately compiled object files as needed.");
1431
1432   c = add_cmd ("paths", no_class, path_info,
1433             "Current search path for finding object files.\n\
1434 $cwd in the path means the current working directory.\n\
1435 This path is equivalent to the $PATH shell variable.  It is a list of\n\
1436 directories, separated by colons.  These directories are searched to find\n\
1437 fully linked executable files and separately compiled object files as needed.",
1438                &showlist);
1439   c->completer = noop_completer;
1440
1441  add_com ("attach", class_run, attach_command,
1442            "Attach to a process or file outside of GDB.\n\
1443 This command attaches to another target, of the same type as your last\n\
1444 \"target\" command (\"info files\" will show your target stack).\n\
1445 The command may take as argument a process id or a device file.\n\
1446 For a process id, you must have permission to send the process a signal,\n\
1447 and it must have the same effective uid as the debugger.\n\
1448 When using \"attach\" with a process id, the debugger finds the\n\
1449 program running in the process, looking first in the current working\n\
1450 directory, or (if not found there) using the source file search path\n\
1451 (see the \"directory\" command).  You can also use the \"file\" command\n\
1452 to specify the program, and to load its symbol table.");
1453
1454   add_com ("detach", class_run, detach_command,
1455            "Detach a process or file previously attached.\n\
1456 If a process, it is no longer traced, and it continues its execution.  If\n\
1457 you were debugging a file, the file is closed and gdb no longer accesses it.");
1458
1459   add_com ("signal", class_run, signal_command,
1460            "Continue program giving it signal specified by the argument.\n\
1461 An argument of \"0\" means continue program without giving it a signal.");
1462
1463   add_com ("stepi", class_run, stepi_command,
1464            "Step one instruction exactly.\n\
1465 Argument N means do this N times (or till program stops for another reason).");
1466   add_com_alias ("si", "stepi", class_alias, 0);
1467
1468   add_com ("nexti", class_run, nexti_command,
1469            "Step one instruction, but proceed through subroutine calls.\n\
1470 Argument N means do this N times (or till program stops for another reason).");
1471   add_com_alias ("ni", "nexti", class_alias, 0);
1472
1473   add_com ("finish", class_run, finish_command,
1474            "Execute until selected stack frame returns.\n\
1475 Upon return, the value returned is printed and put in the value history.");
1476
1477   add_com ("next", class_run, next_command,
1478            "Step program, proceeding through subroutine calls.\n\
1479 Like the \"step\" command as long as subroutine calls do not happen;\n\
1480 when they do, the call is treated as one instruction.\n\
1481 Argument N means do this N times (or till program stops for another reason).");
1482   add_com_alias ("n", "next", class_run, 1);
1483   if (xdb_commands)
1484     add_com_alias("S", "next", class_run, 1);
1485
1486   add_com ("step", class_run, step_command,
1487            "Step program until it reaches a different source line.\n\
1488 Argument N means do this N times (or till program stops for another reason).");
1489   add_com_alias ("s", "step", class_run, 1);
1490
1491   add_com ("until", class_run, until_command,
1492 "Execute until the program reaches a source line greater than the current\n\
1493 or a specified line or address or function (same args as break command).\n\
1494 Execution will also stop upon exit from the current stack frame.");
1495   add_com_alias ("u", "until", class_run, 1);
1496   
1497   add_com ("jump", class_run, jump_command,
1498            "Continue program being debugged at specified line or address.\n\
1499 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
1500 for an address to start at.");
1501
1502   add_com ("go", class_run, go_command,
1503            "Usage: go <location>\n\
1504 Continue program being debugged, stopping at specified line or \n\
1505 address.\n\
1506 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
1507 expression for an address to start at.\n\
1508 This command is a combination of tbreak and jump.");
1509   if (xdb_commands)
1510     add_com_alias("g", "g", class_run, 1);
1511
1512   add_com ("continue", class_run, continue_command,
1513            "Continue program being debugged, after signal or breakpoint.\n\
1514 If proceeding from breakpoint, a number N may be used as an argument,\n\
1515 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
1516 the breakpoint won't break until the Nth time it is reached).");
1517   add_com_alias ("c", "cont", class_run, 1);
1518   add_com_alias ("fg", "cont", class_run, 1);
1519
1520   add_com ("run", class_run, run_command,
1521            "Start debugged program.  You may specify arguments to give it.\n\
1522 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
1523 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
1524 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
1525 To cancel previous arguments and run with no arguments,\n\
1526 use \"set args\" without arguments.");
1527   add_com_alias ("r", "run", class_run, 1);
1528   if (xdb_commands)
1529     add_com ("R", class_run, run_no_args_command,
1530          "Start debugged program with no arguments.");
1531
1532   add_info ("registers", nofp_registers_info,
1533     "List of integer registers and their contents, for selected stack frame.\n\
1534 Register name as argument means describe only that register.");
1535
1536   if (xdb_commands)
1537     add_com("lr", class_info, nofp_registers_info,
1538     "List of integer registers and their contents, for selected stack frame.\n\
1539   Register name as argument means describe only that register.");
1540   add_info ("all-registers", all_registers_info,
1541     "List of all registers and their contents, for selected stack frame.\n\
1542 Register name as argument means describe only that register.");
1543
1544   add_info ("program", program_info,
1545             "Execution status of the program.");
1546
1547   add_info ("float", float_info,
1548             "Print the status of the floating point unit\n");
1549
1550   inferior_args = savestring ("", 1);   /* Initially no args */
1551   inferior_environ = make_environ ();
1552   init_environ (inferior_environ);
1553 }