⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tm-29k.h

📁 早期freebsd实现
💻 H
📖 第 1 页 / 共 2 页
字号:
   code (i.e. the line of the open brace, i.e. the prologue) of a function   before trying to print arguments or anything.   The following diagram attempts to depict what is going on in memory   (see also the _am29k user's guide_) and also how that interacts with   GDB frames.  We arbitrarily pick fci->frame to point the same place   as the register stack pointer; since we set it ourself in   INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_*   macros, it doesn't really matter exactly how we   do it.  However, note that FRAME_FP is used in two ways in GDB:   (1) as a "magic cookie" which uniquely identifies frames (even over   calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK])   as the value of SP_REGNUM before the dummy frame was pushed.  These   two meanings would be incompatible for the 29k if we defined   CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it).   Also note that "lr1" below, while called a frame pointer   in the user's guide, has only one function:  To determine whether   registers need to be filled in the function epilogue.   Consider the code:              < call bar>       	loc1: . . .        bar:  sub gr1,gr1,rsize_b	      . . .	      add mfp,msp,0	      sub msp,msp,msize_b	      . . .	      < call foo >	loc2: . . .        foo:  sub gr1,gr1,rsize_f	      . . .	      add mfp,msp,0	      sub msp,msp,msize_f	      . . .        loc3: < suppose the inferior stops here >                   memory stack      register stack		   |           |     |____________|		   |           |     |____loc1____|	  +------->|___________|     |            |   ^	  |        | ^         |     |  locals_b  |   |	  |        | |         |     |____________|   |	  |        | |         |     |            |   | rsize_b	  |        | | msize_b |     | args_to_f  |   |	  |        | |         |     |____________|   |	  |        | |         |     |____lr1_____|   V	  |        | V         |     |____loc2____|<----------------+	  |   +--->|___________|<---------mfp     |   ^             |	  |   |    | ^         |     |  locals_f  |   |             |	  |   |    | | msize_f |     |____________|   |             |	  |   |    | |         |     |            |   | rsize_f     |	  |   |    | V         |     |   args     |   |             |	  |   |    |___________|<msp |____________|   |             |	  |   |                      |_____lr1____|   V             |	  |   |                      |___garbage__| <- gr1 <----+   | 	  |   |                 		                |   |          |   |                 		                |   |	  |   |	       	       	     pc=loc3	                |   |	  |   |         		      	                |   |	  |   |         		      	                |   |	  |   |            frame cache	      	                |   |          |   |       |_________________|     	                |   |          |   |       |rsize=rsize_b    |     	                |   |          |   |       |msize=msize_b    |     	                |   |          +---|--------saved_msp        |     	                |   |              |       |frame------------------------------------|---+              |       |pc=loc2          |                       |              |       |_________________|                       |              |       |rsize=rsize_f    |                       |              |       |msize=msize_f    |                       |              +--------saved_msp        |                       |                      |frame------------------------------------+                      |pc=loc3          |                      |_________________|   So, is that sufficiently confusing?  Welcome to the 29000.   Notes:   * The frame for foo uses a memory frame pointer but the frame for     bar does not.  In the latter case the saved_msp is     computed by adding msize to the saved_msp of the     next frame.   * msize is in the frame cache only for high C's sake.  */void read_register_stack ();long read_register_stack_integer ();#define EXTRA_FRAME_INFO  \  CORE_ADDR saved_msp;    \  unsigned int rsize;     \  unsigned int msize;	  \  unsigned char flags;/* Bits for flags in EXTRA_FRAME_INFO */#define TRANSPARENT	0x1		/* This is a transparent frame */#define MFP_USED	0x2		/* A memory frame pointer is used *//* Because INIT_FRAME_PC gets passed fromleaf, that's where we init   not only ->pc and ->frame, but all the extra stuff, when called from   get_prev_frame_info, that is.  */#define INIT_EXTRA_FRAME_INFO(fromleaf, fci)  init_extra_frame_info(fci)void init_extra_frame_info ();#define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci)void init_frame_pc ();/* FRAME_CHAIN takes a FRAME   and produces the frame's chain-pointer.   However, if FRAME_CHAIN_VALID returns zero,   it means the given frame is the outermost one and has no caller.  *//* On the 29k, the nominal address of a frame is the address on the   register stack of the return address (the one next to the incoming   arguments, not down at the bottom so nominal address == stack pointer).   GDB expects "nominal address" to equal contents of FP_REGNUM,   at least when it comes time to create the innermost frame.   However, that doesn't work for us, so when creating the innermost   frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO.  *//* These are mostly dummies for the 29k because INIT_FRAME_PC   sets prev->frame instead.  */#define FRAME_CHAIN(thisframe) ((thisframe)->frame + (thisframe)->rsize)/* Determine if the frame has a 'previous' and back-traceable frame. */#define FRAME_IS_UNCHAINED(frame)	((frame)->flags & TRANSPARENT)/* Find the previous frame of a transparent routine. * For now lets not try and trace through a transparent routine (we might  * have to assume that all transparent routines are traps). */#define FIND_PREV_UNCHAINED_FRAME(frame)	0/* Define other aspects of the stack frame.  *//* A macro that tells us whether the function invocation represented   by FI does not have a frame on the stack associated with it.  If it   does not, FRAMELESS is set to 1, else 0.  */#define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \  (FRAMELESS) = frameless_look_for_prologue(FI)/* Saved pc (i.e. return address).  */#define FRAME_SAVED_PC(fraim) \  (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4))/* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their   offsets being relative to the memory stack pointer (high C) or   saved_msp (gcc).  */#define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi)extern CORE_ADDR frame_locals_address ();/* Return number of args passed to a frame.   Can return -1, meaning no way to tell.  *//* While we could go the effort of finding the tags word and getting   the argcount field from it,   (1) It only counts arguments in registers, i.e. the first 16 words       of arguments   (2) It gives the number of arguments the function was declared with       not how many it was called with (or some variation, like all 16       words for varadic functions).  This makes argcount pretty much       redundant with -g info, even for varadic functions.   So don't bother.  */#define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1)#define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi)/* Return number of bytes at start of arglist that are not really args.  */#define FRAME_ARGS_SKIP 0/* Provide our own get_saved_register.  HAVE_REGISTER_WINDOWS is insufficient   because registers get renumbered on the 29k without getting saved.  */#define GET_SAVED_REGISTER/* Call function stuff.  *//* The dummy frame looks like this (see also the general frame picture   above):					register stack	                	      |                |  frame for function               	                      |   locals_sproc |  executing at time                                      |________________|  of call_function.                     		      |	               |  We must not disturb                     		      |	args_out_sproc |  it.        memory stack 		      |________________|                     		      |____lr1_sproc___|<-+       |            |		      |__retaddr_sproc_|  | <-- gr1 (at start)       |____________|<-msp 0 <-----------mfp_dummy_____|  |       |            |  (at start)     |  save regs     |  |       | arg_slop   |		      |  pc0,pc1       |  |       | (16 words) |		      | gr96-gr124     |  |       |____________|<-msp 1--after   | sr160-sr162    |  |       |            | PUSH_DUMMY_FRAME| sr128-sr135    |  |       | struct ret |                 |________________|  |       | 17+        |                 |                |  |        |____________|<- lrp           | args_out_dummy |  |       | struct ret |		      |  (16 words)    |  |       | 16         |		      |________________|  |       | (16 words) |                 |____lr1_dummy___|--+       |____________|<- msp 2--after  |_retaddr_dummy__|<- gr1 after       |            | struct ret      |                |   PUSH_DUMMY_FRAME       | margs17+   | area allocated  |  locals_inf    |       |            |                 |________________|    called       |____________|<- msp 4--when   |                |    function's       |            |   inf called    | args_out_inf   |    frame (set up       | margs16    |                 |________________|    by called       | (16 words) |                 |_____lr1_inf____|    function).       |____________|<- msp 3--after  |       .        |       |            |   args pushed   |       .        |       |            |	              |       .        |                                      |                |   arg_slop: This area is so that when the call dummy adds 16 words to      the msp, it won't end up larger than mfp_dummy (it is needed in the      case where margs and struct_ret do not add up to at least 16 words).   struct ret:  This area is allocated by GDB if the return value is more      than 16 words.  struct ret_16 is not used on the 29k.   margs:  Pushed by GDB.  The call dummy copies the first 16 words to      args_out_dummy.   retaddr_sproc:  Contains the PC at the time we call the function.      set by PUSH_DUMMY_FRAME and read by POP_FRAME.   retaddr_dummy:  This points to a breakpoint instruction in the dummy.  *//* Rsize for dummy frame, in bytes.  *//* Bytes for outgoing args, lr1, and retaddr.  */#define DUMMY_ARG (2 * 4 + 16 * 4)/* Number of special registers (sr128-) to save.  */#define DUMMY_SAVE_SR128 8/* Number of special registers (sr160-) to save.  */#define DUMMY_SAVE_SR160 3/* Number of general (gr96- or gr64-) registers to save.  */#define DUMMY_SAVE_GREGS 29#define DUMMY_FRAME_RSIZE \(4 /* mfp_dummy */     	  \ + 2 * 4  /* pc0, pc1 */  \ + DUMMY_SAVE_GREGS * 4   \ + DUMMY_SAVE_SR160 * 4	  \ + DUMMY_SAVE_SR128 * 4	  \ + DUMMY_ARG		  \ + 4 /* pad to doubleword */ )/* Push an empty stack frame, to record the current PC, etc.  */#define PUSH_DUMMY_FRAME push_dummy_frame()extern void push_dummy_frame ();/* Discard from the stack the innermost frame,   restoring all saved registers.  */#define POP_FRAME pop_frame()extern void pop_frame ();/* This sequence of words is the instructions   mtsrim cr, 15   loadm 0, 0, lr2, msp     ; load first 16 words of arguments into registers   add msp, msp, 16 * 4     ; point to the remaining arguments CONST_INSN:   const lr0,inf		; (replaced by       half of target addr)   consth lr0,inf		; (replaced by other half of target addr)   calli lr0, lr0    aseq 0x40,gr1,gr1   ; nop BREAKPT_INSN:   asneq 0x50,gr1,gr1  ; breakpoint	(replaced by local breakpoint insn)   */#if TARGET_BYTE_ORDER == HOST_BYTE_ORDER#define BS(const)	const#else#define	BS(const)	(((const) & 0xff) << 24) |	\			(((const) & 0xff00) << 8) |	\			(((const) & 0xff0000) >> 8) |	\			(((const) & 0xff000000) >> 24)#endif/* Position of the "const" and blkt instructions within CALL_DUMMY in bytes. */#define CONST_INSN (3 * 4)#define BREAKPT_INSN (7 * 4)#define CALL_DUMMY {	\		BS(0x0400870f),\		BS(0x36008200|(MSP_HW_REGNUM)), \		BS(0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16)), \		BS(0x03ff80ff),	\		BS(0x02ff80ff),	\		BS(0xc8008080),	\		BS(0x70400101),	\		BS(0x72500101)}#define CALL_DUMMY_LENGTH (8 * 4)#define CALL_DUMMY_START_OFFSET 0  /* Start execution at beginning of dummy *//* Helper macro for FIX_CALL_DUMMY.  WORDP is a long * which points to a   word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with   bits 0-7 and 8-15 of DATA (which is in host byte order).  */#if TARGET_BYTE_ORDER == BIG_ENDIAN#define STUFF_I16(WORDP, DATA) \  { \    *((char *)(WORDP) + 3) = ((DATA) & 0xff);\    *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\  }#else /* Target is little endian.  */#define STUFF_I16(WORDP, DATA) \  {    *(char *)(WORDP) = ((DATA) & 0xff);    *((char *)(WORDP) + 2) = (((DATA) >> 8) & 0xff);  }#endif /* Target is little endian.  *//* Insert the specified number of args and function address   into a call sequence of the above form stored at DUMMYNAME.  *//* Currently this stuffs in the address of the function that we are calling.   Since different 29k systems use different breakpoint instructions, it   also stuffs BREAKPOINT in the right place (to avoid having to   duplicate CALL_DUMMY in each tm-*.h file).  */#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p)   \  {\    STUFF_I16((char *)dummyname + CONST_INSN, fun);		\    STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16);	\  /* FIXME  memcpy ((char *)(dummyname) + BREAKPT_INSN, break_insn, 4); */ \  }/* 29k architecture has separate data & instruction memories -- wired to   different pins on the chip -- and can't execute the data memory.   Also, there should be space after text_end;   we won't get a SIGSEGV or scribble on data space.  */#define CALL_DUMMY_LOCATION AFTER_TEXT_END/* Because of this, we need (as a kludge) to know the addresses of the   text section.  */#define	NEED_TEXT_START_END/* How to translate register numbers in the .stab's into gdb's internal register   numbers.  We don't translate them, but we warn if an invalid register   number is seen.  Note that FIXME, we use the value "sym" as an implicit   argument in printing the error message.  It happens to be available where   this macro is used.  (This macro definition appeared in a late revision   of gdb-3.91.6 and is not well tested.  Also, it should be a "complaint".) */#define	STAB_REG_TO_REGNUM(num) \	(((num) > LR0_REGNUM + 127) \	   ? fprintf(stderr, 	\		"Invalid register number %d in symbol table entry for %s\n", \	         (num), SYMBOL_NAME (sym)), (num)	\	   : (num))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -