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