FRAME_ADDR step_frame_address;
/* 1 means step over all subroutine calls.
+ 0 means don't step over calls (used by stepi).
-1 means step over calls to undebuggable functions. */
int step_over_calls;
if (from_tty)
{
- printf_filtered ("Starting program: %s %s\n",
- exec_file? exec_file: "", inferior_args);
+ puts_filtered("Starting program: ");
+ if (exec_file)
+ puts_filtered(exec_file);
+ puts_filtered(" ");
+ puts_filtered(inferior_args);
+ puts_filtered("\n");
fflush (stdout);
}
{
struct minimal_symbol *msymbol;
+ /* FIXME: This should be using containing_function_bounds or a
+ cleaned-up version thereof, to deal with things like the
+ end of the text segment. */
+
msymbol = lookup_minimal_symbol_by_pc (stop_pc);
target_terminal_ours ();
printf_filtered ("Current function has no line number information.\n");
fflush (stdout);
- /* No info or after _etext ("Can't happen") */
- if (msymbol == NULL || (msymbol + 1) -> name == NULL)
- error ("No data available on pc function.");
+ if (msymbol == NULL || SYMBOL_NAME (msymbol + 1) == NULL)
+ {
+ /* If sigtramp is in the u area, check for it. */
+#if defined SIGTRAMP_START
+ if (IN_SIGTRAMP (stop_pc, (char *)NULL))
+ {
+ step_range_start = SIGTRAMP_START;
+ step_range_end = SIGTRAMP_END;
+ }
+ else
+#endif
+ error ("Cannot find bounds of current function.");
+ }
+ else
+ {
+ step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
+ step_range_end = SYMBOL_VALUE_ADDRESS (msymbol + 1);
+ }
printf_filtered ("Single stepping until function exit.\n");
fflush (stdout);
-
- step_range_start = msymbol -> address;
- step_range_end = (msymbol + 1) -> address;
}
}
else
register CORE_ADDR addr;
struct symtabs_and_lines sals;
struct symtab_and_line sal;
+ struct symbol *fn;
+ struct symbol *sfn;
ERROR_NO_INFERIOR;
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.");
- }
+ /* 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)
+ {
+ if (!query ("Line %d is not in `%s'. Jump anyway? ", sal.line,
+ SYMBOL_SOURCE_NAME (fn)))
+ {
+ error ("Not confirmed.");
+ /* NOTREACHED */
+ }
+ }
addr = ADDR_BITS_SET (sal.pc);
/* 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
if (msymbol == NULL)
error ("Execution is not within a known function.");
- step_range_start = msymbol -> address;
+ step_range_start = SYMBOL_VALUE_ADDRESS (msymbol);
step_range_end = pc;
}
else
{
register char *val = get_in_environ (inferior_environ, var);
if (val)
- printf_filtered ("%s = %s\n", var, val);
+ {
+ puts_filtered (var);
+ puts_filtered (" = ");
+ puts_filtered (val);
+ puts_filtered ("\n");
+ }
else
- printf_filtered ("Environment variable \"%s\" not defined.\n", var);
+ {
+ puts_filtered ("Environment variable \"");
+ puts_filtered (var);
+ puts_filtered ("\" not defined.\n");
+ }
}
else
{
register char **vector = environ_vector (inferior_environ);
while (*vector)
- printf_filtered ("%s\n", *vector++);
+ {
+ puts_filtered (*vector++);
+ puts_filtered ("\n");
+ }
}
}
if (p != 0 && val != 0)
{
/* We have both a space and an equals. If the space is before the
- equals and the only thing between the two is more space, use
- the equals */
+ equals, walk forward over the spaces til we see a nonspace
+ (possibly the equals). */
if (p > val)
while (*val == ' ')
val++;
- /* Take the smaller of the two. If there was space before the
- "=", they will be the same right now. */
- p = arg + min (p - arg, val - arg);
+ /* Now if the = is after the char following the spaces,
+ take the char following the spaces. */
+ if (p > val)
+ p = val - 1;
}
else if (val != 0 && p == 0)
p = val;
/* Handle the execution path (PATH variable) */
-const static char path_var_name[] = "PATH";
+static const char path_var_name[] = "PATH";
/* ARGSUSED */
static void
char *args;
int from_tty;
{
- printf_filtered ("Executable and object file path: %s\n",
- get_in_environ (inferior_environ, path_var_name));
+ puts_filtered ("Executable and object file path: ");
+ puts_filtered (get_in_environ (inferior_environ, path_var_name));
+ puts_filtered ("\n");
}
/* Add zero or more directories to the front of the execution path. */
path_info ((char *)NULL, from_tty);
}
\f
+/* XXX - This routine is getting awfully cluttered with #if's. It's probably
+ time to turn this into target_read_pc. Ditto for write_pc. */
+
CORE_ADDR
read_pc ()
{
+#ifdef GDB_TARGET_IS_HPPA
+ int flags = read_register(FLAGS_REGNUM);
+
+ if (flags & 2)
+ return read_register(31) & ~0x3; /* User PC is here when in sys call */
+ return read_register (PC_REGNUM) & ~0x3;
+#else
+#ifdef GDB_TARGET_IS_H8500
+ return (read_register (SEG_C_REGNUM) << 16) | read_register (PC_REGNUM);
+#else
return ADDR_BITS_REMOVE ((CORE_ADDR) read_register (PC_REGNUM));
+#endif
+#endif
}
void
{
write_register (PC_REGNUM, (long) val);
#ifdef NPC_REGNUM
- write_register (NPC_REGNUM, (long) val+4);
+ write_register (NPC_REGNUM, (long) val + 4);
+#ifdef NNPC_REGNUM
+ write_register (NNPC_REGNUM, (long) val + 8);
+#endif
+#endif
+#ifdef GDB_TARGET_IS_H8500
+ write_register (SEG_C_REGNUM, val >> 16);
#endif
pc_changed = 0;
}
continue;
}
- target_convert_to_virtual (i, raw_buffer, virtual_buffer);
+ REGISTER_CONVERT_TO_VIRTUAL (i, raw_buffer, virtual_buffer);
/* If virtual format is floating, print it that way, and in raw hex. */
if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT
int fpregs;
{
int regnum;
+ register char *end;
if (!target_has_registers)
error ("The program has no registers now.");
- if (addr_exp)
+ if (!addr_exp)
{
- if (*addr_exp >= '0' && *addr_exp <= '9')
- regnum = atoi (addr_exp);
- else
- {
- register char *p = addr_exp;
- if (p[0] == '$')
- p++;
- for (regnum = 0; regnum < NUM_REGS; regnum++)
- if (!strcmp (p, reg_names[regnum]))
- break;
- if (regnum == NUM_REGS)
- error ("%s: invalid register name.", addr_exp);
- }
+ DO_REGISTERS_INFO(-1, fpregs);
+ return;
}
- else
- regnum = -1;
- DO_REGISTERS_INFO(regnum, fpregs);
+ do
+ {
+ if (addr_exp[0] == '$')
+ addr_exp++;
+ end = addr_exp;
+ while (*end != '\0' && *end != ' ' && *end != '\t')
+ ++end;
+ for (regnum = 0; regnum < NUM_REGS; regnum++)
+ if (!strncmp (addr_exp, reg_names[regnum], end - addr_exp)
+ && strlen (reg_names[regnum]) == end - addr_exp)
+ goto found;
+ if (*addr_exp >= '0' && *addr_exp <= '9')
+ regnum = atoi (addr_exp); /* Take a number */
+ if (regnum >= NUM_REGS) /* Bad name, or bad number */
+ error ("%.*s: invalid register", end - addr_exp, addr_exp);
+
+found:
+ DO_REGISTERS_INFO(regnum, fpregs);
+
+ addr_exp = end;
+ while (*addr_exp == ' ' || *addr_exp == '\t')
+ ++addr_exp;
+ } while (*addr_exp != '\0');
}
static void
*/
/*
- * attach_command --
- * takes a program started up outside of gdb and ``attaches'' to it.
- * This stops it cold in its tracks and allows us to start tracing it.
- * For this to work, we must be able to send the process a
- * signal and we must have the same effective uid as the program.
- */
+ attach_command --
+ takes a program started up outside of gdb and ``attaches'' to it.
+ This stops it cold in its tracks and allows us to start debugging it.
+ and wait for the trace-trap that results from attaching. */
+
void
attach_command (args, from_tty)
char *args;
int from_tty;
{
dont_repeat (); /* Not for the faint of heart */
+
+ if (target_has_execution)
+ {
+ if (query ("A program is being debugged already. Kill it? "))
+ target_kill ();
+ else
+ error ("Not killed.");
+ }
+
target_attach (args, from_tty);
+
+ /* Set up the "saved terminal modes" of the inferior
+ based on what modes we are starting it with. */
+ target_terminal_init ();
+
+ /* Install inferior's terminal modes. */
+ target_terminal_inferior ();
+
+ /* Set up execution context to know that we should return from
+ wait_for_inferior as soon as the target reports a stop. */
+ init_wait_for_inferior ();
+ clear_proceed_status ();
+ stop_soon_quietly = 1;
+
+ wait_for_inferior ();
+
+#ifdef SOLIB_ADD
+ /* Add shared library symbols from the newly attached process, if any. */
+ SOLIB_ADD ((char *)0, from_tty, (struct target_ops *)0);
+#endif
+
+ normal_stop ();
}
/*
#endif
}
\f
-struct cmd_list_element *unsetlist = NULL;
-
/* ARGSUSED */
static void
unset_command (args, from_tty)
"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);