|
|
1.1 root 1: /* Definitions to make GDB run on a vax under 4.2bsd.
2: Copyright (C) 1986, 1987 Free Software Foundation, Inc.
3:
4: GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5: WARRANTY. No author or distributor accepts responsibility to anyone
6: for the consequences of using it or for whether it serves any
7: particular purpose or works at all, unless he says so in writing.
8: Refer to the GDB General Public License for full details.
9:
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:
17: In other words, go ahead and share GDB, but don't try to stop
18: anyone else from sharing it farther. Help stamp out software hoarding!
19: */
20:
21: #ifndef vax
22: #define vax
23: #endif
24:
25: /* Get rid of any system-imposed stack limit if possible. */
26:
27: #define SET_STACK_LIMIT_HUGE
28:
29: /* Define this if the C compiler puts an underscore at the front
30: of external names before giving them to the linker. */
31:
32: #define NAMES_HAVE_UNDERSCORE
33:
34: /* Debugger information will be in DBX format. */
35:
36: #define READ_DBX_FORMAT
37:
38: /* Offset from address of function to start of its code.
39: Zero on most machines. */
40:
41: #define FUNCTION_START_OFFSET 2
42:
43: /* Advance PC across any function entry prologue instructions
44: to reach some "real" code. */
45:
46: #define SKIP_PROLOGUE(pc) \
47: { register int op = read_memory_integer (pc, 1); \
48: if (op == 0x11) pc += 2; /* skip brb */ \
49: if (op == 0x31) pc += 3; /* skip brw */ \
50: }
51:
52: /* Immediately after a function call, return the saved pc.
53: Can't always go through the frames for this because on some machines
54: the new frame is not set up until the new function executes
55: some instructions. */
56:
57: #define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame)
58:
59: /* This is the amount to subtract from u.u_ar0
60: to get the offset in the core file of the register values. */
61:
62: #define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG))
63:
64: /* Address of end of stack space. */
65:
66: #define STACK_END_ADDR (0x80000000 - (UPAGES * NBPG))
67:
68: /* Stack grows downward. */
69:
70: #define INNER_THAN <
71:
72: /* Sequence of bytes for breakpoint instruction. */
73:
74: #define BREAKPOINT {3}
75:
76: /* Amount PC must be decremented by after a breakpoint.
77: This is often the number of bytes in BREAKPOINT
78: but not always. */
79:
80: #define DECR_PC_AFTER_BREAK 0
81:
82: /* Nonzero if instruction at PC is a return instruction. */
83:
84: #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 04)
85:
86: /* Return 1 if P points to an invalid floating point value.
87: LEN is the length in bytes -- not relevant on the Vax. */
88:
89: #define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000)
90:
91: /* Say how long (ordinary) registers are. */
92:
93: #define REGISTER_TYPE long
94:
95: /* Number of machine registers */
96:
97: #define NUM_REGS 17
98:
99: /* Initializer for an array of names of registers.
100: There should be NUM_REGS strings in this initializer. */
101:
102: #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", "ps"}
103:
104: /* Register numbers of various important registers.
105: Note that some of these values are "real" register numbers,
106: and correspond to the general registers of the machine,
107: and some are "phony" register numbers which are too large
108: to be actual register numbers as far as the user is concerned
109: but do serve to get the desired values when passed to read_register. */
110:
111: #define AP_REGNUM 12
112: #define FP_REGNUM 13 /* Contains address of executing stack frame */
113: #define SP_REGNUM 14 /* Contains address of top of stack */
114: #define PC_REGNUM 15 /* Contains program counter */
115: #define PS_REGNUM 16 /* Contains processor status */
116:
117: #define REGISTER_U_ADDR(addr, blockend, regno) \
118: { addr = blockend - 0110 + regno * 4; \
119: if (regno == PC_REGNUM) addr = blockend - 8; \
120: if (regno == PS_REGNUM) addr = blockend - 4; \
121: if (regno == FP_REGNUM) addr = blockend - 0120; \
122: if (regno == AP_REGNUM) addr = blockend - 0124; \
123: if (regno == SP_REGNUM) addr = blockend - 20; }
124:
125: /* Total amount of space needed to store our copies of the machine's
126: register state, the array `registers'. */
127: #define REGISTER_BYTES (17*4)
128:
129: /* Index within `registers' of the first byte of the space for
130: register N. */
131:
132: #define REGISTER_BYTE(N) ((N) * 4)
133:
134: /* Number of bytes of storage in the actual machine representation
135: for register N. On the vax, all regs are 4 bytes. */
136:
137: #define REGISTER_RAW_SIZE(N) 4
138:
139: /* Number of bytes of storage in the program's representation
140: for register N. On the vax, all regs are 4 bytes. */
141:
142: #define REGISTER_VIRTUAL_SIZE(N) 4
143:
144: /* Largest value REGISTER_RAW_SIZE can have. */
145:
146: #define MAX_REGISTER_RAW_SIZE 4
147:
148: /* Largest value REGISTER_VIRTUAL_SIZE can have. */
149:
150: #define MAX_REGISTER_VIRTUAL_SIZE 4
151:
152: /* Nonzero if register N requires conversion
153: from raw format to virtual format. */
154:
155: #define REGISTER_CONVERTIBLE(N) 0
156:
157: /* Convert data from raw format for register REGNUM
158: to virtual format for register REGNUM. */
159:
160: #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
161: bcopy ((FROM), (TO), 4);
162:
163: /* Convert data from virtual format for register REGNUM
164: to raw format for register REGNUM. */
165:
166: #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
167: bcopy ((FROM), (TO), 4);
168:
169: /* Return the GDB type object for the "standard" data type
170: of data in register N. */
171:
172: #define REGISTER_VIRTUAL_TYPE(N) builtin_type_int
173:
174: /* Extract from an array REGBUF containing the (raw) register state
175: a function return value of type TYPE, and copy that, in virtual format,
176: into VALBUF. */
177:
178: #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
179: bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
180:
181: /* Write into appropriate registers a function return value
182: of type TYPE, given in virtual format. */
183:
184: #define STORE_RETURN_VALUE(TYPE,VALBUF) \
185: write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
186:
187: /* Extract from an array REGBUF containing the (raw) register state
188: the address in which a function should return its structure value,
189: as a CORE_ADDR (or an expression that can be used as one). */
190:
191: #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
192:
193: /* Compensate for lack of `vprintf' function. */
194: #define vprintf(format, ap) _doprnt (format, ap, stdout)
195:
196: /* Describe the pointer in each stack frame to the previous stack frame
197: (its caller). */
198:
199: /* FRAME_CHAIN takes a frame's nominal address
200: and produces the frame's chain-pointer.
201:
202: FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
203: and produces the nominal address of the caller frame.
204:
205: However, if FRAME_CHAIN_VALID returns zero,
206: it means the given frame is the outermost one and has no caller.
207: In that case, FRAME_CHAIN_COMBINE is not used. */
208:
209: /* In the case of the Vax, the frame's nominal address is the FP value,
210: and 12 bytes later comes the saved previous FP value as a 4-byte word. */
211:
212: #define FRAME_CHAIN(thisframe) (read_memory_integer (thisframe + 12, 4))
213:
214: #define FRAME_CHAIN_VALID(chain, thisframe) \
215: (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end))
216:
217: #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
218:
219: /* Define other aspects of the stack frame. */
220:
221: #define FRAME_SAVED_PC(frame) (read_memory_integer (frame + 16, 4))
222:
223: /* Cannot find the AP register value directly from the FP value.
224: Must find it saved in the frame called by this one, or in the AP register
225: for the innermost frame. */
226: #define FRAME_ARGS_ADDRESS(fi) \
227: (((fi).next_frame \
228: ? read_memory_integer ((fi).next_frame + 8, 4) \
229: : read_register (AP_REGNUM)))
230:
231: #define FRAME_LOCALS_ADDRESS(fi) (fi).frame
232:
233: /* Return number of args passed to a frame.
234: Can return -1, meaning no way to tell. */
235:
236: #define FRAME_NUM_ARGS(numargs, fi) \
237: { numargs = (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1)); }
238:
239: /* Return number of bytes at start of arglist that are not really args. */
240:
241: #define FRAME_ARGS_SKIP 4
242:
243: /* Put here the code to store, into a struct frame_saved_regs,
244: the addresses of the saved registers of frame described by FRAME_INFO.
245: This includes special registers such as pc and fp saved in special
246: ways in the stack frame. sp is even more special:
247: the address we return for it IS the sp for the next frame. */
248:
249: #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
250: { register int regnum; \
251: register int regmask = read_memory_integer ((frame_info).frame+4, 4) >> 16; \
252: register CORE_ADDR next_addr; \
253: bzero (&frame_saved_regs, sizeof frame_saved_regs); \
254: next_addr = (frame_info).frame + 16; \
255: /* Regmask's low bit is for register 0, \
256: which is the first one that would be pushed. */ \
257: for (regnum = 0; regnum < 12; regnum++, regmask >>= 1) \
258: (frame_saved_regs).regs[regnum] = (regmask & 1) ? (next_addr += 4) : 0; \
259: (frame_saved_regs).regs[SP_REGNUM] = next_addr + 4; \
260: if (read_memory_integer ((frame_info).frame + 4, 4) & 0x20000000) \
261: (frame_saved_regs).regs[SP_REGNUM] += 4 + 4 * read_memory_integer (next_addr + 4, 4); \
262: (frame_saved_regs).regs[PC_REGNUM] = (frame_info).frame + 16; \
263: (frame_saved_regs).regs[FP_REGNUM] = (frame_info).frame + 12; \
264: (frame_saved_regs).regs[AP_REGNUM] = (frame_info).frame + 8; \
265: (frame_saved_regs).regs[PS_REGNUM] = (frame_info).frame + 4; \
266: }
267:
268: /* Things needed for making the inferior call functions. */
269:
270: /* Push an empty stack frame, to record the current PC, etc. */
271:
272: #define PUSH_DUMMY_FRAME \
273: { register CORE_ADDR sp = read_register (SP_REGNUM);\
274: register int regnum; \
275: sp = push_word (sp, 0); /* arglist */ \
276: for (regnum = 11; regnum >= 0; regnum--) \
277: sp = push_word (sp, read_register (regnum)); \
278: sp = push_word (sp, read_register (PC_REGNUM)); \
279: sp = push_word (sp, read_register (FP_REGNUM)); \
280: sp = push_word (sp, read_register (AP_REGNUM)); \
281: sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) \
282: + 0x2fff0000); \
283: sp = push_word (sp, 0); \
284: write_register (SP_REGNUM, sp); \
285: write_register (FP_REGNUM, sp); \
286: write_register (AP_REGNUM, sp + 17 * sizeof (int)); }
287:
288: /* Discard from the stack the innermost frame, restoring all registers. */
289:
290: #define POP_FRAME \
291: { register CORE_ADDR fp = read_register (FP_REGNUM); \
292: register int regnum; \
293: register int regmask = read_memory_integer (fp + 4, 4); \
294: write_register (PS_REGNUM, \
295: (regmask & 0xffff) \
296: | (read_register (PS_REGNUM) & 0xffff0000)); \
297: write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); \
298: write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); \
299: write_register (AP_REGNUM, read_memory_integer (fp + 8, 4)); \
300: fp += 16; \
301: for (regnum = 0; regnum < 12; regnum++) \
302: if (regmask & (0x10000 << regnum)) \
303: write_register (regnum, read_memory_integer (fp += 4, 4)); \
304: fp = fp + 4 + ((regmask >> 30) & 3); \
305: if (regmask & 0x20000000) \
306: { regnum = read_memory_integer (fp, 4); \
307: fp += (regnum + 1) * 4; } \
308: write_register (SP_REGNUM, fp); \
309: set_current_frame (read_register (FP_REGNUM)); }
310:
311: /* This sequence of words is the instructions
312: calls #69, @#32323232
313: bpt
314: Note this is 8 bytes. */
315:
316: #define CALL_DUMMY {0x329f69fb, 0x03323232}
317:
318: #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
319:
320: /* Insert the specified number of args and function address
321: into a call sequence of the above form stored at DUMMYNAME. */
322:
323: #define FIX_CALL_DUMMY(dummyname, fun, nargs) \
324: { *((char *) dummyname + 1) = nargs; \
325: *(int *)((char *) dummyname + 3) = fun; }
326:
327: /* Interface definitions for kernel debugger KDB. */
328:
329: /* Map machine fault codes into signal numbers.
330: First subtract 0, divide by 4, then index in a table.
331: Faults for which the entry in this table is 0
332: are not handled by KDB; the program's own trap handler
333: gets to handle then. */
334:
335: #define FAULT_CODE_ORIGIN 0
336: #define FAULT_CODE_UNITS 4
337: #define FAULT_TABLE \
338: { 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \
339: 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \
340: 0, 0, 0, 0, 0, 0, 0, 0}
341:
342: /* Start running with a stack stretching from BEG to END.
343: BEG and END should be symbols meaningful to the assembler.
344: This is used only for kdb. */
345:
346: #define INIT_STACK(beg, end) \
347: { asm (".globl end"); \
348: asm ("movl $ end, sp"); \
349: asm ("clrl fp"); }
350:
351: /* Push the frame pointer register on the stack. */
352: #define PUSH_FRAME_PTR \
353: asm ("pushl fp");
354:
355: /* Copy the top-of-stack to the frame pointer register. */
356: #define POP_FRAME_PTR \
357: asm ("movl (sp), fp");
358:
359: /* After KDB is entered by a fault, push all registers
360: that GDB thinks about (all NUM_REGS of them),
361: so that they appear in order of ascending GDB register number.
362: The fault code will be on the stack beyond the last register. */
363:
364: #define PUSH_REGISTERS \
365: { asm ("pushl 8(sp)"); \
366: asm ("pushl 8(sp)"); \
367: asm ("pushal 0x14(sp)"); \
368: asm ("pushr $037777"); }
369:
370: /* Assuming the registers (including processor status) have been
371: pushed on the stack in order of ascending GDB register number,
372: restore them and return to the address in the saved PC register. */
373:
374: #define POP_REGISTERS \
375: { asm ("popr $037777"); \
376: asm ("subl2 $8,(sp)"); \
377: asm ("movl (sp),sp"); \
378: asm ("rei"); }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.