1 |
227 |
jeremybenn |
/* Target-dependent code for the 32-bit OpenRISC 1000, for the GNU Debugger.
|
2 |
|
|
|
3 |
|
|
Copyright 1988-2008, Free Software Foundation, Inc.
|
4 |
|
|
Copyright (C) 2008, 2010 Embecosm Limited
|
5 |
|
|
|
6 |
|
|
Contributed by Alessandro Forin(af@cs.cmu.edu at CMU
|
7 |
|
|
and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
|
8 |
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
9 |
|
|
|
10 |
|
|
This file is part of GDB.
|
11 |
|
|
|
12 |
|
|
This program is free software; you can redistribute it and/or modify it
|
13 |
|
|
under the terms of the GNU General Public License as published by the Free
|
14 |
|
|
Software Foundation; either version 3 of the License, or (at your option)
|
15 |
|
|
any later version.
|
16 |
|
|
|
17 |
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
18 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
20 |
|
|
more details.
|
21 |
|
|
|
22 |
|
|
You should have received a copy of the GNU General Public License along
|
23 |
|
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
24 |
|
|
|
25 |
|
|
/*-----------------------------------------------------------------------------
|
26 |
|
|
This version for the OpenRISC 1000 architecture is a rewrite by Jeremy
|
27 |
|
|
Bennett of the old GDB 5.3 interface to make use of gdbarch for GDB 6.8.
|
28 |
|
|
|
29 |
|
|
The code tries to follow the GDB coding style.
|
30 |
|
|
|
31 |
|
|
Commenting is Doxygen compatible.
|
32 |
|
|
|
33 |
|
|
Much has been stripped out in the interests of getting a basic working
|
34 |
|
|
system. This is described as the OpenRISC 1000 target architecture, so
|
35 |
|
|
should work with 16, 32 and 64 bit versions of that architecture and should
|
36 |
|
|
work whether or not they have floating point and/or vector registers.
|
37 |
|
|
|
38 |
|
|
There was never a capability to run simulator commands (no remote target
|
39 |
|
|
implemented the required function), so that has been removed.
|
40 |
|
|
|
41 |
|
|
The info trace command has been removed. The meaning of this is not clear -
|
42 |
|
|
it relies on a value in register 255 of the debug group, which is
|
43 |
|
|
undocumented.
|
44 |
|
|
|
45 |
|
|
All the hardware trace has been removed for the time being. The new debug
|
46 |
|
|
interface does not support hardware trace, so there is no plan to reinstate
|
47 |
|
|
this functionality.
|
48 |
|
|
|
49 |
|
|
Support for multiple contexts (which was rudimentary, and not working) has
|
50 |
|
|
been removed. */
|
51 |
|
|
/*---------------------------------------------------------------------------*/
|
52 |
|
|
|
53 |
|
|
#include "demangle.h"
|
54 |
|
|
#include "defs.h"
|
55 |
|
|
#include "gdb_string.h"
|
56 |
|
|
#include "frame.h"
|
57 |
|
|
#include "inferior.h"
|
58 |
|
|
#include "symtab.h"
|
59 |
|
|
#include "value.h"
|
60 |
|
|
#include "gdbcmd.h"
|
61 |
|
|
#include "language.h"
|
62 |
|
|
#include "gdbcore.h"
|
63 |
|
|
#include "symfile.h"
|
64 |
|
|
#include "objfiles.h"
|
65 |
|
|
#include "gdbtypes.h"
|
66 |
|
|
#include "target.h"
|
67 |
|
|
#include "regcache.h"
|
68 |
|
|
|
69 |
|
|
#include "opcode/or32.h"
|
70 |
|
|
#include "or32-tdep.h"
|
71 |
|
|
|
72 |
|
|
#include "safe-ctype.h"
|
73 |
|
|
#include "block.h"
|
74 |
|
|
#include "reggroups.h"
|
75 |
|
|
#include "arch-utils.h"
|
76 |
|
|
#include "frame.h"
|
77 |
|
|
#include "frame-unwind.h"
|
78 |
|
|
#include "frame-base.h"
|
79 |
|
|
#include "dwarf2-frame.h"
|
80 |
|
|
#include "trad-frame.h"
|
81 |
|
|
|
82 |
|
|
#include <inttypes.h>
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
/* Support functions for the architecture definition */
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/*----------------------------------------------------------------------------*/
|
91 |
|
|
/*!Get an instruction
|
92 |
|
|
|
93 |
|
|
This reads from memory. The old version relied on the frame, this relies
|
94 |
|
|
just on the architecture. The old version also guaranteed not to get a
|
95 |
|
|
software breakpoint if one had been set. However that seems to happen just
|
96 |
|
|
before execution and is removed immediately after, so we believe should not
|
97 |
|
|
happen. The old function from GDB 6.8 to do this has been deleted.
|
98 |
|
|
|
99 |
|
|
@param[in] gdbarch Architecture for which we are getting the instruction.
|
100 |
|
|
@param[in] addr Address from which to get the instruction
|
101 |
|
|
|
102 |
|
|
@return The instruction */
|
103 |
|
|
/*---------------------------------------------------------------------------*/
|
104 |
|
|
|
105 |
|
|
static ULONGEST
|
106 |
|
|
or32_fetch_instruction (struct gdbarch *gdbarch,
|
107 |
|
|
CORE_ADDR addr)
|
108 |
|
|
{
|
109 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
110 |
|
|
char buf[OR32_INSTLEN];
|
111 |
|
|
int status;
|
112 |
|
|
|
113 |
|
|
status = target_read_memory (addr, buf, OR32_INSTLEN);
|
114 |
|
|
|
115 |
|
|
if (status)
|
116 |
|
|
{
|
117 |
|
|
memory_error (status, addr);
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
return extract_unsigned_integer (buf, OR32_INSTLEN, byte_order);
|
121 |
|
|
|
122 |
|
|
} /* or32_fetch_instruction() */
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
/*---------------------------------------------------------------------------*/
|
126 |
|
|
/*!Generic function to read bits from an instruction
|
127 |
|
|
|
128 |
|
|
printf style. Basic syntax
|
129 |
|
|
|
130 |
|
|
or32_analyse_inst (inst, format, &arg1, &arg2 ...)
|
131 |
|
|
|
132 |
|
|
Format string can contain the following characters:
|
133 |
|
|
|
134 |
|
|
- SPACE: Ignored, just for layout
|
135 |
|
|
- 0: Match with a zero bit
|
136 |
|
|
- 1: Match with a one bit
|
137 |
|
|
- %<n>b: Match <n> bits to the next argument (n decimal)
|
138 |
|
|
|
139 |
|
|
If the arg corresponding to a bit field is non-null, the value will be
|
140 |
|
|
assigned to that argument (using NULL allows fields to be skipped).
|
141 |
|
|
|
142 |
|
|
Any bad string will cause a fatal error. These are constant strings, so
|
143 |
|
|
should be correct.
|
144 |
|
|
|
145 |
|
|
The bit field must be 32 bits long. A failure here will cause a fatal error
|
146 |
|
|
for the same reason.
|
147 |
|
|
|
148 |
|
|
@note The format string is presented MS field to LS field, left to
|
149 |
|
|
right. This means that it is read lowest numbered char first.
|
150 |
|
|
|
151 |
|
|
@note Some of the arg fields may be populated, even if recognition
|
152 |
|
|
ultimately fails.
|
153 |
|
|
|
154 |
|
|
@param[in] inst The instruction to analyse
|
155 |
|
|
@param[in] format The format string
|
156 |
|
|
@param[out] ... Argument fields
|
157 |
|
|
|
158 |
|
|
@return 1 (TRUE) if the instruction matches, 0 (FALSE) otherwise. */
|
159 |
|
|
/*---------------------------------------------------------------------------*/
|
160 |
|
|
static int
|
161 |
|
|
or32_analyse_inst (uint32_t inst,
|
162 |
|
|
const char *format,
|
163 |
|
|
...)
|
164 |
|
|
{
|
165 |
|
|
/* Break out each field in turn, validating as we go. */
|
166 |
|
|
va_list ap;
|
167 |
|
|
|
168 |
|
|
int i;
|
169 |
|
|
int iptr = 0; /* Instruction pointer */
|
170 |
|
|
|
171 |
|
|
va_start (ap, format);
|
172 |
|
|
|
173 |
|
|
for (i = 0; 0 != format[i];)
|
174 |
|
|
{
|
175 |
|
|
const char *start_ptr;
|
176 |
|
|
char *end_ptr;
|
177 |
|
|
|
178 |
|
|
uint32_t bits; /* Bit substring of interest */
|
179 |
|
|
uint32_t width; /* Substring width */
|
180 |
|
|
uint32_t *arg_ptr;
|
181 |
|
|
|
182 |
|
|
switch (format[i])
|
183 |
|
|
{
|
184 |
|
|
case ' ': i++; break; /* Formatting: ignored */
|
185 |
|
|
|
186 |
|
|
case '0': case '1': /* Constant bit field */
|
187 |
|
|
bits = (inst >> (OR32_INSTBITLEN - iptr - 1)) & 0x1;
|
188 |
|
|
|
189 |
|
|
if ((format[i] - '0') != bits)
|
190 |
|
|
{
|
191 |
|
|
return 0;
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
iptr++;
|
195 |
|
|
i++;
|
196 |
|
|
break;
|
197 |
|
|
|
198 |
|
|
case '%': /* Bit field */
|
199 |
|
|
i++;
|
200 |
|
|
start_ptr = &(format[i]);
|
201 |
|
|
width = strtoul (start_ptr, &end_ptr, 10);
|
202 |
|
|
|
203 |
|
|
/* Check we got something, and if so skip on */
|
204 |
|
|
if (start_ptr == end_ptr)
|
205 |
|
|
{
|
206 |
|
|
fatal ("bitstring \"%s\" at offset %d has no length field.\n",
|
207 |
|
|
format, i);
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
i += end_ptr - start_ptr;
|
211 |
|
|
|
212 |
|
|
/* Look for and skip the terminating 'b'. If it's not there, we
|
213 |
|
|
still give a fatal error, because these are fixed strings that
|
214 |
|
|
just should not be wrong. */
|
215 |
|
|
if ('b' != format[i++])
|
216 |
|
|
{
|
217 |
|
|
fatal ("bitstring \"%s\" at offset %d has no terminating 'b'.\n",
|
218 |
|
|
format, i);
|
219 |
|
|
}
|
220 |
|
|
|
221 |
|
|
/* Break out the field. There is a special case with a bit width of
|
222 |
|
|
32. */
|
223 |
|
|
if (32 == width)
|
224 |
|
|
{
|
225 |
|
|
bits = inst;
|
226 |
|
|
}
|
227 |
|
|
else
|
228 |
|
|
{
|
229 |
|
|
bits = (inst >> (OR32_INSTBITLEN - iptr - width)) & ((1 << width) - 1);
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
arg_ptr = va_arg (ap, uint32_t *);
|
233 |
|
|
*arg_ptr = bits;
|
234 |
|
|
iptr += width;
|
235 |
|
|
break;
|
236 |
|
|
|
237 |
|
|
default:
|
238 |
|
|
fatal ("invalid character in bitstring \"%s\" at offset %d.\n",
|
239 |
|
|
format, i);
|
240 |
|
|
break;
|
241 |
|
|
}
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
/* Is the length OK? */
|
245 |
|
|
gdb_assert (OR32_INSTBITLEN == iptr);
|
246 |
|
|
|
247 |
|
|
return 1; /* We succeeded */
|
248 |
|
|
|
249 |
|
|
} /* or32_analyse_inst () */
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
/*---------------------------------------------------------------------------*/
|
253 |
|
|
/*!Analyse a l.addi instruction
|
254 |
|
|
|
255 |
|
|
General form is:
|
256 |
|
|
|
257 |
|
|
l.addi rD,rA,I
|
258 |
|
|
|
259 |
|
|
Makes use of the generic analysis function (@see or32_analyse_inst ()).
|
260 |
|
|
|
261 |
|
|
@param[in] inst The instruction to analyse.
|
262 |
|
|
@param[out] rd_ptr Pointer to the rD value.
|
263 |
|
|
@param[out] ra_ptr Pointer to the rA value.
|
264 |
|
|
@param[out] simm_ptr Pointer to the signed immediate value.
|
265 |
|
|
|
266 |
|
|
@return 1 (TRUE) if the instruction matches, 0 (FALSE) otherwise. */
|
267 |
|
|
/*---------------------------------------------------------------------------*/
|
268 |
|
|
static int
|
269 |
|
|
or32_analyse_l_addi (uint32_t inst,
|
270 |
|
|
unsigned int *rd_ptr,
|
271 |
|
|
unsigned int *ra_ptr,
|
272 |
|
|
int *simm_ptr)
|
273 |
|
|
{
|
274 |
|
|
/* Instruction fields */
|
275 |
|
|
uint32_t rd, ra, i;
|
276 |
|
|
|
277 |
|
|
if (or32_analyse_inst (inst, "10 0111 %5b %5b %16b", &rd, &ra, &i))
|
278 |
|
|
{
|
279 |
|
|
/* Found it. Construct the result fields */
|
280 |
|
|
*rd_ptr = (unsigned int) rd;
|
281 |
|
|
*ra_ptr = (unsigned int) ra;
|
282 |
|
|
*simm_ptr = (int) (((i & 0x8000) == 0x8000) ? 0xffff0000 | i : i);
|
283 |
|
|
|
284 |
|
|
return 1; /* Success */
|
285 |
|
|
}
|
286 |
|
|
else
|
287 |
|
|
{
|
288 |
|
|
return 0; /* Failure */
|
289 |
|
|
}
|
290 |
|
|
} /* or32_analyse_l_addi () */
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
/*---------------------------------------------------------------------------*/
|
294 |
|
|
/*!Analyse a l.sw instruction
|
295 |
|
|
|
296 |
|
|
General form is:
|
297 |
|
|
|
298 |
|
|
l.sw I(rA),rB
|
299 |
|
|
|
300 |
|
|
Makes use of the generic analysis function (@see or32_analyse_inst ()).
|
301 |
|
|
|
302 |
|
|
@param[in] inst The instruction to analyse.
|
303 |
|
|
@param[out] simm_ptr Pointer to the signed immediate value.
|
304 |
|
|
@param[out] ra_ptr Pointer to the rA value.
|
305 |
|
|
@param[out] rb_ptr Pointer to the rB value.
|
306 |
|
|
|
307 |
|
|
@return 1 (TRUE) if the instruction matches, 0 (FALSE) otherwise. */
|
308 |
|
|
/*---------------------------------------------------------------------------*/
|
309 |
|
|
static int
|
310 |
|
|
or32_analyse_l_sw (uint32_t inst,
|
311 |
|
|
int *simm_ptr,
|
312 |
|
|
unsigned int *ra_ptr,
|
313 |
|
|
unsigned int *rb_ptr)
|
314 |
|
|
{
|
315 |
|
|
/* Instruction fields */
|
316 |
|
|
uint32_t ihi, ilo, ra, rb;
|
317 |
|
|
|
318 |
|
|
if (or32_analyse_inst (inst, "11 0101 %5b %5b %5b %11b", &ihi, &ra, &rb,
|
319 |
|
|
&ilo))
|
320 |
|
|
|
321 |
|
|
{
|
322 |
|
|
/* Found it. Construct the result fields */
|
323 |
|
|
*simm_ptr = (int) ((ihi << 11) | ilo);
|
324 |
|
|
*simm_ptr |= ((ihi & 0x10) == 0x10) ? 0xffff0000 : 0;
|
325 |
|
|
|
326 |
|
|
*ra_ptr = (unsigned int) ra;
|
327 |
|
|
*rb_ptr = (unsigned int) rb;
|
328 |
|
|
|
329 |
|
|
return 1; /* Success */
|
330 |
|
|
}
|
331 |
|
|
else
|
332 |
|
|
{
|
333 |
|
|
return 0; /* Failure */
|
334 |
|
|
}
|
335 |
|
|
} /* or32_analyse_l_sw () */
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
/* Functions defining the architecture */
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
/*----------------------------------------------------------------------------*/
|
344 |
|
|
/*!Determine the return convention used for a given type
|
345 |
|
|
|
346 |
|
|
Optionally, fetch or set the return value via "readbuf" or "writebuf"
|
347 |
|
|
respectively using "regcache" for the register values.
|
348 |
|
|
|
349 |
|
|
The OpenRISC 1000 returns scalar values via R11 and (for 64 bit values on
|
350 |
|
|
32 bit architectures) R12. Structs and unions are returned by reference,
|
351 |
|
|
with the address in R11
|
352 |
|
|
|
353 |
|
|
The result returned is independent of the function type, so we ignore that.
|
354 |
|
|
|
355 |
|
|
Throughout use read_memory(), not target_read_memory(), since the address
|
356 |
|
|
may be invalid and we want an error reported (read_memory() is
|
357 |
|
|
target_read_memory() with error reporting).
|
358 |
|
|
|
359 |
|
|
@todo This implementation is labelled OR32, but in fact is just for the 32
|
360 |
|
|
bit version, OR32. This should be made explicit
|
361 |
|
|
|
362 |
|
|
@param[in] gdbarch The GDB architecture being used
|
363 |
|
|
@param[in] functype The type of the function to be called (may be NULL)
|
364 |
|
|
@param[in] valtype The type of the entity to be returned
|
365 |
|
|
@param[in] regcache The register cache
|
366 |
|
|
@param[in] readbuf Buffer into which the return value should be written
|
367 |
|
|
@param[out] writebuf Buffer from which the return value should be written
|
368 |
|
|
|
369 |
|
|
@return The type of return value */
|
370 |
|
|
/*---------------------------------------------------------------------------*/
|
371 |
|
|
|
372 |
|
|
static enum return_value_convention
|
373 |
|
|
or32_return_value (struct gdbarch *gdbarch,
|
374 |
|
|
struct type *functype,
|
375 |
|
|
struct type *valtype,
|
376 |
|
|
struct regcache *regcache,
|
377 |
|
|
gdb_byte *readbuf,
|
378 |
|
|
const gdb_byte *writebuf)
|
379 |
|
|
{
|
380 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
381 |
|
|
enum type_code rv_type = TYPE_CODE (valtype);
|
382 |
|
|
unsigned int rv_size = TYPE_LENGTH (valtype);
|
383 |
|
|
ULONGEST tmp;
|
384 |
|
|
|
385 |
|
|
/* Deal with struct/union and large scalars first. Large (> 4 byte) scalars
|
386 |
|
|
are returned via a pointer (despite what is says in the architecture
|
387 |
|
|
document). Result pointed to by R11 */
|
388 |
|
|
|
389 |
|
|
if((TYPE_CODE_STRUCT == rv_type) ||
|
390 |
|
|
(TYPE_CODE_UNION == rv_type) ||
|
391 |
|
|
(rv_size > 4))
|
392 |
|
|
{
|
393 |
|
|
if (readbuf)
|
394 |
|
|
{
|
395 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_RV_REGNUM, &tmp);
|
396 |
|
|
read_memory (tmp, readbuf, rv_size);
|
397 |
|
|
}
|
398 |
|
|
if (writebuf)
|
399 |
|
|
{
|
400 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_RV_REGNUM, &tmp);
|
401 |
|
|
write_memory (tmp, writebuf, rv_size);
|
402 |
|
|
}
|
403 |
|
|
|
404 |
|
|
return RETURN_VALUE_ABI_RETURNS_ADDRESS;
|
405 |
|
|
}
|
406 |
|
|
|
407 |
|
|
/* 1-4 byte scalars are returned in R11 */
|
408 |
|
|
|
409 |
|
|
if (readbuf)
|
410 |
|
|
{
|
411 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_RV_REGNUM, &tmp);
|
412 |
|
|
store_unsigned_integer (readbuf, rv_size, byte_order, tmp);
|
413 |
|
|
}
|
414 |
|
|
if (writebuf)
|
415 |
|
|
{
|
416 |
|
|
gdb_byte buf[4];
|
417 |
|
|
memset (buf, 0, sizeof (buf)); /* Pad with zeros if < 4 bytes */
|
418 |
|
|
|
419 |
|
|
if (BFD_ENDIAN_BIG == byte_order)
|
420 |
|
|
{
|
421 |
|
|
memcpy (buf + sizeof (buf) - rv_size, writebuf, rv_size);
|
422 |
|
|
}
|
423 |
|
|
else
|
424 |
|
|
{
|
425 |
|
|
memcpy (buf, writebuf, rv_size);
|
426 |
|
|
}
|
427 |
|
|
|
428 |
|
|
regcache_cooked_write (regcache, OR32_RV_REGNUM, buf);
|
429 |
|
|
}
|
430 |
|
|
|
431 |
|
|
return RETURN_VALUE_REGISTER_CONVENTION;
|
432 |
|
|
|
433 |
|
|
} /* or32_return_value() */
|
434 |
|
|
|
435 |
|
|
|
436 |
|
|
/*----------------------------------------------------------------------------*/
|
437 |
|
|
/*!Determine the instruction to use for a breakpoint.
|
438 |
|
|
|
439 |
|
|
Given the address at which to insert a breakpoint (bp_addr), what will
|
440 |
|
|
that breakpoint be?
|
441 |
|
|
|
442 |
|
|
For or32, we have a breakpoint instruction. Since all or32 instructions
|
443 |
|
|
are 32 bits, this is all we need, regardless of address.
|
444 |
|
|
|
445 |
|
|
@param[in] gdbarch The GDB architecture being used
|
446 |
|
|
@param[in] bp_addr The breakpoint address in question
|
447 |
|
|
@param[out] bp_size The size of instruction selected
|
448 |
|
|
|
449 |
|
|
@return The chosen breakpoint instruction */
|
450 |
|
|
/*---------------------------------------------------------------------------*/
|
451 |
|
|
|
452 |
|
|
static const gdb_byte *
|
453 |
|
|
or32_breakpoint_from_pc (struct gdbarch *gdbarch,
|
454 |
|
|
CORE_ADDR *bp_addr,
|
455 |
|
|
int *bp_size)
|
456 |
|
|
{
|
457 |
|
|
static const gdb_byte breakpoint[] = OR32_BRK_INSTR_STRUCT;
|
458 |
|
|
|
459 |
|
|
*bp_size = OR32_INSTLEN;
|
460 |
|
|
return breakpoint;
|
461 |
|
|
|
462 |
|
|
} /* or32_breakpoint_from_pc() */
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
/*----------------------------------------------------------------------------*/
|
466 |
|
|
/*!Determine if we are executing a delay slot
|
467 |
|
|
|
468 |
|
|
Looks at the instruction at the previous instruction to see if it was one
|
469 |
|
|
with a delay slot. But it also has to be the address prior to NPC, because
|
470 |
|
|
we may have just taken an exception.
|
471 |
|
|
|
472 |
|
|
@param[in] gdbarch The GDB architecture being used
|
473 |
|
|
@param[in] this_frame Information about THIS frame
|
474 |
|
|
|
475 |
|
|
@return 1 (true) if this instruction is executing a delay slot, 0 (false)
|
476 |
|
|
otherwise. */
|
477 |
|
|
/*--------------------------------------------------------------------------*/
|
478 |
|
|
|
479 |
|
|
static int
|
480 |
|
|
or32_single_step_through_delay( struct gdbarch *gdbarch,
|
481 |
|
|
struct frame_info *this_frame )
|
482 |
|
|
{
|
483 |
|
|
struct regcache *regcache = get_current_regcache ();
|
484 |
|
|
ULONGEST val;
|
485 |
|
|
CORE_ADDR ppc;
|
486 |
|
|
CORE_ADDR npc;
|
487 |
|
|
int index;
|
488 |
|
|
|
489 |
|
|
/* Get and the previous and current instruction addresses. If they are not
|
490 |
|
|
adjacent, we cannot be in a delay slot. */
|
491 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_PPC_REGNUM, &val);
|
492 |
|
|
ppc = (CORE_ADDR) val;
|
493 |
|
|
regcache_cooked_read_unsigned (regcache, OR32_NPC_REGNUM, &val);
|
494 |
|
|
npc = (CORE_ADDR) val;
|
495 |
|
|
|
496 |
|
|
if (0x4 != (npc - ppc))
|
497 |
|
|
{
|
498 |
|
|
return 0;
|
499 |
|
|
}
|
500 |
|
|
|
501 |
|
|
/* Decode the previous instruction to see if it was a branch or a jump, and
|
502 |
|
|
hence we are in a delay slot. */
|
503 |
|
|
index = insn_decode (or32_fetch_instruction (gdbarch, ppc));
|
504 |
|
|
return or32_opcodes[index].flags & OR32_IF_DELAY;
|
505 |
|
|
|
506 |
|
|
} /* or32_single_step_through_delay() */
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
/*----------------------------------------------------------------------------*/
|
510 |
|
|
/*!Read a pseudo register
|
511 |
|
|
|
512 |
|
|
Since we have no pseudo registers this is a null function for now.
|
513 |
|
|
|
514 |
|
|
@todo The floating point and vector registers ought to be done as
|
515 |
|
|
pseudo-registers.
|
516 |
|
|
|
517 |
|
|
@param[in] gdbarch The GDB architecture to consider
|
518 |
|
|
@param[in] regcache The cached register values as an array
|
519 |
|
|
@param[in] regnum The register to read
|
520 |
|
|
@param[out] buf A buffer to put the result in */
|
521 |
|
|
/*---------------------------------------------------------------------------*/
|
522 |
|
|
|
523 |
|
|
static void
|
524 |
|
|
or32_pseudo_register_read (struct gdbarch *gdbarch,
|
525 |
|
|
struct regcache *regcache,
|
526 |
|
|
int regnum,
|
527 |
|
|
gdb_byte *buf)
|
528 |
|
|
{
|
529 |
|
|
return;
|
530 |
|
|
|
531 |
|
|
} /* or32_pseudo_register_read() */
|
532 |
|
|
|
533 |
|
|
|
534 |
|
|
/*----------------------------------------------------------------------------*/
|
535 |
|
|
/*!Write a pseudo register
|
536 |
|
|
|
537 |
|
|
Since we have no pseudo registers this is a null function for now.
|
538 |
|
|
|
539 |
|
|
@todo The floating point and vector registers ought to be done as
|
540 |
|
|
pseudo-registers.
|
541 |
|
|
|
542 |
|
|
@param[in] gdbarch The GDB architecture to consider
|
543 |
|
|
@param[in] regcache The cached register values as an array
|
544 |
|
|
@param[in] regnum The register to read
|
545 |
|
|
@param[in] buf A buffer with the value to write */
|
546 |
|
|
/*---------------------------------------------------------------------------*/
|
547 |
|
|
|
548 |
|
|
static void
|
549 |
|
|
or32_pseudo_register_write (struct gdbarch *gdbarch,
|
550 |
|
|
struct regcache *regcache,
|
551 |
|
|
int regnum,
|
552 |
|
|
const gdb_byte *buf)
|
553 |
|
|
{
|
554 |
|
|
return;
|
555 |
|
|
|
556 |
|
|
} /* or32_pseudo_register_write() */
|
557 |
|
|
|
558 |
|
|
|
559 |
|
|
/*----------------------------------------------------------------------------*/
|
560 |
|
|
/*!Return the register name for the OpenRISC 1000 architecture
|
561 |
|
|
|
562 |
|
|
This version converted to ANSI C, made static and incorporates the static
|
563 |
|
|
table of register names (this is the only place it is referenced).
|
564 |
|
|
|
565 |
|
|
@todo The floating point and vector registers ought to be done as
|
566 |
|
|
pseudo-registers.
|
567 |
|
|
|
568 |
|
|
@param[in] gdbarch The GDB architecture being used
|
569 |
|
|
@param[in] regnum The register number
|
570 |
|
|
|
571 |
|
|
@return The textual name of the register */
|
572 |
|
|
/*---------------------------------------------------------------------------*/
|
573 |
|
|
|
574 |
|
|
static const char *
|
575 |
|
|
or32_register_name (struct gdbarch *gdbarch,
|
576 |
|
|
int regnum)
|
577 |
|
|
{
|
578 |
|
|
static char *or32_gdb_reg_names[OR32_TOTAL_NUM_REGS] =
|
579 |
|
|
{
|
580 |
|
|
/* general purpose registers */
|
581 |
244 |
jeremybenn |
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
582 |
|
|
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
583 |
|
|
"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
|
584 |
|
|
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
|
585 |
227 |
jeremybenn |
|
586 |
|
|
/* previous program counter, next program counter and status register */
|
587 |
|
|
"ppc", "npc", "sr"
|
588 |
|
|
|
589 |
|
|
/* Floating point and vector registers may appear as pseudo registers in
|
590 |
|
|
the future. */
|
591 |
|
|
};
|
592 |
|
|
|
593 |
|
|
return or32_gdb_reg_names[regnum];
|
594 |
|
|
|
595 |
|
|
} /* or32_register_name() */
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
/*----------------------------------------------------------------------------*/
|
599 |
|
|
/*!Identify the type of a register
|
600 |
|
|
|
601 |
|
|
@todo I don't fully understand exactly what this does, but I think this
|
602 |
|
|
makes sense!
|
603 |
|
|
|
604 |
|
|
@param[in] arch The GDB architecture to consider
|
605 |
|
|
@param[in] regnum The register to identify
|
606 |
|
|
|
607 |
|
|
@return The type of the register */
|
608 |
|
|
/*---------------------------------------------------------------------------*/
|
609 |
|
|
|
610 |
|
|
static struct type *
|
611 |
|
|
or32_register_type (struct gdbarch *arch,
|
612 |
|
|
int regnum)
|
613 |
|
|
{
|
614 |
|
|
static struct type *void_func_ptr = NULL;
|
615 |
|
|
static struct type *void_ptr = NULL;
|
616 |
|
|
|
617 |
|
|
/* Set up the static pointers once, the first time*/
|
618 |
|
|
if (NULL == void_func_ptr)
|
619 |
|
|
{
|
620 |
|
|
struct type *void_type = builtin_type (arch)->builtin_void;
|
621 |
|
|
|
622 |
|
|
void_ptr = lookup_pointer_type (void_type);
|
623 |
|
|
void_func_ptr = lookup_pointer_type (lookup_function_type (void_type));
|
624 |
|
|
}
|
625 |
|
|
|
626 |
|
|
if((regnum >= 0) && (regnum < OR32_TOTAL_NUM_REGS))
|
627 |
|
|
{
|
628 |
|
|
switch (regnum)
|
629 |
|
|
{
|
630 |
|
|
case OR32_PPC_REGNUM:
|
631 |
|
|
case OR32_NPC_REGNUM:
|
632 |
|
|
return void_func_ptr; /* Pointer to code */
|
633 |
|
|
|
634 |
|
|
case OR32_SP_REGNUM:
|
635 |
|
|
case OR32_FP_REGNUM:
|
636 |
|
|
return void_ptr; /* Pointer to data */
|
637 |
|
|
|
638 |
|
|
default:
|
639 |
|
|
return builtin_type (arch)->builtin_uint32; /* Data */
|
640 |
|
|
}
|
641 |
|
|
}
|
642 |
|
|
|
643 |
|
|
internal_error (__FILE__, __LINE__,
|
644 |
|
|
_("or32_register_type: illegal register number %d"), regnum);
|
645 |
|
|
|
646 |
|
|
} /* or32_register_type() */
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
/*----------------------------------------------------------------------------*/
|
650 |
|
|
/*!Handle the "info register" command
|
651 |
|
|
|
652 |
|
|
Print the identified register, unless it is -1, in which case print all
|
653 |
|
|
the registers. If all is 1 means all registers, otherwise only the core
|
654 |
|
|
GPRs.
|
655 |
|
|
|
656 |
|
|
@todo At present all registers are printed with the default method. Should
|
657 |
|
|
there be something special for FP registers?
|
658 |
|
|
|
659 |
|
|
@param[in] gdbarch The GDB architecture being used
|
660 |
|
|
@param[in] file File handle for use with any custom I/O
|
661 |
|
|
@param[in] frame Frame info for use with custom output
|
662 |
|
|
@param[in] regnum Register of interest, or -1 if all registers
|
663 |
|
|
@param[in] all 1 if all means all, 0 if all means just GPRs
|
664 |
|
|
|
665 |
|
|
@return The aligned stack frame address */
|
666 |
|
|
/*---------------------------------------------------------------------------*/
|
667 |
|
|
|
668 |
|
|
static void
|
669 |
|
|
or32_registers_info (struct gdbarch *gdbarch,
|
670 |
|
|
struct ui_file *file,
|
671 |
|
|
struct frame_info *frame,
|
672 |
|
|
int regnum,
|
673 |
|
|
int all)
|
674 |
|
|
{
|
675 |
|
|
if (-1 == regnum)
|
676 |
|
|
{
|
677 |
|
|
/* Do all (valid) registers */
|
678 |
|
|
unsigned int lim = all ? OR32_NUM_REGS : OR32_MAX_GPR_REGS;
|
679 |
|
|
|
680 |
|
|
for (regnum = 0; regnum < lim; regnum++) {
|
681 |
|
|
if ('\0' != *(or32_register_name (gdbarch, regnum)))
|
682 |
|
|
{
|
683 |
|
|
or32_registers_info (gdbarch, file, frame, regnum, all);
|
684 |
|
|
}
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
else
|
688 |
|
|
{
|
689 |
|
|
/* Do one specified register - if it is part of this architecture */
|
690 |
|
|
if ('\0' == *(or32_register_name (gdbarch, regnum)))
|
691 |
|
|
{
|
692 |
|
|
error ("Not a valid register for the current processor type");
|
693 |
|
|
}
|
694 |
|
|
else
|
695 |
|
|
{
|
696 |
|
|
default_print_registers_info (gdbarch, file, frame, regnum, all);
|
697 |
|
|
}
|
698 |
|
|
}
|
699 |
|
|
} /* or32_registers_info() */
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
/*----------------------------------------------------------------------------*/
|
703 |
|
|
/*!Identify if a register belongs to a specified group
|
704 |
|
|
|
705 |
|
|
Return true if the specified register is a member of the specified
|
706 |
|
|
register group.
|
707 |
|
|
|
708 |
|
|
These are the groups of registers that can be displayed via "info reg".
|
709 |
|
|
|
710 |
|
|
@todo The Vector and Floating Point registers ought to be displayed as
|
711 |
|
|
pseudo-registers.
|
712 |
|
|
|
713 |
|
|
@param[in] gdbarch The GDB architecture to consider
|
714 |
|
|
@param[in] regnum The register to consider
|
715 |
|
|
@param[in] group The group to consider
|
716 |
|
|
|
717 |
|
|
@return True (1) if regnum is a member of group */
|
718 |
|
|
/*---------------------------------------------------------------------------*/
|
719 |
|
|
|
720 |
|
|
static int
|
721 |
|
|
or32_register_reggroup_p (struct gdbarch *gdbarch,
|
722 |
|
|
int regnum,
|
723 |
|
|
struct reggroup *group)
|
724 |
|
|
{
|
725 |
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
726 |
|
|
|
727 |
|
|
/* All register group */
|
728 |
|
|
if (group == all_reggroup)
|
729 |
|
|
{
|
730 |
|
|
return ((regnum >= 0) &&
|
731 |
|
|
(regnum < OR32_TOTAL_NUM_REGS) &&
|
732 |
|
|
(or32_register_name (gdbarch, regnum)[0] != '\0'));
|
733 |
|
|
}
|
734 |
|
|
|
735 |
|
|
/* For now everything except the PC */
|
736 |
|
|
if (group == general_reggroup)
|
737 |
|
|
{
|
738 |
|
|
return ((regnum >= OR32_ZERO_REGNUM) &&
|
739 |
|
|
(regnum < tdep->num_gpr_regs) &&
|
740 |
|
|
(regnum != OR32_PPC_REGNUM) &&
|
741 |
|
|
(regnum != OR32_NPC_REGNUM));
|
742 |
|
|
}
|
743 |
|
|
|
744 |
|
|
if (group == float_reggroup)
|
745 |
|
|
{
|
746 |
|
|
return 0; /* No float regs. */
|
747 |
|
|
}
|
748 |
|
|
|
749 |
|
|
if (group == vector_reggroup)
|
750 |
|
|
{
|
751 |
|
|
return 0; /* No vector regs. */
|
752 |
|
|
}
|
753 |
|
|
|
754 |
|
|
/* For any that are not handled above. */
|
755 |
|
|
return default_register_reggroup_p (gdbarch, regnum, group);
|
756 |
|
|
|
757 |
|
|
} /* or32_register_reggroup_p() */
|
758 |
|
|
|
759 |
|
|
|
760 |
|
|
/*----------------------------------------------------------------------------*/
|
761 |
244 |
jeremybenn |
/*!Is this one of the registers used for passing arguments?
|
762 |
|
|
|
763 |
|
|
These are r3-r8 in the API.
|
764 |
|
|
|
765 |
|
|
@param[in] regnum The register to consider
|
766 |
|
|
|
767 |
|
|
@return Non-zero (TRUE) if it is an argument register, zero (FALSE)
|
768 |
|
|
otherwise. */
|
769 |
|
|
/*----------------------------------------------------------------------------*/
|
770 |
|
|
static int
|
771 |
|
|
or32_is_arg_reg (unsigned int regnum)
|
772 |
|
|
{
|
773 |
|
|
return (OR32_FIRST_ARG_REGNUM <= regnum) && (regnum <= OR32_LAST_ARG_REGNUM);
|
774 |
|
|
|
775 |
|
|
} /* or32_is_arg_reg () */
|
776 |
|
|
|
777 |
|
|
|
778 |
|
|
/*----------------------------------------------------------------------------*/
|
779 |
|
|
/*!Is this a callee saved register?
|
780 |
|
|
|
781 |
|
|
These are r10, r12, r14, r16, r18, r20, r22, r24, r26, r28 and r30 in the
|
782 |
|
|
API.
|
783 |
|
|
|
784 |
|
|
@param[in] regnum The register to consider
|
785 |
|
|
|
786 |
|
|
@return Non-zero (TRUE) if it is a callee saved register, zero (FALSE)
|
787 |
|
|
otherwise. */
|
788 |
|
|
/*----------------------------------------------------------------------------*/
|
789 |
|
|
static int
|
790 |
|
|
or32_is_callee_saved_reg (unsigned int regnum)
|
791 |
|
|
{
|
792 |
|
|
return (OR32_FIRST_SAVED_REGNUM <= regnum) && (0 == regnum % 2);
|
793 |
|
|
|
794 |
|
|
} /* or32_is_callee_saved_reg () */
|
795 |
|
|
|
796 |
|
|
|
797 |
|
|
/*----------------------------------------------------------------------------*/
|
798 |
227 |
jeremybenn |
/*!Skip a function prolog
|
799 |
|
|
|
800 |
|
|
If the input address, PC, is in a function prologue, return the address of
|
801 |
|
|
the end of the prologue, otherwise return the input address.
|
802 |
|
|
|
803 |
|
|
@see For details of the stack frame, see the function
|
804 |
244 |
jeremybenn |
or32_frame_cache().
|
805 |
227 |
jeremybenn |
|
806 |
244 |
jeremybenn |
@note The old version of this function used to use skip_prologue_using_sal
|
807 |
|
|
to skip the prologue without checking if it had actually worked. It
|
808 |
|
|
doesn't for STABS, so we had better check for a valid result.
|
809 |
|
|
|
810 |
227 |
jeremybenn |
This function reuses the helper functions from or32_frame_cache() to
|
811 |
|
|
locate the various parts of the prolog, any or all of which may be missing.
|
812 |
|
|
|
813 |
|
|
@param[in] gdbarch The GDB architecture being used
|
814 |
|
|
@param[in] pc Current program counter
|
815 |
|
|
|
816 |
|
|
@return The address of the end of the prolog if the PC is in a function
|
817 |
|
|
prologue, otherwise the input address. */
|
818 |
|
|
/*----------------------------------------------------------------------------*/
|
819 |
|
|
static CORE_ADDR
|
820 |
|
|
or32_skip_prologue (struct gdbarch *gdbarch,
|
821 |
|
|
CORE_ADDR pc)
|
822 |
|
|
{
|
823 |
|
|
CORE_ADDR addr;
|
824 |
|
|
uint32_t inst;
|
825 |
|
|
|
826 |
|
|
unsigned int ra, rb, rd; /* For instruction analysis */
|
827 |
|
|
int simm;
|
828 |
|
|
|
829 |
|
|
int frame_size = 0;
|
830 |
|
|
|
831 |
|
|
/* Try using SAL first if we have symbolic information available. */
|
832 |
244 |
jeremybenn |
/* if (find_pc_partial_function (pc, NULL, NULL, NULL)) */
|
833 |
|
|
/* { */
|
834 |
|
|
/* CORE_ADDR prologue_end = skip_prologue_using_sal( gdbarch, pc ); */
|
835 |
227 |
jeremybenn |
|
836 |
244 |
jeremybenn |
/* if (0 != prologue_end) */
|
837 |
|
|
/* { */
|
838 |
|
|
/* return (prologue_end > pc) ? prologue_end : pc; */
|
839 |
|
|
/* } */
|
840 |
|
|
/* } */
|
841 |
227 |
jeremybenn |
|
842 |
|
|
/* Look to see if we can find any of the standard prologue sequence. All
|
843 |
|
|
quite difficult, since any or all of it may be missing. So this is just a
|
844 |
|
|
best guess! */
|
845 |
|
|
addr = pc; /* Where we have got to */
|
846 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
847 |
|
|
|
848 |
|
|
/* Look for the new stack pointer being set up. */
|
849 |
|
|
if (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
850 |
|
|
(OR32_SP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
851 |
|
|
(simm < 0) && (0 == (simm % 4)))
|
852 |
|
|
{
|
853 |
|
|
frame_size = -simm;
|
854 |
|
|
addr += OR32_INSTLEN;
|
855 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
856 |
|
|
}
|
857 |
|
|
|
858 |
|
|
/* Look for the frame pointer being manipulated. */
|
859 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
860 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_FP_REGNUM == rb) &&
|
861 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
862 |
|
|
{
|
863 |
|
|
addr += OR32_INSTLEN;
|
864 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
865 |
|
|
|
866 |
|
|
gdb_assert (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
867 |
|
|
(OR32_FP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
868 |
|
|
(simm == frame_size));
|
869 |
|
|
|
870 |
|
|
addr += OR32_INSTLEN;
|
871 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
872 |
|
|
}
|
873 |
|
|
|
874 |
|
|
/* Look for the link register being saved */
|
875 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
876 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_LR_REGNUM == rb) &&
|
877 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
878 |
|
|
{
|
879 |
|
|
addr += OR32_INSTLEN;
|
880 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
881 |
|
|
}
|
882 |
|
|
|
883 |
244 |
jeremybenn |
/* Look for arguments or callee-saved register being saved. The register
|
884 |
|
|
must be one of the arguments (r3-r8) or the 10 callee saved registers
|
885 |
|
|
(r10, r12, r14, r16, r18, r20, r22, r24, r26, r28, r30). The base
|
886 |
|
|
register must be the FP (for the args) or the SP (for the callee_saved
|
887 |
|
|
registers). */
|
888 |
227 |
jeremybenn |
while (1)
|
889 |
|
|
{
|
890 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
891 |
244 |
jeremybenn |
(((OR32_FP_REGNUM == ra) && or32_is_arg_reg (rb)) ||
|
892 |
|
|
((OR32_SP_REGNUM == ra) && or32_is_callee_saved_reg (rb))) &&
|
893 |
|
|
(0 == (simm % 4)))
|
894 |
227 |
jeremybenn |
{
|
895 |
|
|
addr += OR32_INSTLEN;
|
896 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
897 |
|
|
}
|
898 |
|
|
else
|
899 |
|
|
{
|
900 |
|
|
/* Nothing else to look for. We have found the end of the prologue. */
|
901 |
|
|
return addr;
|
902 |
|
|
}
|
903 |
|
|
}
|
904 |
|
|
} /* or32_skip_prologue() */
|
905 |
|
|
|
906 |
|
|
|
907 |
|
|
/*----------------------------------------------------------------------------*/
|
908 |
|
|
/*!Align the stack frame
|
909 |
|
|
|
910 |
|
|
OpenRISC 1000 uses a falling stack frame, so this aligns down to the
|
911 |
|
|
nearest 8 bytes. Useful when we'be building a dummy frame.
|
912 |
|
|
|
913 |
|
|
@param[in] gdbarch The GDB architecture being used
|
914 |
|
|
@param[in] sp Current stack pointer
|
915 |
|
|
|
916 |
|
|
@return The aligned stack frame address */
|
917 |
|
|
/*---------------------------------------------------------------------------*/
|
918 |
|
|
|
919 |
|
|
static CORE_ADDR
|
920 |
|
|
or32_frame_align (struct gdbarch *gdbarch,
|
921 |
|
|
CORE_ADDR sp)
|
922 |
|
|
{
|
923 |
|
|
return align_down (sp, OR32_STACK_ALIGN);
|
924 |
|
|
|
925 |
|
|
} /* or32_frame_align() */
|
926 |
|
|
|
927 |
|
|
|
928 |
|
|
/*----------------------------------------------------------------------------*/
|
929 |
|
|
/*!Unwind the program counter from a stack frame
|
930 |
|
|
|
931 |
|
|
This just uses the built in frame unwinder
|
932 |
|
|
|
933 |
|
|
@param[in] gdbarch The GDB architecture being used
|
934 |
|
|
@param[in] next_frame Frame info for the NEXT frame
|
935 |
|
|
|
936 |
|
|
@return The program counter for THIS frame */
|
937 |
|
|
/*---------------------------------------------------------------------------*/
|
938 |
|
|
|
939 |
|
|
static CORE_ADDR
|
940 |
|
|
or32_unwind_pc (struct gdbarch *gdbarch,
|
941 |
|
|
struct frame_info *next_frame)
|
942 |
|
|
{
|
943 |
|
|
CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, OR32_NPC_REGNUM);
|
944 |
|
|
|
945 |
|
|
return pc;
|
946 |
|
|
|
947 |
|
|
} /* or32_unwind_pc() */
|
948 |
|
|
|
949 |
|
|
|
950 |
|
|
/*----------------------------------------------------------------------------*/
|
951 |
|
|
/*!Unwind the stack pointer from a stack frame
|
952 |
|
|
|
953 |
|
|
This just uses the built in frame unwinder
|
954 |
|
|
|
955 |
|
|
@param[in] gdbarch The GDB architecture being used
|
956 |
|
|
@param[in] next_frame Frame info for the NEXT frame
|
957 |
|
|
|
958 |
|
|
@return The stack pointer for THIS frame */
|
959 |
|
|
/*---------------------------------------------------------------------------*/
|
960 |
|
|
|
961 |
|
|
static CORE_ADDR
|
962 |
|
|
or32_unwind_sp (struct gdbarch *gdbarch,
|
963 |
|
|
struct frame_info *next_frame)
|
964 |
|
|
{
|
965 |
|
|
CORE_ADDR sp = frame_unwind_register_unsigned (next_frame, OR32_SP_REGNUM);
|
966 |
|
|
|
967 |
|
|
return sp;
|
968 |
|
|
|
969 |
|
|
} /* or32_unwind_sp() */
|
970 |
|
|
|
971 |
|
|
|
972 |
|
|
/*----------------------------------------------------------------------------*/
|
973 |
|
|
/*!Create a dummy stack frame
|
974 |
|
|
|
975 |
|
|
The arguments are placed in registers and/or pushed on the stack as per the
|
976 |
|
|
OR32 ABI.
|
977 |
|
|
|
978 |
|
|
@param[in] gdbarch The architecture to use
|
979 |
|
|
@param[in] function Pointer to the function that will be called
|
980 |
|
|
@param[in] regcache The register cache to use
|
981 |
|
|
@param[in] bp_addr Breakpoint address
|
982 |
|
|
@param[in] nargs Number of ags to push
|
983 |
|
|
@param[in] args The arguments
|
984 |
|
|
@param[in] sp The stack pointer
|
985 |
|
|
@param[in] struct_return True (1) if this returns a structure
|
986 |
|
|
@param[in] struct_addr Address for returning structures
|
987 |
|
|
|
988 |
|
|
@return The updated stack pointer */
|
989 |
|
|
/*---------------------------------------------------------------------------*/
|
990 |
|
|
|
991 |
|
|
static CORE_ADDR
|
992 |
|
|
or32_push_dummy_call (struct gdbarch *gdbarch,
|
993 |
|
|
struct value *function,
|
994 |
|
|
struct regcache *regcache,
|
995 |
|
|
CORE_ADDR bp_addr,
|
996 |
|
|
int nargs,
|
997 |
|
|
struct value **args,
|
998 |
|
|
CORE_ADDR sp,
|
999 |
|
|
int struct_return,
|
1000 |
|
|
CORE_ADDR struct_addr)
|
1001 |
|
|
{
|
1002 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
|
1003 |
|
|
|
1004 |
|
|
int argreg;
|
1005 |
|
|
int argnum;
|
1006 |
|
|
int first_stack_arg;
|
1007 |
|
|
int stack_offset = 0;
|
1008 |
|
|
|
1009 |
|
|
unsigned int bpa = (gdbarch_tdep (gdbarch))->bytes_per_address;
|
1010 |
|
|
unsigned int bpw = (gdbarch_tdep (gdbarch))->bytes_per_word;
|
1011 |
|
|
|
1012 |
|
|
/* Return address */
|
1013 |
|
|
regcache_cooked_write_unsigned (regcache, OR32_LR_REGNUM, bp_addr);
|
1014 |
|
|
|
1015 |
|
|
/* Register for the next argument */
|
1016 |
|
|
argreg = OR32_FIRST_ARG_REGNUM;
|
1017 |
|
|
|
1018 |
|
|
/* Location for a returned structure. This is passed as a silent first
|
1019 |
|
|
argument. */
|
1020 |
|
|
|
1021 |
|
|
if (struct_return)
|
1022 |
|
|
{
|
1023 |
|
|
regcache_cooked_write_unsigned (regcache, OR32_FIRST_ARG_REGNUM,
|
1024 |
|
|
struct_addr);
|
1025 |
|
|
argreg++;
|
1026 |
|
|
}
|
1027 |
|
|
|
1028 |
|
|
/* Put as many args as possible in registers */
|
1029 |
|
|
for (argnum = 0; argnum < nargs; argnum++)
|
1030 |
|
|
{
|
1031 |
|
|
char *val;
|
1032 |
|
|
char valbuf[sizeof (ULONGEST) ];
|
1033 |
|
|
|
1034 |
|
|
struct value *arg = args[argnum];
|
1035 |
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
1036 |
|
|
int len = arg_type->length;
|
1037 |
|
|
enum type_code typecode = arg_type->main_type->code;
|
1038 |
|
|
|
1039 |
|
|
/* The EABI passes structures that do not fit in a register by
|
1040 |
|
|
reference. In all other cases, pass the structure by value. */
|
1041 |
|
|
if((len > bpw) &&
|
1042 |
|
|
((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)))
|
1043 |
|
|
{
|
1044 |
|
|
|
1045 |
|
|
store_unsigned_integer (valbuf, bpa, byte_order, value_offset (arg));
|
1046 |
|
|
len = bpa;
|
1047 |
|
|
val = valbuf;
|
1048 |
|
|
}
|
1049 |
|
|
else
|
1050 |
|
|
{
|
1051 |
|
|
val = (char *)value_contents (arg);
|
1052 |
|
|
}
|
1053 |
|
|
|
1054 |
|
|
if((len > bpw) && (argreg <= (OR32_LAST_ARG_REGNUM - 1)))
|
1055 |
|
|
{
|
1056 |
|
|
|
1057 |
249 |
jeremybenn |
/* Big scalars use two registers, but need NOT be pair aligned. This
|
1058 |
|
|
code breaks if we can have quad-word scalars (e.g. long
|
1059 |
|
|
double). */
|
1060 |
227 |
jeremybenn |
ULONGEST regval = extract_unsigned_integer (val, len, byte_order);
|
1061 |
|
|
|
1062 |
249 |
jeremybenn |
unsigned int bits_per_word = bpw * 8;
|
1063 |
|
|
ULONGEST mask = (((ULONGEST) 1) << bits_per_word) - 1;
|
1064 |
|
|
ULONGEST lo = regval & mask;
|
1065 |
|
|
ULONGEST hi = regval >> bits_per_word;
|
1066 |
|
|
|
1067 |
227 |
jeremybenn |
gdb_assert (len <= (bpw * 2));
|
1068 |
|
|
|
1069 |
249 |
jeremybenn |
regcache_cooked_write_unsigned (regcache, argreg, hi);
|
1070 |
|
|
regcache_cooked_write_unsigned (regcache, argreg + 1, lo);
|
1071 |
227 |
jeremybenn |
argreg += 2;
|
1072 |
|
|
}
|
1073 |
|
|
else if (argreg <= OR32_LAST_ARG_REGNUM)
|
1074 |
|
|
{
|
1075 |
249 |
jeremybenn |
printf ("Writing 0x%08llx to r%d\n",
|
1076 |
|
|
extract_unsigned_integer (val, len, byte_order), argreg);
|
1077 |
|
|
|
1078 |
227 |
jeremybenn |
regcache_cooked_write_unsigned (regcache, argreg,
|
1079 |
|
|
extract_unsigned_integer (val, len,
|
1080 |
|
|
byte_order));
|
1081 |
|
|
argreg++;
|
1082 |
|
|
}
|
1083 |
|
|
else
|
1084 |
|
|
{
|
1085 |
|
|
/* Run out of regs */
|
1086 |
|
|
break;
|
1087 |
|
|
}
|
1088 |
|
|
}
|
1089 |
|
|
|
1090 |
|
|
first_stack_arg = argnum;
|
1091 |
|
|
|
1092 |
|
|
/* If we get here with argnum < nargs, then arguments remain to be placed on
|
1093 |
|
|
the stack. This is tricky, since they must be pushed in reverse order and
|
1094 |
|
|
the stack in the end must be aligned. The only solution is to do it in
|
1095 |
|
|
two stages, the first to compute the stack size, the second to save the
|
1096 |
|
|
args. */
|
1097 |
|
|
|
1098 |
|
|
for (argnum = first_stack_arg; argnum < nargs; argnum++)
|
1099 |
|
|
{
|
1100 |
|
|
struct value *arg = args[argnum];
|
1101 |
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
1102 |
|
|
int len = arg_type->length;
|
1103 |
|
|
enum type_code typecode = arg_type->main_type->code;
|
1104 |
|
|
|
1105 |
|
|
if((len > bpw) &&
|
1106 |
|
|
((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)))
|
1107 |
|
|
{
|
1108 |
|
|
/* Large structures are passed as addresses */
|
1109 |
|
|
sp -= bpa;
|
1110 |
|
|
}
|
1111 |
|
|
else
|
1112 |
|
|
{
|
1113 |
|
|
/* Big scalars use more than one word. Code here allows for future
|
1114 |
|
|
quad-word entities (e.g. long double) */
|
1115 |
|
|
sp -= ((len + bpw - 1) / bpw) * bpw;
|
1116 |
|
|
}
|
1117 |
|
|
}
|
1118 |
|
|
|
1119 |
|
|
sp = gdbarch_frame_align (gdbarch, sp);
|
1120 |
|
|
stack_offset = 0;
|
1121 |
|
|
|
1122 |
|
|
/* Push the remaining args on the stack */
|
1123 |
|
|
for (argnum = first_stack_arg; argnum < nargs; argnum++)
|
1124 |
|
|
{
|
1125 |
|
|
char *val;
|
1126 |
|
|
char valbuf[sizeof (ULONGEST) ];
|
1127 |
|
|
|
1128 |
|
|
struct value *arg = args[argnum];
|
1129 |
|
|
struct type *arg_type = check_typedef (value_type (arg));
|
1130 |
|
|
int len = arg_type->length;
|
1131 |
|
|
enum type_code typecode = arg_type->main_type->code;
|
1132 |
|
|
|
1133 |
|
|
/* The EABI passes structures that do not fit in a register by
|
1134 |
|
|
reference. In all other cases, pass the structure by value. */
|
1135 |
|
|
if((len > bpw) &&
|
1136 |
|
|
((TYPE_CODE_STRUCT == typecode) || (TYPE_CODE_UNION == typecode)))
|
1137 |
|
|
{
|
1138 |
|
|
|
1139 |
|
|
store_unsigned_integer (valbuf, bpa, byte_order, value_offset (arg));
|
1140 |
|
|
len = bpa;
|
1141 |
|
|
val = valbuf;
|
1142 |
|
|
}
|
1143 |
|
|
else
|
1144 |
|
|
{
|
1145 |
|
|
val = (char *)value_contents (arg);
|
1146 |
|
|
}
|
1147 |
|
|
|
1148 |
|
|
gdb_assert (len <= (bpw * 2));
|
1149 |
|
|
|
1150 |
|
|
write_memory (sp + stack_offset, val, len);
|
1151 |
|
|
stack_offset += ((len + bpw - 1) / bpw) * bpw;
|
1152 |
|
|
}
|
1153 |
|
|
|
1154 |
|
|
/* Save the updated stack pointer */
|
1155 |
|
|
regcache_cooked_write_unsigned (regcache, OR32_SP_REGNUM, sp);
|
1156 |
|
|
|
1157 |
|
|
return sp;
|
1158 |
|
|
|
1159 |
|
|
} /* or32_push_dummy_call() */
|
1160 |
|
|
|
1161 |
|
|
|
1162 |
|
|
/*----------------------------------------------------------------------------*/
|
1163 |
|
|
/*!Return the frame ID for a dummy stack frame
|
1164 |
|
|
|
1165 |
|
|
Tear down a dummy frame created by or32_push_dummy_call(). This data has to
|
1166 |
|
|
be constructed manually from the data in our hand.
|
1167 |
|
|
|
1168 |
|
|
The stack pointer and program counter can be obtained from the frame info.
|
1169 |
|
|
|
1170 |
|
|
@param[in] gdbarch The architecture to use
|
1171 |
|
|
@param[in] this_frame Information about this frame
|
1172 |
|
|
|
1173 |
|
|
@return Frame ID of this frame */
|
1174 |
|
|
/*---------------------------------------------------------------------------*/
|
1175 |
|
|
|
1176 |
|
|
static struct frame_id
|
1177 |
|
|
or32_dummy_id (struct gdbarch *gdbarch,
|
1178 |
|
|
struct frame_info *this_frame)
|
1179 |
|
|
{
|
1180 |
|
|
return frame_id_build (get_frame_sp (this_frame), get_frame_pc (this_frame));
|
1181 |
|
|
|
1182 |
|
|
} /* or32_dummy_id() */
|
1183 |
|
|
|
1184 |
|
|
|
1185 |
|
|
|
1186 |
|
|
|
1187 |
|
|
/* Support functions for frame handling */
|
1188 |
|
|
|
1189 |
|
|
/* -------------------------------------------------------------------------- */
|
1190 |
|
|
/*!Initialize a prologue cache
|
1191 |
|
|
|
1192 |
|
|
This function is changed from its GDB 6.8 version (named
|
1193 |
|
|
or32_frame_unwind_cache), in that it is based on THIS frame, not the NEXT
|
1194 |
|
|
frame.
|
1195 |
|
|
|
1196 |
249 |
jeremybenn |
We build a cache, saying where registers of the PREV frame can be found
|
1197 |
|
|
from the data so far set up in this THIS.
|
1198 |
227 |
jeremybenn |
|
1199 |
249 |
jeremybenn |
We also compute a unique ID for this frame, based on the function start
|
1200 |
|
|
address and the stack pointer (as it will be, even if it has yet to be
|
1201 |
|
|
computed.
|
1202 |
|
|
|
1203 |
227 |
jeremybenn |
STACK FORMAT
|
1204 |
|
|
============
|
1205 |
|
|
|
1206 |
|
|
The OR32 has a falling stack frame and a simple prolog. The Stack pointer
|
1207 |
|
|
is R1 and the frame pointer R2. The frame base is therefore the address
|
1208 |
|
|
held in R2 and the stack pointer (R1) is the frame base of the NEXT frame.
|
1209 |
|
|
|
1210 |
|
|
@verbatim
|
1211 |
|
|
l.addi r1,r1,-frame_size # SP now points to end of new stack frame
|
1212 |
|
|
@endverbatim
|
1213 |
|
|
|
1214 |
|
|
The stack pointer may not be set up in a frameless function (e.g. a simple
|
1215 |
|
|
leaf function).
|
1216 |
|
|
|
1217 |
|
|
@verbatim
|
1218 |
|
|
l.sw fp_loc(r1),r2 # old FP saved in new stack frame
|
1219 |
|
|
l.addi r2,r1,frame_size # FP now points to base of new stack frame
|
1220 |
|
|
@endverbatim
|
1221 |
|
|
|
1222 |
|
|
The frame pointer is not necessarily saved right at the end of the stack
|
1223 |
|
|
frame - OR32 saves enough space for any args to called functions right at
|
1224 |
|
|
the end (this is a difference from the Architecture Manual).
|
1225 |
|
|
|
1226 |
|
|
@verbatim
|
1227 |
|
|
l.sw lr_loc(r1),r9 # Link (return) address
|
1228 |
|
|
@endverbatim
|
1229 |
|
|
|
1230 |
|
|
The link register is usally saved at fp_loc - 4. It may not be saved at all
|
1231 |
|
|
in a leaf function.
|
1232 |
|
|
|
1233 |
|
|
@verbatim
|
1234 |
|
|
l.sw reg_loc(r1),ry # Save any callee saved regs
|
1235 |
|
|
@endverbatim
|
1236 |
|
|
|
1237 |
|
|
The offsets x for the callee saved registers generally (always?) rise in
|
1238 |
|
|
increments of 4, starting at fp_loc + 4. If the frame pointer is omitted
|
1239 |
|
|
(an option to GCC), then it may not be saved at all. There may be no callee
|
1240 |
|
|
saved registers.
|
1241 |
|
|
|
1242 |
|
|
So in summary none of this may be present. However what is present seems
|
1243 |
|
|
always to follow this fixed order, and occur before any substantive code
|
1244 |
|
|
(it is possible for GCC to have more flexible scheduling of the prologue,
|
1245 |
|
|
but this does not seem to occur for OR32).
|
1246 |
|
|
|
1247 |
|
|
ANALYSIS
|
1248 |
|
|
========
|
1249 |
|
|
|
1250 |
|
|
This prolog is used, even for -O3 with GCC.
|
1251 |
|
|
|
1252 |
|
|
All this analysis must allow for the possibility that the PC is in the
|
1253 |
249 |
jeremybenn |
middle of the prologue. Data in the cache should only be set up insofar as
|
1254 |
|
|
it has been computed.
|
1255 |
227 |
jeremybenn |
|
1256 |
249 |
jeremybenn |
HOWEVER. The frame_id must be created with the SP *as it will be* at the
|
1257 |
|
|
end of the Prologue. Otherwise a recursive call, checking the frame with
|
1258 |
|
|
the PC at the start address will end up with the same frame_id as the
|
1259 |
|
|
caller.
|
1260 |
|
|
|
1261 |
227 |
jeremybenn |
A suite of "helper" routines are used, allowing reuse for
|
1262 |
|
|
or32_skip_prologue().
|
1263 |
|
|
|
1264 |
|
|
Reportedly, this is only valid for frames less than 0x7fff in size.
|
1265 |
|
|
|
1266 |
|
|
@param[in] this_frame Our stack frame.
|
1267 |
|
|
@param[in,out] prologue_cache The prologue cache. If not supplied, we
|
1268 |
|
|
build it.
|
1269 |
|
|
|
1270 |
|
|
@return The prolog cache (duplicates the return through the argument) */
|
1271 |
|
|
/* ---------------------------------------------------------------------------*/
|
1272 |
|
|
static struct trad_frame_cache *
|
1273 |
|
|
or32_frame_cache (struct frame_info *this_frame,
|
1274 |
|
|
void **prologue_cache)
|
1275 |
|
|
{
|
1276 |
|
|
struct gdbarch *gdbarch;
|
1277 |
|
|
struct trad_frame_cache *info;
|
1278 |
|
|
|
1279 |
|
|
CORE_ADDR this_pc;
|
1280 |
|
|
CORE_ADDR this_sp;
|
1281 |
249 |
jeremybenn |
CORE_ADDR this_sp_for_id;
|
1282 |
227 |
jeremybenn |
int frame_size = 0;
|
1283 |
|
|
|
1284 |
|
|
CORE_ADDR start_addr;
|
1285 |
|
|
CORE_ADDR end_addr;
|
1286 |
|
|
|
1287 |
|
|
/* Nothing to do if we already have this info */
|
1288 |
|
|
if (NULL != *prologue_cache)
|
1289 |
|
|
{
|
1290 |
|
|
return *prologue_cache;
|
1291 |
|
|
}
|
1292 |
|
|
|
1293 |
|
|
/* Get a new prologue cache and populate it with default values */
|
1294 |
|
|
info = trad_frame_cache_zalloc (this_frame);
|
1295 |
|
|
*prologue_cache = info;
|
1296 |
|
|
|
1297 |
|
|
/* Find the start address of THIS function (which is a NORMAL frame, even if
|
1298 |
|
|
the NEXT frame is the sentinel frame) and the end of its prologue. */
|
1299 |
|
|
this_pc = get_frame_pc (this_frame);
|
1300 |
|
|
find_pc_partial_function (this_pc, NULL, &start_addr, NULL);
|
1301 |
|
|
|
1302 |
|
|
/* Return early if GDB couldn't find the function. */
|
1303 |
|
|
if (start_addr == 0)
|
1304 |
|
|
{
|
1305 |
|
|
return info;
|
1306 |
|
|
}
|
1307 |
|
|
|
1308 |
|
|
/* Get the stack pointer if we have one (if there's no process executing yet
|
1309 |
|
|
we won't have a frame. */
|
1310 |
|
|
this_sp = (NULL == this_frame) ? 0 :
|
1311 |
|
|
get_frame_register_unsigned (this_frame,
|
1312 |
|
|
OR32_SP_REGNUM);
|
1313 |
|
|
|
1314 |
249 |
jeremybenn |
/* The default frame base of THIS frame (for ID purposes only - frame base
|
1315 |
|
|
is an overloaded term) is its stack pointer. For now we use the value of
|
1316 |
|
|
the SP register in THIS frame. However if the PC is in the prologue of
|
1317 |
|
|
THIS frame, before the SP has been set up, then the value will actually
|
1318 |
|
|
be that of the PREV frame, and we'll need to adjust it later. */
|
1319 |
227 |
jeremybenn |
trad_frame_set_this_base (info, this_sp);
|
1320 |
249 |
jeremybenn |
this_sp_for_id = this_sp;
|
1321 |
227 |
jeremybenn |
|
1322 |
|
|
/* The default is to find the PC of the PREVIOUS frame in the link register
|
1323 |
|
|
of this frame. This may be changed if we find the link register was saved
|
1324 |
|
|
on the stack. */
|
1325 |
|
|
trad_frame_set_reg_realreg (info, OR32_NPC_REGNUM, OR32_LR_REGNUM);
|
1326 |
|
|
|
1327 |
249 |
jeremybenn |
/* We should only examine code that is in the prologue. This is all code up
|
1328 |
|
|
to (but not including) end_addr. We should only populate the cache while
|
1329 |
|
|
the address is up to (but not including) the PC or end_addr, whichever is
|
1330 |
|
|
first. */
|
1331 |
227 |
jeremybenn |
gdbarch = get_frame_arch (this_frame);
|
1332 |
|
|
end_addr = or32_skip_prologue (gdbarch, start_addr);
|
1333 |
|
|
|
1334 |
|
|
/* All the following analysis only occurs if we are in the prologue and have
|
1335 |
|
|
executed the code. Check we have a sane prologue size, and if zero we
|
1336 |
|
|
are frameless and can give up here. */
|
1337 |
|
|
if (end_addr < start_addr)
|
1338 |
|
|
{
|
1339 |
|
|
fatal ("end addr 0x%08x is less than start addr 0x%08x\n",
|
1340 |
|
|
(unsigned int) end_addr, (unsigned int) start_addr);
|
1341 |
|
|
}
|
1342 |
|
|
|
1343 |
|
|
if (end_addr == start_addr)
|
1344 |
|
|
{
|
1345 |
|
|
frame_size = 0;
|
1346 |
|
|
}
|
1347 |
|
|
else
|
1348 |
|
|
{
|
1349 |
|
|
/* have a frame. Look for the various components */
|
1350 |
|
|
CORE_ADDR addr = start_addr; /* Where we have got to */
|
1351 |
|
|
uint32_t inst = or32_fetch_instruction (gdbarch, addr);
|
1352 |
|
|
|
1353 |
|
|
unsigned int ra, rb, rd; /* For instruction analysis */
|
1354 |
|
|
int simm;
|
1355 |
|
|
|
1356 |
|
|
/* Look for the new stack pointer being set up. */
|
1357 |
|
|
if (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
1358 |
|
|
(OR32_SP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
1359 |
|
|
(simm < 0) && (0 == (simm % 4)))
|
1360 |
|
|
{
|
1361 |
|
|
frame_size = -simm;
|
1362 |
|
|
addr += OR32_INSTLEN;
|
1363 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1364 |
|
|
|
1365 |
249 |
jeremybenn |
/* If the PC has not actually got to this point, then the frame base
|
1366 |
|
|
will be wrong, and we adjust it.
|
1367 |
|
|
|
1368 |
|
|
If we are past this point, then we need to populate the stack
|
1369 |
|
|
accoringly. */
|
1370 |
|
|
if (this_pc <= addr)
|
1371 |
|
|
{
|
1372 |
|
|
/* Only do if executing */
|
1373 |
|
|
if (0 != this_sp)
|
1374 |
|
|
{
|
1375 |
|
|
this_sp_for_id = this_sp + frame_size;
|
1376 |
|
|
trad_frame_set_this_base (info, this_sp_for_id);
|
1377 |
|
|
}
|
1378 |
|
|
}
|
1379 |
|
|
else
|
1380 |
|
|
{
|
1381 |
|
|
/* We are past this point, so the stack pointer of the PREV
|
1382 |
|
|
frame is frame_size greater than the stack pointer of THIS
|
1383 |
|
|
frame. */
|
1384 |
|
|
trad_frame_set_reg_value (info, OR32_SP_REGNUM,
|
1385 |
|
|
this_sp + frame_size);
|
1386 |
|
|
}
|
1387 |
227 |
jeremybenn |
}
|
1388 |
|
|
|
1389 |
249 |
jeremybenn |
/* From now on we are only populating the cache, so we stop once we get
|
1390 |
|
|
to either the end OR the current PC. */
|
1391 |
|
|
end_addr = (this_pc < end_addr) ? this_pc : end_addr;
|
1392 |
|
|
|
1393 |
227 |
jeremybenn |
/* Look for the frame pointer being manipulated. */
|
1394 |
|
|
if ((addr < end_addr) &&
|
1395 |
|
|
or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
1396 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_FP_REGNUM == rb) &&
|
1397 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
1398 |
|
|
{
|
1399 |
|
|
addr += OR32_INSTLEN;
|
1400 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1401 |
|
|
|
1402 |
|
|
/* At this stage, we can find the frame pointer of the PREVIOUS
|
1403 |
|
|
frame on the stack of the current frame. */
|
1404 |
|
|
trad_frame_set_reg_addr (info, OR32_FP_REGNUM, this_sp + simm);
|
1405 |
|
|
|
1406 |
|
|
/* Look for the new frame pointer being set up */
|
1407 |
|
|
if (addr < end_addr)
|
1408 |
|
|
{
|
1409 |
|
|
gdb_assert (or32_analyse_l_addi (inst, &rd, &ra, &simm) &&
|
1410 |
|
|
(OR32_FP_REGNUM == rd) && (OR32_SP_REGNUM == ra) &&
|
1411 |
|
|
(simm == frame_size));
|
1412 |
|
|
|
1413 |
|
|
addr += OR32_INSTLEN;
|
1414 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1415 |
|
|
|
1416 |
|
|
/* If we have got this far, the stack pointer of the PREVIOUS
|
1417 |
|
|
frame is the frame pointer of THIS frame. */
|
1418 |
|
|
trad_frame_set_reg_realreg (info, OR32_SP_REGNUM, OR32_FP_REGNUM);
|
1419 |
|
|
}
|
1420 |
|
|
}
|
1421 |
|
|
|
1422 |
|
|
/* Look for the link register being saved */
|
1423 |
|
|
if ((addr < end_addr) &&
|
1424 |
|
|
or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
1425 |
|
|
(OR32_SP_REGNUM == ra) && (OR32_LR_REGNUM == rb) &&
|
1426 |
|
|
(simm >= 0) && (0 == (simm % 4)))
|
1427 |
|
|
{
|
1428 |
|
|
addr += OR32_INSTLEN;
|
1429 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1430 |
|
|
|
1431 |
|
|
/* If the link register is saved in the THIS frame, it holds the
|
1432 |
|
|
value of the PC in the PREVIOUS frame. This overwrites the
|
1433 |
|
|
previous information about finding the PC in the link
|
1434 |
|
|
register. */
|
1435 |
|
|
trad_frame_set_reg_addr (info, OR32_NPC_REGNUM, this_sp + simm);
|
1436 |
|
|
}
|
1437 |
|
|
|
1438 |
244 |
jeremybenn |
/* Look for arguments or callee-saved register being saved. The register
|
1439 |
|
|
must be one of the arguments (r3-r8) or the 10 callee saved registers
|
1440 |
|
|
(r10, r12, r14, r16, r18, r20, r22, r24, r26, r28, r30). The base
|
1441 |
|
|
register must be the FP (for the args) or the SP (for the
|
1442 |
|
|
callee_saved registers). */
|
1443 |
227 |
jeremybenn |
while (addr < end_addr)
|
1444 |
|
|
{
|
1445 |
|
|
if (or32_analyse_l_sw (inst, &simm, &ra, &rb) &&
|
1446 |
244 |
jeremybenn |
(((OR32_FP_REGNUM == ra) && or32_is_arg_reg (rb)) ||
|
1447 |
|
|
((OR32_SP_REGNUM == ra) && or32_is_callee_saved_reg (rb))) &&
|
1448 |
|
|
(0 == (simm % 4)))
|
1449 |
227 |
jeremybenn |
{
|
1450 |
|
|
addr += OR32_INSTLEN;
|
1451 |
|
|
inst = or32_fetch_instruction (gdbarch, addr);
|
1452 |
|
|
|
1453 |
|
|
/* The register in the PREVIOUS frame can be found at this
|
1454 |
|
|
location in THIS frame */
|
1455 |
|
|
trad_frame_set_reg_addr (info, rb, this_sp + simm);
|
1456 |
|
|
}
|
1457 |
|
|
else
|
1458 |
|
|
{
|
1459 |
|
|
break; /* Not a register save instruction */
|
1460 |
|
|
}
|
1461 |
|
|
}
|
1462 |
|
|
}
|
1463 |
|
|
|
1464 |
|
|
/* Build the frame ID */
|
1465 |
249 |
jeremybenn |
trad_frame_set_id (info, frame_id_build (this_sp_for_id, start_addr));
|
1466 |
227 |
jeremybenn |
|
1467 |
|
|
return info;
|
1468 |
|
|
|
1469 |
|
|
} /* or32_frame_cache() */
|
1470 |
|
|
|
1471 |
|
|
|
1472 |
|
|
/* -------------------------------------------------------------------------- */
|
1473 |
|
|
/*!Find the frame ID of this frame
|
1474 |
|
|
|
1475 |
|
|
This function has changed since GDB 6.8 to use THIS frame, rather than the
|
1476 |
|
|
NEXT frame.
|
1477 |
|
|
|
1478 |
|
|
Given a GDB frame, return its frame_id.
|
1479 |
|
|
|
1480 |
|
|
@param[in] this_frame Our frame, for which the ID is wanted.
|
1481 |
|
|
@param[in] prologue_cache Any cached prologue for THIS function.
|
1482 |
|
|
@param[out] this_id Frame ID of our own frame.
|
1483 |
|
|
|
1484 |
|
|
@return Frame ID for THIS frame */
|
1485 |
|
|
/* ------------------------------------------------------------------------- */
|
1486 |
|
|
static void
|
1487 |
|
|
or32_frame_this_id (struct frame_info *this_frame,
|
1488 |
|
|
void **prologue_cache,
|
1489 |
|
|
struct frame_id *this_id)
|
1490 |
|
|
{
|
1491 |
|
|
struct trad_frame_cache *info =
|
1492 |
|
|
or32_frame_cache (this_frame, prologue_cache);
|
1493 |
|
|
|
1494 |
|
|
trad_frame_get_id (info, this_id);
|
1495 |
|
|
|
1496 |
|
|
} /* or32_frame_this_id() */
|
1497 |
|
|
|
1498 |
|
|
|
1499 |
|
|
/*----------------------------------------------------------------------------*/
|
1500 |
|
|
/*!Get a register from the PREVIOUS frame
|
1501 |
|
|
|
1502 |
|
|
This function has changed from GDB 6.8. It now takes a reference to THIS
|
1503 |
|
|
frame, not the NEXT frame. It returns it results via a structure, not its
|
1504 |
|
|
argument list.
|
1505 |
|
|
|
1506 |
|
|
Given a pointer to the THIS frame, return the details of a register in the
|
1507 |
|
|
PREVIOUS frame.
|
1508 |
|
|
|
1509 |
|
|
@param[in] this_frame The stack frame under consideration
|
1510 |
|
|
@param[in] prologue_cache Any cached prologue associated with THIS frame,
|
1511 |
|
|
which may therefore tell us about registers in
|
1512 |
|
|
the PREVIOUS frame.
|
1513 |
|
|
@param[in] regnum The register of interest in the PREVIOUS frame
|
1514 |
|
|
|
1515 |
|
|
@return A value structure representing the register. */
|
1516 |
|
|
/* -------------------------------------------------------------------------- */
|
1517 |
|
|
static struct value *
|
1518 |
|
|
or32_frame_prev_register (struct frame_info *this_frame,
|
1519 |
|
|
void **prologue_cache,
|
1520 |
|
|
int regnum)
|
1521 |
|
|
{
|
1522 |
|
|
struct trad_frame_cache *info = or32_frame_cache (this_frame,
|
1523 |
|
|
prologue_cache);
|
1524 |
|
|
|
1525 |
|
|
return trad_frame_get_register (info, this_frame, regnum);
|
1526 |
|
|
|
1527 |
|
|
} /* or32_frame_prev_register() */
|
1528 |
|
|
|
1529 |
|
|
|
1530 |
|
|
/* -------------------------------------------------------------------------- */
|
1531 |
|
|
/*!Structure defining the OR32 frame unwind functions
|
1532 |
|
|
|
1533 |
|
|
Must be global (to this file), since referred to by multiple functions.
|
1534 |
|
|
|
1535 |
|
|
Since we are the fallback unwinder, we use the default frame sniffer, which
|
1536 |
|
|
always accepts the frame
|
1537 |
|
|
|
1538 |
|
|
This applies to NORMAL frames only. We provide the following functions.
|
1539 |
|
|
- to give the ID of THIS frame
|
1540 |
|
|
- to give the details of a register in PREVIOUS frame
|
1541 |
|
|
- a frame sniffer. */
|
1542 |
|
|
/* -------------------------------------------------------------------------- */
|
1543 |
|
|
static const struct frame_unwind or32_frame_unwind = {
|
1544 |
|
|
.type = NORMAL_FRAME,
|
1545 |
|
|
.this_id = or32_frame_this_id,
|
1546 |
|
|
.prev_register = or32_frame_prev_register,
|
1547 |
|
|
.unwind_data = NULL,
|
1548 |
|
|
.sniffer = default_frame_sniffer,
|
1549 |
|
|
.dealloc_cache = NULL,
|
1550 |
|
|
.prev_arch = NULL
|
1551 |
|
|
};
|
1552 |
|
|
|
1553 |
|
|
|
1554 |
|
|
/*----------------------------------------------------------------------------*/
|
1555 |
|
|
/*!Return the base address of the frame
|
1556 |
|
|
|
1557 |
|
|
The implementations has changed since GDB 6.8, since we are now provided
|
1558 |
|
|
with the address of THIS frame, rather than the NEXT frame.
|
1559 |
|
|
|
1560 |
244 |
jeremybenn |
For the OR32, the base address is the frame pointer
|
1561 |
227 |
jeremybenn |
|
1562 |
|
|
@param[in] this_frame The current stack frame.
|
1563 |
|
|
@param[in] prologue_cache Any cached prologue for THIS function.
|
1564 |
|
|
|
1565 |
|
|
@return The frame base address */
|
1566 |
|
|
/*---------------------------------------------------------------------------*/
|
1567 |
|
|
|
1568 |
|
|
static CORE_ADDR
|
1569 |
|
|
or32_frame_base_address (struct frame_info *this_frame,
|
1570 |
|
|
void **prologue_cache)
|
1571 |
|
|
{
|
1572 |
244 |
jeremybenn |
return (CORE_ADDR) get_frame_register_unsigned (this_frame, OR32_FP_REGNUM);
|
1573 |
227 |
jeremybenn |
|
1574 |
|
|
} /* or32_frame_base_address() */
|
1575 |
|
|
|
1576 |
|
|
|
1577 |
|
|
/* -------------------------------------------------------------------------- */
|
1578 |
|
|
/*!Identify our frame base sniffer functions
|
1579 |
|
|
|
1580 |
|
|
This function just identifies our family of frame sniffing functions.
|
1581 |
|
|
|
1582 |
|
|
@param[in] this_frame The frame of THIS function. Not used here.
|
1583 |
|
|
|
1584 |
|
|
@return A pointer to a struct identifying the frame base sniffing
|
1585 |
|
|
functions. */
|
1586 |
|
|
/* -------------------------------------------------------------------------- */
|
1587 |
|
|
static const struct frame_base *
|
1588 |
|
|
or32_frame_base_sniffer (struct frame_info *this_frame)
|
1589 |
|
|
{
|
1590 |
|
|
/* Structure defining how the frame base is to be identified. */
|
1591 |
|
|
static const struct frame_base or32_frame_base =
|
1592 |
|
|
{
|
1593 |
|
|
.unwind = &or32_frame_unwind,
|
1594 |
|
|
.this_base = or32_frame_base_address,
|
1595 |
|
|
.this_locals = or32_frame_base_address,
|
1596 |
|
|
.this_args = or32_frame_base_address
|
1597 |
|
|
};
|
1598 |
|
|
|
1599 |
|
|
return &or32_frame_base;
|
1600 |
|
|
|
1601 |
|
|
} /* or32_frame_base_sniffer () */
|
1602 |
|
|
|
1603 |
|
|
|
1604 |
|
|
/* -------------------------------------------------------------------------- */
|
1605 |
|
|
/*!Architecture initialization for OpenRISC 1000
|
1606 |
|
|
|
1607 |
|
|
Looks for a candidate architecture in the list of architectures supplied
|
1608 |
|
|
using the info supplied. If none match, create a new architecture.
|
1609 |
|
|
|
1610 |
|
|
@param[in] info Information about the target architecture
|
1611 |
|
|
@param[in] arches The list of currently know architectures
|
1612 |
|
|
|
1613 |
|
|
@return A structure describing the target architecture */
|
1614 |
|
|
/* -------------------------------------------------------------------------- */
|
1615 |
|
|
static struct gdbarch *
|
1616 |
|
|
or32_gdbarch_init (struct gdbarch_info info,
|
1617 |
|
|
struct gdbarch_list *arches)
|
1618 |
|
|
{
|
1619 |
|
|
static struct frame_base or32_frame_base;
|
1620 |
|
|
struct gdbarch *gdbarch;
|
1621 |
|
|
struct gdbarch_tdep *tdep;
|
1622 |
|
|
const struct bfd_arch_info *binfo;
|
1623 |
|
|
|
1624 |
|
|
/* Find a candidate among the list of pre-declared architectures. */
|
1625 |
|
|
arches = gdbarch_list_lookup_by_info (arches, &info);
|
1626 |
|
|
if (NULL != arches)
|
1627 |
|
|
{
|
1628 |
|
|
return arches->gdbarch;
|
1629 |
|
|
}
|
1630 |
|
|
|
1631 |
|
|
/* None found, create a new architecture from the information
|
1632 |
|
|
provided. Can't initialize all the target dependencies until we actually
|
1633 |
|
|
know which target we are talking to, but put in some defaults for now. */
|
1634 |
|
|
|
1635 |
|
|
binfo = info.bfd_arch_info;
|
1636 |
|
|
tdep = xmalloc (sizeof *tdep);
|
1637 |
|
|
tdep->num_matchpoints = OR32_MAX_MATCHPOINTS;
|
1638 |
|
|
tdep->num_gpr_regs = OR32_MAX_GPR_REGS;
|
1639 |
|
|
tdep->bytes_per_word = binfo->bits_per_word / binfo->bits_per_byte;
|
1640 |
|
|
tdep->bytes_per_address = binfo->bits_per_address / binfo->bits_per_byte;
|
1641 |
|
|
gdbarch = gdbarch_alloc (&info, tdep);
|
1642 |
|
|
|
1643 |
|
|
/* Target data types. */
|
1644 |
|
|
set_gdbarch_short_bit (gdbarch, 16);
|
1645 |
|
|
set_gdbarch_int_bit (gdbarch, 32);
|
1646 |
|
|
set_gdbarch_long_bit (gdbarch, 32);
|
1647 |
|
|
set_gdbarch_long_long_bit (gdbarch, 64);
|
1648 |
|
|
set_gdbarch_float_bit (gdbarch, 32);
|
1649 |
|
|
set_gdbarch_float_format (gdbarch, floatformats_ieee_single);
|
1650 |
|
|
set_gdbarch_double_bit (gdbarch, 64);
|
1651 |
|
|
set_gdbarch_double_format (gdbarch, floatformats_ieee_double);
|
1652 |
|
|
set_gdbarch_long_double_bit (gdbarch, 64);
|
1653 |
|
|
set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double);
|
1654 |
|
|
set_gdbarch_ptr_bit (gdbarch, binfo->bits_per_address);
|
1655 |
|
|
set_gdbarch_addr_bit (gdbarch, binfo->bits_per_address);
|
1656 |
|
|
set_gdbarch_char_signed (gdbarch, 1);
|
1657 |
|
|
|
1658 |
|
|
/* Information about the target architecture */
|
1659 |
|
|
set_gdbarch_return_value (gdbarch, or32_return_value);
|
1660 |
|
|
set_gdbarch_breakpoint_from_pc (gdbarch, or32_breakpoint_from_pc);
|
1661 |
|
|
set_gdbarch_single_step_through_delay
|
1662 |
|
|
(gdbarch, or32_single_step_through_delay);
|
1663 |
|
|
set_gdbarch_have_nonsteppable_watchpoint
|
1664 |
|
|
(gdbarch, 1);
|
1665 |
|
|
switch (gdbarch_byte_order (gdbarch))
|
1666 |
|
|
{
|
1667 |
|
|
case BFD_ENDIAN_BIG:
|
1668 |
|
|
set_gdbarch_print_insn (gdbarch, print_insn_big_or32);
|
1669 |
|
|
break;
|
1670 |
|
|
|
1671 |
|
|
case BFD_ENDIAN_LITTLE:
|
1672 |
|
|
set_gdbarch_print_insn (gdbarch, print_insn_little_or32);
|
1673 |
|
|
break;
|
1674 |
|
|
|
1675 |
|
|
case BFD_ENDIAN_UNKNOWN:
|
1676 |
|
|
error ("or32_gdbarch_init: Unknown endianness");
|
1677 |
|
|
break;
|
1678 |
|
|
}
|
1679 |
|
|
|
1680 |
|
|
/* Register architecture */
|
1681 |
|
|
set_gdbarch_pseudo_register_read (gdbarch, or32_pseudo_register_read);
|
1682 |
|
|
set_gdbarch_pseudo_register_write (gdbarch, or32_pseudo_register_write);
|
1683 |
|
|
set_gdbarch_num_regs (gdbarch, OR32_NUM_REGS);
|
1684 |
|
|
set_gdbarch_num_pseudo_regs (gdbarch, OR32_NUM_PSEUDO_REGS);
|
1685 |
|
|
set_gdbarch_sp_regnum (gdbarch, OR32_SP_REGNUM);
|
1686 |
|
|
set_gdbarch_pc_regnum (gdbarch, OR32_NPC_REGNUM);
|
1687 |
|
|
set_gdbarch_ps_regnum (gdbarch, OR32_SR_REGNUM);
|
1688 |
|
|
set_gdbarch_deprecated_fp_regnum (gdbarch, OR32_FP_REGNUM);
|
1689 |
|
|
|
1690 |
|
|
/* Functions to supply register information */
|
1691 |
|
|
set_gdbarch_register_name (gdbarch, or32_register_name);
|
1692 |
|
|
set_gdbarch_register_type (gdbarch, or32_register_type);
|
1693 |
|
|
set_gdbarch_print_registers_info (gdbarch, or32_registers_info);
|
1694 |
|
|
set_gdbarch_register_reggroup_p (gdbarch, or32_register_reggroup_p);
|
1695 |
|
|
|
1696 |
|
|
/* Functions to analyse frames */
|
1697 |
|
|
set_gdbarch_skip_prologue (gdbarch, or32_skip_prologue);
|
1698 |
|
|
set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
|
1699 |
|
|
set_gdbarch_frame_align (gdbarch, or32_frame_align);
|
1700 |
|
|
set_gdbarch_frame_red_zone_size (gdbarch, OR32_FRAME_RED_ZONE_SIZE);
|
1701 |
|
|
|
1702 |
|
|
/* Functions to access frame data */
|
1703 |
|
|
set_gdbarch_unwind_pc (gdbarch, or32_unwind_pc);
|
1704 |
|
|
set_gdbarch_unwind_sp (gdbarch, or32_unwind_sp);
|
1705 |
|
|
|
1706 |
|
|
/* Functions handling dummy frames */
|
1707 |
|
|
set_gdbarch_push_dummy_call (gdbarch, or32_push_dummy_call);
|
1708 |
|
|
set_gdbarch_dummy_id (gdbarch, or32_dummy_id);
|
1709 |
|
|
|
1710 |
|
|
/* Set up sniffers for the frame base. Use DWARF debug info if available,
|
1711 |
|
|
otherwise use our own sniffer. */
|
1712 |
|
|
frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
|
1713 |
|
|
frame_base_append_sniffer (gdbarch, or32_frame_base_sniffer);
|
1714 |
|
|
|
1715 |
|
|
/* Frame unwinders. Use DWARF debug info if available, otherwise use our
|
1716 |
|
|
own unwinder. */
|
1717 |
|
|
dwarf2_append_unwinders (gdbarch);
|
1718 |
|
|
frame_unwind_append_unwinder (gdbarch, &or32_frame_unwind);
|
1719 |
|
|
|
1720 |
|
|
return gdbarch;
|
1721 |
|
|
|
1722 |
|
|
} /* or32_gdbarch_init() */
|
1723 |
|
|
|
1724 |
|
|
|
1725 |
|
|
/*----------------------------------------------------------------------------*/
|
1726 |
|
|
/*!Dump the target specific data for this architecture
|
1727 |
|
|
|
1728 |
|
|
@param[in] gdbarch The architecture of interest
|
1729 |
|
|
@param[in] file Where to dump the data */
|
1730 |
|
|
/*---------------------------------------------------------------------------*/
|
1731 |
|
|
|
1732 |
|
|
static void
|
1733 |
|
|
or32_dump_tdep (struct gdbarch *gdbarch,
|
1734 |
|
|
struct ui_file *file)
|
1735 |
|
|
{
|
1736 |
|
|
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
|
1737 |
|
|
|
1738 |
|
|
if (NULL == tdep)
|
1739 |
|
|
{
|
1740 |
|
|
return; /* Nothing to report */
|
1741 |
|
|
}
|
1742 |
|
|
|
1743 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d matchpoints available\n",
|
1744 |
|
|
tdep->num_matchpoints);
|
1745 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d general purpose registers\n",
|
1746 |
|
|
tdep->num_gpr_regs);
|
1747 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d bytes per word\n",
|
1748 |
|
|
tdep->bytes_per_word);
|
1749 |
|
|
fprintf_unfiltered (file, "or32_dump_tdep: %d bytes per address\n",
|
1750 |
|
|
tdep->bytes_per_address);
|
1751 |
|
|
|
1752 |
|
|
} /* or32_dump_tdep() */
|
1753 |
|
|
|
1754 |
|
|
|
1755 |
|
|
|
1756 |
|
|
/* Functions to add extra commands to GDB */
|
1757 |
|
|
|
1758 |
|
|
|
1759 |
|
|
/*----------------------------------------------------------------------------*/
|
1760 |
|
|
/*!Returns a special purpose register group name
|
1761 |
|
|
|
1762 |
|
|
@param[in] group The SPR group number
|
1763 |
|
|
|
1764 |
|
|
@return The SPR name (pointer to the name argument) */
|
1765 |
|
|
/*---------------------------------------------------------------------------*/
|
1766 |
|
|
|
1767 |
|
|
static const char *
|
1768 |
|
|
or32_spr_group_name (int group)
|
1769 |
|
|
{
|
1770 |
|
|
static const char *or32_group_names[OR32_NUM_SPGS] =
|
1771 |
|
|
{
|
1772 |
|
|
"SYS",
|
1773 |
|
|
"DMMU",
|
1774 |
|
|
"IMMU",
|
1775 |
|
|
"DCACHE",
|
1776 |
|
|
"ICACHE",
|
1777 |
|
|
"MAC",
|
1778 |
|
|
"DEBUG",
|
1779 |
|
|
"PERF",
|
1780 |
|
|
"POWER",
|
1781 |
|
|
"PIC",
|
1782 |
|
|
"TIMER",
|
1783 |
|
|
"FPU"
|
1784 |
|
|
};
|
1785 |
|
|
|
1786 |
|
|
if ((0 <= group) && (group < OR32_NUM_SPGS))
|
1787 |
|
|
{
|
1788 |
|
|
return or32_group_names[group];
|
1789 |
|
|
}
|
1790 |
|
|
else
|
1791 |
|
|
{
|
1792 |
|
|
return "";
|
1793 |
|
|
}
|
1794 |
|
|
} /* or32_spr_group_name() */
|
1795 |
|
|
|
1796 |
|
|
|
1797 |
|
|
/*----------------------------------------------------------------------------*/
|
1798 |
|
|
/*!Returns a special purpose register name
|
1799 |
|
|
|
1800 |
|
|
@param[in] group The SPR group
|
1801 |
|
|
@param[in] index The index within the SPR group
|
1802 |
|
|
@param[out] name Array to put the name in
|
1803 |
|
|
|
1804 |
|
|
@return The SPR name (pointer to the name argument) */
|
1805 |
|
|
/*---------------------------------------------------------------------------*/
|
1806 |
|
|
|
1807 |
|
|
static char *
|
1808 |
|
|
or32_spr_register_name (int group,
|
1809 |
|
|
int index,
|
1810 |
|
|
char *name)
|
1811 |
|
|
{
|
1812 |
|
|
char di;
|
1813 |
|
|
|
1814 |
|
|
switch (group)
|
1815 |
|
|
{
|
1816 |
|
|
|
1817 |
|
|
case OR32_SPG_SYS:
|
1818 |
|
|
/* 1:1 names */
|
1819 |
|
|
switch (index)
|
1820 |
|
|
{
|
1821 |
|
|
case OR32_SPG_SYS_VR: sprintf (name, "VR" ); return name;
|
1822 |
|
|
case OR32_SPG_SYS_UPR: sprintf (name, "UPR" ); return name;
|
1823 |
|
|
case OR32_SPG_SYS_CPUCFGR: sprintf (name, "CPUCFGR" ); return name;
|
1824 |
|
|
case OR32_SPG_SYS_DMMUCFGR: sprintf (name, "DMMUCFGR"); return name;
|
1825 |
|
|
case OR32_SPG_SYS_IMMUCFGR: sprintf (name, "IMMUCFGR"); return name;
|
1826 |
|
|
case OR32_SPG_SYS_DCCFGR: sprintf (name, "DCCFGR" ); return name;
|
1827 |
|
|
case OR32_SPG_SYS_ICCFGR: sprintf (name, "ICCFGR" ); return name;
|
1828 |
|
|
case OR32_SPG_SYS_DCFGR: sprintf (name, "DCFGR" ); return name;
|
1829 |
|
|
case OR32_SPG_SYS_PCCFGR: sprintf (name, "PCCFGR" ); return name;
|
1830 |
|
|
case OR32_SPG_SYS_NPC: sprintf (name, "NPC" ); return name;
|
1831 |
|
|
case OR32_SPG_SYS_SR: sprintf (name, "SR" ); return name;
|
1832 |
|
|
case OR32_SPG_SYS_PPC: sprintf (name, "PPC" ); return name;
|
1833 |
|
|
case OR32_SPG_SYS_FPCSR: sprintf (name, "FPCSR" ); return name;
|
1834 |
|
|
}
|
1835 |
|
|
|
1836 |
|
|
/* Exception PC regs */
|
1837 |
|
|
if((OR32_SPG_SYS_EPCR <= index) &&
|
1838 |
|
|
(index <= OR32_SPG_SYS_EPCR_END))
|
1839 |
|
|
{
|
1840 |
|
|
sprintf (name, "EPCR%d", index - OR32_SPG_SYS_EPCR);
|
1841 |
|
|
return name;
|
1842 |
|
|
}
|
1843 |
|
|
|
1844 |
|
|
/* Exception EA regs */
|
1845 |
|
|
if((OR32_SPG_SYS_EEAR <= index) &&
|
1846 |
|
|
(index <= OR32_SPG_SYS_EEAR_END))
|
1847 |
|
|
{
|
1848 |
|
|
sprintf (name, "EEAR%d", index - OR32_SPG_SYS_EEAR);
|
1849 |
|
|
return name;
|
1850 |
|
|
}
|
1851 |
|
|
|
1852 |
|
|
/* Exception SR regs */
|
1853 |
|
|
if((OR32_SPG_SYS_ESR <= index) &&
|
1854 |
|
|
(index <= OR32_SPG_SYS_ESR_END))
|
1855 |
|
|
{
|
1856 |
|
|
sprintf (name, "ESR%d", index - OR32_SPG_SYS_ESR);
|
1857 |
|
|
return name;
|
1858 |
|
|
}
|
1859 |
|
|
|
1860 |
|
|
/* GPRs */
|
1861 |
|
|
if((OR32_SPG_SYS_GPR <= index) &&
|
1862 |
|
|
(index <= OR32_SPG_SYS_GPR_END))
|
1863 |
|
|
{
|
1864 |
|
|
sprintf (name, "GPR%d", index - OR32_SPG_SYS_GPR);
|
1865 |
|
|
return name;
|
1866 |
|
|
}
|
1867 |
|
|
|
1868 |
|
|
break;
|
1869 |
|
|
|
1870 |
|
|
case OR32_SPG_DMMU:
|
1871 |
|
|
case OR32_SPG_IMMU:
|
1872 |
|
|
/* MMU registers. Use DMMU constants throughout, but these are identical
|
1873 |
|
|
to the corresponding IMMU constants */
|
1874 |
|
|
di = OR32_SPG_DMMU == group ? 'D' : 'I';
|
1875 |
|
|
|
1876 |
|
|
/* 1:1 names */
|
1877 |
|
|
switch (index)
|
1878 |
|
|
{
|
1879 |
|
|
case OR32_SPG_DMMU_DMMUCR:
|
1880 |
|
|
sprintf (name, "%cMMUCR", di); return name;
|
1881 |
|
|
case OR32_SPG_DMMU_DMMUPR:
|
1882 |
|
|
sprintf (name, "%cMMUPR", di); return name;
|
1883 |
|
|
case OR32_SPG_DMMU_DTLBEIR:
|
1884 |
|
|
sprintf (name, "%cTLBEIR", di); return name;
|
1885 |
|
|
}
|
1886 |
|
|
|
1887 |
|
|
/* ATB Match registers */
|
1888 |
|
|
if((OR32_SPG_DMMU_DATBMR <= index) &&
|
1889 |
|
|
(index <= OR32_SPG_DMMU_DATBMR_END))
|
1890 |
|
|
{
|
1891 |
|
|
sprintf (name, "%cATBMR%d", di, index - OR32_SPG_DMMU_DATBMR);
|
1892 |
|
|
return name;
|
1893 |
|
|
}
|
1894 |
|
|
|
1895 |
|
|
/* ATB Translate registers */
|
1896 |
|
|
if((OR32_SPG_DMMU_DATBTR <= index) &&
|
1897 |
|
|
(index <= OR32_SPG_DMMU_DATBTR_END))
|
1898 |
|
|
{
|
1899 |
|
|
sprintf (name, "%cATBTR%d", di, index - OR32_SPG_DMMU_DATBTR);
|
1900 |
|
|
return name;
|
1901 |
|
|
}
|
1902 |
|
|
|
1903 |
|
|
/* TLB Way 1 Match registers */
|
1904 |
|
|
if((OR32_SPG_DMMU_DTLBW1MR <= index) &&
|
1905 |
|
|
(index <= OR32_SPG_DMMU_DTLBW1MR_END))
|
1906 |
|
|
{
|
1907 |
|
|
sprintf (name, "%cTLBW1MR%d", di, index - OR32_SPG_DMMU_DTLBW1MR);
|
1908 |
|
|
return name;
|
1909 |
|
|
}
|
1910 |
|
|
|
1911 |
|
|
/* TLB Way 1 Translate registers */
|
1912 |
|
|
if((OR32_SPG_DMMU_DTLBW1TR <= index) &&
|
1913 |
|
|
(index <= OR32_SPG_DMMU_DTLBW1TR_END))
|
1914 |
|
|
{
|
1915 |
|
|
sprintf (name, "%cTLBW1TR%d", di, index - OR32_SPG_DMMU_DTLBW1TR);
|
1916 |
|
|
return name;
|
1917 |
|
|
}
|
1918 |
|
|
|
1919 |
|
|
/* TLB Way 2 Match registers */
|
1920 |
|
|
if((OR32_SPG_DMMU_DTLBW2MR <= index) &&
|
1921 |
|
|
(index <= OR32_SPG_DMMU_DTLBW2MR_END))
|
1922 |
|
|
{
|
1923 |
|
|
sprintf (name, "%cTLBW2MR%d", di, index - OR32_SPG_DMMU_DTLBW2MR);
|
1924 |
|
|
return name;
|
1925 |
|
|
}
|
1926 |
|
|
|
1927 |
|
|
/* TLB Way 2 Translate registers */
|
1928 |
|
|
if((OR32_SPG_DMMU_DTLBW2TR <= index) &&
|
1929 |
|
|
(index <= OR32_SPG_DMMU_DTLBW2TR_END))
|
1930 |
|
|
{
|
1931 |
|
|
sprintf (name, "%cTLBW2TR%d", di, index - OR32_SPG_DMMU_DTLBW2TR);
|
1932 |
|
|
return name;
|
1933 |
|
|
}
|
1934 |
|
|
|
1935 |
|
|
/* TLB Way 3 Match registers */
|
1936 |
|
|
if((OR32_SPG_DMMU_DTLBW3MR <= index) &&
|
1937 |
|
|
(index <= OR32_SPG_DMMU_DTLBW3MR_END))
|
1938 |
|
|
{
|
1939 |
|
|
sprintf (name, "%cTLBW3MR%d", di, index - OR32_SPG_DMMU_DTLBW3MR);
|
1940 |
|
|
return name;
|
1941 |
|
|
}
|
1942 |
|
|
|
1943 |
|
|
/* TLB Way 3 Translate registers */
|
1944 |
|
|
if((OR32_SPG_DMMU_DTLBW3TR <= index) &&
|
1945 |
|
|
(index <= OR32_SPG_DMMU_DTLBW3TR_END))
|
1946 |
|
|
{
|
1947 |
|
|
sprintf (name, "%cTLBW3TR%d", di, index - OR32_SPG_DMMU_DTLBW3TR);
|
1948 |
|
|
return name;
|
1949 |
|
|
}
|
1950 |
|
|
|
1951 |
|
|
break;
|
1952 |
|
|
|
1953 |
|
|
case OR32_SPG_DC:
|
1954 |
|
|
/* Data cache registers. These do not have an exact correspondence with
|
1955 |
|
|
their instruction cache counterparts, so must be done separately. */
|
1956 |
|
|
|
1957 |
|
|
/* 1:1 names */
|
1958 |
|
|
switch (index)
|
1959 |
|
|
{
|
1960 |
|
|
case OR32_SPG_DC_DCCR: sprintf (name, "DCCR" ); return name;
|
1961 |
|
|
case OR32_SPG_DC_DCBPR: sprintf (name, "DCBPR"); return name;
|
1962 |
|
|
case OR32_SPG_DC_DCBFR: sprintf (name, "DCBFR"); return name;
|
1963 |
|
|
case OR32_SPG_DC_DCBIR: sprintf (name, "DCBIR"); return name;
|
1964 |
|
|
case OR32_SPG_DC_DCBWR: sprintf (name, "DCBWR"); return name;
|
1965 |
|
|
case OR32_SPG_DC_DCBLR: sprintf (name, "DCBLR"); return name;
|
1966 |
|
|
}
|
1967 |
|
|
|
1968 |
|
|
break;
|
1969 |
|
|
|
1970 |
|
|
case OR32_SPG_IC:
|
1971 |
|
|
/* Instruction cache registers */
|
1972 |
|
|
|
1973 |
|
|
/* 1:1 names */
|
1974 |
|
|
switch (index)
|
1975 |
|
|
{
|
1976 |
|
|
case OR32_SPG_IC_ICCR: sprintf (name, "ICCR" ); return name;
|
1977 |
|
|
case OR32_SPG_IC_ICBPR: sprintf (name, "ICBPR"); return name;
|
1978 |
|
|
case OR32_SPG_IC_ICBIR: sprintf (name, "ICBIR"); return name;
|
1979 |
|
|
case OR32_SPG_IC_ICBLR: sprintf (name, "ICBLR"); return name;
|
1980 |
|
|
}
|
1981 |
|
|
|
1982 |
|
|
break;
|
1983 |
|
|
|
1984 |
|
|
case OR32_SPG_MAC:
|
1985 |
|
|
/* MAC registers */
|
1986 |
|
|
|
1987 |
|
|
/* 1:1 names */
|
1988 |
|
|
switch (index)
|
1989 |
|
|
{
|
1990 |
|
|
case OR32_SPG_MAC_MACLO: sprintf (name, "MACLO"); return name;
|
1991 |
|
|
case OR32_SPG_MAC_MACHI: sprintf (name, "MACHI"); return name;
|
1992 |
|
|
}
|
1993 |
|
|
|
1994 |
|
|
break;
|
1995 |
|
|
|
1996 |
|
|
case OR32_SPG_DEBUG:
|
1997 |
|
|
/* Debug registers */
|
1998 |
|
|
|
1999 |
|
|
/* Debug Value registers */
|
2000 |
|
|
if((OR32_SPG_DEBUG_DVR <= index) &&
|
2001 |
|
|
(index <= OR32_SPG_DEBUG_DVR_END))
|
2002 |
|
|
{
|
2003 |
|
|
sprintf (name, "DVR%d", index - OR32_SPG_DEBUG_DVR);
|
2004 |
|
|
return name;
|
2005 |
|
|
}
|
2006 |
|
|
|
2007 |
|
|
/* Debug Control registers */
|
2008 |
|
|
if((OR32_SPG_DEBUG_DCR <= index) &&
|
2009 |
|
|
(index <= OR32_SPG_DEBUG_DCR_END))
|
2010 |
|
|
{
|
2011 |
|
|
sprintf (name, "DCR%d", index - OR32_SPG_DEBUG_DCR);
|
2012 |
|
|
return name;
|
2013 |
|
|
}
|
2014 |
|
|
|
2015 |
|
|
/* 1:1 names */
|
2016 |
|
|
switch (index)
|
2017 |
|
|
{
|
2018 |
|
|
case OR32_SPG_DEBUG_DMR1: sprintf (name, "DMR1" ); return name;
|
2019 |
|
|
case OR32_SPG_DEBUG_DMR2: sprintf (name, "DMR2" ); return name;
|
2020 |
|
|
case OR32_SPG_DEBUG_DCWR0: sprintf (name, "DCWR0"); return name;
|
2021 |
|
|
case OR32_SPG_DEBUG_DCWR1: sprintf (name, "DCWR1"); return name;
|
2022 |
|
|
case OR32_SPG_DEBUG_DSR: sprintf (name, "DSR" ); return name;
|
2023 |
|
|
case OR32_SPG_DEBUG_DRR: sprintf (name, "DRR" ); return name;
|
2024 |
|
|
}
|
2025 |
|
|
|
2026 |
|
|
break;
|
2027 |
|
|
|
2028 |
|
|
case OR32_SPG_PC:
|
2029 |
|
|
/* Performance Counter registers */
|
2030 |
|
|
|
2031 |
|
|
/* Performance Counters Count registers */
|
2032 |
|
|
if((OR32_SPG_PC_PCCR <= index) &&
|
2033 |
|
|
(index <= OR32_SPG_PC_PCCR_END))
|
2034 |
|
|
{
|
2035 |
|
|
sprintf (name, "PCCR%d", index - OR32_SPG_PC_PCCR);
|
2036 |
|
|
return name;
|
2037 |
|
|
}
|
2038 |
|
|
|
2039 |
|
|
/* Performance Counters Mode registers */
|
2040 |
|
|
if((OR32_SPG_PC_PCMR <= index) &&
|
2041 |
|
|
(index <= OR32_SPG_PC_PCMR_END))
|
2042 |
|
|
{
|
2043 |
|
|
sprintf (name, "PCMR%d", index - OR32_SPG_PC_PCMR);
|
2044 |
|
|
return name;
|
2045 |
|
|
}
|
2046 |
|
|
|
2047 |
|
|
break;
|
2048 |
|
|
|
2049 |
|
|
case OR32_SPG_PM:
|
2050 |
|
|
/* Power Management registers */
|
2051 |
|
|
|
2052 |
|
|
/* 1:1 names */
|
2053 |
|
|
switch (index)
|
2054 |
|
|
{
|
2055 |
|
|
case OR32_SPG_PM_PMR: sprintf (name, "PMR"); return name;
|
2056 |
|
|
}
|
2057 |
|
|
|
2058 |
|
|
break;
|
2059 |
|
|
|
2060 |
|
|
case OR32_SPG_PIC:
|
2061 |
|
|
/* Programmable Interrupt Controller registers */
|
2062 |
|
|
|
2063 |
|
|
/* 1:1 names */
|
2064 |
|
|
switch (index)
|
2065 |
|
|
{
|
2066 |
|
|
case OR32_SPG_PIC_PICMR: sprintf (name, "PICMR"); return name;
|
2067 |
|
|
case OR32_SPG_PIC_PICSR: sprintf (name, "PICSR"); return name;
|
2068 |
|
|
}
|
2069 |
|
|
|
2070 |
|
|
break;
|
2071 |
|
|
|
2072 |
|
|
case OR32_SPG_TT:
|
2073 |
|
|
/* Tick Timer registers */
|
2074 |
|
|
|
2075 |
|
|
/* 1:1 names */
|
2076 |
|
|
switch (index)
|
2077 |
|
|
{
|
2078 |
|
|
case OR32_SPG_TT_TTMR: sprintf (name, "TTMR"); return name;
|
2079 |
|
|
case OR32_SPG_TT_TTCR: sprintf (name, "TTCR"); return name;
|
2080 |
|
|
}
|
2081 |
|
|
|
2082 |
|
|
break;
|
2083 |
|
|
|
2084 |
|
|
case OR32_SPG_FPU:
|
2085 |
|
|
|
2086 |
|
|
break;
|
2087 |
|
|
}
|
2088 |
|
|
|
2089 |
|
|
/* Not a recognized register */
|
2090 |
|
|
strcpy (name, "");
|
2091 |
|
|
return name;
|
2092 |
|
|
|
2093 |
|
|
} /* or32_spr_register_name() */
|
2094 |
|
|
|
2095 |
|
|
|
2096 |
|
|
/*----------------------------------------------------------------------------*/
|
2097 |
|
|
/*!Get SPR group number from a name
|
2098 |
|
|
|
2099 |
|
|
@param[in] group_name SPR register group
|
2100 |
|
|
|
2101 |
|
|
@return The index, or negative if no match. */
|
2102 |
|
|
/*----------------------------------------------------------------------------*/
|
2103 |
|
|
|
2104 |
|
|
static int
|
2105 |
|
|
or32_groupnum_from_name (char *group_name)
|
2106 |
|
|
{
|
2107 |
|
|
int group;
|
2108 |
|
|
|
2109 |
|
|
for (group = 0; group < OR32_NUM_SPGS; group++)
|
2110 |
|
|
{
|
2111 |
|
|
if (0 == strcasecmp (group_name, or32_spr_group_name (group)))
|
2112 |
|
|
{
|
2113 |
|
|
return group;
|
2114 |
|
|
}
|
2115 |
|
|
}
|
2116 |
|
|
|
2117 |
|
|
return -1;
|
2118 |
|
|
|
2119 |
|
|
} /* or32_groupnum_from_name() */
|
2120 |
|
|
|
2121 |
|
|
|
2122 |
|
|
/*----------------------------------------------------------------------------*/
|
2123 |
|
|
/*!Get register index in special purpose register group from name
|
2124 |
|
|
|
2125 |
|
|
The name may either be SPR<group_num>_<index> or a known unique name. In
|
2126 |
|
|
either case the group number must match the supplied group number.
|
2127 |
|
|
|
2128 |
|
|
@param[in] group SPR register group
|
2129 |
|
|
@param[in] name Register name
|
2130 |
|
|
|
2131 |
|
|
@return The index, or negative if no match. */
|
2132 |
|
|
/*----------------------------------------------------------------------------*/
|
2133 |
|
|
|
2134 |
|
|
static int
|
2135 |
|
|
or32_regnum_from_name (int group,
|
2136 |
|
|
char *name)
|
2137 |
|
|
{
|
2138 |
|
|
/* Last valid register in each group. */
|
2139 |
|
|
static const int or32_spr_group_last[OR32_NUM_SPGS] =
|
2140 |
|
|
{
|
2141 |
|
|
OR32_SPG_SYS_LAST,
|
2142 |
|
|
OR32_SPG_DMMU_LAST,
|
2143 |
|
|
OR32_SPG_IMMU_LAST,
|
2144 |
|
|
OR32_SPG_DC_LAST,
|
2145 |
|
|
OR32_SPG_IC_LAST,
|
2146 |
|
|
OR32_SPG_MAC_LAST,
|
2147 |
|
|
OR32_SPG_DEBUG_LAST,
|
2148 |
|
|
OR32_SPG_PC_LAST,
|
2149 |
|
|
OR32_SPG_PM_LAST,
|
2150 |
|
|
OR32_SPG_PIC_LAST,
|
2151 |
|
|
OR32_SPG_TT_LAST,
|
2152 |
|
|
OR32_SPG_FPU_LAST
|
2153 |
|
|
};
|
2154 |
|
|
|
2155 |
|
|
int i;
|
2156 |
|
|
char spr_name[32];
|
2157 |
|
|
|
2158 |
|
|
if (0 == strcasecmp (name, "SPR"))
|
2159 |
|
|
{
|
2160 |
|
|
char *ptr_c;
|
2161 |
|
|
|
2162 |
|
|
/* Skip SPR */
|
2163 |
|
|
name += 3;
|
2164 |
|
|
|
2165 |
|
|
/* Get group number */
|
2166 |
|
|
i = (int) strtoul (name, &ptr_c, 10);
|
2167 |
|
|
if (*ptr_c != '_' || i != group)
|
2168 |
|
|
{
|
2169 |
|
|
return -1;
|
2170 |
|
|
}
|
2171 |
|
|
|
2172 |
|
|
/* Get index */
|
2173 |
|
|
ptr_c++;
|
2174 |
|
|
i = (int) strtoul (name, &ptr_c, 10);
|
2175 |
|
|
if (*ptr_c)
|
2176 |
|
|
{
|
2177 |
|
|
return -1;
|
2178 |
|
|
}
|
2179 |
|
|
else
|
2180 |
|
|
{
|
2181 |
|
|
return i;
|
2182 |
|
|
}
|
2183 |
|
|
}
|
2184 |
|
|
|
2185 |
|
|
/* Look for a "known" name in this group */
|
2186 |
|
|
for (i = 0; i <= or32_spr_group_last[group]; i++)
|
2187 |
|
|
{
|
2188 |
|
|
char *s = or32_spr_register_name (group, i, spr_name);
|
2189 |
|
|
|
2190 |
|
|
if (0 == strcasecmp (name, s))
|
2191 |
|
|
{
|
2192 |
|
|
return i;
|
2193 |
|
|
}
|
2194 |
|
|
}
|
2195 |
|
|
|
2196 |
|
|
/* Failure */
|
2197 |
|
|
return -1;
|
2198 |
|
|
|
2199 |
|
|
} /* or32_regnum_from_name() */
|
2200 |
|
|
|
2201 |
|
|
|
2202 |
|
|
/*----------------------------------------------------------------------------*/
|
2203 |
|
|
/*!Get the next token from a string
|
2204 |
|
|
|
2205 |
|
|
I can't believe there isn't a library argument for this, but strtok is
|
2206 |
|
|
deprecated.
|
2207 |
|
|
|
2208 |
|
|
Take a string and find the start of the next token and its length. A token
|
2209 |
|
|
is anything containing non-blank characters.
|
2210 |
|
|
|
2211 |
|
|
@param[in] str The string to look at (may be NULL).
|
2212 |
|
|
@param[out] tok Pointer to the start of the token within str. May be NULL
|
2213 |
|
|
if this result is not wanted (e.g. just the length is
|
2214 |
|
|
wanted. If no token is found will be the NULL char at the
|
2215 |
|
|
end of the string, if the original str was NULL, this will
|
2216 |
|
|
be NULL.
|
2217 |
|
|
|
2218 |
|
|
@return The length of the token found */
|
2219 |
|
|
/*----------------------------------------------------------------------------*/
|
2220 |
|
|
|
2221 |
|
|
static int
|
2222 |
|
|
or32_tokenize (char *str,
|
2223 |
|
|
char **tok)
|
2224 |
|
|
{
|
2225 |
|
|
char *ptr;
|
2226 |
|
|
int len;
|
2227 |
|
|
|
2228 |
|
|
/* Deal with NULL argument */
|
2229 |
|
|
if (NULL == str)
|
2230 |
|
|
{
|
2231 |
|
|
if (NULL != tok)
|
2232 |
|
|
{
|
2233 |
|
|
*tok = NULL;
|
2234 |
|
|
}
|
2235 |
|
|
return 0;
|
2236 |
|
|
}
|
2237 |
|
|
|
2238 |
|
|
/* Find the start */
|
2239 |
|
|
for (ptr = str; ISBLANK (*ptr) ; ptr++)
|
2240 |
|
|
{
|
2241 |
|
|
continue;
|
2242 |
|
|
}
|
2243 |
|
|
|
2244 |
|
|
/* Return the start pointer if requested */
|
2245 |
|
|
if (NULL != tok)
|
2246 |
|
|
{
|
2247 |
|
|
*tok = ptr;
|
2248 |
|
|
}
|
2249 |
|
|
|
2250 |
|
|
/* Find the end and put in EOS */
|
2251 |
|
|
for (len = 0; ('\0' != ptr[len]) && (!ISBLANK (ptr[len])); len++)
|
2252 |
|
|
{
|
2253 |
|
|
continue;
|
2254 |
|
|
}
|
2255 |
|
|
|
2256 |
|
|
return len;
|
2257 |
|
|
|
2258 |
|
|
} /* or32_tokenize() */
|
2259 |
|
|
|
2260 |
|
|
|
2261 |
|
|
/*----------------------------------------------------------------------------*/
|
2262 |
|
|
/*!Parses args for spr commands
|
2263 |
|
|
|
2264 |
|
|
Determines the special purpose register (SPR) name and puts result into
|
2265 |
|
|
group and index
|
2266 |
|
|
|
2267 |
|
|
Syntax is:
|
2268 |
|
|
|
2269 |
|
|
@verbatim
|
2270 |
|
|
<spr_args> -> <group_ref> | <reg_name>
|
2271 |
|
|
<group_ref> -> <group_id> <index>
|
2272 |
|
|
<group_id> -> <group_num> | <group_name>
|
2273 |
|
|
@endverbatim
|
2274 |
|
|
|
2275 |
|
|
Where the indices/names have to be valid.
|
2276 |
|
|
|
2277 |
|
|
So to parse, we look for 1 or 2 args. If 1 it must be a unique register
|
2278 |
|
|
name. If 2, the first must be a group number or name and the second an
|
2279 |
|
|
index within that group.
|
2280 |
|
|
|
2281 |
|
|
Also responsible for providing diagnostics if the arguments do not match.
|
2282 |
|
|
|
2283 |
|
|
Rewritten for GDB 6.8 to use the new UI calls and remove assorted
|
2284 |
|
|
bugs. Syntax also slightly restricted to be more comprehensible.
|
2285 |
|
|
|
2286 |
|
|
@param[in] arg_str The argument string
|
2287 |
|
|
@param[out] group The group this SPR belongs in, or -1 to indicate
|
2288 |
|
|
failure
|
2289 |
|
|
@param[out] index Index of the register within the group, or -1 to
|
2290 |
|
|
indicate the whole group
|
2291 |
|
|
@param[in] is_set 1 (true) if we are called from the "spr" command (so
|
2292 |
|
|
there is an extra arg) rather than the "info spr"
|
2293 |
|
|
command. Needed to distinguish between the case where
|
2294 |
|
|
info is sought from a register specified as group and
|
2295 |
|
|
index and setting a uniquely identified register to a
|
2296 |
|
|
value.
|
2297 |
|
|
|
2298 |
|
|
@return A pointer to any remaining args */
|
2299 |
|
|
/*---------------------------------------------------------------------------*/
|
2300 |
|
|
|
2301 |
|
|
static char *
|
2302 |
|
|
or32_parse_spr_params (char *arg_str,
|
2303 |
|
|
int *group,
|
2304 |
|
|
int *index,
|
2305 |
|
|
int is_set)
|
2306 |
|
|
{
|
2307 |
|
|
struct {
|
2308 |
|
|
char *str;
|
2309 |
|
|
int len;
|
2310 |
|
|
unsigned long int val;
|
2311 |
|
|
int is_num;
|
2312 |
|
|
} arg[3] = {
|
2313 |
|
|
{
|
2314 |
|
|
.str = NULL,
|
2315 |
|
|
.len = 0,
|
2316 |
|
|
.val = 0,
|
2317 |
|
|
.is_num = 0,
|
2318 |
|
|
},
|
2319 |
|
|
{
|
2320 |
|
|
.str = NULL,
|
2321 |
|
|
.len = 0,
|
2322 |
|
|
.val = 0,
|
2323 |
|
|
.is_num = 0,
|
2324 |
|
|
},
|
2325 |
|
|
{
|
2326 |
|
|
.str = NULL,
|
2327 |
|
|
.len = 0,
|
2328 |
|
|
.val = 0,
|
2329 |
|
|
.is_num = 0,
|
2330 |
|
|
}
|
2331 |
|
|
};
|
2332 |
|
|
|
2333 |
|
|
int num_args;
|
2334 |
|
|
char *trailer = arg_str;
|
2335 |
|
|
char *tmp_str;
|
2336 |
|
|
int i;
|
2337 |
|
|
|
2338 |
|
|
char spr_name[32];
|
2339 |
|
|
|
2340 |
|
|
/* Break out the arguments. Note that the strings are NOT null terminated
|
2341 |
|
|
(we don't want to change arg_str), so we must rely on len. The stroul
|
2342 |
|
|
call will still work, since there is always a non-digit char (possibly EOS)
|
2343 |
|
|
after the last digit. */
|
2344 |
|
|
if (NULL == arg_str)
|
2345 |
|
|
{
|
2346 |
|
|
num_args = 0;
|
2347 |
|
|
}
|
2348 |
|
|
else
|
2349 |
|
|
{
|
2350 |
|
|
for (num_args = 0; num_args < 3; num_args++)
|
2351 |
|
|
{
|
2352 |
|
|
arg[num_args].len = or32_tokenize (trailer, &(arg[num_args].str));
|
2353 |
|
|
trailer = arg[num_args].str + arg[num_args].len;
|
2354 |
|
|
|
2355 |
|
|
if (0 == arg[num_args].len)
|
2356 |
|
|
{
|
2357 |
|
|
break;
|
2358 |
|
|
}
|
2359 |
|
|
}
|
2360 |
|
|
}
|
2361 |
|
|
|
2362 |
|
|
/* Patch nulls into the arg strings and see about values. Couldn't do this
|
2363 |
|
|
earlier, since we needed the next char clean to check later args. This
|
2364 |
|
|
means advancing trailer, UNLESS it was already at EOS */
|
2365 |
|
|
|
2366 |
|
|
if((NULL != arg_str) && ('\0' != *trailer))
|
2367 |
|
|
{
|
2368 |
|
|
trailer++;
|
2369 |
|
|
}
|
2370 |
|
|
|
2371 |
|
|
for (i = 0; i < num_args; i++)
|
2372 |
|
|
{
|
2373 |
|
|
(arg[i].str)[arg[i].len] = '\0';
|
2374 |
|
|
errno = 0;
|
2375 |
|
|
arg[i].val = strtoul (arg[i].str, &tmp_str, 0);
|
2376 |
|
|
arg[i].is_num = (0 == errno) && ('\0' == *tmp_str);
|
2377 |
|
|
}
|
2378 |
|
|
|
2379 |
|
|
/* Deal with the case where we are setting a register, so the final argument
|
2380 |
|
|
should be disregarded (it is the trailer). Do this anyway if we get a
|
2381 |
|
|
third argument */
|
2382 |
|
|
if ((is_set & (num_args > 0)) || (num_args > 2))
|
2383 |
|
|
{
|
2384 |
|
|
trailer = arg[num_args - 1].str;
|
2385 |
|
|
num_args--;
|
2386 |
|
|
}
|
2387 |
|
|
|
2388 |
|
|
/* Deal with different numbers of args */
|
2389 |
|
|
|
2390 |
|
|
switch (num_args)
|
2391 |
|
|
{
|
2392 |
|
|
|
2393 |
|
|
case 0:
|
2394 |
|
|
ui_out_message (uiout, 0,
|
2395 |
|
|
"Usage: <command> <register> |\n"
|
2396 |
|
|
" <command> <group> |\n"
|
2397 |
|
|
" <command> <group> <index>\n"
|
2398 |
|
|
"Valid groups are:\n");
|
2399 |
|
|
for (i = 0; i < OR32_NUM_SPGS; i++)
|
2400 |
|
|
{
|
2401 |
|
|
ui_out_field_string (uiout, NULL, or32_spr_group_name (i));
|
2402 |
|
|
ui_out_spaces (uiout, 1);
|
2403 |
|
|
ui_out_wrap_hint (uiout, NULL);
|
2404 |
|
|
}
|
2405 |
|
|
ui_out_field_string (uiout, NULL, "\n");
|
2406 |
|
|
|
2407 |
|
|
*index = -1;
|
2408 |
|
|
return trailer;
|
2409 |
|
|
|
2410 |
|
|
case 1:
|
2411 |
|
|
/* See if it is a numeric group */
|
2412 |
|
|
if (arg[0].is_num)
|
2413 |
|
|
{
|
2414 |
|
|
if (arg[0].val < OR32_NUM_SPGS)
|
2415 |
|
|
{
|
2416 |
|
|
*group = arg[0].val;
|
2417 |
|
|
*index = -1;
|
2418 |
|
|
return trailer;
|
2419 |
|
|
}
|
2420 |
|
|
else
|
2421 |
|
|
{
|
2422 |
|
|
ui_out_message (uiout, 0,
|
2423 |
|
|
"Group index should be in the range 0 - %d\n",
|
2424 |
|
|
OR32_NUM_SPGS);
|
2425 |
|
|
*group = -1;
|
2426 |
|
|
*index = -1;
|
2427 |
|
|
return trailer;
|
2428 |
|
|
}
|
2429 |
|
|
}
|
2430 |
|
|
|
2431 |
|
|
/* Is is it a group name? */
|
2432 |
|
|
*group = or32_groupnum_from_name (arg[0].str);
|
2433 |
|
|
if (*group >= 0)
|
2434 |
|
|
{
|
2435 |
|
|
*index = -1;
|
2436 |
|
|
return trailer;
|
2437 |
|
|
}
|
2438 |
|
|
|
2439 |
|
|
/* See if it is a valid register name in any group */
|
2440 |
|
|
for (*group = 0; *group < OR32_NUM_SPGS; (*group)++)
|
2441 |
|
|
{
|
2442 |
|
|
*index = or32_regnum_from_name (*group, arg[0].str);
|
2443 |
|
|
|
2444 |
|
|
if (*index >= 0)
|
2445 |
|
|
{
|
2446 |
|
|
return trailer;
|
2447 |
|
|
}
|
2448 |
|
|
}
|
2449 |
|
|
|
2450 |
|
|
/* Couldn't find it - print out a rude message */
|
2451 |
|
|
ui_out_message (uiout, 0,
|
2452 |
|
|
"Group or register name not recognized.\n"
|
2453 |
|
|
"Valid groups are:\n");
|
2454 |
|
|
for (i = 0; i < OR32_NUM_SPGS; i++)
|
2455 |
|
|
{
|
2456 |
|
|
ui_out_field_string (uiout, NULL, or32_spr_group_name (i));
|
2457 |
|
|
ui_out_spaces (uiout, 1);
|
2458 |
|
|
ui_out_wrap_hint (uiout, NULL);
|
2459 |
|
|
}
|
2460 |
|
|
ui_out_field_string (uiout, NULL, "\n");
|
2461 |
|
|
|
2462 |
|
|
*group = -1;
|
2463 |
|
|
*index = -1;
|
2464 |
|
|
return trailer;
|
2465 |
|
|
|
2466 |
|
|
case 2:
|
2467 |
|
|
/* See if first arg is a numeric group */
|
2468 |
|
|
if (arg[0].is_num)
|
2469 |
|
|
{
|
2470 |
|
|
if (arg[0].val < OR32_NUM_SPGS)
|
2471 |
|
|
{
|
2472 |
|
|
*group = arg[0].val;
|
2473 |
|
|
*index = -1;
|
2474 |
|
|
}
|
2475 |
|
|
else
|
2476 |
|
|
{
|
2477 |
|
|
ui_out_message (uiout, 0,
|
2478 |
|
|
"Group index should be in the range 0 - %d\n",
|
2479 |
|
|
OR32_NUM_SPGS - 1);
|
2480 |
|
|
*group = -1;
|
2481 |
|
|
*index = -1;
|
2482 |
|
|
return trailer;
|
2483 |
|
|
}
|
2484 |
|
|
}
|
2485 |
|
|
else
|
2486 |
|
|
{
|
2487 |
|
|
/* Is is it a group name? */
|
2488 |
|
|
*group = or32_groupnum_from_name (arg[0].str);
|
2489 |
|
|
if (*group >= 0)
|
2490 |
|
|
{
|
2491 |
|
|
*index = -1;
|
2492 |
|
|
}
|
2493 |
|
|
else
|
2494 |
|
|
{
|
2495 |
|
|
ui_out_message (uiout, 0,
|
2496 |
|
|
"Group name not recognized.\n"
|
2497 |
|
|
"Valid groups are:\n");
|
2498 |
|
|
for (i = 0; i < OR32_NUM_SPGS; i++)
|
2499 |
|
|
{
|
2500 |
|
|
ui_out_field_string (uiout, NULL, or32_spr_group_name (i));
|
2501 |
|
|
ui_out_spaces (uiout, 1);
|
2502 |
|
|
ui_out_wrap_hint (uiout, NULL);
|
2503 |
|
|
}
|
2504 |
|
|
ui_out_field_string (uiout, NULL, "\n");
|
2505 |
|
|
|
2506 |
|
|
*group = -1;
|
2507 |
|
|
*index = -1;
|
2508 |
|
|
return trailer;
|
2509 |
|
|
}
|
2510 |
|
|
}
|
2511 |
|
|
|
2512 |
|
|
/* Is second arg an index or name? */
|
2513 |
|
|
if (arg[1].is_num)
|
2514 |
|
|
{
|
2515 |
|
|
if (arg[1].val < OR32_SPG_SIZE)
|
2516 |
|
|
{
|
2517 |
|
|
/* Check this really is a register */
|
2518 |
|
|
if (0 != strlen (or32_spr_register_name (*group, arg[1].val,
|
2519 |
|
|
spr_name)))
|
2520 |
|
|
{
|
2521 |
|
|
*index = arg[1].val;
|
2522 |
|
|
return trailer;
|
2523 |
|
|
}
|
2524 |
|
|
else
|
2525 |
|
|
{
|
2526 |
|
|
ui_out_message (uiout, 0,
|
2527 |
|
|
"No valid register at that index in group\n");
|
2528 |
|
|
*group = -1;
|
2529 |
|
|
*index = -1;
|
2530 |
|
|
return trailer;
|
2531 |
|
|
}
|
2532 |
|
|
}
|
2533 |
|
|
else
|
2534 |
|
|
{
|
2535 |
|
|
ui_out_message (uiout, 0,
|
2536 |
|
|
"Register index should be in the range 0 - %d\n",
|
2537 |
|
|
OR32_SPG_SIZE - 1);
|
2538 |
|
|
*group = -1;
|
2539 |
|
|
*index = -1;
|
2540 |
|
|
return trailer;
|
2541 |
|
|
}
|
2542 |
|
|
}
|
2543 |
|
|
|
2544 |
|
|
/* Must be a name */
|
2545 |
|
|
*index = or32_regnum_from_name (*group, arg[1].str);
|
2546 |
|
|
|
2547 |
|
|
if (*index >= 0)
|
2548 |
|
|
{
|
2549 |
|
|
return trailer;
|
2550 |
|
|
}
|
2551 |
|
|
|
2552 |
|
|
/* Couldn't find it - print out a rude message */
|
2553 |
|
|
ui_out_message (uiout, 0, "Register name not recognized in group.\n");
|
2554 |
|
|
*group = -1;
|
2555 |
|
|
*index = -1;
|
2556 |
|
|
return trailer;
|
2557 |
|
|
|
2558 |
|
|
default:
|
2559 |
|
|
/* Anything else is an error */
|
2560 |
|
|
ui_out_message (uiout, 0, "Unable to parse arguments\n");
|
2561 |
|
|
*group = -1;
|
2562 |
|
|
*index = -1;
|
2563 |
|
|
return trailer;
|
2564 |
|
|
}
|
2565 |
|
|
} /* or32_parse_spr_params() */
|
2566 |
|
|
|
2567 |
|
|
|
2568 |
|
|
/*---------------------------------------------------------------------------*/
|
2569 |
|
|
/*!Read a special purpose register from the target
|
2570 |
|
|
|
2571 |
|
|
This has to be done using the target remote command "readspr"
|
2572 |
|
|
|
2573 |
|
|
@param[in] regnum The register to read
|
2574 |
|
|
|
2575 |
|
|
@return The value read */
|
2576 |
|
|
/*---------------------------------------------------------------------------*/
|
2577 |
|
|
|
2578 |
|
|
static ULONGEST
|
2579 |
|
|
or32_read_spr (unsigned int regnum)
|
2580 |
|
|
{
|
2581 |
|
|
struct ui_file *uibuf = mem_fileopen ();
|
2582 |
|
|
char cmd[sizeof ("readspr ffff")];
|
2583 |
|
|
unsigned long int data;
|
2584 |
|
|
char *res;
|
2585 |
|
|
long int len;
|
2586 |
|
|
|
2587 |
|
|
/* Create the command string and pass it to target remote command function */
|
2588 |
|
|
sprintf (cmd, "readspr %4x", regnum);
|
2589 |
|
|
target_rcmd (cmd, uibuf);
|
2590 |
|
|
|
2591 |
|
|
/* Get the output for the UI file as a string */
|
2592 |
|
|
res = ui_file_xstrdup (uibuf, &len);
|
2593 |
|
|
sscanf (res, "%lx", &data);
|
2594 |
|
|
|
2595 |
|
|
/* Tidy up */
|
2596 |
|
|
xfree (res);
|
2597 |
|
|
ui_file_delete (uibuf);
|
2598 |
|
|
|
2599 |
|
|
return (ULONGEST)data;
|
2600 |
|
|
|
2601 |
|
|
} /* or32_read_spr() */
|
2602 |
|
|
|
2603 |
|
|
|
2604 |
|
|
/*---------------------------------------------------------------------------*/
|
2605 |
|
|
/*!Write a special purpose register on the target
|
2606 |
|
|
|
2607 |
|
|
This has to be done using the target remote command "writespr"
|
2608 |
|
|
|
2609 |
|
|
Since the SPRs may map to GPR's or the other GDB register (PPC, NPC, SR),
|
2610 |
|
|
any register cache is flushed.
|
2611 |
|
|
|
2612 |
|
|
@param[in] regnum The register to write
|
2613 |
|
|
@param[in] data The value to write */
|
2614 |
|
|
/*---------------------------------------------------------------------------*/
|
2615 |
|
|
|
2616 |
|
|
static void
|
2617 |
|
|
or32_write_spr (unsigned int regnum,
|
2618 |
|
|
ULONGEST data)
|
2619 |
|
|
{
|
2620 |
|
|
struct ui_file *uibuf = mem_fileopen ();
|
2621 |
|
|
char cmd[sizeof ("writespr ffff ffffffff")];
|
2622 |
|
|
char *res;
|
2623 |
|
|
long int len;
|
2624 |
|
|
|
2625 |
|
|
/* Create the command string and pass it to target remote command function */
|
2626 |
|
|
sprintf (cmd, "writespr %4x %8llx", regnum, (long long unsigned int)data);
|
2627 |
|
|
target_rcmd (cmd, uibuf);
|
2628 |
|
|
|
2629 |
|
|
/* Flush the register cache */
|
2630 |
|
|
registers_changed ();
|
2631 |
|
|
|
2632 |
|
|
/* We ignore the result - Rcmd can put out its own error messages. Just
|
2633 |
|
|
tidy up */
|
2634 |
|
|
ui_file_delete (uibuf);
|
2635 |
|
|
|
2636 |
|
|
} /* or32_write_spr() */
|
2637 |
|
|
|
2638 |
|
|
|
2639 |
|
|
/*----------------------------------------------------------------------------*/
|
2640 |
|
|
/*!Show the value of a special purpose register or group
|
2641 |
|
|
|
2642 |
|
|
This is a custom extension to the GDB info command.
|
2643 |
|
|
|
2644 |
|
|
@param[in] args
|
2645 |
|
|
@param[in] from_tty True (1) if GDB is running from a TTY, false (0)
|
2646 |
|
|
otherwise. */
|
2647 |
|
|
/*---------------------------------------------------------------------------*/
|
2648 |
|
|
|
2649 |
|
|
static void
|
2650 |
|
|
or32_info_spr_command (char *args,
|
2651 |
|
|
int from_tty)
|
2652 |
|
|
{
|
2653 |
|
|
int group;
|
2654 |
|
|
int index;
|
2655 |
|
|
|
2656 |
|
|
char spr_name[32];
|
2657 |
|
|
|
2658 |
|
|
or32_parse_spr_params (args, &group, &index, 0);
|
2659 |
|
|
|
2660 |
|
|
if (group < 0)
|
2661 |
|
|
{
|
2662 |
|
|
return; /* Couldn't parse the args */
|
2663 |
|
|
}
|
2664 |
|
|
|
2665 |
|
|
if (index >= 0)
|
2666 |
|
|
{
|
2667 |
|
|
ULONGEST value = or32_read_spr (OR32_SPR (group, index));
|
2668 |
|
|
|
2669 |
|
|
ui_out_field_fmt (uiout, NULL, "%s.%s = SPR%i_%i = %llu (0x%llx)\n",
|
2670 |
|
|
or32_spr_group_name (group),
|
2671 |
|
|
or32_spr_register_name (group, index, spr_name), group,
|
2672 |
|
|
index, (long long unsigned int)value, (long long unsigned int)value);
|
2673 |
|
|
}
|
2674 |
|
|
else
|
2675 |
|
|
{
|
2676 |
|
|
/* Print all valid registers in the group */
|
2677 |
|
|
for (index = 0; index < OR32_SPG_SIZE; index++)
|
2678 |
|
|
{
|
2679 |
|
|
if (0 != strlen (or32_spr_register_name (group, index, spr_name)))
|
2680 |
|
|
{
|
2681 |
|
|
ULONGEST value = or32_read_spr (OR32_SPR (group, index));
|
2682 |
|
|
|
2683 |
|
|
ui_out_field_fmt (uiout, NULL,
|
2684 |
|
|
"%s.%s = SPR%i_%i = %llu (0x%llx)\n",
|
2685 |
|
|
or32_spr_group_name (group),
|
2686 |
|
|
or32_spr_register_name (group, index, spr_name),
|
2687 |
|
|
group, index, (long long unsigned int)value, (long long unsigned int)value);
|
2688 |
|
|
}
|
2689 |
|
|
}
|
2690 |
|
|
}
|
2691 |
|
|
} /* or32_info_spr_command() */
|
2692 |
|
|
|
2693 |
|
|
|
2694 |
|
|
/*----------------------------------------------------------------------------*/
|
2695 |
|
|
/*!Set a special purpose register
|
2696 |
|
|
|
2697 |
|
|
This is a custom command added to GDB.
|
2698 |
|
|
|
2699 |
|
|
@param[in] args
|
2700 |
|
|
@param[in] from_tty True (1) if GDB is running from a TTY, false (0)
|
2701 |
|
|
otherwise. */
|
2702 |
|
|
/*---------------------------------------------------------------------------*/
|
2703 |
|
|
|
2704 |
|
|
static void
|
2705 |
|
|
or32_spr_command (char *args,
|
2706 |
|
|
int from_tty)
|
2707 |
|
|
{
|
2708 |
|
|
int group;
|
2709 |
|
|
int index;
|
2710 |
|
|
char *tmp_str;
|
2711 |
|
|
char *nargs = or32_parse_spr_params (args, &group, &index, 1);
|
2712 |
|
|
|
2713 |
|
|
ULONGEST old_val;
|
2714 |
|
|
ULONGEST new_val;
|
2715 |
|
|
|
2716 |
|
|
char spr_name[32];
|
2717 |
|
|
|
2718 |
|
|
/* Do we have a valid register spec? */
|
2719 |
|
|
if (index < 0)
|
2720 |
|
|
{
|
2721 |
|
|
return; /* Parser will have printed the error message */
|
2722 |
|
|
}
|
2723 |
|
|
|
2724 |
|
|
/* Do we have a value to set? */
|
2725 |
|
|
|
2726 |
|
|
errno = 0;
|
2727 |
|
|
new_val = (ULONGEST)strtoul (nargs, &tmp_str, 0);
|
2728 |
|
|
|
2729 |
|
|
if((0 != errno) || ('\0' != *tmp_str))
|
2730 |
|
|
{
|
2731 |
|
|
ui_out_message (uiout, 0, "Invalid value - register not changed\n");
|
2732 |
|
|
return;
|
2733 |
|
|
}
|
2734 |
|
|
|
2735 |
|
|
old_val = or32_read_spr (OR32_SPR (group, index));
|
2736 |
|
|
|
2737 |
|
|
or32_write_spr (OR32_SPR (group, index) , new_val);
|
2738 |
|
|
|
2739 |
|
|
ui_out_field_fmt (uiout, NULL,
|
2740 |
|
|
"%s.%s (SPR%i_%i) set to %llu (0x%llx), "
|
2741 |
|
|
"was: %llu (0x%llx)\n",
|
2742 |
|
|
or32_spr_group_name (group),
|
2743 |
|
|
or32_spr_register_name (group, index, spr_name) , group,
|
2744 |
|
|
index, (long long unsigned int)new_val, (long long unsigned int)new_val, (long long unsigned int)old_val, (long long unsigned int)old_val);
|
2745 |
|
|
|
2746 |
|
|
} /* or32_spr_command() */
|
2747 |
|
|
|
2748 |
|
|
|
2749 |
|
|
/*----------------------------------------------------------------------------*/
|
2750 |
|
|
/*!Main entry point for target architecture initialization
|
2751 |
|
|
|
2752 |
|
|
In this version initializes the architecture via
|
2753 |
|
|
registers_gdbarch_init(). Add a command to set and show special purpose
|
2754 |
|
|
registers. */
|
2755 |
|
|
/*---------------------------------------------------------------------------*/
|
2756 |
|
|
|
2757 |
|
|
void
|
2758 |
|
|
_initialize_or32_tdep (void)
|
2759 |
|
|
{
|
2760 |
|
|
/* Register this architecture. We should do this for or16 and or64 when
|
2761 |
|
|
they have their BFD defined. */
|
2762 |
|
|
gdbarch_register (bfd_arch_or32, or32_gdbarch_init, or32_dump_tdep);
|
2763 |
|
|
|
2764 |
|
|
/* Initialize the automata for the assembler */
|
2765 |
|
|
build_automata();
|
2766 |
|
|
|
2767 |
|
|
/* Commands to show and set special purpose registers */
|
2768 |
|
|
add_info ("spr", or32_info_spr_command,
|
2769 |
|
|
"Show the value of a special purpose register");
|
2770 |
|
|
add_com ("spr", class_support, or32_spr_command,
|
2771 |
|
|
"Set a special purpose register");
|
2772 |
|
|
|
2773 |
|
|
} /* _initialize_or32_tdep() */
|