📄 tm-pyr.h
字号:
a function return value of type TYPE, and copy that, in virtual format, into VALBUF. *//* Note that on a register-windowing machine (eg, Pyr, SPARC), this is where the value is found after the function call -- ie, it should correspond to GNU CC's FUNCTION_VALUE rather than FUNCTION_OUTGOING_VALUE.*/#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ bcopy (((int *)(REGBUF))+TR0_REGNUM, VALBUF, TYPE_LENGTH (TYPE))/* Write into appropriate registers a function return value of type TYPE, given in virtual format. *//* on pyrs, values are returned in */#define STORE_RETURN_VALUE(TYPE,VALBUF) \ write_register_bytes (REGISTER_BYTE(TR0_REGNUM), VALBUF, TYPE_LENGTH (TYPE))/* Extract from an array REGBUF containing the (raw) register state the address in which a function should return its structure value, as a CORE_ADDR (or an expression that can be used as one). *//* FIXME */#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ ( ((int *)(REGBUF)) [TR0_REGNUM])/* Describe the pointer in each stack frame to the previous stack frame (its caller). */#define EXTRA_FRAME_INFO \ FRAME_ADDR bottom; \ CORE_ADDR frame_cfp; \ CORE_ADDR frame_window_addr;#define INIT_EXTRA_FRAME_INFO(fromleaf, fci) \do { \ (fci)->frame_window_addr = (fci)->frame; \ (fci)->bottom = \ ((fci)->next ? \ ((fci)->frame == (fci)->next_frame ? \ (fci)->next->bottom : (fci)->next->frame) : \ read_register (SP_REGNUM)); \ (fci)->frame_cfp = \ read_register (CFP_REGNUM); \ /***fprintf (stderr, \ "[[creating new frame for %0x,pc=%0x,csp=%0x]]\n", \ (fci)->frame, (fci)->pc,(fci)->frame_cfp);*/ \} while (0);/* FRAME_CHAIN takes a frame's nominal address and produces the frame's chain-pointer. *//* In the case of the pyr, the frame's nominal address is the address of parameter register 0. The previous frame is found 32 words up. */#define FRAME_CHAIN(thisframe) \ ( (thisframe) -> frame - CONTROL_STACK_FRAME_SIZE) /*((thisframe) >= CONTROL_STACK_ADDR))*//* 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. I do not understand what this means on a Pyramid, where functions *always* have a control-stack frame, but may or may not have a frame on the data stack. Since GBD uses the value of the control stack pointer as its "address" of a frame, FRAMELESS is always 1, so does not need to be defined. *//* Where is the PC for a specific frame */#define FRAME_SAVED_PC(fi) \ ((CORE_ADDR) (read_memory_integer ( (fi) -> frame + 60, 4)))/* There may be bugs in FRAME_ARGS_ADDRESS and FRAME_LOCALS_ADDRESS; or there may be bugs in accessing the registers that break their definitions. Having the macros expand into functions makes them easier to debug. When the bug is finally located, the inline macro defintions can be un-#if 0ed, and frame_args_addr and frame_locals_address can be deleted from pyr-dep.c */ /* If the argument is on the stack, it will be here. */#define FRAME_ARGS_ADDRESS(fi) \ frame_args_addr(fi)#define FRAME_LOCALS_ADDRESS(fi) \ frame_locals_address(fi)/* The following definitions doesn't seem to work. I don't understand why. */#if 0#define FRAME_ARGS_ADDRESS(fi) \ /*(FRAME_FP(fi) + (13*4))*/ (read_register (CFP_REGNUM))#define FRAME_LOCALS_ADDRESS(fi) \ ((fi)->frame +(16*4))#endif /* 0 *//* Return number of args passed to a frame. Can return -1, meaning no way to tell. */#define FRAME_NUM_ARGS(val, fi) (val = -1)/* Return number of bytes at start of arglist that are not really args. */#define FRAME_ARGS_SKIP 0/* Put here the code to store, into a struct frame_saved_regs, the addresses of the saved registers of frame described by FRAME_INFO. This includes special registers such as pc and fp saved in special ways in the stack frame. sp is even more special: the address we return for it IS the sp for the next frame. Note that on register window machines, we are currently making the assumption that window registers are being saved somewhere in the frame in which they are being used. If they are stored in an inferior frame, find_saved_register will break. On pyrs, frames of window registers are stored contiguously on a separate stack. All window registers are always stored. The pc and psw (gr15 and gr14) are also always saved: the call insn saves them in pr15 and pr14 of the new frame (tr15,tr14 of the old frame). The data-stack frame pointer (CFP) is only saved in functions which allocate a (data)stack frame (with "adsf"). We detect them by looking at the first insn of the procedure. Other non-window registers (gr0-gr11) are never saved. Pyramid's C compiler and gcc currently ignore them, so it's not an issue. */ #define FRAME_FIND_SAVED_REGS(fi_p, frame_saved_regs) \{ register int regnum; \ register CORE_ADDR pc; \ register CORE_ADDR fn_start_pc; \ register int first_insn; \ register CORE_ADDR prev_cf_addr; \ register int window_ptr; \ FRAME fid = FRAME_INFO_ID (fi_p); \ if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); \ bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ \ window_ptr = prev_cf_addr = FRAME_FP(fi_p); \ \ for (regnum = 16 ; regnum < 64; regnum++,window_ptr+=4) \ { \ (frame_saved_regs).regs[regnum] = window_ptr; \ } \ \ /* In each window, psw, and pc are "saved" in tr14,tr15. */ \ /*** psw is sometimes saved in gr12 (so sez <sys/pcb.h>) */ \ (frame_saved_regs).regs[PS_REGNUM] = FRAME_FP(fi_p) + (14*4); \ \/*(frame_saved_regs).regs[PC_REGNUM] = (frame_saved_regs).regs[31];*/ \ (frame_saved_regs).regs[PC_REGNUM] = FRAME_FP(fi_p) + ((15+32)*4); \ \ /* Functions that allocate a frame save sp *where*? */ \/*first_insn = read_memory_integer (get_pc_function_start ((fi_p)->pc),4); */ \ \ fn_start_pc = (get_pc_function_start ((fi_p)->pc)); \ first_insn = read_memory_integer(fn_start_pc, 4); \ \ if (0x08 == ((first_insn >> 20) &0x0ff)) { \ /* NB: because WINDOW_REGISTER_P(cfp) is false, a saved cfp \ in this frame is only visible in this frame's callers. \ That means the cfp we mark saved is my caller's cfp, ie pr13. \ I don't understand why we don't have to do that for pc, too. */ \ \ (frame_saved_regs).regs[CFP_REGNUM] = FRAME_FP(fi_p)+(13*4); \ \ (frame_saved_regs).regs[SP_REGNUM] = \ read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ } \ \/* \ *(frame_saved_regs).regs[CFP_REGNUM] = (frame_saved_regs).regs[61]; \ * (frame_saved_regs).regs[SP_REGNUM] = \ * read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ */ \ \ (frame_saved_regs).regs[CSP_REGNUM] = prev_cf_addr; \}/* Things needed for making the inferior call functions. */#if 0/* These are all lies. These macro definitions are appropriate for a SPARC. On a pyramid, pushing a dummy frame will surely involve writing the control stack pointer, then saving the pc. This requires a privileged instruction. Maybe one day Pyramid can be persuaded to add a syscall to do this. Until then, we are out of luck. *//* Push an empty stack frame, to record the current PC, etc. */#define PUSH_DUMMY_FRAME \{ register CORE_ADDR sp = read_register (SP_REGNUM);\ register int regnum; \ sp = push_word (sp, 0); /* arglist */ \ for (regnum = 11; regnum >= 0; regnum--) \ sp = push_word (sp, read_register (regnum)); \ sp = push_word (sp, read_register (PC_REGNUM)); \ sp = push_word (sp, read_register (FP_REGNUM)); \/* sp = push_word (sp, read_register (AP_REGNUM));*/ \ sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) \ + 0x2fff0000); \ sp = push_word (sp, 0); \ write_register (SP_REGNUM, sp); \ write_register (FP_REGNUM, sp); \/* write_register (AP_REGNUM, sp + 17 * sizeof (int));*/ }/* Discard from the stack the innermost frame, restoring all registers. */#define POP_FRAME \{ register CORE_ADDR fp = read_register (FP_REGNUM); \ register int regnum; \ register int regmask = read_memory_integer (fp + 4, 4); \ write_register (PS_REGNUM, \ (regmask & 0xffff) \ | (read_register (PS_REGNUM) & 0xffff0000)); \ write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); \ write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); \/* write_register (AP_REGNUM, read_memory_integer (fp + 8, 4));*/ \ fp += 16; \ for (regnum = 0; regnum < 12; regnum++) \ if (regmask & (0x10000 << regnum)) \ write_register (regnum, read_memory_integer (fp += 4, 4)); \ fp = fp + 4 + ((regmask >> 30) & 3); \ if (regmask & 0x20000000) \ { regnum = read_memory_integer (fp, 4); \ fp += (regnum + 1) * 4; } \ write_register (SP_REGNUM, fp); \ set_current_frame (read_register (FP_REGNUM)); }/* This sequence of words is the instructions calls #69, @#32323232 bpt Note this is 8 bytes. */#define CALL_DUMMY {0x329f69fb, 0x03323232}#define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy *//* Insert the specified number of args and function address into a call sequence of the above form stored at DUMMYNAME. */#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \{ *((char *) dummyname + 1) = nargs; \ *(int *)((char *) dummyname + 3) = fun; }#endif /* 0 */#define POP_FRAME \ { error ("The return command is not supported on this machine."); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -