Commit | Line | Data |
---|---|---|
5076de82 FF |
1 | /* Parameters for target machine of AMD 29000, for GDB, the GNU debugger. |
2 | Copyright 1990, 1991, 1993 Free Software Foundation, Inc. | |
3 | Contributed by Cygnus Support. Written by Jim Kingdon. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | /* Parameters for an EB29K (a board which plugs into a PC and is | |
22 | accessed through EBMON software running on the PC, which we | |
23 | use as we'd use a remote stub (see remote-eb.c). | |
24 | ||
d7d35f00 | 25 | If gdb is ported to other a29k machines/systems, the |
5076de82 | 26 | machine/system-specific parts should be removed from this file (a |
2225eb85 | 27 | la tm-m68k.h). */ |
5076de82 FF |
28 | |
29 | /* Byte order is configurable, but this machine runs big-endian. */ | |
30 | #define TARGET_BYTE_ORDER BIG_ENDIAN | |
31 | ||
32 | /* Floating point uses IEEE representations. */ | |
33 | #define IEEE_FLOAT | |
34 | ||
35 | /* Recognize our magic number. */ | |
36 | #define BADMAG(x) ((x).f_magic != 0572) | |
37 | ||
38 | /* Offset from address of function to start of its code. | |
39 | Zero on most machines. */ | |
40 | ||
41 | #define FUNCTION_START_OFFSET 0 | |
42 | ||
43 | /* Advance PC across any function entry prologue instructions | |
44 | to reach some "real" code. */ | |
45 | ||
46 | #define SKIP_PROLOGUE(pc) \ | |
47 | { pc = skip_prologue (pc); } | |
48 | CORE_ADDR skip_prologue (); | |
49 | ||
50 | /* Immediately after a function call, return the saved pc. | |
51 | Can't go through the frames for this because on some machines | |
52 | the new frame is not set up until the new function executes | |
53 | some instructions. */ | |
54 | ||
899931b6 JK |
55 | #define SAVED_PC_AFTER_CALL(frame) ((frame->flags & TRANSPARENT) \ |
56 | ? read_register (TPC_REGNUM) \ | |
57 | : read_register (LR0_REGNUM)) | |
5076de82 FF |
58 | |
59 | /* I'm not sure about the exact value of this, but based on looking | |
60 | at the stack pointer when we get to main this seems to be right. | |
61 | ||
62 | This is the register stack; We call it "CONTROL" in GDB for consistency | |
63 | with Pyramid. */ | |
75fa3e0f | 64 | /* I suspect this is obsolete, just like STACK_END_ADDR. */ |
5076de82 FF |
65 | #define CONTROL_END_ADDR 0x80200000 |
66 | ||
5076de82 FF |
67 | /* Stack grows downward. */ |
68 | ||
69 | #define INNER_THAN < | |
70 | ||
71 | /* Stack must be aligned on 32-bit word boundaries. */ | |
72 | #define STACK_ALIGN(ADDR) (((ADDR) + 3) & ~3) | |
73 | ||
74 | /* Sequence of bytes for breakpoint instruction. */ | |
75 | /* ASNEQ 0x50, gr1, gr1 | |
76 | The trap number 0x50 is chosen arbitrarily. | |
77 | We let the command line (or previously included files) override this | |
78 | setting. */ | |
79 | #ifndef BREAKPOINT | |
80 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
81 | #define BREAKPOINT {0x72, 0x50, 0x01, 0x01} | |
82 | #else /* Target is little-endian. */ | |
83 | #define BREAKPOINT {0x01, 0x01, 0x50, 0x72} | |
84 | #endif /* Target is little-endian. */ | |
85 | #endif /* BREAKPOINT */ | |
86 | ||
87 | /* Amount PC must be decremented by after a breakpoint. | |
88 | This is often the number of bytes in BREAKPOINT | |
89 | but not always. */ | |
90 | ||
91 | #define DECR_PC_AFTER_BREAK 0 | |
92 | ||
93 | /* Nonzero if instruction at PC is a return instruction. | |
d7d35f00 | 94 | On the a29k, this is a "jmpi l0" instruction. */ |
5076de82 FF |
95 | |
96 | #define ABOUT_TO_RETURN(pc) \ | |
97 | ((read_memory_integer (pc, 4) & 0xff0000ff) == 0xc0000080) | |
98 | ||
99 | /* Return 1 if P points to an invalid floating point value. */ | |
100 | ||
101 | #define INVALID_FLOAT(p, len) 0 /* Just a first guess; not checked */ | |
102 | ||
f4f0d174 JK |
103 | /* Say how long (ordinary) registers are. This is a piece of bogosity |
104 | used in push_word and a few other places; REGISTER_RAW_SIZE is the | |
105 | real way to know how big a register is. */ | |
5076de82 | 106 | |
f4f0d174 | 107 | #define REGISTER_SIZE 4 |
5076de82 FF |
108 | |
109 | /* Allow the register declarations here to be overridden for remote | |
110 | kernel debugging. */ | |
111 | #if !defined (REGISTER_NAMES) | |
112 | ||
113 | /* Number of machine registers */ | |
114 | ||
115 | #define NUM_REGS 205 | |
116 | ||
117 | /* Initializer for an array of names of registers. | |
118 | There should be NUM_REGS strings in this initializer. | |
119 | ||
120 | FIXME, add floating point registers and support here. | |
121 | ||
122 | Also note that this list does not attempt to deal with kernel | |
123 | debugging (in which the first 32 registers are gr64-gr95). */ | |
124 | ||
125 | #define REGISTER_NAMES \ | |
126 | {"gr96", "gr97", "gr98", "gr99", "gr100", "gr101", "gr102", "gr103", "gr104", \ | |
127 | "gr105", "gr106", "gr107", "gr108", "gr109", "gr110", "gr111", "gr112", \ | |
128 | "gr113", "gr114", "gr115", "gr116", "gr117", "gr118", "gr119", "gr120", \ | |
129 | "gr121", "gr122", "gr123", "gr124", "gr125", "gr126", "gr127", \ | |
130 | "lr0", "lr1", "lr2", "lr3", "lr4", "lr5", "lr6", "lr7", "lr8", "lr9", \ | |
131 | "lr10", "lr11", "lr12", "lr13", "lr14", "lr15", "lr16", "lr17", "lr18", \ | |
132 | "lr19", "lr20", "lr21", "lr22", "lr23", "lr24", "lr25", "lr26", "lr27", \ | |
133 | "lr28", "lr29", "lr30", "lr31", "lr32", "lr33", "lr34", "lr35", "lr36", \ | |
134 | "lr37", "lr38", "lr39", "lr40", "lr41", "lr42", "lr43", "lr44", "lr45", \ | |
135 | "lr46", "lr47", "lr48", "lr49", "lr50", "lr51", "lr52", "lr53", "lr54", \ | |
136 | "lr55", "lr56", "lr57", "lr58", "lr59", "lr60", "lr61", "lr62", "lr63", \ | |
137 | "lr64", "lr65", "lr66", "lr67", "lr68", "lr69", "lr70", "lr71", "lr72", \ | |
138 | "lr73", "lr74", "lr75", "lr76", "lr77", "lr78", "lr79", "lr80", "lr81", \ | |
139 | "lr82", "lr83", "lr84", "lr85", "lr86", "lr87", "lr88", "lr89", "lr90", \ | |
140 | "lr91", "lr92", "lr93", "lr94", "lr95", "lr96", "lr97", "lr98", "lr99", \ | |
141 | "lr100", "lr101", "lr102", "lr103", "lr104", "lr105", "lr106", "lr107", \ | |
142 | "lr108", "lr109", "lr110", "lr111", "lr112", "lr113", "lr114", "lr115", \ | |
143 | "lr116", "lr117", "lr118", "lr119", "lr120", "lr121", "lr122", "lr123", \ | |
144 | "lr124", "lr125", "lr126", "lr127", \ | |
145 | "AI0", "AI1", "AI2", "AI3", "AI4", "AI5", "AI6", "AI7", "AI8", "AI9", \ | |
146 | "AI10", "AI11", "AI12", "AI13", "AI14", "AI15", "FP", \ | |
147 | "bp", "fc", "cr", "q", \ | |
148 | "vab", "ops", "cps", "cfg", "cha", "chd", "chc", "rbp", "tmc", "tmr", \ | |
149 | "pc0", "pc1", "pc2", "mmu", "lru", "fpe", "inte", "fps", "exo", "gr1", \ | |
150 | "alu", "ipc", "ipa", "ipb" } | |
151 | ||
152 | /* | |
153 | * Converts an sdb register number to an internal gdb register number. | |
154 | * Currently under epi, gr96->0...gr127->31...lr0->32...lr127->159, or... | |
155 | * gr64->0...gr95->31, lr0->32...lr127->159. | |
156 | */ | |
157 | #define SDB_REG_TO_REGNUM(value) \ | |
158 | (((value) >= 96 && (value) <= 127) ? ((value) - 96) : \ | |
159 | ((value) >= 128 && (value) <= 255) ? ((value) - 128 + LR0_REGNUM) : \ | |
160 | (value)) | |
161 | ||
162 | /* | |
163 | * Provide the processor register numbers of some registers that are | |
164 | * expected/written in instructions that might change under different | |
165 | * register sets. Namely, gcc can compile (-mkernel-registers) so that | |
166 | * it uses gr64-gr95 in stead of gr96-gr127. | |
167 | */ | |
168 | #define MSP_HW_REGNUM 125 /* gr125 */ | |
169 | #define RAB_HW_REGNUM 126 /* gr126 */ | |
170 | ||
171 | /* Convert Processor Special register #x to REGISTER_NAMES register # */ | |
172 | #define SR_REGNUM(x) \ | |
173 | ((x) < 15 ? VAB_REGNUM + (x) \ | |
174 | : (x) >= 128 && (x) < 131 ? IPC_REGNUM + (x) - 128 \ | |
175 | : (x) == 131 ? Q_REGNUM \ | |
176 | : (x) == 132 ? ALU_REGNUM \ | |
177 | : (x) >= 133 && (x) < 136 ? BP_REGNUM + (x) - 133 \ | |
178 | : (x) >= 160 && (x) < 163 ? FPE_REGNUM + (x) - 160 \ | |
179 | : (x) == 164 ? EXO_REGNUM \ | |
180 | : (error ("Internal error in SR_REGNUM"), 0)) | |
181 | #define GR96_REGNUM 0 | |
899931b6 | 182 | |
5076de82 FF |
183 | /* Define the return register separately, so it can be overridden for |
184 | kernel procedure calling conventions. */ | |
185 | #define RETURN_REGNUM GR96_REGNUM | |
186 | #define GR1_REGNUM 200 | |
187 | /* This needs to be the memory stack pointer, not the register stack pointer, | |
188 | to make call_function work right. */ | |
189 | #define SP_REGNUM MSP_REGNUM | |
190 | #define FP_REGNUM 33 /* lr1 */ | |
899931b6 JK |
191 | |
192 | /* Return register for transparent calling convention (gr122). */ | |
193 | #define TPC_REGNUM (122 - 96 + GR96_REGNUM) | |
194 | ||
5076de82 FF |
195 | /* Large Return Pointer (gr123). */ |
196 | #define LRP_REGNUM (123 - 96 + GR96_REGNUM) | |
899931b6 | 197 | |
5076de82 FF |
198 | /* Static link pointer (gr124). */ |
199 | #define SLP_REGNUM (124 - 96 + GR96_REGNUM) | |
899931b6 | 200 | |
5076de82 FF |
201 | /* Memory Stack Pointer (gr125). */ |
202 | #define MSP_REGNUM (125 - 96 + GR96_REGNUM) | |
899931b6 | 203 | |
5076de82 FF |
204 | /* Register allocate bound (gr126). */ |
205 | #define RAB_REGNUM (126 - 96 + GR96_REGNUM) | |
899931b6 | 206 | |
5076de82 FF |
207 | /* Register Free Bound (gr127). */ |
208 | #define RFB_REGNUM (127 - 96 + GR96_REGNUM) | |
899931b6 | 209 | |
5076de82 FF |
210 | /* Register Stack Pointer. */ |
211 | #define RSP_REGNUM GR1_REGNUM | |
212 | #define LR0_REGNUM 32 | |
213 | #define BP_REGNUM 177 | |
214 | #define FC_REGNUM 178 | |
215 | #define CR_REGNUM 179 | |
216 | #define Q_REGNUM 180 | |
217 | #define VAB_REGNUM 181 | |
218 | #define OPS_REGNUM (VAB_REGNUM + 1) | |
219 | #define CPS_REGNUM (VAB_REGNUM + 2) | |
220 | #define CFG_REGNUM (VAB_REGNUM + 3) | |
221 | #define CHA_REGNUM (VAB_REGNUM + 4) | |
222 | #define CHD_REGNUM (VAB_REGNUM + 5) | |
223 | #define CHC_REGNUM (VAB_REGNUM + 6) | |
224 | #define RBP_REGNUM (VAB_REGNUM + 7) | |
225 | #define TMC_REGNUM (VAB_REGNUM + 8) | |
226 | #define TMR_REGNUM (VAB_REGNUM + 9) | |
227 | #define NPC_REGNUM (VAB_REGNUM + 10) /* pc0 */ | |
228 | #define PC_REGNUM (VAB_REGNUM + 11) /* pc1 */ | |
229 | #define PC2_REGNUM (VAB_REGNUM + 12) | |
230 | #define MMU_REGNUM (VAB_REGNUM + 13) | |
231 | #define LRU_REGNUM (VAB_REGNUM + 14) | |
232 | #define FPE_REGNUM (VAB_REGNUM + 15) | |
233 | #define INTE_REGNUM (VAB_REGNUM + 16) | |
234 | #define FPS_REGNUM (VAB_REGNUM + 17) | |
235 | #define EXO_REGNUM (VAB_REGNUM + 18) | |
236 | /* gr1 is defined above as 200 = VAB_REGNUM + 19 */ | |
237 | #define ALU_REGNUM (VAB_REGNUM + 20) | |
238 | #define PS_REGNUM ALU_REGNUM | |
239 | #define IPC_REGNUM (VAB_REGNUM + 21) | |
240 | #define IPA_REGNUM (VAB_REGNUM + 22) | |
241 | #define IPB_REGNUM (VAB_REGNUM + 23) | |
242 | ||
243 | #endif /* !defined(REGISTER_NAMES) */ | |
244 | ||
245 | /* Total amount of space needed to store our copies of the machine's | |
246 | register state, the array `registers'. */ | |
247 | #define REGISTER_BYTES (NUM_REGS * 4) | |
248 | ||
249 | /* Index within `registers' of the first byte of the space for | |
250 | register N. */ | |
251 | #define REGISTER_BYTE(N) ((N)*4) | |
252 | ||
253 | /* Number of bytes of storage in the actual machine representation | |
254 | for register N. */ | |
255 | ||
256 | /* All regs are 4 bytes. */ | |
257 | ||
258 | #define REGISTER_RAW_SIZE(N) (4) | |
259 | ||
260 | /* Number of bytes of storage in the program's representation | |
261 | for register N. */ | |
262 | ||
263 | /* All regs are 4 bytes. */ | |
264 | ||
265 | #define REGISTER_VIRTUAL_SIZE(N) (4) | |
266 | ||
267 | /* Largest value REGISTER_RAW_SIZE can have. */ | |
268 | ||
269 | #define MAX_REGISTER_RAW_SIZE (4) | |
270 | ||
271 | /* Largest value REGISTER_VIRTUAL_SIZE can have. */ | |
272 | ||
273 | #define MAX_REGISTER_VIRTUAL_SIZE (4) | |
274 | ||
5076de82 FF |
275 | /* Return the GDB type object for the "standard" data type |
276 | of data in register N. */ | |
277 | ||
278 | #define REGISTER_VIRTUAL_TYPE(N) \ | |
279 | (((N) == PC_REGNUM || (N) == LRP_REGNUM || (N) == SLP_REGNUM \ | |
280 | || (N) == MSP_REGNUM || (N) == RAB_REGNUM || (N) == RFB_REGNUM \ | |
281 | || (N) == GR1_REGNUM || (N) == FP_REGNUM || (N) == LR0_REGNUM \ | |
282 | || (N) == NPC_REGNUM || (N) == PC2_REGNUM) \ | |
283 | ? lookup_pointer_type (builtin_type_void) : builtin_type_int) | |
284 | \f | |
285 | /* Store the address of the place in which to copy the structure the | |
286 | subroutine will return. This is called from call_function. */ | |
d7d35f00 | 287 | /* On the a29k the LRP points to the part of the structure beyond the first |
5076de82 FF |
288 | 16 words. */ |
289 | #define STORE_STRUCT_RETURN(ADDR, SP) \ | |
290 | write_register (LRP_REGNUM, (ADDR) + 16 * 4); | |
291 | ||
292 | /* Should call_function allocate stack space for a struct return? */ | |
d7d35f00 | 293 | /* On the a29k objects over 16 words require the caller to allocate space. */ |
5076de82 FF |
294 | #define USE_STRUCT_CONVENTION(gcc_p, type) (TYPE_LENGTH (type) > 16 * 4) |
295 | ||
296 | /* Extract from an array REGBUF containing the (raw) register state | |
297 | a function return value of type TYPE, and copy that, in virtual format, | |
298 | into VALBUF. */ | |
299 | ||
300 | #define EXTRACT_RETURN_VALUE(TYPE,REGBUF,VALBUF) \ | |
301 | { \ | |
302 | int reg_length = TYPE_LENGTH (TYPE); \ | |
303 | if (reg_length > 16 * 4) \ | |
304 | { \ | |
305 | reg_length = 16 * 4; \ | |
306 | read_memory (*((int *)(REGBUF) + LRP_REGNUM), (VALBUF) + 16 * 4, \ | |
307 | TYPE_LENGTH (TYPE) - 16 * 4); \ | |
308 | } \ | |
ade40d31 | 309 | memcpy ((VALBUF), ((int *)(REGBUF))+RETURN_REGNUM, reg_length); \ |
5076de82 FF |
310 | } |
311 | ||
312 | /* Write into appropriate registers a function return value | |
313 | of type TYPE, given in virtual format. */ | |
314 | ||
315 | #define STORE_RETURN_VALUE(TYPE,VALBUF) \ | |
316 | { \ | |
317 | int reg_length = TYPE_LENGTH (TYPE); \ | |
318 | if (reg_length > 16 * 4) \ | |
319 | { \ | |
320 | reg_length = 16 * 4; \ | |
321 | write_memory (read_register (LRP_REGNUM), \ | |
322 | (char *)(VALBUF) + 16 * 4, \ | |
323 | TYPE_LENGTH (TYPE) - 16 * 4); \ | |
324 | } \ | |
325 | write_register_bytes (REGISTER_BYTE (RETURN_REGNUM), (char *)(VALBUF), \ | |
326 | TYPE_LENGTH (TYPE)); \ | |
327 | } | |
328 | \f | |
d7d35f00 | 329 | /* The a29k user's guide documents well what the stacks look like. |
5076de82 FF |
330 | But what isn't so clear there is how this interracts with the |
331 | symbols, or with GDB. | |
332 | In the following saved_msp, saved memory stack pointer (which functions | |
333 | as a memory frame pointer), means either | |
334 | a register containing the memory frame pointer or, in the case of | |
335 | functions with fixed size memory frames (i.e. those who don't use | |
336 | alloca()), the result of the calculation msp + msize. | |
337 | ||
338 | LOC_ARG, LOC_LOCAL - For GCC, these are relative to saved_msp. | |
339 | For high C, these are relative to msp (making alloca impossible). | |
340 | LOC_REGISTER, LOC_REGPARM - The register number is the number at the | |
341 | time the function is running (after the prologue), or in the case | |
342 | of LOC_REGPARM, may be a register number in the range 160-175. | |
343 | ||
344 | The compilers do things like store an argument into memory, and then put out | |
345 | a LOC_ARG for it, or put it into global registers and put out a | |
346 | LOC_REGPARM. Thus is it important to execute the first line of | |
347 | code (i.e. the line of the open brace, i.e. the prologue) of a function | |
348 | before trying to print arguments or anything. | |
349 | ||
350 | The following diagram attempts to depict what is going on in memory | |
d7d35f00 | 351 | (see also the _a29k user's guide_) and also how that interacts with |
5076de82 FF |
352 | GDB frames. We arbitrarily pick fci->frame to point the same place |
353 | as the register stack pointer; since we set it ourself in | |
354 | INIT_EXTRA_FRAME_INFO, and access it only through the FRAME_* | |
355 | macros, it doesn't really matter exactly how we | |
356 | do it. However, note that FRAME_FP is used in two ways in GDB: | |
357 | (1) as a "magic cookie" which uniquely identifies frames (even over | |
358 | calls to the inferior), (2) (in PC_IN_CALL_DUMMY [ON_STACK]) | |
359 | as the value of SP_REGNUM before the dummy frame was pushed. These | |
d7d35f00 | 360 | two meanings would be incompatible for the a29k if we defined |
5076de82 FF |
361 | CALL_DUMMY_LOCATION == ON_STACK (but we don't, so don't worry about it). |
362 | Also note that "lr1" below, while called a frame pointer | |
363 | in the user's guide, has only one function: To determine whether | |
364 | registers need to be filled in the function epilogue. | |
365 | ||
366 | Consider the code: | |
367 | < call bar> | |
368 | loc1: . . . | |
369 | bar: sub gr1,gr1,rsize_b | |
370 | . . . | |
371 | add mfp,msp,0 | |
372 | sub msp,msp,msize_b | |
373 | . . . | |
374 | < call foo > | |
375 | loc2: . . . | |
376 | foo: sub gr1,gr1,rsize_f | |
377 | . . . | |
378 | add mfp,msp,0 | |
379 | sub msp,msp,msize_f | |
380 | . . . | |
381 | loc3: < suppose the inferior stops here > | |
382 | ||
383 | memory stack register stack | |
384 | | | |____________| | |
385 | | | |____loc1____| | |
386 | +------->|___________| | | ^ | |
387 | | | ^ | | locals_b | | | |
388 | | | | | |____________| | | |
389 | | | | | | | | rsize_b | |
390 | | | | msize_b | | args_to_f | | | |
391 | | | | | |____________| | | |
392 | | | | | |____lr1_____| V | |
393 | | | V | |____loc2____|<----------------+ | |
394 | | +--->|___________|<---------mfp | ^ | | |
395 | | | | ^ | | locals_f | | | | |
396 | | | | | msize_f | |____________| | | | |
397 | | | | | | | | | rsize_f | | |
398 | | | | V | | args | | | | |
399 | | | |___________|<msp |____________| | | | |
400 | | | |_____lr1____| V | | |
401 | | | |___garbage__| <- gr1 <----+ | | |
402 | | | | | | |
403 | | | | | | |
404 | | | pc=loc3 | | | |
405 | | | | | | |
406 | | | | | | |
407 | | | frame cache | | | |
408 | | | |_________________| | | | |
409 | | | |rsize=rsize_b | | | | |
410 | | | |msize=msize_b | | | | |
411 | +---|--------saved_msp | | | | |
412 | | |frame------------------------------------|---+ | |
413 | | |pc=loc2 | | | |
414 | | |_________________| | | |
415 | | |rsize=rsize_f | | | |
416 | | |msize=msize_f | | | |
417 | +--------saved_msp | | | |
418 | |frame------------------------------------+ | |
419 | |pc=loc3 | | |
420 | |_________________| | |
421 | ||
422 | So, is that sufficiently confusing? Welcome to the 29000. | |
423 | Notes: | |
424 | * The frame for foo uses a memory frame pointer but the frame for | |
425 | bar does not. In the latter case the saved_msp is | |
426 | computed by adding msize to the saved_msp of the | |
427 | next frame. | |
428 | * msize is in the frame cache only for high C's sake. */ | |
429 | ||
430 | void read_register_stack (); | |
431 | long read_register_stack_integer (); | |
432 | \f | |
433 | #define EXTRA_FRAME_INFO \ | |
434 | CORE_ADDR saved_msp; \ | |
435 | unsigned int rsize; \ | |
436 | unsigned int msize; \ | |
437 | unsigned char flags; | |
438 | ||
439 | /* Bits for flags in EXTRA_FRAME_INFO */ | |
440 | #define TRANSPARENT 0x1 /* This is a transparent frame */ | |
441 | #define MFP_USED 0x2 /* A memory frame pointer is used */ | |
442 | ||
443 | /* Because INIT_FRAME_PC gets passed fromleaf, that's where we init | |
444 | not only ->pc and ->frame, but all the extra stuff, when called from | |
445 | get_prev_frame_info, that is. */ | |
446 | #define INIT_EXTRA_FRAME_INFO(fromleaf, fci) init_extra_frame_info(fci) | |
447 | void init_extra_frame_info (); | |
448 | ||
449 | #define INIT_FRAME_PC(fromleaf, fci) init_frame_pc(fromleaf, fci) | |
450 | void init_frame_pc (); | |
451 | ||
452 | \f | |
453 | /* FRAME_CHAIN takes a FRAME | |
454 | and produces the frame's chain-pointer. | |
455 | ||
456 | However, if FRAME_CHAIN_VALID returns zero, | |
457 | it means the given frame is the outermost one and has no caller. */ | |
458 | ||
d7d35f00 | 459 | /* On the a29k, the nominal address of a frame is the address on the |
5076de82 FF |
460 | register stack of the return address (the one next to the incoming |
461 | arguments, not down at the bottom so nominal address == stack pointer). | |
462 | ||
463 | GDB expects "nominal address" to equal contents of FP_REGNUM, | |
464 | at least when it comes time to create the innermost frame. | |
465 | However, that doesn't work for us, so when creating the innermost | |
466 | frame we set ->frame ourselves in INIT_EXTRA_FRAME_INFO. */ | |
467 | ||
d7d35f00 | 468 | /* These are mostly dummies for the a29k because INIT_FRAME_PC |
5076de82 | 469 | sets prev->frame instead. */ |
f8efbf22 JK |
470 | /* If rsize is zero, we must be at end of stack (or otherwise hosed). |
471 | If we don't check rsize, we loop forever if we see rsize == 0. */ | |
472 | #define FRAME_CHAIN(thisframe) \ | |
473 | ((thisframe)->rsize == 0 \ | |
474 | ? 0 \ | |
475 | : (thisframe)->frame + (thisframe)->rsize) | |
5076de82 FF |
476 | |
477 | /* Determine if the frame has a 'previous' and back-traceable frame. */ | |
478 | #define FRAME_IS_UNCHAINED(frame) ((frame)->flags & TRANSPARENT) | |
479 | ||
480 | /* Find the previous frame of a transparent routine. | |
481 | * For now lets not try and trace through a transparent routine (we might | |
482 | * have to assume that all transparent routines are traps). | |
483 | */ | |
484 | #define FIND_PREV_UNCHAINED_FRAME(frame) 0 | |
485 | ||
486 | /* Define other aspects of the stack frame. */ | |
487 | ||
488 | /* A macro that tells us whether the function invocation represented | |
489 | by FI does not have a frame on the stack associated with it. If it | |
490 | does not, FRAMELESS is set to 1, else 0. */ | |
491 | #define FRAMELESS_FUNCTION_INVOCATION(FI, FRAMELESS) \ | |
492 | (FRAMELESS) = frameless_look_for_prologue(FI) | |
493 | ||
494 | /* Saved pc (i.e. return address). */ | |
495 | #define FRAME_SAVED_PC(fraim) \ | |
496 | (read_register_stack_integer ((fraim)->frame + (fraim)->rsize, 4)) | |
497 | ||
498 | /* Local variables (i.e. LOC_LOCAL) are on the memory stack, with their | |
499 | offsets being relative to the memory stack pointer (high C) or | |
500 | saved_msp (gcc). */ | |
501 | ||
502 | #define FRAME_LOCALS_ADDRESS(fi) frame_locals_address (fi) | |
503 | extern CORE_ADDR frame_locals_address (); | |
504 | ||
505 | /* Return number of args passed to a frame. | |
506 | Can return -1, meaning no way to tell. */ | |
507 | /* While we could go the effort of finding the tags word and getting | |
508 | the argcount field from it, | |
509 | (1) It only counts arguments in registers, i.e. the first 16 words | |
510 | of arguments | |
511 | (2) It gives the number of arguments the function was declared with | |
512 | not how many it was called with (or some variation, like all 16 | |
513 | words for varadic functions). This makes argcount pretty much | |
514 | redundant with -g info, even for varadic functions. | |
515 | So don't bother. */ | |
516 | #define FRAME_NUM_ARGS(numargs, fi) ((numargs) = -1) | |
517 | ||
518 | #define FRAME_ARGS_ADDRESS(fi) FRAME_LOCALS_ADDRESS (fi) | |
519 | ||
520 | /* Return number of bytes at start of arglist that are not really args. */ | |
521 | ||
522 | #define FRAME_ARGS_SKIP 0 | |
523 | ||
524 | /* Provide our own get_saved_register. HAVE_REGISTER_WINDOWS is insufficient | |
d7d35f00 | 525 | because registers get renumbered on the a29k without getting saved. */ |
5076de82 FF |
526 | |
527 | #define GET_SAVED_REGISTER | |
528 | \f | |
529 | /* Call function stuff. */ | |
530 | ||
531 | /* The dummy frame looks like this (see also the general frame picture | |
532 | above): | |
533 | ||
534 | register stack | |
535 | ||
536 | | | frame for function | |
537 | | locals_sproc | executing at time | |
538 | |________________| of call_function. | |
539 | | | We must not disturb | |
540 | | args_out_sproc | it. | |
541 | memory stack |________________| | |
542 | |____lr1_sproc___|<-+ | |
543 | | | |__retaddr_sproc_| | <-- gr1 (at start) | |
544 | |____________|<-msp 0 <-----------mfp_dummy_____| | | |
545 | | | (at start) | save regs | | | |
546 | | arg_slop | | pc0,pc1 | | | |
547 | | (16 words) | | gr96-gr124 | | | |
548 | |____________|<-msp 1--after | sr160-sr162 | | | |
549 | | | PUSH_DUMMY_FRAME| sr128-sr135 | | | |
550 | | struct ret | |________________| | | |
551 | | 17+ | | | | | |
552 | |____________|<- lrp | args_out_dummy | | | |
553 | | struct ret | | (16 words) | | | |
554 | | 16 | |________________| | | |
555 | | (16 words) | |____lr1_dummy___|--+ | |
556 | |____________|<- msp 2--after |_retaddr_dummy__|<- gr1 after | |
557 | | | struct ret | | PUSH_DUMMY_FRAME | |
558 | | margs17+ | area allocated | locals_inf | | |
559 | | | |________________| called | |
560 | |____________|<- msp 4--when | | function's | |
561 | | | inf called | args_out_inf | frame (set up | |
562 | | margs16 | |________________| by called | |
563 | | (16 words) | |_____lr1_inf____| function). | |
564 | |____________|<- msp 3--after | . | | |
565 | | | args pushed | . | | |
566 | | | | . | | |
567 | | | | |
568 | ||
569 | arg_slop: This area is so that when the call dummy adds 16 words to | |
570 | the msp, it won't end up larger than mfp_dummy (it is needed in the | |
571 | case where margs and struct_ret do not add up to at least 16 words). | |
572 | struct ret: This area is allocated by GDB if the return value is more | |
d7d35f00 | 573 | than 16 words. struct ret_16 is not used on the a29k. |
5076de82 FF |
574 | margs: Pushed by GDB. The call dummy copies the first 16 words to |
575 | args_out_dummy. | |
576 | retaddr_sproc: Contains the PC at the time we call the function. | |
577 | set by PUSH_DUMMY_FRAME and read by POP_FRAME. | |
578 | retaddr_dummy: This points to a breakpoint instruction in the dummy. */ | |
579 | \f | |
580 | /* Rsize for dummy frame, in bytes. */ | |
581 | ||
582 | /* Bytes for outgoing args, lr1, and retaddr. */ | |
583 | #define DUMMY_ARG (2 * 4 + 16 * 4) | |
584 | ||
585 | /* Number of special registers (sr128-) to save. */ | |
586 | #define DUMMY_SAVE_SR128 8 | |
587 | /* Number of special registers (sr160-) to save. */ | |
588 | #define DUMMY_SAVE_SR160 3 | |
589 | /* Number of general (gr96- or gr64-) registers to save. */ | |
590 | #define DUMMY_SAVE_GREGS 29 | |
591 | ||
592 | #define DUMMY_FRAME_RSIZE \ | |
593 | (4 /* mfp_dummy */ \ | |
594 | + 2 * 4 /* pc0, pc1 */ \ | |
595 | + DUMMY_SAVE_GREGS * 4 \ | |
596 | + DUMMY_SAVE_SR160 * 4 \ | |
597 | + DUMMY_SAVE_SR128 * 4 \ | |
598 | + DUMMY_ARG \ | |
599 | + 4 /* pad to doubleword */ ) | |
600 | ||
601 | /* Push an empty stack frame, to record the current PC, etc. */ | |
602 | ||
603 | #define PUSH_DUMMY_FRAME push_dummy_frame() | |
604 | extern void push_dummy_frame (); | |
605 | ||
606 | /* Discard from the stack the innermost frame, | |
607 | restoring all saved registers. */ | |
608 | ||
609 | #define POP_FRAME pop_frame() | |
610 | extern void pop_frame (); | |
611 | ||
612 | /* This sequence of words is the instructions | |
613 | mtsrim cr, 15 | |
614 | loadm 0, 0, lr2, msp ; load first 16 words of arguments into registers | |
615 | add msp, msp, 16 * 4 ; point to the remaining arguments | |
616 | CONST_INSN: | |
617 | const lr0,inf ; (replaced by half of target addr) | |
618 | consth lr0,inf ; (replaced by other half of target addr) | |
619 | calli lr0, lr0 | |
620 | aseq 0x40,gr1,gr1 ; nop | |
621 | BREAKPT_INSN: | |
622 | asneq 0x50,gr1,gr1 ; breakpoint (replaced by local breakpoint insn) | |
623 | */ | |
624 | ||
625 | #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER | |
626 | #define BS(const) const | |
627 | #else | |
628 | #define BS(const) (((const) & 0xff) << 24) | \ | |
629 | (((const) & 0xff00) << 8) | \ | |
630 | (((const) & 0xff0000) >> 8) | \ | |
631 | (((const) & 0xff000000) >> 24) | |
632 | #endif | |
633 | ||
634 | /* Position of the "const" and blkt instructions within CALL_DUMMY in bytes. */ | |
635 | #define CONST_INSN (3 * 4) | |
636 | #define BREAKPT_INSN (7 * 4) | |
637 | #define CALL_DUMMY { \ | |
638 | BS(0x0400870f),\ | |
639 | BS(0x36008200|(MSP_HW_REGNUM)), \ | |
640 | BS(0x15000040|(MSP_HW_REGNUM<<8)|(MSP_HW_REGNUM<<16)), \ | |
641 | BS(0x03ff80ff), \ | |
642 | BS(0x02ff80ff), \ | |
643 | BS(0xc8008080), \ | |
644 | BS(0x70400101), \ | |
645 | BS(0x72500101)} | |
646 | #define CALL_DUMMY_LENGTH (8 * 4) | |
647 | ||
648 | #define CALL_DUMMY_START_OFFSET 0 /* Start execution at beginning of dummy */ | |
649 | ||
650 | /* Helper macro for FIX_CALL_DUMMY. WORDP is a long * which points to a | |
651 | word in target byte order; bits 0-7 and 16-23 of *WORDP are replaced with | |
652 | bits 0-7 and 8-15 of DATA (which is in host byte order). */ | |
653 | ||
654 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
655 | #define STUFF_I16(WORDP, DATA) \ | |
656 | { \ | |
657 | *((char *)(WORDP) + 3) = ((DATA) & 0xff);\ | |
658 | *((char *)(WORDP) + 1) = (((DATA) >> 8) & 0xff);\ | |
659 | } | |
660 | #else /* Target is little endian. */ | |
661 | #define STUFF_I16(WORDP, DATA) \ | |
662 | { | |
663 | *(char *)(WORDP) = ((DATA) & 0xff); | |
664 | *((char *)(WORDP) + 2) = (((DATA) >> 8) & 0xff); | |
665 | } | |
666 | #endif /* Target is little endian. */ | |
667 | ||
668 | /* Insert the specified number of args and function address | |
669 | into a call sequence of the above form stored at DUMMYNAME. */ | |
670 | ||
671 | /* Currently this stuffs in the address of the function that we are calling. | |
d7d35f00 | 672 | Since different a29k systems use different breakpoint instructions, it |
5076de82 FF |
673 | also stuffs BREAKPOINT in the right place (to avoid having to |
674 | duplicate CALL_DUMMY in each tm-*.h file). */ | |
675 | ||
676 | #define FIX_CALL_DUMMY(dummyname, pc, fun, nargs, args, type, gcc_p) \ | |
677 | {\ | |
678 | STUFF_I16((char *)dummyname + CONST_INSN, fun); \ | |
679 | STUFF_I16((char *)dummyname + CONST_INSN + 4, fun >> 16); \ | |
680 | /* FIXME memcpy ((char *)(dummyname) + BREAKPT_INSN, break_insn, 4); */ \ | |
681 | } | |
682 | ||
d7d35f00 | 683 | /* a29k architecture has separate data & instruction memories -- wired to |
5076de82 FF |
684 | different pins on the chip -- and can't execute the data memory. |
685 | Also, there should be space after text_end; | |
686 | we won't get a SIGSEGV or scribble on data space. */ | |
687 | ||
688 | #define CALL_DUMMY_LOCATION AFTER_TEXT_END | |
689 | ||
690 | /* Because of this, we need (as a kludge) to know the addresses of the | |
691 | text section. */ | |
692 | ||
693 | #define NEED_TEXT_START_END | |
694 | ||
695 | /* How to translate register numbers in the .stab's into gdb's internal register | |
696 | numbers. We don't translate them, but we warn if an invalid register | |
697 | number is seen. Note that FIXME, we use the value "sym" as an implicit | |
698 | argument in printing the error message. It happens to be available where | |
699 | this macro is used. (This macro definition appeared in a late revision | |
700 | of gdb-3.91.6 and is not well tested. Also, it should be a "complaint".) */ | |
701 | ||
702 | #define STAB_REG_TO_REGNUM(num) \ | |
703 | (((num) > LR0_REGNUM + 127) \ | |
704 | ? fprintf(stderr, \ | |
705 | "Invalid register number %d in symbol table entry for %s\n", \ | |
706 | (num), SYMBOL_SOURCE_NAME (sym)), (num) \ | |
707 | : (num)) | |
ca0622e7 JK |
708 | |
709 | extern enum a29k_processor_types { | |
710 | a29k_unknown, | |
711 | ||
712 | /* Bit 0x400 of the CPS does *not* identify freeze mode, i.e. 29000, | |
713 | 29030, etc. */ | |
714 | a29k_no_freeze_mode, | |
715 | ||
716 | /* Bit 0x400 of the CPS does identify freeze mode, i.e. 29050. */ | |
717 | a29k_freeze_mode | |
718 | } processor_type; |