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