]>
Commit | Line | Data |
---|---|---|
5140562f JG |
1 | /* Parameters for execution on a Hewlett-Packard PA-RISC machine. |
2 | Copyright 1986, 1987, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. | |
3 | ||
4 | Contributed by the Center for Software Science at the | |
5 | University of Utah ([email protected]). | |
6 | ||
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the Free Software | |
21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
22 | ||
23 | /* Target system byte order. */ | |
24 | ||
25 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
26 | ||
27 | /* Get at various relevent fields of an instruction word. */ | |
28 | ||
29 | #define MASK_5 0x1f | |
30 | #define MASK_11 0x7ff | |
31 | #define MASK_14 0x3fff | |
32 | #define MASK_21 0x1fffff | |
33 | ||
34 | /* This macro gets bit fields using HP's numbering (MSB = 0) */ | |
35 | ||
36 | #define GET_FIELD(X, FROM, TO) \ | |
37 | ((X) >> 31 - (TO) & (1 << ((TO) - (FROM) + 1)) - 1) | |
38 | ||
39 | /* Watch out for NaNs */ | |
40 | ||
41 | #define IEEE_FLOAT | |
42 | ||
43 | /* Groan */ | |
44 | ||
45 | #define ARGS_GROW_DOWN | |
46 | ||
47 | /* Define this if the C compiler puts an underscore at the front | |
48 | of external names before giving them to the linker. */ | |
49 | ||
50 | /* #define NAMES_HAVE_UNDERSCORE */ | |
51 | ||
52 | /* Offset from address of function to start of its code. | |
53 | Zero on most machines. */ | |
54 | ||
55 | #define FUNCTION_START_OFFSET 0 | |
56 | ||
57 | /* Advance PC across any function entry prologue instructions | |
58 | to reach some "real" code. */ | |
59 | ||
60 | /* skip (stw rp, -20(0,sp)); copy 4,1; copy sp, 4; stwm 1,framesize(sp) | |
61 | for gcc, or (stw rp, -20(0,sp); stwm 1, framesize(sp) for hcc */ | |
62 | ||
63 | #define SKIP_PROLOGUE(pc) \ | |
64 | { if (read_memory_integer ((pc), 4) == 0x6BC23FD9) \ | |
65 | { if (read_memory_integer ((pc) + 4, 4) == 0x8040241) \ | |
66 | (pc) += 16; \ | |
67 | else if ((read_memory_integer (pc + 4, 4) & ~MASK_14) == 0x68810000) \ | |
68 | (pc) += 8;} \ | |
69 | else if (read_memory_integer ((pc), 4) == 0x8040241) \ | |
70 | (pc) += 12; \ | |
71 | else if ((read_memory_integer (pc, 4) & ~MASK_14) == 0x68810000) \ | |
72 | (pc) += 4;} | |
73 | ||
74 | /* Immediately after a function call, return the saved pc. | |
75 | Can't go through the frames for this because on some machines | |
76 | the new frame is not set up until the new function executes | |
77 | some instructions. */ | |
78 | ||
79 | #define SAVED_PC_AFTER_CALL(frame) (read_register (RP_REGNUM) & ~3) | |
80 | ||
81 | /* Address of end of stack space. Who knows. */ | |
82 | ||
83 | #define STACK_END_ADDR 0x80000000 | |
84 | ||
85 | /* Stack grows upward */ | |
86 | ||
87 | #define INNER_THAN > | |
88 | ||
89 | ||
90 | /* Sequence of bytes for breakpoint instruction. */ | |
91 | ||
92 | /*#define BREAKPOINT {0x00, 0x00, 0x00, 0x00}*/ | |
93 | #ifdef KERNELDEBUG /* XXX */ | |
94 | #define BREAKPOINT {0x00, 0x00, 0xa0, 0x00} | |
95 | #else | |
96 | #define BREAKPOINT {0x00, 0x01, 0x00, 0x04} | |
97 | #endif | |
98 | ||
99 | /* Amount PC must be decremented by after a breakpoint. | |
100 | This is often the number of bytes in BREAKPOINT | |
101 | but not always. | |
102 | ||
103 | Not on the PA-RISC */ | |
104 | ||
105 | #define DECR_PC_AFTER_BREAK 0 | |
106 | ||
107 | /* return instruction is bv r0(rp) */ | |
108 | ||
109 | #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0xE840C000) | |
110 | ||
111 | /* Return 1 if P points to an invalid floating point value. */ | |
112 | ||
113 | #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ | |
114 | ||
115 | /* Largest integer type */ | |
116 | #define LONGEST long | |
117 | ||
118 | /* Name of the builtin type for the LONGEST type above. */ | |
119 | #define BUILTIN_TYPE_LONGEST builtin_type_long | |
120 | ||
121 | /* Say how long (ordinary) registers are. */ | |
122 | ||
123 | #define REGISTER_TYPE long | |
124 | ||
125 | /* Number of machine registers */ | |
126 | ||
127 | #define NUM_REGS 100 | |
128 | ||
129 | /* Initializer for an array of names of registers. | |
130 | There should be NUM_REGS strings in this initializer. */ | |
131 | ||
132 | #define REGISTER_NAMES \ | |
133 | {"flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9", \ | |
134 | "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", \ | |
135 | "r20", "r21", "r22", "arg3", "arg2", "arg1", "arg0", "dp", "ret0", "ret1", \ | |
136 | "sp", "r31", "sar", "pcoqh", "pcsqh", "pcoqt", "pcsqt", \ | |
137 | "eiem", "iir", "isr", "ior", "ipsw", "goto", "sr4", "sr0", "sr1", "sr2", \ | |
138 | "sr3", "sr5", "sr6", "sr7", "cr0", "cr8", "cr9", "ccr", "cr12", "cr13", \ | |
139 | "cr24", "cr25", "cr26", "mpsfu_high", "mpsfu_low", "mpsfu_ovflo", "pad", \ | |
140 | "fpsr", "fpe1", "fpe2", "fpe3", "fpe4", "fpe5", "fpe6", "fpe7", \ | |
141 | "fp4", "fp5", "fp6", "fp7", "fp8", \ | |
142 | "fp9", "fp10", "fp11", "fp12", "fp13", "fp14", "fp15", \ | |
143 | "fp16", "fp17", "fp18", "fp19", "fp20", "fp21", "fp22", "fp23", \ | |
144 | "fp24", "fp25", "fp26", "fp27", "fp28", "fp29", "fp30", "fp31"} | |
145 | ||
146 | /* Register numbers of various important registers. | |
147 | Note that some of these values are "real" register numbers, | |
148 | and correspond to the general registers of the machine, | |
149 | and some are "phony" register numbers which are too large | |
150 | to be actual register numbers as far as the user is concerned | |
151 | but do serve to get the desired values when passed to read_register. */ | |
152 | ||
153 | #define RP_REGNUM 2 /* return pointer */ | |
154 | #define FP_REGNUM 4 /* Contains address of executing stack */ | |
155 | /* frame */ | |
156 | #define SP_REGNUM 30 /* Contains address of top of stack */ | |
157 | #define SAR_REGNUM 32 /* shift amount register */ | |
158 | #define IPSW_REGNUM 41 /* processor status word. ? */ | |
159 | #define PCOQ_HEAD_REGNUM 33 /* instruction offset queue head */ | |
160 | #define PCSQ_HEAD_REGNUM 34 /* instruction space queue head */ | |
161 | #define PCOQ_TAIL_REGNUM 35 /* instruction offset queue tail */ | |
162 | #define PCSQ_TAIL_REGNUM 36 /* instruction space queue tail */ | |
163 | #define FP0_REGNUM 64 /* floating point reg. 0 */ | |
164 | #define FP4_REGNUM 72 | |
165 | ||
166 | /* compatibility with the rest of gdb. */ | |
167 | #define PC_REGNUM PCOQ_HEAD_REGNUM | |
168 | #define NPC_REGNUM PCOQ_TAIL_REGNUM | |
169 | ||
e0ba1d14 JG |
170 | /* When fetching register values from an inferior or a core file, |
171 | clean them up using this macro. BUF is a char pointer to | |
172 | the raw value of the register in the registers[] array. */ | |
173 | ||
174 | #define CLEAN_UP_REGISTER_VALUE(regno, buf) \ | |
175 | do { \ | |
176 | if ((regno) == PCOQ_HEAD_REGNUM || (regno) == PCOQ_TAIL_REGNUM) \ | |
177 | (buf)[3] &= ~0x3; \ | |
178 | } while (0) | |
179 | ||
5140562f JG |
180 | /* Define DO_REGISTERS_INFO() to do machine-specific formatting |
181 | of register dumps. */ | |
182 | ||
183 | #define DO_REGISTERS_INFO(_regnum, fp) pa_do_registers_info (_regnum, fp) | |
184 | ||
185 | /* PA specific macro to see if the current instruction is nullified. */ | |
186 | #define INSTRUCTION_NULLIFIED ((int)read_register (IPSW_REGNUM) & 0x00200000) | |
187 | ||
188 | /* Total amount of space needed to store our copies of the machine's | |
189 | register state, the array `registers'. */ | |
190 | #define REGISTER_BYTES (32 * 4 + 11 * 4 + 8 * 4 + 12 * 4 + 4 + 32 * 8) | |
191 | ||
192 | /* Index within `registers' of the first byte of the space for | |
193 | register N. */ | |
194 | ||
195 | #define REGISTER_BYTE(N) \ | |
196 | ((N) >= FP4_REGNUM ? ((N) - FP4_REGNUM) * 8 + 288 : (N) * 4) | |
197 | ||
198 | /* Number of bytes of storage in the actual machine representation | |
199 | for register N. On the PA-RISC, all regs are 4 bytes | |
200 | except the floating point regs which are 8 bytes. */ | |
201 | ||
202 | #define REGISTER_RAW_SIZE(N) ((N) < FP4_REGNUM ? 4 : 8) | |
203 | ||
204 | /* Number of bytes of storage in the program's representation | |
205 | for register N. */ | |
206 | ||
207 | #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N) | |
208 | ||
209 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
210 | ||
211 | #define MAX_REGISTER_RAW_SIZE 8 | |
212 | ||
213 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
214 | ||
215 | #define MAX_REGISTER_VIRTUAL_SIZE 8 | |
216 | ||
217 | /* Nonzero if register N requires conversion | |
218 | from raw format to virtual format. */ | |
219 | ||
220 | #define REGISTER_CONVERTIBLE(N) 0 | |
221 | ||
222 | /* Convert data from raw format for register REGNUM | |
223 | to virtual format for register REGNUM. */ | |
224 | ||
225 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ | |
226 | { bcopy ((FROM), (TO), (REGNUM) < FP4_REGNUM ? 4 : 8); } | |
227 | ||
228 | /* Convert data from virtual format for register REGNUM | |
229 | to raw format for register REGNUM. */ | |
230 | ||
231 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ | |
232 | { bcopy ((FROM), (TO), (REGNUM) < FP4_REGNUM ? 4 : 8); } | |
233 | ||
234 | /* Return the GDB type object for the "standard" data type | |
235 | of data in register N. */ | |
236 | ||
237 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
238 | ((N) < FP4_REGNUM ? builtin_type_int : builtin_type_double) | |
239 | ||
240 | /* Store the address of the place in which to copy the structure the | |
241 | subroutine will return. This is called from call_function. */ | |
242 | ||
243 | #define STORE_STRUCT_RETURN(ADDR, SP) {write_register (28, (ADDR)); } | |
244 | ||
245 | /* Extract from an array REGBUF containing the (raw) register state | |
246 | a function return value of type TYPE, and copy that, in virtual format, | |
247 | into VALBUF. */ | |
248 | ||
249 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
250 | bcopy ((REGBUF) + REGISTER_BYTE(TYPE_LENGTH(TYPE) > 4 ? \ | |
251 | FP4_REGNUM :28), VALBUF, TYPE_LENGTH (TYPE)) | |
252 | ||
253 | /* Write into appropriate registers a function return value | |
254 | of type TYPE, given in virtual format. */ | |
255 | ||
256 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
257 | write_register_bytes (TYPE_LENGTH(TYPE) > 4 ? FP4_REGNUM :28, \ | |
258 | VALBUF, TYPE_LENGTH (TYPE)) | |
259 | ||
260 | /* Extract from an array REGBUF containing the (raw) register state | |
261 | the address in which a function should return its structure value, | |
262 | as a CORE_ADDR (or an expression that can be used as one). */ | |
263 | ||
264 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)((REGBUF) + 28)) | |
265 | ||
266 | /* This is a piece of magic that is given a register number REGNO | |
267 | and as BLOCKEND the address in the system of the end of the user structure | |
268 | and stores in ADDR the address in the kernel or core dump | |
269 | of that register. */ | |
270 | ||
271 | ||
272 | /* Describe the pointer in each stack frame to the previous stack frame | |
273 | (its caller). */ | |
274 | ||
275 | /* FRAME_CHAIN takes a frame's nominal address | |
276 | and produces the frame's chain-pointer. | |
277 | ||
278 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address | |
279 | and produces the nominal address of the caller frame. | |
280 | ||
281 | However, if FRAME_CHAIN_VALID returns zero, | |
282 | it means the given frame is the outermost one and has no caller. | |
283 | In that case, FRAME_CHAIN_COMBINE is not used. */ | |
284 | ||
285 | /* In the case of the PA-RISC, the frame's nominal address | |
286 | is the address of a 4-byte word containing the calling frame's | |
287 | address (previous FP). */ | |
288 | ||
289 | #define FRAME_CHAIN(thisframe) \ | |
290 | (inside_entry_file ((thisframe)->pc) ? \ | |
291 | read_memory_integer ((thisframe)->frame, 4) :\ | |
292 | 0) | |
293 | ||
294 | #define FRAME_CHAIN_VALID(chain, thisframe) \ | |
295 | frame_chain_valid (chain, thisframe) | |
296 | ||
297 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) | |
298 | ||
299 | /* Define other aspects of the stack frame. */ | |
300 | ||
301 | /* A macro that tells us whether the function invocation represented | |
302 | by FI does not have a frame on the stack associated with it. If it | |
303 | does not, FRAMELESS is set to 1, else 0. */ | |
304 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ | |
305 | (FRAMELESS) = frameless_look_for_prologue(FI) | |
306 | ||
307 | #define FRAME_SAVED_PC(FRAME) frame_saved_pc (FRAME) | |
308 | ||
309 | #define FRAME_ARGS_ADDRESS(fi) ((fi)->frame) | |
310 | ||
311 | #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame) | |
312 | /* Set VAL to the number of args passed to frame described by FI. | |
313 | Can set VAL to -1, meaning no way to tell. */ | |
314 | ||
315 | /* We can't tell how many args there are | |
316 | now that the C compiler delays popping them. */ | |
317 | #define FRAME_NUM_ARGS(val,fi) (val = -1) | |
318 | ||
319 | /* Return number of bytes at start of arglist that are not really args. */ | |
320 | ||
321 | #define FRAME_ARGS_SKIP 0 | |
322 | ||
323 | /* Put here the code to store, into a struct frame_saved_regs, | |
324 | the addresses of the saved registers of frame described by FRAME_INFO. | |
325 | This includes special registers such as pc and fp saved in special | |
326 | ways in the stack frame. sp is even more special: | |
327 | the address we return for it IS the sp for the next frame. */ | |
328 | ||
329 | /* Deal with dummy functions later. */ | |
330 | ||
331 | #define STW_P(INSN) (((INSN) & 0xfc000000) == 0x68000000) | |
332 | #define ADDIL_P(INSN) (((INSN) & 0xfc000000) == 0x28000000) | |
333 | #define LDO_P(INSN) (((INSN) & 0xfc00c000) == 0x34000000) | |
334 | ||
335 | ||
336 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
337 | { register int regnum; \ | |
338 | register CORE_ADDR next_addr; \ | |
339 | register CORE_ADDR pc; \ | |
340 | unsigned this_insn; \ | |
341 | unsigned address; \ | |
342 | \ | |
343 | bzero (&frame_saved_regs, sizeof frame_saved_regs); \ | |
344 | if ((frame_info)->pc <= ((frame_info)->frame - CALL_DUMMY_LENGTH - \ | |
345 | FP_REGNUM * 4 - 16 * 8) \ | |
346 | && (frame_info)->pc > (frame_info)->frame) \ | |
347 | find_dummy_frame_regs ((frame_info), &(frame_saved_regs)); \ | |
348 | else \ | |
349 | { pc = get_pc_function_start ((frame_info)->pc); \ | |
350 | if (read_memory_integer (pc, 4) == 0x6BC23FD9) \ | |
351 | { (frame_saved_regs).regs[RP_REGNUM] = (frame_info)->frame - 20;\ | |
352 | pc = pc + 4; \ | |
353 | } \ | |
354 | if (read_memory_integer (pc, 4) != 0x8040241) goto lose; \ | |
355 | pc += 8; /* skip "copy 4,1; copy 30, 4" */ \ | |
356 | /* skip either "stw 1,0(4);addil L'fsize,30;ldo R'fsize(1),30" \ | |
357 | or "stwm 1,fsize(30)" */ \ | |
358 | if ((read_memory_integer (pc, 4) & ~MASK_14) == 0x68810000) \ | |
359 | pc += 12; \ | |
360 | else \ | |
361 | pc += 4; \ | |
362 | while (1) \ | |
363 | { this_insn = read_memory_integer(pc, 4); \ | |
364 | if (STW_P (this_insn)) /* stw */ \ | |
365 | { regnum = GET_FIELD (this_insn, 11, 15); \ | |
366 | if (!regnum) goto lose; \ | |
367 | (frame_saved_regs).regs[regnum] = (frame_info)->frame + \ | |
368 | extract_14 (this_insn); \ | |
369 | pc += 4; \ | |
370 | } \ | |
371 | else if (ADDIL_P (this_insn)) /* addil */ \ | |
372 | { int next_insn; \ | |
373 | next_insn = read_memory_integer(pc + 4, 4); \ | |
374 | if (STW_P (next_insn)) /* stw */ \ | |
375 | { regnum = GET_FIELD (this_insn, 6, 10); \ | |
376 | if (!regnum) goto lose; \ | |
377 | (frame_saved_regs).regs[regnum] = (frame_info)->frame +\ | |
378 | (extract_21 (this_insn) << 11) + extract_14 (next_insn);\ | |
379 | pc += 8; \ | |
380 | } \ | |
381 | else \ | |
382 | break; \ | |
383 | } \ | |
384 | else \ | |
385 | { pc += 4; \ | |
386 | break; \ | |
387 | } \ | |
388 | } \ | |
389 | this_insn = read_memory_integer (pc, 4); \ | |
390 | if (LDO_P (this_insn)) \ | |
391 | { next_addr = (frame_info)->frame + extract_14 (this_insn); \ | |
392 | pc += 4; \ | |
393 | } \ | |
394 | else if (ADDIL_P (this_insn)) \ | |
395 | { next_addr = (frame_info)->frame + (extract_21 (this_insn) << 11)\ | |
396 | + extract_14 (read_memory_integer (pc + 4, 4)); \ | |
397 | pc += 8; \ | |
398 | } \ | |
399 | while (1) \ | |
400 | { this_insn = read_memory_integer (pc, 4); \ | |
401 | if ((this_insn & 0xfc001fe0) == 0x2c001220) /* fstds,ma */ \ | |
402 | { regnum = GET_FIELD (this_insn, 27, 31); \ | |
403 | (frame_saved_regs).regs[regnum + FP0_REGNUM] = next_addr; \ | |
404 | next_addr += 8; \ | |
405 | } \ | |
406 | else \ | |
407 | break; \ | |
408 | } \ | |
409 | lose: \ | |
410 | (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \ | |
411 | (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame -4; \ | |
412 | }} | |
413 | \f | |
414 | /* Things needed for making the inferior call functions. */ | |
415 | ||
416 | /* Push an empty stack frame, to record the current PC, etc. */ | |
417 | ||
418 | #define PUSH_DUMMY_FRAME \ | |
419 | { register CORE_ADDR sp = read_register (SP_REGNUM); \ | |
420 | register int regnum; \ | |
421 | int int_buffer; \ | |
422 | double freg_buffer; \ | |
423 | /* Space for "arguments"; the RP goes in here. */ \ | |
424 | sp += 48; \ | |
425 | int_buffer = read_register (RP_REGNUM) | 0x3; \ | |
426 | write_memory (sp - 20, &int_buffer, 4); \ | |
427 | int_buffer = read_register (FP_REGNUM); \ | |
428 | write_memory (sp, &int_buffer, 4); \ | |
429 | write_register (FP_REGNUM, sp); \ | |
430 | sp += 4; \ | |
431 | for (regnum = 1; regnum < 31; regnum++) \ | |
432 | if (regnum != RP_REGNUM && regnum != FP_REGNUM) \ | |
433 | sp = push_word (sp, read_register (regnum)); \ | |
434 | for (regnum = FP0_REGNUM; regnum < NUM_REGS; regnum++) \ | |
435 | { read_register_bytes (REGISTER_BYTE (regnum), &freg_buffer, 8); \ | |
436 | sp = push_bytes (sp, &freg_buffer, 8);} \ | |
437 | sp = push_word (sp, read_register (IPSW_REGNUM)); \ | |
438 | sp = push_word (sp, read_register (SAR_REGNUM)); \ | |
439 | sp = push_word (sp, read_register (PCOQ_TAIL_REGNUM)); \ | |
440 | sp = push_word (sp, read_register (PCSQ_TAIL_REGNUM)); \ | |
441 | write_register (SP_REGNUM, sp);} | |
442 | ||
443 | /* Discard from the stack the innermost frame, | |
444 | restoring all saved registers. */ | |
445 | #define POP_FRAME \ | |
446 | { register FRAME frame = get_current_frame (); \ | |
447 | register CORE_ADDR fp; \ | |
448 | register int regnum; \ | |
449 | struct frame_saved_regs fsr; \ | |
450 | struct frame_info *fi; \ | |
451 | double freg_buffer; \ | |
452 | fi = get_frame_info (frame); \ | |
453 | fp = fi->frame; \ | |
454 | get_frame_saved_regs (fi, &fsr); \ | |
455 | for (regnum = 31; regnum > 0; regnum--) \ | |
456 | if (fsr.regs[regnum]) \ | |
457 | write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \ | |
458 | for (regnum = NUM_REGS - 1; regnum >= FP0_REGNUM ; regnum--) \ | |
459 | if (fsr.regs[regnum]) \ | |
460 | { read_memory (fsr.regs[regnum], &freg_buffer, 8); \ | |
461 | write_register_bytes (REGISTER_BYTE (regnum), &freg_buffer, 8); }\ | |
462 | if (fsr.regs[IPSW_REGNUM]) \ | |
463 | write_register (IPSW_REGNUM, \ | |
464 | read_memory_integer (fsr.regs[IPSW_REGNUM], 4)); \ | |
465 | if (fsr.regs[SAR_REGNUM]) \ | |
466 | write_register (SAR_REGNUM, \ | |
467 | read_memory_integer (fsr.regs[SAR_REGNUM], 4)); \ | |
468 | if (fsr.regs[PCOQ_TAIL_REGNUM]) \ | |
469 | write_register (PCOQ_TAIL_REGNUM, \ | |
470 | read_memory_integer (fsr.regs[PCOQ_TAIL_REGNUM], 4));\ | |
471 | if (fsr.regs[PCSQ_TAIL_REGNUM]) \ | |
472 | write_register (PCSQ_TAIL_REGNUM, \ | |
473 | read_memory_integer (fsr.regs[PCSQ_TAIL_REGNUM], 4));\ | |
474 | write_register (FP_REGNUM, read_memory_integer (fp, 4)); \ | |
475 | write_register (SP_REGNUM, fp + 8); \ | |
476 | flush_cached_frames (); \ | |
477 | set_current_frame (create_new_frame (read_register (FP_REGNUM),\ | |
478 | read_pc ())); } | |
479 | ||
480 | /* This sequence of words is the instructions | |
481 | ||
482 | ; Call stack frame has already been built by gdb. Since we could be calling | |
483 | ; a varargs function, and we do not have the benefit of a stub to put things in | |
484 | ; the right place, we load the first 4 word of arguments into both the general | |
485 | ; and fp registers. | |
486 | call_dummy | |
487 | ldw -36(sp), arg0 | |
488 | ldw -40(sp), arg1 | |
489 | ldw -44(sp), arg2 | |
490 | ldw -48(sp), arg3 | |
491 | ldo -36(sp), r1 | |
492 | fldws 0(0, r1), fr4 | |
493 | fldds -4(0, r1), fr5 | |
494 | fldws -8(0, r1), fr6 | |
495 | fldds -12(0, r1), fr7 | |
496 | ldil 0, r22 ; target will be placed here. | |
497 | ldo 0(r22), r22 | |
498 | ldsid (0,r22), r3 | |
499 | ldil 0, r1 ; _sr4export will be placed here. | |
500 | ldo 0(r1), r1 | |
501 | ldsid (0,r1), r4 | |
502 | combt,=,n r3, r4, text_space ; If target is in data space, do a | |
503 | ble 0(sr5, r22) ; "normal" procedure call | |
504 | copy r31, r2 | |
505 | break 4, 8 | |
506 | text_space ; Otherwise, go through _sr4export, | |
507 | ble (sr4, r1) ; which will return back here. | |
508 | stw 31,-24(r30) | |
509 | break 4, 8 | |
510 | ||
511 | The dummy decides if the target is in text space or data space. If | |
512 | it's in data space, there's no problem because the target can | |
513 | return back to the dummy. However, if the target is in text space, | |
514 | the dummy calls the secret, undocumented routine _sr4export, which | |
515 | calls a function in text space and can return to any space. Instead | |
516 | of including fake instructions to represent saved registers, we | |
517 | know that the frame is associated with the call dummy and treat it | |
518 | specially. */ | |
519 | ||
520 | #define CALL_DUMMY { 0x4bda3fb9, 0x4bd93fb1, 0x4bd83fa9, 0x4bd73fa1, \ | |
521 | 0x37c13fb9, 0x24201004, 0x2c391005, 0x24311006, \ | |
522 | 0x2c291007, 0x22c00000, 0x36d60000, 0x02c010a3, \ | |
523 | 0x20200000, 0x34210000, 0x002010a4, 0x80832012, \ | |
524 | 0xe6c06000, 0x081f0242, 0x00010004, 0xe4202000, \ | |
525 | 0x6bdf3fd1, 0x00010004} | |
526 | ||
527 | #define CALL_DUMMY_LENGTH 88 | |
528 | #define CALL_DUMMY_START_OFFSET 0 | |
529 | /* Insert the specified number of args and function address | |
530 | into a call sequence of the above form stored at DUMMYNAME. */ | |
531 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
532 | { static CORE_ADDR sr4export_address = 0; \ | |
533 | \ | |
534 | if (!sr4export_address) \ | |
535 | { \ | |
536 | struct minimal_symbol *msymbol; \ | |
537 | msymbol = lookup_minimal_symbol ("_sr4export", (struct objfile *) NULL);\ | |
538 | if (msymbol = NULL) \ | |
539 | error ("Can't find an address for _sr4export trampoline"); \ | |
540 | else \ | |
541 | sr4export_address = msymbol -> address; \ | |
542 | } \ | |
543 | dummyname[9] = deposit_21 (fun >> 11, dummyname[9]); \ | |
544 | dummyname[10] = deposit_14 (fun & MASK_11, dummyname[10]); \ | |
545 | dummyname[12] = deposit_21 (sr4export_address >> 11, dummyname[12]); \ | |
546 | dummyname[13] = deposit_14 (sr4export_address & MASK_11, dummyname[13]);\ | |
547 | } | |
548 | ||
e0ba1d14 JG |
549 | |
550 | #define PUSH_ARGUMENTS(nargs, args, sp, struct_return, struct_addr) \ | |
551 | sp = hp_push_arguments(nargs, args, sp, struct_return, struct_addr) | |
552 | ||
5140562f JG |
553 | /* Write the PC to a random value. |
554 | On PA-RISC, we need to be sure that the PC space queue is correct. */ | |
555 | ||
556 | #define WRITE_PC(addr) \ | |
557 | { int space_reg, space = ((addr) >> 30); \ | |
558 | int space_val; \ | |
559 | if (space == 0) \ | |
560 | space_reg = 43; /* Space reg sr4 */ \ | |
561 | else if (space == 1) \ | |
562 | space_reg = 48; /* Space reg sr5*/ \ | |
563 | else \ | |
564 | error ("pc = %x is in illegal space.", addr); \ | |
565 | space_val = read_register (space_reg); \ | |
566 | write_register (PCOQ_HEAD_REGNUM, addr); \ | |
567 | write_register (PCSQ_HEAD_REGNUM, space_val); \ | |
568 | write_register (PCOQ_TAIL_REGNUM, addr); \ | |
569 | write_register (PCSQ_TAIL_REGNUM, space_val);} | |
e0ba1d14 JG |
570 | |
571 | /* Symbol files have two symbol tables. Rather than do this right, | |
572 | like the ELF symbol reading code, massive hackery was added | |
573 | to dbxread.c and partial-stab.h. This flag turns on that | |
574 | hackery, which should all go away FIXME FIXME FIXME FIXME now. */ | |
575 | ||
576 | #define GDB_TARGET_IS_HPPA |