1 /* Definitions to make GDB run on a vax under 4.2bsd.
2 Copyright (C) 1986, 1987 Free Software Foundation, Inc.
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.
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.
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!
25 /* Get rid of any system-imposed stack limit if possible. */
27 #define SET_STACK_LIMIT_HUGE
29 /* Define this if the C compiler puts an underscore at the front
30 of external names before giving them to the linker. */
32 #define NAMES_HAVE_UNDERSCORE
34 /* Debugger information will be in DBX format. */
36 #define READ_DBX_FORMAT
38 /* Offset from address of function to start of its code.
39 Zero on most machines. */
41 #define FUNCTION_START_OFFSET 2
43 /* Advance PC across any function entry prologue instructions
44 to reach some "real" code. */
46 #define SKIP_PROLOGUE(pc) \
47 { register int op = (unsigned char) read_memory_integer (pc, 1); \
48 if (op == 0x11) pc += 2; /* skip brb */ \
49 if (op == 0x31) pc += 3; /* skip brw */ \
51 ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5E) \
52 pc += 3; /* skip subl2 */ \
54 ((unsigned char) read_memory_integer (pc+1, 1)) == 0xAE && \
55 ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5E) \
56 pc += 4; /* skip movab */ \
58 ((unsigned char) read_memory_integer (pc+1, 1)) == 0xCE && \
59 ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5E) \
60 pc += 5; /* skip movab */ \
62 ((unsigned char) read_memory_integer (pc+1, 1)) == 0xEE && \
63 ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5E) \
64 pc += 7; /* skip movab */ \
67 /* Immediately after a function call, return the saved pc.
68 Can't always go through the frames for this because on some machines
69 the new frame is not set up until the new function executes
72 #define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame)
74 /* This is the amount to subtract from u.u_ar0
75 to get the offset in the core file of the register values. */
77 #define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG))
79 /* Address of end of stack space. */
81 #define STACK_END_ADDR (0x80000000 - (UPAGES * NBPG))
83 /* Stack grows downward. */
87 /* Sequence of bytes for breakpoint instruction. */
89 #define BREAKPOINT {3}
91 /* Amount PC must be decremented by after a breakpoint.
92 This is often the number of bytes in BREAKPOINT
95 #define DECR_PC_AFTER_BREAK 0
97 /* Nonzero if instruction at PC is a return instruction. */
99 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 04)
101 /* Return 1 if P points to an invalid floating point value.
102 LEN is the length in bytes -- not relevant on the Vax. */
104 #define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000)
106 /* Largest integer type */
109 /* Name of the builtin type for the LONGEST type above. */
110 #define BUILTIN_TYPE_LONGEST builtin_type_long
112 /* Say how long (ordinary) registers are. */
114 #define REGISTER_TYPE long
116 /* Number of machine registers */
120 /* Initializer for an array of names of registers.
121 There should be NUM_REGS strings in this initializer. */
123 #define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "ap", "fp", "sp", "pc", "ps"}
125 /* Register numbers of various important registers.
126 Note that some of these values are "real" register numbers,
127 and correspond to the general registers of the machine,
128 and some are "phony" register numbers which are too large
129 to be actual register numbers as far as the user is concerned
130 but do serve to get the desired values when passed to read_register. */
133 #define FP_REGNUM 13 /* Contains address of executing stack frame */
134 #define SP_REGNUM 14 /* Contains address of top of stack */
135 #define PC_REGNUM 15 /* Contains program counter */
136 #define PS_REGNUM 16 /* Contains processor status */
138 #define REGISTER_U_ADDR(addr, blockend, regno) \
139 { addr = blockend - 0110 + regno * 4; \
140 if (regno == PC_REGNUM) addr = blockend - 8; \
141 if (regno == PS_REGNUM) addr = blockend - 4; \
142 if (regno == FP_REGNUM) addr = blockend - 0120; \
143 if (regno == AP_REGNUM) addr = blockend - 0124; \
144 if (regno == SP_REGNUM) addr = blockend - 20; }
146 /* Total amount of space needed to store our copies of the machine's
147 register state, the array `registers'. */
148 #define REGISTER_BYTES (17*4)
150 /* Index within `registers' of the first byte of the space for
153 #define REGISTER_BYTE(N) ((N) * 4)
155 /* Number of bytes of storage in the actual machine representation
156 for register N. On the vax, all regs are 4 bytes. */
158 #define REGISTER_RAW_SIZE(N) 4
160 /* Number of bytes of storage in the program's representation
161 for register N. On the vax, all regs are 4 bytes. */
163 #define REGISTER_VIRTUAL_SIZE(N) 4
165 /* Largest value REGISTER_RAW_SIZE can have. */
167 #define MAX_REGISTER_RAW_SIZE 4
169 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
171 #define MAX_REGISTER_VIRTUAL_SIZE 4
173 /* Nonzero if register N requires conversion
174 from raw format to virtual format. */
176 #define REGISTER_CONVERTIBLE(N) 0
178 /* Convert data from raw format for register REGNUM
179 to virtual format for register REGNUM. */
181 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
182 bcopy ((FROM), (TO), 4);
184 /* Convert data from virtual format for register REGNUM
185 to raw format for register REGNUM. */
187 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
188 bcopy ((FROM), (TO), 4);
190 /* Return the GDB type object for the "standard" data type
191 of data in register N. */
193 #define REGISTER_VIRTUAL_TYPE(N) builtin_type_int
195 /* Store the address of the place in which to copy the structure the
196 subroutine will return. This is called from call_function. */
198 #define STORE_STRUCT_RETURN(ADDR, SP) \
199 { write_register (1, (ADDR)); }
201 /* Extract from an array REGBUF containing the (raw) register state
202 a function return value of type TYPE, and copy that, in virtual format,
205 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
206 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
208 /* Write into appropriate registers a function return value
209 of type TYPE, given in virtual format. */
211 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
212 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
214 /* Extract from an array REGBUF containing the (raw) register state
215 the address in which a function should return its structure value,
216 as a CORE_ADDR (or an expression that can be used as one). */
218 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
220 /* Compensate for lack of `vprintf' function. */
221 #define vprintf(format, ap) _doprnt (format, ap, stdout)
223 /* Describe the pointer in each stack frame to the previous stack frame
226 /* FRAME_CHAIN takes a frame's nominal address
227 and produces the frame's chain-pointer.
229 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
230 and produces the nominal address of the caller frame.
232 However, if FRAME_CHAIN_VALID returns zero,
233 it means the given frame is the outermost one and has no caller.
234 In that case, FRAME_CHAIN_COMBINE is not used. */
236 /* In the case of the Vax, the frame's nominal address is the FP value,
237 and 12 bytes later comes the saved previous FP value as a 4-byte word. */
239 #define FRAME_CHAIN(thisframe) (read_memory_integer ((thisframe)->frame + 12, 4))
241 #define FRAME_CHAIN_VALID(chain, thisframe) \
242 (chain != 0 && (FRAME_SAVED_PC (thisframe) >= first_object_file_end))
244 #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain)
246 /* Define other aspects of the stack frame. */
248 #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 16, 4))
250 /* Cannot find the AP register value directly from the FP value.
251 Must find it saved in the frame called by this one, or in the AP register
252 for the innermost frame. */
253 #define FRAME_ARGS_ADDRESS(fi) \
255 ? read_memory_integer ((fi)->next_frame + 8, 4) \
256 : read_register (AP_REGNUM)))
258 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
260 /* Return number of args passed to a frame.
261 Can return -1, meaning no way to tell. */
263 #define FRAME_NUM_ARGS(numargs, fi) \
264 { numargs = (0xff & read_memory_integer (FRAME_ARGS_ADDRESS (fi), 1)); }
266 /* Return number of bytes at start of arglist that are not really args. */
268 #define FRAME_ARGS_SKIP 4
270 /* Put here the code to store, into a struct frame_saved_regs,
271 the addresses of the saved registers of frame described by FRAME_INFO.
272 This includes special registers such as pc and fp saved in special
273 ways in the stack frame. sp is even more special:
274 the address we return for it IS the sp for the next frame. */
276 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
277 { register int regnum; \
278 register int regmask = read_memory_integer ((frame_info)->frame+4, 4) >> 16; \
279 register CORE_ADDR next_addr; \
280 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
281 next_addr = (frame_info)->frame + 16; \
282 /* Regmask's low bit is for register 0, \
283 which is the first one that would be pushed. */ \
284 for (regnum = 0; regnum < 12; regnum++, regmask >>= 1) \
285 (frame_saved_regs).regs[regnum] = (regmask & 1) ? (next_addr += 4) : 0; \
286 (frame_saved_regs).regs[SP_REGNUM] = next_addr + 4; \
287 if (read_memory_integer ((frame_info)->frame + 4, 4) & 0x20000000) \
288 (frame_saved_regs).regs[SP_REGNUM] += 4 + 4 * read_memory_integer (next_addr + 4, 4); \
289 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 16; \
290 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 12; \
291 (frame_saved_regs).regs[AP_REGNUM] = (frame_info)->frame + 8; \
292 (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4; \
295 /* Things needed for making the inferior call functions. */
297 /* Push an empty stack frame, to record the current PC, etc. */
299 #define PUSH_DUMMY_FRAME \
300 { register CORE_ADDR sp = read_register (SP_REGNUM);\
301 register int regnum; \
302 sp = push_word (sp, 0); /* arglist */ \
303 for (regnum = 11; regnum >= 0; regnum--) \
304 sp = push_word (sp, read_register (regnum)); \
305 sp = push_word (sp, read_register (PC_REGNUM)); \
306 sp = push_word (sp, read_register (FP_REGNUM)); \
307 sp = push_word (sp, read_register (AP_REGNUM)); \
308 sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) \
310 sp = push_word (sp, 0); \
311 write_register (SP_REGNUM, sp); \
312 write_register (FP_REGNUM, sp); \
313 write_register (AP_REGNUM, sp + 17 * sizeof (int)); }
315 /* Discard from the stack the innermost frame, restoring all registers. */
318 { register CORE_ADDR fp = read_register (FP_REGNUM); \
319 register int regnum; \
320 register int regmask = read_memory_integer (fp + 4, 4); \
321 write_register (PS_REGNUM, \
323 | (read_register (PS_REGNUM) & 0xffff0000)); \
324 write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); \
325 write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); \
326 write_register (AP_REGNUM, read_memory_integer (fp + 8, 4)); \
328 for (regnum = 0; regnum < 12; regnum++) \
329 if (regmask & (0x10000 << regnum)) \
330 write_register (regnum, read_memory_integer (fp += 4, 4)); \
331 fp = fp + 4 + ((regmask >> 30) & 3); \
332 if (regmask & 0x20000000) \
333 { regnum = read_memory_integer (fp, 4); \
334 fp += (regnum + 1) * 4; } \
335 write_register (SP_REGNUM, fp); \
336 flush_cached_frames (); \
337 set_current_frame (create_new_frame (read_register (FP_REGNUM),\
340 /* This sequence of words is the instructions
341 calls #69, @#32323232
343 Note this is 8 bytes. */
345 #define CALL_DUMMY {0x329f69fb, 0x03323232}
347 #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */
349 /* Insert the specified number of args and function address
350 into a call sequence of the above form stored at DUMMYNAME. */
352 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
353 { *((char *) dummyname + 1) = nargs; \
354 *(int *)((char *) dummyname + 3) = fun; }
356 /* Interface definitions for kernel debugger KDB. */
358 /* Map machine fault codes into signal numbers.
359 First subtract 0, divide by 4, then index in a table.
360 Faults for which the entry in this table is 0
361 are not handled by KDB; the program's own trap handler
362 gets to handle then. */
364 #define FAULT_CODE_ORIGIN 0
365 #define FAULT_CODE_UNITS 4
366 #define FAULT_TABLE \
367 { 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \
368 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \
369 0, 0, 0, 0, 0, 0, 0, 0}
371 /* Start running with a stack stretching from BEG to END.
372 BEG and END should be symbols meaningful to the assembler.
373 This is used only for kdb. */
375 #define INIT_STACK(beg, end) \
376 { asm (".globl end"); \
377 asm ("movl $ end, sp"); \
380 /* Push the frame pointer register on the stack. */
381 #define PUSH_FRAME_PTR \
384 /* Copy the top-of-stack to the frame pointer register. */
385 #define POP_FRAME_PTR \
386 asm ("movl (sp), fp");
388 /* After KDB is entered by a fault, push all registers
389 that GDB thinks about (all NUM_REGS of them),
390 so that they appear in order of ascending GDB register number.
391 The fault code will be on the stack beyond the last register. */
393 #define PUSH_REGISTERS \
394 { asm ("pushl 8(sp)"); \
395 asm ("pushl 8(sp)"); \
396 asm ("pushal 0x14(sp)"); \
397 asm ("pushr $037777"); }
399 /* Assuming the registers (including processor status) have been
400 pushed on the stack in order of ascending GDB register number,
401 restore them and return to the address in the saved PC register. */
403 #define POP_REGISTERS \
404 { asm ("popr $037777"); \
405 asm ("subl2 $8,(sp)"); \
406 asm ("movl (sp),sp"); \
This page took 0.036873 seconds and 4 git commands to generate.