7a67dd45 |
1 | /* Definitions to make GDB run on a Pyramidax under OSx 4.0 (4.2bsd). |
2 | Copyright (C) 1988, 1989 Free Software Foundation, Inc. |
3 | |
4 | This file is part of GDB. |
5 | |
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. |
10 | |
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 | /* The FSF prefers to define "pyramid on Pyramid 90x machines; the |
21 | manufacturer insists on "pyr". Define both. */ |
22 | |
23 | #ifndef pyr |
24 | #define pyr |
25 | #endif |
26 | |
27 | #ifndef pyramid |
28 | #define pyramid |
29 | #endif |
30 | |
31 | /* Define PYRAMID_CONTROL_FRAME_DEBUGGING to get copious messages |
32 | about reading the control stack on standard output. This |
33 | makes gdb unusable as a debugger. */ |
34 | |
35 | /* #define PYRAMID_CONTROL_FRAME_DEBUGGING */ |
36 | |
37 | /* Define PYRAMID_FRAME_DEBUGGING |
38 | /* use Pyramid's slightly strange ptrace */ |
39 | #define PYRAMID_PTRACE |
40 | |
41 | /* Traditional Unix virtual address spaces have thre regions: text, |
42 | data and stack. The text, initialised data, and uninitialised data |
43 | are represented in separate segments of the a.out file. |
44 | When a process dumps core, the data and stack regions are written |
45 | to a core file. This gives a debugger enough information to |
46 | reconstruct (and debug) the virtual address space at the time of |
47 | the coredump. |
48 | Pyramids have an distinct fourth region of the virtual address |
49 | space, in which the contents of the windowed registers are stacked |
50 | in fixed-size frames. Pyramid refer to this region as the control |
51 | stack. Each call (or trap) automatically allocates a new register |
52 | frame; each return deallocates the current frame and restores the |
53 | windowed registers to their values before the call. |
54 | |
55 | When dumping core, the control stack is written to a core files as |
56 | a third segment. The core-handling functions need to know to deal |
57 | with it. */ |
58 | /* Tell core.c there is an extra segment. */ |
59 | #define REG_STACK_SEGMENT |
60 | /* Tell dep.c what the extra segment is. */ |
61 | #define PYRAMID_CORE |
62 | |
63 | /* Define the bit, byte, and word ordering of the machine. */ |
64 | #define BITS_BIG_ENDIAN |
65 | #define BYTES_BIG_ENDIAN |
66 | #define WORDS_BIG_ENDIAN |
67 | |
68 | /* Floating point is IEEE compatible on most Pyramid hardware |
69 | (Older processors do not have IEEE NaNs). */ |
70 | #define IEEE_FLOAT |
71 | |
72 | #define NO_SIGINTERRUPT |
73 | |
74 | #define HAVE_WAIT_STRUCT |
75 | |
76 | /* Get rid of any system-imposed stack limit if possible. */ |
77 | |
78 | #define SET_STACK_LIMIT_HUGE |
79 | |
80 | /* Define this if the C compiler puts an underscore at the front |
81 | of external names before giving them to the linker. */ |
82 | |
83 | #define NAMES_HAVE_UNDERSCORE |
84 | |
85 | /* Debugger information will be in DBX format. */ |
86 | |
87 | #define READ_DBX_FORMAT |
88 | |
89 | /* Offset from address of function to start of its code. |
90 | Zero on most machines. */ |
91 | |
92 | #define FUNCTION_START_OFFSET 0 |
93 | |
94 | /* Advance PC across any function entry prologue instructions |
95 | to reach some "real" code. */ |
96 | |
97 | /* FIXME -- do we want to skip insns to allocate the local frame? |
98 | If so, what do they look like? |
99 | This is becoming harder, since tege@sics.SE wants to change |
100 | gcc to not output a prologue when no frame is needed. */ |
101 | #define SKIP_PROLOGUE(pc) do {} while (0) |
102 | |
103 | |
104 | /* Immediately after a function call, return the saved pc. |
105 | Can't always go through the frames for this because on some machines |
106 | the new frame is not set up until the new function executes |
107 | some instructions. */ |
108 | |
109 | #define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame) |
110 | |
111 | /* This is the amount to subtract from u.u_ar0 |
112 | to get the offset in the core file of the register values. */ |
113 | |
114 | #define KERNEL_U_ADDR (0x80000000 - (UPAGES * NBPG)) |
115 | |
116 | /* Address of end of stack space. */ |
117 | /* This seems to be right for the 90x comp.vuw.ac.nz. |
118 | The correct value at any site may be a function of the configured |
119 | maximum control stack depth. If so, I don't know where the |
120 | control-stack depth is configured, so I can't #include it here. */ |
121 | #define STACK_END_ADDR (0xc00cc000) |
122 | |
123 | /* Register window stack (Control stack) stack definitions |
124 | - Address of beginning of control stack. |
125 | - size of control stack frame |
126 | (Note that since crts0 is usually the first function called, |
127 | main()'s control stack is one frame (0x80 bytes) beyond this value. */ |
128 | |
129 | #define CONTROL_STACK_ADDR (0xc00cd000) |
130 | |
131 | /* Bytes in a register window -- 16 parameter regs, 16 local regs |
132 | for each call, is 32 regs * 4 bytes */ |
133 | |
134 | #define CONTROL_STACK_FRAME_SIZE (32*4) |
135 | |
136 | /* FIXME. On a pyr, Data Stack grows downward; control stack goes upwards. |
137 | Which direction should we use for INNER_THAN, PC_INNER_THAN ?? */ |
138 | |
139 | #define INNER_THAN < |
140 | #define PC_INNER_THAN > |
141 | |
142 | /* Stack has strict alignment. */ |
143 | |
144 | #define STACK_ALIGN(ADDR) (((ADDR)+3)&-4) |
145 | |
146 | /* Sequence of bytes for breakpoint instruction. */ |
147 | |
148 | #define BREAKPOINT {0xf0, 00, 00, 00} |
149 | |
150 | /* Amount PC must be decremented by after a breakpoint. |
151 | This is often the number of bytes in BREAKPOINT |
152 | but not always. */ |
153 | |
154 | #define DECR_PC_AFTER_BREAK 0 |
155 | |
156 | /* Nonzero if instruction at PC is a return instruction. |
157 | On a pyr, this is either "ret" or "retd". |
158 | It would be friendly to check that any "retd" always had an |
159 | argument of 0, since anything else is invalid. */ |
160 | |
161 | #define ABOUT_TO_RETURN(pc) \ |
162 | (((read_memory_integer (pc, 2) & 0x3ff0) == 0x3090) || \ |
163 | ((read_memory_integer (pc, 2) & 0x0ff0) == 0x00a0)) |
164 | |
165 | /* Return 1 if P points to an invalid floating point value. |
166 | LEN is the length in bytes -- not relevant on the Vax. */ |
167 | /* FIXME -- this is ok for a vax, bad for big-endian ieee format. |
168 | I would use the definition for a Sun; but it is no better! */ |
169 | |
170 | #define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000) |
171 | |
172 | /* Larges integer type */ |
173 | #define LONGEST long |
174 | |
175 | /* Name of the builtin type for the LONGEST type above. */ |
176 | #define BUILTIN_TYPE_LONGEST builtin_type_long |
177 | |
178 | /* Say how long (ordinary) registers are. */ |
179 | |
180 | #define REGISTER_TYPE long |
181 | |
182 | /* Number of machine registers */ |
183 | /* pyramids have 64, plus one for the PSW; plus perhaps one more for the |
184 | kernel stack pointer (ksp) and control-stack pointer (CSP) */ |
185 | |
186 | #define NUM_REGS 67 |
187 | |
188 | /* Initializer for an array of names of registers. |
189 | There should be NUM_REGS strings in this initializer. */ |
190 | |
191 | #define REGISTER_NAMES \ |
192 | {"gr0", "gr1", "gr2", "gr3", "gr4", "gr5", "gr6", "gr7", \ |
193 | "gr8", "gr9", "gr10", "gr11", "logpsw", "cfp", "sp", "pc", \ |
194 | "pr0", "pr1", "pr2", "pr3", "pr4", "pr5", "pr6", "pr7", \ |
195 | "pr8", "pr9", "pr10", "pr11", "pr12", "pr13", "pr14", "pr15", \ |
196 | "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", \ |
197 | "lr8", "lr9", "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", \ |
198 | "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \ |
199 | "tr8", "tr9", "tr10", "tr11", "tr12", "tr13", "tr14", "tr15", \ |
200 | "psw", "ksp", "csp"} |
201 | |
202 | /* Register numbers of various important registers. |
203 | Note that some of these values are "real" register numbers, |
204 | and correspond to the general registers of the machine, |
205 | and some are "phony" register numbers which are too large |
206 | to be actual register numbers as far as the user is concerned |
207 | but do serve to get the desired values when passed to read_register. */ |
208 | |
209 | /* pseudo-registers: */ |
210 | #define PS_REGNUM 64 /* Contains processor status */ |
211 | #define PSW_REGNUM 64 /* Contains current psw, whatever it is.*/ |
212 | #define CSP_REGNUM 65 /* address of this control stack frame*/ |
213 | #define KSP_REGNUM 66 /* Contains process's Kernel Stack Pointer */ |
214 | |
215 | #define CFP_REGNUM 13 /* Current data-stack frame ptr */ |
216 | #define TR0_REGNUM 48 /* After function call, contains |
217 | function result */ |
218 | |
219 | /* Registers interesting to the machine-independent part of gdb*/ |
220 | |
221 | #define FP_REGNUM CSP_REGNUM /* Contains address of executing (control) |
222 | stack frame */ |
223 | #define SP_REGNUM 14 /* Contains address of top of stack -??*/ |
224 | #define PC_REGNUM 15 /* Contains program counter */ |
225 | |
226 | /* Define DO_REGISTERS_INFO() to do machine-specific formatting |
227 | of register dumps. */ |
228 | |
229 | #define DO_REGISTERS_INFO(_regnum) pyr_do_registers_info(_regnum) |
230 | |
231 | /* need this so we can find the global registers: they never get saved. */ |
232 | extern unsigned int global_reg_offset; |
233 | extern unsigned int last_frame_offset; |
234 | extern unsigned int reg_stack_start; |
235 | extern unsigned int reg_stack_end; |
236 | extern unsigned int reg_stack_offset; |
237 | |
238 | |
239 | /* Define offsets of registers in the core file (or maybe u area) */ |
240 | #define REGISTER_U_ADDR(addr, blockend, regno) \ |
241 | { struct user __u; \ |
242 | addr = blockend + (regno - 16 ) * 4; \ |
243 | if (regno == 67) { \ |
244 | printf("\\geting reg 67\\"); \ |
245 | addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ |
246 | } else if (regno == KSP_REGNUM) { \ |
247 | printf("\\geting KSP (reg %d)\\", KSP_REGNUM); \ |
248 | addr = (int)(&__u.u_pcb.pcb_ksp) - (int) &__u; \ |
249 | } else if (regno == CSP_REGNUM) { \ |
250 | printf("\\geting CSP (reg %d\\",CSP_REGNUM); \ |
251 | addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ |
252 | } else if (regno == 64) { \ |
253 | printf("\\geting reg 64\\"); \ |
254 | addr = (int)(&__u.u_pcb.pcb_csp) - (int) &__u; \ |
255 | } else if (regno == PS_REGNUM) \ |
256 | addr = blockend - 4; \ |
257 | else if (1 && ((16 > regno) && (regno > 11))) \ |
258 | addr = last_frame_offset + (4 *(regno+32)); \ |
259 | else if (0 && (12 > regno)) \ |
260 | addr = global_reg_offset + (4 *regno); \ |
261 | else if (16 > regno) \ |
262 | addr = global_reg_offset + (4 *regno); \ |
263 | else \ |
264 | addr = blockend + (regno - 16 ) * 4; \ |
265 | } |
266 | |
267 | |
268 | |
269 | /* Total amount of space needed to store our copies of the machine's |
270 | register state, the array `registers'. */ |
271 | #define REGISTER_BYTES (NUM_REGS*4) |
272 | |
273 | /* the Pyramid has register windows. */ |
274 | |
275 | #define HAVE_REGISTER_WINDOWS |
276 | |
277 | /* Is this register part of the register window system? A yes answer |
278 | implies that 1) The name of this register will not be the same in |
279 | other frames, and 2) This register is automatically "saved" (out |
280 | registers shifting into ins counts) upon subroutine calls and thus |
281 | there is no need to search more than one stack frame for it. */ |
282 | |
283 | #define REGISTER_IN_WINDOW_P(regnum) \ |
284 | ((regnum) >= 16 && (regnum) < 64) |
285 | |
286 | /* Index within `registers' of the first byte of the space for |
287 | register N. */ |
288 | |
289 | #define REGISTER_BYTE(N) ((N) * 4) |
290 | |
291 | /* Number of bytes of storage in the actual machine representation |
292 | for register N. On the Pyramid, all regs are 4 bytes. */ |
293 | |
294 | #define REGISTER_RAW_SIZE(N) 4 |
295 | |
296 | /* Number of bytes of storage in the program's representation |
297 | for register N. On the Pyramid, all regs are 4 bytes. */ |
298 | |
299 | #define REGISTER_VIRTUAL_SIZE(N) 4 |
300 | |
301 | /* Largest value REGISTER_RAW_SIZE can have. */ |
302 | |
303 | #define MAX_REGISTER_RAW_SIZE 4 |
304 | |
305 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ |
306 | |
307 | #define MAX_REGISTER_VIRTUAL_SIZE 4 |
308 | |
309 | /* Nonzero if register N requires conversion |
310 | from raw format to virtual format. */ |
311 | |
312 | #define REGISTER_CONVERTIBLE(N) 0 |
313 | |
314 | /* Convert data from raw format for register REGNUM |
315 | to virtual format for register REGNUM. */ |
316 | |
317 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ |
318 | bcopy ((FROM), (TO), 4); |
319 | |
320 | /* Convert data from virtual format for register REGNUM |
321 | to raw format for register REGNUM. */ |
322 | |
323 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ |
324 | bcopy ((FROM), (TO), 4); |
325 | |
326 | /* Return the GDB type object for the "standard" data type |
327 | of data in register N. */ |
328 | |
329 | #define REGISTER_VIRTUAL_TYPE(N) builtin_type_int |
330 | |
331 | /* FIXME: It seems impossible for both EXTRACT_RETURN_VALUE and |
332 | STORE_RETURN_VALUE to be correct. */ |
333 | |
334 | /* Store the address of the place in which to copy the structure the |
335 | subroutine will return. This is called from call_function. */ |
336 | |
337 | /****FIXME****/ |
338 | #define STORE_STRUCT_RETURN(ADDR, SP) \ |
339 | { write_register (TR0_REGNUM, (ADDR)); } |
340 | |
341 | /* Extract from an array REGBUF containing the (raw) register state |
342 | a function return value of type TYPE, and copy that, in virtual format, |
343 | into VALBUF. */ |
344 | |
345 | /* Note that on a register-windowing machine (eg, Pyr, SPARC), this is |
346 | where the value is found after the function call -- ie, it should |
347 | correspond to GNU CC's FUNCTION_VALUE rather than FUNCTION_OUTGOING_VALUE.*/ |
348 | |
349 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ |
350 | bcopy (((int *)(REGBUF))+TR0_REGNUM, VALBUF, TYPE_LENGTH (TYPE)) |
351 | |
352 | /* Write into appropriate registers a function return value |
353 | of type TYPE, given in virtual format. */ |
354 | /* on pyrs, values are returned in */ |
355 | |
356 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ |
357 | write_register_bytes (REGISTER_BYTE(TR0_REGNUM), VALBUF, TYPE_LENGTH (TYPE)) |
358 | |
359 | /* Extract from an array REGBUF containing the (raw) register state |
360 | the address in which a function should return its structure value, |
361 | as a CORE_ADDR (or an expression that can be used as one). */ |
362 | /* FIXME */ |
363 | #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) \ |
364 | ( ((int *)(REGBUF)) [TR0_REGNUM]) |
365 | |
366 | /* Compensate for lack of `vprintf' function. */ |
367 | #define vprintf(format, ap) _doprnt (format, ap, stdout) |
368 | \f |
369 | /* Describe the pointer in each stack frame to the previous stack frame |
370 | (its caller). */ |
371 | |
372 | #define EXTRA_FRAME_INFO \ |
373 | FRAME_ADDR bottom; \ |
374 | CORE_ADDR frame_cfp; \ |
375 | CORE_ADDR frame_window_addr; |
376 | |
377 | #define INIT_EXTRA_FRAME_INFO(fci) \ |
378 | do { \ |
379 | (fci)->frame_window_addr = (fci)->frame; \ |
380 | (fci)->bottom = \ |
381 | ((fci)->next ? \ |
382 | ((fci)->frame == (fci)->next_frame ? \ |
383 | (fci)->next->bottom : (fci)->next->frame) : \ |
384 | read_register (SP_REGNUM)); \ |
385 | (fci)->frame_cfp = \ |
386 | read_register (CFP_REGNUM); \ |
387 | /***fprintf (stderr, \ |
388 | "[[creating new frame for %0x,pc=%0x,csp=%0x]]\n", \ |
389 | (fci)->frame, (fci)->pc,(fci)->frame_cfp);*/ \ |
390 | } while (0); |
391 | |
392 | /* FRAME_CHAIN takes a frame's nominal address |
393 | and produces the frame's chain-pointer. |
394 | |
395 | FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address |
396 | and produces the nominal address of the caller frame. |
397 | |
398 | However, if FRAME_CHAIN_VALID returns zero, |
399 | it means the given frame is the outermost one and has no caller. |
400 | In that case, FRAME_CHAIN_COMBINE is not used. */ |
401 | |
402 | /* In the case of the pyr, the frame's nominal address is the address |
403 | of parameter register 0. The previous frame is found 32 words up. */ |
404 | |
405 | #define FRAME_CHAIN(thisframe) \ |
406 | ( (thisframe) -> frame - CONTROL_STACK_FRAME_SIZE) |
407 | |
408 | #define FRAME_CHAIN_VALID(chain, thisframe) \ |
409 | (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) |
410 | |
411 | /*((thisframe) >= CONTROL_STACK_ADDR))*/ |
412 | |
413 | #define FRAME_CHAIN_COMBINE(chain, thisframe) (chain) |
414 | |
415 | /* Define other aspects of the stack frame. */ |
416 | |
417 | /* A macro that tells us whether the function invocation represented |
418 | by FI does not have a frame on the stack associated with it. If it |
419 | does not, FRAMELESS is set to 1, else 0. |
420 | |
421 | I do not understand what this means on a Pyramid, where functions |
422 | *always* have a control-stack frame, but may or may not have a |
423 | frame on the data stack. Since GBD uses the value of the |
424 | control stack pointer as its "address" of a frame, FRAMELESS |
425 | is always 1, so does not need to be defined. */ |
426 | |
427 | |
428 | /* Where is the PC for a specific frame */ |
429 | |
430 | #define FRAME_SAVED_PC(fi) \ |
431 | ((CORE_ADDR) (read_memory_integer ( (fi) -> frame + 60, 4))) |
432 | |
433 | /* There may be bugs in FRAME_ARGS_ADDRESS and FRAME_LOCALS_ADDRESS; |
434 | or there may be bugs in accessing the registers that break |
435 | their definitions. |
436 | Having the macros expand into functions makes them easier to debug. |
437 | When the bug is finally located, the inline macro defintions can |
438 | be un-#if 0ed, and frame_args_addr and frame_locals_address can |
439 | be deleted from pyr-dep.c */ |
440 | |
441 | /* If the argument is on the stack, it will be here. */ |
442 | #define FRAME_ARGS_ADDRESS(fi) \ |
443 | frame_args_addr(fi) |
444 | |
445 | #define FRAME_LOCALS_ADDRESS(fi) \ |
446 | frame_locals_address(fi) |
447 | |
448 | /* The following definitions doesn't seem to work. |
449 | I don't understand why. */ |
450 | #if 0 |
451 | #define FRAME_ARGS_ADDRESS(fi) \ |
452 | /*(FRAME_FP(fi) + (13*4))*/ (read_register (CFP_REGNUM)) |
453 | |
454 | #define FRAME_LOCALS_ADDRESS(fi) \ |
455 | ((fi)->frame +(16*4)) |
456 | |
457 | #endif /* 0 */ |
458 | |
459 | /* Return number of args passed to a frame. |
460 | Can return -1, meaning no way to tell. */ |
461 | |
462 | #define FRAME_NUM_ARGS(val, fi) (val = -1) |
463 | |
464 | /* Return number of bytes at start of arglist that are not really args. */ |
465 | |
466 | #define FRAME_ARGS_SKIP 0 |
467 | |
468 | /* Put here the code to store, into a struct frame_saved_regs, |
469 | the addresses of the saved registers of frame described by FRAME_INFO. |
470 | This includes special registers such as pc and fp saved in special |
471 | ways in the stack frame. sp is even more special: |
472 | the address we return for it IS the sp for the next frame. |
473 | |
474 | Note that on register window machines, we are currently making the |
475 | assumption that window registers are being saved somewhere in the |
476 | frame in which they are being used. If they are stored in an |
477 | inferior frame, find_saved_register will break. |
478 | |
479 | On pyrs, frames of window registers are stored contiguously on a |
480 | separate stack. All window registers are always stored. |
481 | The pc and psw (gr15 and gr14) are also always saved: the call |
482 | insn saves them in pr15 and pr14 of the new frame (tr15,tr14 of the |
483 | old frame). |
484 | The data-stack frame pointer (CFP) is only saved in functions which |
485 | allocate a (data)stack frame (with "adsf"). We detect them by |
486 | looking at the first insn of the procedure. |
487 | |
488 | Other non-window registers (gr0-gr11) are never saved. Pyramid's C |
489 | compiler and gcc currently ignore them, so it's not an issue. */ |
490 | |
491 | #define FRAME_FIND_SAVED_REGS(fi_p, frame_saved_regs) \ |
492 | { register int regnum; \ |
493 | register CORE_ADDR pc; \ |
494 | register CORE_ADDR fn_start_pc; \ |
495 | register int first_insn; \ |
496 | register CORE_ADDR prev_cf_addr; \ |
497 | register int window_ptr; \ |
498 | FRAME fid = FRAME_INFO_ID (fi_p); \ |
499 | if (!fid) fatal ("Bad frame info struct in FRAME_FIND_SAVED_REGS"); \ |
500 | bzero (&(frame_saved_regs), sizeof (frame_saved_regs)); \ |
501 | \ |
502 | window_ptr = prev_cf_addr = FRAME_FP(fi_p); \ |
503 | \ |
504 | for (regnum = 16 ; regnum < 64; regnum++,window_ptr+=4) \ |
505 | { \ |
506 | (frame_saved_regs).regs[regnum] = window_ptr; \ |
507 | } \ |
508 | \ |
509 | /* In each window, psw, and pc are "saved" in tr14,tr15. */ \ |
510 | /*** psw is sometimes saved in gr12 (so sez <sys/pcb.h>) */ \ |
511 | (frame_saved_regs).regs[PS_REGNUM] = FRAME_FP(fi_p) + (14*4); \ |
512 | \ |
513 | /*(frame_saved_regs).regs[PC_REGNUM] = (frame_saved_regs).regs[31];*/ \ |
514 | (frame_saved_regs).regs[PC_REGNUM] = FRAME_FP(fi_p) + ((15+32)*4); \ |
515 | \ |
516 | /* Functions that allocate a frame save sp *where*? */ \ |
517 | /*first_insn = read_memory_integer (get_pc_function_start ((fi_p)->pc),4); */ \ |
518 | \ |
519 | fn_start_pc = (get_pc_function_start ((fi_p)->pc)); \ |
520 | first_insn = read_memory_integer(fn_start_pc, 4); \ |
521 | \ |
522 | if (0x08 == ((first_insn >> 20) &0x0ff)) { \ |
523 | /* NB: because WINDOW_REGISTER_P(cfp) is false, a saved cfp \ |
524 | in this frame is only visible in this frame's callers. \ |
525 | That means the cfp we mark saved is my caller's cfp, ie pr13. \ |
526 | I don't understand why we don't have to do that for pc, too. */ \ |
527 | \ |
528 | (frame_saved_regs).regs[CFP_REGNUM] = FRAME_FP(fi_p)+(13*4); \ |
529 | \ |
530 | (frame_saved_regs).regs[SP_REGNUM] = \ |
531 | read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ |
532 | } \ |
533 | \ |
534 | /* \ |
535 | *(frame_saved_regs).regs[CFP_REGNUM] = (frame_saved_regs).regs[61]; \ |
536 | * (frame_saved_regs).regs[SP_REGNUM] = \ |
537 | * read_memory_integer (FRAME_FP(fi_p)+((13+32)*4),4); \ |
538 | */ \ |
539 | \ |
540 | (frame_saved_regs).regs[CSP_REGNUM] = prev_cf_addr; \ |
541 | } |
542 | \f |
543 | /* Things needed for making the inferior call functions. */ |
544 | |
545 | /* These are all lies. These macro definitions are appropriate for a |
546 | SPARC. On a pyramid, pushing a dummy frame will |
547 | surely involve writing the control stack pointer, |
548 | then saving the pc. This requires a privileged instruction. |
549 | Maybe one day Pyramid can be persuaded to add a syscall to do this. |
550 | Until then, we are out of luck. */ |
551 | |
552 | /* Push an empty stack frame, to record the current PC, etc. */ |
553 | |
554 | #define PUSH_DUMMY_FRAME \ |
555 | { register CORE_ADDR sp = read_register (SP_REGNUM);\ |
556 | register int regnum; \ |
557 | sp = push_word (sp, 0); /* arglist */ \ |
558 | for (regnum = 11; regnum >= 0; regnum--) \ |
559 | sp = push_word (sp, read_register (regnum)); \ |
560 | sp = push_word (sp, read_register (PC_REGNUM)); \ |
561 | sp = push_word (sp, read_register (FP_REGNUM)); \ |
562 | /* sp = push_word (sp, read_register (AP_REGNUM));*/ \ |
563 | sp = push_word (sp, (read_register (PS_REGNUM) & 0xffef) \ |
564 | + 0x2fff0000); \ |
565 | sp = push_word (sp, 0); \ |
566 | write_register (SP_REGNUM, sp); \ |
567 | write_register (FP_REGNUM, sp); \ |
568 | /* write_register (AP_REGNUM, sp + 17 * sizeof (int));*/ } |
569 | |
570 | /* Discard from the stack the innermost frame, restoring all registers. */ |
571 | |
572 | #define POP_FRAME \ |
573 | { register CORE_ADDR fp = read_register (FP_REGNUM); \ |
574 | register int regnum; \ |
575 | register int regmask = read_memory_integer (fp + 4, 4); \ |
576 | write_register (PS_REGNUM, \ |
577 | (regmask & 0xffff) \ |
578 | | (read_register (PS_REGNUM) & 0xffff0000)); \ |
579 | write_register (PC_REGNUM, read_memory_integer (fp + 16, 4)); \ |
580 | write_register (FP_REGNUM, read_memory_integer (fp + 12, 4)); \ |
581 | /* write_register (AP_REGNUM, read_memory_integer (fp + 8, 4));*/ \ |
582 | fp += 16; \ |
583 | for (regnum = 0; regnum < 12; regnum++) \ |
584 | if (regmask & (0x10000 << regnum)) \ |
585 | write_register (regnum, read_memory_integer (fp += 4, 4)); \ |
586 | fp = fp + 4 + ((regmask >> 30) & 3); \ |
587 | if (regmask & 0x20000000) \ |
588 | { regnum = read_memory_integer (fp, 4); \ |
589 | fp += (regnum + 1) * 4; } \ |
590 | write_register (SP_REGNUM, fp); \ |
591 | set_current_frame (read_register (FP_REGNUM)); } |
592 | |
593 | /* This sequence of words is the instructions |
594 | calls #69, @#32323232 |
595 | bpt |
596 | Note this is 8 bytes. */ |
597 | |
598 | #define CALL_DUMMY {0x329f69fb, 0x03323232} |
599 | |
600 | #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ |
601 | |
602 | /* Insert the specified number of args and function address |
603 | into a call sequence of the above form stored at DUMMYNAME. */ |
604 | |
605 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \ |
606 | { *((char *) dummyname + 1) = nargs; \ |
607 | *(int *)((char *) dummyname + 3) = fun; } |
608 | \f |
609 | /* Interface definitions for kernel debugger KDB. */ |
610 | |
611 | /* I have *no idea* how to debug OSx kernels, so this |
612 | is flushed, possible forever. */ |