and stack pointer during stepping, to speed things up.
A. Changes to not select a frame until we need a selected frame:
* blockframe.c (flush_cached_frames): Call select_frame (NULL, -1).
* infrun.c (wait_for_inferior): Move call to select_frame back to
normal_stop. This reverts a change of 13 Apr 94 (it says Jeff
Law, but the change was my idea); the only reason for that change
was so we could save and restore the selected frame in
wait_for_inferior, and now that flush_cached frames clears the
selected frame, that should work OK now.
B. Changes to not create a current_frame until we need one:
* blockframe.c (get_current_frame): If current_frame is NULL, try
to create an innermost frame.
* sparc-tdep.c (sparc_pop_frame), infcmd.c (run-stack_dummy),
infrun.c (wait_for_inferior), thread.c (thread_switch),
convex-tdep.c (set_thread_command), a29k-tdep.c (pop_frame),
alpha-tdep.c (alpha_pop_frame), convex-xdep.c (core_file_command),
h8300-tdep.c (h8300_pop_frame), h8500-tdep.c (h8300_pop_frame),
hppa-tdep.c (hppa_pop_frame), i386-tdep.c (i386_pop_frame),
i960-tdep.c (pop_frame), m68k-tdep.c
(m68k_pop_frame), mips-tdep.c (mips_pop_frame), rs6000-tdep.c
(push_dummy_frame, pop_dummy_frame, pop_frame), sh-tdep.c
(pop_frame), config/arm/tm-arm.h (POP_FRAME),
config/convex/tm-convex.h (POP_FRAME), config/gould/tm-pn.h
(POP_FRAME), config/ns32k/tm-merlin.h (POP_FRAME),
config/ns32k/tm-umax.h (POP_FRAME), config/tahoe/tm-tahoe.h
(POP_FRAME), config/vax/tm-vax.h (POP_FRAME): Don't
call create_new_frame.
* corelow.c (core_open), altos-xdep.c (core_file_command),
arm-xdep.c (core_file_command), gould-xdep.c (core_file_command),
m3-nat.c (select_thread), sun386-nat.c (core_file_command),
umax-xdep.c (core_file_command): Don't call create_new_frame; do
call flush_cached_frames.
* blockframe.c (reinit_frame_cache): Don't call create_new_frame
or select_frame.
C. Changes to get rid of stop_frame_address and instead only
fetch the frame pointer when we need it.
* breakpoint.c (bpstat_stop_status): Remove argument
frame_address; use FRAME_FP (get_current_frame ()).
* infrun.c (wait_for_inferior): Don't pass frame pointer to
bpstat_stop_status.
* infrun.c (wait_for_inferior): Use FRAME_FP (get_current_frame
()) instead of stop_frame_address.
* infrun.c (save_inferior_status, restore_inferior_status),
inferior.h (struct inferior_status): Don't save and restore
stop_frame_address.
* inferior.h, infcmd.c, thread.c (thread_switch), m3-nat.c
(select_thread): Remove stop_frame_address and uses thereof.
D. Same thing for the stack pointer.
* infrun.c (wait_for_inferior): Remove stop_sp and replace
uses thereof with read_sp ().
E. Change to eliminate one nasty little spot where we were
wanting to know the frame pointer from before the current step
(idea from GDB 3.5, which saved my ass, because my other ideas of
how to fix it were very baroque).
* infrun.c: Remove prev_frame_address.
* infrun.c (wait_for_inferior, step_over_function): Use
step_frame_address instead of prev_frame_address.
F. Same basic idea for the stack pointer.
* inferior.h, infcmd.c: New variable step_sp.
* infcmd.c (step_1, until_next_command): Set it.
* infrun.c: Remove prev_sp and replace uses by step_sp.
* infrun.c (wait_for_inferior): If we get out of the step
range, then set step_sp to the current stack pointer before we
start going again.
+Fri Oct 7 08:48:18 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ The point of these changes is to avoid reading the frame pointer
+ and stack pointer during stepping, to speed things up.
+ A. Changes to not select a frame until we need a selected frame:
+ * blockframe.c (flush_cached_frames): Call select_frame (NULL, -1).
+ * infrun.c (wait_for_inferior): Move call to select_frame back to
+ normal_stop. This reverts a change of 13 Apr 94 (it says Jeff
+ Law, but the change was my idea); the only reason for that change
+ was so we could save and restore the selected frame in
+ wait_for_inferior, and now that flush_cached frames clears the
+ selected frame, that should work OK now.
+ B. Changes to not create a current_frame until we need one:
+ * blockframe.c (get_current_frame): If current_frame is NULL, try
+ to create an innermost frame.
+ * sparc-tdep.c (sparc_pop_frame), infcmd.c (run-stack_dummy),
+ infrun.c (wait_for_inferior), thread.c (thread_switch),
+ convex-tdep.c (set_thread_command), a29k-tdep.c (pop_frame),
+ alpha-tdep.c (alpha_pop_frame), convex-xdep.c (core_file_command),
+ h8300-tdep.c (h8300_pop_frame), h8500-tdep.c (h8300_pop_frame),
+ hppa-tdep.c (hppa_pop_frame), i386-tdep.c (i386_pop_frame),
+ i960-tdep.c (pop_frame), m68k-tdep.c
+ (m68k_pop_frame), mips-tdep.c (mips_pop_frame), rs6000-tdep.c
+ (push_dummy_frame, pop_dummy_frame, pop_frame), sh-tdep.c
+ (pop_frame), config/arm/tm-arm.h (POP_FRAME),
+ config/convex/tm-convex.h (POP_FRAME), config/gould/tm-pn.h
+ (POP_FRAME), config/ns32k/tm-merlin.h (POP_FRAME),
+ config/ns32k/tm-umax.h (POP_FRAME), config/tahoe/tm-tahoe.h
+ (POP_FRAME), config/vax/tm-vax.h (POP_FRAME): Don't
+ call create_new_frame.
+ * corelow.c (core_open), altos-xdep.c (core_file_command),
+ arm-xdep.c (core_file_command), gould-xdep.c (core_file_command),
+ m3-nat.c (select_thread), sun386-nat.c (core_file_command),
+ umax-xdep.c (core_file_command): Don't call create_new_frame; do
+ call flush_cached_frames.
+ * blockframe.c (reinit_frame_cache): Don't call create_new_frame
+ or select_frame.
+ C. Changes to get rid of stop_frame_address and instead only
+ fetch the frame pointer when we need it.
+ * breakpoint.c (bpstat_stop_status): Remove argument
+ frame_address; use FRAME_FP (get_current_frame ()).
+ * infrun.c (wait_for_inferior): Don't pass frame pointer to
+ bpstat_stop_status.
+ * infrun.c (wait_for_inferior): Use FRAME_FP (get_current_frame
+ ()) instead of stop_frame_address.
+ * infrun.c (save_inferior_status, restore_inferior_status),
+ inferior.h (struct inferior_status): Don't save and restore
+ stop_frame_address.
+ * inferior.h, infcmd.c, thread.c (thread_switch), m3-nat.c
+ (select_thread): Remove stop_frame_address and uses thereof.
+ D. Same thing for the stack pointer.
+ * infrun.c (wait_for_inferior): Remove stop_sp and replace
+ uses thereof with read_sp ().
+ E. Change to eliminate one nasty little spot where we were
+ wanting to know the frame pointer from before the current step
+ (idea from GDB 3.5, which saved my ass, because my other ideas of
+ how to fix it were very baroque).
+ * infrun.c: Remove prev_frame_address.
+ * infrun.c (wait_for_inferior, step_over_function): Use
+ step_frame_address instead of prev_frame_address.
+ F. Same basic idea for the stack pointer.
+ * inferior.h, infcmd.c: New variable step_sp.
+ * infcmd.c (step_1, until_next_command): Set it.
+ * infrun.c: Remove prev_sp and replace uses by step_sp.
+ * infrun.c (wait_for_inferior): If we get out of the step
+ range, then set step_sp to the current stack pointer before we
+ start going again.
+
Fri Oct 7 12:17:17 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
* top.c (target_byte_order_auto): New static variable.
}
}
flush_cached_frames ();
- set_current_frame (create_new_frame (0, read_pc()));
}
/* Push an empty stack frame, to record the current PC, etc. */
}
write_register (SP_REGNUM, new_sp);
flush_cached_frames ();
- /* We let init_extra_frame_info figure out the frame pointer */
- set_current_frame (create_new_frame (0, read_pc ()));
if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc))
{
corefile = concat (current_directory, "/", filename, NULL);
}
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
validate_files ();
}
corefile = concat (current_directory, "/", filename, NULL);
}
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
validate_files ();
}
#include "value.h" /* for read_register */
#include "target.h" /* for target_has_stack */
#include "inferior.h" /* for read_pc */
+#include "annotate.h"
/* Is ADDR inside the startup file? Note that if your machine
has a way to detect the bottom of the stack, there is no need
FRAME
get_current_frame ()
{
- /* We assume its address is kept in a general register;
- param.h says which register. */
-
+ if (current_frame == NULL)
+ {
+ if (target_has_stack)
+ current_frame = create_new_frame (read_fp (), read_pc ());
+ else
+ error ("No stack.");
+ }
return current_frame;
}
current_frame = frame;
}
+/* Create an arbitrary (i.e. address specified by user) or innermost frame.
+ Always returns a non-NULL value. */
+
FRAME
create_new_frame (addr, pc)
FRAME_ADDR addr;
obstack_init (&frame_cache_obstack);
current_frame = (struct frame_info *) 0; /* Invalidate cache */
- if (annotation_level > 1)
- {
- target_terminal_ours ();
- printf_unfiltered ("\n\032\032frames-invalid\n");
- }
+ select_frame ((FRAME) 0, -1);
+ annotate_frames_invalid ();
}
/* Flush the frame cache, and start a new one if necessary. */
+
void
reinit_frame_cache ()
{
flush_cached_frames ();
- if (target_has_stack)
+#if 0
+ /* The inferior_pid test is wrong if there is a corefile. But I don't
+ think this code is needed at all, now that get_current_frame will
+ create the frame if it is needed. */
+ if (inferior_pid != 0)
{
set_current_frame (create_new_frame (read_fp (), read_pc ()));
select_frame (get_current_frame (), 0);
set_current_frame (0);
select_frame ((FRAME) 0, -1);
}
+#endif
}
/* Return a structure containing various interesting information
{
FRAME frame = NULL;
- if (frame_addr == NULL)
+ if (frame_addr == (CORE_ADDR)0)
return NULL;
while (1)
if (*arg)
error ("Junk at end of expression");
}
+ breakpoints_changed ();
return;
}
*/
bpstat
-bpstat_stop_status (pc, frame_address, not_a_breakpoint)
+bpstat_stop_status (pc, not_a_breakpoint)
CORE_ADDR *pc;
- FRAME_ADDR frame_address;
int not_a_breakpoint;
{
register struct breakpoint *b;
real_breakpoint = 1;
#endif
- if (b->frame && b->frame != frame_address)
+ if (b->frame && b->frame != FRAME_FP (get_current_frame ()))
bs->stop = 0;
else
{
{
/* FIXME should make an annotation for this */
- printf_filtered ("\tbreakpoint already hit %d times\n",
- b->hit_count);
+ printf_filtered ("\tbreakpoint already hit %d time%s\n",
+ b->hit_count, (b->hit_count == 1 ? "" : "s"));
}
if (b->ignore_count)
write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
write_register (SP_REGNUM, fp + 8); \
flush_cached_frames (); \
- set_current_frame (create_new_frame (read_register (FP_REGNUM),\
- read_pc ())); \
}
/* This sequence of words is the instructions
write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
write_register (SP_REGNUM, fp + 8); \
flush_cached_frames (); \
- set_current_frame (create_new_frame (read_register (FP_REGNUM),\
- read_pc ())); }
+}
/* This sequence of words is the instructions
enter 0xff,0 82 ff 00
fp += (regnum + 1) * 4; } \
write_register (SP_REGNUM, fp); \
flush_cached_frames (); \
- set_current_frame (create_new_frame (read_register (FP_REGNUM),\
- read_pc ())); }
+}
/* This sequence of words is the instructions
calls #69, @#32323232
stop_pc = read_pc ();
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
select_frame (get_current_frame (), 0);
print_stack_frame (selected_frame, selected_frame_level, -1);
}
core_aouthdr.a_magic = 0;
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
select_frame (get_current_frame (), 0);
validate_files ();
#endif
/* Now, set up the frame cache, and print the top of stack */
- set_current_frame (create_new_frame (read_fp (),
- read_pc ()));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
print_stack_frame (selected_frame, selected_frame_level, 1);
} else {
corefile = concat (current_directory, "/", filename, NULL);
}
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
validate_files ();
}
}
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
}
}
}
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
-
}
}
write_register (SP_REGNUM, fp);
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
}
/*
and make it the current frame. */
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM), read_pc ()));
}
/* Given a 960 stop code (fault or trace), return the signal which
CORE_ADDR stop_pc;
-/* Stack frame when program stopped. */
-
-FRAME_ADDR stop_frame_address;
-
/* Chain containing status of breakpoint(s) that we have stopped at. */
bpstat stop_bpstat;
FRAME_ADDR step_frame_address;
+/* Our notion of the current stack pointer. */
+
+CORE_ADDR step_sp;
+
/* 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. */
dont_repeat ();
- /* Shouldn't this be target_has_execution? FIXME. */
if (inferior_pid)
{
if (
if (!fr) /* Avoid coredump here. Why tho? */
error ("No current frame");
step_frame_address = FRAME_FP (fr);
+ step_sp = read_sp ();
if (! single_inst)
{
frame in case there is only one copy of the dummy (e.g.
CALL_DUMMY_LOCATION == AFTER_TEXT_END). */
flush_cached_frames ();
- set_current_frame (create_new_frame (read_fp (), sal.pc));
/* If defined, CALL_DUMMY_BREAKPOINT_OFFSET is where we need to put
a breakpoint instruction. If not, the call dummy already has the
step_over_calls = 1;
step_frame_address = FRAME_FP (frame);
-
+ step_sp = read_sp ();
+
step_multi = 0; /* Only one call to proceed */
proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 1);
to provide that format. */
#if !defined (DO_REGISTERS_INFO)
+
#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;
+ int numregs = ARCH_NUM_REGS;
- for (i = 0; i < NUM_REGS; i++)
+ for (i = 0; i < numregs; i++)
{
char raw_buffer[MAX_REGISTER_RAW_SIZE];
char virtual_buffer[MAX_REGISTER_VIRTUAL_SIZE];
REGISTER_VIRTUAL_SIZE (i));
/* If virtual format is floating, print it that way, and in raw hex. */
- if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT
- && ! INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
+ if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (i)) == TYPE_CODE_FLT)
{
register int j;
- val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0,
- gdb_stdout, 0, 1, 0, Val_pretty_default);
+#ifdef INVALID_FLOAT
+ if (INVALID_FLOAT (virtual_buffer, REGISTER_VIRTUAL_SIZE (i)))
+ printf_filtered ("<invalid float>");
+ else
+#endif
+ val_print (REGISTER_VIRTUAL_TYPE (i), virtual_buffer, 0,
+ gdb_stdout, 0, 1, 0, Val_pretty_default);
printf_filtered ("\t(raw 0x");
for (j = 0; j < REGISTER_RAW_SIZE (i); j++)
char *addr_exp;
int fpregs;
{
- int regnum;
+ int regnum, numregs;
register char *end;
if (!target_has_registers)
end = addr_exp;
while (*end != '\0' && *end != ' ' && *end != '\t')
++end;
- for (regnum = 0; regnum < NUM_REGS; regnum++)
+ numregs = ARCH_NUM_REGS;
+ for (regnum = 0; regnum < numregs; 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 */
+ if (regnum >= numregs) /* Bad name, or bad number */
error ("%.*s: invalid register", end - addr_exp, addr_exp);
found:
CHK ("Could not abort system calls when selecting a thread", ret);
stop_pc = read_pc();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- stop_pc));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
-
- stop_frame_address = FRAME_FP (get_current_frame ());
}
return KERN_SUCCESS;
otherwise things like do_registers_info() wouldn't work properly! */
flush_cached_frames ();
- set_current_frame (create_new_frame (sp-DUMMY_FRAME_SIZE, pc));
/* save program counter in link register's space. */
write_memory (sp+8, pc_targ, 4);
target_store_registers (-1);
pc = read_pc ();
flush_cached_frames ();
- set_current_frame (create_new_frame (sp, pc));
}
write_register (SP_REGNUM, prev_sp);
target_store_registers (-1);
flush_cached_frames ();
- set_current_frame (create_new_frame (prev_sp, lr));
}
/* fixup the call sequence of a dummy function, with the real function address.
write_register (PC_REGNUM, fi->return_pc);
write_register (SP_REGNUM, fp + 4);
flush_cached_frames ();
- set_current_frame (create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
}
/* Print the registers in a form similar to the E7000 */
#include "target.h"
#include "value.h"
-#include "symfile.h" /* for objfiles.h */
-#include "objfiles.h" /* for find_pc_section */
-
#ifdef USE_PROC_FS
#include <sys/procfs.h>
#endif
frame = fi->bottom ?
fi->bottom : read_register (SP_REGNUM);
for (regnum = L0_REGNUM; regnum < L0_REGNUM+16; regnum++)
- saved_regs_addr->regs[regnum] = frame + (regnum-L0_REGNUM) * 4;
+ saved_regs_addr->regs[regnum] =
+ frame + (regnum - L0_REGNUM) * REGISTER_RAW_SIZE (L0_REGNUM);
}
if (fi->next)
{
fi->next->bottom :
read_register (SP_REGNUM));
for (regnum = O0_REGNUM; regnum < O0_REGNUM+8; regnum++)
- saved_regs_addr->regs[regnum] = next_next_frame + regnum * 4;
+ saved_regs_addr->regs[regnum] =
+ next_next_frame + regnum * REGISTER_RAW_SIZE (O0_REGNUM);
}
/* Otherwise, whatever we would get from ptrace(GETREGS) is accurate */
saved_regs_addr->regs[SP_REGNUM] = FRAME_FP (fi);
write_register (NPC_REGNUM, pc + 4);
}
flush_cached_frames ();
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
}
/* On the Sun 4 under SunOS, the compile will leave a fake insn which
return 1;
}
#endif /* GET_LONGJMP_TARGET */
-
-/* So far used only for sparc solaris. In sparc solaris, we recognize
- a trampoline by it's section name. That is, if the pc is in a
- section named ".plt" then we are in a trampline. */
-
-int
-in_solib_trampoline(pc, name)
- CORE_ADDR pc;
- char *name;
-{
- struct obj_section *s;
- int retval = 0;
-
- s = find_pc_section(pc);
-
- retval = (s != NULL
- && s->the_bfd_section->name != NULL
- && STREQ (s->the_bfd_section->name, ".plt"));
- return(retval);
-}
-
corefile = concat (current_directory, "/", filename, NULL);
}
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
validate_files ();
flush_cached_frames ();
registers_changed ();
stop_pc = read_pc();
- set_current_frame (create_new_frame (read_fp (), stop_pc));
- stop_frame_address = FRAME_FP (get_current_frame ());
select_frame (get_current_frame (), 0);
}
corefile = concat (current_directory, "/", filename, NULL);
}
- set_current_frame ( create_new_frame (read_register (FP_REGNUM),
- read_pc ()));
+ flush_cached_frames ();
select_frame (get_current_frame (), 0);
validate_files ();
}