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