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