m-isi-ov.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. /* Definitions to make GDB run on a ISI Optimum V (3.05) under 4.2bsd.
  2. WARNING: This is preliminary and it was for GDB version 1.
  3. It certainly requires additional macros and changes for GDB version 2.
  4. Copyright (C) 1986 Free Software Foundation, Inc.
  5. GDB is distributed in the hope that it will be useful, but WITHOUT ANY
  6. WARRANTY. No author or distributor accepts responsibility to anyone
  7. for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.
  9. Refer to the GDB General Public License for full details.
  10. Everyone is granted permission to copy, modify and redistribute GDB,
  11. but only under the conditions described in the GDB General Public
  12. License. A copy of this license is supposed to have been given to you
  13. along with GDB so you can know your rights and responsibilities. It
  14. should be in a file named COPYING. Among other things, the copyright
  15. notice and this notice must be preserved on all copies.
  16. In other words, go ahead and share GDB, but don't try to stop
  17. anyone else from sharing it farther. Help stamp out software hoarding!
  18. */
  19. /* Define this if the C compiler puts an underscore at the front
  20. of external names before giving them to the linker. */
  21. #define NAMES_HAVE_UNDERSCORE
  22. /* Offset from address of function to start of its code.
  23. Zero on most machines. */
  24. #define FUNCTION_START_OFFSET 0
  25. /* Advance PC across any function entry prologue instructions
  26. to reach some "real" code. */
  27. #define SKIP_PROLOGUE(pc) \
  28. { register int op = read_memory_integer (pc, 2); \
  29. if (op == 0047126) \
  30. pc += 4; /* Skip link #word */ \
  31. else if (op == 0044016) \
  32. pc += 6; /* Skip link #long */ \
  33. else if (op == 0x6000) \
  34. pc += 4; /* Skip bra #word */ \
  35. else if (op == 0x60ff) \
  36. pc += 6; /* skip bra #long */ \
  37. else if (op & 0xff00 == 0x6000) \
  38. pc += 2; /* skip bra #char */ \
  39. }
  40. /* Immediately after a function call, return the saved pc.
  41. Can't always go through the frames for this because on some machines
  42. the new frame is not set up until the new function executes
  43. some instructions. */
  44. #define SAVED_PC_AFTER_CALL(frame) \
  45. read_memory_integer (read_register (SP_REGNUM), 4)
  46. /* This is the amount to subtract from u.u_ar0
  47. to get the offset in the core file of the register values. */
  48. #define KERNEL_U_ADDR 0x10800000
  49. /* Address of end of stack space. */
  50. #define STACK_END_ADDR 0x10000000
  51. /* Stack grows downward. */
  52. #define INNER_THAN <
  53. /* Sequence of bytes for breakpoint instruction. */
  54. #define BREAKPOINT {0x4e, 0x4f}
  55. /* Amount PC must be decremented by after a breakpoint.
  56. This is often the number of bytes in BREAKPOINT
  57. but not always. */
  58. #define DECR_PC_AFTER_BREAK 2
  59. /* Nonzero if instruction at PC is a return instruction. */
  60. #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e76)
  61. /* Return 1 if P points to an invalid floating point value. */
  62. #define INVALID_FLOAT(p) 0
  63. /* Say how long registers are. */
  64. #define REGISTER_TYPE long
  65. /* Number of machine registers */
  66. #define NUM_REGS 18
  67. /* Number that are really general registers */
  68. #define NUM_GENERAL_REGS 16
  69. /* Initializer for an array of names of registers.
  70. There should be NUM_REGS strings in this initializer. */
  71. #define REGISTER_NAMES {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", "ps", "pc"}
  72. /* Register numbers of various important registers.
  73. Note that some of these values are "real" register numbers,
  74. and correspond to the general registers of the machine,
  75. and some are "phony" register numbers which are too large
  76. to be actual register numbers as far as the user is concerned
  77. but do serve to get the desired values when passed to read_register. */
  78. #define FP_REGNUM 14 /* Contains address of executing stack frame */
  79. #define SP_REGNUM 15 /* Contains address of top of stack */
  80. #define PS_REGNUM 16 /* Contains processor status */
  81. #define PC_REGNUM 17 /* Contains program counter */
  82. #define REGISTER_U_ADDR(addr, blockend, regno) \
  83. { if (regno < 2) addr = blockend - 0x18 + regno * 4; \
  84. else if (regno < 8) addr = blockend - 0x54 + regno * 4; \
  85. else if (regno < 10) addr = blockend - 0x30 + regno * 4;\
  86. else if (regno < 15) addr = blockend - 0x5c + regno * 4;\
  87. else if (regno < 16) addr = blockend - 0x1c; \
  88. else addr = blockend - 0x44 + regno * 4; } \
  89. /* Describe the pointer in each stack frame to the previous stack frame
  90. (its caller). */
  91. /* FRAME_CHAIN takes a frame's nominal address
  92. and produces the frame's chain-pointer.
  93. FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
  94. and produces the nominal address of the caller frame.
  95. However, if FRAME_CHAIN_VALID returns zero,
  96. it means the given frame is the outermost one and has no caller.
  97. In that case, FRAME_CHAIN_COMBINE is not used. */
  98. /* In the case of the ISI, the frame's nominal address
  99. is the address of a 4-byte word containing the calling frame's address. */
  100. #define FRAME_CHAIN(thisframe) (read_memory_integer (thisframe, 4))
  101. #define FRAME_CHAIN_VALID(chain, thisframe) \
  102. (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end))
  103. #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
  104. /* Define other aspects of the stack frame. */
  105. #define FRAME_SAVED_PC(frame) (read_memory_integer (frame + 4, 4))
  106. #define FRAME_ARGS_ADDRESS(fi) (fi.frame)
  107. #define FRAME_LOCALS_ADDRESS(fi) (fi.frame)
  108. /* Return number of args passed to a frame.
  109. Can return -1, meaning no way to tell. */
  110. #define FRAME_NUM_ARGS(val, fi) \
  111. { register CORE_ADDR pc = FRAME_SAVED_PC (fi.frame); \
  112. register int insn = 0177777 & read_memory_integer (pc, 2); \
  113. val = 0; \
  114. if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \
  115. val = read_memory_integer (pc + 2, 2); \
  116. else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \
  117. || (insn & 0170777) == 0050117) /* addqw */ \
  118. { val = (insn >> 9) & 7; if (val == 0) val = 8; } \
  119. else if (insn == 0157774) /* addal #WW, sp */ \
  120. val = read_memory_integer (pc + 2, 4); \
  121. val >>= 2; }
  122. /* Return number of bytes at start of arglist that are not really args. */
  123. #define FRAME_ARGS_SKIP 4
  124. /* Put here the code to store, into a struct frame_saved_regs,
  125. the addresses of the saved registers of frame described by FRAME_INFO.
  126. This includes special registers such as pc and fp saved in special
  127. ways in the stack frame. sp is even more special:
  128. the address we return for it IS the sp for the next frame. */
  129. #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
  130. { register int regnum; \
  131. register int regmask; \
  132. register CORE_ADDR next_addr; \
  133. register CORE_ADDR pc; \
  134. bzero (&frame_saved_regs, sizeof frame_saved_regs); \
  135. if ((frame_info).pc >= (frame_info).frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 4 \
  136. && (frame_info).pc <= (frame_info).frame) \
  137. { next_addr = (frame_info).frame; \
  138. pc = (frame_info).frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 4; }\
  139. else \
  140. { pc = get_pc_function_start ((frame_info).pc); \
  141. /* Verify we have a link a6 instruction next; \
  142. if not we lose. If we win, find the address above the saved \
  143. regs using the amount of storage from the link instruction. */\
  144. if (044016 == read_memory_integer (pc, 2)) \
  145. next_addr = (frame_info).frame - read_memory_integer (pc += 2, 4), pc+=4; \
  146. else if (047126 == read_memory_integer (pc, 2)) \
  147. next_addr = (frame_info).frame - read_memory_integer (pc += 2, 2), pc+=2; \
  148. else goto lose; \
  149. /* If have an addal #-n, sp next, adjust next_addr. */ \
  150. if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \
  151. next_addr += read_memory_integer (pc += 2, 4), pc += 4; \
  152. } \
  153. /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \
  154. regmask = read_memory_integer (pc + 2, 2); \
  155. if (0044327 == read_memory_integer (pc, 2)) \
  156. { pc += 4; /* Regmask's low bit is for register 0, the first written */ \
  157. for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \
  158. if (regmask & 1) \
  159. (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \
  160. else if (0044347 == read_memory_integer (pc, 2)) \
  161. { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \
  162. for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \
  163. if (regmask & 1) \
  164. (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
  165. else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \
  166. { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \
  167. (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \
  168. /* clrw -(sp); movw ccr,-(sp) may follow. */ \
  169. if (0x426742e7 == read_memory_integer (pc, 4)) \
  170. (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \
  171. lose: ; \
  172. (frame_saved_regs).regs[SP_REGNUM] = (frame_info).frame + 8; \
  173. (frame_saved_regs).regs[FP_REGNUM] = (frame_info).frame; \
  174. (frame_saved_regs).regs[PC_REGNUM] = (frame_info).frame + 4; \
  175. }
  176. /* Things needed for making the inferior call functions. */
  177. /* Push an empty stack frame, to record the current PC, etc. */
  178. #define PUSH_DUMMY_FRAME \
  179. { register CORE_ADDR sp = read_register (SP_REGNUM);\
  180. register int regnum; \
  181. sp = push_word (sp, read_register (PC_REGNUM)); \
  182. sp = push_word (sp, read_register (FP_REGNUM)); \
  183. write_register (FP_REGNUM, sp); \
  184. for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
  185. sp = push_word (sp, read_register (regnum)); \
  186. sp = push_word (sp, read_register (PS_REGNUM)); \
  187. write_register (SP_REGNUM, sp); }
  188. /* Discard from the stack the innermost frame, restoring all registers. */
  189. #define POP_FRAME \
  190. { register CORE_ADDR fp = read_register (FP_REGNUM); \
  191. register int regnum; \
  192. struct frame_saved_regs fsr; \
  193. struct frame_info fi; \
  194. fi = get_frame_info (fp); \
  195. get_frame_saved_regs (&fi, &fsr); \
  196. for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
  197. if (fsr.regs[regnum]) \
  198. write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
  199. if (fsr.regs[PS_REGNUM]) \
  200. write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
  201. write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
  202. write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
  203. write_register (SP_REGNUM, fp + 8); \
  204. }
  205. /* This sequence of words is the instructions
  206. moveml 0xfffc,-(sp)
  207. clrw -(sp)
  208. movew ccr,-(sp)
  209. /..* The arguments are pushed at this point by GDB;
  210. no code is needed in the dummy for this.
  211. The CALL_DUMMY_START_OFFSET gives the position of
  212. the following jsr instruction. *../
  213. jsr @#32323232
  214. addl #69696969,sp
  215. bpt
  216. nop
  217. Note this is 24 bytes.
  218. We actually start executing at the jsr, since the pushing of the
  219. registers is done by PUSH_DUMMY_FRAME. If this were real code,
  220. the arguments for the function called by the jsr would be pushed
  221. between the moveml and the jsr, and we could allow it to execute through.
  222. But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done,
  223. and we cannot allow the moveml to push the registers again lest they be
  224. taken for the arguments. */
  225. #define CALL_DUMMY {0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71}
  226. #define CALL_DUMMY_LENGTH 24
  227. #define CALL_DUMMY_START_OFFSET 8
  228. /* Insert the specified number of args and function address
  229. into a call sequence of the above form stored at DUMMYNAME. */
  230. #define FIX_CALL_DUMMY(dummyname, fun, nargs) \
  231. { *(int *)((char *) dummyname + 16) = nargs * 4; \
  232. *(int *)((char *) dummyname + 10) = fun; }
  233. /* Interface definitions for kernel debugger KDB. */
  234. /* Map machine fault codes into signal numbers.
  235. First subtract 0, divide by 4, then index in a table.
  236. Faults for which the entry in this table is 0
  237. are not handled by KDB; the program's own trap handler
  238. gets to handle then. */
  239. #define FAULT_CODE_ORIGIN 0
  240. #define FAULT_CODE_UNITS 4
  241. #define FAULT_TABLE \
  242. { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
  243. 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
  244. 0, 0, 0, 0, 0, 0, 0, 0, \
  245. SIGILL }
  246. /* Start running with a stack stretching from BEG to END.
  247. BEG and END should be symbols meaningful to the assembler.
  248. This is used only for kdb. */
  249. #define INIT_STACK(beg, end) \
  250. { asm (".globl end"); \
  251. asm ("movl $ end, sp"); \
  252. asm ("clrl fp"); }
  253. /* Push the frame pointer register on the stack. */
  254. #define PUSH_FRAME_PTR \
  255. asm ("movel fp, -(sp)");
  256. /* Copy the top-of-stack to the frame pointer register. */
  257. #define POP_FRAME_PTR \
  258. asm ("movl (sp), fp");
  259. /* After KDB is entered by a fault, push all registers
  260. that GDB thinks about (all NUM_REGS of them),
  261. so that they appear in order of ascending GDB register number.
  262. The fault code will be on the stack beyond the last register. */
  263. #define PUSH_REGISTERS \
  264. { asm ("clrw -(sp)"); \
  265. asm ("pea 10(sp)"); \
  266. asm ("movem $ 0xfffe,-(sp)"); }
  267. /* Assuming the registers (including processor status) have been
  268. pushed on the stack in order of ascending GDB register number,
  269. restore them and return to the address in the saved PC register. */
  270. #define POP_REGISTERS \
  271. { asm ("subil $8,28(sp)"); \
  272. asm ("movem (sp),$ 0xffff"); \
  273. asm ("rte"); }
  274. ============================================================m-isi-ovinit.h
  275. /* This is how the size of an individual .o file's text segment
  276. is rounded on a vax. */
  277. #define FILEADDR_ROUND(addr) (addr)
  278. ============================================================