1 /* Memory-access and commands for "inferior" process, for GDB.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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. */
25 #include "gdb_string.h"
39 #include "completer.h"
41 #include "event-top.h"
42 #include "parser-defs.h"
44 #include "reggroups.h"
47 /* Functions exported for general use, in inferior.h: */
49 void all_registers_info (char *, int);
51 void registers_info (char *, int);
53 void nexti_command (char *, int);
55 void stepi_command (char *, int);
57 void continue_command (char *, int);
59 void interrupt_target_command (char *args, int from_tty);
61 /* Local functions: */
63 static void nofp_registers_info (char *, int);
65 static void print_return_value (int struct_return, struct type *value_type);
67 static void finish_command_continuation (struct continuation_arg *);
69 static void until_next_command (int);
71 static void until_command (char *, int);
73 static void path_info (char *, int);
75 static void path_command (char *, int);
77 static void unset_command (char *, int);
79 static void float_info (char *, int);
81 static void detach_command (char *, int);
83 static void unset_environment_command (char *, int);
85 static void set_environment_command (char *, int);
87 static void environment_info (char *, int);
89 static void program_info (char *, int);
91 static void finish_command (char *, int);
93 static void signal_command (char *, int);
95 static void jump_command (char *, int);
97 static void step_1 (int, int, char *);
98 static void step_once (int skip_subroutines, int single_inst, int count);
99 static void step_1_continuation (struct continuation_arg *arg);
101 static void next_command (char *, int);
103 static void step_command (char *, int);
105 static void run_command (char *, int);
107 static void run_no_args_command (char *args, int from_tty);
109 static void go_command (char *line_no, int from_tty);
111 static int strip_bg_char (char **);
113 void _initialize_infcmd (void);
115 #define GO_USAGE "Usage: go <location>\n"
117 static void breakpoint_auto_delete_contents (PTR);
119 #define ERROR_NO_INFERIOR \
120 if (!target_has_execution) error ("The program is not being run.");
122 /* String containing arguments to give to the program, separated by spaces.
123 Empty string (pointer to '\0') means no args. */
125 static char *inferior_args;
127 /* The inferior arguments as a vector. If INFERIOR_ARGC is nonzero,
128 then we must compute INFERIOR_ARGS from this (via the target). */
130 static int inferior_argc;
131 static char **inferior_argv;
133 /* File name for default use for standard in/out in the inferior. */
135 char *inferior_io_terminal;
137 /* Pid of our debugged inferior, or 0 if no inferior now.
138 Since various parts of infrun.c test this to see whether there is a program
139 being debugged it should be nonzero (currently 3 is used) for remote
142 ptid_t inferior_ptid;
144 /* Last signal that the inferior received (why it stopped). */
146 enum target_signal stop_signal;
148 /* Address at which inferior stopped. */
152 /* Chain containing status of breakpoint(s) that we have stopped at. */
156 /* Flag indicating that a command has proceeded the inferior past the
157 current breakpoint. */
159 int breakpoint_proceeded;
161 /* Nonzero if stopped due to a step command. */
165 /* Nonzero if stopped due to completion of a stack dummy routine. */
167 int stop_stack_dummy;
169 /* Nonzero if stopped due to a random (unexpected) signal in inferior
172 int stopped_by_random_signal;
174 /* Range to single step within.
175 If this is nonzero, respond to a single-step signal
176 by continuing to step if the pc is in this range. */
178 CORE_ADDR step_range_start; /* Inclusive */
179 CORE_ADDR step_range_end; /* Exclusive */
181 /* Stack frame address as of when stepping command was issued.
182 This is how we know when we step into a subroutine call,
183 and how to set the frame for the breakpoint used to step out. */
185 struct frame_id step_frame_id;
187 /* Our notion of the current stack pointer. */
191 enum step_over_calls_kind step_over_calls;
193 /* If stepping, nonzero means step count is > 1
194 so don't print frame next time inferior stops
195 if it stops due to stepping. */
199 /* Environment to use for running inferior,
200 in format described in environ.h. */
202 struct environ *inferior_environ;
204 /* Accessor routines. */
207 get_inferior_args (void)
209 if (inferior_argc != 0)
213 n = gdbarch_construct_inferior_arguments (current_gdbarch,
214 inferior_argc, inferior_argv);
215 old = set_inferior_args (n);
219 if (inferior_args == NULL)
220 inferior_args = xstrdup ("");
222 return inferior_args;
226 set_inferior_args (char *newargs)
228 char *saved_args = inferior_args;
230 inferior_args = newargs;
238 set_inferior_args_vector (int argc, char **argv)
240 inferior_argc = argc;
241 inferior_argv = argv;
244 /* Notice when `set args' is run. */
246 notice_args_set (char *args, int from_tty, struct cmd_list_element *c)
252 /* Notice when `show args' is run. */
254 notice_args_read (char *args, int from_tty, struct cmd_list_element *c)
256 /* Might compute the value. */
257 get_inferior_args ();
261 /* Compute command-line string given argument vector. This does the
262 same shell processing as fork_inferior. */
265 construct_inferior_arguments (struct gdbarch *gdbarch, int argc, char **argv)
269 if (STARTUP_WITH_SHELL)
271 /* This holds all the characters considered special to the
272 typical Unix shells. We include `^' because the SunOS
273 /bin/sh treats it as a synonym for `|'. */
274 char *special = "\"!#$&*()\\|[]{}<>?'\"`~^; \t\n";
279 /* We over-compute the size. It shouldn't matter. */
280 for (i = 0; i < argc; ++i)
281 length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0');
283 result = (char *) xmalloc (length);
286 for (i = 0; i < argc; ++i)
291 /* Need to handle empty arguments specially. */
292 if (argv[i][0] == '\0')
299 for (cp = argv[i]; *cp; ++cp)
301 if (strchr (special, *cp) != NULL)
311 /* In this case we can't handle arguments that contain spaces,
312 tabs, or newlines -- see breakup_args(). */
316 for (i = 0; i < argc; ++i)
318 char *cp = strchr (argv[i], ' ');
320 cp = strchr (argv[i], '\t');
322 cp = strchr (argv[i], '\n');
324 error ("can't handle command-line argument containing whitespace");
325 length += strlen (argv[i]) + 1;
328 result = (char *) xmalloc (length);
330 for (i = 0; i < argc; ++i)
333 strcat (result, " ");
334 strcat (result, argv[i]);
342 /* This function detects whether or not a '&' character (indicating
343 background execution) has been added as *the last* of the arguments ARGS
344 of a command. If it has, it removes it and returns 1. Otherwise it
345 does nothing and returns 0. */
347 strip_bg_char (char **args)
351 p = strchr (*args, '&');
355 if (p == (*args + strlen (*args) - 1))
357 if (strlen (*args) > 1)
361 while (*p == ' ' || *p == '\t');
374 tty_command (char *file, int from_tty)
377 error_no_arg ("terminal name for running target process");
379 inferior_io_terminal = savestring (file, strlen (file));
383 run_command (char *args, int from_tty)
389 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
392 && !query ("The program being debugged has been started already.\n\
393 Start it from the beginning? "))
394 error ("Program not restarted.");
396 #if defined(SOLIB_RESTART)
399 init_wait_for_inferior ();
402 clear_breakpoint_hit_counts ();
404 /* Purge old solib objfiles. */
405 objfile_purge_solibs ();
407 do_run_cleanups (NULL);
409 /* The comment here used to read, "The exec file is re-read every
410 time we do a generic_mourn_inferior, so we just have to worry
411 about the symbol file." The `generic_mourn_inferior' function
412 gets called whenever the program exits. However, suppose the
413 program exits, and *then* the executable file changes? We need
414 to check again here. Since reopen_exec_file doesn't do anything
415 if the timestamp hasn't changed, I don't see the harm. */
419 exec_file = (char *) get_exec_file (0);
421 /* We keep symbols from add-symbol-file, on the grounds that the
422 user might want to add some symbols before running the program
423 (right?). But sometimes (dynamic loading where the user manually
424 introduces the new symbols with add-symbol-file), the code which
425 the symbols describe does not persist between runs. Currently
426 the user has to manually nuke all symbols between runs if they
427 want them to go away (PR 2207). This is probably reasonable. */
431 if (event_loop_p && target_can_async_p ())
432 async_disable_stdin ();
436 int async_exec = strip_bg_char (&args);
438 /* If we get a request for running in the bg but the target
439 doesn't support it, error out. */
440 if (event_loop_p && async_exec && !target_can_async_p ())
441 error ("Asynchronous execution not supported on this target.");
443 /* If we don't get a request of running in the bg, then we need
444 to simulate synchronous (fg) execution. */
445 if (event_loop_p && !async_exec && target_can_async_p ())
447 /* Simulate synchronous execution */
448 async_disable_stdin ();
451 /* If there were other args, beside '&', process them. */
454 char *old_args = set_inferior_args (xstrdup (args));
461 ui_out_field_string (uiout, NULL, "Starting program");
462 ui_out_text (uiout, ": ");
464 ui_out_field_string (uiout, "execfile", exec_file);
465 ui_out_spaces (uiout, 1);
466 /* We call get_inferior_args() because we might need to compute
468 ui_out_field_string (uiout, "infargs", get_inferior_args ());
469 ui_out_text (uiout, "\n");
470 ui_out_flush (uiout);
473 /* We call get_inferior_args() because we might need to compute
475 target_create_inferior (exec_file, get_inferior_args (),
476 environ_vector (inferior_environ));
481 run_no_args_command (char *args, int from_tty)
483 char *old_args = set_inferior_args (xstrdup (""));
489 continue_command (char *proc_count_exp, int from_tty)
494 /* Find out whether we must run in the background. */
495 if (proc_count_exp != NULL)
496 async_exec = strip_bg_char (&proc_count_exp);
498 /* If we must run in the background, but the target can't do it,
500 if (event_loop_p && async_exec && !target_can_async_p ())
501 error ("Asynchronous execution not supported on this target.");
503 /* If we are not asked to run in the bg, then prepare to run in the
504 foreground, synchronously. */
505 if (event_loop_p && !async_exec && target_can_async_p ())
507 /* Simulate synchronous execution */
508 async_disable_stdin ();
511 /* If have argument (besides '&'), set proceed count of breakpoint
513 if (proc_count_exp != NULL)
515 bpstat bs = stop_bpstat;
516 int num = bpstat_num (&bs);
517 if (num == 0 && from_tty)
520 ("Not stopped at any breakpoint; argument ignored.\n");
524 set_ignore_count (num,
525 parse_and_eval_long (proc_count_exp) - 1,
527 /* set_ignore_count prints a message ending with a period.
528 So print two spaces before "Continuing.". */
530 printf_filtered (" ");
531 num = bpstat_num (&bs);
536 printf_filtered ("Continuing.\n");
538 clear_proceed_status ();
540 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
543 /* Step until outside of current statement. */
547 step_command (char *count_string, int from_tty)
549 step_1 (0, 0, count_string);
552 /* Likewise, but skip over subroutine calls as if single instructions. */
556 next_command (char *count_string, int from_tty)
558 step_1 (1, 0, count_string);
561 /* Likewise, but step only one instruction. */
565 stepi_command (char *count_string, int from_tty)
567 step_1 (0, 1, count_string);
572 nexti_command (char *count_string, int from_tty)
574 step_1 (1, 1, count_string);
578 disable_longjmp_breakpoint_cleanup (void *ignore)
580 disable_longjmp_breakpoint ();
584 step_1 (int skip_subroutines, int single_inst, char *count_string)
586 register int count = 1;
587 struct frame_info *frame;
588 struct cleanup *cleanups = 0;
594 async_exec = strip_bg_char (&count_string);
596 /* If we get a request for running in the bg but the target
597 doesn't support it, error out. */
598 if (event_loop_p && async_exec && !target_can_async_p ())
599 error ("Asynchronous execution not supported on this target.");
601 /* If we don't get a request of running in the bg, then we need
602 to simulate synchronous (fg) execution. */
603 if (event_loop_p && !async_exec && target_can_async_p ())
605 /* Simulate synchronous execution */
606 async_disable_stdin ();
609 count = count_string ? parse_and_eval_long (count_string) : 1;
611 if (!single_inst || skip_subroutines) /* leave si command alone */
613 enable_longjmp_breakpoint ();
614 if (!event_loop_p || !target_can_async_p ())
615 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
617 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
620 /* In synchronous case, all is well, just use the regular for loop. */
621 if (!event_loop_p || !target_can_async_p ())
623 for (; count > 0; count--)
625 clear_proceed_status ();
627 frame = get_current_frame ();
628 if (!frame) /* Avoid coredump here. Why tho? */
629 error ("No current frame");
630 step_frame_id = get_frame_id (frame);
631 step_sp = read_sp ();
635 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
636 if (step_range_end == 0)
639 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
640 &step_range_end) == 0)
641 error ("Cannot find bounds of current function");
643 target_terminal_ours ();
645 Single stepping until exit from function %s, \n\
646 which has no line number information.\n", name);
651 /* Say we are stepping, but stop after one insn whatever it does. */
652 step_range_start = step_range_end = 1;
653 if (!skip_subroutines)
655 Don't step over function calls, not even to functions lacking
657 step_over_calls = STEP_OVER_NONE;
660 if (skip_subroutines)
661 step_over_calls = STEP_OVER_ALL;
663 step_multi = (count > 1);
664 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
669 /* FIXME: On nexti, this may have already been done (when we hit the
670 step resume break, I think). Probably this should be moved to
671 wait_for_inferior (near the top). */
672 #if defined (SHIFT_INST_REGS)
677 if (!single_inst || skip_subroutines)
678 do_cleanups (cleanups);
681 /* In case of asynchronous target things get complicated, do only
682 one step for now, before returning control to the event loop. Let
683 the continuation figure out how many other steps we need to do,
684 and handle them one at the time, through step_once(). */
687 if (event_loop_p && target_can_async_p ())
688 step_once (skip_subroutines, single_inst, count);
692 /* Called after we are done with one step operation, to check whether
693 we need to step again, before we print the prompt and return control
694 to the user. If count is > 1, we will need to do one more call to
695 proceed(), via step_once(). Basically it is like step_once and
696 step_1_continuation are co-recursive. */
698 step_1_continuation (struct continuation_arg *arg)
701 int skip_subroutines;
704 skip_subroutines = arg->data.integer;
705 single_inst = arg->next->data.integer;
706 count = arg->next->next->data.integer;
710 /* FIXME: On nexti, this may have already been done (when we hit the
711 step resume break, I think). Probably this should be moved to
712 wait_for_inferior (near the top). */
713 #if defined (SHIFT_INST_REGS)
716 step_once (skip_subroutines, single_inst, count - 1);
719 if (!single_inst || skip_subroutines)
720 do_exec_cleanups (ALL_CLEANUPS);
723 /* Do just one step operation. If count >1 we will have to set up a
724 continuation to be done after the target stops (after this one
725 step). This is useful to implement the 'step n' kind of commands, in
726 case of asynchronous targets. We had to split step_1 into two parts,
727 one to be done before proceed() and one afterwards. This function is
728 called in case of step n with n>1, after the first step operation has
731 step_once (int skip_subroutines, int single_inst, int count)
733 struct continuation_arg *arg1;
734 struct continuation_arg *arg2;
735 struct continuation_arg *arg3;
736 struct frame_info *frame;
740 clear_proceed_status ();
742 frame = get_current_frame ();
743 if (!frame) /* Avoid coredump here. Why tho? */
744 error ("No current frame");
745 step_frame_id = get_frame_id (frame);
746 step_sp = read_sp ();
750 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
752 /* If we have no line info, switch to stepi mode. */
753 if (step_range_end == 0 && step_stop_if_no_debug)
755 step_range_start = step_range_end = 1;
757 else if (step_range_end == 0)
760 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
761 &step_range_end) == 0)
762 error ("Cannot find bounds of current function");
764 target_terminal_ours ();
766 Single stepping until exit from function %s, \n\
767 which has no line number information.\n", name);
772 /* Say we are stepping, but stop after one insn whatever it does. */
773 step_range_start = step_range_end = 1;
774 if (!skip_subroutines)
776 Don't step over function calls, not even to functions lacking
778 step_over_calls = STEP_OVER_NONE;
781 if (skip_subroutines)
782 step_over_calls = STEP_OVER_ALL;
784 step_multi = (count > 1);
786 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
788 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
790 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
792 arg1->data.integer = skip_subroutines;
794 arg2->data.integer = single_inst;
796 arg3->data.integer = count;
797 add_intermediate_continuation (step_1_continuation, arg1);
798 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
803 /* Continue program at specified address. */
806 jump_command (char *arg, int from_tty)
808 register CORE_ADDR addr;
809 struct symtabs_and_lines sals;
810 struct symtab_and_line sal;
817 /* Find out whether we must run in the background. */
819 async_exec = strip_bg_char (&arg);
821 /* If we must run in the background, but the target can't do it,
823 if (event_loop_p && async_exec && !target_can_async_p ())
824 error ("Asynchronous execution not supported on this target.");
826 /* If we are not asked to run in the bg, then prepare to run in the
827 foreground, synchronously. */
828 if (event_loop_p && !async_exec && target_can_async_p ())
830 /* Simulate synchronous execution */
831 async_disable_stdin ();
835 error_no_arg ("starting address");
837 sals = decode_line_spec_1 (arg, 1);
840 error ("Unreasonable jump request");
846 if (sal.symtab == 0 && sal.pc == 0)
847 error ("No source file has been specified.");
849 resolve_sal_pc (&sal); /* May error out */
851 /* See if we are trying to jump to another function. */
852 fn = get_frame_function (get_current_frame ());
853 sfn = find_pc_function (sal.pc);
854 if (fn != NULL && sfn != fn)
856 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
857 SYMBOL_SOURCE_NAME (fn)))
859 error ("Not confirmed.");
866 fixup_symbol_section (sfn, 0);
867 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
868 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
870 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
872 error ("Not confirmed.");
882 printf_filtered ("Continuing at ");
883 print_address_numeric (addr, 1, gdb_stdout);
884 printf_filtered (".\n");
887 clear_proceed_status ();
888 proceed (addr, TARGET_SIGNAL_0, 0);
892 /* Go to line or address in current procedure */
894 go_command (char *line_no, int from_tty)
896 if (line_no == (char *) NULL || !*line_no)
897 printf_filtered (GO_USAGE);
900 tbreak_command (line_no, from_tty);
901 jump_command (line_no, from_tty);
906 /* Continue program giving it specified signal. */
909 signal_command (char *signum_exp, int from_tty)
911 enum target_signal oursig;
913 dont_repeat (); /* Too dangerous. */
917 error_no_arg ("signal number");
919 /* It would be even slicker to make signal names be valid expressions,
920 (the type could be "enum $signal" or some such), then the user could
921 assign them to convenience variables. */
922 oursig = target_signal_from_name (signum_exp);
924 if (oursig == TARGET_SIGNAL_UNKNOWN)
926 /* No, try numeric. */
927 int num = parse_and_eval_long (signum_exp);
930 oursig = TARGET_SIGNAL_0;
932 oursig = target_signal_from_command (num);
937 if (oursig == TARGET_SIGNAL_0)
938 printf_filtered ("Continuing with no signal.\n");
940 printf_filtered ("Continuing with signal %s.\n",
941 target_signal_to_name (oursig));
944 clear_proceed_status ();
945 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
946 FIXME: Neither should "signal foo" but when I tried passing
947 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
948 tried to track down yet. */
949 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
952 /* Call breakpoint_auto_delete on the current contents of the bpstat
953 pointed to by arg (which is really a bpstat *). */
956 breakpoint_auto_delete_contents (PTR arg)
958 breakpoint_auto_delete (*(bpstat *) arg);
962 /* Execute a "stack dummy", a piece of code stored in the stack
963 by the debugger to be executed in the inferior.
965 To call: first, do PUSH_DUMMY_FRAME.
966 Then push the contents of the dummy. It should end with a breakpoint insn.
967 Then call here, passing address at which to start the dummy.
969 The contents of all registers are saved before the dummy frame is popped
970 and copied into the buffer BUFFER.
972 The dummy's frame is automatically popped whenever that break is hit.
973 If that is the first time the program stops, run_stack_dummy
974 returns to its caller with that frame already gone and returns 0.
976 Otherwise, run_stack-dummy returns a non-zero value.
977 If the called function receives a random signal, we do not allow the user
978 to continue executing it as this may not work. The dummy frame is poped
980 If we hit a breakpoint, we leave the frame in place and return 2 (the frame
981 will eventually be popped when we do hit the dummy end breakpoint). */
984 run_stack_dummy (CORE_ADDR addr, struct regcache *buffer)
986 struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
989 /* Now proceed, having reached the desired place. */
990 clear_proceed_status ();
992 if (CALL_DUMMY_BREAKPOINT_OFFSET_P)
994 struct breakpoint *bpt;
995 struct symtab_and_line sal;
997 init_sal (&sal); /* initialize to zeroes */
998 if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT)
1000 sal.pc = CALL_DUMMY_ADDRESS ();
1004 sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET;
1006 sal.section = find_pc_overlay (sal.pc);
1008 /* Set up a FRAME for the dummy frame so we can pass it to
1009 set_momentary_breakpoint. We need to give the breakpoint a
1010 frame in case there is only one copy of the dummy (e.g.
1011 CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
1012 flush_cached_frames ();
1013 set_current_frame (create_new_frame (read_fp (), sal.pc));
1015 /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
1016 a breakpoint instruction. If not, the call dummy already has the
1017 breakpoint instruction in it.
1019 addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
1020 so we need to subtract the CALL_DUMMY_START_OFFSET. */
1021 /* FIXME: cagney/2002-12-01: Rather than pass in curent frame,
1022 why not just create, and then pass in a frame ID. This would
1023 make it possible to eliminate set_current_frame(). */
1024 bpt = set_momentary_breakpoint (sal,
1025 get_frame_id (get_current_frame ()),
1027 bpt->disposition = disp_del;
1029 /* If all error()s out of proceed ended up calling normal_stop (and
1030 perhaps they should; it already does in the special case of error
1031 out of resume()), then we wouldn't need this. */
1032 make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
1035 disable_watchpoints_before_interactive_call_start ();
1036 proceed_to_finish = 1; /* We want stop_registers, please... */
1038 if (target_can_async_p ())
1039 saved_async = target_async_mask (0);
1041 proceed (addr, TARGET_SIGNAL_0, 0);
1044 target_async_mask (saved_async);
1046 enable_watchpoints_after_interactive_call_stop ();
1048 discard_cleanups (old_cleanups);
1050 /* We can stop during an inferior call because a signal is received. */
1051 if (stopped_by_random_signal)
1054 /* We may also stop prematurely because we hit a breakpoint in the
1056 if (!stop_stack_dummy)
1059 /* On normal return, the stack dummy has been popped already. */
1060 regcache_cpy_no_passthrough (buffer, stop_registers);
1064 /* Proceed until we reach a different source line with pc greater than
1065 our current one or exit the function. We skip calls in both cases.
1067 Note that eventually this command should probably be changed so
1068 that only source lines are printed out when we hit the breakpoint
1069 we set. This may involve changes to wait_for_inferior and the
1070 proceed status code. */
1074 until_next_command (int from_tty)
1076 struct frame_info *frame;
1078 struct symbol *func;
1079 struct symtab_and_line sal;
1081 clear_proceed_status ();
1083 frame = get_current_frame ();
1085 /* Step until either exited from this function or greater
1086 than the current line (if in symbolic section) or pc (if
1090 func = find_pc_function (pc);
1094 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1096 if (msymbol == NULL)
1097 error ("Execution is not within a known function.");
1099 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1100 step_range_end = pc;
1104 sal = find_pc_line (pc, 0);
1106 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1107 step_range_end = sal.end;
1110 step_over_calls = STEP_OVER_ALL;
1111 step_frame_id = get_frame_id (frame);
1112 step_sp = read_sp ();
1114 step_multi = 0; /* Only one call to proceed */
1116 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1120 until_command (char *arg, int from_tty)
1124 if (!target_has_execution)
1125 error ("The program is not running.");
1127 /* Find out whether we must run in the background. */
1129 async_exec = strip_bg_char (&arg);
1131 /* If we must run in the background, but the target can't do it,
1133 if (event_loop_p && async_exec && !target_can_async_p ())
1134 error ("Asynchronous execution not supported on this target.");
1136 /* If we are not asked to run in the bg, then prepare to run in the
1137 foreground, synchronously. */
1138 if (event_loop_p && !async_exec && target_can_async_p ())
1140 /* Simulate synchronous execution */
1141 async_disable_stdin ();
1145 until_break_command (arg, from_tty);
1147 until_next_command (from_tty);
1151 /* Print the result of a function at the end of a 'finish' command. */
1153 print_return_value (int structure_return, struct type *value_type)
1155 struct value *value;
1156 static struct ui_stream *stb = NULL;
1158 if (!structure_return)
1160 value = value_being_returned (value_type, stop_registers, structure_return);
1161 stb = ui_out_stream_new (uiout);
1162 ui_out_text (uiout, "Value returned is ");
1163 ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
1164 ui_out_text (uiout, " = ");
1165 value_print (value, stb->stream, 0, Val_no_prettyprint);
1166 ui_out_field_stream (uiout, "return-value", stb);
1167 ui_out_text (uiout, "\n");
1171 /* We cannot determine the contents of the structure because
1172 it is on the stack, and we don't know where, since we did not
1173 initiate the call, as opposed to the call_function_by_hand case */
1174 #ifdef VALUE_RETURNED_FROM_STACK
1176 ui_out_text (uiout, "Value returned has type: ");
1177 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1178 ui_out_text (uiout, ".");
1179 ui_out_text (uiout, " Cannot determine contents\n");
1181 value = value_being_returned (value_type, stop_registers, structure_return);
1182 stb = ui_out_stream_new (uiout);
1183 ui_out_text (uiout, "Value returned is ");
1184 ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
1185 ui_out_text (uiout, " = ");
1186 value_print (value, stb->stream, 0, Val_no_prettyprint);
1187 ui_out_field_stream (uiout, "return-value", stb);
1188 ui_out_text (uiout, "\n");
1193 /* Stuff that needs to be done by the finish command after the target
1194 has stopped. In asynchronous mode, we wait for the target to stop in
1195 the call to poll or select in the event loop, so it is impossible to
1196 do all the stuff as part of the finish_command function itself. The
1197 only chance we have to complete this command is in
1198 fetch_inferior_event, which is called by the event loop as soon as it
1199 detects that the target has stopped. This function is called via the
1200 cmd_continuation pointer. */
1202 finish_command_continuation (struct continuation_arg *arg)
1204 register struct symbol *function;
1205 struct breakpoint *breakpoint;
1206 struct cleanup *cleanups;
1208 breakpoint = (struct breakpoint *) arg->data.pointer;
1209 function = (struct symbol *) arg->next->data.pointer;
1210 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1212 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1215 struct type *value_type;
1219 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1221 internal_error (__FILE__, __LINE__,
1222 "finish_command: function has no target type");
1224 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1226 do_exec_cleanups (cleanups);
1230 funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
1232 struct_return = using_struct_return (value_of_variable (function, NULL),
1234 check_typedef (value_type),
1235 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
1237 print_return_value (struct_return, value_type);
1239 do_exec_cleanups (cleanups);
1242 /* "finish": Set a temporary breakpoint at the place
1243 the selected frame will return to, then continue. */
1246 finish_command (char *arg, int from_tty)
1248 struct symtab_and_line sal;
1249 register struct frame_info *frame;
1250 register struct symbol *function;
1251 struct breakpoint *breakpoint;
1252 struct cleanup *old_chain;
1253 struct continuation_arg *arg1, *arg2, *arg3;
1257 /* Find out whether we must run in the background. */
1259 async_exec = strip_bg_char (&arg);
1261 /* If we must run in the background, but the target can't do it,
1263 if (event_loop_p && async_exec && !target_can_async_p ())
1264 error ("Asynchronous execution not supported on this target.");
1266 /* If we are not asked to run in the bg, then prepare to run in the
1267 foreground, synchronously. */
1268 if (event_loop_p && !async_exec && target_can_async_p ())
1270 /* Simulate synchronous execution */
1271 async_disable_stdin ();
1275 error ("The \"finish\" command does not take any arguments.");
1276 if (!target_has_execution)
1277 error ("The program is not running.");
1278 if (deprecated_selected_frame == NULL)
1279 error ("No selected frame.");
1281 frame = get_prev_frame (deprecated_selected_frame);
1283 error ("\"finish\" not meaningful in the outermost frame.");
1285 clear_proceed_status ();
1287 sal = find_pc_line (get_frame_pc (frame), 0);
1288 sal.pc = get_frame_pc (frame);
1290 breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame), bp_finish);
1292 if (!event_loop_p || !target_can_async_p ())
1293 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1295 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1297 /* Find the function we will return from. */
1299 function = find_pc_function (get_frame_pc (deprecated_selected_frame));
1301 /* Print info on the selected frame, including level number
1305 printf_filtered ("Run till exit from ");
1306 print_stack_frame (deprecated_selected_frame,
1307 frame_relative_level (deprecated_selected_frame), 0);
1310 /* If running asynchronously and the target support asynchronous
1311 execution, set things up for the rest of the finish command to be
1312 completed later on, when gdb has detected that the target has
1313 stopped, in fetch_inferior_event. */
1314 if (event_loop_p && target_can_async_p ())
1317 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1319 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1321 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1325 arg1->data.pointer = breakpoint;
1326 arg2->data.pointer = function;
1327 arg3->data.pointer = old_chain;
1328 add_continuation (finish_command_continuation, arg1);
1331 proceed_to_finish = 1; /* We want stop_registers, please... */
1332 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1334 /* Do this only if not running asynchronously or if the target
1335 cannot do async execution. Otherwise, complete this command when
1336 the target actually stops, in fetch_inferior_event. */
1337 if (!event_loop_p || !target_can_async_p ())
1340 /* Did we stop at our breakpoint? */
1341 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1344 struct type *value_type;
1348 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1350 internal_error (__FILE__, __LINE__,
1351 "finish_command: function has no target type");
1353 /* FIXME: Shouldn't we do the cleanups before returning? */
1354 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1357 funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
1360 using_struct_return (value_of_variable (function, NULL),
1362 check_typedef (value_type),
1363 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
1365 print_return_value (struct_return, value_type);
1367 do_cleanups (old_chain);
1373 program_info (char *args, int from_tty)
1375 bpstat bs = stop_bpstat;
1376 int num = bpstat_num (&bs);
1378 if (!target_has_execution)
1380 printf_filtered ("The program being debugged is not being run.\n");
1384 target_files_info ();
1385 printf_filtered ("Program stopped at %s.\n",
1386 local_hex_string ((unsigned long) stop_pc));
1388 printf_filtered ("It stopped after being stepped.\n");
1391 /* There may be several breakpoints in the same place, so this
1392 isn't as strange as it seems. */
1397 printf_filtered ("It stopped at a breakpoint that has ");
1398 printf_filtered ("since been deleted.\n");
1401 printf_filtered ("It stopped at breakpoint %d.\n", num);
1402 num = bpstat_num (&bs);
1405 else if (stop_signal != TARGET_SIGNAL_0)
1407 printf_filtered ("It stopped with signal %s, %s.\n",
1408 target_signal_to_name (stop_signal),
1409 target_signal_to_string (stop_signal));
1414 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1415 printf_filtered ("for more information.\n");
1420 environment_info (char *var, int from_tty)
1424 register char *val = get_in_environ (inferior_environ, var);
1427 puts_filtered (var);
1428 puts_filtered (" = ");
1429 puts_filtered (val);
1430 puts_filtered ("\n");
1434 puts_filtered ("Environment variable \"");
1435 puts_filtered (var);
1436 puts_filtered ("\" not defined.\n");
1441 register char **vector = environ_vector (inferior_environ);
1444 puts_filtered (*vector++);
1445 puts_filtered ("\n");
1451 set_environment_command (char *arg, int from_tty)
1453 register char *p, *val, *var;
1457 error_no_arg ("environment variable and value");
1459 /* Find seperation between variable name and value */
1460 p = (char *) strchr (arg, '=');
1461 val = (char *) strchr (arg, ' ');
1463 if (p != 0 && val != 0)
1465 /* We have both a space and an equals. If the space is before the
1466 equals, walk forward over the spaces til we see a nonspace
1467 (possibly the equals). */
1472 /* Now if the = is after the char following the spaces,
1473 take the char following the spaces. */
1477 else if (val != 0 && p == 0)
1481 error_no_arg ("environment variable to set");
1483 if (p == 0 || p[1] == 0)
1487 p = arg + strlen (arg); /* So that savestring below will work */
1491 /* Not setting variable value to null */
1493 while (*val == ' ' || *val == '\t')
1497 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1500 var = savestring (arg, p - arg);
1503 printf_filtered ("Setting environment variable ");
1504 printf_filtered ("\"%s\" to null value.\n", var);
1505 set_in_environ (inferior_environ, var, "");
1508 set_in_environ (inferior_environ, var, val);
1513 unset_environment_command (char *var, int from_tty)
1517 /* If there is no argument, delete all environment variables.
1518 Ask for confirmation if reading from the terminal. */
1519 if (!from_tty || query ("Delete all environment variables? "))
1521 free_environ (inferior_environ);
1522 inferior_environ = make_environ ();
1526 unset_in_environ (inferior_environ, var);
1529 /* Handle the execution path (PATH variable) */
1531 static const char path_var_name[] = "PATH";
1535 path_info (char *args, int from_tty)
1537 puts_filtered ("Executable and object file path: ");
1538 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1539 puts_filtered ("\n");
1542 /* Add zero or more directories to the front of the execution path. */
1545 path_command (char *dirname, int from_tty)
1550 env = get_in_environ (inferior_environ, path_var_name);
1551 /* Can be null if path is not set */
1554 exec_path = xstrdup (env);
1555 mod_path (dirname, &exec_path);
1556 set_in_environ (inferior_environ, path_var_name, exec_path);
1559 path_info ((char *) NULL, from_tty);
1563 #ifdef REGISTER_NAMES
1564 char *gdb_register_names[] = REGISTER_NAMES;
1566 /* Print out the machine register regnum. If regnum is -1, print all
1567 registers (print_all == 1) or all non-float and non-vector
1568 registers (print_all == 0).
1570 For most machines, having all_registers_info() print the
1571 register(s) one per line is good enough. If a different format is
1572 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1573 regs), or there is an existing convention for showing all the
1574 registers, define the architecture method PRINT_REGISTERS_INFO to
1575 provide that format. */
1578 default_print_registers_info (struct gdbarch *gdbarch,
1579 struct ui_file *file,
1580 struct frame_info *frame,
1581 int regnum, int print_all)
1584 const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
1585 char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
1586 char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
1588 if (DEPRECATED_DO_REGISTERS_INFO_P ())
1590 DEPRECATED_DO_REGISTERS_INFO (regnum, print_all);
1594 for (i = 0; i < numregs; i++)
1596 /* Decide between printing all regs, non-float / vector regs, or
1602 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1607 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1617 /* If the register name is empty, it is undefined for this
1618 processor, so don't display anything. */
1619 if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1622 fputs_filtered (REGISTER_NAME (i), file);
1623 print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
1625 /* Get the data in raw format. */
1626 if (! frame_register_read (frame, i, raw_buffer))
1628 fprintf_filtered (file, "*value not available*\n");
1632 /* FIXME: cagney/2002-08-03: This code shouldn't be necessary.
1633 The function frame_register_read() should have returned the
1634 pre-cooked register so no conversion is necessary. */
1635 /* Convert raw data to virtual format if necessary. */
1636 if (REGISTER_CONVERTIBLE (i))
1638 REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
1639 raw_buffer, virtual_buffer);
1643 memcpy (virtual_buffer, raw_buffer,
1644 REGISTER_VIRTUAL_SIZE (i));
1647 /* If virtual format is floating, print it that way, and in raw
1649 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
1653 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1654 file, 0, 1, 0, Val_pretty_default);
1656 fprintf_filtered (file, "\t(raw 0x");
1657 for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
1660 if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
1663 idx = REGISTER_RAW_SIZE (i) - 1 - j;
1664 fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
1666 fprintf_filtered (file, ")");
1670 /* Print the register in hex. */
1671 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1672 file, 'x', 1, 0, Val_pretty_default);
1673 /* If not a vector register, print it also according to its
1675 if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)) == 0)
1677 fprintf_filtered (file, "\t");
1678 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1679 file, 0, 1, 0, Val_pretty_default);
1683 fprintf_filtered (file, "\n");
1688 registers_info (char *addr_exp, int fpregs)
1690 int regnum, numregs;
1693 if (!target_has_registers)
1694 error ("The program has no registers now.");
1695 if (deprecated_selected_frame == NULL)
1696 error ("No selected frame.");
1700 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1701 deprecated_selected_frame, -1, fpregs);
1705 while (*addr_exp != '\0')
1710 /* Keep skipping leading white space. */
1711 if (isspace ((*addr_exp)))
1717 /* Discard any leading ``$''. Check that there is something
1718 resembling a register following it. */
1719 if (addr_exp[0] == '$')
1721 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1722 error ("Missing register name");
1724 /* Find the start/end of this register name/num/group. */
1726 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1730 /* Figure out what we've found and display it. */
1732 /* A register name? */
1734 int regnum = frame_map_name_to_regnum (start, end - start);
1737 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1738 deprecated_selected_frame, regnum, fpregs);
1743 /* A register number? (how portable is this one?). */
1746 int regnum = strtol (start, &endptr, 0);
1749 && regnum < NUM_REGS + NUM_PSEUDO_REGS)
1751 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1752 deprecated_selected_frame, regnum, fpregs);
1757 /* A register group? */
1759 struct reggroup *const *group;
1760 for (group = reggroups (current_gdbarch);
1764 /* Don't bother with a length check. Should the user
1765 enter a short register group name, go with the first
1766 group that matches. */
1767 if (strncmp (start, reggroup_name ((*group)), end - start) == 0)
1770 if ((*group) != NULL)
1773 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1775 if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
1777 gdbarch_print_registers_info (current_gdbarch,
1778 gdb_stdout, deprecated_selected_frame,
1785 /* Nothing matched. */
1786 error ("Invalid register `%.*s'", (int) (end - start), start);
1791 all_registers_info (char *addr_exp, int from_tty)
1793 registers_info (addr_exp, 1);
1797 nofp_registers_info (char *addr_exp, int from_tty)
1799 registers_info (addr_exp, 0);
1803 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
1804 struct frame_info *frame, const char *args)
1806 if (!target_has_registers)
1807 error ("The program has no registers now.");
1808 if (deprecated_selected_frame == NULL)
1809 error ("No selected frame.");
1811 if (gdbarch_print_vector_info_p (gdbarch))
1812 gdbarch_print_vector_info (gdbarch, file, frame, args);
1816 int printed_something = 0;
1818 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1820 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
1822 printed_something = 1;
1823 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1826 if (!printed_something)
1827 fprintf_filtered (file, "No vector information\n");
1832 vector_info (char *args, int from_tty)
1834 print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
1840 * Should save/restore the tty state since it might be that the
1841 * program to be debugged was started on this tty and it wants
1842 * the tty in some state other than what we want. If it's running
1843 * on another terminal or without a terminal, then saving and
1844 * restoring the tty state is a harmless no-op.
1845 * This only needs to be done if we are attaching to a process.
1850 takes a program started up outside of gdb and ``attaches'' to it.
1851 This stops it cold in its tracks and allows us to start debugging it.
1852 and wait for the trace-trap that results from attaching. */
1855 attach_command (char *args, int from_tty)
1858 char *full_exec_path = NULL;
1860 dont_repeat (); /* Not for the faint of heart */
1862 if (target_has_execution)
1864 if (query ("A program is being debugged already. Kill it? "))
1867 error ("Not killed.");
1870 target_attach (args, from_tty);
1872 /* Set up the "saved terminal modes" of the inferior
1873 based on what modes we are starting it with. */
1874 target_terminal_init ();
1876 /* Install inferior's terminal modes. */
1877 target_terminal_inferior ();
1879 /* Set up execution context to know that we should return from
1880 wait_for_inferior as soon as the target reports a stop. */
1881 init_wait_for_inferior ();
1882 clear_proceed_status ();
1884 /* No traps are generated when attaching to inferior under Mach 3
1886 #ifndef ATTACH_NO_WAIT
1887 stop_soon_quietly = 1;
1888 wait_for_inferior ();
1892 * If no exec file is yet known, try to determine it from the
1895 exec_file = (char *) get_exec_file (0);
1898 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
1901 /* It's possible we don't have a full path, but rather just a
1902 filename. Some targets, such as HP-UX, don't provide the
1905 Attempt to qualify the filename against the source path.
1906 (If that fails, we'll just fall back on the original
1907 filename. Not much more we can do...)
1909 if (!source_full_path_of (exec_file, &full_exec_path))
1910 full_exec_path = savestring (exec_file, strlen (exec_file));
1912 exec_file_attach (full_exec_path, from_tty);
1913 symbol_file_add_main (full_exec_path, from_tty);
1918 /* Add shared library symbols from the newly attached process, if any. */
1919 SOLIB_ADD ((char *) 0, from_tty, ¤t_target, auto_solib_add);
1920 re_enable_breakpoints_in_shlibs ();
1923 /* Take any necessary post-attaching actions for this platform.
1925 target_post_attach (PIDGET (inferior_ptid));
1935 * takes a program previously attached to and detaches it.
1936 * The program resumes execution and will no longer stop
1937 * on signals, etc. We better not have left any breakpoints
1938 * in the program or it'll die when it hits one. For this
1939 * to work, it may be necessary for the process to have been
1940 * previously attached. It *might* work if the program was
1941 * started via the normal ptrace (PTRACE_TRACEME).
1945 detach_command (char *args, int from_tty)
1947 dont_repeat (); /* Not for the faint of heart */
1948 target_detach (args, from_tty);
1949 #if defined(SOLIB_RESTART)
1956 /* Stop the execution of the target while running in async mode, in
1959 interrupt_target_command (char *args, int from_tty)
1961 if (event_loop_p && target_can_async_p ())
1963 dont_repeat (); /* Not for the faint of heart */
1970 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
1971 struct frame_info *frame, const char *args)
1973 if (!target_has_registers)
1974 error ("The program has no registers now.");
1975 if (deprecated_selected_frame == NULL)
1976 error ("No selected frame.");
1978 if (gdbarch_print_float_info_p (gdbarch))
1979 gdbarch_print_float_info (gdbarch, file, frame, args);
1983 #if GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL
1984 #error "FLOAT_INFO defined in multi-arch"
1989 int printed_something = 0;
1991 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1993 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
1995 printed_something = 1;
1996 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1999 if (!printed_something)
2000 fprintf_filtered (file, "\
2001 No floating-point info available for this processor.\n");
2007 float_info (char *args, int from_tty)
2009 print_float_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
2014 unset_command (char *args, int from_tty)
2016 printf_filtered ("\"unset\" must be followed by the name of ");
2017 printf_filtered ("an unset subcommand.\n");
2018 help_list (unsetlist, "unset ", -1, gdb_stdout);
2022 _initialize_infcmd (void)
2024 struct cmd_list_element *c;
2026 c = add_com ("tty", class_run, tty_command,
2027 "Set terminal for future runs of program being debugged.");
2028 set_cmd_completer (c, filename_completer);
2030 c = add_set_cmd ("args", class_run, var_string_noescape,
2031 (char *) &inferior_args,
2032 "Set argument list to give program being debugged when it is started.\n\
2033 Follow this command with any number of args, to be passed to the program.",
2035 set_cmd_completer (c, filename_completer);
2036 set_cmd_sfunc (c, notice_args_set);
2037 c = add_show_from_set (c, &showlist);
2038 set_cmd_sfunc (c, notice_args_read);
2041 ("environment", no_class, environment_info,
2042 "The environment to give the program, or one variable's value.\n\
2043 With an argument VAR, prints the value of environment variable VAR to\n\
2044 give the program being debugged. With no arguments, prints the entire\n\
2045 environment to be given to the program.", &showlist);
2046 set_cmd_completer (c, noop_completer);
2048 add_prefix_cmd ("unset", no_class, unset_command,
2049 "Complement to certain \"set\" commands.",
2050 &unsetlist, "unset ", 0, &cmdlist);
2052 c = add_cmd ("environment", class_run, unset_environment_command,
2053 "Cancel environment variable VAR for the program.\n\
2054 This does not affect the program until the next \"run\" command.",
2056 set_cmd_completer (c, noop_completer);
2058 c = add_cmd ("environment", class_run, set_environment_command,
2059 "Set environment variable value to give the program.\n\
2060 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2061 VALUES of environment variables are uninterpreted strings.\n\
2062 This does not affect the program until the next \"run\" command.",
2064 set_cmd_completer (c, noop_completer);
2066 c = add_com ("path", class_files, path_command,
2067 "Add directory DIR(s) to beginning of search path for object files.\n\
2068 $cwd in the path means the current working directory.\n\
2069 This path is equivalent to the $PATH shell variable. It is a list of\n\
2070 directories, separated by colons. These directories are searched to find\n\
2071 fully linked executable files and separately compiled object files as needed.");
2072 set_cmd_completer (c, filename_completer);
2074 c = add_cmd ("paths", no_class, path_info,
2075 "Current search path for finding object files.\n\
2076 $cwd in the path means the current working directory.\n\
2077 This path is equivalent to the $PATH shell variable. It is a list of\n\
2078 directories, separated by colons. These directories are searched to find\n\
2079 fully linked executable files and separately compiled object files as needed.",
2081 set_cmd_completer (c, noop_completer);
2083 add_com ("attach", class_run, attach_command,
2084 "Attach to a process or file outside of GDB.\n\
2085 This command attaches to another target, of the same type as your last\n\
2086 \"target\" command (\"info files\" will show your target stack).\n\
2087 The command may take as argument a process id or a device file.\n\
2088 For a process id, you must have permission to send the process a signal,\n\
2089 and it must have the same effective uid as the debugger.\n\
2090 When using \"attach\" with a process id, the debugger finds the\n\
2091 program running in the process, looking first in the current working\n\
2092 directory, or (if not found there) using the source file search path\n\
2093 (see the \"directory\" command). You can also use the \"file\" command\n\
2094 to specify the program, and to load its symbol table.");
2096 add_com ("detach", class_run, detach_command,
2097 "Detach a process or file previously attached.\n\
2098 If a process, it is no longer traced, and it continues its execution. If\n\
2099 you were debugging a file, the file is closed and gdb no longer accesses it.");
2101 add_com ("signal", class_run, signal_command,
2102 "Continue program giving it signal specified by the argument.\n\
2103 An argument of \"0\" means continue program without giving it a signal.");
2105 add_com ("stepi", class_run, stepi_command,
2106 "Step one instruction exactly.\n\
2107 Argument N means do this N times (or till program stops for another reason).");
2108 add_com_alias ("si", "stepi", class_alias, 0);
2110 add_com ("nexti", class_run, nexti_command,
2111 "Step one instruction, but proceed through subroutine calls.\n\
2112 Argument N means do this N times (or till program stops for another reason).");
2113 add_com_alias ("ni", "nexti", class_alias, 0);
2115 add_com ("finish", class_run, finish_command,
2116 "Execute until selected stack frame returns.\n\
2117 Upon return, the value returned is printed and put in the value history.");
2119 add_com ("next", class_run, next_command,
2120 "Step program, proceeding through subroutine calls.\n\
2121 Like the \"step\" command as long as subroutine calls do not happen;\n\
2122 when they do, the call is treated as one instruction.\n\
2123 Argument N means do this N times (or till program stops for another reason).");
2124 add_com_alias ("n", "next", class_run, 1);
2126 add_com_alias ("S", "next", class_run, 1);
2128 add_com ("step", class_run, step_command,
2129 "Step program until it reaches a different source line.\n\
2130 Argument N means do this N times (or till program stops for another reason).");
2131 add_com_alias ("s", "step", class_run, 1);
2133 c = add_com ("until", class_run, until_command,
2134 "Execute until the program reaches a source line greater than the current\n\
2135 or a specified line or address or function (same args as break command).\n\
2136 Execution will also stop upon exit from the current stack frame.");
2137 set_cmd_completer (c, location_completer);
2138 add_com_alias ("u", "until", class_run, 1);
2140 c = add_com ("jump", class_run, jump_command,
2141 "Continue program being debugged at specified line or address.\n\
2142 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2143 for an address to start at.");
2144 set_cmd_completer (c, location_completer);
2148 c = add_com ("go", class_run, go_command,
2149 "Usage: go <location>\n\
2150 Continue program being debugged, stopping at specified line or \n\
2152 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2153 expression for an address to start at.\n\
2154 This command is a combination of tbreak and jump.");
2155 set_cmd_completer (c, location_completer);
2159 add_com_alias ("g", "go", class_run, 1);
2161 add_com ("continue", class_run, continue_command,
2162 "Continue program being debugged, after signal or breakpoint.\n\
2163 If proceeding from breakpoint, a number N may be used as an argument,\n\
2164 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2165 the breakpoint won't break until the Nth time it is reached).");
2166 add_com_alias ("c", "cont", class_run, 1);
2167 add_com_alias ("fg", "cont", class_run, 1);
2169 c = add_com ("run", class_run, run_command,
2170 "Start debugged program. You may specify arguments to give it.\n\
2171 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2172 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2173 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2174 To cancel previous arguments and run with no arguments,\n\
2175 use \"set args\" without arguments.");
2176 set_cmd_completer (c, filename_completer);
2177 add_com_alias ("r", "run", class_run, 1);
2179 add_com ("R", class_run, run_no_args_command,
2180 "Start debugged program with no arguments.");
2182 add_com ("interrupt", class_run, interrupt_target_command,
2183 "Interrupt the execution of the debugged program.");
2185 add_info ("registers", nofp_registers_info,
2186 "List of integer registers and their contents, for selected stack frame.\n\
2187 Register name as argument means describe only that register.");
2188 add_info_alias ("r", "registers", 1);
2191 add_com ("lr", class_info, nofp_registers_info,
2192 "List of integer registers and their contents, for selected stack frame.\n\
2193 Register name as argument means describe only that register.");
2194 add_info ("all-registers", all_registers_info,
2195 "List of all registers and their contents, for selected stack frame.\n\
2196 Register name as argument means describe only that register.");
2198 add_info ("program", program_info,
2199 "Execution status of the program.");
2201 add_info ("float", float_info,
2202 "Print the status of the floating point unit\n");
2204 add_info ("vector", vector_info,
2205 "Print the status of the vector unit\n");
2207 inferior_environ = make_environ ();
2208 init_environ (inferior_environ);