gdb-3.5
[deliverable/binutils-gdb.git] / gdb / m-npl.h
CommitLineData
3bf57d21 1/* Parameters for execution on a Gould NP1, for GDB, the GNU debugger.
4187119d 2 Copyright (C) 1986, 1987, 1989 Free Software Foundation, Inc.
3bf57d21 3
4187119d 4This file is part of GDB.
3bf57d21 5
4187119d 6GDB is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
3bf57d21 10
4187119d 11GDB is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GDB; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/* Define the bit, byte, and word ordering of the machine. */
21#define BITS_BIG_ENDIAN
22#define BYTES_BIG_ENDIAN
23#define WORDS_BIG_ENDIAN
3bf57d21 24
e91b87a3 25/* This code appears in libraries on Gould machines. Ignore it. */
26#define IGNORE_SYMBOL(type) (type == N_ENTRY)
3bf57d21 27
4187119d 28/* We don't want the extra gnu symbols on the machine;
29 they will interfere with the shared segment symbols. */
30#define NO_GNU_STABS
31
3bf57d21 32/* Macro for text-offset and data info (in NPL a.out format). */
33#define TEXTINFO \
34 text_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr); \
35 exec_data_offset = N_TXTOFF (exec_coffhdr, exec_aouthdr)\
36 + exec_aouthdr.a_text
37
38/* Macro for number of symbol table entries */
39#define END_OF_TEXT_DEFAULT \
40 (0xffffff)
41
42/* Macro for number of symbol table entries */
43#define NUMBER_OF_SYMBOLS \
44 (coffhdr.f_nsyms)
45
46/* Macro for file-offset of symbol table (in NPL a.out format). */
47#define SYMBOL_TABLE_OFFSET \
48 N_SYMOFF (coffhdr)
49
50/* Macro for file-offset of string table (in NPL a.out format). */
51#define STRING_TABLE_OFFSET \
52 (N_STROFF (coffhdr) + sizeof(int))
53
54/* Macro to store the length of the string table data in INTO. */
55#define READ_STRING_TABLE_SIZE(INTO) \
56 { INTO = hdr.a_stsize; }
57
58/* Macro to declare variables to hold the file's header data. */
59#define DECLARE_FILE_HEADERS struct exec hdr; \
60 FILHDR coffhdr
61
62/* Macro to read the header data from descriptor DESC and validate it.
63 NAME is the file name, for error messages. */
64#define READ_FILE_HEADERS(DESC, NAME) \
65{ val = myread (DESC, &coffhdr, sizeof coffhdr); \
66 if (val < 0) \
67 perror_with_name (NAME); \
68 val = myread (DESC, &hdr, sizeof hdr); \
69 if (val < 0) \
70 perror_with_name (NAME); \
71 if (coffhdr.f_magic != GNP1MAGIC) \
72 error ("File \"%s\" not in coff executable format.", NAME); \
73 if (N_BADMAG (hdr)) \
74 error ("File \"%s\" not in executable format.", NAME); }
75
76/* Define COFF and other symbolic names needed on NP1 */
77#define NS32GMAGIC GNP1MAGIC
78#define NS32SMAGIC GPNMAGIC
4187119d 79#ifndef HAVE_VPRINTF
3bf57d21 80#define vprintf printf
4187119d 81#endif /* not HAVE_VPRINTF */
3bf57d21 82
83/* Get rid of any system-imposed stack limit if possible. */
84#define SET_STACK_LIMIT_HUGE
85
86/* Define this if the C compiler puts an underscore at the front
87 of external names before giving them to the linker. */
88#define NAMES_HAVE_UNDERSCORE
89
90/* Debugger information will be in DBX format. */
91#define READ_DBX_FORMAT
92
93/* Offset from address of function to start of its code.
94 Zero on most machines. */
95#define FUNCTION_START_OFFSET 8
96
97/* Advance PC across any function entry prologue instructions
98 to reach some "real" code. One NPL we can have one two startup
99 sequences depending on the size of the local stack:
100
101 Either:
102 "suabr b2, #"
103 of
104 "lil r4, #", "suabr b2, #(r4)"
105
106 "lwbr b6, #", "stw r1, 8(b2)"
107 Optional "stwbr b3, c(b2)"
108 Optional "trr r2,r7" (Gould first argument register passing)
109 or
110 Optional "stw r2,8(b3)" (Gould first argument register passing)
111 */
112#define SKIP_PROLOGUE(pc) { \
113 register int op = read_memory_integer ((pc), 4); \
114 if ((op & 0xffff0000) == 0xFA0B0000) { \
115 pc += 4; \
116 op = read_memory_integer ((pc), 4); \
117 if ((op & 0xffff0000) == 0x59400000) { \
118 pc += 4; \
119 op = read_memory_integer ((pc), 4); \
120 if ((op & 0xffff0000) == 0x5F000000) { \
121 pc += 4; \
122 op = read_memory_integer ((pc), 4); \
123 if (op == 0xD4820008) { \
124 pc += 4; \
125 op = read_memory_integer ((pc), 4); \
126 if (op == 0x5582000C) { \
127 pc += 4; \
128 op = read_memory_integer ((pc), 2); \
129 if (op == 0x2fa0) { \
130 pc += 2; \
131 } else { \
132 op = read_memory_integer ((pc), 4); \
133 if (op == 0xd5030008) { \
134 pc += 4; \
135 } \
136 } \
137 } else { \
138 op = read_memory_integer ((pc), 2); \
139 if (op == 0x2fa0) { \
140 pc += 2; \
141 } \
142 } \
143 } \
144 } \
145 } \
146 } \
147 if ((op & 0xffff0000) == 0x59000000) { \
148 pc += 4; \
149 op = read_memory_integer ((pc), 4); \
150 if ((op & 0xffff0000) == 0x5F000000) { \
151 pc += 4; \
152 op = read_memory_integer ((pc), 4); \
153 if (op == 0xD4820008) { \
154 pc += 4; \
155 op = read_memory_integer ((pc), 4); \
156 if (op == 0x5582000C) { \
157 pc += 4; \
158 op = read_memory_integer ((pc), 2); \
159 if (op == 0x2fa0) { \
160 pc += 2; \
161 } else { \
162 op = read_memory_integer ((pc), 4); \
163 if (op == 0xd5030008) { \
164 pc += 4; \
165 } \
166 } \
167 } else { \
168 op = read_memory_integer ((pc), 2); \
169 if (op == 0x2fa0) { \
170 pc += 2; \
171 } \
172 } \
173 } \
174 } \
175 } \
176}
177
178/* Immediately after a function call, return the saved pc.
179 Can't go through the frames for this because on some machines
180 the new frame is not set up until the new function executes
181 some instructions. True on NPL! Return address is in R1.
182 The true return address is REALLY 4 past that location! */
e91b87a3 183`#define SAVED_PC_AFTER_CALL(frame) \
3bf57d21 184 (read_register(R1_REGNUM) + 4)
185
186/* Address of U in kernel space */
187#define KERNEL_U_ADDR 0x7fffc000
188
189/* Address of end of stack space. */
190#define STACK_END_ADDR 0x7fffc000
191
192/* Stack grows downward. */
193#define INNER_THAN <
194
195/* Sequence of bytes for breakpoint instruction. */
196#define BREAKPOINT {0x28, 0x09}
197
198/* Amount PC must be decremented by after a breakpoint.
199 This is often the number of bytes in BREAKPOINT
200 but not always. */
201#define DECR_PC_AFTER_BREAK 2
202
203/* Nonzero if instruction at PC is a return instruction. "bu 4(r1)" */
204#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 4) == 0x40100004)
205
206/* Return 1 if P points to an invalid floating point value. */
207#define INVALID_FLOAT(p, len) ((*(short *)p & 0xff80) == 0x8000)
208
e91b87a3 209/* Largest integer type */
210#define LONGEST long
211
212/* Name of the builtin type for the LONGEST type above. */
213#define BUILTIN_TYPE_LONGEST builtin_type_long
214
3bf57d21 215/* Say how long (ordinary) registers are. */
216#define REGISTER_TYPE long
217
218/* Size of bytes of vector register (NP1 only), 32 elements * sizeof(int) */
219#define VR_SIZE 128
220
221/* Number of machine registers */
222#define NUM_REGS 27
223#define NUM_GEN_REGS 16
224#define NUM_CPU_REGS 4
225#define NUM_VECTOR_REGS 7
226
227/* Initializer for an array of names of registers.
228 There should be NUM_REGS strings in this initializer. */
229#define REGISTER_NAMES { \
230 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
231 "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", \
232 "sp", "ps", "pc", "ve", \
233 "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
234}
235
236/* Register numbers of various important registers.
237 Note that some of these values are "real" register numbers,
238 and correspond to the general registers of the machine,
239 and some are "phony" register numbers which are too large
240 to be actual register numbers as far as the user is concerned
241 but do serve to get the desired values when passed to read_register. */
242#define R1_REGNUM 1 /* Gr1 => return address of caller */
243#define R4_REGNUM 4 /* Gr4 => register save area */
244#define R5_REGNUM 5 /* Gr5 => register save area */
245#define R6_REGNUM 6 /* Gr6 => register save area */
246#define R7_REGNUM 7 /* Gr7 => register save area */
247#define B1_REGNUM 9 /* Br1 => start of this code routine */
248#define FP_REGNUM 10 /* Br2 == (sp) */
249#define AP_REGNUM 11 /* Br3 == (ap) */
250#define SP_REGNUM 16 /* A copy of Br2 saved in trap */
251#define PS_REGNUM 17 /* Contains processor status */
252#define PC_REGNUM 18 /* Contains program counter */
253#define VE_REGNUM 19 /* Vector end (user setup) register */
254#define V1_REGNUM 20 /* First vector register */
255#define V7_REGNUM 27 /* First vector register */
256
257/* This is a piece of magic that is given a register number REGNO
258 and as BLOCKEND the address in the system of the end of the user structure
259 and stores in ADDR the address in the kernel or core dump
260 of that register. */
261#define REGISTER_U_ADDR(addr, blockend, regno) { \
262 addr = blockend + regno * 4; \
263 if (regno == VE_REGNUM) addr = blockend - 9 * 4; \
264 if (regno == PC_REGNUM) addr = blockend - 8 * 4; \
265 if (regno == PS_REGNUM) addr = blockend - 7 * 4; \
266 if (regno == SP_REGNUM) addr = blockend - 6 * 4; \
267 if (regno >= V1_REGNUM) \
268 addr = blockend + 16 * 4 + (regno - V1_REGNUM) * VR_SIZE; \
269}
270
271/* Total amount of space needed to store our copies of the machine's
272 register state, the array `registers'. */
273#define REGISTER_BYTES \
274 (NUM_GEN_REGS*4 + NUM_VECTOR_REGS*VR_SIZE + NUM_CPU_REGS*4)
275
276/* Index within `registers' of the first byte of the space for
277 register N. */
278#define REGISTER_BYTE(N) \
279 (((N) < V1_REGNUM) ? ((N) * 4) : (((N) - V1_REGNUM) * VR_SIZE) + 80)
280
281/* Number of bytes of storage in the actual machine representation
282 for register N. On the NP1, all normal regs are 4 bytes, but
283 the vector registers are VR_SIZE*4 bytes long. */
284#define REGISTER_RAW_SIZE(N) \
285 (((N) < V1_REGNUM) ? 4 : VR_SIZE)
286
287/* Number of bytes of storage in the program's representation
288 for register N. On the NP1, all regs are 4 bytes. */
289#define REGISTER_VIRTUAL_SIZE(N) \
290 (((N) < V1_REGNUM) ? 4 : VR_SIZE)
291
292/* Largest value REGISTER_RAW_SIZE can have. */
293#define MAX_REGISTER_RAW_SIZE VR_SIZE
294
295/* Largest value REGISTER_VIRTUAL_SIZE can have. */
296#define MAX_REGISTER_VIRTUAL_SIZE VR_SIZE
297
298/* Nonzero if register N requires conversion
299 from raw format to virtual format. */
300#define REGISTER_CONVERTIBLE(N) (0)
301
302/* Convert data from raw format for register REGNUM
303 to virtual format for register REGNUM. */
304#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
305 bcopy ((FROM), (TO), REGISTER_RAW_SIZE(REGNUM));
306
307/* Convert data from virtual format for register REGNUM
308 to raw format for register REGNUM. */
309#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
310 bcopy ((FROM), (TO), REGISTER_VIRTUAL_SIZE(REGNUM));
311
312/* Return the GDB type object for the "standard" data type
313 of data in register N. */
314#define REGISTER_VIRTUAL_TYPE(N) (builtin_type_int)
315
e91b87a3 316/* Store the address of the place in which to copy the structure the
317 subroutine will return. This is called from call_function.
318
319 On this machine this is a no-op, because gcc isn't used on it
320 yet. So this calling convention is not used. */
321
322#define STORE_STRUCT_RETURN(ADDR, SP)
323
3bf57d21 324/* Extract from an arrary REGBUF containing the (raw) register state
325 a function return value of type TYPE, and copy that, in virtual format,
326 into VALBUF. */
327
328#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
329 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
330
331/* Write into appropriate registers a function return value
332 of type TYPE, given in virtual format. */
333
334#define STORE_RETURN_VALUE(TYPE,VALBUF) \
335 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
336
337/* Extract from an array REGBUF containing the (raw) register state
338 the address in which a function should return its structure value,
339 as a CORE_ADDR (or an expression that can be used as one). */
340
341#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
342
343\f
344/* Describe the pointer in each stack frame to the previous stack frame
345 (its caller). */
346
347/* FRAME_CHAIN takes a frame's nominal address
348 and produces the frame's chain-pointer.
349
350 FRAME_CHAIN_COMBINE takes the chain pointer and the frame's nominal address
351 and produces the nominal address of the caller frame.
352
353 However, if FRAME_CHAIN_VALID returns zero,
354 it means the given frame is the outermost one and has no caller.
355 In that case, FRAME_CHAIN_COMBINE is not used. */
356
357/* In the case of the NPL, the frame's norminal address is Br2 and the
358 previous routines frame is up the stack X bytes, where X is the
359 value stored in the code function header xA(Br1). */
360#define FRAME_CHAIN(thisframe) (findframe(thisframe))
361
362#define FRAME_CHAIN_VALID(chain, thisframe) \
e91b87a3 363 (chain != 0 && chain != (thisframe)->frame)
3bf57d21 364
365#define FRAME_CHAIN_COMBINE(chain, thisframe) \
366 (chain)
367
368/* Define other aspects of the stack frame on NPL. */
e91b87a3 369#define FRAME_SAVED_PC(FRAME) \
370 (read_memory_integer ((FRAME)->frame + 8, 4))
3bf57d21 371
372#define FRAME_ARGS_ADDRESS(fi) \
e91b87a3 373 ((fi)->next_frame ? \
374 read_memory_integer ((fi)->frame + 12, 4) : \
3bf57d21 375 read_register (AP_REGNUM))
376
e91b87a3 377#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame + 80)
3bf57d21 378
379/* Set VAL to the number of args passed to frame described by FI.
380 Can set VAL to -1, meaning no way to tell. */
381
382/* We can check the stab info to see how
383 many arg we have. No info in stack will tell us */
384#define FRAME_NUM_ARGS(val,fi) (val = findarg(fi))
385
386/* Return number of bytes at start of arglist that are not really args. */
387#define FRAME_ARGS_SKIP 8
388
389/* Put here the code to store, into a struct frame_saved_regs,
390 the addresses of the saved registers of frame described by FRAME_INFO.
391 This includes special registers such as pc and fp saved in special
392 ways in the stack frame. sp is even more special:
393 the address we return for it IS the sp for the next frame. */
394
395#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
396{ \
397 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
e91b87a3 398 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame + 8; \
399 (frame_saved_regs).regs[R4_REGNUM] = (frame_info)->frame + 0x30; \
400 (frame_saved_regs).regs[R5_REGNUM] = (frame_info)->frame + 0x34; \
401 (frame_saved_regs).regs[R6_REGNUM] = (frame_info)->frame + 0x38; \
402 (frame_saved_regs).regs[R7_REGNUM] = (frame_info)->frame + 0x3C; \
3bf57d21 403}
404\f
405/* Things needed for making the inferior call functions. */
406
407/* Push an empty stack frame, to record the current PC, etc. */
408
409#define PUSH_DUMMY_FRAME \
410{ register CORE_ADDR sp = read_register (SP_REGNUM); \
411 register int regnum; \
412 sp = push_word (sp, read_register (PC_REGNUM)); \
413 sp = push_word (sp, read_register (FP_REGNUM)); \
414 write_register (FP_REGNUM, sp); \
415 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
416 sp = push_word (sp, read_register (regnum)); \
417 sp = push_word (sp, read_register (PS_REGNUM)); \
418 write_register (SP_REGNUM, sp); }
419
420/* Discard from the stack the innermost frame,
421 restoring all saved registers. */
422
423#define POP_FRAME \
e91b87a3 424{ register FRAME frame = get_current_frame (); \
425 register CORE_ADDR fp; \
3bf57d21 426 register int regnum; \
427 struct frame_saved_regs fsr; \
e91b87a3 428 struct frame_info *fi; \
429 fi = get_frame_info (frame); \
430 fp = fi->frame; \
431 get_frame_saved_regs (fi, &fsr); \
3bf57d21 432 for (regnum = FP_REGNUM - 1; regnum >= 0; regnum--) \
433 if (fsr.regs[regnum]) \
434 write_register (regnum, read_memory_integer (fsr.regs[regnum], 4)); \
435 if (fsr.regs[PS_REGNUM]) \
436 write_register (PS_REGNUM, read_memory_integer (fsr.regs[PS_REGNUM], 4)); \
437 write_register (FP_REGNUM, read_memory_integer (fp, 4)); \
438 write_register (PC_REGNUM, read_memory_integer (fp + 4, 4)); \
439 write_register (SP_REGNUM, fp + 8); \
e91b87a3 440 flush_cached_frames (); \
441 set_current_frame ( create_new_frame (read_register (FP_REGNUM),\
442 read_pc ())); }
3bf57d21 443
444/* This sequence of words is the instructions:
445 halt
446 halt
447 halt
448 halt
449 suabr b2, #<stacksize>
450 lwbr b6, #con
451 stw r1, 8(b2) - save caller address, do we care?
452 lw r2, 60(b2) - arg1
453 labr b3, 50(b2)
454 std r4, 30(b2) - save r4-r7
455 std r6, 38(b2)
456 lwbr b1, #<func> - load function call address
457 brlnk r1, 8(b1) - call function
458 halt
459 halt
460 ld r4, 30(b2) - restore r4-r7
461 ld r6, 38(b2)
462
463 Setup our stack frame, load argumemts, call and then restore registers.
464*/
465
466#define CALL_DUMMY {0xf227e0ff, 0x48e7fffc, 0x426742e7, 0x4eb93232, 0x3232dffc, 0x69696969, 0x4e4f4e71}
467
468#define CALL_DUMMY_LENGTH 28
469
470#define CALL_DUMMY_START_OFFSET 12
471
472/* Insert the specified number of args and function address
473 into a call sequence of the above form stored at DUMMYNAME. */
474
e91b87a3 475#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, type) \
3bf57d21 476{ *(int *)((char *) dummyname + 20) = nargs * 4; \
477 *(int *)((char *) dummyname + 14) = fun; }
478\f
479/*
480 * No KDB support, Yet! */
481/* Interface definitions for kernel debugger KDB. */
482
483/* Map machine fault codes into signal numbers.
484 First subtract 0, divide by 4, then index in a table.
485 Faults for which the entry in this table is 0
486 are not handled by KDB; the program's own trap handler
487 gets to handle then. */
488
489#define FAULT_CODE_ORIGIN 0
490#define FAULT_CODE_UNITS 4
491#define FAULT_TABLE \
492{ 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
493 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
494 0, 0, 0, 0, 0, 0, 0, 0, \
495 SIGILL }
496
497/* Start running with a stack stretching from BEG to END.
498 BEG and END should be symbols meaningful to the assembler.
499 This is used only for kdb. */
500
501#define INIT_STACK(beg, end) \
502{ asm (".globl end"); \
503 asm ("movel $ end, sp"); \
504 asm ("clrl fp"); }
505
506/* Push the frame pointer register on the stack. */
507#define PUSH_FRAME_PTR \
508 asm ("movel fp, -(sp)");
509
510/* Copy the top-of-stack to the frame pointer register. */
511#define POP_FRAME_PTR \
512 asm ("movl (sp), fp");
513
514/* After KDB is entered by a fault, push all registers
515 that GDB thinks about (all NUM_REGS of them),
516 so that they appear in order of ascending GDB register number.
517 The fault code will be on the stack beyond the last register. */
518
519#define PUSH_REGISTERS \
520{ asm ("clrw -(sp)"); \
521 asm ("pea 10(sp)"); \
522 asm ("movem $ 0xfffe,-(sp)"); }
523
524/* Assuming the registers (including processor status) have been
525 pushed on the stack in order of ascending GDB register number,
526 restore them and return to the address in the saved PC register. */
527
528#define POP_REGISTERS \
529{ asm ("subil $8,28(sp)"); \
530 asm ("movem (sp),$ 0xffff"); \
531 asm ("rte"); }
This page took 0.153197 seconds and 4 git commands to generate.