From f2bf454e0f1bc17d01f9c2f22fe2010ee2442f3c Mon Sep 17 00:00:00 2001 From: Fred Fish Date: Sun, 28 Jul 1996 21:41:09 +0000 Subject: [PATCH] * config/mips/tm-mips.h (struct frame_info): Forward decl. (struct type): Ditto. (struct value): Ditto. * config/mips/tm-mips.h (sigtramp_address): Move extern decl from mips-tdep.c to here. (sigtramp_end): Ditto. (fixup_sigtramp): Ditto. * config/mips/tm-mips.h (init_extra_frame_info): Add prototype. (mips_frame_chain): Ditto. (mips_step_skips_delay): Ditto. (mips_frame_saved_pc): Ditto. (mips_find_saved_regs): Ditto. (mips_frame_num_args): Ditto. (mips_pop_frame): Ditto. (mips_extract_return_value): Ditto. (mips_store_return_value): Ditto. (mips_push_dummy_frame): Ditto. (mips_push_arguments): Ditto. (mips_do_registers_info): Ditto. (ecoff_relocate_efi): Ditto. (ecoff_relocate_efi): Ditto. * irix4-nat.c (fetch_core_registers): Add prototype. * mips-tdep.c (read_next_frame_reg): Add prototype (heuristic_proc_start): Ditto. (heuristic_proc_desc): Ditto. (mips_print_register): Ditto. * config/mips/nm-irix5.h (procfs_set_watchpoint): Add prototype. (procfs_stopped_by_watchpoint): Ditto. * config/mips/nm-irix4.h (procfs_set_watchpoint): Add prototype. (procfs_stopped_by_watchpoint): Ditto. * config/alpha/tm-alpha.h (ecoff_relocate_efi): Add prototype. (struct symbol): Add forward decl for prototype. * breakpoint.c (internal_breakpoint_number): Only needed if GET_LONGJMP_TARGET or SOLIB_ADD is defined. * objfiles.c (ecoff_relocate_efi): Remove prototype. --- gdb/ChangeLog | 42 +++++++++++++++++++++ gdb/config/mips/nm-irix4.h | 2 + gdb/config/mips/tm-mips.h | 27 ++++++++++++++ gdb/irix4-nat.c | 3 ++ gdb/mips-tdep.c | 75 ++++++++++++++++++++++++++++++++++++-- gdb/objfiles.c | 4 -- 6 files changed, 145 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 404a6bd620b..07e71bec8db 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,45 @@ +Sun Jul 28 10:46:39 1996 Fred Fish + + * config/mips/tm-mips.h (struct frame_info): Forward decl. + (struct type): Ditto. + (struct value): Ditto. + + * config/mips/tm-mips.h (sigtramp_address): Move extern decl + from mips-tdep.c to here. + (sigtramp_end): Ditto. + (fixup_sigtramp): Ditto. + + * config/mips/tm-mips.h (init_extra_frame_info): Add prototype. + (mips_frame_chain): Ditto. + (mips_step_skips_delay): Ditto. + (mips_frame_saved_pc): Ditto. + (mips_find_saved_regs): Ditto. + (mips_frame_num_args): Ditto. + (mips_pop_frame): Ditto. + (mips_extract_return_value): Ditto. + (mips_store_return_value): Ditto. + (mips_push_dummy_frame): Ditto. + (mips_push_arguments): Ditto. + (mips_do_registers_info): Ditto. + (ecoff_relocate_efi): Ditto. + (ecoff_relocate_efi): Ditto. + * irix4-nat.c (fetch_core_registers): Add prototype. + * mips-tdep.c (read_next_frame_reg): Add prototype + (heuristic_proc_start): Ditto. + (heuristic_proc_desc): Ditto. + (mips_print_register): Ditto. + * config/mips/nm-irix5.h (procfs_set_watchpoint): Add prototype. + (procfs_stopped_by_watchpoint): Ditto. + * config/mips/nm-irix4.h (procfs_set_watchpoint): Add prototype. + (procfs_stopped_by_watchpoint): Ditto. + * config/alpha/tm-alpha.h (ecoff_relocate_efi): Add prototype. + (struct symbol): Add forward decl for prototype. + + * breakpoint.c (internal_breakpoint_number): Only needed if + GET_LONGJMP_TARGET or SOLIB_ADD is defined. + + * objfiles.c (ecoff_relocate_efi): Remove prototype. + Sat Jul 27 17:47:35 1996 Fred Fish * configure.in: Add test for "long long" support. diff --git a/gdb/config/mips/nm-irix4.h b/gdb/config/mips/nm-irix4.h index 78b88dfe762..c4227ba34e2 100644 --- a/gdb/config/mips/nm-irix4.h +++ b/gdb/config/mips/nm-irix4.h @@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define STOPPED_BY_WATCHPOINT(W) \ procfs_stopped_by_watchpoint(inferior_pid) +extern int procfs_stopped_by_watchpoint PARAMS ((int)); #define HAVE_NONSTEPPABLE_WATCHPOINT @@ -54,3 +55,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */ #define target_insert_watchpoint(addr, len, type) procfs_set_watchpoint (inferior_pid, addr, len, 2) #define target_remove_watchpoint(addr, len, type) procfs_set_watchpoint (inferior_pid, addr, 0, 0) +extern int procfs_set_watchpoint PARAMS ((int, CORE_ADDR, int, int)); diff --git a/gdb/config/mips/tm-mips.h b/gdb/config/mips/tm-mips.h index 499750f7149..935a277ede2 100644 --- a/gdb/config/mips/tm-mips.h +++ b/gdb/config/mips/tm-mips.h @@ -20,6 +20,13 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef __STDC__ +struct frame_info; +struct symbol; +struct type; +struct value; +#endif + #include #include "coff/sym.h" /* Needed for PDR below. */ #include "coff/symconst.h" @@ -72,6 +79,7 @@ extern CORE_ADDR mips_skip_prologue PARAMS ((CORE_ADDR addr, int lenient)); /* Return non-zero if PC points to an instruction which will cause a step to execute both the instruction at PC and an instruction at PC+4. */ #define STEP_SKIPS_DELAY(pc) (mips_step_skips_delay (pc)) +extern int mips_step_skips_delay PARAMS ((CORE_ADDR)); /* Immediately after a function call, return the saved pc. Can't always go through the frames for this because on some machines @@ -173,6 +181,7 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); of register dumps. */ #define DO_REGISTERS_INFO(_regnum, fp) mips_do_registers_info(_regnum, fp) +extern void mips_do_registers_info PARAMS ((int, int)); /* Total amount of space needed to store our copies of the machine's register state, the array `registers'. */ @@ -245,12 +254,15 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ mips_extract_return_value(TYPE, REGBUF, VALBUF) +extern void +mips_extract_return_value PARAMS ((struct type *, char [], char *)); /* Write into appropriate registers a function return value of type TYPE, given in virtual format. */ #define STORE_RETURN_VALUE(TYPE,VALBUF) \ mips_store_return_value(TYPE, VALBUF) +extern void mips_store_return_value PARAMS ((struct type *, char *)); /* Extract from an array REGBUF containing the (raw) register state the address in which a function should return its structure value, @@ -275,6 +287,7 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); and produces the frame's chain-pointer. */ #define FRAME_CHAIN(thisframe) (CORE_ADDR) mips_frame_chain (thisframe) +extern CORE_ADDR mips_frame_chain PARAMS ((struct frame_info *)); /* Define other aspects of the stack frame. */ @@ -289,6 +302,7 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); /* Saved Pc. */ #define FRAME_SAVED_PC(FRAME) (mips_frame_saved_pc(FRAME)) +extern int mips_frame_saved_pc PARAMS ((struct frame_info *)); #define FRAME_ARGS_ADDRESS(fi) (fi)->frame @@ -298,6 +312,7 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); Can return -1, meaning no way to tell. */ #define FRAME_NUM_ARGS(num, fi) (num = mips_frame_num_args(fi)) +extern int mips_frame_num_args PARAMS ((struct frame_info *)); /* Return number of bytes at start of arglist that are not really args. */ @@ -316,6 +331,7 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); (frame_saved_regs) = *(frame_info)->saved_regs; \ (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame; \ } while (0) +extern void mips_find_saved_regs PARAMS ((struct frame_info *)); /* Things needed for making the inferior call functions. */ @@ -326,14 +342,18 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \ sp = mips_push_arguments(nargs, args, sp, struct_return, struct_addr) +extern CORE_ADDR +mips_push_arguments PARAMS ((int, struct value **, CORE_ADDR, int, CORE_ADDR)); /* Push an empty stack frame, to record the current PC, etc. */ #define PUSH_DUMMY_FRAME mips_push_dummy_frame() +extern void mips_push_dummy_frame PARAMS ((void)); /* Discard from the stack the innermost frame, restoring all registers. */ #define POP_FRAME mips_pop_frame() +extern void mips_pop_frame PARAMS ((void)); #define MK_OP(op,rs,rt,offset) (((op)<<26)|((rs)<<21)|((rt)<<16)|(offset)) #ifndef OP_LDFPR @@ -448,6 +468,7 @@ extern int in_sigtramp PARAMS ((CORE_ADDR, char *)); mips_extra_func_info_t's off of this. */ #define MIPS_EFI_SYMBOL_NAME "__GDB_EFI_INFO__" +extern void ecoff_relocate_efi PARAMS ((struct symbol *, CORE_ADDR)); /* Specific information about a procedure. This overlays the MIPS's PDR records, @@ -464,6 +485,7 @@ typedef struct mips_extra_func_info { struct frame_saved_regs *saved_regs; #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) +extern void init_extra_frame_info PARAMS ((struct frame_info *)); #define PRINT_EXTRA_FRAME_INFO(fi) \ { \ @@ -510,3 +532,8 @@ extern struct frame_info *setup_arbitrary_frame PARAMS ((int, CORE_ADDR *)); probably much more common. (FIXME). */ #define COERCE_FLOAT_TO_DOUBLE (current_language -> la_language == language_c) + +/* These are defined in mdebugread.c and are used in mips-tdep.c */ +extern CORE_ADDR sigtramp_address, sigtramp_end; +extern void fixup_sigtramp PARAMS ((void)); + diff --git a/gdb/irix4-nat.c b/gdb/irix4-nat.c index 8cd9b4c998d..a0176e916a4 100644 --- a/gdb/irix4-nat.c +++ b/gdb/irix4-nat.c @@ -35,6 +35,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ typedef unsigned int greg_t; /* why isn't this defined? */ +static void +fetch_core_registers PARAMS ((char *, unsigned int, int, unsigned int)); + /* * See the comment in m68k-tdep.c regarding the utility of these functions. */ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 7c95a4f728b..427e0f68d63 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -44,6 +44,15 @@ extern struct obstack frame_cache_obstack; static int mips_in_lenient_prologue PARAMS ((CORE_ADDR, CORE_ADDR)); #endif +static void mips_print_register PARAMS ((int, int)); + +static mips_extra_func_info_t +heuristic_proc_desc PARAMS ((CORE_ADDR, CORE_ADDR, struct frame_info *)); + +static CORE_ADDR heuristic_proc_start PARAMS ((CORE_ADDR)); + +static int read_next_frame_reg PARAMS ((struct frame_info *, int)); + static void mips_set_fpu_command PARAMS ((char *, int, struct cmd_list_element *)); @@ -59,6 +68,12 @@ static void mips_show_processor_type_command PARAMS ((char *, int)); static void reinit_frame_cache_sfunc PARAMS ((char *, int, struct cmd_list_element *)); +static mips_extra_func_info_t + find_proc_desc PARAMS ((CORE_ADDR pc, struct frame_info *next_frame)); + +static CORE_ADDR after_prologue PARAMS ((CORE_ADDR pc, + mips_extra_func_info_t proc_desc)); + /* This value is the model of MIPS in use. It is derived from the value of the PrID register. */ @@ -186,6 +201,44 @@ struct linked_proc_info } *linked_proc_desc_table = NULL; + +/* This returns the PC of the first inst after the prologue. If we can't + find the prologue, then return 0. */ + +static CORE_ADDR +after_prologue (pc, proc_desc) + CORE_ADDR pc; + mips_extra_func_info_t proc_desc; +{ + struct symtab_and_line sal; + CORE_ADDR func_addr, func_end; + + if (!proc_desc) + proc_desc = find_proc_desc (pc, NULL); + + if (proc_desc) + { + /* If function is frameless, then we need to do it the hard way. I + strongly suspect that frameless always means prologueless... */ + if (PROC_FRAME_REG (proc_desc) == SP_REGNUM + && PROC_FRAME_OFFSET (proc_desc) == 0) + return 0; + } + + if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end)) + return 0; /* Unknown */ + + sal = find_pc_line (func_addr, 0); + + if (sal.end < func_end) + return sal.end; + + /* The line after the prologue is after the end of the function. In this + case, tell the caller to find the prologue the hard way. */ + + return 0; +} + /* Guaranteed to set fci->saved_regs to some values (it never leaves it NULL). */ @@ -258,6 +311,11 @@ mips_find_saved_regs (fci) /* In a dummy frame we know exactly where things are saved. */ && !PROC_DESC_IS_DUMMY (proc_desc) + /* Don't bother unless we are inside a function prologue. Outside the + prologue, we know where everything is. */ + + && in_prologue (fci->pc, PROC_LOW_ADDR (proc_desc)) + /* Not sure exactly what kernel_trap means, but if it means the kernel saves the registers without a prologue doing it, we better not examine the prologue to see whether registers @@ -1129,6 +1187,19 @@ mips_skip_prologue (pc, lenient) int offset; int seen_sp_adjust = 0; int load_immediate_bytes = 0; + CORE_ADDR post_prologue_pc; + + /* See if we can determine the end of the prologue via the symbol table. + If so, then return either PC, or the PC after the prologue, whichever + is greater. */ + + post_prologue_pc = after_prologue (pc, NULL); + + if (post_prologue_pc != 0) + return max (pc, post_prologue_pc); + + /* Can't determine prologue from the symbol table, need to examine + instructions. */ /* Skip the typical prologue instructions. These are the stack adjustment instruction and the instructions that save registers on the stack @@ -1284,10 +1355,6 @@ mips_store_return_value (valtype, valbuf) write_register_bytes(REGISTER_BYTE (regnum), raw_buffer, TYPE_LENGTH (valtype)); } -/* These exist in mdebugread.c. */ -extern CORE_ADDR sigtramp_address, sigtramp_end; -extern void fixup_sigtramp PARAMS ((void)); - /* Exported procedure: Is PC in the signal trampoline code */ int diff --git a/gdb/objfiles.c b/gdb/objfiles.c index f135720b5f2..b78f80b23f2 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -35,10 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "obstack.h" #include "gdb_string.h" -/* FIXME: imported from mdebugread.c */ - -extern void ecoff_relocate_efi PARAMS ((struct symbol *, CORE_ADDR)); - /* Prototypes for local functions */ #if !defined(NO_MMALLOC) && defined(HAVE_MMAP) -- 2.30.2