1 /* Parameters for targe of a Gould Powernode, for GDB, the GNU debugger.
2 Copyright 1986, 1987, 1989, 1991, 1993 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #define TARGET_BYTE_ORDER BIG_ENDIAN
24 /* This code appears in libraries on Gould machines. Ignore it. */
25 #define IGNORE_SYMBOL(type) (type == N_ENTRY)
27 /* We don't want the extra gnu symbols on the machine;
28 they will interfere with the shared segment symbols. */
31 /* Macro for text-offset and data info (in PN a.out format). */
33 text_offset = N_TXTOFF (exec_coffhdr); \
34 exec_data_offset = N_TXTOFF (exec_coffhdr) \
37 /* Macro for number of symbol table entries */
38 #define END_OF_TEXT_DEFAULT \
41 /* Macro for number of symbol table entries */
42 #define NUMBER_OF_SYMBOLS \
45 /* Macro for file-offset of symbol table (in usual a.out format). */
46 #define SYMBOL_TABLE_OFFSET \
49 /* Macro for file-offset of string table (in usual a.out format). */
50 #define STRING_TABLE_OFFSET \
51 (N_STROFF (coffhdr) + sizeof(int))
53 /* Macro to store the length of the string table data in INTO. */
54 #define READ_STRING_TABLE_SIZE(INTO) \
55 { INTO = hdr.a_stsize; }
57 /* Macro to declare variables to hold the file's header data. */
58 #define DECLARE_FILE_HEADERS struct old_exec hdr; \
61 /* Macro to read the header data from descriptor DESC and validate it.
62 NAME is the file name, for error messages. */
63 #define READ_FILE_HEADERS(DESC, NAME) \
64 { val = myread (DESC, &coffhdr, sizeof coffhdr); \
66 perror_with_name (NAME); \
67 val = myread (DESC, &hdr, sizeof hdr); \
69 perror_with_name (NAME); \
70 if (coffhdr.f_magic != GNP1MAGIC) \
71 error ("File \"%s\" not in coff executable format.", NAME); \
73 error ("File \"%s\" not in executable format.", NAME); }
75 /* Define COFF and other symbolic names needed on NP1 */
76 #define NS32GMAGIC GDPMAGIC
77 #define NS32SMAGIC PN_MAGIC
79 /* Offset from address of function to start of its code.
80 Zero on most machines. */
81 #define FUNCTION_START_OFFSET 4
83 /* Advance PC across any function entry prologue instructions
84 to reach some "real" code. One PN we can have one or two startup
85 sequences depending on the size of the local stack:
90 "lil r4, #", "suabr b2, #(r4)"
92 "lwbr b6, #", "stw r1, 8(b2)"
93 Optional "stwbr b3, c(b2)"
94 Optional "trr r2,r7" (Gould first argument register passing)
96 Optional "stw r2,8(b3)" (Gould first argument register passing)
98 #define SKIP_PROLOGUE(pc) { \
99 register int op = read_memory_integer ((pc), 4); \
100 if ((op & 0xffff0000) == 0x580B0000) { \
102 op = read_memory_integer ((pc), 4); \
103 if ((op & 0xffff0000) == 0x59400000) { \
105 op = read_memory_integer ((pc), 4); \
106 if ((op & 0xffff0000) == 0x5F000000) { \
108 op = read_memory_integer ((pc), 4); \
109 if (op == 0xD4820008) { \
111 op = read_memory_integer ((pc), 4); \
112 if (op == 0x5582000C) { \
114 op = read_memory_integer ((pc), 2); \
115 if (op == 0x2fa0) { \
118 op = read_memory_integer ((pc), 4); \
119 if (op == 0xd5030008) { \
124 op = read_memory_integer ((pc), 2); \
125 if (op == 0x2fa0) { \
133 if ((op & 0xffff0000) == 0x59000000) { \
135 op = read_memory_integer ((pc), 4); \
136 if ((op & 0xffff0000) == 0x5F000000) { \
138 op = read_memory_integer ((pc), 4); \
139 if (op == 0xD4820008) { \
141 op = read_memory_integer ((pc), 4); \
142 if (op == 0x5582000C) { \
144 op = read_memory_integer ((pc), 2); \
145 if (op == 0x2fa0) { \
148 op = read_memory_integer ((pc), 4); \
149 if (op == 0xd5030008) { \
154 op = read_memory_integer ((pc), 2); \
155 if (op == 0x2fa0) { \
164 /* Immediately after a function call, return the saved pc.
165 Can't go through the frames for this because on some machines
166 the new frame is not set up until the new function executes
167 some instructions. True on PN! Return address is in R1.
168 Note: true return location is 4 bytes past R1! */
169 #define SAVED_PC_AFTER_CALL(frame) \
170 (read_register(R1_REGNUM) + 4)
172 /* Address of end of stack space. */
173 #define STACK_END_ADDR 0x480000
175 /* Stack grows downward. */
178 /* Sequence of bytes for breakpoint instruction. */
179 #define BREAKPOINT {0x28, 0x09}
181 /* Amount PC must be decremented by after a breakpoint.
182 This is often the number of bytes in BREAKPOINT
184 #define DECR_PC_AFTER_BREAK 2
186 /* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */
187 #define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0xEC100004)
189 /* Return 1 if P points to an invalid floating point value. */
190 #define INVALID_FLOAT(p, len) ((*(short *)p & 0xff80) == 0x8000)
192 /* Say how long (ordinary) registers are. */
193 #define REGISTER_TYPE long
195 /* Number of machine registers */
197 #define NUM_GEN_REGS 16
198 #define NUM_CPU_REGS 3
200 /* Initializer for an array of names of registers.
201 There should be NUM_REGS strings in this initializer. */
202 #define REGISTER_NAMES { \
203 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
204 "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \
208 /* Register numbers of various important registers.
209 Note that some of these values are "real" register numbers,
210 and correspond to the general registers of the machine,
211 and some are "phony" register numbers which are too large
212 to be actual register numbers as far as the user is concerned
213 but do serve to get the desired values when passed to read_register. */
214 #define R1_REGNUM 1 /* Gr1 => return address of caller */
215 #define R4_REGNUM 4 /* Gr4 => register save area */
216 #define R5_REGNUM 5 /* Gr5 => register save area */
217 #define R6_REGNUM 6 /* Gr6 => register save area */
218 #define R7_REGNUM 7 /* Gr7 => register save area */
219 #define B1_REGNUM 9 /* Br1 => start of this code routine */
220 #define FP_REGNUM 10 /* Br2 == (sp) */
221 #define AP_REGNUM 11 /* Br3 == (ap) */
222 #define SP_REGNUM 16 /* A copy of Br2 saved in trap */
223 #define PS_REGNUM 17 /* Contains processor status */
224 #define PC_REGNUM 18 /* Contains program counter */
226 /* Total amount of space needed to store our copies of the machine's
227 register state, the array `registers'. */
228 #define REGISTER_BYTES (NUM_GEN_REGS*4 + NUM_CPU_REGS*4)
230 /* Index within `registers' of the first byte of the space for
232 #define REGISTER_BYTE(N) ((N) * 4)
234 /* Number of bytes of storage in the actual machine representation
235 for register N. On the PN, all normal regs are 4 bytes. */
236 #define REGISTER_RAW_SIZE(N) (4)
238 /* Number of bytes of storage in the program's representation
239 for register N. On the PN, all regs are 4 bytes. */
240 #define REGISTER_VIRTUAL_SIZE(N) (4)
242 /* Largest value REGISTER_RAW_SIZE can have. */
243 #define MAX_REGISTER_RAW_SIZE (4)
245 /* Largest value REGISTER_VIRTUAL_SIZE can have. */
246 #define MAX_REGISTER_VIRTUAL_SIZE (4)
248 /* Nonzero if register N requires conversion
249 from raw format to virtual format. */
250 #define REGISTER_CONVERTIBLE(N) (0)
252 /* Convert data from raw format for register REGNUM
253 to virtual format for register REGNUM. */
254 #define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
255 bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM));
257 /* Convert data from virtual format for register REGNUM
258 to raw format for register REGNUM. */
259 #define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
260 bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
262 /* Return the GDB type object for the "standard" data type
263 of data in register N. */
264 #define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
266 /* Store the address of the place in which to copy the structure the
267 subroutine will return. This is called from call_function.
269 On this machine this is a no-op, because gcc isn't used on it
270 yet. So this calling convention is not used. */
272 #define STORE_STRUCT_RETURN(ADDR, SP)
274 /* Extract from an arrary REGBUF containing the (raw) register state
275 a function return value of type TYPE, and copy that, in virtual format,
278 #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
279 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
281 /* Write into appropriate registers a function return value
282 of type TYPE, given in virtual format. */
284 #define STORE_RETURN_VALUE(TYPE,VALBUF) \
285 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
287 /* Extract from an array REGBUF containing the (raw) register state
288 the address in which a function should return its structure value,
289 as a CORE_ADDR (or an expression that can be used as one). */
291 #define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
294 /* Describe the pointer in each stack frame to the previous stack frame
297 /* FRAME_CHAIN takes a frame's nominal address
298 and produces the frame's chain-pointer.
300 However, if FRAME_CHAIN_VALID returns zero,
301 it means the given frame is the outermost one and has no caller. */
303 /* In the case of the NPL, the frame's norminal address is Br2 and the
304 previous routines frame is up the stack X bytes, where X is the
305 value stored in the code function header xA(Br1). */
306 #define FRAME_CHAIN(thisframe) (findframe(thisframe))
308 #define FRAME_CHAIN_VALID(chain, thisframe) \
309 (chain != 0 && chain != (thisframe)->frame)
311 /* Define other aspects of the stack frame on NPL. */
312 #define FRAME_SAVED_PC(frame) \
313 (read_memory_integer ((frame)->frame + 8, 4))
315 #define FRAME_ARGS_ADDRESS(fi) \
316 ((fi)->next_frame ? \
317 read_memory_integer ((fi)->frame + 12, 4) : \
318 read_register (AP_REGNUM))
320 #define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame + 80)
322 /* Set VAL to the number of args passed to frame described by FI.
323 Can set VAL to -1, meaning no way to tell. */
325 /* We can check the stab info to see how
326 many arg we have. No info in stack will tell us */
327 #define FRAME_NUM_ARGS(val,fi) (val = findarg(fi))
329 /* Return number of bytes at start of arglist that are not really args. */
330 #define FRAME_ARGS_SKIP 8
332 /* Put here the code to store, into a struct frame_saved_regs,
333 the addresses of the saved registers of frame described by FRAME_INFO.
334 This includes special registers such as pc and fp saved in special
335 ways in the stack frame. sp is even more special:
336 the address we return for it IS the sp for the next frame. */
338 #define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
340 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
341 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8; \
342 (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30; \
343 (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34; \
344 (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38; \
345 (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C; \
348 /* Things needed for making the inferior call functions. */
350 /* Push an empty stack frame, to record the current PC, etc. */
352 #define PUSH_DUMMY_FRAME \
353 { register CORE_ADDR sp = read_register (SP_REGNUM); \
354 register int regnum; \
355 sp = push_word (sp, read_register (PC_REGNUM)); \
356 sp = push_word (sp, read_register (FP_REGNUM)); \
357 write_register (FP_REGNUM, sp); \
358 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
359 sp = push_word (sp, read_register (regnum)); \
360 sp = push_word (sp, read_register (PS_REGNUM)); \
361 write_register (SP_REGNUM, sp); }
363 /* Discard from the stack the innermost frame,
364 restoring all saved registers. */
367 { register FRAME frame = get_current_frame (); \
368 register CORE_ADDR fp; \
369 register int regnum; \
370 struct frame_saved_regs fsr; \
371 struct frame_info *fi; \
372 fi = get_frame_info (frame); \
374 get_frame_saved_regs (fi, &fsr); \
375 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
376 if (fsr.regs[regnum]) \
377 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
378 if (fsr.regs[PS_REGNUM]) \
379 write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
380 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
381 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
382 write_register (SP_REGNUM, fp + 8); \
383 flush_cached_frames (); \
384 set_current_frame ( create_new_frame (read_register (FP_REGNUM),\
387 /* This sequence of words is the instructions:
392 suabr b2, #<stacksize>
394 stw r1, 8(b2) - save caller address, do we care?
397 std r4, 30(b2) - save r4-r7
399 lwbr b1, #<func> - load function call address
400 brlnk r1, 8(b1) - call function
403 ld r4, 30(b2) - restore r4-r7
406 Setup our stack frame, load argumemts, call and then restore registers.
409 /* FIXME: The below defines an m68k CALL_DUMMY, which looks nothing like what
410 is documented above. */
412 #define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71}
414 #define CALL_DUMMY_LENGTH 28
416 #define CALL_DUMMY_START_OFFSET 12
418 /* Insert the specified number of args and function address
419 into a call sequence of the above form stored at DUMMYNAME. */
421 #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \
422 { *(int *)((char *) dummyname + 20) = nargs * 4; \
423 *(int *)((char *) dummyname + 14) = fun; }