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