-/* Memory-access and commands for inferior process, for GDB.
- Copyright (C) 1986, 1987, 1988, 1989 Free Software Foundation, Inc.
+/* Memory-access and commands for "inferior" (child) process, for GDB.
+ Copyright 1986, 1987, 1988, 1989, 1991, 1992 Free Software Foundation, Inc.
This file is part of GDB.
-GDB is free software; you can redistribute it and/or modify
+This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-GDB is distributed in the hope that it will be useful,
+This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GDB; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <stdio.h>
+#include "defs.h"
#include <signal.h>
#include <sys/param.h>
#include <string.h>
-#include "defs.h"
-#include "param.h"
#include "symtab.h"
+#include "gdbtypes.h"
#include "frame.h"
#include "inferior.h"
#include "environ.h"
#include "gdbcore.h"
#include "target.h"
-extern char *sys_siglist[];
+static void
+continue_command PARAMS ((char *, int));
+
+static void
+until_next_command PARAMS ((int));
+
+static void
+until_command PARAMS ((char *, int));
+
+static void
+path_info PARAMS ((char *, int));
+
+static void
+path_command PARAMS ((char *, int));
+
+static void
+unset_command PARAMS ((char *, int));
+
+static void
+float_info PARAMS ((char *, int));
+
+static void
+detach_command PARAMS ((char *, int));
+
+static void
+nofp_registers_info PARAMS ((char *, int));
+
+static void
+all_registers_info PARAMS ((char *, int));
+
+static void
+registers_info PARAMS ((char *, int));
-extern void until_break_command (); /* breakpoint.c */
+static void
+do_registers_info PARAMS ((int, int));
+
+static void
+unset_environment_command PARAMS ((char *, int));
+
+static void
+set_environment_command PARAMS ((char *, int));
+
+static void
+environment_info PARAMS ((char *, int));
+
+static void
+program_info PARAMS ((char *, int));
+
+static void
+finish_command PARAMS ((char *, int));
+
+static void
+signal_command PARAMS ((char *, int));
+
+static void
+jump_command PARAMS ((char *, int));
+
+static void
+step_1 PARAMS ((int, int, char *));
+
+static void
+nexti_command PARAMS ((char *, int));
+
+static void
+stepi_command PARAMS ((char *, int));
+
+static void
+next_command PARAMS ((char *, int));
+
+static void
+step_command PARAMS ((char *, int));
+
+static void
+run_command PARAMS ((char *, int));
#define ERROR_NO_INFERIOR \
if (!target_has_execution) error ("The program is not being run.");
struct environ *inferior_environ;
-CORE_ADDR read_pc ();
-void breakpoint_clear_ignore_counts ();
-
\f
+/* ARGSUSED */
void
tty_command (file, from_tty)
char *file;
!query ("The program being debugged has been started already.\n\
Start it from the beginning? "))
error ("Program not restarted.");
- target_kill ((char *)0, 0);
+ target_kill ();
}
exec_file = (char *) get_exec_file (0);
- /* The exec file is re-read every time we do an inferior_died, so
+ /* The exec file is re-read every time we do a generic_mourn_inferior, so
we just have to worry about the symbol file. */
reread_symbols ();
if (args)
{
char *cmd;
- cmd = concat ("set args ", args, "");
+ cmd = concat ("set args ", args, NULL);
make_cleanup (free, cmd);
execute_command (cmd, from_tty);
}
if (from_tty)
{
- printf ("Starting program: %s %s\n",
+ printf_filtered ("Starting program: %s %s\n",
exec_file? exec_file: "", inferior_args);
fflush (stdout);
}
environ_vector (inferior_environ));
}
\f
-void
+static void
continue_command (proc_count_exp, from_tty)
char *proc_count_exp;
int from_tty;
/* set_ignore_count prints a message ending with a period.
So print two spaces before "Continuing.". */
if (from_tty)
- printf (" ");
+ printf_filtered (" ");
num = bpstat_num (&bs);
}
}
if (from_tty)
- printf ("Continuing.\n");
+ printf_filtered ("Continuing.\n");
clear_proceed_status ();
}
\f
/* Step until outside of current statement. */
-static void step_1 ();
+/* ARGSUSED */
static void
step_command (count_string, from_tty)
- char * count_string;
+ char *count_string;
int from_tty;
{
step_1 (0, 0, count_string);
/* Likewise, but skip over subroutine calls as if single instructions. */
+/* ARGSUSED */
static void
next_command (count_string, from_tty)
- char * count_string;
+ char *count_string;
int from_tty;
{
step_1 (1, 0, count_string);
/* Likewise, but step only one instruction. */
+/* ARGSUSED */
static void
stepi_command (count_string, from_tty)
- char * count_string;
+ char *count_string;
int from_tty;
{
step_1 (0, 1, count_string);
}
+/* ARGSUSED */
static void
nexti_command (count_string, from_tty)
- char * count_string;
+ char *count_string;
int from_tty;
{
step_1 (1, 1, count_string);
{
register int count = 1;
FRAME fr;
+ struct cleanup *cleanups = 0;
ERROR_NO_INFERIOR;
count = count_string ? parse_and_eval_address (count_string) : 1;
+ if (!single_inst || skip_subroutines) /* leave si command alone */
+ {
+ enable_longjmp_breakpoint();
+ cleanups = make_cleanup(disable_longjmp_breakpoint, 0);
+ }
+
for (; count > 0; count--)
{
clear_proceed_status ();
-
fr = get_current_frame ();
if (!fr) /* Avoid coredump here. Why tho? */
error ("No current frame");
find_pc_line_pc_range (stop_pc, &step_range_start, &step_range_end);
if (step_range_end == 0)
{
- int misc;
+ struct minimal_symbol *msymbol;
- misc = find_pc_misc_function (stop_pc);
+ msymbol = lookup_minimal_symbol_by_pc (stop_pc);
target_terminal_ours ();
- printf ("Current function has no line number information.\n");
+ printf_filtered ("Current function has no line number information.\n");
fflush (stdout);
/* No info or after _etext ("Can't happen") */
- if (misc == -1 || misc == misc_function_count - 1)
+ if (msymbol == NULL || (msymbol + 1) -> name == NULL)
error ("No data available on pc function.");
- printf ("Single stepping until function exit.\n");
+ printf_filtered ("Single stepping until function exit.\n");
fflush (stdout);
- step_range_start = misc_function_vector[misc].address;
- step_range_end = misc_function_vector[misc + 1].address;
+ step_range_start = msymbol -> address;
+ step_range_end = (msymbol + 1) -> address;
}
}
else
write_register (NPC_REGNUM, read_register (PC_REGNUM));
#endif
}
+
+ if (!single_inst || skip_subroutines)
+ do_cleanups(cleanups);
}
\f
/* Continue program at specified address. */
register CORE_ADDR addr;
struct symtabs_and_lines sals;
struct symtab_and_line sal;
+ struct symbol *fn;
+ struct symbol *sfn;
+ char *fname;
+ struct cleanup *back_to;
ERROR_NO_INFERIOR;
}
sal = sals.sals[0];
- free (sals.sals);
+ free ((PTR)sals.sals);
if (sal.symtab == 0 && sal.pc == 0)
error ("No source file has been specified.");
- if (sal.pc == 0)
- sal.pc = find_line_pc (sal.symtab, sal.line);
+ resolve_sal_pc (&sal); /* May error out */
- {
- struct symbol *fn = get_frame_function (get_current_frame ());
- struct symbol *sfn = find_pc_function (sal.pc);
- if (fn != 0 && sfn != fn
- && ! query ("Line %d is not in `%s'. Jump anyway? ",
- sal.line, SYMBOL_NAME (fn)))
- error ("Not confirmed.");
- }
-
- if (sal.pc == 0)
- error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
+ /* See if we are trying to jump to another function. */
+ fn = get_frame_function (get_current_frame ());
+ sfn = find_pc_function (sal.pc);
+ if (fn != NULL && sfn != fn)
+ {
+ fname = strdup_demangled (SYMBOL_NAME (fn));
+ back_to = make_cleanup (free, fname);
+ if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line, fname))
+ {
+ error ("Not confirmed.");
+ /* NOTREACHED */
+ }
+ do_cleanups (back_to);
+ }
addr = ADDR_BITS_SET (sal.pc);
if (from_tty)
- printf ("Continuing at 0x%x.\n", addr);
+ printf_filtered ("Continuing at %s.\n", local_hex_string(addr));
clear_proceed_status ();
proceed (addr, 0, 0);
signum = parse_and_eval_address (signum_exp);
if (from_tty)
- printf ("Continuing with signal %d.\n", signum);
+ printf_filtered ("Continuing with signal %d.\n", signum);
clear_proceed_status ();
proceed (stop_pc, signum, 0);
returns to its caller with that frame already gone.
Otherwise, the caller never gets returned to. */
-/* 4 => return instead of letting the stack dummy run. */
+/* DEBUG HOOK: 4 => return instead of letting the stack dummy run. */
static int stack_dummy_testing = 0;
/* On return, the stack dummy has been popped already. */
- bcopy (stop_registers, buffer, sizeof stop_registers);
+ memcpy (buffer, stop_registers, sizeof stop_registers);
}
\f
/* Proceed until we reach a different source line with pc greater than
we set. I'm going to postpone this until after a hopeful rewrite
of wait_for_inferior and the proceed status code. -- randy */
-void
+/* ARGSUSED */
+static void
until_next_command (from_tty)
int from_tty;
{
if (!func)
{
- int misc_func = find_pc_misc_function (pc);
+ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
- if (misc_func != -1)
+ if (msymbol == NULL)
error ("Execution is not within a known function.");
- step_range_start = misc_function_vector[misc_func].address;
+ step_range_start = msymbol -> address;
step_range_end = pc;
}
else
proceed ((CORE_ADDR) -1, -1, 1);
}
-void
+static void
until_command (arg, from_tty)
char *arg;
int from_tty;
register FRAME frame;
struct frame_info *fi;
register struct symbol *function;
+ struct breakpoint *breakpoint;
+ struct cleanup *old_chain;
if (arg)
error ("The \"finish\" command does not take any arguments.");
if (!target_has_execution)
error ("The program is not running.");
+ if (selected_frame == NULL)
+ error ("No selected frame.");
frame = get_prev_frame (selected_frame);
if (frame == 0)
fi = get_frame_info (frame);
sal = find_pc_line (fi->pc, 0);
sal.pc = fi->pc;
- set_momentary_breakpoint (sal, frame);
+
+ breakpoint = set_momentary_breakpoint (sal, frame, bp_finish);
+
+ old_chain = make_cleanup(delete_breakpoint, breakpoint);
/* Find the function we will return from. */
fi = get_frame_info (selected_frame);
function = find_pc_function (fi->pc);
+ /* Print info on the selected frame, including level number
+ but not source. */
if (from_tty)
{
- printf ("Run till exit from ");
- print_selected_frame ();
+ printf_filtered ("Run till exit from ");
+ print_stack_frame (selected_frame, selected_frame_level, 0);
}
proceed_to_finish = 1; /* We want stop_registers, please... */
proceed ((CORE_ADDR) -1, -1, 0);
- if (bpstat_momentary_breakpoint (stop_bpstat) && function != 0)
+ /* Did we stop at our breakpoint? */
+ if (bpstat_find_breakpoint(stop_bpstat, breakpoint) != NULL
+ && function != 0)
{
struct type *value_type;
register value val;
value_type,
BLOCK_GCC_COMPILED (SYMBOL_BLOCK_VALUE (function))));
- printf ("Value returned is $%d = ", record_latest_value (val));
+ printf_filtered ("Value returned is $%d = ", record_latest_value (val));
value_print (val, stdout, 0, Val_no_prettyprint);
- putchar ('\n');
+ printf_filtered ("\n");
}
+ do_cleanups(old_chain);
}
\f
+/* ARGSUSED */
static void
program_info (args, from_tty)
char *args;
if (!target_has_execution)
{
- printf ("The program being debugged is not being run.\n");
+ printf_filtered ("The program being debugged is not being run.\n");
return;
}
target_files_info ();
- printf ("Program stopped at 0x%x.\n", stop_pc);
+ printf_filtered ("Program stopped at %s.\n", local_hex_string(stop_pc));
if (stop_step)
- printf ("It stopped after being stepped.\n");
+ printf_filtered ("It stopped after being stepped.\n");
else if (num != 0)
{
/* There may be several breakpoints in the same place, so this
while (num != 0)
{
if (num < 0)
- printf ("It stopped at a breakpoint that has since been deleted.\n");
+ printf_filtered ("It stopped at a breakpoint that has since been deleted.\n");
else
- printf ("It stopped at breakpoint %d.\n", num);
+ printf_filtered ("It stopped at breakpoint %d.\n", num);
num = bpstat_num (&bs);
}
}
#ifdef PRINT_RANDOM_SIGNAL
PRINT_RANDOM_SIGNAL (stop_signal);
#else
- printf ("It stopped with signal %d (%s).\n",
- stop_signal,
- (stop_signal > NSIG)? "unknown": sys_siglist[stop_signal]);
+ printf_filtered ("It stopped with signal %d (%s).\n",
+ stop_signal, safe_strsignal (stop_signal));
#endif
}
if (!from_tty)
- printf ("Type \"info stack\" or \"info registers\" for more information.\n");
+ printf_filtered ("Type \"info stack\" or \"info registers\" for more information.\n");
}
\f
static void
-environment_info (var)
+environment_info (var, from_tty)
char *var;
+ int from_tty;
{
if (var)
{
register char *val = get_in_environ (inferior_environ, var);
if (val)
- printf ("%s = %s\n", var, val);
+ printf_filtered ("%s = %s\n", var, val);
else
- printf ("Environment variable \"%s\" not defined.\n", var);
+ printf_filtered ("Environment variable \"%s\" not defined.\n", var);
}
else
{
register char **vector = environ_vector (inferior_environ);
while (*vector)
- printf ("%s\n", *vector++);
+ printf_filtered ("%s\n", *vector++);
}
}
static void
-set_environment_command (arg)
+set_environment_command (arg, from_tty)
char *arg;
+ int from_tty;
{
register char *p, *val, *var;
int nullset = 0;
var = savestring (arg, p - arg);
if (nullset)
{
- printf ("Setting environment variable \"%s\" to null value.\n", var);
+ printf_filtered ("Setting environment variable \"%s\" to null value.\n", var);
set_in_environ (inferior_environ, var, "");
}
else
const static char path_var_name[] = "PATH";
-void
+/* ARGSUSED */
+static void
path_info (args, from_tty)
char *args;
int from_tty;
{
- printf ("Executable and object file path: %s\n",
+ printf_filtered ("Executable and object file path: %s\n",
get_in_environ (inferior_environ, path_var_name));
}
/* Add zero or more directories to the front of the execution path. */
-void
+static void
path_command (dirname, from_tty)
char *dirname;
int from_tty;
dont_repeat ();
exec_path = strsave (get_in_environ (inferior_environ, path_var_name));
- mod_path (dirname, from_tty, &exec_path);
+ mod_path (dirname, &exec_path);
set_in_environ (inferior_environ, path_var_name, exec_path);
free (exec_path);
if (from_tty)
- path_info ();
+ path_info ((char *)NULL, from_tty);
}
\f
CORE_ADDR
pc_changed = 0;
}
-char *reg_names[] = REGISTER_NAMES;
+const char * const reg_names[] = REGISTER_NAMES;
/* Print out the machine register regnum. If regnum is -1,
- print all registers.
+ print all registers (fpregs == 1) or all non-float registers
+ (fpregs == 0).
+
For most machines, having all_registers_info() print the
register(s) one per line is good enough. If a different format
- is required, (eg, for SPARC or Pyramid 90x, which both have
+ is required, (eg, for MIPS or Pyramid 90x, which both have
lots of regs), or there is an existing convention for showing
- all the registers, define the macro DO_REGISTERS_INFO(regnum)
+ all the registers, define the macro DO_REGISTERS_INFO(regnum, fp)
to provide that format. */
+
#if !defined (DO_REGISTERS_INFO)
-#define DO_REGISTERS_INFO(regnum) do_registers_info(regnum)
-static void do_registers_info (regnum)
+#define DO_REGISTERS_INFO(regnum, fp) do_registers_info(regnum, fp)
+static void
+do_registers_info (regnum, fpregs)
int regnum;
+ int fpregs;
{
register int i;
- if (regnum == -1)
- printf_filtered (
- "Register Contents (relative to selected stack frame)\n\n");
-
for (i = 0; i < NUM_REGS; i++)
{
char raw_buffer[MAX_REGISTER_RAW_SIZE];
char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
- if (regnum != -1 && i != regnum)
- continue;
+ /* Decide between printing all regs, nonfloat regs, or specific reg. */
+ if (regnum == -1) {
+ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT && !fpregs)
+ continue;
+ } else {
+ if (i != regnum)
+ continue;
+ }
fputs_filtered (reg_names[i], stdout);
print_spaces_filtered (15 - strlen (reg_names[i]), stdout);
#endif /* no DO_REGISTERS_INFO. */
static void
-registers_info (addr_exp)
+registers_info (addr_exp, fpregs)
char *addr_exp;
+ int fpregs;
{
int regnum;
else
regnum = -1;
- DO_REGISTERS_INFO(regnum);
+ DO_REGISTERS_INFO(regnum, fpregs);
+}
+
+static void
+all_registers_info (addr_exp, from_tty)
+ char *addr_exp;
+ int from_tty;
+{
+ registers_info (addr_exp, 1);
+}
+
+static void
+nofp_registers_info (addr_exp, from_tty)
+ char *addr_exp;
+ int from_tty;
+{
+ registers_info (addr_exp, 0);
}
\f
/*
char *args;
int from_tty;
{
+ dont_repeat (); /* Not for the faint of heart */
target_attach (args, from_tty);
}
char *args;
int from_tty;
{
+ dont_repeat (); /* Not for the faint of heart */
target_detach (args, from_tty);
}
/* ARGSUSED */
static void
-float_info (addr_exp)
+float_info (addr_exp, from_tty)
char *addr_exp;
+ int from_tty;
{
#ifdef FLOAT_INFO
FLOAT_INFO;
#else
- printf ("No floating point info available for this processor.\n");
+ printf_filtered ("No floating point info available for this processor.\n");
#endif
}
\f
+struct cmd_list_element *unsetlist = NULL;
+
+/* ARGSUSED */
+static void
+unset_command (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ printf_filtered ("\"unset\" must be followed by the name of an unset subcommand.\n");
+ help_list (unsetlist, "unset ", -1, stdout);
+}
+
void
_initialize_infcmd ()
{
environment to be given to the program.", &showlist);
c->completer = noop_completer;
+ add_prefix_cmd ("unset", no_class, unset_command,
+ "Complement to certain \"set\" commands",
+ &unsetlist, "unset ", 0, &cmdlist);
+
c = add_cmd ("environment", class_run, unset_environment_command,
"Cancel environment variable VAR for the program.\n\
This does not affect the program until the next \"run\" command.",
- &deletelist);
+ &unsetlist);
c->completer = noop_completer;
c = add_cmd ("environment", class_run, set_environment_command,
directories, separated by colons. These directories are searched to find\n\
fully linked executable files and separately compiled object files as needed.");
- add_info ("path", path_info,
+ c = add_cmd ("paths", no_class, path_info,
"Current search path for finding object files.\n\
$cwd in the path means the current working directory.\n\
This path is equivalent to the $PATH shell variable. It is a list of\n\
directories, separated by colons. These directories are searched to find\n\
-fully linked executable files and separately compiled object files as needed.");
+fully linked executable files and separately compiled object files as needed.", &showlist);
+ c->completer = noop_completer;
add_com ("attach", class_run, attach_command,
"Attach to a process or file outside of GDB.\n\
"Start debugged program. You may specify arguments to give it.\n\
Args may include \"*\", or \"[...]\"; they are expanded using \"sh\".\n\
Input and output redirection with \">\", \"<\", or \">>\" are also allowed.\n\n\
-With no arguments, uses arguments last specified (with \"run\" or \"set args\".\n\
+With no arguments, uses arguments last specified (with \"run\" or \"set args\").\n\
To cancel previous arguments and run with no arguments,\n\
use \"set args\" without arguments.");
add_com_alias ("r", "run", class_run, 1);
- add_info ("registers", registers_info,
- "List of registers and their contents, for selected stack frame.\n\
+ add_info ("registers", nofp_registers_info,
+ "List of integer registers and their contents, for selected stack frame.\n\
+Register name as argument means describe only that register.");
+
+ add_info ("all-registers", all_registers_info,
+"List of all registers and their contents, for selected stack frame.\n\
Register name as argument means describe only that register.");
add_info ("program", program_info,