From 941b2747b65855b51dbabbd4f7f9fe4607ce25db Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Sun, 18 Jan 1998 12:35:48 +0000 Subject: [PATCH] Don't override FRAME_CHAIN(). If the current frame is valid, then the previous frame is in the usual place even for traps, interrupts and syscalls in the kernel, because the assembly language stubs don't change the frame pointer. The previous frame is just not for the calling function. We may as well depend on this as on magic to determine the trap frame address. The magic is in FRAME_SAVED_PC() which elides the correct number of stubs (1) to go back to a pc that matches the previous frame. Removing fbsd_kern_frame_chain() fixes bugs in it. Xsyscall was misspelled as _Xsyscall (gdb removes one leading underscore), so the tf_syscall frame type was never found. This was harmless because tf_normal works in all cases in fbsd_kern_frame_chain() and Xsyscall is spelled correctly in fbsd_kern_frame_saved_pc() where it matters. There were style bugs on almost every line, starting with a primary indent of 7. --- gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c | 38 ------------------------ gnu/usr.bin/binutils/gdb/i386/tm.h | 15 ---------- gnu/usr.bin/binutils/gdb/kvm-fbsd.c | 38 ------------------------ gnu/usr.bin/gdb/gdb/kvm-fbsd.c | 38 ------------------------ gnu/usr.bin/gdb/gdb/tm.h | 15 ---------- 5 files changed, 144 deletions(-) diff --git a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c index ed1504ec9ac..8004a38059e 100644 --- a/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/i386/kvm-fbsd.c @@ -162,44 +162,6 @@ struct frame_info *fr; } } -CORE_ADDR -fbsd_kern_frame_chain (fr) -struct frame_info *fr; -{ - struct minimal_symbol *sym; - CORE_ADDR this_saved_pc; - enum frametype frametype; - - this_saved_pc = read_memory_integer (fr->frame + 4, 4); - sym = lookup_minimal_symbol_by_pc (this_saved_pc); - frametype = tf_normal; - if (sym != NULL) { - if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0) - frametype = tf_trap; - else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0) - frametype = tf_interrupt; - else if (strcmp (SYMBOL_NAME(sym), "_Xsyscall") == 0) - frametype = tf_syscall; - } - - switch (frametype) { - case tf_normal: - return (read_memory_integer (fr->frame, 4)); - -#define oEBP offsetof(struct trapframe, tf_ebp) - - case tf_trap: - return (read_memory_integer (fr->frame + 8 + oEBP, 4)); - - case tf_interrupt: - return (read_memory_integer (fr->frame + 16 + oEBP, 4)); - - case tf_syscall: - return (read_memory_integer (fr->frame + 8 + oEBP, 4)); -#undef oEBP - } -} - static CORE_ADDR ksym_lookup (name) const char *name; diff --git a/gnu/usr.bin/binutils/gdb/i386/tm.h b/gnu/usr.bin/binutils/gdb/i386/tm.h index 6f5fc9168af..39fda778633 100644 --- a/gnu/usr.bin/binutils/gdb/i386/tm.h +++ b/gnu/usr.bin/binutils/gdb/i386/tm.h @@ -35,21 +35,6 @@ extern void i386_float_info PARAMS ((void)); #define IN_SOLIB_CALL_TRAMPOLINE(pc, name) STREQ (name, "_DYNAMIC") -/* FRAME_CHAIN takes a frame's nominal address and produces the frame's - chain-pointer. - In the case of the i386, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -extern CORE_ADDR fbsd_kern_frame_chain (struct frame_info *); -#undef FRAME_CHAIN -#define FRAME_CHAIN(thisframe) \ - (kernel_debugging ? fbsd_kern_frame_chain(thisframe) : \ - ((thisframe)->signal_handler_caller \ - ? (thisframe)->frame \ - : (!inside_entry_file ((thisframe)->pc) \ - ? read_memory_integer ((thisframe)->frame, 4) \ - : 0))) - /* Saved Pc. Get it from sigcontext if within sigtramp. */ extern CORE_ADDR fbsd_kern_frame_saved_pc (struct frame_info *); diff --git a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c index ed1504ec9ac..8004a38059e 100644 --- a/gnu/usr.bin/binutils/gdb/kvm-fbsd.c +++ b/gnu/usr.bin/binutils/gdb/kvm-fbsd.c @@ -162,44 +162,6 @@ struct frame_info *fr; } } -CORE_ADDR -fbsd_kern_frame_chain (fr) -struct frame_info *fr; -{ - struct minimal_symbol *sym; - CORE_ADDR this_saved_pc; - enum frametype frametype; - - this_saved_pc = read_memory_integer (fr->frame + 4, 4); - sym = lookup_minimal_symbol_by_pc (this_saved_pc); - frametype = tf_normal; - if (sym != NULL) { - if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0) - frametype = tf_trap; - else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0) - frametype = tf_interrupt; - else if (strcmp (SYMBOL_NAME(sym), "_Xsyscall") == 0) - frametype = tf_syscall; - } - - switch (frametype) { - case tf_normal: - return (read_memory_integer (fr->frame, 4)); - -#define oEBP offsetof(struct trapframe, tf_ebp) - - case tf_trap: - return (read_memory_integer (fr->frame + 8 + oEBP, 4)); - - case tf_interrupt: - return (read_memory_integer (fr->frame + 16 + oEBP, 4)); - - case tf_syscall: - return (read_memory_integer (fr->frame + 8 + oEBP, 4)); -#undef oEBP - } -} - static CORE_ADDR ksym_lookup (name) const char *name; diff --git a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c index ed1504ec9ac..8004a38059e 100644 --- a/gnu/usr.bin/gdb/gdb/kvm-fbsd.c +++ b/gnu/usr.bin/gdb/gdb/kvm-fbsd.c @@ -162,44 +162,6 @@ struct frame_info *fr; } } -CORE_ADDR -fbsd_kern_frame_chain (fr) -struct frame_info *fr; -{ - struct minimal_symbol *sym; - CORE_ADDR this_saved_pc; - enum frametype frametype; - - this_saved_pc = read_memory_integer (fr->frame + 4, 4); - sym = lookup_minimal_symbol_by_pc (this_saved_pc); - frametype = tf_normal; - if (sym != NULL) { - if (strcmp (SYMBOL_NAME(sym), "calltrap") == 0) - frametype = tf_trap; - else if (strncmp (SYMBOL_NAME(sym), "Xresume", 7) == 0) - frametype = tf_interrupt; - else if (strcmp (SYMBOL_NAME(sym), "_Xsyscall") == 0) - frametype = tf_syscall; - } - - switch (frametype) { - case tf_normal: - return (read_memory_integer (fr->frame, 4)); - -#define oEBP offsetof(struct trapframe, tf_ebp) - - case tf_trap: - return (read_memory_integer (fr->frame + 8 + oEBP, 4)); - - case tf_interrupt: - return (read_memory_integer (fr->frame + 16 + oEBP, 4)); - - case tf_syscall: - return (read_memory_integer (fr->frame + 8 + oEBP, 4)); -#undef oEBP - } -} - static CORE_ADDR ksym_lookup (name) const char *name; diff --git a/gnu/usr.bin/gdb/gdb/tm.h b/gnu/usr.bin/gdb/gdb/tm.h index 6f5fc9168af..39fda778633 100644 --- a/gnu/usr.bin/gdb/gdb/tm.h +++ b/gnu/usr.bin/gdb/gdb/tm.h @@ -35,21 +35,6 @@ extern void i386_float_info PARAMS ((void)); #define IN_SOLIB_CALL_TRAMPOLINE(pc, name) STREQ (name, "_DYNAMIC") -/* FRAME_CHAIN takes a frame's nominal address and produces the frame's - chain-pointer. - In the case of the i386, the frame's nominal address - is the address of a 4-byte word containing the calling frame's address. */ - -extern CORE_ADDR fbsd_kern_frame_chain (struct frame_info *); -#undef FRAME_CHAIN -#define FRAME_CHAIN(thisframe) \ - (kernel_debugging ? fbsd_kern_frame_chain(thisframe) : \ - ((thisframe)->signal_handler_caller \ - ? (thisframe)->frame \ - : (!inside_entry_file ((thisframe)->pc) \ - ? read_memory_integer ((thisframe)->frame, 4) \ - : 0))) - /* Saved Pc. Get it from sigcontext if within sigtramp. */ extern CORE_ADDR fbsd_kern_frame_saved_pc (struct frame_info *);