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