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