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