]>
Commit | Line | Data |
---|---|---|
dd3b648e | 1 | /* Definitions to make GDB run on Convex Unix (4bsd) |
fbcb5095 | 2 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
dd3b648e RP |
3 | |
4 | This file is part of GDB. | |
5 | ||
99a7de40 | 6 | This program is free software; you can redistribute it and/or modify |
dd3b648e | 7 | it under the terms of the GNU General Public License as published by |
99a7de40 JG |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
dd3b648e | 10 | |
99a7de40 | 11 | This program is distributed in the hope that it will be useful, |
dd3b648e RP |
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 | |
99a7de40 JG |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
dd3b648e RP |
19 | |
20 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
21 | ||
dd3b648e RP |
22 | /* Define this if the C compiler puts an underscore at the front |
23 | of external names before giving them to the linker. */ | |
24 | ||
25 | #define NAMES_HAVE_UNDERSCORE | |
26 | ||
dd3b648e RP |
27 | /* There is come problem with the debugging symbols generated by the |
28 | compiler such that the debugging symbol for the first line of a | |
29 | function overlap with the function prologue. */ | |
30 | #define PROLOGUE_FIRSTLINE_OVERLAP | |
31 | ||
32 | /* When convex pcc says CHAR or SHORT, it provides the correct address. */ | |
33 | ||
34 | #define BELIEVE_PCC_PROMOTION 1 | |
35 | ||
36 | /* Symbol types to ignore. */ | |
37 | /* 0xc4 is N_MONPT. Use the numeric value for the benefit of people | |
38 | with (rather) old OS's. */ | |
39 | #define IGNORE_SYMBOL(TYPE) \ | |
40 | (((TYPE) & ~N_EXT) == N_TBSS \ | |
41 | || ((TYPE) & ~N_EXT) == N_TDATA \ | |
42 | || ((TYPE) & ~N_EXT) == 0xc4) | |
43 | ||
44 | /* Offset from address of function to start of its code. | |
45 | Zero on most machines. */ | |
46 | ||
47 | #define FUNCTION_START_OFFSET 0 | |
48 | ||
49 | /* Advance PC across any function entry prologue instructions | |
50 | to reach some "real" code. | |
51 | Convex prolog is: | |
52 | [sub.w #-,sp] in one of 3 possible sizes | |
53 | [mov psw,- fc/vc main program prolog | |
54 | and #-,- (skip it because the "mov psw" saves the | |
55 | mov -,psw] T bit, so continue gets a surprise trap) | |
56 | [and #-,sp] fc/vc O2 main program prolog | |
57 | [ld.- -(ap),-] pcc/gcc register arg loads | |
58 | */ | |
59 | ||
60 | #define SKIP_PROLOGUE(pc) \ | |
61 | { int op, ix; \ | |
62 | op = read_memory_integer (pc, 2); \ | |
63 | if ((op & 0xffc7) == 0x5ac0) pc += 2; \ | |
64 | else if (op == 0x1580) pc += 4; \ | |
65 | else if (op == 0x15c0) pc += 6; \ | |
66 | if ((read_memory_integer (pc, 2) & 0xfff8) == 0x7c40 \ | |
67 | && (read_memory_integer (pc + 2, 2) & 0xfff8) == 0x1240 \ | |
68 | && (read_memory_integer (pc + 8, 2) & 0xfff8) == 0x7c48) \ | |
69 | pc += 10; \ | |
70 | if (read_memory_integer (pc, 2) == 0x1240) pc += 6; \ | |
71 | for (;;) { \ | |
72 | op = read_memory_integer (pc, 2); \ | |
73 | ix = (op >> 3) & 7; \ | |
74 | if (ix != 6) break; \ | |
75 | if ((op & 0xfcc0) == 0x3000) pc += 4; \ | |
76 | else if ((op & 0xfcc0) == 0x3040) pc += 6; \ | |
77 | else if ((op & 0xfcc0) == 0x2800) pc += 4; \ | |
78 | else if ((op & 0xfcc0) == 0x2840) pc += 6; \ | |
79 | else break;}} | |
80 | ||
81 | /* Immediately after a function call, return the saved pc. | |
82 | (ignore frame and return *$sp so we can handle both calls and callq) */ | |
83 | ||
84 | #define SAVED_PC_AFTER_CALL(frame) \ | |
85 | read_memory_integer (read_register (SP_REGNUM), 4) | |
86 | ||
87 | /* Address of end of stack space. | |
88 | This is ((USRSTACK + 0xfff) & -0x1000)) from <convex/vmparam.h> but | |
89 | that expression depends on the kernel version; instead, fetch a | |
90 | page-zero pointer and get it from that. This will be invalid if | |
91 | they ever change the way bkpt signals are delivered. */ | |
92 | ||
93 | #define STACK_END_ADDR (0xfffff000 & *(unsigned *) 0x80000050) | |
94 | ||
95 | /* User-mode traps push an extended rtn block, | |
96 | then fault with one of the following PCs */ | |
97 | ||
98 | #define is_trace_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000040)) <= 4) | |
99 | #define is_arith_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000044)) <= 4) | |
100 | #define is_break_pc(pc) ((unsigned) ((pc) - (*(int *) 0x80000050)) <= 4) | |
101 | ||
102 | /* We need to manipulate trap bits in the psw */ | |
103 | ||
104 | #define PSW_TRAP_FLAGS 0x69670000 | |
105 | #define PSW_T_BIT 0x08000000 | |
106 | #define PSW_S_BIT 0x01000000 | |
107 | ||
108 | /* Stack grows downward. */ | |
109 | ||
110 | #define INNER_THAN < | |
111 | ||
112 | /* Sequence of bytes for breakpoint instruction. (bkpt) */ | |
113 | ||
114 | #define BREAKPOINT {0x7d,0x50} | |
115 | ||
116 | /* Amount PC must be decremented by after a breakpoint. | |
117 | This is often the number of bytes in BREAKPOINT but not always. | |
118 | (The break PC needs to be decremented by 2, but we do it when the | |
119 | break frame is recognized and popped. That way gdb can tell breaks | |
120 | from trace traps with certainty.) */ | |
121 | ||
122 | #define DECR_PC_AFTER_BREAK 0 | |
123 | ||
124 | /* Nonzero if instruction at PC is a return instruction. (rtn or rtnq) */ | |
125 | ||
126 | #define ABOUT_TO_RETURN(pc) \ | |
127 | ((read_memory_integer (pc, 2) & 0xffe0) == 0x7c80) | |
128 | ||
129 | /* Return 1 if P points to an invalid floating point value. */ | |
130 | ||
131 | #define INVALID_FLOAT(p,len) 0 | |
132 | ||
133 | /* Say how long (ordinary) registers are. */ | |
134 | ||
135 | #define REGISTER_TYPE long long | |
136 | ||
137 | /* Number of machine registers */ | |
138 | ||
139 | #define NUM_REGS 26 | |
140 | ||
141 | /* Initializer for an array of names of registers. | |
142 | There should be NUM_REGS strings in this initializer. */ | |
143 | ||
144 | #define REGISTER_NAMES {"pc","psw","fp","ap","a5","a4","a3","a2","a1","sp",\ | |
145 | "s7","s6","s5","s4","s3","s2","s1","s0",\ | |
146 | "S7","S6","S5","S4","S3","S2","S1","S0"} | |
147 | ||
148 | /* Register numbers of various important registers. | |
149 | Note that some of these values are "real" register numbers, | |
150 | and correspond to the general registers of the machine, | |
151 | and some are "phony" register numbers which are too large | |
152 | to be actual register numbers as far as the user is concerned | |
153 | but do serve to get the desired values when passed to read_register. */ | |
154 | ||
155 | #define S0_REGNUM 25 /* the real S regs */ | |
156 | #define S7_REGNUM 18 | |
157 | #define s0_REGNUM 17 /* low-order halves of S regs */ | |
158 | #define s7_REGNUM 10 | |
159 | #define SP_REGNUM 9 /* A regs */ | |
160 | #define A1_REGNUM 8 | |
161 | #define A5_REGNUM 4 | |
162 | #define AP_REGNUM 3 | |
163 | #define FP_REGNUM 2 /* Contains address of executing stack frame */ | |
164 | #define PS_REGNUM 1 /* Contains processor status */ | |
165 | #define PC_REGNUM 0 /* Contains program counter */ | |
166 | ||
167 | /* convert dbx stab register number (from `r' declaration) to a gdb REGNUM */ | |
168 | ||
169 | #define STAB_REG_TO_REGNUM(value) \ | |
170 | ((value) < 8 ? S0_REGNUM - (value) : SP_REGNUM - ((value) - 8)) | |
171 | ||
172 | /* Vector register numbers, not handled as ordinary regs. | |
173 | They are treated as convenience variables whose values are read | |
174 | from the inferior when needed. */ | |
175 | ||
176 | #define V0_REGNUM 0 | |
177 | #define V7_REGNUM 7 | |
178 | #define VM_REGNUM 8 | |
179 | #define VS_REGNUM 9 | |
180 | #define VL_REGNUM 10 | |
181 | ||
182 | /* Total amount of space needed to store our copies of the machine's | |
183 | register state, the array `registers'. */ | |
184 | #define REGISTER_BYTES (4*10 + 8*8) | |
185 | ||
186 | /* Index within `registers' of the first byte of the space for | |
187 | register N. | |
188 | NB: must match structure of struct syscall_context for correct operation */ | |
189 | ||
190 | #define REGISTER_BYTE(N) ((N) < s7_REGNUM ? 4*(N) : \ | |
191 | (N) < S7_REGNUM ? 44 + 8 * ((N)-s7_REGNUM) : \ | |
192 | 40 + 8 * ((N)-S7_REGNUM)) | |
193 | ||
194 | /* Number of bytes of storage in the actual machine representation | |
195 | for register N. */ | |
196 | ||
197 | #define REGISTER_RAW_SIZE(N) ((N) < S7_REGNUM ? 4 : 8) | |
198 | ||
199 | /* Number of bytes of storage in the program's representation | |
200 | for register N. */ | |
201 | ||
202 | #define REGISTER_VIRTUAL_SIZE(N) REGISTER_RAW_SIZE(N) | |
203 | ||
204 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
205 | ||
206 | #define MAX_REGISTER_RAW_SIZE 8 | |
207 | ||
208 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
209 | ||
210 | #define MAX_REGISTER_VIRTUAL_SIZE 8 | |
211 | ||
212 | /* Nonzero if register N requires conversion | |
213 | from raw format to virtual format. */ | |
214 | ||
215 | #define REGISTER_CONVERTIBLE(N) 0 | |
216 | ||
217 | /* Convert data from raw format for register REGNUM | |
218 | to virtual format for register REGNUM. */ | |
219 | ||
220 | #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \ | |
221 | bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)); | |
222 | ||
223 | /* Convert data from virtual format for register REGNUM | |
224 | to raw format for register REGNUM. */ | |
225 | ||
226 | #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \ | |
227 | bcopy ((FROM), (TO), REGISTER_RAW_SIZE (REGNUM)); | |
228 | ||
229 | /* Return the GDB type object for the "standard" data type | |
230 | of data in register N. */ | |
231 | ||
232 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
233 | ((N) < S7_REGNUM ? builtin_type_int : builtin_type_long_long) | |
234 | ||
235 | /* Store the address of the place in which to copy the structure the | |
236 | subroutine will return. This is called from call_function. */ | |
237 | ||
238 | #define STORE_STRUCT_RETURN(ADDR, SP) \ | |
239 | { write_register (A1_REGNUM, (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 (&((char *) REGBUF) [REGISTER_BYTE (S0_REGNUM) + \ | |
247 | 8 - TYPE_LENGTH (TYPE)],\ | |
248 | VALBUF, TYPE_LENGTH (TYPE)) | |
249 | ||
250 | /* Write into appropriate registers a function return value | |
251 | of type TYPE, given in virtual format. */ | |
252 | ||
253 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
254 | write_register_bytes (REGISTER_BYTE (S0_REGNUM), VALBUF, 8) | |
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) \ | |
261 | (*(int *) & ((char *) REGBUF) [REGISTER_BYTE (s0_REGNUM)]) | |
262 | ||
263 | /* Define trapped internal variable hooks to read and write | |
264 | vector and communication registers. */ | |
265 | ||
266 | #define IS_TRAPPED_INTERNALVAR is_trapped_internalvar | |
267 | #define VALUE_OF_TRAPPED_INTERNALVAR value_of_trapped_internalvar | |
268 | #define SET_TRAPPED_INTERNALVAR set_trapped_internalvar | |
269 | ||
270 | extern struct value *value_of_trapped_internalvar (); | |
271 | ||
272 | /* Hooks to read data from soff exec and core files, | |
273 | and to describe the files. */ | |
274 | ||
275 | #define XFER_CORE_FILE | |
276 | #define FILES_INFO_HOOK print_maps | |
277 | ||
278 | /* Hook to call to print a typeless integer value, normally printed in decimal. | |
279 | For convex, use hex instead if the number looks like an address. */ | |
280 | ||
281 | #define PRINT_TYPELESS_INTEGER decout | |
282 | ||
283 | /* For the native compiler, variables for a particular lexical context | |
284 | are listed after the beginning LBRAC instead of before in the | |
285 | executables list of symbols. Using "gcc_compiled." to distinguish | |
286 | between GCC and native compiler doesn't work on Convex because the | |
287 | linker sorts the symbols to put "gcc_compiled." in the wrong place. | |
288 | desc is nonzero for native, zero for gcc. */ | |
289 | #define VARIABLES_INSIDE_BLOCK(desc, gcc_p) (desc != 0) | |
290 | ||
291 | /* Pcc occaisionally puts an SO where there should be an SOL. */ | |
292 | #define PCC_SOL_BROKEN | |
dd3b648e RP |
293 | \f |
294 | /* Describe the pointer in each stack frame to the previous stack frame | |
295 | (its caller). */ | |
296 | ||
297 | /* FRAME_CHAIN takes a frame_info with a frame's nominal address in fi->frame, | |
298 | and produces the frame's chain-pointer. | |
299 | ||
dd3b648e | 300 | However, if FRAME_CHAIN_VALID returns zero, |
e140f1da | 301 | it means the given frame is the outermost one and has no caller. */ |
dd3b648e RP |
302 | |
303 | /* (caller fp is saved at 8(fp)) */ | |
304 | ||
305 | #define FRAME_CHAIN(fi) (read_memory_integer ((fi)->frame + 8, 4)) | |
306 | ||
307 | #define FRAME_CHAIN_VALID(chain, thisframe) \ | |
308 | (chain != 0 && (outside_startup_file (FRAME_SAVED_PC (thisframe)))) | |
309 | ||
dd3b648e RP |
310 | /* Define other aspects of the stack frame. */ |
311 | ||
841c051c JG |
312 | /* We need the boundaries of the text in the exec file, as a kludge, |
313 | for FRAMELESS_FUNCTION_INVOCATION and CALL_DUMMY_LOCATION. */ | |
314 | ||
315 | #define NEED_TEXT_START_END | |
316 | ||
dd3b648e RP |
317 | /* A macro that tells us whether the function invocation represented |
318 | by FI does not have a frame on the stack associated with it. If it | |
319 | does not, FRAMELESS is set to 1, else 0. | |
320 | On convex, check at the return address for `callq' -- if so, frameless, | |
321 | otherwise, not. */ | |
322 | ||
323 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ | |
324 | { \ | |
325 | extern CORE_ADDR text_start, text_end; \ | |
326 | CORE_ADDR call_addr = SAVED_PC_AFTER_CALL (FI); \ | |
327 | (FRAMELESS) = (call_addr >= text_start && call_addr < text_end \ | |
328 | && read_memory_integer (call_addr - 6, 1) == 0x22); \ | |
329 | } | |
330 | ||
331 | #define FRAME_SAVED_PC(fi) (read_memory_integer ((fi)->frame, 4)) | |
332 | ||
333 | #define FRAME_ARGS_ADDRESS(fi) (read_memory_integer ((fi)->frame + 12, 4)) | |
334 | ||
335 | #define FRAME_LOCALS_ADDRESS(fi) (fi)->frame | |
336 | ||
337 | /* Return number of args passed to a frame. | |
338 | Can return -1, meaning no way to tell. */ | |
339 | ||
340 | #define FRAME_NUM_ARGS(numargs, fi) \ | |
341 | { numargs = read_memory_integer (FRAME_ARGS_ADDRESS (fi) - 4, 4); \ | |
342 | if (numargs < 0 || numargs >= 256) numargs = -1;} | |
343 | ||
344 | /* Return number of bytes at start of arglist that are not really args. */ | |
345 | ||
346 | #define FRAME_ARGS_SKIP 0 | |
347 | ||
348 | /* Put here the code to store, into a struct frame_saved_regs, | |
349 | the addresses of the saved registers of frame described by FRAME_INFO. | |
350 | This includes special registers such as pc and fp saved in special | |
351 | ways in the stack frame. sp is even more special: | |
352 | the address we return for it IS the sp for the next frame. */ | |
353 | ||
354 | /* Normal (short) frames save only PC, FP, (callee's) AP. To reasonably | |
355 | handle gcc and pcc register variables, scan the code following the | |
356 | call for the instructions the compiler inserts to reload register | |
357 | variables from stack slots and record the stack slots as the saved | |
358 | locations of those registers. This will occasionally identify some | |
359 | random load as a saved register; this is harmless. vc does not | |
360 | declare its register allocation actions in the stabs. */ | |
361 | ||
362 | #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \ | |
363 | { register int regnum; \ | |
364 | register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */\ | |
365 | (read_memory_integer ((frame_info)->frame + 4, 4) >> 25) & 3; \ | |
366 | register CORE_ADDR frame_fp = \ | |
367 | read_memory_integer ((frame_info)->frame + 8, 4); \ | |
368 | register CORE_ADDR next_addr; \ | |
369 | bzero (&frame_saved_regs, sizeof frame_saved_regs); \ | |
370 | (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 0; \ | |
371 | (frame_saved_regs).regs[PS_REGNUM] = (frame_info)->frame + 4; \ | |
372 | (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame + 8; \ | |
373 | (frame_saved_regs).regs[AP_REGNUM] = frame_fp + 12; \ | |
374 | next_addr = (frame_info)->frame + 12; \ | |
375 | if (frame_length < 3) \ | |
376 | for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \ | |
377 | (frame_saved_regs).regs[regnum] = (next_addr += 4); \ | |
378 | if (frame_length < 2) \ | |
379 | (frame_saved_regs).regs[SP_REGNUM] = (next_addr += 4); \ | |
380 | next_addr -= 4; \ | |
381 | if (frame_length < 3) \ | |
382 | for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) \ | |
383 | (frame_saved_regs).regs[regnum] = (next_addr += 8); \ | |
384 | if (frame_length < 2) \ | |
385 | (frame_saved_regs).regs[S0_REGNUM] = (next_addr += 8); \ | |
386 | else \ | |
387 | (frame_saved_regs).regs[SP_REGNUM] = next_addr + 8; \ | |
388 | if (frame_length == 3) { \ | |
389 | CORE_ADDR pc = read_memory_integer ((frame_info)->frame, 4); \ | |
390 | int op, ix, disp; \ | |
391 | op = read_memory_integer (pc, 2); \ | |
392 | if ((op & 0xffc7) == 0x1480) pc += 4; /* add.w #-,sp */ \ | |
393 | else if ((op & 0xffc7) == 0x58c0) pc += 2; /* add.w #-,sp */ \ | |
394 | op = read_memory_integer (pc, 2); \ | |
395 | if ((op & 0xffc7) == 0x2a06) pc += 4; /* ld.w -,ap */ \ | |
396 | for (;;) { \ | |
397 | op = read_memory_integer (pc, 2); \ | |
398 | ix = (op >> 3) & 7; \ | |
399 | if ((op & 0xfcc0) == 0x2800) { /* ld.- -,ak */ \ | |
400 | regnum = SP_REGNUM - (op & 7); \ | |
401 | disp = read_memory_integer (pc + 2, 2); \ | |
402 | pc += 4;} \ | |
403 | else if ((op & 0xfcc0) == 0x2840) { /* ld.- -,ak */ \ | |
404 | regnum = SP_REGNUM - (op & 7); \ | |
405 | disp = read_memory_integer (pc + 2, 4); \ | |
406 | pc += 6;} \ | |
407 | if ((op & 0xfcc0) == 0x3000) { /* ld.- -,sk */ \ | |
408 | regnum = S0_REGNUM - (op & 7); \ | |
409 | disp = read_memory_integer (pc + 2, 2); \ | |
410 | pc += 4;} \ | |
411 | else if ((op & 0xfcc0) == 0x3040) { /* ld.- -,sk */ \ | |
412 | regnum = S0_REGNUM - (op & 7); \ | |
413 | disp = read_memory_integer (pc + 2, 4); \ | |
414 | pc += 6;} \ | |
415 | else if ((op & 0xff00) == 0x7100) { /* br crossjump */ \ | |
416 | pc += 2 * (char) op; \ | |
417 | continue;} \ | |
418 | else if (op == 0x0140) { /* jmp crossjump */ \ | |
419 | pc = read_memory_integer (pc + 2, 4); \ | |
420 | continue;} \ | |
421 | else break; \ | |
422 | if ((frame_saved_regs).regs[regnum]) \ | |
423 | break; \ | |
424 | if (ix == 7) disp += frame_fp; \ | |
425 | else if (ix == 6) disp += read_memory_integer (frame_fp + 12, 4); \ | |
426 | else if (ix != 0) break; \ | |
427 | (frame_saved_regs).regs[regnum] = \ | |
428 | disp - 8 + (1 << ((op >> 8) & 3)); \ | |
429 | if (regnum >= S7_REGNUM) \ | |
430 | (frame_saved_regs).regs[regnum - S0_REGNUM + s0_REGNUM] = \ | |
431 | disp - 4 + (1 << ((op >> 8) & 3)); \ | |
432 | } \ | |
433 | } \ | |
434 | } | |
435 | \f | |
436 | /* Things needed for making the inferior call functions. */ | |
437 | ||
841c051c JG |
438 | #define CALL_DUMMY_LOCATION BEFORE_TEXT_END |
439 | ||
dd3b648e RP |
440 | /* Push an empty stack frame, to record the current PC, etc. */ |
441 | ||
442 | #define PUSH_DUMMY_FRAME \ | |
443 | { register CORE_ADDR sp = read_register (SP_REGNUM); \ | |
444 | register int regnum; \ | |
445 | char buf[8]; \ | |
446 | long word; \ | |
447 | for (regnum = S0_REGNUM; regnum >= S7_REGNUM; --regnum) { \ | |
448 | read_register_bytes (REGISTER_BYTE (regnum), buf, 8); \ | |
449 | sp = push_bytes (sp, buf, 8);} \ | |
450 | for (regnum = SP_REGNUM; regnum >= FP_REGNUM; --regnum) { \ | |
451 | word = read_register (regnum); \ | |
452 | sp = push_bytes (sp, &word, 4);} \ | |
453 | word = (read_register (PS_REGNUM) &~ (3<<25)) | (1<<25); \ | |
454 | sp = push_bytes (sp, &word, 4); \ | |
455 | word = read_register (PC_REGNUM); \ | |
456 | sp = push_bytes (sp, &word, 4); \ | |
457 | write_register (SP_REGNUM, sp); \ | |
458 | write_register (FP_REGNUM, sp); \ | |
459 | write_register (AP_REGNUM, sp);} | |
460 | ||
461 | /* Discard from the stack the innermost frame, restoring all registers. */ | |
462 | ||
463 | #define POP_FRAME do {\ | |
464 | register CORE_ADDR fp = read_register (FP_REGNUM); \ | |
465 | register int regnum; \ | |
466 | register int frame_length = /* 3 short, 2 long, 1 extended, 0 context */ \ | |
467 | (read_memory_integer (fp + 4, 4) >> 25) & 3; \ | |
468 | char buf[8]; \ | |
469 | write_register (PC_REGNUM, read_memory_integer (fp, 4)); \ | |
470 | write_register (PS_REGNUM, read_memory_integer (fp += 4, 4)); \ | |
471 | write_register (FP_REGNUM, read_memory_integer (fp += 4, 4)); \ | |
472 | write_register (AP_REGNUM, read_memory_integer (fp += 4, 4)); \ | |
473 | if (frame_length < 3) \ | |
474 | for (regnum = A5_REGNUM; regnum < SP_REGNUM; ++regnum) \ | |
475 | write_register (regnum, read_memory_integer (fp += 4, 4)); \ | |
476 | if (frame_length < 2) \ | |
477 | write_register (SP_REGNUM, read_memory_integer (fp += 4, 4)); \ | |
478 | fp -= 4; \ | |
479 | if (frame_length < 3) \ | |
480 | for (regnum = S7_REGNUM; regnum < S0_REGNUM; ++regnum) { \ | |
481 | read_memory (fp += 8, buf, 8); \ | |
482 | write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \ | |
483 | if (frame_length < 2) { \ | |
484 | read_memory (fp += 8, buf, 8); \ | |
485 | write_register_bytes (REGISTER_BYTE (regnum), buf, 8);} \ | |
486 | else write_register (SP_REGNUM, fp + 8); \ | |
487 | flush_cached_frames (); \ | |
488 | set_current_frame (create_new_frame (read_register (FP_REGNUM), \ | |
489 | read_pc ())); \ | |
490 | } while (0) | |
491 | ||
492 | /* This sequence of words is the instructions | |
493 | mov sp,ap | |
494 | pshea 69696969 | |
495 | calls 32323232 | |
496 | bkpt | |
497 | Note this is 16 bytes. */ | |
498 | ||
499 | #define CALL_DUMMY {0x50860d4069696969LL,0x2140323232327d50LL} | |
500 | ||
501 | #define CALL_DUMMY_LENGTH 16 | |
502 | ||
503 | #define CALL_DUMMY_START_OFFSET 0 | |
504 | ||
505 | /* Insert the specified number of args and function address | |
506 | into a call sequence of the above form stored at DUMMYNAME. */ | |
507 | ||
508 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
509 | { *(int *)((char *) dummyname + 4) = nargs; \ | |
510 | *(int *)((char *) dummyname + 10) = fun; } | |
511 | \f | |
512 | /* Defs to read soff symbol tables, see dbxread.c */ | |
513 | ||
514 | #define NUMBER_OF_SYMBOLS ((long) opthdr.o_nsyms) | |
515 | #define STRING_TABLE_OFFSET ((long) filehdr.h_strptr) | |
516 | #define SYMBOL_TABLE_OFFSET ((long) opthdr.o_symptr) | |
517 | #define STRING_TABLE_SIZE ((long) filehdr.h_strsiz) | |
518 | #define SIZE_OF_TEXT_SEGMENT ((long) txthdr.s_size) | |
519 | #define ENTRY_POINT ((long) opthdr.o_entry) | |
520 | ||
521 | #define READ_STRING_TABLE_SIZE(BUFFER) \ | |
522 | (BUFFER = STRING_TABLE_SIZE) | |
523 | ||
524 | #define DECLARE_FILE_HEADERS \ | |
525 | FILEHDR filehdr; \ | |
526 | OPTHDR opthdr; \ | |
527 | SCNHDR txthdr | |
528 | ||
529 | #define READ_FILE_HEADERS(DESC,NAME) \ | |
530 | { \ | |
531 | int n; \ | |
532 | val = myread (DESC, &filehdr, sizeof filehdr); \ | |
533 | if (val < 0) \ | |
534 | perror_with_name (NAME); \ | |
535 | if (! IS_SOFF_MAGIC (filehdr.h_magic)) \ | |
536 | error ("%s: not an executable file.", NAME); \ | |
537 | lseek (DESC, 0L, 0); \ | |
538 | if (myread (DESC, &filehdr, sizeof filehdr) < 0) \ | |
539 | perror_with_name (NAME); \ | |
540 | if (myread (DESC, &opthdr, filehdr.h_opthdr) <= 0) \ | |
541 | perror_with_name (NAME); \ | |
542 | for (n = 0; n < filehdr.h_nscns; n++) \ | |
543 | { \ | |
544 | if (myread (DESC, &txthdr, sizeof txthdr) < 0) \ | |
545 | perror_with_name (NAME); \ | |
546 | if ((txthdr.s_flags & S_TYPMASK) == S_TEXT) \ | |
547 | break; \ | |
548 | } \ | |
549 | } |