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