From: Zdenek Radouch Date: Thu, 7 Jan 1999 22:54:18 +0000 (+0000) Subject: Beta version of the FR30 port. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c3101060cb8d12b022a9475395230909cc59c03;p=binutils-gdb.git Beta version of the FR30 port. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6276a25bb95..d30ab2a3c65 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ + +Thu Jan 7 17:50:15 EST 1999 Zdenek Radouch (radouch@cygnus.com) + Beta FR30 port. + * fr30-tdep.c + * config/fr30/tm-fr30.h + Wed Jan 6 12:28:35 1999 David Taylor * configure.in: Add an --enable-tui argument. Construct diff --git a/gdb/config/fr30/tm-fr30.h b/gdb/config/fr30/tm-fr30.h index 8214f7797aa..3870f88483a 100644 --- a/gdb/config/fr30/tm-fr30.h +++ b/gdb/config/fr30/tm-fr30.h @@ -102,13 +102,9 @@ extern void fr30_pop_frame PARAMS ((void)); #define CALL_DUMMY_LOCATION AT_ENTRY_POINT #define FIX_CALL_DUMMY(DUMMY, START, FUNADDR, NARGS, ARGS, TYPE, GCCP) #define CALL_DUMMY_ADDRESS() entry_point_address () -extern CORE_ADDR fr30_push_return_address PARAMS ((CORE_ADDR, CORE_ADDR)); -#define PUSH_RETURN_ADDRESS(PC, SP) fr30_push_return_address (PC, SP) - - +#define PUSH_RETURN_ADDRESS(PC, SP) (write_register(RP_REGNUM, CALL_DUMMY_ADDRESS()), SP) #define PUSH_DUMMY_FRAME generic_push_dummy_frame () - /* Number of bytes at start of arglist that are not really args. */ #define FRAME_ARGS_SKIP 0 @@ -120,7 +116,8 @@ extern CORE_ADDR fr30_push_return_address PARAMS ((CORE_ADDR, CORE_ADDR)); a function return value of type TYPE, and copy that, in virtual format, into VALBUF. */ #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ - memcpy (VALBUF, REGBUF + REGISTER_BYTE(RETVAL_REG), TYPE_LENGTH (TYPE)) + memcpy (VALBUF, REGBUF + REGISTER_BYTE(RETVAL_REG) + \ + (TYPE_LENGTH(TYPE) < 4 ? 4 - TYPE_LENGTH(TYPE) : 0), TYPE_LENGTH (TYPE)) /* Extract from an array REGBUF containing the (raw) register state the address in which a function should return its structure value, @@ -132,8 +129,6 @@ extern CORE_ADDR fr30_push_return_address PARAMS ((CORE_ADDR, CORE_ADDR)); #define STORE_STRUCT_RETURN(ADDR, SP) \ { write_register (RETVAL_REG, (ADDR)); } - - #define FRAME_ARGS_ADDRESS(fi) (fi->frame) #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) @@ -186,10 +181,6 @@ extern CORE_ADDR fr30_skip_prologue PARAMS ((CORE_ADDR pc)); /* Define this for Wingdb */ #define TARGET_FR30 -#if(1) /* Z.R. */ - -/*ARM example*/ - /* IEEE format floating point */ #define IEEE_FLOAT @@ -208,8 +199,6 @@ extern CORE_ADDR fr30_skip_prologue PARAMS ((CORE_ADDR pc)); (FRAMELESS) = (after_prologue == func_start); \ } -/*V850 example*/ - extern void fr30_init_extra_frame_info PARAMS ((struct frame_info *fi)); #define INIT_EXTRA_FRAME_INFO(fromleaf, fi) fr30_init_extra_frame_info (fi) @@ -224,7 +213,9 @@ fr30_push_arguments PARAMS ((int nargs, struct value **args, CORE_ADDR sp, #define PC_IN_CALL_DUMMY(PC, SP, FP) generic_pc_in_call_dummy (PC, SP) -#define USE_STRUCT_CONVENTION(GCC_P, TYPE) \ - (TYPE_NFIELDS (TYPE) > 1 || TYPE_LENGTH (TYPE) > 4) - -#endif /* Z.R. */ +/* always pass struct by value as a pointer */ +/* XXX Z.R. GCC does not do that today */ +#define REG_STRUCT_HAS_ADDR(gcc_p,type) \ + ((TYPE_LENGTH(type) > 4) && (TYPE_LENGTH(type) & 0x3)) +/* alway return struct by value by input pointer */ +#define USE_STRUCT_CONVENTION(GCC_P, TYPE) 1 diff --git a/gdb/fr30-tdep.c b/gdb/fr30-tdep.c index c6d257f72c6..0d442dafa4d 100644 --- a/gdb/fr30-tdep.c +++ b/gdb/fr30-tdep.c @@ -1,5 +1,5 @@ /* Target-dependent code for the Fujitsu FR30. - Copyright 1996, Free Software Foundation, Inc. + Copyright 1999, Free Software Foundation, Inc. This file is part of GDB. @@ -28,12 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gdbcore.h" #include "symfile.h" -__t(int l, char *s, int a) -{ - fprintf(stderr, "(%d): %s: 0x%08x\n", l, s, a); -} -#define T(s, a) __t(__LINE__, s, (int)(a)) - /* Function: pop_frame This routine gets called when either the user uses the `return' command, or the call dummy breakpoint gets hit. */ @@ -43,6 +37,7 @@ fr30_pop_frame () { struct frame_info *frame = get_current_frame(); int regnum; + CORE_ADDR sp = read_register(SP_REGNUM); if (PC_IN_CALL_DUMMY(frame->pc, frame->frame, frame->frame)) generic_pop_dummy_frame (); @@ -51,14 +46,13 @@ fr30_pop_frame () write_register (PC_REGNUM, FRAME_SAVED_PC (frame)); for (regnum = 0; regnum < NUM_REGS; regnum++) - if (frame->fsr.regs[regnum] != 0) + if (frame->fsr.regs[regnum] != 0) { write_register (regnum, read_memory_unsigned_integer (frame->fsr.regs[regnum], REGISTER_RAW_SIZE(regnum))); - - write_register (SP_REGNUM, read_register (frame->framereg)); + } + write_register (SP_REGNUM, sp + frame->framesize); } - flush_cached_frames (); } @@ -91,6 +85,18 @@ fr30_skip_prologue(CORE_ADDR pc) } +/* Function: push_arguments + Setup arguments and RP for a call to the target. First four args + go in FIRST_ARGREG -> LAST_ARGREG, subsequent args go on stack... + Structs are passed by reference. XXX not right now Z.R. + 64 bit quantities (doubles and long longs) may be split between + the regs and the stack. + When calling a function that returns a struct, a pointer to the struct + is passed in as a secret first argument (always in FIRST_ARGREG). + + Stack space for the args has NOT been allocated: that job is up to us. +*/ + CORE_ADDR fr30_push_arguments(nargs, args, sp, struct_return, struct_addr) int nargs; @@ -117,15 +123,7 @@ fr30_push_arguments(nargs, args, sp, struct_return, struct_addr) if (struct_return) write_register (argreg++, struct_addr); -#if(0) - /* 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 = REGISTER_SIZE * 4; -#else -/* XXX which ABI are we using ? Z.R. */ stack_offset = 0; -#endif /* Process args from left to right. Store as many as allowed in registers, save the rest to be pushed on the stack */ @@ -244,8 +242,9 @@ save_prologue_cache (fi) prologue_cache.framesize = fi->framesize; prologue_cache.frameoffset = fi->frameoffset; - for (i = 0; i <= NUM_REGS; i++) + for (i = 0; i <= NUM_REGS; i++) { prologue_cache.fsr.regs[i] = fi->fsr.regs[i]; + } } @@ -289,11 +288,9 @@ fr30_scan_prologue (fi) } else { - T("NIY", 0); - /* XXX ??? Z.R. Get address of the stmfd in the prologue of the callee; the saved - PC is the address of the stmfd + 12. */ + /* XXX Z.R. What now??? The following is entirely bogus */ prologue_start = (read_memory_integer (fi->frame, 4) & 0x03fffffc) - 12; - prologue_end = prologue_start + 40; /* FIXME: should be big enough */ + prologue_end = prologue_start + 40; } /* Now search the prologue looking for instructions that set up the @@ -324,6 +321,13 @@ fr30_scan_prologue (fi) fi->fsr.regs[reg] = sp_offset; } } + else if((insn & 0xfff0) == 0x1700) /* st rx,@-r15 */ + { + int reg = insn & 0xf; + + sp_offset -= 4; + fi->fsr.regs[reg] = sp_offset; + } else if((insn & 0xff00) == 0x0f00) /* enter */ { fp_offset = fi->fsr.regs[FP_REGNUM] = sp_offset - 4; @@ -420,12 +424,12 @@ fr30_init_extra_frame_info (fi) if (fi->next->fsr.regs[fi->framereg] != 0) fi->frame = read_memory_integer (fi->next->fsr.regs[fi->framereg], 4); - /* Calculate actual addresses of saved registers using offsets determined by fr30_scan_prologue. */ for (reg = 0; reg < NUM_REGS; reg++) - if (fi->fsr.regs[reg] != 0) + if (fi->fsr.regs[reg] != 0) { fi->fsr.regs[reg] += fi->frame + fi->framesize - fi->frameoffset; + } } /* Function: find_callers_reg @@ -502,112 +506,6 @@ fr30_frame_chain (fi) return fi->frame + fi->framesize; } -/* Function: push_arguments - Setup arguments and RP for a call to the target. First four args - go in R4->R7, subsequent args go on stack... Structs - are passed by reference. 64 bit quantities (doubles and long - longs) may be split between the regs and the stack. When calling a - function that returns a struct, a pointer to the struct is passed - in as a secret first argument (always in R6). - - Stack space for the args has NOT been allocated: that job is up to us. - */ - -#if(0) /* Z.R. XXX */ -CORE_ADDR -fr30_push_arguments (nargs, args, sp, struct_return, struct_addr) - int nargs; - value_ptr *args; - CORE_ADDR sp; - unsigned char struct_return; - CORE_ADDR struct_addr; -{ - int argreg; - int argnum; - int len = 0; - int stack_offset; - - /* First, just for safety, make sure stack is aligned */ - sp &= ~3; - - /* Now make space on the stack for the args. */ - for (argnum = 0; argnum < nargs; argnum++) - len += ((TYPE_LENGTH(VALUE_TYPE(args[argnum])) + 3) & ~3); - sp -= len; /* possibly over-allocating, but it works... */ - /* (you might think we could allocate 16 bytes */ - /* less, but the ABI seems to use it all! ) */ - argreg = ARG0_REGNUM; - - /* the struct_return pointer occupies the first parameter-passing reg */ - if (struct_return) - write_register (argreg++, struct_addr); - - stack_offset = 16; - /* The offset onto the stack at which we will start copying parameters - (after the registers are used up) begins at 16 rather than at zero. - I don't really know why, that's just the way it seems to work. */ - - /* Now load as many as possible of the first arguments into - registers, and push the rest onto the stack. There are 16 bytes - in four registers available. Loop thru args from first to last. */ - for (argnum = 0; argnum < nargs; argnum++) - { - int len; - char *val; - char valbuf[REGISTER_RAW_SIZE(ARG0_REGNUM)]; - - if (TYPE_CODE (VALUE_TYPE (*args)) == TYPE_CODE_STRUCT - && TYPE_LENGTH (VALUE_TYPE (*args)) > 8) - { - store_address (valbuf, 4, VALUE_ADDRESS (*args)); - len = 4; - val = valbuf; - } - else - { - len = TYPE_LENGTH (VALUE_TYPE (*args)); - val = (char *)VALUE_CONTENTS (*args); - } - - while (len > 0) - if (argreg <= ARGLAST_REGNUM) - { - CORE_ADDR regval; - - regval = extract_address (val, REGISTER_RAW_SIZE (argreg)); - write_register (argreg, regval); - - len -= REGISTER_RAW_SIZE (argreg); - val += REGISTER_RAW_SIZE (argreg); - argreg++; - } - else - { - write_memory (sp + stack_offset, val, 4); - - len -= 4; - val += 4; - stack_offset += 4; - } - args++; - } - return sp; -} -#endif /* Z.R. */ - -/* Function: push_return_address (pc) - Set up the return address for the inferior function call. - Needed for targets where we don't actually execute a JSR/BSR instruction */ - -CORE_ADDR -fr30_push_return_address (pc, sp) - CORE_ADDR pc; - CORE_ADDR sp; -{ - write_register (RP_REGNUM, CALL_DUMMY_ADDRESS ()); - return sp; -} - /* Function: frame_saved_pc Find the caller of this frame. We do this by seeing if RP_REGNUM is saved in the stack anywhere, otherwise we get it from the @@ -625,22 +523,6 @@ fr30_frame_saved_pc (fi) return fr30_find_callers_reg (fi, RP_REGNUM); } -#if(0) /* Z.R. XXX */ -void -get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) - char *raw_buffer; - int *optimized; - CORE_ADDR *addrp; - struct frame_info *frame; - int regnum; - enum lval_type *lval; -{ - generic_get_saved_register (raw_buffer, optimized, addrp, - frame, regnum, lval); -} -#endif /* Z.R. */ - - /* Function: fix_call_dummy Pokes the callee function's address into the CALL_DUMMY assembly stub. Assumes that the CALL_DUMMY looks like this: @@ -668,4 +550,3 @@ fr30_fix_call_dummy (dummy, sp, fun, nargs, args, type, gcc_p) store_unsigned_integer ((unsigned int *)&dummy[0], 2, offset24 >> 16); return 0; } -