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 CORE_ADDR step_frame_address;
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;
283 result = (char *) xmalloc (length);
286 for (i = 0; i < argc; ++i)
291 for (cp = argv[i]; *cp; ++cp)
293 if (strchr (special, *cp) != NULL)
302 /* In this case we can't handle arguments that contain spaces,
303 tabs, or newlines -- see breakup_args(). */
307 for (i = 0; i < argc; ++i)
309 char *cp = strchr (argv[i], ' ');
311 cp = strchr (argv[i], '\t');
313 cp = strchr (argv[i], '\n');
315 error ("can't handle command-line argument containing whitespace");
316 length += strlen (argv[i]) + 1;
319 result = (char *) xmalloc (length);
321 for (i = 0; i < argc; ++i)
324 strcat (result, " ");
325 strcat (result, argv[i]);
333 /* This function detects whether or not a '&' character (indicating
334 background execution) has been added as *the last* of the arguments ARGS
335 of a command. If it has, it removes it and returns 1. Otherwise it
336 does nothing and returns 0. */
338 strip_bg_char (char **args)
342 p = strchr (*args, '&');
346 if (p == (*args + strlen (*args) - 1))
348 if (strlen (*args) > 1)
352 while (*p == ' ' || *p == '\t');
365 tty_command (char *file, int from_tty)
368 error_no_arg ("terminal name for running target process");
370 inferior_io_terminal = savestring (file, strlen (file));
374 run_command (char *args, int from_tty)
380 if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
383 && !query ("The program being debugged has been started already.\n\
384 Start it from the beginning? "))
385 error ("Program not restarted.");
387 #if defined(SOLIB_RESTART)
390 init_wait_for_inferior ();
393 clear_breakpoint_hit_counts ();
395 /* Purge old solib objfiles. */
396 objfile_purge_solibs ();
398 do_run_cleanups (NULL);
400 /* The comment here used to read, "The exec file is re-read every
401 time we do a generic_mourn_inferior, so we just have to worry
402 about the symbol file." The `generic_mourn_inferior' function
403 gets called whenever the program exits. However, suppose the
404 program exits, and *then* the executable file changes? We need
405 to check again here. Since reopen_exec_file doesn't do anything
406 if the timestamp hasn't changed, I don't see the harm. */
410 exec_file = (char *) get_exec_file (0);
412 /* We keep symbols from add-symbol-file, on the grounds that the
413 user might want to add some symbols before running the program
414 (right?). But sometimes (dynamic loading where the user manually
415 introduces the new symbols with add-symbol-file), the code which
416 the symbols describe does not persist between runs. Currently
417 the user has to manually nuke all symbols between runs if they
418 want them to go away (PR 2207). This is probably reasonable. */
422 if (event_loop_p && target_can_async_p ())
423 async_disable_stdin ();
427 int async_exec = strip_bg_char (&args);
429 /* If we get a request for running in the bg but the target
430 doesn't support it, error out. */
431 if (event_loop_p && async_exec && !target_can_async_p ())
432 error ("Asynchronous execution not supported on this target.");
434 /* If we don't get a request of running in the bg, then we need
435 to simulate synchronous (fg) execution. */
436 if (event_loop_p && !async_exec && target_can_async_p ())
438 /* Simulate synchronous execution */
439 async_disable_stdin ();
442 /* If there were other args, beside '&', process them. */
445 char *old_args = set_inferior_args (xstrdup (args));
452 ui_out_field_string (uiout, NULL, "Starting program");
453 ui_out_text (uiout, ": ");
455 ui_out_field_string (uiout, "execfile", exec_file);
456 ui_out_spaces (uiout, 1);
457 /* We call get_inferior_args() because we might need to compute
459 ui_out_field_string (uiout, "infargs", get_inferior_args ());
460 ui_out_text (uiout, "\n");
461 ui_out_flush (uiout);
464 /* We call get_inferior_args() because we might need to compute
466 target_create_inferior (exec_file, get_inferior_args (),
467 environ_vector (inferior_environ));
472 run_no_args_command (char *args, int from_tty)
474 char *old_args = set_inferior_args (xstrdup (""));
480 continue_command (char *proc_count_exp, int from_tty)
485 /* Find out whether we must run in the background. */
486 if (proc_count_exp != NULL)
487 async_exec = strip_bg_char (&proc_count_exp);
489 /* If we must run in the background, but the target can't do it,
491 if (event_loop_p && async_exec && !target_can_async_p ())
492 error ("Asynchronous execution not supported on this target.");
494 /* If we are not asked to run in the bg, then prepare to run in the
495 foreground, synchronously. */
496 if (event_loop_p && !async_exec && target_can_async_p ())
498 /* Simulate synchronous execution */
499 async_disable_stdin ();
502 /* If have argument (besides '&'), set proceed count of breakpoint
504 if (proc_count_exp != NULL)
506 bpstat bs = stop_bpstat;
507 int num = bpstat_num (&bs);
508 if (num == 0 && from_tty)
511 ("Not stopped at any breakpoint; argument ignored.\n");
515 set_ignore_count (num,
516 parse_and_eval_long (proc_count_exp) - 1,
518 /* set_ignore_count prints a message ending with a period.
519 So print two spaces before "Continuing.". */
521 printf_filtered (" ");
522 num = bpstat_num (&bs);
527 printf_filtered ("Continuing.\n");
529 clear_proceed_status ();
531 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
534 /* Step until outside of current statement. */
538 step_command (char *count_string, int from_tty)
540 step_1 (0, 0, count_string);
543 /* Likewise, but skip over subroutine calls as if single instructions. */
547 next_command (char *count_string, int from_tty)
549 step_1 (1, 0, count_string);
552 /* Likewise, but step only one instruction. */
556 stepi_command (char *count_string, int from_tty)
558 step_1 (0, 1, count_string);
563 nexti_command (char *count_string, int from_tty)
565 step_1 (1, 1, count_string);
569 disable_longjmp_breakpoint_cleanup (void *ignore)
571 disable_longjmp_breakpoint ();
575 step_1 (int skip_subroutines, int single_inst, char *count_string)
577 register int count = 1;
578 struct frame_info *frame;
579 struct cleanup *cleanups = 0;
585 async_exec = strip_bg_char (&count_string);
587 /* If we get a request for running in the bg but the target
588 doesn't support it, error out. */
589 if (event_loop_p && async_exec && !target_can_async_p ())
590 error ("Asynchronous execution not supported on this target.");
592 /* If we don't get a request of running in the bg, then we need
593 to simulate synchronous (fg) execution. */
594 if (event_loop_p && !async_exec && target_can_async_p ())
596 /* Simulate synchronous execution */
597 async_disable_stdin ();
600 count = count_string ? parse_and_eval_long (count_string) : 1;
602 if (!single_inst || skip_subroutines) /* leave si command alone */
604 enable_longjmp_breakpoint ();
605 if (!event_loop_p || !target_can_async_p ())
606 cleanups = make_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
608 make_exec_cleanup (disable_longjmp_breakpoint_cleanup, 0 /*ignore*/);
611 /* In synchronous case, all is well, just use the regular for loop. */
612 if (!event_loop_p || !target_can_async_p ())
614 for (; count > 0; count--)
616 clear_proceed_status ();
618 frame = get_current_frame ();
619 if (!frame) /* Avoid coredump here. Why tho? */
620 error ("No current frame");
621 step_frame_address = get_frame_base (frame);
622 step_sp = read_sp ();
626 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
627 if (step_range_end == 0)
630 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
631 &step_range_end) == 0)
632 error ("Cannot find bounds of current function");
634 target_terminal_ours ();
636 Single stepping until exit from function %s, \n\
637 which has no line number information.\n", name);
642 /* Say we are stepping, but stop after one insn whatever it does. */
643 step_range_start = step_range_end = 1;
644 if (!skip_subroutines)
646 Don't step over function calls, not even to functions lacking
648 step_over_calls = STEP_OVER_NONE;
651 if (skip_subroutines)
652 step_over_calls = STEP_OVER_ALL;
654 step_multi = (count > 1);
655 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
660 /* FIXME: On nexti, this may have already been done (when we hit the
661 step resume break, I think). Probably this should be moved to
662 wait_for_inferior (near the top). */
663 #if defined (SHIFT_INST_REGS)
668 if (!single_inst || skip_subroutines)
669 do_cleanups (cleanups);
672 /* In case of asynchronous target things get complicated, do only
673 one step for now, before returning control to the event loop. Let
674 the continuation figure out how many other steps we need to do,
675 and handle them one at the time, through step_once(). */
678 if (event_loop_p && target_can_async_p ())
679 step_once (skip_subroutines, single_inst, count);
683 /* Called after we are done with one step operation, to check whether
684 we need to step again, before we print the prompt and return control
685 to the user. If count is > 1, we will need to do one more call to
686 proceed(), via step_once(). Basically it is like step_once and
687 step_1_continuation are co-recursive. */
689 step_1_continuation (struct continuation_arg *arg)
692 int skip_subroutines;
695 skip_subroutines = arg->data.integer;
696 single_inst = arg->next->data.integer;
697 count = arg->next->next->data.integer;
701 /* FIXME: On nexti, this may have already been done (when we hit the
702 step resume break, I think). Probably this should be moved to
703 wait_for_inferior (near the top). */
704 #if defined (SHIFT_INST_REGS)
707 step_once (skip_subroutines, single_inst, count - 1);
710 if (!single_inst || skip_subroutines)
711 do_exec_cleanups (ALL_CLEANUPS);
714 /* Do just one step operation. If count >1 we will have to set up a
715 continuation to be done after the target stops (after this one
716 step). This is useful to implement the 'step n' kind of commands, in
717 case of asynchronous targets. We had to split step_1 into two parts,
718 one to be done before proceed() and one afterwards. This function is
719 called in case of step n with n>1, after the first step operation has
722 step_once (int skip_subroutines, int single_inst, int count)
724 struct continuation_arg *arg1;
725 struct continuation_arg *arg2;
726 struct continuation_arg *arg3;
727 struct frame_info *frame;
731 clear_proceed_status ();
733 frame = get_current_frame ();
734 if (!frame) /* Avoid coredump here. Why tho? */
735 error ("No current frame");
736 step_frame_address = get_frame_base (frame);
737 step_sp = read_sp ();
741 find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
743 /* If we have no line info, switch to stepi mode. */
744 if (step_range_end == 0 && step_stop_if_no_debug)
746 step_range_start = step_range_end = 1;
748 else if (step_range_end == 0)
751 if (find_pc_partial_function (stop_pc, &name, &step_range_start,
752 &step_range_end) == 0)
753 error ("Cannot find bounds of current function");
755 target_terminal_ours ();
757 Single stepping until exit from function %s, \n\
758 which has no line number information.\n", name);
763 /* Say we are stepping, but stop after one insn whatever it does. */
764 step_range_start = step_range_end = 1;
765 if (!skip_subroutines)
767 Don't step over function calls, not even to functions lacking
769 step_over_calls = STEP_OVER_NONE;
772 if (skip_subroutines)
773 step_over_calls = STEP_OVER_ALL;
775 step_multi = (count > 1);
777 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
779 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
781 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
783 arg1->data.integer = skip_subroutines;
785 arg2->data.integer = single_inst;
787 arg3->data.integer = count;
788 add_intermediate_continuation (step_1_continuation, arg1);
789 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
794 /* Continue program at specified address. */
797 jump_command (char *arg, int from_tty)
799 register CORE_ADDR addr;
800 struct symtabs_and_lines sals;
801 struct symtab_and_line sal;
808 /* Find out whether we must run in the background. */
810 async_exec = strip_bg_char (&arg);
812 /* If we must run in the background, but the target can't do it,
814 if (event_loop_p && async_exec && !target_can_async_p ())
815 error ("Asynchronous execution not supported on this target.");
817 /* If we are not asked to run in the bg, then prepare to run in the
818 foreground, synchronously. */
819 if (event_loop_p && !async_exec && target_can_async_p ())
821 /* Simulate synchronous execution */
822 async_disable_stdin ();
826 error_no_arg ("starting address");
828 sals = decode_line_spec_1 (arg, 1);
831 error ("Unreasonable jump request");
837 if (sal.symtab == 0 && sal.pc == 0)
838 error ("No source file has been specified.");
840 resolve_sal_pc (&sal); /* May error out */
842 /* See if we are trying to jump to another function. */
843 fn = get_frame_function (get_current_frame ());
844 sfn = find_pc_function (sal.pc);
845 if (fn != NULL && sfn != fn)
847 if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
848 SYMBOL_SOURCE_NAME (fn)))
850 error ("Not confirmed.");
857 fixup_symbol_section (sfn, 0);
858 if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) &&
859 !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
861 if (!query ("WARNING!!! Destination is in unmapped overlay! Jump anyway? "))
863 error ("Not confirmed.");
873 printf_filtered ("Continuing at ");
874 print_address_numeric (addr, 1, gdb_stdout);
875 printf_filtered (".\n");
878 clear_proceed_status ();
879 proceed (addr, TARGET_SIGNAL_0, 0);
883 /* Go to line or address in current procedure */
885 go_command (char *line_no, int from_tty)
887 if (line_no == (char *) NULL || !*line_no)
888 printf_filtered (GO_USAGE);
891 tbreak_command (line_no, from_tty);
892 jump_command (line_no, from_tty);
897 /* Continue program giving it specified signal. */
900 signal_command (char *signum_exp, int from_tty)
902 enum target_signal oursig;
904 dont_repeat (); /* Too dangerous. */
908 error_no_arg ("signal number");
910 /* It would be even slicker to make signal names be valid expressions,
911 (the type could be "enum $signal" or some such), then the user could
912 assign them to convenience variables. */
913 oursig = target_signal_from_name (signum_exp);
915 if (oursig == TARGET_SIGNAL_UNKNOWN)
917 /* No, try numeric. */
918 int num = parse_and_eval_long (signum_exp);
921 oursig = TARGET_SIGNAL_0;
923 oursig = target_signal_from_command (num);
928 if (oursig == TARGET_SIGNAL_0)
929 printf_filtered ("Continuing with no signal.\n");
931 printf_filtered ("Continuing with signal %s.\n",
932 target_signal_to_name (oursig));
935 clear_proceed_status ();
936 /* "signal 0" should not get stuck if we are stopped at a breakpoint.
937 FIXME: Neither should "signal foo" but when I tried passing
938 (CORE_ADDR)-1 unconditionally I got a testsuite failure which I haven't
939 tried to track down yet. */
940 proceed (oursig == TARGET_SIGNAL_0 ? (CORE_ADDR) -1 : stop_pc, oursig, 0);
943 /* Call breakpoint_auto_delete on the current contents of the bpstat
944 pointed to by arg (which is really a bpstat *). */
947 breakpoint_auto_delete_contents (PTR arg)
949 breakpoint_auto_delete (*(bpstat *) arg);
953 /* Execute a "stack dummy", a piece of code stored in the stack
954 by the debugger to be executed in the inferior.
956 To call: first, do PUSH_DUMMY_FRAME.
957 Then push the contents of the dummy. It should end with a breakpoint insn.
958 Then call here, passing address at which to start the dummy.
960 The contents of all registers are saved before the dummy frame is popped
961 and copied into the buffer BUFFER.
963 The dummy's frame is automatically popped whenever that break is hit.
964 If that is the first time the program stops, run_stack_dummy
965 returns to its caller with that frame already gone and returns 0.
967 Otherwise, run_stack-dummy returns a non-zero value.
968 If the called function receives a random signal, we do not allow the user
969 to continue executing it as this may not work. The dummy frame is poped
971 If we hit a breakpoint, we leave the frame in place and return 2 (the frame
972 will eventually be popped when we do hit the dummy end breakpoint). */
975 run_stack_dummy (CORE_ADDR addr, struct regcache *buffer)
977 struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
980 /* Now proceed, having reached the desired place. */
981 clear_proceed_status ();
983 if (CALL_DUMMY_BREAKPOINT_OFFSET_P)
985 struct breakpoint *bpt;
986 struct symtab_and_line sal;
988 init_sal (&sal); /* initialize to zeroes */
989 if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT)
991 sal.pc = CALL_DUMMY_ADDRESS ();
995 sal.pc = addr - CALL_DUMMY_START_OFFSET + CALL_DUMMY_BREAKPOINT_OFFSET;
997 sal.section = find_pc_overlay (sal.pc);
999 /* Set up a FRAME for the dummy frame so we can pass it to
1000 set_momentary_breakpoint. We need to give the breakpoint a
1001 frame in case there is only one copy of the dummy (e.g.
1002 CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
1003 flush_cached_frames ();
1004 set_current_frame (create_new_frame (read_fp (), sal.pc));
1006 /* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
1007 a breakpoint instruction. If not, the call dummy already has the
1008 breakpoint instruction in it.
1010 addr is the address of the call dummy plus the CALL_DUMMY_START_OFFSET,
1011 so we need to subtract the CALL_DUMMY_START_OFFSET. */
1012 bpt = set_momentary_breakpoint (sal,
1013 get_current_frame (),
1015 bpt->disposition = disp_del;
1017 /* If all error()s out of proceed ended up calling normal_stop (and
1018 perhaps they should; it already does in the special case of error
1019 out of resume()), then we wouldn't need this. */
1020 make_cleanup (breakpoint_auto_delete_contents, &stop_bpstat);
1023 disable_watchpoints_before_interactive_call_start ();
1024 proceed_to_finish = 1; /* We want stop_registers, please... */
1026 if (target_can_async_p ())
1027 saved_async = target_async_mask (0);
1029 proceed (addr, TARGET_SIGNAL_0, 0);
1032 target_async_mask (saved_async);
1034 enable_watchpoints_after_interactive_call_stop ();
1036 discard_cleanups (old_cleanups);
1038 /* We can stop during an inferior call because a signal is received. */
1039 if (stopped_by_random_signal)
1042 /* We may also stop prematurely because we hit a breakpoint in the
1044 if (!stop_stack_dummy)
1047 /* On normal return, the stack dummy has been popped already. */
1048 regcache_cpy_no_passthrough (buffer, stop_registers);
1052 /* Proceed until we reach a different source line with pc greater than
1053 our current one or exit the function. We skip calls in both cases.
1055 Note that eventually this command should probably be changed so
1056 that only source lines are printed out when we hit the breakpoint
1057 we set. This may involve changes to wait_for_inferior and the
1058 proceed status code. */
1062 until_next_command (int from_tty)
1064 struct frame_info *frame;
1066 struct symbol *func;
1067 struct symtab_and_line sal;
1069 clear_proceed_status ();
1071 frame = get_current_frame ();
1073 /* Step until either exited from this function or greater
1074 than the current line (if in symbolic section) or pc (if
1078 func = find_pc_function (pc);
1082 struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
1084 if (msymbol == NULL)
1085 error ("Execution is not within a known function.");
1087 step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
1088 step_range_end = pc;
1092 sal = find_pc_line (pc, 0);
1094 step_range_start = BLOCK_START (SYMBOL_BLOCK_VALUE (func));
1095 step_range_end = sal.end;
1098 step_over_calls = STEP_OVER_ALL;
1099 step_frame_address = get_frame_base (frame);
1100 step_sp = read_sp ();
1102 step_multi = 0; /* Only one call to proceed */
1104 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
1108 until_command (char *arg, int from_tty)
1112 if (!target_has_execution)
1113 error ("The program is not running.");
1115 /* Find out whether we must run in the background. */
1117 async_exec = strip_bg_char (&arg);
1119 /* If we must run in the background, but the target can't do it,
1121 if (event_loop_p && async_exec && !target_can_async_p ())
1122 error ("Asynchronous execution not supported on this target.");
1124 /* If we are not asked to run in the bg, then prepare to run in the
1125 foreground, synchronously. */
1126 if (event_loop_p && !async_exec && target_can_async_p ())
1128 /* Simulate synchronous execution */
1129 async_disable_stdin ();
1133 until_break_command (arg, from_tty);
1135 until_next_command (from_tty);
1139 /* Print the result of a function at the end of a 'finish' command. */
1141 print_return_value (int structure_return, struct type *value_type)
1143 struct value *value;
1144 static struct ui_stream *stb = NULL;
1146 if (!structure_return)
1148 value = value_being_returned (value_type, stop_registers, structure_return);
1149 stb = ui_out_stream_new (uiout);
1150 ui_out_text (uiout, "Value returned is ");
1151 ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
1152 ui_out_text (uiout, " = ");
1153 value_print (value, stb->stream, 0, Val_no_prettyprint);
1154 ui_out_field_stream (uiout, "return-value", stb);
1155 ui_out_text (uiout, "\n");
1159 /* We cannot determine the contents of the structure because
1160 it is on the stack, and we don't know where, since we did not
1161 initiate the call, as opposed to the call_function_by_hand case */
1162 #ifdef VALUE_RETURNED_FROM_STACK
1164 ui_out_text (uiout, "Value returned has type: ");
1165 ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
1166 ui_out_text (uiout, ".");
1167 ui_out_text (uiout, " Cannot determine contents\n");
1169 value = value_being_returned (value_type, stop_registers, structure_return);
1170 stb = ui_out_stream_new (uiout);
1171 ui_out_text (uiout, "Value returned is ");
1172 ui_out_field_fmt (uiout, "gdb-result-var", "$%d", record_latest_value (value));
1173 ui_out_text (uiout, " = ");
1174 value_print (value, stb->stream, 0, Val_no_prettyprint);
1175 ui_out_field_stream (uiout, "return-value", stb);
1176 ui_out_text (uiout, "\n");
1181 /* Stuff that needs to be done by the finish command after the target
1182 has stopped. In asynchronous mode, we wait for the target to stop in
1183 the call to poll or select in the event loop, so it is impossible to
1184 do all the stuff as part of the finish_command function itself. The
1185 only chance we have to complete this command is in
1186 fetch_inferior_event, which is called by the event loop as soon as it
1187 detects that the target has stopped. This function is called via the
1188 cmd_continuation pointer. */
1190 finish_command_continuation (struct continuation_arg *arg)
1192 register struct symbol *function;
1193 struct breakpoint *breakpoint;
1194 struct cleanup *cleanups;
1196 breakpoint = (struct breakpoint *) arg->data.pointer;
1197 function = (struct symbol *) arg->next->data.pointer;
1198 cleanups = (struct cleanup *) arg->next->next->data.pointer;
1200 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1203 struct type *value_type;
1207 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1209 internal_error (__FILE__, __LINE__,
1210 "finish_command: function has no target type");
1212 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1214 do_exec_cleanups (cleanups);
1218 funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
1220 struct_return = using_struct_return (value_of_variable (function, NULL),
1222 check_typedef (value_type),
1223 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
1225 print_return_value (struct_return, value_type);
1227 do_exec_cleanups (cleanups);
1230 /* "finish": Set a temporary breakpoint at the place
1231 the selected frame will return to, then continue. */
1234 finish_command (char *arg, int from_tty)
1236 struct symtab_and_line sal;
1237 register struct frame_info *frame;
1238 register struct symbol *function;
1239 struct breakpoint *breakpoint;
1240 struct cleanup *old_chain;
1241 struct continuation_arg *arg1, *arg2, *arg3;
1245 /* Find out whether we must run in the background. */
1247 async_exec = strip_bg_char (&arg);
1249 /* If we must run in the background, but the target can't do it,
1251 if (event_loop_p && async_exec && !target_can_async_p ())
1252 error ("Asynchronous execution not supported on this target.");
1254 /* If we are not asked to run in the bg, then prepare to run in the
1255 foreground, synchronously. */
1256 if (event_loop_p && !async_exec && target_can_async_p ())
1258 /* Simulate synchronous execution */
1259 async_disable_stdin ();
1263 error ("The \"finish\" command does not take any arguments.");
1264 if (!target_has_execution)
1265 error ("The program is not running.");
1266 if (selected_frame == NULL)
1267 error ("No selected frame.");
1269 frame = get_prev_frame (selected_frame);
1271 error ("\"finish\" not meaningful in the outermost frame.");
1273 clear_proceed_status ();
1275 sal = find_pc_line (frame->pc, 0);
1278 breakpoint = set_momentary_breakpoint (sal, frame, bp_finish);
1280 if (!event_loop_p || !target_can_async_p ())
1281 old_chain = make_cleanup_delete_breakpoint (breakpoint);
1283 old_chain = make_exec_cleanup_delete_breakpoint (breakpoint);
1285 /* Find the function we will return from. */
1287 function = find_pc_function (selected_frame->pc);
1289 /* Print info on the selected frame, including level number
1293 printf_filtered ("Run till exit from ");
1294 print_stack_frame (selected_frame,
1295 frame_relative_level (selected_frame), 0);
1298 /* If running asynchronously and the target support asynchronous
1299 execution, set things up for the rest of the finish command to be
1300 completed later on, when gdb has detected that the target has
1301 stopped, in fetch_inferior_event. */
1302 if (event_loop_p && target_can_async_p ())
1305 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1307 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1309 (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
1313 arg1->data.pointer = breakpoint;
1314 arg2->data.pointer = function;
1315 arg3->data.pointer = old_chain;
1316 add_continuation (finish_command_continuation, arg1);
1319 proceed_to_finish = 1; /* We want stop_registers, please... */
1320 proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
1322 /* Do this only if not running asynchronously or if the target
1323 cannot do async execution. Otherwise, complete this command when
1324 the target actually stops, in fetch_inferior_event. */
1325 if (!event_loop_p || !target_can_async_p ())
1328 /* Did we stop at our breakpoint? */
1329 if (bpstat_find_breakpoint (stop_bpstat, breakpoint) != NULL
1332 struct type *value_type;
1336 value_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (function));
1338 internal_error (__FILE__, __LINE__,
1339 "finish_command: function has no target type");
1341 /* FIXME: Shouldn't we do the cleanups before returning? */
1342 if (TYPE_CODE (value_type) == TYPE_CODE_VOID)
1345 funcaddr = BLOCK_START (SYMBOL_BLOCK_VALUE (function));
1348 using_struct_return (value_of_variable (function, NULL),
1350 check_typedef (value_type),
1351 BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function)));
1353 print_return_value (struct_return, value_type);
1355 do_cleanups (old_chain);
1361 program_info (char *args, int from_tty)
1363 bpstat bs = stop_bpstat;
1364 int num = bpstat_num (&bs);
1366 if (!target_has_execution)
1368 printf_filtered ("The program being debugged is not being run.\n");
1372 target_files_info ();
1373 printf_filtered ("Program stopped at %s.\n",
1374 local_hex_string ((unsigned long) stop_pc));
1376 printf_filtered ("It stopped after being stepped.\n");
1379 /* There may be several breakpoints in the same place, so this
1380 isn't as strange as it seems. */
1385 printf_filtered ("It stopped at a breakpoint that has ");
1386 printf_filtered ("since been deleted.\n");
1389 printf_filtered ("It stopped at breakpoint %d.\n", num);
1390 num = bpstat_num (&bs);
1393 else if (stop_signal != TARGET_SIGNAL_0)
1395 printf_filtered ("It stopped with signal %s, %s.\n",
1396 target_signal_to_name (stop_signal),
1397 target_signal_to_string (stop_signal));
1402 printf_filtered ("Type \"info stack\" or \"info registers\" ");
1403 printf_filtered ("for more information.\n");
1408 environment_info (char *var, int from_tty)
1412 register char *val = get_in_environ (inferior_environ, var);
1415 puts_filtered (var);
1416 puts_filtered (" = ");
1417 puts_filtered (val);
1418 puts_filtered ("\n");
1422 puts_filtered ("Environment variable \"");
1423 puts_filtered (var);
1424 puts_filtered ("\" not defined.\n");
1429 register char **vector = environ_vector (inferior_environ);
1432 puts_filtered (*vector++);
1433 puts_filtered ("\n");
1439 set_environment_command (char *arg, int from_tty)
1441 register char *p, *val, *var;
1445 error_no_arg ("environment variable and value");
1447 /* Find seperation between variable name and value */
1448 p = (char *) strchr (arg, '=');
1449 val = (char *) strchr (arg, ' ');
1451 if (p != 0 && val != 0)
1453 /* We have both a space and an equals. If the space is before the
1454 equals, walk forward over the spaces til we see a nonspace
1455 (possibly the equals). */
1460 /* Now if the = is after the char following the spaces,
1461 take the char following the spaces. */
1465 else if (val != 0 && p == 0)
1469 error_no_arg ("environment variable to set");
1471 if (p == 0 || p[1] == 0)
1475 p = arg + strlen (arg); /* So that savestring below will work */
1479 /* Not setting variable value to null */
1481 while (*val == ' ' || *val == '\t')
1485 while (p != arg && (p[-1] == ' ' || p[-1] == '\t'))
1488 var = savestring (arg, p - arg);
1491 printf_filtered ("Setting environment variable ");
1492 printf_filtered ("\"%s\" to null value.\n", var);
1493 set_in_environ (inferior_environ, var, "");
1496 set_in_environ (inferior_environ, var, val);
1501 unset_environment_command (char *var, int from_tty)
1505 /* If there is no argument, delete all environment variables.
1506 Ask for confirmation if reading from the terminal. */
1507 if (!from_tty || query ("Delete all environment variables? "))
1509 free_environ (inferior_environ);
1510 inferior_environ = make_environ ();
1514 unset_in_environ (inferior_environ, var);
1517 /* Handle the execution path (PATH variable) */
1519 static const char path_var_name[] = "PATH";
1523 path_info (char *args, int from_tty)
1525 puts_filtered ("Executable and object file path: ");
1526 puts_filtered (get_in_environ (inferior_environ, path_var_name));
1527 puts_filtered ("\n");
1530 /* Add zero or more directories to the front of the execution path. */
1533 path_command (char *dirname, int from_tty)
1538 env = get_in_environ (inferior_environ, path_var_name);
1539 /* Can be null if path is not set */
1542 exec_path = xstrdup (env);
1543 mod_path (dirname, &exec_path);
1544 set_in_environ (inferior_environ, path_var_name, exec_path);
1547 path_info ((char *) NULL, from_tty);
1551 #ifdef REGISTER_NAMES
1552 char *gdb_register_names[] = REGISTER_NAMES;
1554 /* Print out the machine register regnum. If regnum is -1, print all
1555 registers (print_all == 1) or all non-float and non-vector
1556 registers (print_all == 0).
1558 For most machines, having all_registers_info() print the
1559 register(s) one per line is good enough. If a different format is
1560 required, (eg, for MIPS or Pyramid 90x, which both have lots of
1561 regs), or there is an existing convention for showing all the
1562 registers, define the architecture method PRINT_REGISTERS_INFO to
1563 provide that format. */
1566 default_print_registers_info (struct gdbarch *gdbarch,
1567 struct ui_file *file,
1568 struct frame_info *frame,
1569 int regnum, int print_all)
1572 const int numregs = NUM_REGS + NUM_PSEUDO_REGS;
1573 char *raw_buffer = alloca (MAX_REGISTER_RAW_SIZE);
1574 char *virtual_buffer = alloca (MAX_REGISTER_VIRTUAL_SIZE);
1576 if (DEPRECATED_DO_REGISTERS_INFO_P ())
1578 DEPRECATED_DO_REGISTERS_INFO (regnum, print_all);
1582 for (i = 0; i < numregs; i++)
1584 /* Decide between printing all regs, non-float / vector regs, or
1590 if (!gdbarch_register_reggroup_p (gdbarch, i, all_reggroup))
1595 if (!gdbarch_register_reggroup_p (gdbarch, i, general_reggroup))
1605 /* If the register name is empty, it is undefined for this
1606 processor, so don't display anything. */
1607 if (REGISTER_NAME (i) == NULL || *(REGISTER_NAME (i)) == '\0')
1610 fputs_filtered (REGISTER_NAME (i), file);
1611 print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
1613 /* Get the data in raw format. */
1614 if (! frame_register_read (frame, i, raw_buffer))
1616 fprintf_filtered (file, "*value not available*\n");
1620 /* FIXME: cagney/2002-08-03: This code shouldn't be necessary.
1621 The function frame_register_read() should have returned the
1622 pre-cooked register so no conversion is necessary. */
1623 /* Convert raw data to virtual format if necessary. */
1624 if (REGISTER_CONVERTIBLE (i))
1626 REGISTER_CONVERT_TO_VIRTUAL (i, REGISTER_VIRTUAL_TYPE (i),
1627 raw_buffer, virtual_buffer);
1631 memcpy (virtual_buffer, raw_buffer,
1632 REGISTER_VIRTUAL_SIZE (i));
1635 /* If virtual format is floating, print it that way, and in raw
1637 if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
1641 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1642 file, 0, 1, 0, Val_pretty_default);
1644 fprintf_filtered (file, "\t(raw 0x");
1645 for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
1648 if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
1651 idx = REGISTER_RAW_SIZE (i) - 1 - j;
1652 fprintf_filtered (file, "%02x", (unsigned char) raw_buffer[idx]);
1654 fprintf_filtered (file, ")");
1658 /* Print the register in hex. */
1659 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1660 file, 'x', 1, 0, Val_pretty_default);
1661 /* If not a vector register, print it also according to its
1663 if (TYPE_VECTOR (REGISTER_VIRTUAL_TYPE (i)) == 0)
1665 fprintf_filtered (file, "\t");
1666 val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0, 0,
1667 file, 0, 1, 0, Val_pretty_default);
1671 fprintf_filtered (file, "\n");
1676 registers_info (char *addr_exp, int fpregs)
1678 int regnum, numregs;
1681 if (!target_has_registers)
1682 error ("The program has no registers now.");
1683 if (selected_frame == NULL)
1684 error ("No selected frame.");
1688 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1689 selected_frame, -1, fpregs);
1693 while (*addr_exp != '\0')
1698 /* Keep skipping leading white space. */
1699 if (isspace ((*addr_exp)))
1705 /* Discard any leading ``$''. Check that there is something
1706 resembling a register following it. */
1707 if (addr_exp[0] == '$')
1709 if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
1710 error ("Missing register name");
1712 /* Find the start/end of this register name/num/group. */
1714 while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
1718 /* Figure out what we've found and display it. */
1720 /* A register name? */
1722 int regnum = frame_map_name_to_regnum (start, end - start);
1725 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1726 selected_frame, regnum, fpregs);
1731 /* A register number? (how portable is this one?). */
1734 int regnum = strtol (start, &endptr, 0);
1737 && regnum < NUM_REGS + NUM_PSEUDO_REGS)
1739 gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
1740 selected_frame, regnum, fpregs);
1745 /* A register group? */
1747 struct reggroup *const *group;
1748 for (group = reggroups (current_gdbarch);
1752 /* Don't bother with a length check. Should the user
1753 enter a short register group name, go with the first
1754 group that matches. */
1755 if (strncmp (start, reggroup_name ((*group)), end - start) == 0)
1758 if ((*group) != NULL)
1761 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1763 if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
1765 gdbarch_print_registers_info (current_gdbarch,
1766 gdb_stdout, selected_frame,
1773 /* Nothing matched. */
1774 error ("Invalid register `%.*s'", (int) (end - start), start);
1779 all_registers_info (char *addr_exp, int from_tty)
1781 registers_info (addr_exp, 1);
1785 nofp_registers_info (char *addr_exp, int from_tty)
1787 registers_info (addr_exp, 0);
1791 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
1792 struct frame_info *frame, const char *args)
1794 if (!target_has_registers)
1795 error ("The program has no registers now.");
1796 if (selected_frame == NULL)
1797 error ("No selected frame.");
1799 if (gdbarch_print_vector_info_p (gdbarch))
1800 gdbarch_print_vector_info (gdbarch, file, frame, args);
1804 int printed_something = 0;
1806 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1808 if (gdbarch_register_reggroup_p (gdbarch, regnum, vector_reggroup))
1810 printed_something = 1;
1811 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1814 if (!printed_something)
1815 fprintf_filtered (file, "No vector information\n");
1820 vector_info (char *args, int from_tty)
1822 print_vector_info (current_gdbarch, gdb_stdout, selected_frame, args);
1828 * Should save/restore the tty state since it might be that the
1829 * program to be debugged was started on this tty and it wants
1830 * the tty in some state other than what we want. If it's running
1831 * on another terminal or without a terminal, then saving and
1832 * restoring the tty state is a harmless no-op.
1833 * This only needs to be done if we are attaching to a process.
1838 takes a program started up outside of gdb and ``attaches'' to it.
1839 This stops it cold in its tracks and allows us to start debugging it.
1840 and wait for the trace-trap that results from attaching. */
1843 attach_command (char *args, int from_tty)
1846 char *full_exec_path = NULL;
1848 dont_repeat (); /* Not for the faint of heart */
1850 if (target_has_execution)
1852 if (query ("A program is being debugged already. Kill it? "))
1855 error ("Not killed.");
1858 target_attach (args, from_tty);
1860 /* Set up the "saved terminal modes" of the inferior
1861 based on what modes we are starting it with. */
1862 target_terminal_init ();
1864 /* Install inferior's terminal modes. */
1865 target_terminal_inferior ();
1867 /* Set up execution context to know that we should return from
1868 wait_for_inferior as soon as the target reports a stop. */
1869 init_wait_for_inferior ();
1870 clear_proceed_status ();
1872 /* No traps are generated when attaching to inferior under Mach 3
1874 #ifndef ATTACH_NO_WAIT
1875 stop_soon_quietly = 1;
1876 wait_for_inferior ();
1880 * If no exec file is yet known, try to determine it from the
1883 exec_file = (char *) get_exec_file (0);
1886 exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
1889 /* It's possible we don't have a full path, but rather just a
1890 filename. Some targets, such as HP-UX, don't provide the
1893 Attempt to qualify the filename against the source path.
1894 (If that fails, we'll just fall back on the original
1895 filename. Not much more we can do...)
1897 if (!source_full_path_of (exec_file, &full_exec_path))
1898 full_exec_path = savestring (exec_file, strlen (exec_file));
1900 exec_file_attach (full_exec_path, from_tty);
1901 symbol_file_add_main (full_exec_path, from_tty);
1906 /* Add shared library symbols from the newly attached process, if any. */
1907 SOLIB_ADD ((char *) 0, from_tty, ¤t_target, auto_solib_add);
1908 re_enable_breakpoints_in_shlibs ();
1911 /* Take any necessary post-attaching actions for this platform.
1913 target_post_attach (PIDGET (inferior_ptid));
1923 * takes a program previously attached to and detaches it.
1924 * The program resumes execution and will no longer stop
1925 * on signals, etc. We better not have left any breakpoints
1926 * in the program or it'll die when it hits one. For this
1927 * to work, it may be necessary for the process to have been
1928 * previously attached. It *might* work if the program was
1929 * started via the normal ptrace (PTRACE_TRACEME).
1933 detach_command (char *args, int from_tty)
1935 dont_repeat (); /* Not for the faint of heart */
1936 target_detach (args, from_tty);
1937 #if defined(SOLIB_RESTART)
1944 /* Stop the execution of the target while running in async mode, in
1947 interrupt_target_command (char *args, int from_tty)
1949 if (event_loop_p && target_can_async_p ())
1951 dont_repeat (); /* Not for the faint of heart */
1958 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
1959 struct frame_info *frame, const char *args)
1961 if (!target_has_registers)
1962 error ("The program has no registers now.");
1963 if (selected_frame == NULL)
1964 error ("No selected frame.");
1966 if (gdbarch_print_float_info_p (gdbarch))
1967 gdbarch_print_float_info (gdbarch, file, frame, args);
1971 #if GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL
1972 #error "FLOAT_INFO defined in multi-arch"
1977 int printed_something = 0;
1979 for (regnum = 0; regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++)
1981 if (gdbarch_register_reggroup_p (gdbarch, regnum, float_reggroup))
1983 printed_something = 1;
1984 gdbarch_print_registers_info (gdbarch, file, frame, regnum, 1);
1987 if (!printed_something)
1988 fprintf_filtered (file, "\
1989 No floating-point info available for this processor.\n");
1995 float_info (char *args, int from_tty)
1997 print_float_info (current_gdbarch, gdb_stdout, selected_frame, args);
2002 unset_command (char *args, int from_tty)
2004 printf_filtered ("\"unset\" must be followed by the name of ");
2005 printf_filtered ("an unset subcommand.\n");
2006 help_list (unsetlist, "unset ", -1, gdb_stdout);
2010 _initialize_infcmd (void)
2012 struct cmd_list_element *c;
2014 c = add_com ("tty", class_run, tty_command,
2015 "Set terminal for future runs of program being debugged.");
2016 set_cmd_completer (c, filename_completer);
2018 c = add_set_cmd ("args", class_run, var_string_noescape,
2019 (char *) &inferior_args,
2020 "Set argument list to give program being debugged when it is started.\n\
2021 Follow this command with any number of args, to be passed to the program.",
2023 set_cmd_completer (c, filename_completer);
2024 set_cmd_sfunc (c, notice_args_set);
2025 c = add_show_from_set (c, &showlist);
2026 set_cmd_sfunc (c, notice_args_read);
2029 ("environment", no_class, environment_info,
2030 "The environment to give the program, or one variable's value.\n\
2031 With an argument VAR, prints the value of environment variable VAR to\n\
2032 give the program being debugged. With no arguments, prints the entire\n\
2033 environment to be given to the program.", &showlist);
2034 set_cmd_completer (c, noop_completer);
2036 add_prefix_cmd ("unset", no_class, unset_command,
2037 "Complement to certain \"set\" commands.",
2038 &unsetlist, "unset ", 0, &cmdlist);
2040 c = add_cmd ("environment", class_run, unset_environment_command,
2041 "Cancel environment variable VAR for the program.\n\
2042 This does not affect the program until the next \"run\" command.",
2044 set_cmd_completer (c, noop_completer);
2046 c = add_cmd ("environment", class_run, set_environment_command,
2047 "Set environment variable value to give the program.\n\
2048 Arguments are VAR VALUE where VAR is variable name and VALUE is value.\n\
2049 VALUES of environment variables are uninterpreted strings.\n\
2050 This does not affect the program until the next \"run\" command.",
2052 set_cmd_completer (c, noop_completer);
2054 c = add_com ("path", class_files, path_command,
2055 "Add directory DIR(s) to beginning of search path for object files.\n\
2056 $cwd in the path means the current working directory.\n\
2057 This path is equivalent to the $PATH shell variable. It is a list of\n\
2058 directories, separated by colons. These directories are searched to find\n\
2059 fully linked executable files and separately compiled object files as needed.");
2060 set_cmd_completer (c, filename_completer);
2062 c = add_cmd ("paths", no_class, path_info,
2063 "Current search path for finding object files.\n\
2064 $cwd in the path means the current working directory.\n\
2065 This path is equivalent to the $PATH shell variable. It is a list of\n\
2066 directories, separated by colons. These directories are searched to find\n\
2067 fully linked executable files and separately compiled object files as needed.",
2069 set_cmd_completer (c, noop_completer);
2071 add_com ("attach", class_run, attach_command,
2072 "Attach to a process or file outside of GDB.\n\
2073 This command attaches to another target, of the same type as your last\n\
2074 \"target\" command (\"info files\" will show your target stack).\n\
2075 The command may take as argument a process id or a device file.\n\
2076 For a process id, you must have permission to send the process a signal,\n\
2077 and it must have the same effective uid as the debugger.\n\
2078 When using \"attach\" with a process id, the debugger finds the\n\
2079 program running in the process, looking first in the current working\n\
2080 directory, or (if not found there) using the source file search path\n\
2081 (see the \"directory\" command). You can also use the \"file\" command\n\
2082 to specify the program, and to load its symbol table.");
2084 add_com ("detach", class_run, detach_command,
2085 "Detach a process or file previously attached.\n\
2086 If a process, it is no longer traced, and it continues its execution. If\n\
2087 you were debugging a file, the file is closed and gdb no longer accesses it.");
2089 add_com ("signal", class_run, signal_command,
2090 "Continue program giving it signal specified by the argument.\n\
2091 An argument of \"0\" means continue program without giving it a signal.");
2093 add_com ("stepi", class_run, stepi_command,
2094 "Step one instruction exactly.\n\
2095 Argument N means do this N times (or till program stops for another reason).");
2096 add_com_alias ("si", "stepi", class_alias, 0);
2098 add_com ("nexti", class_run, nexti_command,
2099 "Step one instruction, but proceed through subroutine calls.\n\
2100 Argument N means do this N times (or till program stops for another reason).");
2101 add_com_alias ("ni", "nexti", class_alias, 0);
2103 add_com ("finish", class_run, finish_command,
2104 "Execute until selected stack frame returns.\n\
2105 Upon return, the value returned is printed and put in the value history.");
2107 add_com ("next", class_run, next_command,
2108 "Step program, proceeding through subroutine calls.\n\
2109 Like the \"step\" command as long as subroutine calls do not happen;\n\
2110 when they do, the call is treated as one instruction.\n\
2111 Argument N means do this N times (or till program stops for another reason).");
2112 add_com_alias ("n", "next", class_run, 1);
2114 add_com_alias ("S", "next", class_run, 1);
2116 add_com ("step", class_run, step_command,
2117 "Step program until it reaches a different source line.\n\
2118 Argument N means do this N times (or till program stops for another reason).");
2119 add_com_alias ("s", "step", class_run, 1);
2121 c = add_com ("until", class_run, until_command,
2122 "Execute until the program reaches a source line greater than the current\n\
2123 or a specified line or address or function (same args as break command).\n\
2124 Execution will also stop upon exit from the current stack frame.");
2125 set_cmd_completer (c, location_completer);
2126 add_com_alias ("u", "until", class_run, 1);
2128 c = add_com ("jump", class_run, jump_command,
2129 "Continue program being debugged at specified line or address.\n\
2130 Give as argument either LINENUM or *ADDR, where ADDR is an expression\n\
2131 for an address to start at.");
2132 set_cmd_completer (c, location_completer);
2136 c = add_com ("go", class_run, go_command,
2137 "Usage: go <location>\n\
2138 Continue program being debugged, stopping at specified line or \n\
2140 Give as argument either LINENUM or *ADDR, where ADDR is an \n\
2141 expression for an address to start at.\n\
2142 This command is a combination of tbreak and jump.");
2143 set_cmd_completer (c, location_completer);
2147 add_com_alias ("g", "go", class_run, 1);
2149 add_com ("continue", class_run, continue_command,
2150 "Continue program being debugged, after signal or breakpoint.\n\
2151 If proceeding from breakpoint, a number N may be used as an argument,\n\
2152 which means to set the ignore count of that breakpoint to N - 1 (so that\n\
2153 the breakpoint won't break until the Nth time it is reached).");
2154 add_com_alias ("c", "cont", class_run, 1);
2155 add_com_alias ("fg", "cont", class_run, 1);
2157 c = add_com ("run", class_run, run_command,
2158 "Start debugged program. You may specify arguments to give it.\n\
2159 Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
2160 Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
2161 With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
2162 To cancel previous arguments and run with no arguments,\n\
2163 use \"set args\" without arguments.");
2164 set_cmd_completer (c, filename_completer);
2165 add_com_alias ("r", "run", class_run, 1);
2167 add_com ("R", class_run, run_no_args_command,
2168 "Start debugged program with no arguments.");
2170 add_com ("interrupt", class_run, interrupt_target_command,
2171 "Interrupt the execution of the debugged program.");
2173 add_info ("registers", nofp_registers_info,
2174 "List of integer registers and their contents, for selected stack frame.\n\
2175 Register name as argument means describe only that register.");
2176 add_info_alias ("r", "registers", 1);
2179 add_com ("lr", class_info, nofp_registers_info,
2180 "List of integer registers and their contents, for selected stack frame.\n\
2181 Register name as argument means describe only that register.");
2182 add_info ("all-registers", all_registers_info,
2183 "List of all registers and their contents, for selected stack frame.\n\
2184 Register name as argument means describe only that register.");
2186 add_info ("program", program_info,
2187 "Execution status of the program.");
2189 add_info ("float", float_info,
2190 "Print the status of the floating point unit\n");
2192 add_info ("vector", vector_info,
2193 "Print the status of the vector unit\n");
2195 inferior_environ = make_environ ();
2196 init_environ (inferior_environ);