* [commit] Take into account Xtensa TX
@ 2011-03-09 2:22 Maxim Grigoriev
2011-03-09 3:51 ` Joel Brobecker
0 siblings, 1 reply; 2+ messages in thread
From: Maxim Grigoriev @ 2011-03-09 2:22 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 89 bytes --]
Update Xtensa frame analysis to take TX into account.
Add some other cosmetic changes.
[-- Attachment #2: TX.diff --]
[-- Type: text/plain, Size: 5029 bytes --]
2011-03-08 Maxim Grigoriev <maxim2405@gmail.com>
* xtensa-tdep.c (TX_PS): New.
(windowing_enabled): Update to count for Call0 ABI.
(xtensa_hextochar): New.
(xtensa_init_reggroups): Make algorithm generic.
(xtensa_frame_cache): Use TX_PS on Tiny Xtensa.
Index: gdb/xtensa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xtensa-tdep.c,v
retrieving revision 1.47
diff -u -r1.47 xtensa-tdep.c
--- gdb/xtensa-tdep.c 12 Jan 2011 01:23:29 -0000 1.47
+++ gdb/xtensa-tdep.c 9 Mar 2011 00:30:54 -0000
@@ -91,6 +91,11 @@
#define CALLINC(ps) (((ps) & PS_CALLINC_MASK) >> PS_CALLINC_SHIFT)
#define WINSIZE(ra) (4 * (( (ra) >> 30) & 0x3))
+/* On TX, hardware can be configured without Exception Option.
+ There is no PS register in this case. Inside XT-GDB, let us treat
+ it as a virtual read-only register always holding the same value. */
+#define TX_PS 0x20
+
/* ABI-independent macros. */
#define ARG_NOF(gdbarch) \
(gdbarch_tdep (gdbarch)->call_abi \
@@ -116,6 +121,16 @@
#define PS_WOE (1<<18)
#define PS_EXC (1<<4)
+static inline int
+windowing_enabled (struct gdbarch *gdbarch, unsigned int ps)
+{
+ /* If we know CALL0 ABI is set explicitly, say it is Call0. */
+ if (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only)
+ return 0;
+
+ return ((ps & PS_EXC) == 0 && (ps & PS_WOE) != 0);
+}
+
/* Convert a live A-register number to the corresponding AR-register
number. */
static int
@@ -146,12 +161,6 @@
return (areg > 15) ? -1 : areg;
}
-static inline int
-windowing_enabled (CORE_ADDR ps)
-{
- return ((ps & PS_EXC) == 0 && (ps & PS_WOE) != 0);
-}
-
/* Return the window size of the previous call to the function from which we
have just returned.
@@ -692,6 +701,13 @@
_("invalid register number %d"), regnum);
}
+static inline char xtensa_hextochar (int xdigit)
+{
+ static char hex[]="0123456789abcdef";
+
+ return hex[xdigit & 0x0f];
+}
+
static struct reggroup *xtensa_ar_reggroup;
static struct reggroup *xtensa_user_reggroup;
static struct reggroup *xtensa_vectra_reggroup;
@@ -700,18 +716,18 @@
static void
xtensa_init_reggroups (void)
{
+ int i;
+ char cpname[] = "cp0";
+
xtensa_ar_reggroup = reggroup_new ("ar", USER_REGGROUP);
xtensa_user_reggroup = reggroup_new ("user", USER_REGGROUP);
xtensa_vectra_reggroup = reggroup_new ("vectra", USER_REGGROUP);
- xtensa_cp[0] = reggroup_new ("cp0", USER_REGGROUP);
- xtensa_cp[1] = reggroup_new ("cp1", USER_REGGROUP);
- xtensa_cp[2] = reggroup_new ("cp2", USER_REGGROUP);
- xtensa_cp[3] = reggroup_new ("cp3", USER_REGGROUP);
- xtensa_cp[4] = reggroup_new ("cp4", USER_REGGROUP);
- xtensa_cp[5] = reggroup_new ("cp5", USER_REGGROUP);
- xtensa_cp[6] = reggroup_new ("cp6", USER_REGGROUP);
- xtensa_cp[7] = reggroup_new ("cp7", USER_REGGROUP);
+ for (i = 0; i < XTENSA_MAX_COPROCESSOR; i++)
+ {
+ cpname[2] = xtensa_hextochar (i);
+ xtensa_cp[i] = reggroup_new (cpname, USER_REGGROUP);
+ }
}
static void
@@ -1187,23 +1203,26 @@
struct gdbarch *gdbarch = get_frame_arch (this_frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int fp_regnum;
- char op1;
- int windowed;
+ int windowed, ps_regnum;
if (*this_cache)
return *this_cache;
- ps = get_frame_register_unsigned (this_frame, gdbarch_ps_regnum (gdbarch));
- windowed = windowing_enabled (ps);
+ pc = get_frame_register_unsigned (this_frame, gdbarch_pc_regnum (gdbarch));
+ ps_regnum = gdbarch_ps_regnum (gdbarch);
+ ps = (ps_regnum >= 0)
+ ? get_frame_register_unsigned (this_frame, ps_regnum) : TX_PS;
+
+ windowed = windowing_enabled (gdbarch, ps);
/* Get pristine xtensa-frame. */
cache = xtensa_alloc_frame_cache (windowed);
*this_cache = cache;
- pc = get_frame_register_unsigned (this_frame, gdbarch_pc_regnum (gdbarch));
-
if (windowed)
{
+ char op1;
+
/* Get WINDOWBASE, WINDOWSTART, and PS registers. */
wb = get_frame_register_unsigned (this_frame,
gdbarch_tdep (gdbarch)->wb_regnum);
@@ -1228,7 +1247,7 @@
just about to execute ENTRY. SP hasn't been set yet.
We can assume any frame size, because it does not
matter, and, let's fake frame base in cache. */
- cache->base = cache->prev_sp + 16;
+ cache->base = cache->prev_sp - 16;
cache->pc = pc;
cache->ra = (cache->pc & 0xc0000000) | (ra & 0x3fffffff);
@@ -1820,9 +1839,10 @@
if (gdbarch_tdep (gdbarch)->call_abi != CallAbiCall0Only)
{
+ ULONGEST val;
ra = (bp_addr & 0x3fffffff) | 0x40000000;
- regcache_raw_read (regcache, gdbarch_ps_regnum (gdbarch), buf);
- ps = extract_unsigned_integer (buf, 4, byte_order) & ~0x00030000;
+ regcache_raw_read_unsigned (regcache, gdbarch_ps_regnum (gdbarch), &val);
+ ps = (unsigned long) val & ~0x00030000;
regcache_cooked_write_unsigned
(regcache, gdbarch_tdep (gdbarch)->a0_base + 4, ra);
regcache_cooked_write_unsigned (regcache,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [commit] Take into account Xtensa TX
2011-03-09 2:22 [commit] Take into account Xtensa TX Maxim Grigoriev
@ 2011-03-09 3:51 ` Joel Brobecker
0 siblings, 0 replies; 2+ messages in thread
From: Joel Brobecker @ 2011-03-09 3:51 UTC (permalink / raw)
To: Maxim Grigoriev; +Cc: gdb-patches
> 2011-03-08 Maxim Grigoriev <maxim2405@gmail.com>
>
> * xtensa-tdep.c (TX_PS): New.
> (windowing_enabled): Update to count for Call0 ABI.
> (xtensa_hextochar): New.
> (xtensa_init_reggroups): Make algorithm generic.
> (xtensa_frame_cache): Use TX_PS on Tiny Xtensa.
Just a few minor comments...
> +/* On TX, hardware can be configured without Exception Option.
> + There is no PS register in this case. Inside XT-GDB, let us treat
> + it as a virtual read-only register always holding the same value. */
Not really an issue, but we don't need 2 spaces after commas, only
after periods.
> +static inline char xtensa_hextochar (int xdigit)
Formatting:
static inline char
xtensa_hextochar (int xdigit)
Also, we really would like to have every function documented.
While we can't go back and document everything that already
exists, we can try to make an effort for new functions...
> +{
> + static char hex[]="0123456789abcdef";
space around '='.
> + return hex[xdigit & 0x0f];
Why do you need the 0xf? Just a precaution? I would use a gdb_assert,
if you are about this. Note that instead of using a character array,
you can also return '0' + xdigit.
> + ps = (ps_regnum >= 0)
> + ? get_frame_register_unsigned (this_frame, ps_regnum) : TX_PS;
The GNU coding style recommends the use of parentheses in this case
(and the parens around ps_regnum >= 0 are superfluous. Thus:
ps = (ps_regnum >= 0
? get_frame_register_unsigned (this_frame, ps_regnum) : TX_PS)
> if (gdbarch_tdep (gdbarch)->call_abi != CallAbiCall0Only)
> {
> + ULONGEST val;
> ra = (bp_addr & 0x3fffffff) | 0x40000000;
> - regcache_raw_read (regcache, gdbarch_ps_regnum (gdbarch), buf);
Empty line between variable declarations and the first statement.
(this is a GDB convention)
--
Joel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-09 3:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-09 2:22 [commit] Take into account Xtensa TX Maxim Grigoriev
2011-03-09 3:51 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox