3bf57d21 |
1 | /* Parameters for execution on an HP 9000 model 320, for GDB, the GNU debugger. |
4187119d |
2 | Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc. |
7b4ac7e1 |
3 | |
4187119d |
4 | This file is part of GDB. |
7b4ac7e1 |
5 | |
4187119d |
6 | GDB is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 1, or (at your option) |
9 | any later version. |
7b4ac7e1 |
10 | |
4187119d |
11 | GDB is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with GDB; see the file COPYING. If not, write to |
18 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ |
19 | |
20 | /* Define the bit, byte, and word ordering of the machine. */ |
21 | #define BITS_BIG_ENDIAN |
22 | #define BYTES_BIG_ENDIAN |
23 | #define WORDS_BIG_ENDIAN |
7b4ac7e1 |
24 | |
3bf57d21 |
25 | #ifndef HP9K320 |
26 | #define HP9K320 |
27 | #endif |
7b4ac7e1 |
28 | |
4187119d |
29 | /* Define this to indicate problems with traps after continuing. */ |
30 | #define HP_OS_BUG |
31 | |
3bf57d21 |
32 | /* Set flag to indicate whether HP's assembler is in use. */ |
4187119d |
33 | #ifdef __GNUC__ |
3bf57d21 |
34 | #ifdef __HPUX_ASM__ |
4187119d |
35 | #define HPUX_ASM |
3bf57d21 |
36 | #endif |
37 | #else |
4187119d |
38 | #define HPUX_ASM |
7b4ac7e1 |
39 | #endif |
40 | |
3bf57d21 |
41 | /* Define this for versions of hp-ux older than 6.0 */ |
42 | /* #define HPUX_VERSION_5 */ |
43 | |
e91b87a3 |
44 | /* define USG if you are using sys5 /usr/include's */ |
45 | #define USG |
46 | |
3bf57d21 |
47 | #define HAVE_TERMIO |
48 | |
49 | /* Get rid of any system-imposed stack limit if possible. */ |
4187119d |
50 | /* The hp9k320.h doesn't seem to have this feature. */ |
3bf57d21 |
51 | /* #define SET_STACK_LIMIT_HUGE */ |
4187119d |
52 | /* So we'll just have to avoid big alloca's. */ |
53 | #define BROKEN_LARGE_ALLOCA |
3bf57d21 |
54 | |
7b4ac7e1 |
55 | /* Define this if the C compiler puts an underscore at the front |
56 | of external names before giving them to the linker. */ |
57 | |
58 | #define NAMES_HAVE_UNDERSCORE |
59 | |
60 | /* Debugger information will be in DBX format. */ |
61 | |
62 | #define READ_DBX_FORMAT |
63 | |
64 | /* Offset from address of function to start of its code. |
65 | Zero on most machines. */ |
66 | |
67 | #define FUNCTION_START_OFFSET 0 |
68 | |
69 | /* Advance PC across any function entry prologue instructions |
70 | to reach some "real" code. */ |
71 | |
72 | #define SKIP_PROLOGUE(pc) \ |
73 | { register int op = read_memory_integer (pc, 2); \ |
3bf57d21 |
74 | if (op == 0047126) \ |
7b4ac7e1 |
75 | pc += 4; /* Skip link #word */ \ |
3bf57d21 |
76 | else if (op == 0044016) \ |
7b4ac7e1 |
77 | pc += 6; /* Skip link #long */ \ |
7b4ac7e1 |
78 | } |
79 | |
7b4ac7e1 |
80 | /* Immediately after a function call, return the saved pc. |
3bf57d21 |
81 | Can't go through the frames for this because on some machines |
7b4ac7e1 |
82 | the new frame is not set up until the new function executes |
83 | some instructions. */ |
84 | |
85 | #define SAVED_PC_AFTER_CALL(frame) \ |
86 | read_memory_integer (read_register (SP_REGNUM), 4) |
87 | |
88 | /* This is the amount to subtract from u.u_ar0 |
89 | to get the offset in the core file of the register values. */ |
90 | |
3bf57d21 |
91 | #ifdef HPUX_VERSION_5 |
92 | #define KERNEL_U_ADDR 0x00979000 |
93 | #else |
94 | #define KERNEL_U_ADDR 0x00C01000 |
95 | #endif |
7b4ac7e1 |
96 | |
97 | /* Address of end of stack space. */ |
98 | |
3bf57d21 |
99 | #define STACK_END_ADDR 0xFFF00000 |
7b4ac7e1 |
100 | |
101 | /* Stack grows downward. */ |
102 | |
103 | #define INNER_THAN < |
104 | |
105 | /* Sequence of bytes for breakpoint instruction. */ |
106 | |
3bf57d21 |
107 | #define BREAKPOINT {0x4e, 0x41} |
7b4ac7e1 |
108 | |
109 | /* Amount PC must be decremented by after a breakpoint. |
110 | This is often the number of bytes in BREAKPOINT |
3bf57d21 |
111 | but not always. */ |
7b4ac7e1 |
112 | |
3bf57d21 |
113 | #define DECR_PC_AFTER_BREAK 2 |
7b4ac7e1 |
114 | |
115 | /* Nonzero if instruction at PC is a return instruction. */ |
116 | |
3bf57d21 |
117 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 2) == 0x4e75) |
7b4ac7e1 |
118 | |
119 | /* Return 1 if P points to an invalid floating point value. */ |
120 | |
121 | #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ |
122 | |
e91b87a3 |
123 | /* Largest integer type */ |
124 | #define LONGEST long |
125 | |
126 | /* Name of the builtin type for the LONGEST type above. */ |
127 | #define BUILTIN_TYPE_LONGEST builtin_type_long |
128 | |
3bf57d21 |
129 | /* Say how long (ordinary) registers are. */ |
7b4ac7e1 |
130 | |
131 | #define REGISTER_TYPE long |
132 | |
133 | /* Number of machine registers */ |
134 | |
135 | #define NUM_REGS 29 |
136 | |
137 | /* Initializer for an array of names of registers. |
138 | There should be NUM_REGS strings in this initializer. */ |
139 | |
140 | #define REGISTER_NAMES \ |
141 | {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \ |
142 | "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \ |
143 | "ps", "pc", \ |
144 | "fp0", "fp1", "fp2", "fp3", "fp4", "fp5", "fp6", "fp7", \ |
145 | "fpcontrol", "fpstatus", "fpiaddr" } |
146 | |
147 | /* Register numbers of various important registers. |
148 | Note that some of these values are "real" register numbers, |
149 | and correspond to the general registers of the machine, |
150 | and some are "phony" register numbers which are too large |
151 | to be actual register numbers as far as the user is concerned |
152 | but do serve to get the desired values when passed to read_register. */ |
153 | |
154 | #define FP_REGNUM 14 /* Contains address of executing stack frame */ |
155 | #define SP_REGNUM 15 /* Contains address of top of stack */ |
156 | #define PS_REGNUM 16 /* Contains processor status */ |
157 | #define PC_REGNUM 17 /* Contains program counter */ |
158 | #define FP0_REGNUM 18 /* Floating point register 0 */ |
159 | #define FPC_REGNUM 26 /* 68881 control register */ |
160 | |
7b4ac7e1 |
161 | /* Total amount of space needed to store our copies of the machine's |
162 | register state, the array `registers'. */ |
3bf57d21 |
163 | #define REGISTER_BYTES (16*4+8*12+8+12) |
7b4ac7e1 |
164 | |
165 | /* Index within `registers' of the first byte of the space for |
166 | register N. */ |
167 | |
168 | #define REGISTER_BYTE(N) \ |
169 | ((N) >= FPC_REGNUM ? (((N) - FPC_REGNUM) * 4) + 168 \ |
170 | : (N) >= FP0_REGNUM ? (((N) - FP0_REGNUM) * 12) + 72 \ |
171 | : (N) * 4) |
172 | |
173 | /* Number of bytes of storage in the actual machine representation |
174 | for register N. On the 68000, all regs are 4 bytes |
175 | except the floating point regs which are 12 bytes. */ |
176 | |
177 | #define REGISTER_RAW_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 12 : 4) |
178 | |
179 | /* Number of bytes of storage in the program's representation |
180 | for register N. On the 68000, all regs are 4 bytes |
181 | except the floating point regs which are 8-byte doubles. */ |
182 | |
183 | #define REGISTER_VIRTUAL_SIZE(N) (((unsigned)(N) - FP0_REGNUM) < 8 ? 8 : 4) |
184 | |
185 | /* Largest value REGISTER_RAW_SIZE can have. */ |
186 | |
187 | #define MAX_REGISTER_RAW_SIZE 12 |
188 | |
189 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ |
190 | |
191 | #define MAX_REGISTER_VIRTUAL_SIZE 8 |
192 | |
193 | /* Nonzero if register N requires conversion |
194 | from raw format to virtual format. */ |
195 | |
196 | #define REGISTER_CONVERTIBLE(N) (((unsigned)(N) - FP0_REGNUM) < 8) |
197 | |
198 | /* Convert data from raw format for register REGNUM |
199 | to virtual format for register REGNUM. */ |
200 | |
201 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ |
202 | { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ |
203 | convert_from_68881 ((FROM), (TO)); \ |
204 | else \ |
205 | bcopy ((FROM), (TO), 4); } |
206 | |
207 | /* Convert data from virtual format for register REGNUM |
208 | to raw format for register REGNUM. */ |
209 | |
210 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ |
211 | { if ((REGNUM) >= FP0_REGNUM && (REGNUM) < FPC_REGNUM) \ |
212 | convert_to_68881 ((FROM), (TO)); \ |
213 | else \ |
214 | bcopy ((FROM), (TO), 4); } |
215 | |
216 | /* Return the GDB type object for the "standard" data type |
217 | of data in register N. */ |
218 | |
219 | #define REGISTER_VIRTUAL_TYPE(N) \ |
220 | (((unsigned)(N) - FP0_REGNUM) < 8 ? builtin_type_double : builtin_type_int) |
221 | |
e91b87a3 |
222 | /* Store the address of the place in which to copy the structure the |
223 | subroutine will return. This is called from call_function. */ |
224 | |
225 | #define STORE_STRUCT_RETURN(ADDR, SP) \ |
226 | { write_register (9, (ADDR)); } |
227 | |
7b4ac7e1 |
228 | /* Extract from an array REGBUF containing the (raw) register state |
229 | a function return value of type TYPE, and copy that, in virtual format, |
230 | into VALBUF. */ |
231 | |
232 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ |
233 | bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE)) |
234 | |
235 | /* Write into appropriate registers a function return value |
236 | of type TYPE, given in virtual format. */ |
237 | |
238 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ |
239 | write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE)) |
240 | |
241 | /* Extract from an array REGBUF containing the (raw) register state |
242 | the address in which a function should return its structure value, |
243 | as a CORE_ADDR (or an expression that can be used as one). */ |
244 | |
245 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF)) |
3bf57d21 |
246 | |
247 | #define REGISTER_ADDR(u_ar0, regno) \ |
248 | (((regno) < PS_REGNUM) \ |
249 | ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \ |
250 | : (((regno) == PS_REGNUM) \ |
251 | ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \ |
252 | : (&((struct exception_stack *) (u_ar0))->e_PC))) |
253 | |
254 | #define FP_REGISTER_ADDR(u, regno) \ |
e91b87a3 |
255 | (((char *) \ |
256 | (((regno) < FPC_REGNUM) \ |
257 | ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \ |
258 | : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \ |
259 | - ((char *) (& u))) |
7b4ac7e1 |
260 | \f |
7a67dd45 |
261 | /* Do implement the attach and detach commands. */ |
262 | |
263 | #define ATTACH_DETACH |
264 | \f |
7b4ac7e1 |
265 | /* Describe the pointer in each stack frame to the previous stack frame |
266 | (its caller). */ |
267 | |
268 | /* FRAME_CHAIN takes a frame's nominal address |
269 | and produces the frame's chain-pointer. |
270 | |
271 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address |
272 | and produces the nominal address of the caller frame. |
273 | |
274 | However, if FRAME_CHAIN_VALID returns zero, |
275 | it means the given frame is the outermost one and has no caller. |
276 | In that case, FRAME_CHAIN_COMBINE is not used. */ |
277 | |
3bf57d21 |
278 | /* In the case of the Sun, the frame's nominal address |
7b4ac7e1 |
279 | is the address of a 4-byte word containing the calling frame's address. */ |
280 | |
4187119d |
281 | #define FRAME_CHAIN(thisframe) \ |
282 | (outside_startup_file ((thisframe)->pc) ? \ |
283 | read_memory_integer ((thisframe)->frame, 4) : \ |
284 | 0) |
7b4ac7e1 |
285 | |
286 | #define FRAME_CHAIN_VALID(chain, thisframe) \ |
4187119d |
287 | (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) |
7b4ac7e1 |
288 | |
289 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) |
290 | |
291 | /* Define other aspects of the stack frame. */ |
292 | |
4187119d |
293 | /* A macro that tells us whether the function invocation represented |
294 | by FI does not have a frame on the stack associated with it. If it |
295 | does not, FRAMELESS is set to 1, else 0. */ |
296 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ |
297 | FRAMELESS_LOOK_FOR_PROLOGUE(FI, FRAMELESS) |
298 | |
e91b87a3 |
299 | #define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame + 4, 4)) |
7b4ac7e1 |
300 | |
e91b87a3 |
301 | #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) |
7b4ac7e1 |
302 | |
e91b87a3 |
303 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) |
7b4ac7e1 |
304 | |
3bf57d21 |
305 | /* Set VAL to the number of args passed to frame described by FI. |
306 | Can set VAL to -1, meaning no way to tell. */ |
307 | |
308 | /* We can't tell how many args there are |
309 | now that the C compiler delays popping them. */ |
310 | #define FRAME_NUM_ARGS(val,fi) (val = -1) |
7b4ac7e1 |
311 | |
3bf57d21 |
312 | #if 0 |
7b4ac7e1 |
313 | #define FRAME_NUM_ARGS(val, fi) \ |
e91b87a3 |
314 | { register CORE_ADDR pc = FRAME_SAVED_PC (fi); \ |
7b4ac7e1 |
315 | register int insn = 0177777 & read_memory_integer (pc, 2); \ |
316 | val = 0; \ |
317 | if (insn == 0047757 || insn == 0157374) /* lea W(sp),sp or addaw #W,sp */ \ |
318 | val = read_memory_integer (pc + 2, 2); \ |
319 | else if ((insn & 0170777) == 0050217 /* addql #N, sp */ \ |
320 | || (insn & 0170777) == 0050117) /* addqw */ \ |
321 | { val = (insn >> 9) & 7; if (val == 0) val = 8; } \ |
322 | else if (insn == 0157774) /* addal #WW, sp */ \ |
323 | val = read_memory_integer (pc + 2, 4); \ |
324 | val >>= 2; } |
3bf57d21 |
325 | #endif |
7b4ac7e1 |
326 | |
327 | /* Return number of bytes at start of arglist that are not really args. */ |
328 | |
329 | #define FRAME_ARGS_SKIP 8 |
330 | |
331 | /* Put here the code to store, into a struct frame_saved_regs, |
332 | the addresses of the saved registers of frame described by FRAME_INFO. |
333 | This includes special registers such as pc and fp saved in special |
334 | ways in the stack frame. sp is even more special: |
335 | the address we return for it IS the sp for the next frame. */ |
336 | |
337 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ |
338 | { register int regnum; \ |
339 | register int regmask; \ |
340 | register CORE_ADDR next_addr; \ |
341 | register CORE_ADDR pc; \ |
3bf57d21 |
342 | int nextinsn; \ |
7b4ac7e1 |
343 | bzero (&frame_saved_regs, sizeof frame_saved_regs); \ |
e91b87a3 |
344 | if ((frame_info)->pc >= (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM*4 - 8*12 - 4 \ |
345 | && (frame_info)->pc <= (frame_info)->frame) \ |
346 | { next_addr = (frame_info)->frame; \ |
347 | pc = (frame_info)->frame - CALL_DUMMY_LENGTH - FP_REGNUM * 4 - 8*12 - 4; }\ |
7b4ac7e1 |
348 | else \ |
e91b87a3 |
349 | { pc = get_pc_function_start ((frame_info)->pc); \ |
3bf57d21 |
350 | /* Verify we have a link a6 instruction next; \ |
7b4ac7e1 |
351 | if not we lose. If we win, find the address above the saved \ |
352 | regs using the amount of storage from the link instruction. */\ |
3bf57d21 |
353 | if (044016 == read_memory_integer (pc, 2)) \ |
e91b87a3 |
354 | next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 4), pc+=4; \ |
3bf57d21 |
355 | else if (047126 == read_memory_integer (pc, 2)) \ |
e91b87a3 |
356 | next_addr = (frame_info)->frame + read_memory_integer (pc += 2, 2), pc+=2; \ |
3bf57d21 |
357 | else goto lose; \ |
7b4ac7e1 |
358 | /* If have an addal #-n, sp next, adjust next_addr. */ \ |
359 | if ((0177777 & read_memory_integer (pc, 2)) == 0157774) \ |
360 | next_addr += read_memory_integer (pc += 2, 4), pc += 4; \ |
361 | } \ |
362 | /* next should be a moveml to (sp) or -(sp) or a movl r,-(sp) */ \ |
3bf57d21 |
363 | regmask = read_memory_integer (pc + 2, 2); \ |
364 | /* But before that can come an fmovem. Check for it. */ \ |
365 | nextinsn = 0xffff & read_memory_integer (pc, 2); \ |
366 | if (0xf227 == nextinsn \ |
367 | && (regmask & 0xff00) == 0xe000) \ |
368 | { pc += 4; /* Regmask's low bit is for register fp7, the first pushed */ \ |
369 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ |
370 | if (regmask & 1) \ |
371 | (frame_saved_regs).regs[regnum] = (next_addr -= 12); \ |
372 | regmask = read_memory_integer (pc + 2, 2); } \ |
373 | if (0044327 == read_memory_integer (pc, 2)) \ |
374 | { pc += 4; /* Regmask's low bit is for register 0, the first written */ \ |
7b4ac7e1 |
375 | for (regnum = 0; regnum < 16; regnum++, regmask >>= 1) \ |
376 | if (regmask & 1) \ |
3bf57d21 |
377 | (frame_saved_regs).regs[regnum] = (next_addr += 4) - 4; } \ |
378 | else if (0044347 == read_memory_integer (pc, 2)) \ |
379 | { pc += 4; /* Regmask's low bit is for register 15, the first pushed */ \ |
7b4ac7e1 |
380 | for (regnum = 15; regnum >= 0; regnum--, regmask >>= 1) \ |
381 | if (regmask & 1) \ |
382 | (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ |
3bf57d21 |
383 | else if (0x2f00 == 0xfff0 & read_memory_integer (pc, 2)) \ |
384 | { regnum = 0xf & read_memory_integer (pc, 2); pc += 2; \ |
385 | (frame_saved_regs).regs[regnum] = (next_addr -= 4); } \ |
386 | /* fmovemx to index of sp may follow. */ \ |
387 | regmask = read_memory_integer (pc + 2, 2); \ |
388 | nextinsn = 0xffff & read_memory_integer (pc, 2); \ |
389 | if (0xf236 == nextinsn \ |
390 | && (regmask & 0xff00) == 0xf000) \ |
391 | { pc += 10; /* Regmask's low bit is for register fp0, the first written */ \ |
392 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--, regmask >>= 1) \ |
393 | if (regmask & 1) \ |
394 | (frame_saved_regs).regs[regnum] = (next_addr += 12) - 12; \ |
395 | regmask = read_memory_integer (pc + 2, 2); } \ |
7b4ac7e1 |
396 | /* clrw -(sp); movw ccr,-(sp) may follow. */ \ |
3bf57d21 |
397 | if (0x426742e7 == read_memory_integer (pc, 4)) \ |
7b4ac7e1 |
398 | (frame_saved_regs).regs[PS_REGNUM] = (next_addr -= 4); \ |
399 | lose: ; \ |
e91b87a3 |
400 | (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 8; \ |
401 | (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ |
402 | (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 4; \ |
7b4ac7e1 |
403 | } |
404 | \f |
405 | /* Things needed for making the inferior call functions. */ |
406 | |
407 | /* Push an empty stack frame, to record the current PC, etc. */ |
408 | |
409 | #define PUSH_DUMMY_FRAME \ |
410 | { register CORE_ADDR sp = read_register (SP_REGNUM); \ |
411 | register int regnum; \ |
412 | char raw_buffer[12]; \ |
413 | sp = push_word (sp, read_register (PC_REGNUM)); \ |
414 | sp = push_word (sp, read_register (FP_REGNUM)); \ |
415 | write_register (FP_REGNUM, sp); \ |
416 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ |
417 | { read_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); \ |
418 | sp = push_bytes (sp, raw_buffer, 12); } \ |
419 | for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ |
420 | sp = push_word (sp, read_register (regnum)); \ |
421 | sp = push_word (sp, read_register (PS_REGNUM)); \ |
422 | write_register (SP_REGNUM, sp); } |
423 | |
3bf57d21 |
424 | /* Discard from the stack the innermost frame, |
425 | restoring all saved registers. */ |
7b4ac7e1 |
426 | |
427 | #define POP_FRAME \ |
e91b87a3 |
428 | { register FRAME frame = get_current_frame (); \ |
429 | register CORE_ADDR fp; \ |
3bf57d21 |
430 | register int regnum; \ |
431 | struct frame_saved_regs fsr; \ |
e91b87a3 |
432 | struct frame_info *fi; \ |
3bf57d21 |
433 | char raw_buffer[12]; \ |
e91b87a3 |
434 | fi = get_frame_info (frame); \ |
435 | fp = fi->frame; \ |
436 | get_frame_saved_regs (fi, &fsr); \ |
3bf57d21 |
437 | for (regnum = FP0_REGNUM + 7; regnum >= FP0_REGNUM; regnum--) \ |
438 | if (fsr.regs[regnum]) \ |
439 | { read_memory (fsr.regs[regnum], raw_buffer, 12); \ |
7b4ac7e1 |
440 | write_register_bytes (REGISTER_BYTE (regnum), raw_buffer, 12); }\ |
3bf57d21 |
441 | for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \ |
442 | if (fsr.regs[regnum]) \ |
7b4ac7e1 |
443 | write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ |
3bf57d21 |
444 | if (fsr.regs[PS_REGNUM]) \ |
7b4ac7e1 |
445 | write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \ |
3bf57d21 |
446 | write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ |
447 | write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \ |
448 | write_register (SP_REGNUM, fp + 8); \ |
e91b87a3 |
449 | flush_cached_frames (); \ |
450 | set_current_frame (create_new_frame (read_register (FP_REGNUM),\ |
451 | read_pc ()));} |
7b4ac7e1 |
452 | |
453 | /* This sequence of words is the instructions |
3bf57d21 |
454 | fmovem 0xff,-(sp) |
7b4ac7e1 |
455 | moveml 0xfffc,-(sp) |
456 | clrw -(sp) |
457 | movew ccr,-(sp) |
458 | /..* The arguments are pushed at this point by GDB; |
459 | no code is needed in the dummy for this. |
460 | The CALL_DUMMY_START_OFFSET gives the position of |
461 | the following jsr instruction. *../ |
462 | jsr @#32323232 |
463 | addl #69696969,sp |
464 | bpt |
465 | nop |
3bf57d21 |
466 | Note this is 28 bytes. |
7b4ac7e1 |
467 | We actually start executing at the jsr, since the pushing of the |
468 | registers is done by PUSH_DUMMY_FRAME. If this were real code, |
469 | the arguments for the function called by the jsr would be pushed |
470 | between the moveml and the jsr, and we could allow it to execute through. |
471 | But the arguments have to be pushed by GDB after the PUSH_DUMMY_FRAME is done, |
472 | and we cannot allow the moveml to push the registers again lest they be |
473 | taken for the arguments. */ |
474 | |
3bf57d21 |
475 | #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e414e71} |
7b4ac7e1 |
476 | |
477 | #define CALL_DUMMY_LENGTH 28 |
478 | |
479 | #define CALL_DUMMY_START_OFFSET 12 |
480 | |
481 | /* Insert the specified number of args and function address |
482 | into a call sequence of the above form stored at DUMMYNAME. */ |
483 | |
e91b87a3 |
484 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ |
7b4ac7e1 |
485 | { *(int *)((char *) dummyname + 20) = nargs * 4; \ |
486 | *(int *)((char *) dummyname + 14) = fun; } |
487 | \f |
488 | /* Interface definitions for kernel debugger KDB. */ |
489 | |
490 | /* Map machine fault codes into signal numbers. |
491 | First subtract 0, divide by 4, then index in a table. |
492 | Faults for which the entry in this table is 0 |
493 | are not handled by KDB; the program's own trap handler |
494 | gets to handle then. */ |
495 | |
496 | #define FAULT_CODE_ORIGIN 0 |
497 | #define FAULT_CODE_UNITS 4 |
498 | #define FAULT_TABLE \ |
499 | { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ |
500 | 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ |
501 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
502 | SIGILL } |
503 | |
3bf57d21 |
504 | #ifndef HPUX_ASM |
505 | |
7b4ac7e1 |
506 | /* Start running with a stack stretching from BEG to END. |
507 | BEG and END should be symbols meaningful to the assembler. |
508 | This is used only for kdb. */ |
509 | |
510 | #define INIT_STACK(beg, end) \ |
511 | { asm (".globl end"); \ |
3bf57d21 |
512 | asm ("movel $ end, sp"); \ |
7b4ac7e1 |
513 | asm ("clrl fp"); } |
514 | |
515 | /* Push the frame pointer register on the stack. */ |
516 | #define PUSH_FRAME_PTR \ |
517 | asm ("movel fp, -(sp)"); |
518 | |
519 | /* Copy the top-of-stack to the frame pointer register. */ |
520 | #define POP_FRAME_PTR \ |
521 | asm ("movl (sp), fp"); |
522 | |
523 | /* After KDB is entered by a fault, push all registers |
524 | that GDB thinks about (all NUM_REGS of them), |
525 | so that they appear in order of ascending GDB register number. |
526 | The fault code will be on the stack beyond the last register. */ |
527 | |
528 | #define PUSH_REGISTERS \ |
529 | { asm ("clrw -(sp)"); \ |
530 | asm ("pea 10(sp)"); \ |
531 | asm ("movem $ 0xfffe,-(sp)"); } |
532 | |
533 | /* Assuming the registers (including processor status) have been |
534 | pushed on the stack in order of ascending GDB register number, |
535 | restore them and return to the address in the saved PC register. */ |
536 | |
537 | #define POP_REGISTERS \ |
538 | { asm ("subil $8,28(sp)"); \ |
539 | asm ("movem (sp),$ 0xffff"); \ |
540 | asm ("rte"); } |
3bf57d21 |
541 | |
542 | #else /* HPUX_ASM */ |
543 | |
544 | /* Start running with a stack stretching from BEG to END. |
545 | BEG and END should be symbols meaningful to the assembler. |
546 | This is used only for kdb. */ |
547 | |
548 | #define INIT_STACK(beg, end) \ |
549 | { asm ("global end"); \ |
550 | asm ("mov.l &end,%sp"); \ |
551 | asm ("clr.l %a6"); } |
552 | |
553 | /* Push the frame pointer register on the stack. */ |
554 | #define PUSH_FRAME_PTR \ |
555 | asm ("mov.l %fp,-(%sp)"); |
556 | |
557 | /* Copy the top-of-stack to the frame pointer register. */ |
558 | #define POP_FRAME_PTR \ |
559 | asm ("mov.l (%sp),%fp"); |
560 | |
561 | /* After KDB is entered by a fault, push all registers |
562 | that GDB thinks about (all NUM_REGS of them), |
563 | so that they appear in order of ascending GDB register number. |
564 | The fault code will be on the stack beyond the last register. */ |
565 | |
566 | #define PUSH_REGISTERS \ |
567 | { asm ("clr.w -(%sp)"); \ |
568 | asm ("pea 10(%sp)"); \ |
569 | asm ("movm.l &0xfffe,-(%sp)"); } |
570 | |
571 | /* Assuming the registers (including processor status) have been |
572 | pushed on the stack in order of ascending GDB register number, |
573 | restore them and return to the address in the saved PC register. */ |
574 | |
575 | #define POP_REGISTERS \ |
576 | { asm ("subi.l &8,28(%sp)"); \ |
577 | asm ("mov.m (%sp),&0xffff"); \ |
578 | asm ("rte"); } |
579 | |
580 | #endif /* HPUX_ASM */ |