Catch error on close so runtest won't bomb.
[deliverable/binutils-gdb.git] / gdb / tm-tahoe.h
CommitLineData
cb173f45 1/* Definitions to make GDB target for a tahoe running 4.3-Reno.
58dbaabd 2 Copyright 1986, 1987, 1989, 1991, 1992, 1993 Free Software Foundation, Inc.
cb173f45
JK
3
4This file is part of GDB.
5
99a7de40 6This program is free software; you can redistribute it and/or modify
cb173f45 7it under the terms of the GNU General Public License as published by
99a7de40
JG
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
cb173f45 10
99a7de40 11This program is distributed in the hope that it will be useful,
cb173f45
JK
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
99a7de40
JG
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
cb173f45
JK
19
20/*
21 * Ported by the State University of New York at Buffalo by the Distributed
22 * Computer Systems Lab, Department of Computer Science, 1991.
23 */
24
25#define TARGET_BYTE_ORDER BIG_ENDIAN
26#define BITS_BIG_ENDIAN 0
27
cb173f45
JK
28/* Offset from address of function to start of its code.
29 Zero on most machines. */
30
31#define FUNCTION_START_OFFSET 2
32
33/* Advance PC across any function entry prologue instructions
34 to reach some "real" code. */
35
36#define SKIP_PROLOGUE(pc) \
37{ register int op = (unsigned char) read_memory_integer (pc, 1); \
38 if (op == 0x11) pc += 2; /* skip brb */ \
39 if (op == 0x13) pc += 3; /* skip brw */ \
40 if (op == 0x2c && \
41 ((unsigned char) read_memory_integer (pc+2, 1)) == 0x5e) \
42 pc += 3; /* skip subl2 */ \
43 if (op == 0xe9 && \
44 ((unsigned char) read_memory_integer (pc+1, 1)) == 0xae && \
45 ((unsigned char) read_memory_integer(pc+3, 1)) == 0x5e) \
46 pc += 4; /* skip movab */ \
47 if (op == 0xe9 && \
48 ((unsigned char) read_memory_integer (pc+1, 1)) == 0xce && \
49 ((unsigned char) read_memory_integer(pc+4, 1)) == 0x5e) \
50 pc += 5; /* skip movab */ \
51 if (op == 0xe9 && \
52 ((unsigned char) read_memory_integer (pc+1, 1)) == 0xee && \
53 ((unsigned char) read_memory_integer(pc+6, 1)) == 0x5e) \
54 pc += 7; /* skip movab */ \
55}
56
57/* Immediately after a function call, return the saved pc.
58 Can't always go through the frames for this because on some machines
59 the new frame is not set up until the new function executes
60 some instructions. */
61
62#define SAVED_PC_AFTER_CALL(frame) FRAME_SAVED_PC(frame)
63
64/* Wrong for cross-debugging. I don't know the real values. */
0c540082 65#include <machine/param.h>
cb173f45
JK
66#define TARGET_UPAGES UPAGES
67#define TARGET_NBPG NBPG
68
cb173f45
JK
69/* Address of end of stack space. */
70
71#define STACK_END_ADDR (0xc0000000 - (TARGET_UPAGES * TARGET_NBPG))
72
73/* On BSD, sigtramp is in the u area. Can't check the exact
74 addresses because for cross-debugging we don't have target include
75 files around. This should be close enough. */
76#define IN_SIGTRAMP(pc, name) ((pc) >= STACK_END_ADDR && (pc < 0xc0000000))
77
78/* Stack grows downward. */
79
80#define INNER_THAN <
81
82/* Sequence of bytes for breakpoint instruction. */
83
84#define BREAKPOINT {0x30}
85
86/* Amount PC must be decremented by after a breakpoint.
87 This is often the number of bytes in BREAKPOINT
88 but not always. */
89
90#define DECR_PC_AFTER_BREAK 0
91
92/* Nonzero if instruction at PC is a return instruction. */
93
94#define ABOUT_TO_RETURN(pc) (read_memory_integer (pc, 1) == 0x40)
95
96/* Return 1 if P points to an invalid floating point value.
97 LEN is the length in bytes -- not relevant on the Tahoe. */
98
99#define INVALID_FLOAT(p, len) ((*(short *) p & 0xff80) == 0x8000)
100
101/* Say how long (ordinary) registers are. */
102
103#define REGISTER_TYPE long
104
105/* Number of machine registers */
106
107#define NUM_REGS 19
108
109/* Initializer for an array of names of registers.
110 There should be NUM_REGS strings in this initializer. */
111
112#define REGISTER_NAMES {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "fp", "sp", "pc", "ps", "al", "ah"}
113
114#define FP_REGNUM 13 /* Contains address of executing stack frame */
115#define SP_REGNUM 14 /* Contains address of top of stack */
116#define PC_REGNUM 15 /* Contains program counter */
117#define PS_REGNUM 16 /* Contains processor status */
118
119#define AL_REGNUM 17 /* Contains accumulator */
120#define AH_REGNUM 18
121
122/* Total amount of space needed to store our copies of the machine's
123 register state, the array `registers'. */
124
125#define REGISTER_BYTES (19*4)
126
127/* Index within `registers' of the first byte of the space for
128 register N. */
129
130#define REGISTER_BYTE(N) ((N) * 4)
131
132/* Number of bytes of storage in the actual machine representation
133 for register N. On the tahoe, all regs are 4 bytes. */
134
135#define REGISTER_RAW_SIZE(N) 4
136
137/* Number of bytes of storage in the program's representation
138 for register N. On the tahoe, all regs are 4 bytes. */
139
140#define REGISTER_VIRTUAL_SIZE(N) 4
141
142/* Largest value REGISTER_RAW_SIZE can have. */
143
144#define MAX_REGISTER_RAW_SIZE 4
145
146/* Largest value REGISTER_VIRTUAL_SIZE can have. */
147
148#define MAX_REGISTER_VIRTUAL_SIZE 4
149
150/* Nonzero if register N requires conversion
151 from raw format to virtual format. */
152
153#define REGISTER_CONVERTIBLE(N) 0
154
155/* Convert data from raw format for register REGNUM
156 to virtual format for register REGNUM. */
157
158#define REGISTER_CONVERT_TO_VIRTUAL(REGNUM,FROM,TO) \
159 bcopy ((FROM), (TO), 4);
160
161/* Convert data from virtual format for register REGNUM
162 to raw format for register REGNUM. */
163
164#define REGISTER_CONVERT_TO_RAW(REGNUM,FROM,TO) \
165 bcopy ((FROM), (TO), 4);
166
167/* Return the GDB type object for the "standard" data type
168 of data in register N. */
169
170#define REGISTER_VIRTUAL_TYPE(N) builtin_type_int
171
172/* Store the address of the place in which to copy the structure the
173 subroutine will return. This is called from call_function. */
174
175#define STORE_STRUCT_RETURN(ADDR, SP) \
176 { write_register (1, (ADDR)); }
177
178/* Extract from an array REGBUF containing the (raw) register state
179 a function return value of type TYPE, and copy that, in virtual format,
180 into VALBUF. */
181
182#define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \
183 bcopy (REGBUF, VALBUF, TYPE_LENGTH (TYPE))
184
185/* Write into appropriate registers a function return value
186 of type TYPE, given in virtual format. */
187
188#define STORE_RETURN_VALUE(TYPE,VALBUF) \
189 write_register_bytes (0, VALBUF, TYPE_LENGTH (TYPE))
190
191/* Extract from an array REGBUF containing the (raw) register state
192 the address in which a function should return its structure value,
193 as a CORE_ADDR (or an expression that can be used as one). */
194
195#define EXTRACT_STRUCT_VALUE_ADDRESS(REGBUF) (*(int *)(REGBUF))
196
197/* Describe the pointer in each stack frame to the previous stack frame
198 (its caller).
199
200 FRAME_CHAIN takes a frame's nominal address
5e2e79f8 201 and produces the frame's chain-pointer. */
cb173f45
JK
202
203/* In the case of the Tahoe, the frame's nominal address is the FP value,
204 and it points to the old FP */
205
206#define FRAME_CHAIN(thisframe) \
5e2e79f8 207 (!inside_entry_file ((thisframe)->pc) ? \
cb173f45
JK
208 read_memory_integer ((thisframe)->frame, 4) :\
209 0)
210
cb173f45
JK
211/* Define other aspects of the stack frame. */
212
213/* Saved PC */
214
215#define FRAME_SAVED_PC(FRAME) (read_memory_integer ((FRAME)->frame - 8, 4))
216
217/* In most of GDB, getting the args address is too important to
218 just say "I don't know". */
219
b68da3b8 220#define FRAME_ARGS_ADDRESS(fi) ((fi)->frame)
cb173f45
JK
221
222/* Address to use as an anchor for finding local variables */
223
224#define FRAME_LOCALS_ADDRESS(fi) ((fi)->frame)
225
226/* Return number of args passed to a frame.
227 Can return -1, meaning no way to tell. */
228
229#define FRAME_NUM_ARGS(numargs, fi) \
230{ numargs = ((0xffff & read_memory_integer(((fi)->frame-4),4)) - 4) >> 2; }
231
232/* Return number of bytes at start of arglist that are not really args. */
233
234#define FRAME_ARGS_SKIP 0
235
236/* Put here the code to store, into a struct frame_saved_regs,
237 the addresses of the saved registers of frame described by FRAME_INFO.
238 This includes special registers such as pc and fp saved in special
239 ways in the stack frame. sp is even more special:
240 the address we return for it IS the sp for the next frame. */
241
242#define FRAME_FIND_SAVED_REGS(frame_info, frame_saved_regs) \
243{ register int regnum; \
244 register int rmask = read_memory_integer ((frame_info)->frame-4, 4) >> 16;\
245 register CORE_ADDR next_addr; \
246 bzero (&frame_saved_regs, sizeof frame_saved_regs); \
247 next_addr = (frame_info)->frame - 8; \
248 for (regnum = 12; regnum >= 0; regnum--, rmask <<= 1) \
249 (frame_saved_regs).regs[regnum] = (rmask & 0x1000) ? (next_addr -= 4) : 0;\
250 (frame_saved_regs).regs[SP_REGNUM] = (frame_info)->frame + 4; \
251 (frame_saved_regs).regs[PC_REGNUM] = (frame_info)->frame - 8; \
252 (frame_saved_regs).regs[FP_REGNUM] = (frame_info)->frame; \
253}
254
255/* Things needed for making the inferior call functions. */
256
257/* Push an empty stack frame, to record the current PC, etc. */
258
259#define PUSH_DUMMY_FRAME \
260{ register CORE_ADDR sp = read_register (SP_REGNUM); \
261 register int regnum; \
262printf("PUSH_DUMMY_FRAME\n"); \
263 sp = push_word (sp, read_register (FP_REGNUM)); \
264 write_register (FP_REGNUM, sp); \
265 sp = push_word (sp, 0x1fff0004); /*SAVE MASK*/ \
266 sp = push_word (sp, read_register (PC_REGNUM)); \
267 for (regnum = 12; regnum >= 0; regnum--) \
268 sp = push_word (sp, read_register (regnum)); \
269 write_register (SP_REGNUM, sp); \
270}
271
272/* Discard from the stack the innermost frame, restoring all registers. */
273
274#define POP_FRAME \
275{ register CORE_ADDR fp = read_register (FP_REGNUM); \
276 register int regnum; \
277 register int regmask = read_memory_integer (fp-4, 4); \
278printf("POP_FRAME\n"); \
279 regmask >>= 16; \
280 write_register (SP_REGNUM, fp+4); \
281 write_register (PC_REGNUM, read_memory_integer(fp-8, 4)); \
282 write_register (FP_REGNUM, read_memory_integer(fp, 4)); \
283 fp -= 8; \
284 for (regnum = 12; regnum >= 0; regnum--, regmask <<= 1) \
285 if (regmask & 0x1000) \
286 write_register (regnum, read_memory_integer (fp-=4, 4)); \
287 flush_cached_frames (); \
288 set_current_frame (create_new_frame (read_register (FP_REGNUM), \
289 read_pc ())); }
290
291/* This sequence of words is the instructions
292 calls #69, @#32323232
293 bpt
294 Note this is 8 bytes. */
295
296#define CALL_DUMMY {0xbf699f32, 0x32323230}
297
298/* Start execution at beginning of dummy */
299
300#define CALL_DUMMY_START_OFFSET 0
301
302/* Insert the specified number of args and function address
303 into a call sequence of the above form stored at DUMMYNAME. */
304
0c540082 305#define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, valtype, using_gcc) \
cb173f45
JK
306{ int temp = (int) fun; \
307 *((char *) dummyname + 1) = nargs; \
308 bcopy(&temp,(char *)dummyname+3,4); }
309
This page took 0.101463 seconds and 4 git commands to generate.