tm-a29k.h

来自「gdb是linux下的一个远程调试环境.能让你很方便地调试linux下的代码.」· C头文件 代码 · 共 723 行 · 第 1/3 页

H
723
字号
/* OBSOLETE  *//* OBSOLETE /* All regs are 4 bytes.  */ *//* OBSOLETE  *//* OBSOLETE #define REGISTER_RAW_SIZE(N) (4) *//* OBSOLETE  *//* OBSOLETE /* Number of bytes of storage in the program's representation *//* OBSOLETE    for register N.  */ *//* OBSOLETE  *//* OBSOLETE /* All regs are 4 bytes.  */ *//* OBSOLETE  *//* OBSOLETE #define REGISTER_VIRTUAL_SIZE(N) (4) *//* OBSOLETE  *//* OBSOLETE /* Largest value REGISTER_RAW_SIZE can have.  */ *//* OBSOLETE  *//* OBSOLETE #define MAX_REGISTER_RAW_SIZE (4) *//* OBSOLETE  *//* OBSOLETE /* Largest value REGISTER_VIRTUAL_SIZE can have.  */ *//* OBSOLETE  *//* OBSOLETE #define MAX_REGISTER_VIRTUAL_SIZE (4) *//* OBSOLETE  *//* OBSOLETE /* Return the GDB type object for the "standard" data type *//* OBSOLETE    of data in register N.  */ *//* OBSOLETE  *//* OBSOLETE #define REGISTER_VIRTUAL_TYPE(N) \ *//* OBSOLETE   (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM         \ *//* OBSOLETE     || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM     \ *//* OBSOLETE     || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM       \ *//* OBSOLETE     || (N) == NPC_REGNUM || (N) == PC2_REGNUM)                           \ *//* OBSOLETE    ? lookup_pointer_type (builtin_type_void) : builtin_type_int) *//* OBSOLETE  *//* OBSOLETE /* Store the address of the place in which to copy the structure the *//* OBSOLETE    subroutine will return.  This is called from call_function. */ *//* OBSOLETE /* On the a29k the LRP points to the part of the structure beyond the first *//* OBSOLETE    16 words.  */ *//* OBSOLETE #define STORE_STRUCT_RETURN(ADDR, SP) \ *//* OBSOLETE   write_register (LRP_REGNUM, (ADDR) + 16 * 4); *//* OBSOLETE  *//* OBSOLETE /* Should call_function allocate stack space for a struct return?  */ *//* OBSOLETE /* On the a29k objects over 16 words require the caller to allocate space.  */ *//* OBSOLETE extern use_struct_convention_fn a29k_use_struct_convention; *//* OBSOLETE #define USE_STRUCT_CONVENTION(gcc_p, type) a29k_use_struct_convention (gcc_p, type) *//* OBSOLETE  *//* OBSOLETE /* Extract from an array REGBUF containing the (raw) register state *//* OBSOLETE    a function return value of type TYPE, and copy that, in virtual format, *//* OBSOLETE    into VALBUF.  */ *//* OBSOLETE  *//* OBSOLETE #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF)	      \ *//* OBSOLETE   {    	       	       	       	       	       	       	       	       	   \ *//* OBSOLETE     int reg_length = TYPE_LENGTH (TYPE);				   \ *//* OBSOLETE     if (reg_length > 16 * 4)						   \ *//* OBSOLETE       {									   \ *//* OBSOLETE 	reg_length = 16 * 4;						   \ *//* OBSOLETE 	read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4,   \ *//* OBSOLETE 		     TYPE_LENGTH (TYPE) - 16 * 4);			   \ *//* OBSOLETE       }									   \ *//* OBSOLETE     memcpy ((VALBUF), ((int *)(REGBUF))+RETURN_REGNUM, reg_length);	   \ *//* OBSOLETE   } *//* OBSOLETE  *//* OBSOLETE /* Write into appropriate registers a function return value *//* OBSOLETE    of type TYPE, given in virtual format.  */ *//* OBSOLETE  *//* OBSOLETE #define STORE_RETURN_VALUE(TYPE,VALBUF) \ *//* OBSOLETE   {									  \ *//* OBSOLETE     int reg_length = TYPE_LENGTH (TYPE);				  \ *//* OBSOLETE     if (reg_length > 16 * 4)						  \ *//* OBSOLETE       {									  \ *//* OBSOLETE         reg_length = 16 * 4;						  \ *//* OBSOLETE         write_memory (read_register (LRP_REGNUM),			  \ *//* OBSOLETE 		      (char *)(VALBUF) + 16 * 4,			  \ *//* OBSOLETE 		      TYPE_LENGTH (TYPE) - 16 * 4);			  \ *//* OBSOLETE       }									  \ *//* OBSOLETE     write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF),  \ *//* OBSOLETE 			  TYPE_LENGTH (TYPE));				  \ *//* OBSOLETE   } *//* OBSOLETE /* *INDENT-OFF* */ *//* OBSOLETE /* The a29k user's guide documents well what the stacks look like. *//* OBSOLETE    But what isn't so clear there is how this interracts with the *//* OBSOLETE    symbols, or with GDB. *//* OBSOLETE    In the following saved_msp, saved memory stack pointer (which functions *//* OBSOLETE    as a memory frame pointer), means either *//* OBSOLETE    a register containing the memory frame pointer or, in the case of *//* OBSOLETE    functions with fixed size memory frames (i.e. those who don't use *//* OBSOLETE    alloca()), the result of the calculation msp + msize. *//* OBSOLETE  *//* OBSOLETE    LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp. *//* OBSOLETE    For high C, these are relative to msp (making alloca impossible). *//* OBSOLETE    LOC_REGISTER, LOC_REGPARM - The register number is the number at the *//* OBSOLETE    time the function is running (after the prologue), or in the case *//* OBSOLETE    of LOC_REGPARM, may be a register number in the range 160-175. *//* OBSOLETE  *//* OBSOLETE    The compilers do things like store an argument into memory, and then put out *//* OBSOLETE    a LOC_ARG for it, or put it into global registers and put out a *//* OBSOLETE    LOC_REGPARM.  Thus is it important to execute the first line of *//* OBSOLETE    code (i.e. the line of the open brace, i.e. the prologue) of a function *//* OBSOLETE    before trying to print arguments or anything. *//* OBSOLETE  *//* OBSOLETE    The following diagram attempts to depict what is going on in memory *//* OBSOLETE    (see also the _a29k user's guide_) and also how that interacts with *//* OBSOLETE    GDB frames.  We arbitrarily pick fci->frame to point the same place *//* OBSOLETE    as the register stack pointer; since we set it ourself in *//* OBSOLETE    INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_* *//* OBSOLETE    macros, it doesn't really matter exactly how we *//* OBSOLETE    do it.  However, note that FRAME_FP is used in two ways in GDB: *//* OBSOLETE    (1) as a "magic cookie" which uniquely identifies frames (even over *//* OBSOLETE    calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK]) *//* OBSOLETE    as the value of SP_REGNUM before the dummy frame was pushed.  These *//* OBSOLETE    two meanings would be incompatible for the a29k if we defined *//* OBSOLETE    CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it). *//* OBSOLETE    Also note that "lr1" below, while called a frame pointer *//* OBSOLETE    in the user's guide, has only one function:  To determine whether *//* OBSOLETE    registers need to be filled in the function epilogue. *//* OBSOLETE  *//* OBSOLETE    Consider the code: *//* OBSOLETE    < call bar> *//* OBSOLETE    loc1: . . . *//* OBSOLETE    bar:  sub gr1,gr1,rsize_b *//* OBSOLETE    . . . *//* OBSOLETE    add mfp,msp,0 *//* OBSOLETE    sub msp,msp,msize_b *//* OBSOLETE    . . . *//* OBSOLETE    < call foo > *//* OBSOLETE    loc2: . . . *//* OBSOLETE    foo:  sub gr1,gr1,rsize_f *//* OBSOLETE    . . . *//* OBSOLETE    add mfp,msp,0 *//* OBSOLETE    sub msp,msp,msize_f *//* OBSOLETE    . . . *//* OBSOLETE    loc3: < suppose the inferior stops here > *//* OBSOLETE  *//* OBSOLETE    memory stack      register stack *//* OBSOLETE    |           |     |____________| *//* OBSOLETE    |           |     |____loc1____| *//* OBSOLETE    +------->|___________|     |            |   ^ *//* OBSOLETE    |        | ^         |     |  locals_b  |   | *//* OBSOLETE    |        | |         |     |____________|   | *//* OBSOLETE    |        | |         |     |            |   | rsize_b *//* OBSOLETE    |        | | msize_b |     | args_to_f  |   | *//* OBSOLETE    |        | |         |     |____________|   | *//* OBSOLETE    |        | |         |     |____lr1_____|   V *//* OBSOLETE    |        | V         |     |____loc2____|<----------------+ *//* OBSOLETE    |   +--->|___________|<---------mfp     |   ^             | *//* OBSOLETE    |   |    | ^         |     |  locals_f  |   |             | *//* OBSOLETE    |   |    | | msize_f |     |____________|   |             | *//* OBSOLETE    |   |    | |         |     |            |   | rsize_f     | *//* OBSOLETE    |   |    | V         |     |   args     |   |             | *//* OBSOLETE    |   |    |___________|<msp |____________|   |             | *//* OBSOLETE    |   |                      |_____lr1____|   V             | *//* OBSOLETE    |   |                      |___garbage__| <- gr1 <----+   | *//* OBSOLETE    |   |                                                |   | *//* OBSOLETE    |   |                                                |   | *//* OBSOLETE    |   |                             pc=loc3                    |   | *//* OBSOLETE    |   |                                                |   | *//* OBSOLETE    |   |                                                |   | *//* OBSOLETE    |   |            frame cache                         |   | *//* OBSOLETE    |   |       |_________________|                      |   | *//* OBSOLETE    |   |       |rsize=rsize_b    |                      |   | *//* OBSOLETE    |   |       |msize=msize_b    |                      |   | *//* OBSOLETE    +---|--------saved_msp        |                      |   | *//* OBSOLETE    |       |frame------------------------------------|---+ *//* OBSOLETE    |       |pc=loc2          |                       | *//* OBSOLETE    |       |_________________|                       | *//* OBSOLETE    |       |rsize=rsize_f    |                       | *//* OBSOLETE    |       |msize=msize_f    |                       | *//* OBSOLETE    +--------saved_msp        |                       | *//* OBSOLETE    |frame------------------------------------+ *//* OBSOLETE    |pc=loc3          | *//* OBSOLETE    |_________________| *//* OBSOLETE  *//* OBSOLETE    So, is that sufficiently confusing?  Welcome to the 29000. *//* OBSOLETE    Notes: *//* OBSOLETE    * The frame for foo uses a memory frame pointer but the frame for *//* OBSOLETE    bar does not.  In the latter case the saved_msp is *//* OBSOLETE    computed by adding msize to the saved_msp of the *//* OBSOLETE    next frame. *//* OBSOLETE    * msize is in the frame cache only for high C's sake.  */ *//* OBSOLETE /* *INDENT-ON* */ *//* OBSOLETE  *//* OBSOLETE  *//* OBSOLETE void read_register_stack (); *//* OBSOLETE long read_register_stack_integer (); *//* OBSOLETE  *//* OBSOLETE #define FRAME_INIT_SAVED_REGS(fi)	/*no-op */ *//* OBSOLETE  *//* OBSOLETE #define EXTRA_FRAME_INFO  \ *//* OBSOLETE   CORE_ADDR saved_msp;    \ *//* OBSOLETE   unsigned int rsize;     \ *//* OBSOLETE   unsigned int msize;	  \ *//* OBSOLETE   unsigned char flags; *//* OBSOLETE  *//* OBSOLETE /* Bits for flags in EXTRA_FRAME_INFO */ *//* OBSOLETE #define TRANSPARENT_FRAME	0x1	/* This is a transparent frame */ *//* OBSOLETE #define MFP_USED		0x2	/* A memory frame pointer is used */ *//* OBSOLETE  *//* OBSOLETE /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init *//* OBSOLETE    not only ->pc and ->frame, but all the extra stuff, when called from *//* OBSOLETE    get_prev_frame, that is.  */ *//* OBSOLETE #define INIT_EXTRA_FRAME_INFO(fromleaf, fci)  init_extra_frame_info(fci) *//* OBSOLETE void init_extra_frame_info (); *//* OBSOLETE  *//* OBSOLETE #define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci) *//* OBSOLETE void init_frame_pc (); *//* OBSOLETE  *//* OBSOLETE  *//* OBSOLETE /* FRAME_CHAIN takes a FRAME *//* OBSOLETE    and produces the frame's chain-pointer. *//* OBSOLETE  *//* OBSOLETE    However, if FRAME_CHAIN_VALID returns zero, *//* OBSOLETE    it means the given frame is the outermost one and has no caller.  */ *//* OBSOLETE  *//* OBSOLETE /* On the a29k, the nominal address of a frame is the address on the *//* OBSOLETE    register stack of the return address (the one next to the incoming *//* OBSOLETE    arguments, not down at the bottom so nominal address == stack pointer). *//* OBSOLETE  *//* OBSOLETE    GDB expects "nominal address" to equal contents of FP_REGNUM, *//* OBSOLETE    at least when it comes time to create the innermost frame. *//* OBSOLETE    However, that doesn't work for us, so when creating the innermost *//* OBSOLETE    frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO.  */ *//* OBSOLETE  *//* OBSOLETE /* These are mostly dummies for the a29k because INIT_FRAME_PC *//* OBSOLETE    sets prev->frame instead.  */ *//* OBSOLETE /* If rsize is zero, we must be at end of stack (or otherwise hosed). *//* OBSOLETE    If we don't check rsize, we loop forever if we see rsize == 0.  */ *//* OBSOLETE #define FRAME_CHAIN(thisframe) \ *//* OBSOLETE   ((thisframe)->rsize == 0 \ *//* OBSOLETE    ? 0 \ *//* OBSOLETE    : (thisframe)->frame + (thisframe)->rsize) *//* OBSOLETE  *//* OBSOLETE /* Determine if the frame has a 'previous' and back-traceable frame. */ *//* OBSOLETE #define FRAME_IS_UNCHAINED(frame)	((frame)->flags & TRANSPARENT_FRAME) *//* OBSOLETE  *//* OBSOLETE /* Find the previous frame of a transparent routine. *//* OBSOLETE  * For now lets not try and trace through a transparent routine (we might  *//* OBSOLETE  * have to assume that all transparent routines are traps). *//* OBSOLETE  */ *//* OBSOLETE #define FIND_PREV_UNCHAINED_FRAME(frame)	0 *//* OBSOLETE  *//* OBSOLETE /* Define other aspects of the stack frame.  */ *//* OBSOLETE  *//* OBSOLETE /* An expression that tells us whether the function invocation represented *//* OBSOLETE    by FI does not have a frame on the stack associated with it. */ *//* OBSOLETE #define FRAMELESS_FUNCTION_INVOCATION(FI) \ */

⌨️ 快捷键说明

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