* defs.h: Incorporate param.h. All users changed.
* param-no-tm.h: Change users to define TM_FILE_OVERRIDE instead.
* param.h, param-no-tm.h: Removed.
* Update copyrights in all changed files.
* dbxread.c, dwarfread.c, inflow.c, infrun.c, m2-exp.y, putenv.c,
solib.c, symtab.h, tm-umax.h, valprint.c: Lint.
* tm-convex.h, tm-hp300hpux.h, tm-merlin.h, tm-sparc.h,
xm-merlin.h: Avoid host include files in target descriptions.
* getpagesize.h: Removed, libiberty copes now.
1991-11-21 18:42:05 +00:00
|
|
|
/* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger.
|
1996-12-15 04:59:14 +00:00
|
|
|
Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
|
1994-01-31 16:23:48 +00:00
|
|
|
Free Software Foundation, Inc.
|
1991-03-28 16:26:26 +00:00
|
|
|
Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
|
|
|
|
and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
1991-08-19 20:54:03 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
1991-03-28 16:26:26 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
1991-08-19 20:54:03 +00:00
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1991-08-19 20:54:03 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
1991-03-28 16:26:26 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
1991-08-19 20:54:03 +00:00
|
|
|
along with this program; if not, write to the Free Software
|
1995-10-21 13:14:53 +00:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1991-03-28 16:26:26 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
1995-10-21 13:14:53 +00:00
|
|
|
#include "gdb_string.h"
|
1991-03-28 16:26:26 +00:00
|
|
|
#include "frame.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "symtab.h"
|
|
|
|
#include "value.h"
|
|
|
|
#include "gdbcmd.h"
|
1991-09-19 22:48:16 +00:00
|
|
|
#include "language.h"
|
1991-03-28 16:26:26 +00:00
|
|
|
#include "gdbcore.h"
|
1992-03-24 07:02:52 +00:00
|
|
|
#include "symfile.h"
|
|
|
|
#include "objfiles.h"
|
1994-02-25 04:23:19 +00:00
|
|
|
#include "gdbtypes.h"
|
1996-11-11 21:02:55 +00:00
|
|
|
#include "target.h"
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1993-07-19 02:28:21 +00:00
|
|
|
#include "opcode/mips.h"
|
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
#define VM_MIN_ADDRESS (CORE_ADDR)0x400000
|
1994-02-18 01:38:08 +00:00
|
|
|
|
|
|
|
/* FIXME: Put this declaration in frame.h. */
|
|
|
|
extern struct obstack frame_cache_obstack;
|
1996-11-11 21:02:55 +00:00
|
|
|
|
|
|
|
/* FIXME! this code assumes 4-byte instructions. */
|
1996-11-27 03:40:02 +00:00
|
|
|
#define MIPS_INSTLEN 4 /* Length of an instruction */
|
1997-01-31 16:37:07 +00:00
|
|
|
#define MIPS16_INSTLEN 2 /* Length of an instruction on MIPS16*/
|
1996-11-27 03:40:02 +00:00
|
|
|
#define MIPS_NUMREGS 32 /* Number of integer or float registers */
|
|
|
|
typedef unsigned long t_inst; /* Integer big enough to hold an instruction */
|
1996-11-11 21:02:55 +00:00
|
|
|
|
1993-11-12 16:35:59 +00:00
|
|
|
#if 0
|
1993-07-19 02:28:21 +00:00
|
|
|
static int mips_in_lenient_prologue PARAMS ((CORE_ADDR, CORE_ADDR));
|
1993-11-12 16:35:59 +00:00
|
|
|
#endif
|
1993-07-19 02:28:21 +00:00
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
static int gdb_print_insn_mips PARAMS ((bfd_vma, disassemble_info *));
|
|
|
|
|
1996-07-28 21:41:09 +00:00
|
|
|
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));
|
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
static CORE_ADDR read_next_frame_reg PARAMS ((struct frame_info *, int));
|
1996-07-28 21:41:09 +00:00
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
static void mips_set_fpu_command PARAMS ((char *, int,
|
|
|
|
struct cmd_list_element *));
|
|
|
|
|
|
|
|
static void mips_show_fpu_command PARAMS ((char *, int,
|
|
|
|
struct cmd_list_element *));
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
void mips_set_processor_type_command PARAMS ((char *, int));
|
|
|
|
|
1995-01-10 21:24:34 +00:00
|
|
|
int mips_set_processor_type PARAMS ((char *));
|
|
|
|
|
|
|
|
static void mips_show_processor_type_command PARAMS ((char *, int));
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
static void reinit_frame_cache_sfunc PARAMS ((char *, int,
|
|
|
|
struct cmd_list_element *));
|
|
|
|
|
1996-07-28 21:41:09 +00:00
|
|
|
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));
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
/* This value is the model of MIPS in use. It is derived from the value
|
|
|
|
of the PrID register. */
|
|
|
|
|
|
|
|
char *mips_processor_type;
|
|
|
|
|
|
|
|
char *tmp_mips_processor_type;
|
|
|
|
|
1993-02-22 23:43:03 +00:00
|
|
|
/* Some MIPS boards don't support floating point, so we permit the
|
|
|
|
user to turn it off. */
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
enum mips_fpu_type mips_fpu;
|
|
|
|
|
|
|
|
static char *mips_fpu_string;
|
1993-02-22 23:43:03 +00:00
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
/* A set of original names, to be used when restoring back to generic
|
|
|
|
registers from a specific set. */
|
|
|
|
|
|
|
|
char *mips_generic_reg_names[] = REGISTER_NAMES;
|
|
|
|
|
|
|
|
/* Names of IDT R3041 registers. */
|
|
|
|
|
|
|
|
char *mips_r3041_reg_names[] = {
|
|
|
|
"zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
|
|
|
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
|
|
|
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
|
|
|
|
"t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
|
|
|
|
"sr", "lo", "hi", "bad", "cause","pc",
|
|
|
|
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
|
|
|
|
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
|
|
|
|
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
|
|
|
|
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
|
|
|
|
"fsr", "fir", "fp", "",
|
|
|
|
"", "", "bus", "ccfg", "", "", "", "",
|
|
|
|
"", "", "port", "cmp", "", "", "epc", "prid",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Names of IDT R3051 registers. */
|
|
|
|
|
|
|
|
char *mips_r3051_reg_names[] = {
|
|
|
|
"zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
|
|
|
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
|
|
|
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
|
|
|
|
"t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
|
|
|
|
"sr", "lo", "hi", "bad", "cause","pc",
|
|
|
|
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
|
|
|
|
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
|
|
|
|
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
|
|
|
|
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
|
|
|
|
"fsr", "fir", "fp", "",
|
|
|
|
"inx", "rand", "elo", "", "ctxt", "", "", "",
|
|
|
|
"", "", "ehi", "", "", "", "epc", "prid",
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Names of IDT R3081 registers. */
|
|
|
|
|
|
|
|
char *mips_r3081_reg_names[] = {
|
|
|
|
"zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
|
|
|
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
|
|
|
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
|
|
|
|
"t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
|
|
|
|
"sr", "lo", "hi", "bad", "cause","pc",
|
|
|
|
"f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
|
|
|
|
"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15",
|
|
|
|
"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23",
|
|
|
|
"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31",
|
|
|
|
"fsr", "fir", "fp", "",
|
|
|
|
"inx", "rand", "elo", "cfg", "ctxt", "", "", "",
|
|
|
|
"", "", "ehi", "", "", "", "epc", "prid",
|
|
|
|
};
|
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
/* Names of LSI 33k registers. */
|
|
|
|
|
|
|
|
char *mips_lsi33k_reg_names[] = {
|
|
|
|
"zero", "at", "v0", "v1", "a0", "a1", "a2", "a3",
|
|
|
|
"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
|
|
|
|
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
|
|
|
|
"t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra",
|
|
|
|
"epc", "hi", "lo", "sr", "cause","badvaddr",
|
|
|
|
"dcic", "bpc", "bda", "", "", "", "", "",
|
|
|
|
"", "", "", "", "", "", "", "",
|
|
|
|
"", "", "", "", "", "", "", "",
|
|
|
|
"", "", "", "", "", "", "", "",
|
|
|
|
"", "", "", "",
|
|
|
|
"", "", "", "", "", "", "", "",
|
|
|
|
"", "", "", "", "", "", "", "",
|
|
|
|
};
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
char **regnames;
|
|
|
|
} mips_processor_type_table[] = {
|
|
|
|
{ "generic", mips_generic_reg_names },
|
|
|
|
{ "r3041", mips_r3041_reg_names },
|
|
|
|
{ "r3051", mips_r3051_reg_names },
|
|
|
|
{ "r3071", mips_r3081_reg_names },
|
|
|
|
{ "r3081", mips_r3081_reg_names },
|
1995-07-29 08:50:00 +00:00
|
|
|
{ "lsi33k", mips_lsi33k_reg_names },
|
1994-11-18 02:18:09 +00:00
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
/* Table to translate MIPS16 register field to actual register number. */
|
|
|
|
static int mips16_to_32_reg[8] = { 16, 17, 2, 3, 4, 5, 6, 7 };
|
|
|
|
|
1993-04-22 23:32:33 +00:00
|
|
|
/* Heuristic_proc_start may hunt through the text section for a long
|
|
|
|
time across a 2400 baud serial line. Allows the user to limit this
|
|
|
|
search. */
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1993-04-22 23:32:33 +00:00
|
|
|
static unsigned int heuristic_fence_post = 0;
|
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
#define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */
|
1996-11-11 21:02:55 +00:00
|
|
|
#define PROC_HIGH_ADDR(proc) ((proc)->high_addr) /* upper address bound */
|
1992-06-30 08:53:28 +00:00
|
|
|
#define PROC_FRAME_OFFSET(proc) ((proc)->pdr.frameoffset)
|
|
|
|
#define PROC_FRAME_REG(proc) ((proc)->pdr.framereg)
|
|
|
|
#define PROC_REG_MASK(proc) ((proc)->pdr.regmask)
|
|
|
|
#define PROC_FREG_MASK(proc) ((proc)->pdr.fregmask)
|
|
|
|
#define PROC_REG_OFFSET(proc) ((proc)->pdr.regoffset)
|
|
|
|
#define PROC_FREG_OFFSET(proc) ((proc)->pdr.fregoffset)
|
|
|
|
#define PROC_PC_REG(proc) ((proc)->pdr.pcreg)
|
|
|
|
#define PROC_SYMBOL(proc) (*(struct symbol**)&(proc)->pdr.isym)
|
1991-03-28 16:26:26 +00:00
|
|
|
#define _PROC_MAGIC_ 0x0F0F0F0F
|
1992-06-30 08:53:28 +00:00
|
|
|
#define PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym == _PROC_MAGIC_)
|
|
|
|
#define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_)
|
1991-03-28 16:26:26 +00:00
|
|
|
|
|
|
|
struct linked_proc_info
|
|
|
|
{
|
|
|
|
struct mips_extra_func_info info;
|
|
|
|
struct linked_proc_info *next;
|
1992-10-15 08:36:30 +00:00
|
|
|
} *linked_proc_desc_table = NULL;
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1996-07-28 21:41:09 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
/* Decode a MIPS32 instruction that saves a register in the stack, and
|
|
|
|
set the appropriate bit in the general register mask or float register mask
|
|
|
|
to indicate which register is saved. This is a helper function
|
|
|
|
for mips_find_saved_regs. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
mips32_decode_reg_save (inst, gen_mask, float_mask)
|
|
|
|
t_inst inst;
|
|
|
|
unsigned long *gen_mask;
|
|
|
|
unsigned long *float_mask;
|
|
|
|
{
|
|
|
|
int reg;
|
|
|
|
|
|
|
|
if ((inst & 0xffe00000) == 0xafa00000 /* sw reg,n($sp) */
|
|
|
|
|| (inst & 0xffe00000) == 0xafc00000 /* sw reg,n($r30) */
|
|
|
|
|| (inst & 0xffe00000) == 0xffa00000) /* sd reg,n($sp) */
|
|
|
|
{
|
|
|
|
/* It might be possible to use the instruction to
|
|
|
|
find the offset, rather than the code below which
|
|
|
|
is based on things being in a certain order in the
|
|
|
|
frame, but figuring out what the instruction's offset
|
|
|
|
is relative to might be a little tricky. */
|
|
|
|
reg = (inst & 0x001f0000) >> 16;
|
|
|
|
*gen_mask |= (1 << reg);
|
|
|
|
}
|
|
|
|
else if ((inst & 0xffe00000) == 0xe7a00000 /* swc1 freg,n($sp) */
|
|
|
|
|| (inst & 0xffe00000) == 0xe7c00000 /* swc1 freg,n($r30) */
|
|
|
|
|| (inst & 0xffe00000) == 0xf7a00000)/* sdc1 freg,n($sp) */
|
|
|
|
|
|
|
|
{
|
|
|
|
reg = ((inst & 0x001f0000) >> 16);
|
|
|
|
*float_mask |= (1 << reg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Decode a MIPS16 instruction that saves a register in the stack, and
|
|
|
|
set the appropriate bit in the general register or float register mask
|
|
|
|
to indicate which register is saved. This is a helper function
|
|
|
|
for mips_find_saved_regs. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
mips16_decode_reg_save (inst, gen_mask)
|
|
|
|
t_inst inst;
|
|
|
|
unsigned long *gen_mask;
|
|
|
|
{
|
1997-02-04 02:09:33 +00:00
|
|
|
if ((inst & 0xf800) == 0xd000) /* sw reg,n($sp) */
|
1997-01-28 00:50:13 +00:00
|
|
|
{
|
1997-02-04 02:09:33 +00:00
|
|
|
int reg = mips16_to_32_reg[(inst & 0x700) >> 8];
|
|
|
|
*gen_mask |= (1 << reg);
|
|
|
|
}
|
|
|
|
else if ((inst & 0xff00) == 0xf900) /* sd reg,n($sp) */
|
|
|
|
{
|
|
|
|
int reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
|
1997-01-28 00:50:13 +00:00
|
|
|
*gen_mask |= (1 << reg);
|
|
|
|
}
|
|
|
|
else if ((inst & 0xff00) == 0x6200 /* sw $ra,n($sp) */
|
|
|
|
|| (inst & 0xff00) == 0xfa00) /* sd $ra,n($sp) */
|
|
|
|
*gen_mask |= (1 << 31);
|
|
|
|
}
|
|
|
|
|
1994-02-18 01:38:08 +00:00
|
|
|
/* Guaranteed to set fci->saved_regs to some values (it never leaves it
|
|
|
|
NULL). */
|
|
|
|
|
|
|
|
void
|
|
|
|
mips_find_saved_regs (fci)
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *fci;
|
1994-02-18 01:38:08 +00:00
|
|
|
{
|
|
|
|
int ireg;
|
|
|
|
CORE_ADDR reg_position;
|
|
|
|
/* r0 bit means kernel trap */
|
|
|
|
int kernel_trap;
|
|
|
|
/* What registers have been saved? Bitmasks. */
|
|
|
|
unsigned long gen_mask, float_mask;
|
|
|
|
mips_extra_func_info_t proc_desc;
|
|
|
|
|
|
|
|
fci->saved_regs = (struct frame_saved_regs *)
|
|
|
|
obstack_alloc (&frame_cache_obstack, sizeof(struct frame_saved_regs));
|
|
|
|
memset (fci->saved_regs, 0, sizeof (struct frame_saved_regs));
|
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
/* If it is the frame for sigtramp, the saved registers are located
|
|
|
|
in a sigcontext structure somewhere on the stack.
|
|
|
|
If the stack layout for sigtramp changes we might have to change these
|
|
|
|
constants and the companion fixup_sigtramp in mdebugread.c */
|
|
|
|
#ifndef SIGFRAME_BASE
|
|
|
|
/* To satisfy alignment restrictions, sigcontext is located 4 bytes
|
|
|
|
above the sigtramp frame. */
|
1996-11-11 21:02:55 +00:00
|
|
|
#define SIGFRAME_BASE MIPS_REGSIZE
|
|
|
|
/* FIXME! Are these correct?? */
|
|
|
|
#define SIGFRAME_PC_OFF (SIGFRAME_BASE + 2 * MIPS_REGSIZE)
|
|
|
|
#define SIGFRAME_REGSAVE_OFF (SIGFRAME_BASE + 3 * MIPS_REGSIZE)
|
|
|
|
#define SIGFRAME_FPREGSAVE_OFF \
|
|
|
|
(SIGFRAME_REGSAVE_OFF + MIPS_NUMREGS * MIPS_REGSIZE + 3 * MIPS_REGSIZE)
|
1995-07-29 08:50:00 +00:00
|
|
|
#endif
|
|
|
|
#ifndef SIGFRAME_REG_SIZE
|
1996-11-11 21:02:55 +00:00
|
|
|
/* FIXME! Is this correct?? */
|
|
|
|
#define SIGFRAME_REG_SIZE MIPS_REGSIZE
|
1995-07-29 08:50:00 +00:00
|
|
|
#endif
|
|
|
|
if (fci->signal_handler_caller)
|
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
for (ireg = 0; ireg < MIPS_NUMREGS; ireg++)
|
1995-07-29 08:50:00 +00:00
|
|
|
{
|
|
|
|
reg_position = fci->frame + SIGFRAME_REGSAVE_OFF
|
|
|
|
+ ireg * SIGFRAME_REG_SIZE;
|
|
|
|
fci->saved_regs->regs[ireg] = reg_position;
|
|
|
|
}
|
1996-11-11 21:02:55 +00:00
|
|
|
for (ireg = 0; ireg < MIPS_NUMREGS; ireg++)
|
1995-07-29 08:50:00 +00:00
|
|
|
{
|
|
|
|
reg_position = fci->frame + SIGFRAME_FPREGSAVE_OFF
|
|
|
|
+ ireg * SIGFRAME_REG_SIZE;
|
|
|
|
fci->saved_regs->regs[FP0_REGNUM + ireg] = reg_position;
|
|
|
|
}
|
|
|
|
fci->saved_regs->regs[PC_REGNUM] = fci->frame + SIGFRAME_PC_OFF;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1994-02-18 01:38:08 +00:00
|
|
|
proc_desc = fci->proc_desc;
|
|
|
|
if (proc_desc == NULL)
|
|
|
|
/* I'm not sure how/whether this can happen. Normally when we can't
|
|
|
|
find a proc_desc, we "synthesize" one using heuristic_proc_desc
|
|
|
|
and set the saved_regs right away. */
|
|
|
|
return;
|
|
|
|
|
|
|
|
kernel_trap = PROC_REG_MASK(proc_desc) & 1;
|
|
|
|
gen_mask = kernel_trap ? 0xFFFFFFFF : PROC_REG_MASK(proc_desc);
|
|
|
|
float_mask = kernel_trap ? 0xFFFFFFFF : PROC_FREG_MASK(proc_desc);
|
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
if (/* In any frame other than the innermost or a frame interrupted by
|
|
|
|
a signal, we assume that all registers have been saved.
|
|
|
|
This assumes that all register saves in a function happen before
|
|
|
|
the first function call. */
|
|
|
|
(fci->next == NULL || fci->next->signal_handler_caller)
|
1994-02-18 01:38:08 +00:00
|
|
|
|
|
|
|
/* In a dummy frame we know exactly where things are saved. */
|
|
|
|
&& !PROC_DESC_IS_DUMMY (proc_desc)
|
|
|
|
|
1996-07-28 21:41:09 +00:00
|
|
|
/* 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))
|
|
|
|
|
1994-02-18 01:38:08 +00:00
|
|
|
/* 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
|
|
|
|
have been saved yet. */
|
|
|
|
&& !kernel_trap)
|
|
|
|
{
|
|
|
|
/* We need to figure out whether the registers that the proc_desc
|
|
|
|
claims are saved have been saved yet. */
|
|
|
|
|
|
|
|
CORE_ADDR addr;
|
|
|
|
int status;
|
1996-11-11 21:02:55 +00:00
|
|
|
char buf[MIPS_INSTLEN];
|
|
|
|
t_inst inst;
|
1997-01-28 00:50:13 +00:00
|
|
|
int instlen;
|
1994-02-18 01:38:08 +00:00
|
|
|
|
|
|
|
/* Bitmasks; set if we have found a save for the register. */
|
|
|
|
unsigned long gen_save_found = 0;
|
|
|
|
unsigned long float_save_found = 0;
|
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
if ((addr = PROC_LOW_ADDR (proc_desc)) & 1)
|
1994-02-18 01:38:08 +00:00
|
|
|
{
|
1997-01-31 16:37:07 +00:00
|
|
|
instlen = MIPS16_INSTLEN; /* MIPS16 */
|
1997-01-28 00:50:13 +00:00
|
|
|
addr &= ~1;
|
|
|
|
}
|
|
|
|
else
|
1997-01-31 16:37:07 +00:00
|
|
|
instlen = MIPS_INSTLEN; /* MIPS32 */
|
1997-01-28 00:50:13 +00:00
|
|
|
|
1997-01-31 16:37:07 +00:00
|
|
|
/* Scan through this function's instructions preceding the current
|
|
|
|
PC, and look for those that save registers. */
|
1997-01-28 00:50:13 +00:00
|
|
|
while (addr < fci->pc)
|
|
|
|
{
|
|
|
|
status = read_memory_nobpt (addr, buf, instlen);
|
1994-02-18 01:38:08 +00:00
|
|
|
if (status)
|
|
|
|
memory_error (status, addr);
|
1997-01-28 00:50:13 +00:00
|
|
|
inst = extract_unsigned_integer (buf, instlen);
|
1997-01-31 16:37:07 +00:00
|
|
|
if (instlen == MIPS16_INSTLEN)
|
1997-01-28 00:50:13 +00:00
|
|
|
mips16_decode_reg_save (inst, &gen_save_found);
|
|
|
|
else
|
|
|
|
mips32_decode_reg_save (inst, &gen_save_found, &float_save_found);
|
|
|
|
addr += instlen;
|
1994-02-18 01:38:08 +00:00
|
|
|
}
|
|
|
|
gen_mask = gen_save_found;
|
|
|
|
float_mask = float_save_found;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in the offsets for the registers which gen_mask says
|
|
|
|
were saved. */
|
|
|
|
reg_position = fci->frame + PROC_REG_OFFSET (proc_desc);
|
1996-11-11 21:02:55 +00:00
|
|
|
for (ireg= MIPS_NUMREGS-1; gen_mask; --ireg, gen_mask <<= 1)
|
1994-02-18 01:38:08 +00:00
|
|
|
if (gen_mask & 0x80000000)
|
|
|
|
{
|
|
|
|
fci->saved_regs->regs[ireg] = reg_position;
|
|
|
|
reg_position -= MIPS_REGSIZE;
|
|
|
|
}
|
|
|
|
/* Fill in the offsets for the registers which float_mask says
|
|
|
|
were saved. */
|
|
|
|
reg_position = fci->frame + PROC_FREG_OFFSET (proc_desc);
|
|
|
|
|
|
|
|
/* The freg_offset points to where the first *double* register
|
|
|
|
is saved. So skip to the high-order word. */
|
1996-11-11 21:02:55 +00:00
|
|
|
if (! GDB_TARGET_IS_MIPS64)
|
|
|
|
reg_position += 4;
|
|
|
|
|
1997-01-31 16:37:07 +00:00
|
|
|
/* Fill in the offsets for the float registers which float_mask says
|
|
|
|
were saved. */
|
1996-11-11 21:02:55 +00:00
|
|
|
for (ireg = MIPS_NUMREGS-1; float_mask; --ireg, float_mask <<= 1)
|
1994-02-18 01:38:08 +00:00
|
|
|
if (float_mask & 0x80000000)
|
|
|
|
{
|
|
|
|
fci->saved_regs->regs[FP0_REGNUM+ireg] = reg_position;
|
|
|
|
reg_position -= MIPS_REGSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fci->saved_regs->regs[PC_REGNUM] = fci->saved_regs->regs[RA_REGNUM];
|
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
static CORE_ADDR
|
1991-03-28 16:26:26 +00:00
|
|
|
read_next_frame_reg(fi, regno)
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *fi;
|
1991-03-28 16:26:26 +00:00
|
|
|
int regno;
|
|
|
|
{
|
|
|
|
for (; fi; fi = fi->next)
|
1994-02-18 01:38:08 +00:00
|
|
|
{
|
1995-07-29 08:50:00 +00:00
|
|
|
/* We have to get the saved sp from the sigcontext
|
|
|
|
if it is a signal handler frame. */
|
|
|
|
if (regno == SP_REGNUM && !fi->signal_handler_caller)
|
|
|
|
return fi->frame;
|
1994-02-18 01:38:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fi->saved_regs == NULL)
|
|
|
|
mips_find_saved_regs (fi);
|
|
|
|
if (fi->saved_regs->regs[regno])
|
|
|
|
return read_memory_integer(fi->saved_regs->regs[regno], MIPS_REGSIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return read_register (regno);
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
|
1996-11-27 03:40:02 +00:00
|
|
|
/* mips_addr_bits_remove - remove useless address bits */
|
|
|
|
|
|
|
|
CORE_ADDR
|
|
|
|
mips_addr_bits_remove (addr)
|
|
|
|
CORE_ADDR addr;
|
|
|
|
{
|
1996-12-15 04:59:14 +00:00
|
|
|
#if GDB_TARGET_IS_MIPS64
|
|
|
|
if ((addr >> 32 == (CORE_ADDR)0xffffffff)
|
1996-11-27 03:40:02 +00:00
|
|
|
&& (strcmp(target_shortname,"pmon")==0
|
|
|
|
|| strcmp(target_shortname,"ddb")==0
|
|
|
|
|| strcmp(target_shortname,"sim")==0))
|
|
|
|
{
|
|
|
|
/* This hack is a work-around for existing boards using PMON,
|
|
|
|
the simulator, and any other 64-bit targets that doesn't have
|
|
|
|
true 64-bit addressing. On these targets, the upper 32 bits
|
|
|
|
of addresses are ignored by the hardware. Thus, the PC or SP
|
|
|
|
are likely to have been sign extended to all 1s by instruction
|
|
|
|
sequences that load 32-bit addresses. For example, a typical
|
|
|
|
piece of code that loads an address is this:
|
|
|
|
lui $r2, <upper 16 bits>
|
|
|
|
ori $r2, <lower 16 bits>
|
|
|
|
But the lui sign-extends the value such that the upper 32 bits
|
|
|
|
may be all 1s. The workaround is simply to mask off these bits.
|
|
|
|
In the future, gcc may be changed to support true 64-bit
|
|
|
|
addressing, and this masking will have to be disabled. */
|
|
|
|
addr &= (CORE_ADDR)0xffffffff;
|
|
|
|
}
|
1997-01-28 00:50:13 +00:00
|
|
|
#else
|
|
|
|
/* Even when GDB is configured for some 32-bit targets (e.g. mips-elf),
|
|
|
|
BFD is configured to handle 64-bit targets, so CORE_ADDR is 64 bits.
|
|
|
|
So we still have to mask off useless bits from addresses. */
|
|
|
|
addr &= (CORE_ADDR)0xffffffff;
|
1996-12-15 04:59:14 +00:00
|
|
|
#endif
|
1996-11-27 03:40:02 +00:00
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
CORE_ADDR
|
1991-03-28 16:26:26 +00:00
|
|
|
mips_frame_saved_pc(frame)
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *frame;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
CORE_ADDR saved_pc;
|
1992-06-30 08:53:28 +00:00
|
|
|
mips_extra_func_info_t proc_desc = frame->proc_desc;
|
1994-01-31 16:23:48 +00:00
|
|
|
/* We have to get the saved pc from the sigcontext
|
|
|
|
if it is a signal handler frame. */
|
|
|
|
int pcreg = frame->signal_handler_caller ? PC_REGNUM
|
|
|
|
: (proc_desc ? PROC_PC_REG(proc_desc) : RA_REGNUM);
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc))
|
1996-11-11 21:02:55 +00:00
|
|
|
saved_pc = read_memory_integer(frame->frame - MIPS_REGSIZE, MIPS_REGSIZE);
|
|
|
|
else
|
|
|
|
saved_pc = read_next_frame_reg(frame, pcreg);
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1996-11-27 03:40:02 +00:00
|
|
|
return ADDR_BITS_REMOVE (saved_pc);
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct mips_extra_func_info temp_proc_desc;
|
|
|
|
static struct frame_saved_regs temp_saved_regs;
|
|
|
|
|
1993-03-13 00:32:10 +00:00
|
|
|
/* This fencepost looks highly suspicious to me. Removing it also
|
|
|
|
seems suspicious as it could affect remote debugging across serial
|
1993-04-22 23:32:33 +00:00
|
|
|
lines. */
|
1993-03-13 00:32:10 +00:00
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
static CORE_ADDR
|
|
|
|
heuristic_proc_start(pc)
|
1991-03-28 16:26:26 +00:00
|
|
|
CORE_ADDR pc;
|
|
|
|
{
|
1997-02-09 17:36:49 +00:00
|
|
|
CORE_ADDR start_pc;
|
|
|
|
CORE_ADDR fence;
|
1997-01-31 16:37:07 +00:00
|
|
|
int instlen;
|
1997-02-04 02:09:33 +00:00
|
|
|
int seen_adjsp = 0;
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1997-02-09 17:36:49 +00:00
|
|
|
pc = ADDR_BITS_REMOVE (pc);
|
|
|
|
start_pc = pc;
|
|
|
|
fence = start_pc - heuristic_fence_post;
|
1992-06-30 08:53:28 +00:00
|
|
|
if (start_pc == 0) return 0;
|
1993-04-22 23:32:33 +00:00
|
|
|
|
|
|
|
if (heuristic_fence_post == UINT_MAX
|
|
|
|
|| fence < VM_MIN_ADDRESS)
|
|
|
|
fence = VM_MIN_ADDRESS;
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1997-01-31 16:37:07 +00:00
|
|
|
instlen = pc & 1 ? MIPS16_INSTLEN : MIPS_INSTLEN;
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
/* search back for previous return */
|
1997-01-31 16:37:07 +00:00
|
|
|
for (start_pc -= instlen; ; start_pc -= instlen)
|
1993-03-13 00:32:10 +00:00
|
|
|
if (start_pc < fence)
|
|
|
|
{
|
1993-04-22 23:32:33 +00:00
|
|
|
/* It's not clear to me why we reach this point when
|
|
|
|
stop_soon_quietly, but with this test, at least we
|
|
|
|
don't print out warnings for every child forked (eg, on
|
|
|
|
decstation). 22apr93 rich@cygnus.com. */
|
|
|
|
if (!stop_soon_quietly)
|
|
|
|
{
|
1993-07-20 22:36:13 +00:00
|
|
|
static int blurb_printed = 0;
|
|
|
|
|
1993-04-22 23:32:33 +00:00
|
|
|
if (fence == VM_MIN_ADDRESS)
|
|
|
|
warning("Hit beginning of text section without finding");
|
|
|
|
else
|
|
|
|
warning("Hit heuristic-fence-post without finding");
|
|
|
|
|
1996-11-27 03:40:02 +00:00
|
|
|
warning("enclosing function for address 0x%s", paddr (pc));
|
1993-07-20 22:36:13 +00:00
|
|
|
if (!blurb_printed)
|
|
|
|
{
|
|
|
|
printf_filtered ("\
|
|
|
|
This warning occurs if you are debugging a function without any symbols\n\
|
|
|
|
(for example, in a stripped executable). In that case, you may wish to\n\
|
|
|
|
increase the size of the search with the `set heuristic-fence-post' command.\n\
|
|
|
|
\n\
|
|
|
|
Otherwise, you told GDB there was a function where there isn't one, or\n\
|
|
|
|
(more likely) you have encountered a bug in GDB.\n");
|
|
|
|
blurb_printed = 1;
|
|
|
|
}
|
1993-04-22 23:32:33 +00:00
|
|
|
}
|
|
|
|
|
1993-03-13 00:32:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1997-01-31 16:37:07 +00:00
|
|
|
else if (start_pc & 1)
|
|
|
|
{
|
1997-02-04 02:09:33 +00:00
|
|
|
/* On MIPS16, any one of the following is likely to be the
|
|
|
|
start of a function:
|
|
|
|
entry
|
|
|
|
addiu sp,-n
|
|
|
|
daddiu sp,-n
|
|
|
|
extend -n followed by 'addiu sp,+n' or 'daddiu sp,+n' */
|
|
|
|
unsigned short inst = read_memory_integer (start_pc & ~1, 2);
|
|
|
|
if (((inst & 0xf81f) == 0xe809 && (inst & 0x700) != 0x700) /* entry */
|
|
|
|
|| (inst & 0xff80) == 0x6380 /* addiu sp,-n */
|
|
|
|
|| (inst & 0xff80) == 0xfb80 /* daddiu sp,-n */
|
|
|
|
|| ((inst & 0xf810) == 0xf010 && seen_adjsp)) /* extend -n */
|
|
|
|
break;
|
|
|
|
else if ((inst & 0xff00) == 0x6300 /* addiu sp */
|
|
|
|
|| (inst & 0xff00) == 0xfb00) /* daddiu sp */
|
|
|
|
seen_adjsp = 1;
|
|
|
|
else
|
|
|
|
seen_adjsp = 0;
|
1997-01-31 16:37:07 +00:00
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
else if (ABOUT_TO_RETURN(start_pc))
|
1997-01-31 16:37:07 +00:00
|
|
|
{
|
|
|
|
start_pc += 2 * MIPS_INSTLEN; /* skip return, and its delay slot */
|
1991-03-28 16:26:26 +00:00
|
|
|
break;
|
1997-01-31 16:37:07 +00:00
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* skip nops (usually 1) 0 - is this */
|
1996-11-11 21:02:55 +00:00
|
|
|
while (start_pc < pc && read_memory_integer (start_pc, MIPS_INSTLEN) == 0)
|
|
|
|
start_pc += MIPS_INSTLEN;
|
1991-03-28 16:26:26 +00:00
|
|
|
#endif
|
|
|
|
return start_pc;
|
|
|
|
}
|
|
|
|
|
1997-02-04 02:09:33 +00:00
|
|
|
/* Fetch the immediate value from the current instruction.
|
|
|
|
If the previous instruction was an EXTEND, use it to extend
|
|
|
|
the upper bits of the immediate value. This is a helper function
|
|
|
|
for mips16_heuristic_proc_desc. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
mips16_get_imm (prev_inst, inst, nbits, scale, is_signed)
|
|
|
|
unsigned short prev_inst; /* previous instruction */
|
|
|
|
unsigned short inst; /* current current instruction */
|
|
|
|
int nbits; /* number of bits in imm field */
|
|
|
|
int scale; /* scale factor to be applied to imm */
|
|
|
|
int is_signed; /* is the imm field signed? */
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
|
|
|
|
if ((prev_inst & 0xf800) == 0xf000) /* prev instruction was EXTEND? */
|
|
|
|
{
|
1997-02-04 17:18:56 +00:00
|
|
|
offset = ((prev_inst & 0x1f) << 11) | (prev_inst & 0x7e0);
|
1997-02-04 02:09:33 +00:00
|
|
|
if (offset & 0x8000) /* check for negative extend */
|
|
|
|
offset = 0 - (0x10000 - (offset & 0xffff));
|
|
|
|
return offset | (inst & 0x1f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int max_imm = 1 << nbits;
|
|
|
|
int mask = max_imm - 1;
|
|
|
|
int sign_bit = max_imm >> 1;
|
|
|
|
|
|
|
|
offset = inst & mask;
|
|
|
|
if (is_signed && (offset & sign_bit))
|
|
|
|
offset = 0 - (max_imm - offset);
|
|
|
|
return offset * scale;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Fill in values in temp_proc_desc based on the MIPS16 instruction
|
|
|
|
stream from start_pc to limit_pc. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
mips16_heuristic_proc_desc(start_pc, limit_pc, next_frame, sp)
|
1991-03-28 16:26:26 +00:00
|
|
|
CORE_ADDR start_pc, limit_pc;
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *next_frame;
|
1997-02-04 02:09:33 +00:00
|
|
|
CORE_ADDR sp;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1997-02-04 02:09:33 +00:00
|
|
|
CORE_ADDR cur_pc;
|
|
|
|
CORE_ADDR frame_addr = 0; /* Value of $r17, used as frame pointer */
|
|
|
|
unsigned short prev_inst = 0; /* saved copy of previous instruction */
|
|
|
|
unsigned inst = 0; /* current instruction */
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1997-02-04 02:09:33 +00:00
|
|
|
PROC_FRAME_OFFSET(&temp_proc_desc) = 0;
|
1993-07-10 01:35:53 +00:00
|
|
|
|
1997-02-04 02:09:33 +00:00
|
|
|
for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += MIPS16_INSTLEN)
|
|
|
|
{
|
|
|
|
char buf[MIPS16_INSTLEN];
|
|
|
|
int status, reg, offset;
|
|
|
|
|
|
|
|
/* Save the previous instruction. If it's an EXTEND, we'll extract
|
|
|
|
the immediate offset extension from it in mips16_get_imm. */
|
|
|
|
prev_inst = inst;
|
|
|
|
|
|
|
|
/* Fetch the instruction. */
|
|
|
|
status = read_memory_nobpt (cur_pc & ~1, buf, MIPS16_INSTLEN);
|
|
|
|
if (status) memory_error (status, cur_pc);
|
|
|
|
inst = (unsigned short) extract_unsigned_integer (buf, MIPS16_INSTLEN);
|
|
|
|
|
|
|
|
if ((inst & 0xff00) == 0x6300 /* addiu sp */
|
|
|
|
|| (inst & 0xff00) == 0xfb00) /* daddiu sp */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 8, 8, 1);
|
|
|
|
if (offset < 0) /* negative stack adjustment? */
|
|
|
|
PROC_FRAME_OFFSET(&temp_proc_desc) -= offset;
|
|
|
|
else
|
|
|
|
/* Exit loop if a positive stack adjustment is found, which
|
|
|
|
usually means that the stack cleanup code in the function
|
|
|
|
epilogue is reached. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if ((inst & 0xf800) == 0xd000) /* sw reg,n($sp) */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 8, 4, 0);
|
|
|
|
reg = mips16_to_32_reg[(inst & 0x700) >> 8];
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= (1 << reg);
|
|
|
|
temp_saved_regs.regs[reg] = sp + offset;
|
|
|
|
}
|
|
|
|
else if ((inst & 0xff00) == 0xf900) /* sd reg,n($sp) */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 5, 8, 0);
|
|
|
|
reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= (1 << reg);
|
|
|
|
temp_saved_regs.regs[reg] = sp + offset;
|
|
|
|
}
|
|
|
|
else if ((inst & 0xff00) == 0x6200) /* sw $ra,n($sp) */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 8, 4, 0);
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= (1 << 31);
|
|
|
|
temp_saved_regs.regs[31] = sp + offset;
|
1996-12-15 04:59:14 +00:00
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
else if ((inst & 0xff00) == 0xfa00) /* sd $ra,n($sp) */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 8, 8, 0);
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= (1 << 31);
|
|
|
|
temp_saved_regs.regs[31] = sp + offset;
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
else if (inst == 0x673d) /* move $s1, $sp */
|
|
|
|
{
|
|
|
|
frame_addr = read_next_frame_reg(next_frame, 30);
|
|
|
|
PROC_FRAME_REG (&temp_proc_desc) = 17;
|
1996-12-15 04:59:14 +00:00
|
|
|
}
|
1997-02-09 17:36:49 +00:00
|
|
|
else if ((inst & 0xff00) == 0x0100) /* addiu $s1,sp,n */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 8, 4, 0);
|
|
|
|
frame_addr = sp + offset;
|
|
|
|
PROC_FRAME_REG (&temp_proc_desc) = 17;
|
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
else if ((inst & 0xFF00) == 0xd900) /* sw reg,offset($s1) */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 5, 4, 0);
|
|
|
|
reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = frame_addr + offset;
|
|
|
|
}
|
|
|
|
else if ((inst & 0xFF00) == 0x7900) /* sd reg,offset($s1) */
|
|
|
|
{
|
|
|
|
offset = mips16_get_imm (prev_inst, inst, 5, 8, 0);
|
|
|
|
reg = mips16_to_32_reg[(inst & 0xe0) >> 5];
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = frame_addr + offset;
|
|
|
|
}
|
|
|
|
else if ((inst & 0xf81f) == 0xe809 && (inst & 0x700) != 0x700) /* entry */
|
|
|
|
{
|
|
|
|
int areg_count = (inst >> 8) & 7;
|
|
|
|
int sreg_count = (inst >> 6) & 3;
|
|
|
|
|
|
|
|
/* The entry instruction always subtracts 32 from the SP. */
|
|
|
|
PROC_FRAME_OFFSET(&temp_proc_desc) += 32;
|
|
|
|
|
|
|
|
/* Check if a0-a3 were saved in the caller's argument save area. */
|
|
|
|
for (reg = 4, offset = 32; reg < areg_count+4; reg++, offset += 4)
|
|
|
|
{
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = sp + offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the ra register was pushed on the stack. */
|
|
|
|
offset = 28;
|
|
|
|
if (inst & 0x20)
|
|
|
|
{
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << 31;
|
|
|
|
temp_saved_regs.regs[31] = sp + offset;
|
|
|
|
offset -= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the s0 and s1 registers were pushed on the stack. */
|
|
|
|
for (reg = 16; reg < sreg_count+16; reg++, offset -= 4)
|
|
|
|
{
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = sp + offset;
|
|
|
|
}
|
|
|
|
}
|
1997-02-04 17:18:56 +00:00
|
|
|
else if ((inst & 0xf800) == 0x1800) /* jal(x) */
|
|
|
|
cur_pc += MIPS16_INSTLEN; /* 32-bit instruction */
|
1997-02-04 02:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mips32_heuristic_proc_desc(start_pc, limit_pc, next_frame, sp)
|
|
|
|
CORE_ADDR start_pc, limit_pc;
|
|
|
|
struct frame_info *next_frame;
|
|
|
|
CORE_ADDR sp;
|
|
|
|
{
|
|
|
|
CORE_ADDR cur_pc;
|
|
|
|
CORE_ADDR frame_addr = 0; /* Value of $r30. Used by gcc for frame-pointer */
|
|
|
|
restart:
|
|
|
|
PROC_FRAME_OFFSET(&temp_proc_desc) = 0;
|
|
|
|
for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += MIPS_INSTLEN)
|
|
|
|
{
|
|
|
|
char buf[MIPS_INSTLEN];
|
|
|
|
unsigned long inst, high_word, low_word;
|
|
|
|
int status, reg;
|
|
|
|
|
|
|
|
/* Fetch the instruction. */
|
|
|
|
status = (unsigned long) read_memory_nobpt (cur_pc, buf, MIPS_INSTLEN);
|
|
|
|
if (status) memory_error (status, cur_pc);
|
|
|
|
inst = (unsigned long) extract_unsigned_integer (buf, MIPS_INSTLEN);
|
|
|
|
|
|
|
|
/* Save some code by pre-extracting some useful fields. */
|
|
|
|
high_word = (inst >> 16) & 0xffff;
|
|
|
|
low_word = inst & 0xffff;
|
|
|
|
reg = high_word & 0x1f;
|
|
|
|
|
|
|
|
if (high_word == 0x27bd /* addiu $sp,$sp,-i */
|
|
|
|
|| high_word == 0x23bd /* addi $sp,$sp,-i */
|
|
|
|
|| high_word == 0x67bd) /* daddiu $sp,$sp,-i */
|
|
|
|
{
|
|
|
|
if (low_word & 0x8000) /* negative stack adjustment? */
|
|
|
|
PROC_FRAME_OFFSET(&temp_proc_desc) += 0x10000 - low_word;
|
|
|
|
else
|
|
|
|
/* Exit loop if a positive stack adjustment is found, which
|
|
|
|
usually means that the stack cleanup code in the function
|
|
|
|
epilogue is reached. */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if ((high_word & 0xFFE0) == 0xafa0) /* sw reg,offset($sp) */
|
|
|
|
{
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = sp + low_word;
|
|
|
|
}
|
|
|
|
else if ((high_word & 0xFFE0) == 0xffa0) /* sd reg,offset($sp) */
|
|
|
|
{
|
|
|
|
/* Irix 6.2 N32 ABI uses sd instructions for saving $gp and $ra,
|
|
|
|
but the register size used is only 32 bits. Make the address
|
|
|
|
for the saved register point to the lower 32 bits. */
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = sp + low_word + 8 - MIPS_REGSIZE;
|
|
|
|
}
|
|
|
|
else if (high_word == 0x27be) /* addiu $30,$sp,size */
|
|
|
|
{
|
|
|
|
/* Old gcc frame, r30 is virtual frame pointer. */
|
1997-02-09 17:36:49 +00:00
|
|
|
if ((long)low_word != PROC_FRAME_OFFSET(&temp_proc_desc))
|
1997-02-04 02:09:33 +00:00
|
|
|
frame_addr = sp + low_word;
|
|
|
|
else if (PROC_FRAME_REG (&temp_proc_desc) == SP_REGNUM)
|
|
|
|
{
|
|
|
|
unsigned alloca_adjust;
|
|
|
|
PROC_FRAME_REG (&temp_proc_desc) = 30;
|
|
|
|
frame_addr = read_next_frame_reg(next_frame, 30);
|
|
|
|
alloca_adjust = (unsigned)(frame_addr - (sp + low_word));
|
|
|
|
if (alloca_adjust > 0)
|
|
|
|
{
|
|
|
|
/* FP > SP + frame_size. This may be because
|
|
|
|
* of an alloca or somethings similar.
|
|
|
|
* Fix sp to "pre-alloca" value, and try again.
|
|
|
|
*/
|
|
|
|
sp += alloca_adjust;
|
|
|
|
goto restart;
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
/* move $30,$sp. With different versions of gas this will be either
|
|
|
|
`addu $30,$sp,$zero' or `or $30,$sp,$zero' or `daddu 30,sp,$0'.
|
|
|
|
Accept any one of these. */
|
|
|
|
else if (inst == 0x03A0F021 || inst == 0x03a0f025 || inst == 0x03a0f02d)
|
|
|
|
{
|
|
|
|
/* New gcc frame, virtual frame pointer is at r30 + frame_size. */
|
|
|
|
if (PROC_FRAME_REG (&temp_proc_desc) == SP_REGNUM)
|
|
|
|
{
|
|
|
|
unsigned alloca_adjust;
|
|
|
|
PROC_FRAME_REG (&temp_proc_desc) = 30;
|
|
|
|
frame_addr = read_next_frame_reg(next_frame, 30);
|
|
|
|
alloca_adjust = (unsigned)(frame_addr - sp);
|
|
|
|
if (alloca_adjust > 0)
|
|
|
|
{
|
|
|
|
/* FP > SP + frame_size. This may be because
|
|
|
|
* of an alloca or somethings similar.
|
|
|
|
* Fix sp to "pre-alloca" value, and try again.
|
|
|
|
*/
|
|
|
|
sp += alloca_adjust;
|
|
|
|
goto restart;
|
1996-12-15 04:59:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
else if ((high_word & 0xFFE0) == 0xafc0) /* sw reg,offset($30) */
|
|
|
|
{
|
|
|
|
PROC_REG_MASK(&temp_proc_desc) |= 1 << reg;
|
|
|
|
temp_saved_regs.regs[reg] = frame_addr + low_word;
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static mips_extra_func_info_t
|
|
|
|
heuristic_proc_desc(start_pc, limit_pc, next_frame)
|
|
|
|
CORE_ADDR start_pc, limit_pc;
|
|
|
|
struct frame_info *next_frame;
|
|
|
|
{
|
|
|
|
CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM);
|
|
|
|
|
|
|
|
if (start_pc == 0) return NULL;
|
|
|
|
memset (&temp_proc_desc, '\0', sizeof(temp_proc_desc));
|
|
|
|
memset (&temp_saved_regs, '\0', sizeof(struct frame_saved_regs));
|
|
|
|
PROC_LOW_ADDR (&temp_proc_desc) = start_pc;
|
|
|
|
PROC_FRAME_REG (&temp_proc_desc) = SP_REGNUM;
|
|
|
|
PROC_PC_REG (&temp_proc_desc) = RA_REGNUM;
|
|
|
|
|
|
|
|
if (start_pc + 200 < limit_pc)
|
|
|
|
limit_pc = start_pc + 200;
|
|
|
|
if (start_pc & 1)
|
|
|
|
mips16_heuristic_proc_desc (start_pc, limit_pc, next_frame, sp);
|
|
|
|
else
|
|
|
|
mips32_heuristic_proc_desc (start_pc, limit_pc, next_frame, sp);
|
|
|
|
return &temp_proc_desc;
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
static mips_extra_func_info_t
|
1994-11-18 02:18:09 +00:00
|
|
|
find_proc_desc (pc, next_frame)
|
|
|
|
CORE_ADDR pc;
|
|
|
|
struct frame_info *next_frame;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
|
|
|
mips_extra_func_info_t proc_desc;
|
1992-06-30 08:53:28 +00:00
|
|
|
struct block *b = block_for_pc(pc);
|
1993-08-17 22:37:25 +00:00
|
|
|
struct symbol *sym;
|
|
|
|
CORE_ADDR startaddr;
|
|
|
|
|
|
|
|
find_pc_partial_function (pc, NULL, &startaddr, NULL);
|
1996-12-15 04:59:14 +00:00
|
|
|
if (b == NULL || PC_IN_CALL_DUMMY (pc, 0, 0))
|
1993-08-17 22:37:25 +00:00
|
|
|
sym = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (startaddr > BLOCK_START (b))
|
|
|
|
/* This is the "pathological" case referred to in a comment in
|
|
|
|
print_frame_info. It might be better to move this check into
|
|
|
|
symbol reading. */
|
|
|
|
sym = NULL;
|
|
|
|
else
|
|
|
|
sym = lookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE,
|
|
|
|
0, NULL);
|
|
|
|
}
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
/* If we never found a PDR for this function in symbol reading, then
|
|
|
|
examine prologues to find the information. */
|
|
|
|
if (sym && ((mips_extra_func_info_t) SYMBOL_VALUE (sym))->pdr.framereg == -1)
|
|
|
|
sym = NULL;
|
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
if (sym)
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
|
|
|
/* IF this is the topmost frame AND
|
|
|
|
* (this proc does not have debugging information OR
|
|
|
|
* the PC is in the procedure prologue)
|
1992-03-29 23:26:47 +00:00
|
|
|
* THEN create a "heuristic" proc_desc (by analyzing
|
1991-03-28 16:26:26 +00:00
|
|
|
* the actual code) to replace the "official" proc_desc.
|
|
|
|
*/
|
1994-11-18 02:18:09 +00:00
|
|
|
proc_desc = (mips_extra_func_info_t) SYMBOL_VALUE (sym);
|
1991-03-28 16:26:26 +00:00
|
|
|
if (next_frame == NULL) {
|
|
|
|
struct symtab_and_line val;
|
|
|
|
struct symbol *proc_symbol =
|
|
|
|
PROC_DESC_IS_DUMMY(proc_desc) ? 0 : PROC_SYMBOL(proc_desc);
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
if (proc_symbol) {
|
|
|
|
val = find_pc_line (BLOCK_START
|
|
|
|
(SYMBOL_BLOCK_VALUE(proc_symbol)),
|
|
|
|
0);
|
|
|
|
val.pc = val.end ? val.end : pc;
|
|
|
|
}
|
|
|
|
if (!proc_symbol || pc < val.pc) {
|
|
|
|
mips_extra_func_info_t found_heuristic =
|
1994-11-18 02:18:09 +00:00
|
|
|
heuristic_proc_desc (PROC_LOW_ADDR (proc_desc),
|
|
|
|
pc, next_frame);
|
|
|
|
if (found_heuristic)
|
|
|
|
proc_desc = found_heuristic;
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1992-06-30 08:53:28 +00:00
|
|
|
/* Is linked_proc_desc_table really necessary? It only seems to be used
|
|
|
|
by procedure call dummys. However, the procedures being called ought
|
|
|
|
to have their own proc_descs, and even if they don't,
|
|
|
|
heuristic_proc_desc knows how to create them! */
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
register struct linked_proc_info *link;
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
for (link = linked_proc_desc_table; link; link = link->next)
|
1994-11-18 02:18:09 +00:00
|
|
|
if (PROC_LOW_ADDR(&link->info) <= pc
|
|
|
|
&& PROC_HIGH_ADDR(&link->info) > pc)
|
|
|
|
return &link->info;
|
1993-07-20 22:36:13 +00:00
|
|
|
|
1993-08-17 22:37:25 +00:00
|
|
|
if (startaddr == 0)
|
|
|
|
startaddr = heuristic_proc_start (pc);
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
proc_desc =
|
1993-08-17 22:37:25 +00:00
|
|
|
heuristic_proc_desc (startaddr, pc, next_frame);
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
return proc_desc;
|
|
|
|
}
|
|
|
|
|
1996-11-27 03:40:02 +00:00
|
|
|
static CORE_ADDR
|
|
|
|
get_frame_pointer(frame, proc_desc)
|
|
|
|
struct frame_info *frame;
|
|
|
|
mips_extra_func_info_t proc_desc;
|
|
|
|
{
|
|
|
|
return ADDR_BITS_REMOVE (read_next_frame_reg (frame,
|
|
|
|
PROC_FRAME_REG(proc_desc)) + PROC_FRAME_OFFSET(proc_desc));
|
|
|
|
}
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
mips_extra_func_info_t cached_proc_desc;
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
CORE_ADDR
|
1992-06-30 08:53:28 +00:00
|
|
|
mips_frame_chain(frame)
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *frame;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
|
|
|
mips_extra_func_info_t proc_desc;
|
|
|
|
CORE_ADDR saved_pc = FRAME_SAVED_PC(frame);
|
1992-03-29 23:26:47 +00:00
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
if (saved_pc == 0 || inside_entry_file (saved_pc))
|
|
|
|
return 0;
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
proc_desc = find_proc_desc(saved_pc, frame);
|
1992-06-30 08:53:28 +00:00
|
|
|
if (!proc_desc)
|
|
|
|
return 0;
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
cached_proc_desc = proc_desc;
|
1993-09-22 20:33:36 +00:00
|
|
|
|
|
|
|
/* If no frame pointer and frame size is zero, we must be at end
|
|
|
|
of stack (or otherwise hosed). If we don't check frame size,
|
|
|
|
we loop forever if we see a zero size frame. */
|
|
|
|
if (PROC_FRAME_REG (proc_desc) == SP_REGNUM
|
1993-09-23 19:03:38 +00:00
|
|
|
&& PROC_FRAME_OFFSET (proc_desc) == 0
|
1993-11-01 22:25:23 +00:00
|
|
|
/* The previous frame from a sigtramp frame might be frameless
|
|
|
|
and have frame size zero. */
|
|
|
|
&& !frame->signal_handler_caller)
|
1993-09-22 19:31:42 +00:00
|
|
|
return 0;
|
|
|
|
else
|
1996-11-27 03:40:02 +00:00
|
|
|
return get_frame_pointer (frame, proc_desc);
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
init_extra_frame_info(fci)
|
|
|
|
struct frame_info *fci;
|
|
|
|
{
|
1996-11-27 03:40:02 +00:00
|
|
|
int regnum;
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
/* Use proc_desc calculated in frame_chain */
|
1993-07-19 02:28:21 +00:00
|
|
|
mips_extra_func_info_t proc_desc =
|
|
|
|
fci->next ? cached_proc_desc : find_proc_desc(fci->pc, fci->next);
|
1992-06-30 08:53:28 +00:00
|
|
|
|
1994-02-18 01:38:08 +00:00
|
|
|
fci->saved_regs = NULL;
|
1991-03-28 16:26:26 +00:00
|
|
|
fci->proc_desc =
|
1993-07-19 02:28:21 +00:00
|
|
|
proc_desc == &temp_proc_desc ? 0 : proc_desc;
|
1991-03-28 16:26:26 +00:00
|
|
|
if (proc_desc)
|
|
|
|
{
|
1993-02-22 23:43:03 +00:00
|
|
|
/* Fixup frame-pointer - only needed for top frame */
|
1994-01-22 20:45:55 +00:00
|
|
|
/* This may not be quite right, if proc has a real frame register.
|
|
|
|
Get the value of the frame relative sp, procedure might have been
|
|
|
|
interrupted by a signal at it's very start. */
|
1994-02-18 01:38:08 +00:00
|
|
|
if (fci->pc == PROC_LOW_ADDR (proc_desc)
|
|
|
|
&& !PROC_DESC_IS_DUMMY (proc_desc))
|
|
|
|
fci->frame = read_next_frame_reg (fci->next, SP_REGNUM);
|
1993-02-22 23:43:03 +00:00
|
|
|
else
|
1996-11-27 03:40:02 +00:00
|
|
|
fci->frame = get_frame_pointer (fci->next, proc_desc);
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1993-08-17 22:37:25 +00:00
|
|
|
if (proc_desc == &temp_proc_desc)
|
1993-07-19 02:28:21 +00:00
|
|
|
{
|
1995-10-21 13:14:53 +00:00
|
|
|
char *name;
|
|
|
|
|
|
|
|
/* Do not set the saved registers for a sigtramp frame,
|
|
|
|
mips_find_saved_registers will do that for us.
|
|
|
|
We can't use fci->signal_handler_caller, it is not yet set. */
|
|
|
|
find_pc_partial_function (fci->pc, &name,
|
|
|
|
(CORE_ADDR *)NULL,(CORE_ADDR *)NULL);
|
|
|
|
if (!IN_SIGTRAMP (fci->pc, name))
|
|
|
|
{
|
|
|
|
fci->saved_regs = (struct frame_saved_regs*)
|
|
|
|
obstack_alloc (&frame_cache_obstack,
|
|
|
|
sizeof (struct frame_saved_regs));
|
|
|
|
*fci->saved_regs = temp_saved_regs;
|
|
|
|
fci->saved_regs->regs[PC_REGNUM]
|
|
|
|
= fci->saved_regs->regs[RA_REGNUM];
|
|
|
|
}
|
1993-07-19 02:28:21 +00:00
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
|
|
|
|
/* hack: if argument regs are saved, guess these contain args */
|
1996-11-27 03:40:02 +00:00
|
|
|
fci->num_args = -1; /* assume we can't tell how many args for now */
|
|
|
|
for (regnum = MIPS_LAST_ARG_REGNUM; regnum >= A0_REGNUM; regnum--)
|
|
|
|
{
|
|
|
|
if (PROC_REG_MASK(proc_desc) & (1 << regnum))
|
|
|
|
{
|
|
|
|
fci->num_args = regnum - A0_REGNUM + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Mips native support. Decstation and iris4 have been tested.
Iris3 has not.
* mips-tdep.c (supply_gregset, fill_gregset, supply_fpregset,
fill_fpregset): removed to irix4-nat.c
* mips-xdep.c: removed.
* irix4-nat.c, mips-nat.c, nm-irix3.h, nm-irix4.h, nm-mips.h: new
files.
* procfs.c: include nm.h.
* xm-irix3.h (U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS): removed.
* xm-irix4.h: bump copyright.
(U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS, USE_PROC_FS,
PROC_NAME_FMT): removed.
* xm-mips.h (FETCH_INFERIOR_REGISTERS): removed.
* config/irix4.mh (XDEPFILES): removed procfs.o fork-child.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
(CC): supply default compiler switches.
* config/irix3.mh (XDEPFILES): removed infptrace.o inftarg.o fork-child.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support. Note that
irix3 is untested.
* config/decstation.mh (XDEPFILES): removed infptrace.o inftarg.o
fork-child.o mips-xdep.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
1992-10-09 07:59:37 +00:00
|
|
|
/* MIPS stack frames are almost impenetrable. When execution stops,
|
|
|
|
we basically have to look at symbol information for the function
|
|
|
|
that we stopped in, which tells us *which* register (if any) is
|
|
|
|
the base of the frame pointer, and what offset from that register
|
|
|
|
the frame itself is at.
|
|
|
|
|
|
|
|
This presents a problem when trying to examine a stack in memory
|
|
|
|
(that isn't executing at the moment), using the "frame" command. We
|
|
|
|
don't have a PC, nor do we have any registers except SP.
|
|
|
|
|
|
|
|
This routine takes two arguments, SP and PC, and tries to make the
|
|
|
|
cached frames look as if these two arguments defined a frame on the
|
|
|
|
cache. This allows the rest of info frame to extract the important
|
|
|
|
arguments without difficulty. */
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *
|
1993-02-22 23:43:03 +00:00
|
|
|
setup_arbitrary_frame (argc, argv)
|
|
|
|
int argc;
|
1994-11-18 02:18:09 +00:00
|
|
|
CORE_ADDR *argv;
|
Mips native support. Decstation and iris4 have been tested.
Iris3 has not.
* mips-tdep.c (supply_gregset, fill_gregset, supply_fpregset,
fill_fpregset): removed to irix4-nat.c
* mips-xdep.c: removed.
* irix4-nat.c, mips-nat.c, nm-irix3.h, nm-irix4.h, nm-mips.h: new
files.
* procfs.c: include nm.h.
* xm-irix3.h (U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS): removed.
* xm-irix4.h: bump copyright.
(U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS, USE_PROC_FS,
PROC_NAME_FMT): removed.
* xm-mips.h (FETCH_INFERIOR_REGISTERS): removed.
* config/irix4.mh (XDEPFILES): removed procfs.o fork-child.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
(CC): supply default compiler switches.
* config/irix3.mh (XDEPFILES): removed infptrace.o inftarg.o fork-child.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support. Note that
irix3 is untested.
* config/decstation.mh (XDEPFILES): removed infptrace.o inftarg.o
fork-child.o mips-xdep.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
1992-10-09 07:59:37 +00:00
|
|
|
{
|
1993-02-22 23:43:03 +00:00
|
|
|
if (argc != 2)
|
|
|
|
error ("MIPS frame specifications require two arguments: sp and pc");
|
|
|
|
|
|
|
|
return create_new_frame (argv[0], argv[1]);
|
Mips native support. Decstation and iris4 have been tested.
Iris3 has not.
* mips-tdep.c (supply_gregset, fill_gregset, supply_fpregset,
fill_fpregset): removed to irix4-nat.c
* mips-xdep.c: removed.
* irix4-nat.c, mips-nat.c, nm-irix3.h, nm-irix4.h, nm-mips.h: new
files.
* procfs.c: include nm.h.
* xm-irix3.h (U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS): removed.
* xm-irix4.h: bump copyright.
(U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS, USE_PROC_FS,
PROC_NAME_FMT): removed.
* xm-mips.h (FETCH_INFERIOR_REGISTERS): removed.
* config/irix4.mh (XDEPFILES): removed procfs.o fork-child.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
(CC): supply default compiler switches.
* config/irix3.mh (XDEPFILES): removed infptrace.o inftarg.o fork-child.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support. Note that
irix3 is untested.
* config/decstation.mh (XDEPFILES): removed infptrace.o inftarg.o
fork-child.o mips-xdep.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
1992-10-09 07:59:37 +00:00
|
|
|
}
|
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
CORE_ADDR
|
|
|
|
mips_push_arguments(nargs, args, sp, struct_return, struct_addr)
|
1996-12-15 04:59:14 +00:00
|
|
|
int nargs;
|
|
|
|
value_ptr *args;
|
|
|
|
CORE_ADDR sp;
|
|
|
|
int struct_return;
|
|
|
|
CORE_ADDR struct_addr;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1996-12-15 04:59:14 +00:00
|
|
|
int argreg;
|
|
|
|
int float_argreg;
|
|
|
|
int argnum;
|
|
|
|
int len = 0;
|
|
|
|
int stack_offset;
|
|
|
|
|
|
|
|
/* Macros to round N up or down to the next A boundary; A must be
|
|
|
|
a power of two. */
|
|
|
|
#define ROUND_DOWN(n,a) ((n) & ~((a)-1))
|
|
|
|
#define ROUND_UP(n,a) (((n)+(a)-1) & ~((a)-1))
|
1996-11-11 21:02:55 +00:00
|
|
|
|
|
|
|
/* First ensure that the stack and structure return address (if any)
|
1996-12-15 04:59:14 +00:00
|
|
|
are properly aligned. The stack has to be 64-bit aligned even
|
|
|
|
on 32-bit machines, because doubles must be 64-bit aligned. */
|
|
|
|
sp = ROUND_DOWN (sp, 8);
|
|
|
|
struct_addr = ROUND_DOWN (struct_addr, MIPS_REGSIZE);
|
1996-11-11 21:02:55 +00:00
|
|
|
|
1996-12-15 04:59:14 +00:00
|
|
|
/* Now make space on the stack for the args. We allocate more
|
|
|
|
than necessary for EABI, because the first few arguments are
|
|
|
|
passed in registers, but that's OK. */
|
|
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
|
|
|
len += ROUND_UP (TYPE_LENGTH(VALUE_TYPE(args[argnum])), MIPS_REGSIZE);
|
1996-12-21 21:01:01 +00:00
|
|
|
sp -= ROUND_UP (len, 8);
|
1996-12-15 04:59:14 +00:00
|
|
|
|
|
|
|
/* Initialize the integer and float register pointers. */
|
|
|
|
argreg = A0_REGNUM;
|
|
|
|
float_argreg = FPA0_REGNUM;
|
|
|
|
|
|
|
|
/* the struct_return pointer occupies the first parameter-passing reg */
|
1994-01-22 20:45:55 +00:00
|
|
|
if (struct_return)
|
1996-12-15 04:59:14 +00:00
|
|
|
write_register (argreg++, struct_addr);
|
|
|
|
|
|
|
|
/* The offset onto the stack at which we will start copying parameters
|
|
|
|
(after the registers are used up) begins at 16 in the old ABI.
|
|
|
|
This leaves room for the "home" area for register parameters. */
|
|
|
|
stack_offset = MIPS_EABI ? 0 : MIPS_REGSIZE * 4;
|
|
|
|
|
|
|
|
/* Now load as many as possible of the first arguments into
|
|
|
|
registers, and push the rest onto the stack. Loop thru args
|
|
|
|
from first to last. */
|
|
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
1994-01-22 20:45:55 +00:00
|
|
|
{
|
1996-12-15 04:59:14 +00:00
|
|
|
char *val;
|
|
|
|
char valbuf[REGISTER_RAW_SIZE(A0_REGNUM)];
|
|
|
|
value_ptr arg = args[argnum];
|
|
|
|
struct type *arg_type = check_typedef (VALUE_TYPE (arg));
|
|
|
|
int len = TYPE_LENGTH (arg_type);
|
|
|
|
enum type_code typecode = TYPE_CODE (arg_type);
|
|
|
|
|
1996-12-21 21:01:01 +00:00
|
|
|
/* The EABI passes structures that do not fit in a register by
|
|
|
|
reference. In all other cases, pass the structure by value. */
|
|
|
|
if (typecode == TYPE_CODE_STRUCT && MIPS_EABI && len > MIPS_REGSIZE)
|
1996-12-15 04:59:14 +00:00
|
|
|
{
|
|
|
|
store_address (valbuf, MIPS_REGSIZE, VALUE_ADDRESS (arg));
|
|
|
|
len = MIPS_REGSIZE;
|
|
|
|
val = valbuf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val = (char *)VALUE_CONTENTS (arg);
|
|
|
|
|
|
|
|
/* 32-bit ABIs always start floating point arguments in an
|
|
|
|
even-numbered floating point register. */
|
|
|
|
if (!GDB_TARGET_IS_MIPS64 && typecode == TYPE_CODE_FLT
|
|
|
|
&& (float_argreg & 1))
|
|
|
|
float_argreg++;
|
|
|
|
|
|
|
|
/* Floating point arguments passed in registers have to be
|
|
|
|
treated specially. On 32-bit architectures, doubles
|
|
|
|
are passed in register pairs; the even register gets
|
|
|
|
the low word, and the odd register gets the high word. */
|
|
|
|
if (typecode == TYPE_CODE_FLT
|
|
|
|
&& float_argreg <= MIPS_LAST_FP_ARG_REGNUM
|
|
|
|
&& mips_fpu != MIPS_FPU_NONE)
|
|
|
|
{
|
|
|
|
if (!GDB_TARGET_IS_MIPS64 && len == 8)
|
|
|
|
{
|
|
|
|
int low_offset = TARGET_BYTE_ORDER == BIG_ENDIAN ? 4 : 0;
|
|
|
|
unsigned long regval;
|
|
|
|
|
|
|
|
regval = extract_unsigned_integer (val+low_offset, 4);
|
|
|
|
write_register (float_argreg++, regval); /* low word */
|
|
|
|
regval = extract_unsigned_integer (val+4-low_offset, 4);
|
|
|
|
write_register (float_argreg++, regval); /* high word */
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CORE_ADDR regval = extract_address (val, len);
|
|
|
|
write_register (float_argreg++, regval);
|
|
|
|
}
|
1994-01-22 20:45:55 +00:00
|
|
|
|
1996-12-15 04:59:14 +00:00
|
|
|
/* If this is the old ABI, skip one or two general registers. */
|
|
|
|
if (!MIPS_EABI)
|
|
|
|
argreg += GDB_TARGET_IS_MIPS64 ? 1 : 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Copy the argument to general registers or the stack in
|
|
|
|
register-sized pieces. Large arguments are split between
|
|
|
|
registers and stack. */
|
|
|
|
while (len > 0)
|
|
|
|
{
|
|
|
|
int partial_len = len < MIPS_REGSIZE ? len : MIPS_REGSIZE;
|
1996-12-21 21:01:01 +00:00
|
|
|
|
1996-12-15 04:59:14 +00:00
|
|
|
if (argreg <= MIPS_LAST_ARG_REGNUM)
|
|
|
|
{
|
1996-12-21 21:01:01 +00:00
|
|
|
CORE_ADDR regval = extract_address (val, partial_len);
|
|
|
|
|
|
|
|
/* It's a simple argument being passed in a general
|
|
|
|
register.
|
|
|
|
If the argument length is smaller than the register size,
|
1997-02-04 02:09:33 +00:00
|
|
|
we have to adjust the argument on big endian targets.
|
|
|
|
But don't do this adjustment on EABI targets. */
|
1996-12-21 21:01:01 +00:00
|
|
|
if (TARGET_BYTE_ORDER == BIG_ENDIAN
|
1997-02-04 02:09:33 +00:00
|
|
|
&& partial_len < MIPS_REGSIZE
|
|
|
|
&& !MIPS_EABI)
|
1996-12-21 21:01:01 +00:00
|
|
|
regval <<= ((MIPS_REGSIZE - partial_len) * TARGET_CHAR_BIT);
|
1996-12-15 04:59:14 +00:00
|
|
|
write_register (argreg, regval);
|
|
|
|
argreg++;
|
|
|
|
|
|
|
|
/* If this is the old ABI, prevent subsequent floating
|
|
|
|
point arguments from being passed in floating point
|
|
|
|
registers. */
|
|
|
|
if (!MIPS_EABI)
|
|
|
|
float_argreg = MIPS_LAST_FP_ARG_REGNUM + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1996-12-21 21:01:01 +00:00
|
|
|
/* Write this portion of the argument to the stack. */
|
|
|
|
partial_len = len;
|
|
|
|
write_memory (sp + stack_offset, val, partial_len);
|
|
|
|
stack_offset += ROUND_UP (partial_len, MIPS_REGSIZE);
|
1996-12-15 04:59:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
len -= partial_len;
|
|
|
|
val += partial_len;
|
|
|
|
}
|
|
|
|
}
|
1994-01-22 20:45:55 +00:00
|
|
|
}
|
1996-12-15 04:59:14 +00:00
|
|
|
|
|
|
|
/* Set the return address register to point to the entry
|
|
|
|
point of the program, where a breakpoint lies in wait. */
|
|
|
|
write_register (RA_REGNUM, CALL_DUMMY_ADDRESS());
|
|
|
|
|
|
|
|
/* Return adjusted stack pointer. */
|
1991-03-28 16:26:26 +00:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
void
|
|
|
|
mips_push_register(CORE_ADDR *sp, int regno)
|
|
|
|
{
|
|
|
|
char buffer[MAX_REGISTER_RAW_SIZE];
|
|
|
|
int regsize = REGISTER_RAW_SIZE (regno);
|
|
|
|
|
|
|
|
*sp -= regsize;
|
|
|
|
read_register_gen (regno, buffer);
|
|
|
|
write_memory (*sp, buffer, regsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MASK(i,j) == (1<<i) + (1<<(i+1)) + ... + (1<<j)). Assume i<=j<(MIPS_NUMREGS-1). */
|
1993-12-06 17:31:05 +00:00
|
|
|
#define MASK(i,j) (((1 << ((j)+1))-1) ^ ((1 << (i))-1))
|
1991-03-28 16:26:26 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
mips_push_dummy_frame()
|
|
|
|
{
|
|
|
|
int ireg;
|
|
|
|
struct linked_proc_info *link = (struct linked_proc_info*)
|
|
|
|
xmalloc(sizeof(struct linked_proc_info));
|
|
|
|
mips_extra_func_info_t proc_desc = &link->info;
|
1996-11-27 03:40:02 +00:00
|
|
|
CORE_ADDR sp = ADDR_BITS_REMOVE (read_register (SP_REGNUM));
|
1996-11-11 21:02:55 +00:00
|
|
|
CORE_ADDR old_sp = sp;
|
1991-03-28 16:26:26 +00:00
|
|
|
link->next = linked_proc_desc_table;
|
|
|
|
linked_proc_desc_table = link;
|
1996-11-11 21:02:55 +00:00
|
|
|
|
|
|
|
/* FIXME! are these correct ? */
|
1991-03-28 16:26:26 +00:00
|
|
|
#define PUSH_FP_REGNUM 16 /* must be a register preserved across calls */
|
1996-11-11 21:02:55 +00:00
|
|
|
#define GEN_REG_SAVE_MASK MASK(1,16)|MASK(24,28)|(1<<(MIPS_NUMREGS-1))
|
1991-03-28 16:26:26 +00:00
|
|
|
#define FLOAT_REG_SAVE_MASK MASK(0,19)
|
1995-07-29 08:50:00 +00:00
|
|
|
#define FLOAT_SINGLE_REG_SAVE_MASK \
|
|
|
|
((1<<18)|(1<<16)|(1<<14)|(1<<12)|(1<<10)|(1<<8)|(1<<6)|(1<<4)|(1<<2)|(1<<0))
|
1991-03-28 16:26:26 +00:00
|
|
|
/*
|
|
|
|
* The registers we must save are all those not preserved across
|
|
|
|
* procedure calls. Dest_Reg (see tm-mips.h) must also be saved.
|
1996-11-11 21:02:55 +00:00
|
|
|
* In addition, we must save the PC, PUSH_FP_REGNUM, MMLO/-HI
|
|
|
|
* and FP Control/Status registers.
|
|
|
|
*
|
1991-03-28 16:26:26 +00:00
|
|
|
*
|
|
|
|
* Dummy frame layout:
|
|
|
|
* (high memory)
|
|
|
|
* Saved PC
|
|
|
|
* Saved MMHI, MMLO, FPC_CSR
|
|
|
|
* Saved R31
|
|
|
|
* Saved R28
|
|
|
|
* ...
|
|
|
|
* Saved R1
|
|
|
|
* Saved D18 (i.e. F19, F18)
|
|
|
|
* ...
|
|
|
|
* Saved D0 (i.e. F1, F0)
|
1997-01-28 00:50:13 +00:00
|
|
|
* Argument build area and stack arguments written via mips_push_arguments
|
1991-03-28 16:26:26 +00:00
|
|
|
* (low memory)
|
|
|
|
*/
|
1996-11-11 21:02:55 +00:00
|
|
|
|
|
|
|
/* Save special registers (PC, MMHI, MMLO, FPC_CSR) */
|
|
|
|
PROC_FRAME_REG(proc_desc) = PUSH_FP_REGNUM;
|
|
|
|
PROC_FRAME_OFFSET(proc_desc) = 0;
|
|
|
|
mips_push_register (&sp, PC_REGNUM);
|
|
|
|
mips_push_register (&sp, HI_REGNUM);
|
|
|
|
mips_push_register (&sp, LO_REGNUM);
|
|
|
|
mips_push_register (&sp, mips_fpu == MIPS_FPU_NONE ? 0 : FCRCS_REGNUM);
|
|
|
|
|
|
|
|
/* Save general CPU registers */
|
1991-03-28 16:26:26 +00:00
|
|
|
PROC_REG_MASK(proc_desc) = GEN_REG_SAVE_MASK;
|
1996-11-11 21:02:55 +00:00
|
|
|
PROC_REG_OFFSET(proc_desc) = sp - old_sp; /* offset of (Saved R31) from FP */
|
1991-03-28 16:26:26 +00:00
|
|
|
for (ireg = 32; --ireg >= 0; )
|
|
|
|
if (PROC_REG_MASK(proc_desc) & (1 << ireg))
|
1996-11-11 21:02:55 +00:00
|
|
|
mips_push_register (&sp, ireg);
|
1994-02-25 04:23:19 +00:00
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
/* Save floating point registers starting with high order word */
|
|
|
|
PROC_FREG_MASK(proc_desc) =
|
|
|
|
mips_fpu == MIPS_FPU_DOUBLE ? FLOAT_REG_SAVE_MASK
|
|
|
|
: mips_fpu == MIPS_FPU_SINGLE ? FLOAT_SINGLE_REG_SAVE_MASK : 0;
|
|
|
|
PROC_FREG_OFFSET(proc_desc) = sp - old_sp; /* offset of (Saved D18) from FP */
|
1991-03-28 16:26:26 +00:00
|
|
|
for (ireg = 32; --ireg >= 0; )
|
|
|
|
if (PROC_FREG_MASK(proc_desc) & (1 << ireg))
|
1996-11-11 21:02:55 +00:00
|
|
|
mips_push_register (&sp, ireg + FP0_REGNUM);
|
1994-02-25 04:23:19 +00:00
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
/* Update the frame pointer for the call dummy and the stack pointer.
|
|
|
|
Set the procedure's starting and ending addresses to point to the
|
|
|
|
call dummy address at the entry point. */
|
|
|
|
write_register (PUSH_FP_REGNUM, old_sp);
|
1991-03-28 16:26:26 +00:00
|
|
|
write_register (SP_REGNUM, sp);
|
1996-12-15 04:59:14 +00:00
|
|
|
PROC_LOW_ADDR(proc_desc) = CALL_DUMMY_ADDRESS();
|
|
|
|
PROC_HIGH_ADDR(proc_desc) = CALL_DUMMY_ADDRESS() + 4;
|
1991-03-28 16:26:26 +00:00
|
|
|
SET_PROC_DESC_IS_DUMMY(proc_desc);
|
|
|
|
PROC_PC_REG(proc_desc) = RA_REGNUM;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mips_pop_frame()
|
1992-10-15 08:36:30 +00:00
|
|
|
{
|
|
|
|
register int regnum;
|
1994-11-18 02:18:09 +00:00
|
|
|
struct frame_info *frame = get_current_frame ();
|
|
|
|
CORE_ADDR new_sp = FRAME_FP (frame);
|
1992-10-15 08:36:30 +00:00
|
|
|
|
Mips native support. Decstation and iris4 have been tested.
Iris3 has not.
* mips-tdep.c (supply_gregset, fill_gregset, supply_fpregset,
fill_fpregset): removed to irix4-nat.c
* mips-xdep.c: removed.
* irix4-nat.c, mips-nat.c, nm-irix3.h, nm-irix4.h, nm-mips.h: new
files.
* procfs.c: include nm.h.
* xm-irix3.h (U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS): removed.
* xm-irix4.h: bump copyright.
(U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS, USE_PROC_FS,
PROC_NAME_FMT): removed.
* xm-mips.h (FETCH_INFERIOR_REGISTERS): removed.
* config/irix4.mh (XDEPFILES): removed procfs.o fork-child.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
(CC): supply default compiler switches.
* config/irix3.mh (XDEPFILES): removed infptrace.o inftarg.o fork-child.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support. Note that
irix3 is untested.
* config/decstation.mh (XDEPFILES): removed infptrace.o inftarg.o
fork-child.o mips-xdep.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
1992-10-09 07:59:37 +00:00
|
|
|
mips_extra_func_info_t proc_desc = frame->proc_desc;
|
1992-10-15 08:36:30 +00:00
|
|
|
|
|
|
|
write_register (PC_REGNUM, FRAME_SAVED_PC(frame));
|
1994-02-18 01:38:08 +00:00
|
|
|
if (frame->saved_regs == NULL)
|
|
|
|
mips_find_saved_regs (frame);
|
1996-12-21 21:01:01 +00:00
|
|
|
for (regnum = 0; regnum < NUM_REGS; regnum++)
|
1992-10-15 08:36:30 +00:00
|
|
|
{
|
1996-12-21 21:01:01 +00:00
|
|
|
if (regnum != SP_REGNUM && regnum != PC_REGNUM
|
|
|
|
&& frame->saved_regs->regs[regnum])
|
|
|
|
write_register (regnum,
|
|
|
|
read_memory_integer (frame->saved_regs->regs[regnum],
|
|
|
|
MIPS_REGSIZE));
|
1992-10-15 08:36:30 +00:00
|
|
|
}
|
|
|
|
write_register (SP_REGNUM, new_sp);
|
|
|
|
flush_cached_frames ();
|
|
|
|
|
1993-11-01 22:25:23 +00:00
|
|
|
if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc))
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1992-10-15 08:36:30 +00:00
|
|
|
struct linked_proc_info *pi_ptr, *prev_ptr;
|
|
|
|
|
|
|
|
for (pi_ptr = linked_proc_desc_table, prev_ptr = NULL;
|
|
|
|
pi_ptr != NULL;
|
|
|
|
prev_ptr = pi_ptr, pi_ptr = pi_ptr->next)
|
|
|
|
{
|
|
|
|
if (&pi_ptr->info == proc_desc)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pi_ptr == NULL)
|
|
|
|
error ("Can't locate dummy extra frame info\n");
|
|
|
|
|
|
|
|
if (prev_ptr != NULL)
|
|
|
|
prev_ptr->next = pi_ptr->next;
|
|
|
|
else
|
|
|
|
linked_proc_desc_table = pi_ptr->next;
|
|
|
|
|
|
|
|
free (pi_ptr);
|
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
write_register (HI_REGNUM,
|
|
|
|
read_memory_integer (new_sp - 2*MIPS_REGSIZE, MIPS_REGSIZE));
|
|
|
|
write_register (LO_REGNUM,
|
|
|
|
read_memory_integer (new_sp - 3*MIPS_REGSIZE, MIPS_REGSIZE));
|
1995-07-29 08:50:00 +00:00
|
|
|
if (mips_fpu != MIPS_FPU_NONE)
|
1996-11-11 21:02:55 +00:00
|
|
|
write_register (FCRCS_REGNUM,
|
|
|
|
read_memory_integer (new_sp - 4*MIPS_REGSIZE, MIPS_REGSIZE));
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
static void
|
Mips native support. Decstation and iris4 have been tested.
Iris3 has not.
* mips-tdep.c (supply_gregset, fill_gregset, supply_fpregset,
fill_fpregset): removed to irix4-nat.c
* mips-xdep.c: removed.
* irix4-nat.c, mips-nat.c, nm-irix3.h, nm-irix4.h, nm-mips.h: new
files.
* procfs.c: include nm.h.
* xm-irix3.h (U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS): removed.
* xm-irix4.h: bump copyright.
(U_REGS_OFFSET, FETCH_INFERIOR_REGISTERS, USE_PROC_FS,
PROC_NAME_FMT): removed.
* xm-mips.h (FETCH_INFERIOR_REGISTERS): removed.
* config/irix4.mh (XDEPFILES): removed procfs.o fork-child.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
(CC): supply default compiler switches.
* config/irix3.mh (XDEPFILES): removed infptrace.o inftarg.o fork-child.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support. Note that
irix3 is untested.
* config/decstation.mh (XDEPFILES): removed infptrace.o inftarg.o
fork-child.o mips-xdep.o coredep.o.
(NAT_FILE, NATDEPFILES): new macros for native support.
1992-10-09 07:59:37 +00:00
|
|
|
mips_print_register (regnum, all)
|
1991-03-28 16:26:26 +00:00
|
|
|
int regnum, all;
|
|
|
|
{
|
1995-07-29 08:50:00 +00:00
|
|
|
char raw_buffer[MAX_REGISTER_RAW_SIZE];
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1993-08-17 22:37:25 +00:00
|
|
|
/* Get the data in raw format. */
|
|
|
|
if (read_relative_register_raw_bytes (regnum, raw_buffer))
|
|
|
|
{
|
|
|
|
printf_filtered ("%s: [Invalid]", reg_names[regnum]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If an even floating pointer register, also print as double. */
|
1996-11-11 21:02:55 +00:00
|
|
|
if (regnum >= FP0_REGNUM && regnum < FP0_REGNUM+MIPS_NUMREGS
|
1995-07-29 08:50:00 +00:00
|
|
|
&& !((regnum-FP0_REGNUM) & 1))
|
|
|
|
{
|
|
|
|
char dbuffer[MAX_REGISTER_RAW_SIZE];
|
1993-08-17 22:37:25 +00:00
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
read_relative_register_raw_bytes (regnum, dbuffer);
|
1996-11-11 21:02:55 +00:00
|
|
|
read_relative_register_raw_bytes (regnum+1, dbuffer+4); /* FIXME!! */
|
1993-05-22 07:26:25 +00:00
|
|
|
#ifdef REGISTER_CONVERT_TO_TYPE
|
1995-07-29 08:50:00 +00:00
|
|
|
REGISTER_CONVERT_TO_TYPE(regnum, builtin_type_double, dbuffer);
|
1993-05-22 07:26:25 +00:00
|
|
|
#endif
|
1995-07-29 08:50:00 +00:00
|
|
|
printf_filtered ("(d%d: ", regnum-FP0_REGNUM);
|
|
|
|
val_print (builtin_type_double, dbuffer, 0,
|
|
|
|
gdb_stdout, 0, 1, 0, Val_pretty_default);
|
|
|
|
printf_filtered ("); ");
|
|
|
|
}
|
1993-11-01 22:25:23 +00:00
|
|
|
fputs_filtered (reg_names[regnum], gdb_stdout);
|
1993-08-17 22:37:25 +00:00
|
|
|
|
|
|
|
/* The problem with printing numeric register names (r26, etc.) is that
|
|
|
|
the user can't use them on input. Probably the best solution is to
|
|
|
|
fix it so that either the numeric or the funky (a2, etc.) names
|
|
|
|
are accepted on input. */
|
1996-11-11 21:02:55 +00:00
|
|
|
if (regnum < MIPS_NUMREGS)
|
1993-08-17 22:37:25 +00:00
|
|
|
printf_filtered ("(r%d): ", regnum);
|
|
|
|
else
|
|
|
|
printf_filtered (": ");
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1993-08-17 22:37:25 +00:00
|
|
|
/* If virtual format is floating, print it that way. */
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
if (TYPE_CODE (REGISTER_VIRTUAL_TYPE (regnum)) == TYPE_CODE_FLT)
|
1993-08-17 22:37:25 +00:00
|
|
|
val_print (REGISTER_VIRTUAL_TYPE (regnum), raw_buffer, 0,
|
1993-11-01 22:25:23 +00:00
|
|
|
gdb_stdout, 0, 1, 0, Val_pretty_default);
|
1993-08-17 22:37:25 +00:00
|
|
|
/* Else print as integer in hex. */
|
|
|
|
else
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
print_scalar_formatted (raw_buffer, REGISTER_VIRTUAL_TYPE (regnum),
|
|
|
|
'x', 0, gdb_stdout);
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
|
|
|
|
1991-09-19 07:39:54 +00:00
|
|
|
/* Replacement for generic do_registers_info. */
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
void
|
1991-08-19 20:54:03 +00:00
|
|
|
mips_do_registers_info (regnum, fpregs)
|
1991-03-28 16:26:26 +00:00
|
|
|
int regnum;
|
1991-08-19 20:54:03 +00:00
|
|
|
int fpregs;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1994-11-18 02:18:09 +00:00
|
|
|
if (regnum != -1)
|
|
|
|
{
|
|
|
|
if (*(reg_names[regnum]) == '\0')
|
|
|
|
error ("Not a valid register for the current processor type");
|
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
mips_print_register (regnum, 0);
|
|
|
|
printf_filtered ("\n");
|
1994-11-18 02:18:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1995-10-21 13:14:53 +00:00
|
|
|
int did_newline = 0;
|
1994-11-18 02:18:09 +00:00
|
|
|
|
|
|
|
for (regnum = 0; regnum < NUM_REGS; )
|
|
|
|
{
|
|
|
|
if (((!fpregs) && regnum >= FP0_REGNUM && regnum <= FCRIR_REGNUM)
|
|
|
|
|| *(reg_names[regnum]) == '\0')
|
|
|
|
{
|
|
|
|
regnum++;
|
|
|
|
continue;
|
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
mips_print_register (regnum, 1);
|
|
|
|
regnum++;
|
1994-11-18 02:18:09 +00:00
|
|
|
printf_filtered ("; ");
|
|
|
|
did_newline = 0;
|
|
|
|
if ((regnum & 3) == 0)
|
|
|
|
{
|
|
|
|
printf_filtered ("\n");
|
|
|
|
did_newline = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!did_newline)
|
|
|
|
printf_filtered ("\n");
|
|
|
|
}
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
/* Return number of args passed to a frame. described by FIP.
|
|
|
|
Can return -1, meaning no way to tell. */
|
|
|
|
|
1992-06-30 08:53:28 +00:00
|
|
|
int
|
1994-11-18 02:18:09 +00:00
|
|
|
mips_frame_num_args (frame)
|
|
|
|
struct frame_info *frame;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1994-11-18 02:18:09 +00:00
|
|
|
#if 0 /* FIXME Use or lose this! */
|
|
|
|
struct chain_info_t *p;
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
p = mips_find_cached_frame (FRAME_FP (frame));
|
|
|
|
if (p->valid)
|
|
|
|
return p->the_info.numargs;
|
1991-03-28 16:26:26 +00:00
|
|
|
#endif
|
1994-11-18 02:18:09 +00:00
|
|
|
return -1;
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
1996-11-27 03:40:02 +00:00
|
|
|
|
1993-08-27 19:33:43 +00:00
|
|
|
/* Is this a branch with a delay slot? */
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1994-03-01 00:15:07 +00:00
|
|
|
static int is_delayed PARAMS ((unsigned long));
|
|
|
|
|
1993-07-19 02:28:21 +00:00
|
|
|
static int
|
|
|
|
is_delayed (insn)
|
|
|
|
unsigned long insn;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < NUMOPCODES; ++i)
|
|
|
|
if (mips_opcodes[i].pinfo != INSN_MACRO
|
|
|
|
&& (insn & mips_opcodes[i].mask) == mips_opcodes[i].match)
|
|
|
|
break;
|
1993-08-27 19:33:43 +00:00
|
|
|
return (i < NUMOPCODES
|
|
|
|
&& (mips_opcodes[i].pinfo & (INSN_UNCOND_BRANCH_DELAY
|
|
|
|
| INSN_COND_BRANCH_DELAY
|
|
|
|
| INSN_COND_BRANCH_LIKELY)));
|
1993-07-19 02:28:21 +00:00
|
|
|
}
|
1994-03-01 00:15:07 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
mips_step_skips_delay (pc)
|
|
|
|
CORE_ADDR pc;
|
|
|
|
{
|
1996-11-27 03:40:02 +00:00
|
|
|
char buf[MIPS_INSTLEN];
|
1994-03-01 00:15:07 +00:00
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
/* There is no branch delay slot on MIPS16. */
|
|
|
|
if (pc & 1)
|
|
|
|
return 0;
|
|
|
|
|
1996-11-27 03:40:02 +00:00
|
|
|
if (target_read_memory (pc, buf, MIPS_INSTLEN) != 0)
|
1994-03-01 00:15:07 +00:00
|
|
|
/* If error reading memory, guess that it is not a delayed branch. */
|
|
|
|
return 0;
|
1996-11-27 03:40:02 +00:00
|
|
|
return is_delayed ((unsigned long)extract_unsigned_integer (buf, MIPS_INSTLEN));
|
1994-03-01 00:15:07 +00:00
|
|
|
}
|
1993-07-19 02:28:21 +00:00
|
|
|
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1997-01-31 16:37:07 +00:00
|
|
|
/* Skip the PC past function prologue instructions (32-bit version).
|
|
|
|
This is a helper function for mips_skip_prologue. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
mips32_skip_prologue (pc, lenient)
|
|
|
|
CORE_ADDR pc; /* starting PC to search from */
|
1993-07-19 02:28:21 +00:00
|
|
|
int lenient;
|
1991-03-28 16:26:26 +00:00
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
t_inst inst;
|
1997-01-31 16:37:07 +00:00
|
|
|
CORE_ADDR end_pc;
|
1993-03-28 19:28:26 +00:00
|
|
|
int seen_sp_adjust = 0;
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
int load_immediate_bytes = 0;
|
1991-03-28 16:26:26 +00:00
|
|
|
|
1993-04-16 19:29:14 +00:00
|
|
|
/* Skip the typical prologue instructions. These are the stack adjustment
|
|
|
|
instruction and the instructions that save registers on the stack
|
|
|
|
or in the gcc frame. */
|
1997-01-31 16:37:07 +00:00
|
|
|
for (end_pc = pc + 100; pc < end_pc; pc += MIPS_INSTLEN)
|
1993-07-19 02:28:21 +00:00
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
char buf[MIPS_INSTLEN];
|
1993-07-19 02:28:21 +00:00
|
|
|
int status;
|
1997-02-04 02:09:33 +00:00
|
|
|
unsigned long high_word;
|
1993-07-19 02:28:21 +00:00
|
|
|
|
1997-01-31 16:37:07 +00:00
|
|
|
status = read_memory_nobpt (pc, buf, MIPS_INSTLEN);
|
1993-07-19 02:28:21 +00:00
|
|
|
if (status)
|
1997-01-31 16:37:07 +00:00
|
|
|
memory_error (status, pc);
|
1996-11-11 21:02:55 +00:00
|
|
|
inst = (unsigned long)extract_unsigned_integer (buf, MIPS_INSTLEN);
|
1997-02-04 02:09:33 +00:00
|
|
|
high_word = (inst >> 16) & 0xffff;
|
1993-07-19 02:28:21 +00:00
|
|
|
|
1993-11-12 16:35:59 +00:00
|
|
|
#if 0
|
1993-07-19 02:28:21 +00:00
|
|
|
if (lenient && is_delayed (inst))
|
|
|
|
continue;
|
1993-11-12 16:35:59 +00:00
|
|
|
#endif
|
1993-07-19 02:28:21 +00:00
|
|
|
|
1997-02-04 02:09:33 +00:00
|
|
|
if (high_word == 0x27bd /* addiu $sp,$sp,offset */
|
|
|
|
|| high_word == 0x67bd) /* daddiu $sp,$sp,offset */
|
1993-03-28 19:28:26 +00:00
|
|
|
seen_sp_adjust = 1;
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
else if (inst == 0x03a1e823 || /* subu $sp,$sp,$at */
|
|
|
|
inst == 0x03a8e823) /* subu $sp,$sp,$t0 */
|
|
|
|
seen_sp_adjust = 1;
|
1996-12-15 04:59:14 +00:00
|
|
|
else if (((inst & 0xFFE00000) == 0xAFA00000 /* sw reg,n($sp) */
|
|
|
|
|| (inst & 0xFFE00000) == 0xFFA00000) /* sd reg,n($sp) */
|
|
|
|
&& (inst & 0x001F0000)) /* reg != $zero */
|
|
|
|
continue;
|
|
|
|
|
1993-04-16 19:29:14 +00:00
|
|
|
else if ((inst & 0xFFE00000) == 0xE7A00000) /* swc1 freg,n($sp) */
|
|
|
|
continue;
|
|
|
|
else if ((inst & 0xF3E00000) == 0xA3C00000 && (inst & 0x001F0000))
|
|
|
|
/* sx reg,n($s8) */
|
|
|
|
continue; /* reg != $zero */
|
1995-01-10 21:24:34 +00:00
|
|
|
|
|
|
|
/* move $s8,$sp. With different versions of gas this will be either
|
1997-01-31 16:37:07 +00:00
|
|
|
`addu $s8,$sp,$zero' or `or $s8,$sp,$zero' or `daddu s8,sp,$0'.
|
|
|
|
Accept any one of these. */
|
|
|
|
else if (inst == 0x03A0F021 || inst == 0x03a0f025 || inst == 0x03a0f02d)
|
1993-03-28 19:28:26 +00:00
|
|
|
continue;
|
1995-01-10 21:24:34 +00:00
|
|
|
|
1993-05-25 06:52:54 +00:00
|
|
|
else if ((inst & 0xFF9F07FF) == 0x00800021) /* move reg,$a0-$a3 */
|
|
|
|
continue;
|
1997-02-04 02:09:33 +00:00
|
|
|
else if (high_word == 0x3c1c) /* lui $gp,n */
|
1993-12-06 17:31:05 +00:00
|
|
|
continue;
|
1997-02-04 02:09:33 +00:00
|
|
|
else if (high_word == 0x279c) /* addiu $gp,$gp,n */
|
1993-12-06 17:31:05 +00:00
|
|
|
continue;
|
|
|
|
else if (inst == 0x0399e021 /* addu $gp,$gp,$t9 */
|
|
|
|
|| inst == 0x033ce021) /* addu $gp,$t9,$gp */
|
|
|
|
continue;
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
/* The following instructions load $at or $t0 with an immediate
|
|
|
|
value in preparation for a stack adjustment via
|
|
|
|
subu $sp,$sp,[$at,$t0]. These instructions could also initialize
|
|
|
|
a local variable, so we accept them only before a stack adjustment
|
|
|
|
instruction was seen. */
|
|
|
|
else if (!seen_sp_adjust)
|
|
|
|
{
|
1997-02-04 02:09:33 +00:00
|
|
|
if (high_word == 0x3c01 || /* lui $at,n */
|
|
|
|
high_word == 0x3c08) /* lui $t0,n */
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
load_immediate_bytes += MIPS_INSTLEN; /* FIXME!! */
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
1997-02-04 02:09:33 +00:00
|
|
|
else if (high_word == 0x3421 || /* ori $at,$at,n */
|
|
|
|
high_word == 0x3508 || /* ori $t0,$t0,n */
|
|
|
|
high_word == 0x3401 || /* ori $at,$zero,n */
|
|
|
|
high_word == 0x3408) /* ori $t0,$zero,n */
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
load_immediate_bytes += MIPS_INSTLEN; /* FIXME!! */
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
1993-03-28 19:28:26 +00:00
|
|
|
else
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
break;
|
1992-03-03 23:26:26 +00:00
|
|
|
}
|
1993-04-16 19:29:14 +00:00
|
|
|
|
* infcmd.c (do_registers_info) [INVALID_FLOAT]: Only use if
defined.
* values.c (unpack_double) [INVALID_FLOAT]: Ditto.
* mips-tdep.c (mips_print_register): Don't test float validity.
* config/a29k/tm-a29k.h, config/alpha/tm-alpha.h,
config/arm/tm-arm.h, config/convex/tm-convex.h,
config/h8300/tm-h8300.h, config/h8500/tm-h8500.h,
config/i386/tm-i386v.h, config/i386/tm-sun386.h,
config/i960/tm-i960.h, config/m68k/tm-m68k.h,
config/m88k/tm-m88k.h, config/mips/tm-mips.h,
config/ns32k/tm-merlin.h, config/ns32k/tm-nbsd.h,
config/ns32k/tm-ns32km3.h, config/ns32k/tm-umax.h,
config/pa/tm-hppa.h, config/pyr/tm-pyr.h,
config/rs6000/tm-rs6000.h, config/sh/tm-sh.h,
config/sparc/tm-sparc.h, config/z8k/tm-z8k.h (INVALID_FLOAT):
Remove definition.
1994-09-25 21:13:24 +00:00
|
|
|
/* In a frameless function, we might have incorrectly
|
|
|
|
skipped some load immediate instructions. Undo the skipping
|
|
|
|
if the load immediate was not followed by a stack adjustment. */
|
|
|
|
if (load_immediate_bytes && !seen_sp_adjust)
|
1997-01-31 16:37:07 +00:00
|
|
|
pc -= load_immediate_bytes;
|
|
|
|
return pc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Skip the PC past function prologue instructions (16-bit version).
|
|
|
|
This is a helper function for mips_skip_prologue. */
|
|
|
|
|
|
|
|
static CORE_ADDR
|
|
|
|
mips16_skip_prologue (pc, lenient)
|
|
|
|
CORE_ADDR pc; /* starting PC to search from */
|
|
|
|
int lenient;
|
|
|
|
{
|
|
|
|
CORE_ADDR end_pc;
|
|
|
|
|
|
|
|
/* Table of instructions likely to be found in a function prologue. */
|
|
|
|
static struct
|
|
|
|
{
|
|
|
|
unsigned short inst;
|
|
|
|
unsigned short mask;
|
|
|
|
} table[] =
|
|
|
|
{
|
|
|
|
{ 0x6300, 0xff00 }, /* addiu $sp,offset */
|
|
|
|
{ 0xfb00, 0xff00 }, /* daddiu $sp,offset */
|
|
|
|
{ 0xd000, 0xf800 }, /* sw reg,n($sp) */
|
|
|
|
{ 0xf900, 0xff00 }, /* sd reg,n($sp) */
|
|
|
|
{ 0x6200, 0xff00 }, /* sw $ra,n($sp) */
|
|
|
|
{ 0xfa00, 0xff00 }, /* sd $ra,n($sp) */
|
|
|
|
{ 0x673d, 0xffff }, /* move $s1,sp */
|
|
|
|
{ 0xd980, 0xff80 }, /* sw $a0-$a3,n($s1) */
|
|
|
|
{ 0x6704, 0xff1c }, /* move reg,$a0-$a3 */
|
|
|
|
{ 0xe809, 0xf81f }, /* entry pseudo-op */
|
1997-02-09 17:36:49 +00:00
|
|
|
{ 0x0100, 0xff00 }, /* addiu $s1,$sp,n */
|
1997-01-31 16:37:07 +00:00
|
|
|
{ 0, 0 } /* end of table marker */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Skip the typical prologue instructions. These are the stack adjustment
|
|
|
|
instruction and the instructions that save registers on the stack
|
|
|
|
or in the gcc frame. */
|
|
|
|
for (end_pc = pc + 100; pc < end_pc; pc += MIPS16_INSTLEN)
|
|
|
|
{
|
|
|
|
char buf[MIPS16_INSTLEN];
|
|
|
|
int status;
|
|
|
|
unsigned short inst;
|
1997-02-09 17:36:49 +00:00
|
|
|
int extend_bytes = 0;
|
1997-01-31 16:37:07 +00:00
|
|
|
int prev_extend_bytes;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
status = read_memory_nobpt (pc & ~1, buf, MIPS16_INSTLEN);
|
|
|
|
if (status)
|
|
|
|
memory_error (status, pc);
|
|
|
|
inst = (unsigned long)extract_unsigned_integer (buf, MIPS16_INSTLEN);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (lenient && is_delayed (inst))
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Normally we ignore an extend instruction. However, if it is
|
|
|
|
not followed by a valid prologue instruction, we must adjust
|
|
|
|
the pc back over the extend so that it won't be considered
|
|
|
|
part of the prologue. */
|
|
|
|
if ((inst & 0xf800) == 0xf000) /* extend */
|
|
|
|
{
|
|
|
|
extend_bytes = MIPS16_INSTLEN;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
prev_extend_bytes = extend_bytes;
|
|
|
|
extend_bytes = 0;
|
|
|
|
|
|
|
|
/* Check for other valid prologue instructions besides extend. */
|
|
|
|
for (i = 0; table[i].mask != 0; i++)
|
|
|
|
if ((inst & table[i].mask) == table[i].inst) /* found, get out */
|
|
|
|
break;
|
|
|
|
if (table[i].mask != 0) /* it was in table? */
|
1997-02-09 17:36:49 +00:00
|
|
|
continue; /* ignore it */
|
1997-01-31 16:37:07 +00:00
|
|
|
else /* non-prologue */
|
|
|
|
{
|
|
|
|
/* Return the current pc, adjusted backwards by 2 if
|
|
|
|
the previous instruction was an extend. */
|
|
|
|
return pc - prev_extend_bytes;
|
|
|
|
}
|
|
|
|
}
|
1997-02-09 17:36:49 +00:00
|
|
|
return pc;
|
1997-01-31 16:37:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* To skip prologues, I use this predicate. Returns either PC itself
|
|
|
|
if the code at PC does not look like a function prologue; otherwise
|
|
|
|
returns an address that (if we're lucky) follows the prologue. If
|
|
|
|
LENIENT, then we must skip everything which is involved in setting
|
|
|
|
up the frame (it's OK to skip more, just so long as we don't skip
|
|
|
|
anything which might clobber the registers which are being saved.
|
|
|
|
We must skip more in the case where part of the prologue is in the
|
|
|
|
delay slot of a non-prologue instruction). */
|
|
|
|
|
|
|
|
CORE_ADDR
|
|
|
|
mips_skip_prologue (pc, lenient)
|
|
|
|
CORE_ADDR pc;
|
|
|
|
int lenient;
|
|
|
|
{
|
|
|
|
/* 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. */
|
|
|
|
|
|
|
|
CORE_ADDR 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. */
|
|
|
|
|
|
|
|
if (pc & 1)
|
|
|
|
return mips16_skip_prologue (pc, lenient);
|
|
|
|
else
|
|
|
|
return mips32_skip_prologue (pc, lenient);
|
1991-03-28 16:26:26 +00:00
|
|
|
}
|
1993-02-22 23:43:03 +00:00
|
|
|
|
1993-11-12 16:35:59 +00:00
|
|
|
#if 0
|
1997-01-31 16:37:07 +00:00
|
|
|
/* The lenient prologue stuff should be superseded by the code in
|
1993-11-12 16:35:59 +00:00
|
|
|
init_extra_frame_info which looks to see whether the stores mentioned
|
|
|
|
in the proc_desc have actually taken place. */
|
|
|
|
|
1993-07-19 02:28:21 +00:00
|
|
|
/* Is address PC in the prologue (loosely defined) for function at
|
|
|
|
STARTADDR? */
|
|
|
|
|
|
|
|
static int
|
|
|
|
mips_in_lenient_prologue (startaddr, pc)
|
|
|
|
CORE_ADDR startaddr;
|
|
|
|
CORE_ADDR pc;
|
|
|
|
{
|
|
|
|
CORE_ADDR end_prologue = mips_skip_prologue (startaddr, 1);
|
|
|
|
return pc >= startaddr && pc < end_prologue;
|
|
|
|
}
|
1993-11-12 16:35:59 +00:00
|
|
|
#endif
|
1993-07-19 02:28:21 +00:00
|
|
|
|
1993-05-22 07:26:25 +00:00
|
|
|
/* Given a return value in `regbuf' with a type `valtype',
|
|
|
|
extract and copy its value into `valbuf'. */
|
|
|
|
void
|
|
|
|
mips_extract_return_value (valtype, regbuf, valbuf)
|
|
|
|
struct type *valtype;
|
|
|
|
char regbuf[REGISTER_BYTES];
|
|
|
|
char *valbuf;
|
|
|
|
{
|
|
|
|
int regnum;
|
1995-08-01 09:20:05 +00:00
|
|
|
int offset = 0;
|
1993-05-22 07:26:25 +00:00
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
regnum = 2;
|
|
|
|
if (TYPE_CODE (valtype) == TYPE_CODE_FLT
|
|
|
|
&& (mips_fpu == MIPS_FPU_DOUBLE
|
1996-11-11 21:02:55 +00:00
|
|
|
|| (mips_fpu == MIPS_FPU_SINGLE && TYPE_LENGTH (valtype) <= 4))) /* FIXME!! */
|
1995-07-29 08:50:00 +00:00
|
|
|
regnum = FP0_REGNUM;
|
1993-05-22 07:26:25 +00:00
|
|
|
|
1995-08-01 09:20:05 +00:00
|
|
|
if (TARGET_BYTE_ORDER == BIG_ENDIAN
|
|
|
|
&& TYPE_CODE (valtype) != TYPE_CODE_FLT
|
|
|
|
&& TYPE_LENGTH (valtype) < REGISTER_RAW_SIZE (regnum))
|
|
|
|
offset = REGISTER_RAW_SIZE (regnum) - TYPE_LENGTH (valtype);
|
|
|
|
|
|
|
|
memcpy (valbuf, regbuf + REGISTER_BYTE (regnum) + offset,
|
|
|
|
TYPE_LENGTH (valtype));
|
1993-05-22 07:26:25 +00:00
|
|
|
#ifdef REGISTER_CONVERT_TO_TYPE
|
|
|
|
REGISTER_CONVERT_TO_TYPE(regnum, valtype, valbuf);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Given a return value in `regbuf' with a type `valtype',
|
|
|
|
write it's value into the appropriate register. */
|
|
|
|
void
|
|
|
|
mips_store_return_value (valtype, valbuf)
|
|
|
|
struct type *valtype;
|
|
|
|
char *valbuf;
|
|
|
|
{
|
|
|
|
int regnum;
|
|
|
|
char raw_buffer[MAX_REGISTER_RAW_SIZE];
|
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
regnum = 2;
|
|
|
|
if (TYPE_CODE (valtype) == TYPE_CODE_FLT
|
|
|
|
&& (mips_fpu == MIPS_FPU_DOUBLE
|
1996-11-11 21:02:55 +00:00
|
|
|
|| (mips_fpu == MIPS_FPU_SINGLE && TYPE_LENGTH (valtype) <= 4))) /* FIXME!! */
|
1995-07-29 08:50:00 +00:00
|
|
|
regnum = FP0_REGNUM;
|
|
|
|
|
1993-05-22 07:26:25 +00:00
|
|
|
memcpy(raw_buffer, valbuf, TYPE_LENGTH (valtype));
|
|
|
|
|
|
|
|
#ifdef REGISTER_CONVERT_FROM_TYPE
|
|
|
|
REGISTER_CONVERT_FROM_TYPE(regnum, valtype, raw_buffer);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
write_register_bytes(REGISTER_BYTE (regnum), raw_buffer, TYPE_LENGTH (valtype));
|
|
|
|
}
|
|
|
|
|
1993-12-06 17:31:05 +00:00
|
|
|
/* Exported procedure: Is PC in the signal trampoline code */
|
|
|
|
|
|
|
|
int
|
|
|
|
in_sigtramp (pc, ignore)
|
|
|
|
CORE_ADDR pc;
|
|
|
|
char *ignore; /* function name */
|
|
|
|
{
|
|
|
|
if (sigtramp_address == 0)
|
|
|
|
fixup_sigtramp ();
|
|
|
|
return (pc >= sigtramp_address && pc < sigtramp_end);
|
|
|
|
}
|
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
/* Command to set FPU type. mips_fpu_string will have been set to the
|
|
|
|
user's argument. Set mips_fpu based on mips_fpu_string, and then
|
|
|
|
canonicalize mips_fpu_string. */
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
|
|
|
static void
|
|
|
|
mips_set_fpu_command (args, from_tty, c)
|
|
|
|
char *args;
|
|
|
|
int from_tty;
|
|
|
|
struct cmd_list_element *c;
|
|
|
|
{
|
|
|
|
char *err = NULL;
|
|
|
|
|
|
|
|
if (mips_fpu_string == NULL || *mips_fpu_string == '\0')
|
|
|
|
mips_fpu = MIPS_FPU_DOUBLE;
|
|
|
|
else if (strcasecmp (mips_fpu_string, "double") == 0
|
|
|
|
|| strcasecmp (mips_fpu_string, "on") == 0
|
|
|
|
|| strcasecmp (mips_fpu_string, "1") == 0
|
|
|
|
|| strcasecmp (mips_fpu_string, "yes") == 0)
|
|
|
|
mips_fpu = MIPS_FPU_DOUBLE;
|
|
|
|
else if (strcasecmp (mips_fpu_string, "none") == 0
|
|
|
|
|| strcasecmp (mips_fpu_string, "off") == 0
|
|
|
|
|| strcasecmp (mips_fpu_string, "0") == 0
|
|
|
|
|| strcasecmp (mips_fpu_string, "no") == 0)
|
|
|
|
mips_fpu = MIPS_FPU_NONE;
|
|
|
|
else if (strcasecmp (mips_fpu_string, "single") == 0)
|
|
|
|
mips_fpu = MIPS_FPU_SINGLE;
|
|
|
|
else
|
|
|
|
err = strsave (mips_fpu_string);
|
|
|
|
|
|
|
|
if (mips_fpu_string != NULL)
|
|
|
|
free (mips_fpu_string);
|
|
|
|
|
|
|
|
switch (mips_fpu)
|
|
|
|
{
|
|
|
|
case MIPS_FPU_DOUBLE:
|
|
|
|
mips_fpu_string = strsave ("double");
|
|
|
|
break;
|
|
|
|
case MIPS_FPU_SINGLE:
|
|
|
|
mips_fpu_string = strsave ("single");
|
|
|
|
break;
|
|
|
|
case MIPS_FPU_NONE:
|
|
|
|
mips_fpu_string = strsave ("none");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err != NULL)
|
|
|
|
{
|
|
|
|
struct cleanup *cleanups = make_cleanup (free, err);
|
|
|
|
error ("Unknown FPU type `%s'. Use `double', `none', or `single'.",
|
|
|
|
err);
|
|
|
|
do_cleanups (cleanups);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mips_show_fpu_command (args, from_tty, c)
|
|
|
|
char *args;
|
|
|
|
int from_tty;
|
|
|
|
struct cmd_list_element *c;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
/* Command to set the processor type. */
|
|
|
|
|
|
|
|
void
|
|
|
|
mips_set_processor_type_command (args, from_tty)
|
|
|
|
char *args;
|
|
|
|
int from_tty;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (tmp_mips_processor_type == NULL || *tmp_mips_processor_type == '\0')
|
|
|
|
{
|
|
|
|
printf_unfiltered ("The known MIPS processor types are as follows:\n\n");
|
|
|
|
for (i = 0; mips_processor_type_table[i].name != NULL; ++i)
|
|
|
|
printf_unfiltered ("%s\n", mips_processor_type_table[i].name);
|
|
|
|
|
|
|
|
/* Restore the value. */
|
|
|
|
tmp_mips_processor_type = strsave (mips_processor_type);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mips_set_processor_type (tmp_mips_processor_type))
|
|
|
|
{
|
|
|
|
error ("Unknown processor type `%s'.", tmp_mips_processor_type);
|
|
|
|
/* Restore its value. */
|
|
|
|
tmp_mips_processor_type = strsave (mips_processor_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mips_show_processor_type_command (args, from_tty)
|
|
|
|
char *args;
|
|
|
|
int from_tty;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Modify the actual processor type. */
|
|
|
|
|
|
|
|
int
|
|
|
|
mips_set_processor_type (str)
|
|
|
|
char *str;
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
if (str == NULL)
|
1995-01-10 21:24:34 +00:00
|
|
|
return 0;
|
1994-11-18 02:18:09 +00:00
|
|
|
|
|
|
|
for (i = 0; mips_processor_type_table[i].name != NULL; ++i)
|
|
|
|
{
|
|
|
|
if (strcasecmp (str, mips_processor_type_table[i].name) == 0)
|
|
|
|
{
|
|
|
|
mips_processor_type = str;
|
|
|
|
|
|
|
|
for (j = 0; j < NUM_REGS; ++j)
|
|
|
|
reg_names[j] = mips_processor_type_table[i].regnames[j];
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
/* FIXME tweak fpu flag too */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attempt to identify the particular processor model by reading the
|
|
|
|
processor id. */
|
|
|
|
|
|
|
|
char *
|
|
|
|
mips_read_processor_type ()
|
|
|
|
{
|
1996-11-11 21:02:55 +00:00
|
|
|
CORE_ADDR prid;
|
1994-11-18 02:18:09 +00:00
|
|
|
|
|
|
|
prid = read_register (PRID_REGNUM);
|
|
|
|
|
1996-07-30 06:15:13 +00:00
|
|
|
if ((prid & ~0xf) == 0x700)
|
1994-11-18 02:18:09 +00:00
|
|
|
return savestring ("r3041", strlen("r3041"));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
1993-08-27 19:33:43 +00:00
|
|
|
|
|
|
|
/* Just like reinit_frame_cache, but with the right arguments to be
|
|
|
|
callable as an sfunc. */
|
1994-11-18 02:18:09 +00:00
|
|
|
|
1993-08-27 19:33:43 +00:00
|
|
|
static void
|
|
|
|
reinit_frame_cache_sfunc (args, from_tty, c)
|
|
|
|
char *args;
|
|
|
|
int from_tty;
|
|
|
|
struct cmd_list_element *c;
|
|
|
|
{
|
|
|
|
reinit_frame_cache ();
|
|
|
|
}
|
1993-02-22 23:43:03 +00:00
|
|
|
|
1996-11-11 21:02:55 +00:00
|
|
|
static int
|
General cleanup and simplication of disassembler interface.
* a29k-pinsn.c, arm-pinsn.c, convex-pinsn.c, gould-pinsn.c,
hppa-pinsn.c, i386-pinsn.c, i960-pinsn.c, m68k-pinsn.c,
m88k-pinsn.c, mips-pinsn.c, ns32k-pinsn.c, pyr-pinsn.c,
rs6000-pinsn.c, sparc-pinsn.c, tahoe-pinsn.c, vax-pinsn.c: Remove.
* gould-tdep.c, ns32k-tdep.c, tahoe-tdep.c, vax-tdep.c: New files,
had been -pinsn.c files.
* Makefile.in (ALLDEPFILES): Remove removed files.
(a29k-pinsn.o, arm-pinsn.o, convex-pinsn.o, gould-pinsn.o,
hppa-pinsn.o, i386-pinsn.o, i960-pinsn.o, m68k-pinsn.o,
m88k-pinsn.o, mips-pinsn.o, ns32k-pinsn.o, pyr-pinsn.o,
rs6000-pinsn.o, sparc-pinsn.o, tahoe-pinsn.o, vax-pinsn.o):
Remove compile actions.
* arm-tdep.o, gould-tdep.o, ns32k-tdep.o, tahoe-tdep.o,
vax-tdep.o: Add compile actions.
* defs.h (tm_print_insn): New global.
* a29k-tdep.c (gdb_print_insn_a29k): New function.
(_initialize_a29k_tdep): Rename from _initialize_29k,
set tm_print_insn.
* alpha-tdep.c (print_insn): Remove.
(_initialize_alpha_tdep): Set tm_print_insn.
* arm-tdep.c (arm_print_insn): New function, was print_insn
in arm-pinsn.c.
* convex-tdep.c (convex_print_insn): New function, was print_insn
in convex-pinsn.c.
* h8300-tdep.c (print_insn): Remove.
(gdb_print_insn_h8300): New function.
(_initialize_h8300_tdep): New function.
* h8500-tdep.c (print_insn): Remove.
(_initialize_h8500_tdep): New function.
* hppa-tdep.c (_initialize_hppa_tdep): Set tm_print_insn.
* i386-tdep.c (_initialize_i386_tdep): New function.
* i960-tdep.c (mem, next_insn): New functions, were in
i960-pinsn.c.
(_initialize_i960_tdep): Set tm_print_insn.
* m68k-tdep.c (_initialize_m68k_tdep): New function.
* m88k-tdep.c (_initialize_m88k_tdep): New function.
* mips-tdep.c (gdb_print_insn_mips): New function.
(_initialize_mips_tdep): Set tm_print_insn.
* pyr-tdep.c (pyr_print_insn): New function, was print_insn
in pyr-pinsn.c.
* rs6000-tdep.c (_initialize_rs6000_tdep): New function.
* sh-tdep.c (print_insn): Remove.
(gdb_print_insn_sh): New function.
(_initialize_sh_tdep): Set tm_print_insn.
* sparc-tdep.c (_initialize_sparc_tdep): New function.
* w65-tdep.c (print_insn): Remove.
(_initialize_w65_tdep): New function.
* z8k-tdep.c (print_insn): Remove.
(gdb_print_insn_z8k): New function.
(_initialize_z8k_tdep): Set tm_print_insn.
* printcmd.c (print_insn): New function, generic disassembler.
* config/*/*.mt (TDEPFILES): Remove refs to *-pinsn.o.
* defs.h (query_hook, error_hook): Fix prototypes.
1995-01-17 04:36:51 +00:00
|
|
|
gdb_print_insn_mips (memaddr, info)
|
|
|
|
bfd_vma memaddr;
|
|
|
|
disassemble_info *info;
|
|
|
|
{
|
1997-01-28 00:50:13 +00:00
|
|
|
mips_extra_func_info_t proc_desc;
|
|
|
|
|
|
|
|
/* Search for the function containing this address. Set the low bit
|
|
|
|
of the address when searching, in case we were given an even address
|
|
|
|
that is the start of a 16-bit function. If we didn't do this,
|
|
|
|
the search would fail because the symbol table says the function
|
|
|
|
starts at an odd address, i.e. 1 byte past the given address. */
|
|
|
|
proc_desc = find_proc_desc (memaddr | 1, NULL);
|
|
|
|
|
|
|
|
/* Make an attempt to determine if this is a 16-bit function. If
|
|
|
|
the procedure descriptor exists and the address therein is odd,
|
|
|
|
it's definitely a 16-bit function. Otherwise, we have to just
|
|
|
|
guess that if the address passed in is odd, it's 16-bits. */
|
|
|
|
if (proc_desc)
|
|
|
|
info->mach = PROC_LOW_ADDR (proc_desc) & 1 ? 16 : 0;
|
|
|
|
else
|
|
|
|
info->mach = memaddr & 1 ? 16 : 0;
|
|
|
|
|
|
|
|
/* Round down the instruction address to the appropriate boundary.
|
|
|
|
Save the amount rounded down and subtract it from the returned size of
|
|
|
|
the instruction so that the next time through the address won't
|
|
|
|
look bogus. */
|
|
|
|
memaddr &= (info->mach == 16 ? ~1 : ~3);
|
|
|
|
|
|
|
|
/* Call the appropriate disassembler based on the target endian-ness. */
|
General cleanup and simplication of disassembler interface.
* a29k-pinsn.c, arm-pinsn.c, convex-pinsn.c, gould-pinsn.c,
hppa-pinsn.c, i386-pinsn.c, i960-pinsn.c, m68k-pinsn.c,
m88k-pinsn.c, mips-pinsn.c, ns32k-pinsn.c, pyr-pinsn.c,
rs6000-pinsn.c, sparc-pinsn.c, tahoe-pinsn.c, vax-pinsn.c: Remove.
* gould-tdep.c, ns32k-tdep.c, tahoe-tdep.c, vax-tdep.c: New files,
had been -pinsn.c files.
* Makefile.in (ALLDEPFILES): Remove removed files.
(a29k-pinsn.o, arm-pinsn.o, convex-pinsn.o, gould-pinsn.o,
hppa-pinsn.o, i386-pinsn.o, i960-pinsn.o, m68k-pinsn.o,
m88k-pinsn.o, mips-pinsn.o, ns32k-pinsn.o, pyr-pinsn.o,
rs6000-pinsn.o, sparc-pinsn.o, tahoe-pinsn.o, vax-pinsn.o):
Remove compile actions.
* arm-tdep.o, gould-tdep.o, ns32k-tdep.o, tahoe-tdep.o,
vax-tdep.o: Add compile actions.
* defs.h (tm_print_insn): New global.
* a29k-tdep.c (gdb_print_insn_a29k): New function.
(_initialize_a29k_tdep): Rename from _initialize_29k,
set tm_print_insn.
* alpha-tdep.c (print_insn): Remove.
(_initialize_alpha_tdep): Set tm_print_insn.
* arm-tdep.c (arm_print_insn): New function, was print_insn
in arm-pinsn.c.
* convex-tdep.c (convex_print_insn): New function, was print_insn
in convex-pinsn.c.
* h8300-tdep.c (print_insn): Remove.
(gdb_print_insn_h8300): New function.
(_initialize_h8300_tdep): New function.
* h8500-tdep.c (print_insn): Remove.
(_initialize_h8500_tdep): New function.
* hppa-tdep.c (_initialize_hppa_tdep): Set tm_print_insn.
* i386-tdep.c (_initialize_i386_tdep): New function.
* i960-tdep.c (mem, next_insn): New functions, were in
i960-pinsn.c.
(_initialize_i960_tdep): Set tm_print_insn.
* m68k-tdep.c (_initialize_m68k_tdep): New function.
* m88k-tdep.c (_initialize_m88k_tdep): New function.
* mips-tdep.c (gdb_print_insn_mips): New function.
(_initialize_mips_tdep): Set tm_print_insn.
* pyr-tdep.c (pyr_print_insn): New function, was print_insn
in pyr-pinsn.c.
* rs6000-tdep.c (_initialize_rs6000_tdep): New function.
* sh-tdep.c (print_insn): Remove.
(gdb_print_insn_sh): New function.
(_initialize_sh_tdep): Set tm_print_insn.
* sparc-tdep.c (_initialize_sparc_tdep): New function.
* w65-tdep.c (print_insn): Remove.
(_initialize_w65_tdep): New function.
* z8k-tdep.c (print_insn): Remove.
(gdb_print_insn_z8k): New function.
(_initialize_z8k_tdep): Set tm_print_insn.
* printcmd.c (print_insn): New function, generic disassembler.
* config/*/*.mt (TDEPFILES): Remove refs to *-pinsn.o.
* defs.h (query_hook, error_hook): Fix prototypes.
1995-01-17 04:36:51 +00:00
|
|
|
if (TARGET_BYTE_ORDER == BIG_ENDIAN)
|
|
|
|
return print_insn_big_mips (memaddr, info);
|
|
|
|
else
|
|
|
|
return print_insn_little_mips (memaddr, info);
|
|
|
|
}
|
|
|
|
|
1997-01-28 00:50:13 +00:00
|
|
|
/* This function implements the BREAKPOINT_FROM_PC macro. It uses the program
|
|
|
|
counter value to determine whether a 16- or 32-bit breakpoint should be
|
|
|
|
used. It returns a pointer to a string of bytes that encode a breakpoint
|
|
|
|
instruction, stores the length of the string to *lenptr, and adjusts pc
|
|
|
|
(if necessary) to point to the actual memory location where the
|
|
|
|
breakpoint should be inserted. */
|
|
|
|
|
|
|
|
unsigned char *mips_breakpoint_from_pc (pcptr, lenptr)
|
|
|
|
CORE_ADDR *pcptr;
|
|
|
|
int *lenptr;
|
|
|
|
{
|
|
|
|
if (TARGET_BYTE_ORDER == BIG_ENDIAN)
|
|
|
|
{
|
|
|
|
if (*pcptr & 1)
|
|
|
|
{
|
|
|
|
static char mips16_big_breakpoint[] = MIPS16_BIG_BREAKPOINT;
|
|
|
|
*pcptr &= ~1;
|
|
|
|
*lenptr = sizeof(mips16_big_breakpoint);
|
|
|
|
return mips16_big_breakpoint;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static char big_breakpoint[] = BIG_BREAKPOINT;
|
|
|
|
*lenptr = sizeof(big_breakpoint);
|
|
|
|
return big_breakpoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*pcptr & 1)
|
|
|
|
{
|
|
|
|
static char mips16_little_breakpoint[] = MIPS16_LITTLE_BREAKPOINT;
|
|
|
|
*pcptr &= ~1;
|
|
|
|
*lenptr = sizeof(mips16_little_breakpoint);
|
|
|
|
return mips16_little_breakpoint;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
static char little_breakpoint[] = LITTLE_BREAKPOINT;
|
|
|
|
*lenptr = sizeof(little_breakpoint);
|
|
|
|
return little_breakpoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Test whether the PC points to the return instruction at the
|
|
|
|
end of a function. This implements the ABOUT_TO_RETURN macro. */
|
|
|
|
|
|
|
|
int
|
|
|
|
mips_about_to_return (pc)
|
|
|
|
CORE_ADDR pc;
|
|
|
|
{
|
|
|
|
if (pc & 1)
|
|
|
|
/* This mips16 case isn't necessarily reliable. Sometimes the compiler
|
|
|
|
generates a "jr $ra"; other times it generates code to load
|
|
|
|
the return address from the stack to an accessible register (such
|
|
|
|
as $a3), then a "jr" using that register. This second case
|
|
|
|
is almost impossible to distinguish from an indirect jump
|
|
|
|
used for switch statements, so we don't even try. */
|
|
|
|
return read_memory_integer (pc & ~1, 2) == 0xe820; /* jr $ra */
|
|
|
|
else
|
|
|
|
return read_memory_integer (pc, 4) == 0x3e00008; /* jr $ra */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1993-02-22 23:43:03 +00:00
|
|
|
void
|
|
|
|
_initialize_mips_tdep ()
|
|
|
|
{
|
1993-08-27 19:33:43 +00:00
|
|
|
struct cmd_list_element *c;
|
|
|
|
|
General cleanup and simplication of disassembler interface.
* a29k-pinsn.c, arm-pinsn.c, convex-pinsn.c, gould-pinsn.c,
hppa-pinsn.c, i386-pinsn.c, i960-pinsn.c, m68k-pinsn.c,
m88k-pinsn.c, mips-pinsn.c, ns32k-pinsn.c, pyr-pinsn.c,
rs6000-pinsn.c, sparc-pinsn.c, tahoe-pinsn.c, vax-pinsn.c: Remove.
* gould-tdep.c, ns32k-tdep.c, tahoe-tdep.c, vax-tdep.c: New files,
had been -pinsn.c files.
* Makefile.in (ALLDEPFILES): Remove removed files.
(a29k-pinsn.o, arm-pinsn.o, convex-pinsn.o, gould-pinsn.o,
hppa-pinsn.o, i386-pinsn.o, i960-pinsn.o, m68k-pinsn.o,
m88k-pinsn.o, mips-pinsn.o, ns32k-pinsn.o, pyr-pinsn.o,
rs6000-pinsn.o, sparc-pinsn.o, tahoe-pinsn.o, vax-pinsn.o):
Remove compile actions.
* arm-tdep.o, gould-tdep.o, ns32k-tdep.o, tahoe-tdep.o,
vax-tdep.o: Add compile actions.
* defs.h (tm_print_insn): New global.
* a29k-tdep.c (gdb_print_insn_a29k): New function.
(_initialize_a29k_tdep): Rename from _initialize_29k,
set tm_print_insn.
* alpha-tdep.c (print_insn): Remove.
(_initialize_alpha_tdep): Set tm_print_insn.
* arm-tdep.c (arm_print_insn): New function, was print_insn
in arm-pinsn.c.
* convex-tdep.c (convex_print_insn): New function, was print_insn
in convex-pinsn.c.
* h8300-tdep.c (print_insn): Remove.
(gdb_print_insn_h8300): New function.
(_initialize_h8300_tdep): New function.
* h8500-tdep.c (print_insn): Remove.
(_initialize_h8500_tdep): New function.
* hppa-tdep.c (_initialize_hppa_tdep): Set tm_print_insn.
* i386-tdep.c (_initialize_i386_tdep): New function.
* i960-tdep.c (mem, next_insn): New functions, were in
i960-pinsn.c.
(_initialize_i960_tdep): Set tm_print_insn.
* m68k-tdep.c (_initialize_m68k_tdep): New function.
* m88k-tdep.c (_initialize_m88k_tdep): New function.
* mips-tdep.c (gdb_print_insn_mips): New function.
(_initialize_mips_tdep): Set tm_print_insn.
* pyr-tdep.c (pyr_print_insn): New function, was print_insn
in pyr-pinsn.c.
* rs6000-tdep.c (_initialize_rs6000_tdep): New function.
* sh-tdep.c (print_insn): Remove.
(gdb_print_insn_sh): New function.
(_initialize_sh_tdep): Set tm_print_insn.
* sparc-tdep.c (_initialize_sparc_tdep): New function.
* w65-tdep.c (print_insn): Remove.
(_initialize_w65_tdep): New function.
* z8k-tdep.c (print_insn): Remove.
(gdb_print_insn_z8k): New function.
(_initialize_z8k_tdep): Set tm_print_insn.
* printcmd.c (print_insn): New function, generic disassembler.
* config/*/*.mt (TDEPFILES): Remove refs to *-pinsn.o.
* defs.h (query_hook, error_hook): Fix prototypes.
1995-01-17 04:36:51 +00:00
|
|
|
tm_print_insn = gdb_print_insn_mips;
|
|
|
|
|
1993-08-27 19:33:43 +00:00
|
|
|
/* Let the user turn off floating point and set the fence post for
|
|
|
|
heuristic_proc_start. */
|
|
|
|
|
1995-07-29 08:50:00 +00:00
|
|
|
c = add_set_cmd ("mipsfpu", class_support, var_string_noescape,
|
|
|
|
(char *) &mips_fpu_string,
|
|
|
|
"Set use of floating point coprocessor.\n\
|
|
|
|
Set to `none' to avoid using floating point instructions when calling\n\
|
|
|
|
functions or dealing with return values. Set to `single' to use only\n\
|
|
|
|
single precision floating point as on the R4650. Set to `double' for\n\
|
|
|
|
normal floating point support.",
|
|
|
|
&setlist);
|
|
|
|
c->function.sfunc = mips_set_fpu_command;
|
|
|
|
c = add_show_from_set (c, &showlist);
|
|
|
|
c->function.sfunc = mips_show_fpu_command;
|
|
|
|
|
|
|
|
mips_fpu = MIPS_FPU_DOUBLE;
|
|
|
|
mips_fpu_string = strsave ("double");
|
1993-04-22 23:32:33 +00:00
|
|
|
|
1994-11-18 02:18:09 +00:00
|
|
|
c = add_set_cmd ("processor", class_support, var_string_noescape,
|
|
|
|
(char *) &tmp_mips_processor_type,
|
|
|
|
"Set the type of MIPS processor in use.\n\
|
|
|
|
Set this to be able to access processor-type-specific registers.\n\
|
|
|
|
",
|
|
|
|
&setlist);
|
|
|
|
c->function.cfunc = mips_set_processor_type_command;
|
|
|
|
c = add_show_from_set (c, &showlist);
|
|
|
|
c->function.cfunc = mips_show_processor_type_command;
|
|
|
|
|
|
|
|
tmp_mips_processor_type = strsave (DEFAULT_MIPS_TYPE);
|
|
|
|
mips_set_processor_type_command (strsave (DEFAULT_MIPS_TYPE), 0);
|
|
|
|
|
1993-09-22 19:31:42 +00:00
|
|
|
/* We really would like to have both "0" and "unlimited" work, but
|
|
|
|
command.c doesn't deal with that. So make it a var_zinteger
|
|
|
|
because the user can always use "999999" or some such for unlimited. */
|
|
|
|
c = add_set_cmd ("heuristic-fence-post", class_support, var_zinteger,
|
1993-08-27 19:33:43 +00:00
|
|
|
(char *) &heuristic_fence_post,
|
|
|
|
"\
|
1993-07-20 22:36:13 +00:00
|
|
|
Set the distance searched for the start of a function.\n\
|
|
|
|
If you are debugging a stripped executable, GDB needs to search through the\n\
|
|
|
|
program for the start of a function. This command sets the distance of the\n\
|
|
|
|
search. The only need to set it is when debugging a stripped executable.",
|
1993-08-27 19:33:43 +00:00
|
|
|
&setlist);
|
|
|
|
/* We need to throw away the frame cache when we set this, since it
|
|
|
|
might change our ability to get backtraces. */
|
|
|
|
c->function.sfunc = reinit_frame_cache_sfunc;
|
|
|
|
add_show_from_set (c, &showlist);
|
1993-02-22 23:43:03 +00:00
|
|
|
}
|