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