mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-09-10 10:12:21 +08:00
* remote-sim.c: first attempt at general simulator interface
* remote-hms.c: whitespace * h8300-tdep.c: (h8300_skip_prologue, examine_prologue): understand new stack layout. (print_register_hook): print ccr register in a fancy way.
This commit is contained in:
@ -210,6 +210,7 @@ remote-es1800.c
|
|||||||
remote-hms.c
|
remote-hms.c
|
||||||
remote-mm.c
|
remote-mm.c
|
||||||
remote-nindy.c
|
remote-nindy.c
|
||||||
|
remote-sim.c
|
||||||
remote-st2000.c
|
remote-st2000.c
|
||||||
remote-vx.c
|
remote-vx.c
|
||||||
remote.c
|
remote.c
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Sun Jan 3 14:24:56 1993 Steve Chamberlain (sac@thepub.cygnus.com)
|
||||||
|
|
||||||
|
* remote-sim.c: first attempt at general simulator interface
|
||||||
|
* remote-hms.c: whitespace
|
||||||
|
* h8300-tdep.c: (h8300_skip_prologue, examine_prologue):
|
||||||
|
understand new stack layout. (print_register_hook): print ccr
|
||||||
|
register in a fancy way.
|
||||||
|
|
||||||
Sun Jan 3 14:16:10 1993 Fred Fish (fnf@cygnus.com)
|
Sun Jan 3 14:16:10 1993 Fred Fish (fnf@cygnus.com)
|
||||||
|
|
||||||
* eval.c (language.h): Include.
|
* eval.c (language.h): Include.
|
||||||
|
393
gdb/h8300-tdep.c
393
gdb/h8300-tdep.c
@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Contributed by Steve Chamberlain
|
Contributed by Steve Chamberlain
|
||||||
sac@cygnus.com
|
sac@cygnus.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
@ -29,61 +29,80 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
#define UNSIGNED_SHORT(X) ((X) & 0xffff)
|
#define UNSIGNED_SHORT(X) ((X) & 0xffff)
|
||||||
|
|
||||||
/* an easy to debug H8 stack frame looks like:
|
/* an easy to debug H8 stack frame looks like:
|
||||||
0x6df2 push r2
|
0x6df6 push r6
|
||||||
0x6df3 push r3
|
0x0d76 mov.w r7,r6
|
||||||
0x6df6 push r6
|
0x6dfn push reg
|
||||||
0x mov.w r7,r6
|
0x7905 nnnn mov.w #n,r5 or 0x1b87 subs #2,sp
|
||||||
subs stuff,sp mov.w #x,r5
|
0x1957 sub.w r5,sp
|
||||||
subs r5,sp
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define IS_PUSH(x) ((x & 0xff00)==0x6d00)
|
#define IS_PUSH(x) ((x & 0xff00)==0x6d00)
|
||||||
|
#define IS_PUSH_FP(x) (x == 0x6df6)
|
||||||
#define IS_MOVE_FP(x) (x == 0x0d76)
|
#define IS_MOVE_FP(x) (x == 0x0d76)
|
||||||
#define IS_MOV_SP_FP(x) (x == 0x0d76)
|
#define IS_MOV_SP_FP(x) (x == 0x0d76)
|
||||||
#define IS_SUB2_SP(x) (x==0x1b87)
|
#define IS_SUB2_SP(x) (x==0x1b87)
|
||||||
#define IS_MOVK_R5(x) (x==0x7905)
|
#define IS_MOVK_R5(x) (x==0x7905)
|
||||||
CORE_ADDR examine_prologue();
|
#define IS_SUB_R5SP(x) (x==0x1957)
|
||||||
|
CORE_ADDR examine_prologue ();
|
||||||
|
|
||||||
void frame_find_saved_regs ();
|
void frame_find_saved_regs ();
|
||||||
CORE_ADDR h8300_skip_prologue(start_pc)
|
CORE_ADDR
|
||||||
CORE_ADDR start_pc;
|
h8300_skip_prologue (start_pc)
|
||||||
|
CORE_ADDR start_pc;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Skip past all push insns */
|
|
||||||
short int w;
|
short int w;
|
||||||
|
|
||||||
w = read_memory_short(start_pc);
|
|
||||||
while (IS_PUSH(w))
|
|
||||||
{
|
|
||||||
start_pc+=2;
|
|
||||||
w = read_memory_short(start_pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip past a move to FP */
|
w = read_memory_short (start_pc);
|
||||||
if (IS_MOVE_FP(w)) {
|
/* Skip past all push insns */
|
||||||
start_pc +=2 ;
|
while (IS_PUSH_FP (w))
|
||||||
w = read_memory_short(start_pc);
|
{
|
||||||
|
start_pc += 2;
|
||||||
|
w = read_memory_short (start_pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return start_pc;
|
/* Skip past a move to FP */
|
||||||
|
if (IS_MOVE_FP (w))
|
||||||
}
|
{
|
||||||
|
start_pc += 2;
|
||||||
|
w = read_memory_short (start_pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip the stack adjust */
|
||||||
|
|
||||||
|
if (IS_MOVK_R5 (w))
|
||||||
|
{
|
||||||
|
start_pc += 2;
|
||||||
|
w = read_memory_short (start_pc);
|
||||||
|
}
|
||||||
|
if (IS_SUB_R5SP (w))
|
||||||
|
{
|
||||||
|
start_pc += 2;
|
||||||
|
w = read_memory_short (start_pc);
|
||||||
|
}
|
||||||
|
while (IS_SUB2_SP (w))
|
||||||
|
{
|
||||||
|
start_pc += 2;
|
||||||
|
w = read_memory_short (start_pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return start_pc;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
print_insn(memaddr, stream)
|
print_insn (memaddr, stream)
|
||||||
CORE_ADDR memaddr;
|
CORE_ADDR memaddr;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
{
|
{
|
||||||
/* Nothing is bigger than 8 bytes */
|
/* Nothing is bigger than 8 bytes */
|
||||||
char data[8];
|
char data[8];
|
||||||
read_memory (memaddr, data, sizeof(data));
|
|
||||||
return print_insn_h8300(memaddr, data, stream);
|
read_memory (memaddr, data, sizeof (data));
|
||||||
|
return print_insn_h8300 (memaddr, data, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Given a GDB frame, determine the address of the calling function's frame.
|
/* Given a GDB frame, determine the address of the calling function's frame.
|
||||||
This will be used to create a new GDB frame struct, and then
|
This will be used to create a new GDB frame struct, and then
|
||||||
INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
|
INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame.
|
||||||
@ -97,11 +116,9 @@ FRAME_CHAIN (thisframe)
|
|||||||
{
|
{
|
||||||
|
|
||||||
frame_find_saved_regs (thisframe, (struct frame_saved_regs *) 0);
|
frame_find_saved_regs (thisframe, (struct frame_saved_regs *) 0);
|
||||||
return thisframe->fsr->regs[SP_REGNUM];
|
return thisframe->fsr->regs[SP_REGNUM];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Put here the code to store, into a struct frame_saved_regs,
|
/* Put here the code to store, into a struct frame_saved_regs,
|
||||||
the addresses of the saved registers of frame described by FRAME_INFO.
|
the addresses of the saved registers of frame described by FRAME_INFO.
|
||||||
This includes special registers such as pc and fp saved in special
|
This includes special registers such as pc and fp saved in special
|
||||||
@ -128,18 +145,19 @@ frame_find_saved_regs (fi, fsr)
|
|||||||
if (!fi->fsr)
|
if (!fi->fsr)
|
||||||
{
|
{
|
||||||
cache_fsr = (struct frame_saved_regs *)
|
cache_fsr = (struct frame_saved_regs *)
|
||||||
obstack_alloc (&frame_cache_obstack,
|
obstack_alloc (&frame_cache_obstack,
|
||||||
sizeof (struct frame_saved_regs));
|
sizeof (struct frame_saved_regs));
|
||||||
bzero (cache_fsr, sizeof (struct frame_saved_regs));
|
bzero (cache_fsr, sizeof (struct frame_saved_regs));
|
||||||
|
|
||||||
fi->fsr = cache_fsr;
|
fi->fsr = cache_fsr;
|
||||||
|
|
||||||
/* Find the start and end of the function prologue. If the PC
|
/* Find the start and end of the function prologue. If the PC
|
||||||
is in the function prologue, we only consider the part that
|
is in the function prologue, we only consider the part that
|
||||||
has executed already. */
|
has executed already. */
|
||||||
|
|
||||||
ip = get_pc_function_start (fi->pc);
|
ip = get_pc_function_start (fi->pc);
|
||||||
sal = find_pc_line (ip, 0);
|
sal = find_pc_line (ip, 0);
|
||||||
limit = (sal.end && sal.end < fi->pc) ? sal.end: fi->pc;
|
limit = (sal.end && sal.end < fi->pc) ? sal.end : fi->pc;
|
||||||
|
|
||||||
/* This will fill in fields in *fi as well as in cache_fsr. */
|
/* This will fill in fields in *fi as well as in cache_fsr. */
|
||||||
examine_prologue (ip, limit, fi->frame, cache_fsr, fi);
|
examine_prologue (ip, limit, fi->frame, cache_fsr, fi);
|
||||||
@ -148,55 +166,37 @@ frame_find_saved_regs (fi, fsr)
|
|||||||
if (fsr)
|
if (fsr)
|
||||||
*fsr = *fi->fsr;
|
*fsr = *fi->fsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or
|
/* Fetch the instruction at ADDR, returning 0 if ADDR is beyond LIM or
|
||||||
is not the address of a valid instruction, the address of the next
|
is not the address of a valid instruction, the address of the next
|
||||||
instruction beyond ADDR otherwise. *PWORD1 receives the first word
|
instruction beyond ADDR otherwise. *PWORD1 receives the first word
|
||||||
of the instruction.*/
|
of the instruction.*/
|
||||||
|
|
||||||
|
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
NEXT_PROLOGUE_INSN(addr, lim, pword1)
|
NEXT_PROLOGUE_INSN (addr, lim, pword1)
|
||||||
CORE_ADDR addr;
|
CORE_ADDR addr;
|
||||||
CORE_ADDR lim;
|
CORE_ADDR lim;
|
||||||
short *pword1;
|
short *pword1;
|
||||||
{
|
{
|
||||||
if (addr < lim+8)
|
if (addr < lim + 8)
|
||||||
{
|
{
|
||||||
read_memory (addr, pword1, sizeof(*pword1));
|
read_memory (addr, pword1, sizeof (*pword1));
|
||||||
SWAP_TARGET_AND_HOST (pword1, sizeof (short));
|
SWAP_TARGET_AND_HOST (pword1, sizeof (short));
|
||||||
return addr + 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return addr + 2;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Examine the prologue of a function. `ip' points to the first instruction.
|
/* Examine the prologue of a function. `ip' points to the first instruction.
|
||||||
`limit' is the limit of the prologue (e.g. the addr of the first
|
`limit' is the limit of the prologue (e.g. the addr of the first
|
||||||
linenumber, or perhaps the program counter if we're stepping through).
|
linenumber, or perhaps the program counter if we're stepping through).
|
||||||
`frame_sp' is the stack pointer value in use in this frame.
|
`frame_sp' is the stack pointer value in use in this frame.
|
||||||
`fsr' is a pointer to a frame_saved_regs structure into which we put
|
`fsr' is a pointer to a frame_saved_regs structure into which we put
|
||||||
info about the registers saved by this frame.
|
info about the registers saved by this frame.
|
||||||
`fi' is a struct frame_info pointer; we fill in various fields in it
|
`fi' is a struct frame_info pointer; we fill in various fields in it
|
||||||
to reflect the offsets of the arg pointer and the locals pointer. */
|
to reflect the offsets of the arg pointer and the locals pointer. */
|
||||||
|
|
||||||
/* We will find two sorts of prologue, framefull and non framefull:
|
|
||||||
|
|
||||||
push r2
|
|
||||||
push r3
|
|
||||||
push fp
|
|
||||||
mov sp,fp
|
|
||||||
stack_ad
|
|
||||||
|
|
||||||
and
|
|
||||||
push x
|
|
||||||
push y
|
|
||||||
stack_ad
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
static CORE_ADDR
|
static CORE_ADDR
|
||||||
examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
|
examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
|
||||||
register CORE_ADDR ip;
|
register CORE_ADDR ip;
|
||||||
@ -209,107 +209,102 @@ examine_prologue (ip, limit, after_prolog_fp, fsr, fi)
|
|||||||
int r;
|
int r;
|
||||||
int i;
|
int i;
|
||||||
int have_fp = 0;
|
int have_fp = 0;
|
||||||
|
|
||||||
register int src;
|
register int src;
|
||||||
register struct pic_prologue_code *pcode;
|
register struct pic_prologue_code *pcode;
|
||||||
INSN_WORD insn_word;
|
INSN_WORD insn_word;
|
||||||
int size, offset;
|
int size, offset;
|
||||||
unsigned int reg_save_depth = 2; /* Number of things pushed onto
|
unsigned int reg_save_depth = 2; /* Number of things pushed onto
|
||||||
stack, starts at 2, 'cause the
|
stack, starts at 2, 'cause the
|
||||||
PC is already there */
|
PC is already there */
|
||||||
|
|
||||||
unsigned int auto_depth = 0; /* Number of bytes of autos */
|
unsigned int auto_depth = 0; /* Number of bytes of autos */
|
||||||
|
|
||||||
char in_frame[NUM_REGS]; /* One for each reg */
|
char in_frame[NUM_REGS]; /* One for each reg */
|
||||||
|
|
||||||
memset(in_frame, 1, NUM_REGS);
|
memset (in_frame, 1, NUM_REGS);
|
||||||
|
for (r = 0; r < NUM_REGS; r++)
|
||||||
if (after_prolog_fp == 0) {
|
{
|
||||||
after_prolog_fp = read_register(SP_REGNUM);
|
fsr->regs[r] = 0;
|
||||||
}
|
}
|
||||||
if (ip == 0 || ip & ~0xffff) return 0;
|
if (after_prolog_fp == 0)
|
||||||
|
{
|
||||||
|
after_prolog_fp = read_register (SP_REGNUM);
|
||||||
|
}
|
||||||
|
if (ip == 0 || ip & ~0xffff)
|
||||||
|
return 0;
|
||||||
|
|
||||||
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
||||||
|
|
||||||
/* Skip over any push instructions, and remember where they were saved */
|
/* Skip over any fp push instructions */
|
||||||
|
fsr->regs[6] = after_prolog_fp;
|
||||||
|
while (next_ip && IS_PUSH_FP (insn_word))
|
||||||
|
{
|
||||||
|
ip = next_ip;
|
||||||
|
|
||||||
|
in_frame[insn_word & 0x7] = reg_save_depth;
|
||||||
while (next_ip && IS_PUSH(insn_word))
|
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
||||||
{
|
reg_save_depth += 2;
|
||||||
ip = next_ip;
|
}
|
||||||
in_frame[insn_word & 0x7] = reg_save_depth;
|
|
||||||
next_ip = NEXT_PROLOGUE_INSN(ip, limit, &insn_word);
|
|
||||||
reg_save_depth +=2;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Is this a move into the fp */
|
/* Is this a move into the fp */
|
||||||
if (next_ip && IS_MOV_SP_FP(insn_word))
|
if (next_ip && IS_MOV_SP_FP (insn_word))
|
||||||
{
|
{
|
||||||
ip = next_ip;
|
ip = next_ip;
|
||||||
next_ip = NEXT_PROLOGUE_INSN(ip, limit, &insn_word);
|
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
||||||
have_fp = 1;
|
have_fp = 1;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Skip over any stack adjustment, happens either with a number of
|
/* Skip over any stack adjustment, happens either with a number of
|
||||||
sub#2,sp or a mov #x,r5 sub r5,sp */
|
sub#2,sp or a mov #x,r5 sub r5,sp */
|
||||||
|
|
||||||
|
if (next_ip && IS_SUB2_SP (insn_word))
|
||||||
if (next_ip && IS_SUB2_SP(insn_word))
|
|
||||||
{
|
|
||||||
while (next_ip && IS_SUB2_SP(insn_word))
|
|
||||||
{
|
{
|
||||||
auto_depth +=2 ;
|
while (next_ip && IS_SUB2_SP (insn_word))
|
||||||
ip = next_ip;
|
{
|
||||||
next_ip = NEXT_PROLOGUE_INSN(ip, limit, &insn_word);
|
auto_depth += 2;
|
||||||
|
ip = next_ip;
|
||||||
|
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
if (next_ip && IS_MOVK_R5 (insn_word))
|
||||||
if (next_ip && IS_MOVK_R5(insn_word))
|
{
|
||||||
|
ip = next_ip;
|
||||||
|
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
||||||
|
auto_depth += insn_word;
|
||||||
|
|
||||||
|
next_ip = NEXT_PROLOGUE_INSN (next_ip, limit, &insn_word);
|
||||||
|
auto_depth += insn_word;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Work out which regs are stored where */
|
||||||
|
while (next_ip && IS_PUSH (insn_word))
|
||||||
{
|
{
|
||||||
ip = next_ip;
|
ip = next_ip;
|
||||||
next_ip = NEXT_PROLOGUE_INSN(ip, limit, &insn_word);
|
next_ip = NEXT_PROLOGUE_INSN (ip, limit, &insn_word);
|
||||||
auto_depth += insn_word;
|
fsr->regs[r] = after_prolog_fp + auto_depth;
|
||||||
ip +=4;
|
auto_depth += 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* The args are always reffed based from the stack pointer */
|
/* The args are always reffed based from the stack pointer */
|
||||||
fi->args_pointer = after_prolog_fp - auto_depth;
|
fi->args_pointer = after_prolog_fp;
|
||||||
/* Locals are always reffed based from the fp */
|
/* Locals are always reffed based from the fp */
|
||||||
fi->locals_pointer = after_prolog_fp ;
|
fi->locals_pointer = after_prolog_fp;
|
||||||
/* The PC is at a known place */
|
/* The PC is at a known place */
|
||||||
fi->from_pc = read_memory_short(after_prolog_fp + reg_save_depth-2 );
|
fi->from_pc = read_memory_short (after_prolog_fp + 2);
|
||||||
|
|
||||||
|
|
||||||
/* Rememeber any others too */
|
/* Rememeber any others too */
|
||||||
|
|
||||||
in_frame[PC_REGNUM] = 0;
|
in_frame[PC_REGNUM] = 0;
|
||||||
|
|
||||||
for (r = 0; r < NUM_REGS; r++)
|
if (have_fp)
|
||||||
{
|
/* We keep the old FP in the SP spot */
|
||||||
if (in_frame[r] != 1)
|
fsr->regs[SP_REGNUM] = (read_memory_short (fsr->regs[6]));
|
||||||
{
|
else
|
||||||
fsr->regs[r] = after_prolog_fp + reg_save_depth - in_frame[r] -2;
|
fsr->regs[SP_REGNUM] = after_prolog_fp + auto_depth;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fsr->regs[r] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (have_fp)
|
|
||||||
/* We keep the old FP in the SP spot */
|
|
||||||
fsr->regs[SP_REGNUM] = (read_memory_short(fsr->regs[6])) ;
|
|
||||||
else
|
|
||||||
fsr->regs[SP_REGNUM] = after_prolog_fp + reg_save_depth;
|
|
||||||
|
|
||||||
return (ip);
|
return (ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,8 +317,9 @@ init_extra_frame_info (fromleaf, fi)
|
|||||||
fi->args_pointer = 0; /* Unknown */
|
fi->args_pointer = 0; /* Unknown */
|
||||||
fi->locals_pointer = 0; /* Unknown */
|
fi->locals_pointer = 0; /* Unknown */
|
||||||
fi->from_pc = 0;
|
fi->from_pc = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the saved PC from this frame.
|
/* Return the saved PC from this frame.
|
||||||
|
|
||||||
If the frame has a memory copy of SRP_REGNUM, use that. If not,
|
If the frame has a memory copy of SRP_REGNUM, use that. If not,
|
||||||
@ -331,23 +327,23 @@ init_extra_frame_info (fromleaf, fi)
|
|||||||
|
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
frame_saved_pc (frame)
|
frame_saved_pc (frame)
|
||||||
FRAME frame;
|
FRAME frame;
|
||||||
|
|
||||||
{
|
{
|
||||||
return frame->from_pc;
|
return frame->from_pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CORE_ADDR
|
CORE_ADDR
|
||||||
frame_locals_address (fi)
|
frame_locals_address (fi)
|
||||||
struct frame_info *fi;
|
struct frame_info *fi;
|
||||||
{
|
{
|
||||||
if (!fi->locals_pointer)
|
if (!fi->locals_pointer)
|
||||||
{
|
{
|
||||||
struct frame_saved_regs ignore;
|
struct frame_saved_regs ignore;
|
||||||
get_frame_saved_regs(fi, &ignore);
|
|
||||||
|
|
||||||
}
|
get_frame_saved_regs (fi, &ignore);
|
||||||
|
|
||||||
|
}
|
||||||
return fi->locals_pointer;
|
return fi->locals_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,38 +354,87 @@ CORE_ADDR
|
|||||||
frame_args_address (fi)
|
frame_args_address (fi)
|
||||||
struct frame_info *fi;
|
struct frame_info *fi;
|
||||||
{
|
{
|
||||||
if (!fi->args_pointer)
|
if (!fi->args_pointer)
|
||||||
{
|
{
|
||||||
struct frame_saved_regs ignore;
|
struct frame_saved_regs ignore;
|
||||||
get_frame_saved_regs(fi, &ignore);
|
|
||||||
|
get_frame_saved_regs (fi, &ignore);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return fi->args_pointer;
|
return fi->args_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
void h8300_pop_frame()
|
h8300_pop_frame ()
|
||||||
{
|
{
|
||||||
unsigned regnum;
|
unsigned regnum;
|
||||||
struct frame_saved_regs fsr;
|
struct frame_saved_regs fsr;
|
||||||
struct frame_info *fi;
|
struct frame_info *fi;
|
||||||
|
|
||||||
FRAME frame = get_current_frame();
|
FRAME frame = get_current_frame ();
|
||||||
fi = get_frame_info(frame);
|
|
||||||
get_frame_saved_regs(fi, &fsr);
|
|
||||||
|
|
||||||
for (regnum = 0; regnum < NUM_REGS; regnum ++)
|
fi = get_frame_info (frame);
|
||||||
{
|
get_frame_saved_regs (fi, &fsr);
|
||||||
if(fsr.regs[regnum])
|
|
||||||
|
for (regnum = 0; regnum < NUM_REGS; regnum++)
|
||||||
{
|
{
|
||||||
write_register(regnum, read_memory_short (fsr.regs[regnum]));
|
if (fsr.regs[regnum])
|
||||||
|
{
|
||||||
|
write_register (regnum, read_memory_short (fsr.regs[regnum]));
|
||||||
|
}
|
||||||
|
|
||||||
|
flush_cached_frames ();
|
||||||
|
set_current_frame (create_new_frame (read_register (FP_REGNUM),
|
||||||
|
read_pc ()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
flush_cached_frames();
|
|
||||||
set_current_frame(create_new_frame(read_register(FP_REGNUM),
|
|
||||||
read_pc()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_register_hook (regno)
|
||||||
|
{
|
||||||
|
if (regno == 8)
|
||||||
|
{
|
||||||
|
/* CCR register */
|
||||||
|
|
||||||
|
int C, Z, N, V;
|
||||||
|
unsigned char b[2];
|
||||||
|
unsigned char l;
|
||||||
|
|
||||||
|
read_relative_register_raw_bytes (regno, b);
|
||||||
|
l = b[1];
|
||||||
|
printf ("\t");
|
||||||
|
printf ("I-%d - ", (l & 0x80) != 0);
|
||||||
|
printf ("H-%d - ", (l & 0x20) != 0);
|
||||||
|
N = (l & 0x8) != 0;
|
||||||
|
Z = (l & 0x4) != 0;
|
||||||
|
V = (l & 0x2) != 0;
|
||||||
|
C = (l & 0x1) != 0;
|
||||||
|
printf ("N-%d ", N);
|
||||||
|
printf ("Z-%d ", Z);
|
||||||
|
printf ("V-%d ", V);
|
||||||
|
printf ("C-%d ", C);
|
||||||
|
if ((C | Z) == 0)
|
||||||
|
printf ("u> ");
|
||||||
|
if ((C | Z) == 1)
|
||||||
|
printf ("u<= ");
|
||||||
|
if ((C == 0))
|
||||||
|
printf ("u>= ");
|
||||||
|
if (C == 1)
|
||||||
|
printf ("u< ");
|
||||||
|
if (Z == 0)
|
||||||
|
printf ("!= ");
|
||||||
|
if (Z == 1)
|
||||||
|
printf ("== ");
|
||||||
|
if ((N ^ V) == 0)
|
||||||
|
printf (">= ");
|
||||||
|
if ((N ^ V) == 1)
|
||||||
|
printf ("< ");
|
||||||
|
if ((Z | (N ^ V)) == 0)
|
||||||
|
printf ("> ");
|
||||||
|
if ((Z | (N ^ V)) == 1)
|
||||||
|
printf ("<= ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1269
gdb/remote-hms.c
1269
gdb/remote-hms.c
File diff suppressed because it is too large
Load Diff
293
gdb/remote-sim.c
Normal file
293
gdb/remote-sim.c
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
/* Remote debugging interface for generalized simulator
|
||||||
|
Copyright 1992 Free Software Foundation, Inc.
|
||||||
|
Contributed by Cygnus Support. Written by Steve Chamberlain
|
||||||
|
(sac@cygnus.com).
|
||||||
|
|
||||||
|
This file is part of GDB.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
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
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include "defs.h"
|
||||||
|
#include "inferior.h"
|
||||||
|
#include "wait.h"
|
||||||
|
#include "value.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include "terminal.h"
|
||||||
|
#include "target.h"
|
||||||
|
#include "gdbcore.h"
|
||||||
|
|
||||||
|
/* Forward data declarations */
|
||||||
|
extern struct target_ops sim_ops; /* Forward declaration */
|
||||||
|
|
||||||
|
int
|
||||||
|
sim_write_inferior_memory (memaddr, myaddr, len)
|
||||||
|
CORE_ADDR memaddr;
|
||||||
|
unsigned char *myaddr;
|
||||||
|
int len;
|
||||||
|
{
|
||||||
|
return sim_write(memaddr, myaddr, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
store_register(regno)
|
||||||
|
int regno;
|
||||||
|
{
|
||||||
|
if (regno == -1)
|
||||||
|
{
|
||||||
|
for (regno = 0; regno < NUM_REGS; regno++)
|
||||||
|
store_register(regno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sim_store_register(regno, read_register(regno));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Download a file specified in 'args', to the sim.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
sim_load(args,fromtty)
|
||||||
|
char *args;
|
||||||
|
int fromtty;
|
||||||
|
{
|
||||||
|
bfd *abfd;
|
||||||
|
asection *s;
|
||||||
|
|
||||||
|
inferior_pid = 0;
|
||||||
|
abfd = bfd_openr(args, (char*)0);
|
||||||
|
|
||||||
|
if (!abfd)
|
||||||
|
{
|
||||||
|
printf_filtered("Unable to open file %s\n", args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bfd_check_format(abfd, bfd_object) ==0)
|
||||||
|
{
|
||||||
|
printf_filtered("File is not an object file\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = abfd->sections;
|
||||||
|
while (s != (asection *)NULL)
|
||||||
|
{
|
||||||
|
if (s->flags & SEC_LOAD)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int delta = 4096;
|
||||||
|
char *buffer = xmalloc(delta);
|
||||||
|
printf_filtered("%s\t: 0x%4x .. 0x%4x ",
|
||||||
|
s->name, s->vma, s->vma + s->_raw_size);
|
||||||
|
for (i = 0; i < s->_raw_size; i+= delta)
|
||||||
|
{
|
||||||
|
int sub_delta = delta;
|
||||||
|
if (sub_delta > s->_raw_size - i)
|
||||||
|
sub_delta = s->_raw_size - i ;
|
||||||
|
|
||||||
|
bfd_get_section_contents(abfd, s, buffer, i, sub_delta);
|
||||||
|
sim_write_inferior_memory(s->vma + i, buffer, sub_delta);
|
||||||
|
printf_filtered("*");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
printf_filtered( "\n");
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
s = s->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
sim_store_register(PC_REGNUM, abfd->start_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is called not only when we first attach, but also when the
|
||||||
|
user types "run" after having attached. */
|
||||||
|
void
|
||||||
|
sim_create_inferior (execfile, args, env)
|
||||||
|
char *execfile;
|
||||||
|
char *args;
|
||||||
|
char **env;
|
||||||
|
{
|
||||||
|
int entry_pt;
|
||||||
|
|
||||||
|
if (args && *args)
|
||||||
|
error ("Can't pass arguments to remote sim process.");
|
||||||
|
|
||||||
|
if (execfile == 0 || exec_bfd == 0)
|
||||||
|
error ("No exec file specified");
|
||||||
|
|
||||||
|
entry_pt = (int) bfd_get_start_address (exec_bfd);
|
||||||
|
init_wait_for_inferior ();
|
||||||
|
insert_breakpoints ();
|
||||||
|
proceed(entry_pt, -1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
sim_open (name, from_tty)
|
||||||
|
char *name;
|
||||||
|
int from_tty;
|
||||||
|
{
|
||||||
|
if(name == 0)
|
||||||
|
{
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
push_target (&sim_ops);
|
||||||
|
target_fetch_registers(-1);
|
||||||
|
printf_filtered("Connected to the simulator.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close out all files and local state before this target loses control. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
sim_close (quitting)
|
||||||
|
int quitting;
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Terminate the open connection to the remote debugger.
|
||||||
|
Use this when you want to detach and do something else
|
||||||
|
with your gdb. */
|
||||||
|
int
|
||||||
|
sim_detach (args,from_tty)
|
||||||
|
char *args;
|
||||||
|
int from_tty;
|
||||||
|
{
|
||||||
|
pop_target(); /* calls sim_close to do the real work */
|
||||||
|
if (from_tty)
|
||||||
|
printf_filtered ("Ending remote %s debugging\n", target_shortname);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tell the remote machine to resume. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Wait until the remote machine stops, then return,
|
||||||
|
storing status in STATUS just as `wait' would. */
|
||||||
|
|
||||||
|
int
|
||||||
|
sim_wait (status)
|
||||||
|
WAITTYPE *status;
|
||||||
|
{
|
||||||
|
WSETSTOP(*status, sim_stop_signal());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
fetch_register(regno)
|
||||||
|
int regno;
|
||||||
|
{
|
||||||
|
if (regno == -1)
|
||||||
|
{
|
||||||
|
for (regno = 0; regno < NUM_REGS; regno++)
|
||||||
|
fetch_register(regno);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[MAX_REGISTER_RAW_SIZE];
|
||||||
|
sim_fetch_register(regno, buf);
|
||||||
|
supply_register(regno, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
sim_xfer_inferior_memory(memaddr, myaddr, len, write, target)
|
||||||
|
CORE_ADDR memaddr;
|
||||||
|
char *myaddr;
|
||||||
|
int len;
|
||||||
|
int write;
|
||||||
|
struct target_ops *target; /* ignored */
|
||||||
|
{
|
||||||
|
if (write)
|
||||||
|
{
|
||||||
|
sim_write(memaddr, myaddr, len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sim_read(memaddr, myaddr, len);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This routine is run as a hook, just before the main command loop is
|
||||||
|
entered. If gdb is configured for the H8, but has not had its
|
||||||
|
target specified yet, this will loop prompting the user to do so.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
sim_before_main_loop ()
|
||||||
|
{
|
||||||
|
push_target (&sim_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int rem_resume(a,b)
|
||||||
|
{
|
||||||
|
sim_resume(a,b);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pstore()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
/* Define the target subroutine names */
|
||||||
|
|
||||||
|
struct target_ops sim_ops =
|
||||||
|
{
|
||||||
|
"sim", "simulator",
|
||||||
|
"Use the simulator",
|
||||||
|
sim_open, sim_close,
|
||||||
|
0, sim_detach, rem_resume, sim_wait, /* attach */
|
||||||
|
fetch_register, store_register,
|
||||||
|
pstore,
|
||||||
|
sim_xfer_inferior_memory,
|
||||||
|
0,
|
||||||
|
0, 0, /* Breakpoints */
|
||||||
|
0, 0, 0, 0, 0, /* Terminal handling */
|
||||||
|
pstore,
|
||||||
|
sim_load,
|
||||||
|
0, /* lookup_symbol */
|
||||||
|
sim_create_inferior, /* create_inferior */
|
||||||
|
pstore, /* mourn_inferior FIXME */
|
||||||
|
0, /* can_run */
|
||||||
|
0, /* notice_signals */
|
||||||
|
process_stratum, 0, /* next */
|
||||||
|
1, 1, 1, 1, 1, /* all mem, mem, stack, regs, exec */
|
||||||
|
0,0, /* Section pointers */
|
||||||
|
OPS_MAGIC, /* Always the last thing */
|
||||||
|
};
|
||||||
|
|
||||||
|
/***********************************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
_initialize_remote_sim ()
|
||||||
|
{
|
||||||
|
add_target (&sim_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -77,17 +77,8 @@ UNSIGNED_SHORT(read_memory_integer (read_register (SP_REGNUM), 2))
|
|||||||
|
|
||||||
#define INNER_THAN <
|
#define INNER_THAN <
|
||||||
|
|
||||||
/* Sequence of bytes for breakpoint instruction.
|
|
||||||
This is a TRAP instruction. The last 4 bits (0xf below) is the
|
|
||||||
vector. Systems which don't use 0xf should define BPT_VECTOR
|
|
||||||
themselves before including this file. */
|
|
||||||
|
|
||||||
|
#define BREAKPOINT {0x53, 0x00}
|
||||||
#define BPT_VECTOR 0xf
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define BREAKPOINT {0x4e, (0x40 | BPT_VECTOR)}
|
|
||||||
|
|
||||||
|
|
||||||
/* If your kernel resets the pc after the trap happens you may need to
|
/* If your kernel resets the pc after the trap happens you may need to
|
||||||
@ -305,3 +296,6 @@ typedef unsigned short INSN_WORD;
|
|||||||
#define read_memory_short(x) (read_memory_integer(x,2) & 0xffff)
|
#define read_memory_short(x) (read_memory_integer(x,2) & 0xffff)
|
||||||
#define DONT_USE_REMOTE
|
#define DONT_USE_REMOTE
|
||||||
|
|
||||||
|
|
||||||
|
#define PRINT_REGISTER_HOOK(regno) print_register_hook(regno)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user