+2002-12-08 Andrew Cagney <ac131313@redhat.com>
+
+ * gdbarch.sh (INIT_FRAME_PC_FIRST, INIT_FRAME_PC_DEFAULT): Convert
+ to pure functions.
+ * gdbarch.h, gdbarch.c: Re-generate.
+ * frame.c (get_prev_frame): Explictly assign prev's pc with value
+ returned by INIT_FRAME_PC_FIRST and INIT_EXTRA_FRAME_INFO.
+
+ * arch-utils.h (init_frame_pc_default, init_frame_pc_noop): Change
+ declaration to a function returning a CORE_ADDR.
+ * x86-64-tdep.h (x86_64_init_frame_pc): Ditto.
+ * arch-utils.c (init_frame_pc_noop): Return the PC value.
+ (init_frame_pc_default): Ditto.
+ * x86-64-linux-tdep.c (x86_64_init_frame_pc): Ditto.
+ * s390-tdep.c (s390_init_frame_pc_first): Ditto.
+ * mips-tdep.c (mips_init_frame_pc_first): Ditto.
+ * dwarf2cfi.h (cfi_init_frame_pc): Ditto.
+ * dwarf2cfi.c (cfi_init_frame_pc): Ditto.
+ * alpha-tdep.c (alpha_init_frame_pc_first): Ditto.
+
+ * i386-interix-tdep.c (i386_interix_init_abi): Set init_frame_pc
+ to init_frame_pc_noop.
+ (i386_interix_init_frame_pc): Delete function.
+ * z8k-tdep.c (init_frame_pc): Delete function.
+ * config/z8k/tm-z8k.h (INIT_FRAME_PC): Define as init_frame_pc_noop.
+ (INIT_FRAME_PC_FIRST): Ditto.
+ * config/mn10200/tm-mn10200.h (INIT_FRAME_PC): Ditto.
+ (INIT_FRAME_PC_FIRST): Ditto.
+ * config/sparc/tm-sparc.h (INIT_FRAME_PC): Ditto.
+ * config/rs6000/tm-rs6000.h (INIT_FRAME_PC): Redefine as
+ init_frame_pc_noop.
+ (INIT_FRAME_PC_FIRST): Convert to an expression.
+ * config/sparc/tm-sparc.h (INIT_FRAME_PC_FIRST): Ditto.
+
2002-12-08 Andrew Cagney <ac131313@redhat.com>
* blockframe.c: Use get_frame_base instead of directly accessing
fi->saved_regs[SP_REGNUM] = fi->frame;
}
-static void
+static CORE_ADDR
alpha_init_frame_pc_first (int fromleaf, struct frame_info *prev)
{
- prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) :
- prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ());
+ return (fromleaf ? SAVED_PC_AFTER_CALL (get_next_frame (prev))
+ : get_next_frame (prev) ? FRAME_SAVED_PC (prev->next)
+ : read_pc ());
}
static CORE_ADDR
}
-void
+CORE_ADDR
init_frame_pc_noop (int fromleaf, struct frame_info *prev)
{
- return;
+ /* Do nothing, implies return the same PC value. */
+ return get_frame_pc (prev);
}
-void
+CORE_ADDR
init_frame_pc_default (int fromleaf, struct frame_info *prev)
{
if (fromleaf)
- prev->pc = SAVED_PC_AFTER_CALL (get_next_frame (prev));
+ return SAVED_PC_AFTER_CALL (get_next_frame (prev));
else if (get_next_frame (prev) != NULL)
- prev->pc = FRAME_SAVED_PC (get_next_frame (prev));
+ return FRAME_SAVED_PC (get_next_frame (prev));
else
- prev->pc = read_pc ();
+ return read_pc ();
}
void
/* Versions of init_frame_pc(). Do nothing; do the default. */
-void init_frame_pc_noop (int fromleaf, struct frame_info *prev);
+extern CORE_ADDR init_frame_pc_noop (int fromleaf, struct frame_info *prev);
-void init_frame_pc_default (int fromleaf, struct frame_info *prev);
+extern CORE_ADDR init_frame_pc_default (int fromleaf, struct frame_info *prev);
/* Do nothing version of elf_make_msymbol_special. */
extern void mn10200_init_extra_frame_info (struct frame_info *);
#define INIT_EXTRA_FRAME_INFO(fromleaf, fi) mn10200_init_extra_frame_info (fi)
-#define INIT_FRAME_PC(x,y)
+#define INIT_FRAME_PC(x,y) (init_frame_pc_noop (x, y))
+#define INIT_FRAME_PC_FIRST(x,y) (init_frame_pc_noop (x, y))
extern void mn10200_frame_find_saved_regs (struct frame_info *,
struct frame_saved_regs *);
/* Define other aspects of the stack frame. */
#define DEPRECATED_INIT_FRAME_PC_FIRST(fromleaf, prev) \
- prev->pc = (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \
- prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ());
-#define INIT_FRAME_PC(fromleaf, prev) /* nothing */
+ (fromleaf ? SAVED_PC_AFTER_CALL (prev->next) : \
+ prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ())
+#define INIT_FRAME_PC(fromleaf, prev) (init_frame_pc_noop (fromleaf, prev))
/* Flag for machine-specific stuff in shared files. FIXME */
#define IBM6000_TARGET
/* INIT_EXTRA_FRAME_INFO needs the PC to detect flat frames. */
-#define INIT_FRAME_PC(FROMLEAF, PREV) /* nothing */
+#define INIT_FRAME_PC(FROMLEAF, PREV) (init_frame_pc_noop (FROMLEAF, PREV))
#define DEPRECATED_INIT_FRAME_PC_FIRST(FROMLEAF, PREV) \
- (PREV)->pc = ((FROMLEAF) ? SAVED_PC_AFTER_CALL ((PREV)->next) : \
- (PREV)->next ? FRAME_SAVED_PC ((PREV)->next) : read_pc ());
+ ((FROMLEAF) ? SAVED_PC_AFTER_CALL ((PREV)->next) : \
+ (PREV)->next ? FRAME_SAVED_PC ((PREV)->next) : read_pc ())
/* Define other aspects of the stack frame. */
#define REGISTER_VIRTUAL_TYPE(N) \
(REGISTER_VIRTUAL_SIZE(N) == 2? builtin_type_unsigned_int : builtin_type_long)
-/*#define INIT_FRAME_PC(x,y) init_frame_pc(x,y) */
-/* Initializer for an array of names of registers.
- Entries beyond the first NUM_REGS are ignored. */
+#define INIT_FRAME_PC(x,y) (init_frame_pc_noop (x, y))
+#define INIT_FRAME_PC_FIRST(x,y) (init_frame_pc_noop (x, y))
#define REGISTER_NAMES \
{"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
}
/* Sets the pc of the frame. */
-void
+CORE_ADDR
cfi_init_frame_pc (int fromleaf, struct frame_info *fi)
{
- if (fi->next)
- get_reg ((char *) &(fi->pc), UNWIND_CONTEXT (fi->next), PC_REGNUM);
+ if (get_next_frame (fi))
+ {
+ CORE_ADDR pc;
+ /* FIXME: cagney/2002-12-04: This is straight wrong. It's
+ assuming that the PC is CORE_ADDR (a host quantity) in size. */
+ get_reg (&pc, UNWIND_CONTEXT (get_next_frame (fi)), PC_REGNUM);
+ return pc;
+ }
else
- fi->pc = read_pc ();
+ return read_pc ();
}
/* Initialize unwind context informations of the frame. */
CORE_ADDR cfi_frame_chain (struct frame_info *fi);
/* Sets the pc of the frame. */
-void cfi_init_frame_pc (int fromleaf, struct frame_info *fi);
+CORE_ADDR cfi_init_frame_pc (int fromleaf, struct frame_info *fi);
/* Initialize unwind context informations of the frame. */
void cfi_init_extra_frame_info (int fromleaf, struct frame_info *fi);
function does have somewhere to cache that PC value. */
if (DEPRECATED_INIT_FRAME_PC_FIRST_P ())
- DEPRECATED_INIT_FRAME_PC_FIRST (fromleaf, prev);
+ prev->pc = (DEPRECATED_INIT_FRAME_PC_FIRST (fromleaf, prev));
if (INIT_EXTRA_FRAME_INFO_P ())
INIT_EXTRA_FRAME_INFO (fromleaf, prev);
/* This entry is in the frame queue now, which is good since
FRAME_SAVED_PC may use that queue to figure out its value (see
tm-sparc.h). We want the pc saved in the inferior frame. */
- INIT_FRAME_PC (fromleaf, prev);
+ prev->pc = (INIT_FRAME_PC (fromleaf, prev));
/* If ->frame and ->pc are unchanged, we are in the process of
getting ourselves into an infinite backtrace. Some architectures
DEPRECATED_INIT_FRAME_PC_FIRST_P ());
#endif
#ifdef DEPRECATED_INIT_FRAME_PC_FIRST
-#if GDB_MULTI_ARCH
- /* Macro might contain `[{}]' when not multi-arch */
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
"DEPRECATED_INIT_FRAME_PC_FIRST(fromleaf, prev)",
XSTRING (DEPRECATED_INIT_FRAME_PC_FIRST (fromleaf, prev)));
-#endif
if (GDB_MULTI_ARCH)
fprintf_unfiltered (file,
"gdbarch_dump: DEPRECATED_INIT_FRAME_PC_FIRST = 0x%08lx\n",
/*INIT_EXTRA_FRAME_INFO ()*/);
#endif
#ifdef INIT_FRAME_PC
-#if GDB_MULTI_ARCH
- /* Macro might contain `[{}]' when not multi-arch */
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
"INIT_FRAME_PC(fromleaf, prev)",
XSTRING (INIT_FRAME_PC (fromleaf, prev)));
-#endif
if (GDB_MULTI_ARCH)
fprintf_unfiltered (file,
"gdbarch_dump: INIT_FRAME_PC = 0x%08lx\n",
return gdbarch->deprecated_init_frame_pc_first != 0;
}
-void
+CORE_ADDR
gdbarch_deprecated_init_frame_pc_first (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev)
{
gdb_assert (gdbarch != NULL);
"gdbarch: gdbarch_deprecated_init_frame_pc_first invalid");
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_deprecated_init_frame_pc_first called\n");
- gdbarch->deprecated_init_frame_pc_first (fromleaf, prev);
+ return gdbarch->deprecated_init_frame_pc_first (fromleaf, prev);
}
void
gdbarch->deprecated_init_frame_pc_first = deprecated_init_frame_pc_first;
}
-void
+CORE_ADDR
gdbarch_init_frame_pc (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev)
{
gdb_assert (gdbarch != NULL);
"gdbarch: gdbarch_init_frame_pc invalid");
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_init_frame_pc called\n");
- gdbarch->init_frame_pc (fromleaf, prev);
+ return gdbarch->init_frame_pc (fromleaf, prev);
}
void
#define DEPRECATED_INIT_FRAME_PC_FIRST(fromleaf, prev) (internal_error (__FILE__, __LINE__, "DEPRECATED_INIT_FRAME_PC_FIRST"), 0)
#endif
-typedef void (gdbarch_deprecated_init_frame_pc_first_ftype) (int fromleaf, struct frame_info *prev);
-extern void gdbarch_deprecated_init_frame_pc_first (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev);
+typedef CORE_ADDR (gdbarch_deprecated_init_frame_pc_first_ftype) (int fromleaf, struct frame_info *prev);
+extern CORE_ADDR gdbarch_deprecated_init_frame_pc_first (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev);
extern void set_gdbarch_deprecated_init_frame_pc_first (struct gdbarch *gdbarch, gdbarch_deprecated_init_frame_pc_first_ftype *deprecated_init_frame_pc_first);
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_INIT_FRAME_PC_FIRST)
#error "Non multi-arch definition of DEPRECATED_INIT_FRAME_PC_FIRST"
#define INIT_FRAME_PC(fromleaf, prev) (init_frame_pc_default (fromleaf, prev))
#endif
-typedef void (gdbarch_init_frame_pc_ftype) (int fromleaf, struct frame_info *prev);
-extern void gdbarch_init_frame_pc (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev);
+typedef CORE_ADDR (gdbarch_init_frame_pc_ftype) (int fromleaf, struct frame_info *prev);
+extern CORE_ADDR gdbarch_init_frame_pc (struct gdbarch *gdbarch, int fromleaf, struct frame_info *prev);
extern void set_gdbarch_init_frame_pc (struct gdbarch *gdbarch, gdbarch_init_frame_pc_ftype *init_frame_pc);
#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (INIT_FRAME_PC)
#error "Non multi-arch definition of INIT_FRAME_PC"
v:1:CALL_DUMMY_STACK_ADJUST_P:int:call_dummy_stack_adjust_p::::0:-1:::0x%08lx
v:2:CALL_DUMMY_STACK_ADJUST:int:call_dummy_stack_adjust::::0:::gdbarch->call_dummy_stack_adjust_p && gdbarch->call_dummy_stack_adjust == 0:0x%08lx::CALL_DUMMY_STACK_ADJUST_P
f:2:FIX_CALL_DUMMY:void:fix_call_dummy:char *dummy, CORE_ADDR pc, CORE_ADDR fun, int nargs, struct value **args, struct type *type, int gcc_p:dummy, pc, fun, nargs, args, type, gcc_p:::0
-F::DEPRECATED_INIT_FRAME_PC_FIRST:void:deprecated_init_frame_pc_first:int fromleaf, struct frame_info *prev:fromleaf, prev
-f:2:INIT_FRAME_PC:void:init_frame_pc:int fromleaf, struct frame_info *prev:fromleaf, prev:::init_frame_pc_default::0
+F:2:DEPRECATED_INIT_FRAME_PC_FIRST:CORE_ADDR:deprecated_init_frame_pc_first:int fromleaf, struct frame_info *prev:fromleaf, prev
+f:2:INIT_FRAME_PC:CORE_ADDR:init_frame_pc:int fromleaf, struct frame_info *prev:fromleaf, prev:::init_frame_pc_default::0
#
v:2:BELIEVE_PCC_PROMOTION:int:believe_pcc_promotion:::::::
v:2:BELIEVE_PCC_PROMOTION_TYPE:int:believe_pcc_promotion_type:::::::
return i386_pe_skip_trampoline_code (pc, 0);
}
-static void
-i386_interix_init_frame_pc (int fromleaf, struct frame_info *prev)
-{
- /* Nothing to do on Interix. */
-}
-
static int
i386_interix_frame_chain_valid (CORE_ADDR chain, struct frame_info *thisframe)
{
set_gdbarch_skip_trampoline_code (gdbarch,
i386_interix_skip_trampoline_code);
set_gdbarch_init_extra_frame_info (gdbarch, i386_interix_back_one_frame);
- set_gdbarch_init_frame_pc (gdbarch, i386_interix_init_frame_pc);
+ set_gdbarch_init_frame_pc (gdbarch, init_frame_pc_noop);
set_gdbarch_frame_chain_valid (gdbarch, i386_interix_frame_chain_valid);
set_gdbarch_frame_saved_pc (gdbarch, i386_interix_frame_saved_pc);
set_gdbarch_name_of_malloc (gdbarch, "_malloc");
target_remove_breakpoint (next_pc, break_mem);
}
-static void
+static CORE_ADDR
mips_init_frame_pc_first (int fromleaf, struct frame_info *prev)
{
CORE_ADDR pc, tmp;
pc = ((fromleaf) ? SAVED_PC_AFTER_CALL (prev->next) :
prev->next ? FRAME_SAVED_PC (prev->next) : read_pc ());
tmp = SKIP_TRAMPOLINE_CODE (pc);
- prev->pc = tmp ? tmp : pc;
+ return tmp ? tmp : pc;
}
for the moment.
For some reason the blockframe.c calls us with fi->next->fromleaf
so this seems of little use to us. */
-void
+CORE_ADDR
s390_init_frame_pc_first (int next_fromleaf, struct frame_info *fi)
{
CORE_ADDR sigcaller_pc;
-
- fi->pc = 0;
+ CORE_ADDR pc = 0;
if (next_fromleaf)
{
- fi->pc = ADDR_BITS_REMOVE (read_register (S390_RETADDR_REGNUM));
+ pc = ADDR_BITS_REMOVE (read_register (S390_RETADDR_REGNUM));
/* fix signal handlers */
}
- else if (fi->next && fi->next->pc)
- fi->pc = s390_frame_saved_pc_nofix (fi->next);
- if (fi->pc && fi->next && fi->next->frame &&
- s390_is_sigreturn (fi->pc, fi->next, NULL, &sigcaller_pc))
+ else if (get_next_frame (fi) && get_frame_pc (get_next_frame (fi)))
+ pc = s390_frame_saved_pc_nofix (get_next_frame (fi));
+ if (pc && get_next_frame (fi) && get_frame_base (get_next_frame (fi))
+ && s390_is_sigreturn (pc, get_next_frame (fi), NULL, &sigcaller_pc))
{
- fi->pc = sigcaller_pc;
+ pc = sigcaller_pc;
}
-
+ return pc;
}
void
return fp;
}
-void
+CORE_ADDR
x86_64_init_frame_pc (int fromleaf, struct frame_info *fi)
{
CORE_ADDR addr;
- if (fi->next && (get_frame_type (fi->next) == SIGTRAMP_FRAME))
+ if (get_next_frame (fi) && (get_frame_type (fi->next) == SIGTRAMP_FRAME))
{
- addr = fi->next->next->frame
+ addr = get_frame_base (get_next_frame (get_next_frame (fi)))
+ LINUX_SIGINFO_SIZE + LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
- fi->pc = read_memory_integer (addr + LINUX_SIGCONTEXT_PC_OFFSET, 8);
+ return read_memory_integer (addr + LINUX_SIGCONTEXT_PC_OFFSET, 8);
}
else
- cfi_init_frame_pc (fromleaf, fi);
+ return cfi_init_frame_pc (fromleaf, fi);
}
gdbarch_saved_pc_after_call_ftype x86_64_linux_saved_pc_after_call;
gdbarch_pc_in_sigtramp_ftype x86_64_linux_in_sigtramp;
CORE_ADDR x86_64_linux_frame_chain (struct frame_info *fi);
-void x86_64_init_frame_pc (int fromleaf, struct frame_info *fi);
+CORE_ADDR x86_64_init_frame_pc (int fromleaf, struct frame_info *fi);
#endif
return 0;
}
-void
-init_frame_pc (void)
-{
- internal_error (__FILE__, __LINE__, "failed internal consistency check");
-}
-
/* Put here the code to store, into a struct frame_saved_regs,
the addresses of the saved registers of frame described by FRAME_INFO.
This includes special registers such as pc and fp saved in special