* [rfc] [05/05] Get rid of current_gdbarch in xtensa
@ 2007-11-07 11:13 Markus Deuling
2007-11-08 21:55 ` Ulrich Weigand
0 siblings, 1 reply; 9+ messages in thread
From: Markus Deuling @ 2007-11-07 11:13 UTC (permalink / raw)
To: GDB Patches; +Cc: Ulrich Weigand
[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]
Hi,
this patch removes another bunch of current_gdbarch's in xtensa port.
There was the AREG_NUMBER macro which is very complicated and hard to understand. I replaced
this one by a function which is equivalent (proven by a little test programm).
I'd really like to see a testsuite run on xtensa with this patch but I don't have access to such a machine.
Maybe anyone of you has and is willing to test the patch? This would be great.
Furthermore this patch add gdbarch to some of the macros and replaces current_gdbarch with it.
Tested by building with --target=xtensa. Ok to commit?
ChangeLog:
* xtensa-tdep.c (ARG_1ST): Replace ARGS_FIRST_REG by its expression.
(ARGS_FIRST_REG): Remove.
(areg_numer): New function.
(xtensa_pseudo_register_read, xtensa_frame_prev_register)
(xtensa_extract_return_value, xtensa_store_return_value)
(xtensa_frame_cache): Replace AREG_NUMBER by areg_number.
(AREG_NUMBER): Remove.
(XTENSA_IS_ENTRY, ARG_NOF, ARG_1ST): Add gdbarch as parameter.
(xtensa_frame_cache): Update use of XTENSA_IS_ENTRY.
(xtensa_push_dummy_call): Update use of ARG_NOF.
(extract_call_winsize): Add gdbarch as parameter. Replace
current_gdbarch by gdbarch.
(xtensa_extract_return_value, xtensa_store_return_value): Update call
of extract_call_winsize.
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-xtensa --]
[-- Type: text/plain, Size: 8042 bytes --]
diff -urpN src/gdb/xtensa-tdep.c dev2/gdb/xtensa-tdep.c
--- src/gdb/xtensa-tdep.c 2007-11-07 07:44:40.000000000 +0100
+++ dev2/gdb/xtensa-tdep.c 2007-11-07 11:50:52.000000000 +0100
@@ -78,7 +78,6 @@ static int xtensa_debug_level = 0;
/* On Windowed ABI, we use a6 through a11 for passing arguments
to a function called by GDB because CALL4 is used. */
-#define ARGS_FIRST_REG gdbarch_tdep (current_gdbarch)->a0_base + 6
#define ARGS_NUM_REGS 6
#define REGISTER_SIZE 4
@@ -89,21 +88,14 @@ static int xtensa_debug_level = 0;
#define CALLINC(ps) (((ps) & PS_CALLINC_MASK) >> PS_CALLINC_SHIFT)
#define WINSIZE(ra) (4 * (( (ra) >> 30) & 0x3))
-
-/* Convert a live Ax register number to the corresponding Areg number. */
-#define AREG_NUMBER(r, wb) \
- ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
- & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) << WB_SHIFT)) & \
- (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
- + gdbarch_tdep (current_gdbarch)->ar_base)
-
/* ABI-independent macros. */
-#define ARG_NOF (gdbarch_tdep (current_gdbarch)->call_abi \
- == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS))
-#define ARG_1ST (gdbarch_tdep (current_gdbarch)->call_abi \
- == CallAbiCall0Only \
- ? (gdbarch_tdep (current_gdbarch)->a0_base + 0) + C0_ARGS \
- : (ARGS_FIRST_REG))
+#define ARG_NOF(gdbarch) \
+ (gdbarch_tdep (gdbarch)->call_abi \
+ == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS))
+#define ARG_1ST(gdbarch) \
+ (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only \
+ ? (gdbarch_tdep (gdbarch)->a0_base + 0) + C0_ARGS \
+ : (gdbarch_tdep (gdbarch)->a0_base + 6))
extern struct gdbarch_tdep *xtensa_config_tdep (struct gdbarch_info *);
extern int xtensa_config_byte_order (struct gdbarch_info *);
@@ -112,8 +104,8 @@ extern int xtensa_config_byte_order (str
/* XTENSA_IS_ENTRY tests whether the first byte of an instruction
indicates that the instruction is an ENTRY instruction. */
-#define XTENSA_IS_ENTRY(op1) \
- ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) \
+#define XTENSA_IS_ENTRY(gdbarch, op1) \
+ ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) \
? ((op1) == 0x6c) : ((op1) == 0x36))
#define XTENSA_ENTRY_LENGTH 3
@@ -125,6 +117,20 @@ extern int xtensa_config_byte_order (str
#define PS_WOE (1<<18)
#define PS_EXC (1<<4)
+/* Convert a live Ax register number to the corresponding Areg number. */
+static int
+areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ int areg;
+
+ areg = regnum - tdep->a0_base + tdep->ar_base;
+ areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
+ areg &= tdep->num_aregs - 1;
+
+ return areg;
+}
+
static inline int
windowing_enabled (CORE_ADDR ps)
{
@@ -143,7 +149,7 @@ windowing_enabled (CORE_ADDR ps)
method to call the inferior function. */
static int
-extract_call_winsize (CORE_ADDR pc)
+extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
{
int winsize = 4;
int insn;
@@ -163,7 +169,7 @@ extract_call_winsize (CORE_ADDR pc)
call{0,4,8,12} 0101 || {00,01,10,11} || OFFSET
callx{0,4,8,12} 0000 || {00,01,10,11} || 11 || OFFSET. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
{
if (((insn & 0xf) == 0x5) || ((insn & 0xcf) == 0xc0))
winsize = (insn & 0x30) >> 2; /* 0, 4, 8, 12. */
@@ -514,7 +520,7 @@ xtensa_pseudo_register_read (struct gdba
gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
- regnum = AREG_NUMBER (regnum, extract_unsigned_integer (buf, 4));
+ regnum = areg_number(gdbarch, regnum, extract_unsigned_integer (buf, 4));
}
/* We can always read non-pseudo registers. */
@@ -600,7 +606,7 @@ xtensa_pseudo_register_write (struct gdb
regcache_raw_read (regcache,
gdbarch_tdep (gdbarch)->wb_regnum, buf);
- regnum = AREG_NUMBER (regnum, extract_unsigned_integer (buf, 4));
+ regnum = areg_number (gdbarch, regnum, extract_unsigned_integer (buf, 4));
}
/* We can always write 'core' registers.
@@ -1061,7 +1067,7 @@ xtensa_frame_cache (struct frame_info *n
ps = frame_unwind_register_unsigned (next_frame, ps_regnum);
op1 = read_memory_integer (pc, 1);
- if (XTENSA_IS_ENTRY (op1))
+ if (XTENSA_IS_ENTRY (gdbarch, op1))
{
int callinc = CALLINC (ps);
ra = frame_unwind_register_unsigned
@@ -1135,8 +1141,8 @@ xtensa_frame_cache (struct frame_info *n
else
{
/* Read caller's frame SP directly from the previous window. */
- int regnum = AREG_NUMBER
- (gdbarch_tdep (gdbarch)->a0_base + 1,
+ int regnum = areg_number
+ (gdbarch, gdbarch_tdep (gdbarch)->a0_base + 1,
cache->wd.wb);
cache->prev_sp = xtensa_read_register (regnum);
@@ -1290,7 +1296,7 @@ xtensa_frame_prev_register (struct frame
/* Convert A-register numbers to AR-register numbers. */
if (regnum >= gdbarch_tdep (gdbarch)->a0_base + 0
&& regnum <= gdbarch_tdep (gdbarch)->a0_base + 15)
- regnum = AREG_NUMBER (regnum, cache->wd.wb);
+ regnum = areg_number (gdbarch, regnum, cache->wd.wb);
/* Check if AR-register has been saved to stack. */
if (regnum >= gdbarch_tdep (gdbarch)->ar_base
@@ -1417,7 +1423,7 @@ xtensa_extract_return_value (struct type
{
/* First, we have to find the caller window in the register file. */
regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc);
- callsize = extract_call_winsize (pc);
+ callsize = extract_call_winsize (gdbarch, pc);
/* On Xtensa, we can return up to 4 words (or 2 for call12). */
if (len > (callsize > 8 ? 8 : 16))
@@ -1428,7 +1434,8 @@ xtensa_extract_return_value (struct type
register (A2) in the caller window. */
regcache_raw_read_unsigned
(regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb);
- areg = AREG_NUMBER(gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
+ areg = areg_number (gdbarch,
+ gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
}
else
{
@@ -1471,13 +1478,14 @@ xtensa_store_return_value (struct type *
regcache_raw_read_unsigned
(regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb);
regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc);
- callsize = extract_call_winsize (pc);
+ callsize = extract_call_winsize (gdbarch, pc);
if (len > (callsize > 8 ? 8 : 16))
internal_error (__FILE__, __LINE__,
_("unimplemented for this length: %d"),
TYPE_LENGTH (type));
- areg = AREG_NUMBER (gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
+ areg = areg_number (gdbarch,
+ gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
DEBUGTRACE ("[xtensa_store_return_value] callsize %d wb %d\n",
callsize, (int) wb);
@@ -1658,7 +1666,7 @@ xtensa_push_dummy_call (struct gdbarch *
size = (size + info->align - 1) & ~(info->align - 1);
onstack_size = (onstack_size + info->align - 1) & ~(info->align - 1);
- if (size + info->length > REGISTER_SIZE * ARG_NOF)
+ if (size + info->length > REGISTER_SIZE * ARG_NOF (gdbarch))
{
info->onstack = 1;
info->u.offset = onstack_size;
@@ -1667,7 +1675,7 @@ xtensa_push_dummy_call (struct gdbarch *
else
{
info->onstack = 0;
- info->u.regno = ARG_1ST + size / REGISTER_SIZE;
+ info->u.regno = ARG_1ST (gdbarch) + size / REGISTER_SIZE;
}
size += info->length;
}
@@ -1688,7 +1696,7 @@ xtensa_push_dummy_call (struct gdbarch *
if (struct_return)
{
store_unsigned_integer (buf, REGISTER_SIZE, struct_addr);
- regcache_cooked_write (regcache, ARG_1ST, buf);
+ regcache_cooked_write (regcache, ARG_1ST (gdbarch), buf);
}
for (i = 0; i < nargs; i++)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-07 11:13 [rfc] [05/05] Get rid of current_gdbarch in xtensa Markus Deuling
@ 2007-11-08 21:55 ` Ulrich Weigand
2007-11-08 22:18 ` Daniel Jacobowitz
2007-11-09 2:12 ` Maxim Grigoriev
0 siblings, 2 replies; 9+ messages in thread
From: Ulrich Weigand @ 2007-11-08 21:55 UTC (permalink / raw)
To: Markus Deuling; +Cc: GDB Patches
Markus Deuling wrote:
> -#define AREG_NUMBER(r, wb) \
> - ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
> - & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) << WB_SHIFT)) & \
> - (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
> - + gdbarch_tdep (current_gdbarch)->ar_base)
> +/* Convert a live Ax register number to the corresponding Areg number. */
> +static int
> +areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
> +{
> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> + int areg;
> +
> + areg = regnum - tdep->a0_base + tdep->ar_base;
> + areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
> + areg &= tdep->num_aregs - 1;
> +
> + return areg;
> +}
The function does not look equivalent to the macro, that should be
areg = regnum - tdep->a0_base;
areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
areg &= tdep->num_aregs - 1;
return areg + tdep->ar_base;
> + regnum = areg_number(gdbarch, regnum, extract_unsigned_integer (buf, 4));
Space before '('.
Otherwise, I didn't see anything wrong. But I agree that it would
be good to test a change of this complexity; can you set up a simulator
test environment for xtensa?
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-08 21:55 ` Ulrich Weigand
@ 2007-11-08 22:18 ` Daniel Jacobowitz
2007-11-08 22:30 ` Maxim Grigoriev
2007-11-09 2:12 ` Maxim Grigoriev
1 sibling, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2007-11-08 22:18 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Markus Deuling, GDB Patches
On Thu, Nov 08, 2007 at 10:55:25PM +0100, Ulrich Weigand wrote:
> Otherwise, I didn't see anything wrong. But I agree that it would
> be good to test a change of this complexity; can you set up a simulator
> test environment for xtensa?
I don't believe the sim is freely available. Might want to ask Maxim?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-08 22:18 ` Daniel Jacobowitz
@ 2007-11-08 22:30 ` Maxim Grigoriev
0 siblings, 0 replies; 9+ messages in thread
From: Maxim Grigoriev @ 2007-11-08 22:30 UTC (permalink / raw)
To: Ulrich Weigand, Markus Deuling, GDB Patches, Daniel Jacobowitz
Daniel Jacobowitz wrote:
> On Thu, Nov 08, 2007 at 10:55:25PM +0100, Ulrich Weigand wrote:
>
>> Otherwise, I didn't see anything wrong. But I agree that it would
>> be good to test a change of this complexity; can you set up a simulator
>> test environment for xtensa?
>>
>
> I don't believe the sim is freely available. Might want to ask Maxim
Daniel is right, Xtensa simulator is not freely available.
In the near future, I am going to submit Xtensa GDB GNU/Linux
support, and people who have hardware running Xtensa GNU/Linux
will be able to test Xtensa FSF GDB.
In the meantime, I can test this patch and let you know
how it looks like.
Thanks for taking care of Xtensa port.
-- Maxim
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-08 21:55 ` Ulrich Weigand
2007-11-08 22:18 ` Daniel Jacobowitz
@ 2007-11-09 2:12 ` Maxim Grigoriev
2007-11-09 5:59 ` Markus Deuling
2007-11-09 13:13 ` Ulrich Weigand
1 sibling, 2 replies; 9+ messages in thread
From: Maxim Grigoriev @ 2007-11-09 2:12 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: Markus Deuling, GDB Patches
Ulrich Weigand wrote:
> Markus Deuling wrote:
>
>> -#define AREG_NUMBER(r, wb) \
>> - ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
>> - & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) << WB_SHIFT)) & \
>> - (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
>> - + gdbarch_tdep (current_gdbarch)->ar_base)
>>
>> +/* Convert a live Ax register number to the corresponding Areg number. */
>> +static int
>> +areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
>> +{
>> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>> + int areg;
>> +
>> + areg = regnum - tdep->a0_base + tdep->ar_base;
>> + areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
>> + areg &= tdep->num_aregs - 1;
>> +
>> + return areg;
>> +}
>>
>
> The function does not look equivalent to the macro, that should be
>
> areg = regnum - tdep->a0_base;
> areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
> areg &= tdep->num_aregs - 1;
>
> return areg + tdep->ar_base;
>
Ulrich is right. The function should look like he suggested :
static int
areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
int areg;
areg = regnum - tdep->a0_base;
areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
areg &= tdep->num_aregs - 1;
return areg + tdep->ar_base;
}
I applied Markus's patch, corrected areg_number(), and ran GDB dejagnu
tests.
No regression has been detected.
-- Maxim
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-09 2:12 ` Maxim Grigoriev
@ 2007-11-09 5:59 ` Markus Deuling
2007-11-09 7:47 ` Maxim Grigoriev
2007-11-09 13:13 ` Ulrich Weigand
1 sibling, 1 reply; 9+ messages in thread
From: Markus Deuling @ 2007-11-09 5:59 UTC (permalink / raw)
To: GDB Patches; +Cc: Maxim Grigoriev, Ulrich Weigand
[-- Attachment #1: Type: text/plain, Size: 1868 bytes --]
Maxim Grigoriev schrieb:
> Ulrich Weigand wrote:
>> Markus Deuling wrote:
>>
>>> -#define AREG_NUMBER(r, wb) \
>>> - ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
>>> - & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) <<
>>> WB_SHIFT)) & \
>>> - (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
>>> - + gdbarch_tdep (current_gdbarch)->ar_base)
>>> +/* Convert a live Ax register number to the corresponding Areg
>>> number. */
>>> +static int
>>> +areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
>>> +{
>>> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>>> + int areg;
>>> +
>>> + areg = regnum - tdep->a0_base + tdep->ar_base;
>>> + areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
>>> + areg &= tdep->num_aregs - 1;
>>> +
>>> + return areg;
>>> +}
>>>
>>
>> The function does not look equivalent to the macro, that should be
>>
>> areg = regnum - tdep->a0_base;
>> areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
>> areg &= tdep->num_aregs - 1;
>>
>> return areg + tdep->ar_base;
>>
> Ulrich is right. The function should look like he suggested :
>
> static int
> areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
> {
> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> int areg;
>
> areg = regnum - tdep->a0_base;
> areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
> areg &= tdep->num_aregs - 1;
>
> return areg + tdep->ar_base;
> }
>
> I applied Markus's patch, corrected areg_number(), and ran GDB dejagnu
> tests.
> No regression has been detected.
>
> -- Maxim
Uli,
Maxim,
thank you very much for your review and test. I changed areg_number like suggested. Attached
is the new version of the patch. ChangeLog stays the same.
Ok to commit?
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-xtensa --]
[-- Type: text/plain, Size: 8040 bytes --]
diff -urpN src/gdb/xtensa-tdep.c dev/gdb/xtensa-tdep.c
--- src/gdb/xtensa-tdep.c 2007-11-07 07:33:01.000000000 +0100
+++ dev/gdb/xtensa-tdep.c 2007-11-09 06:55:15.000000000 +0100
@@ -78,7 +78,6 @@ static int xtensa_debug_level = 0;
/* On Windowed ABI, we use a6 through a11 for passing arguments
to a function called by GDB because CALL4 is used. */
-#define ARGS_FIRST_REG gdbarch_tdep (current_gdbarch)->a0_base + 6
#define ARGS_NUM_REGS 6
#define REGISTER_SIZE 4
@@ -89,21 +88,14 @@ static int xtensa_debug_level = 0;
#define CALLINC(ps) (((ps) & PS_CALLINC_MASK) >> PS_CALLINC_SHIFT)
#define WINSIZE(ra) (4 * (( (ra) >> 30) & 0x3))
-
-/* Convert a live Ax register number to the corresponding Areg number. */
-#define AREG_NUMBER(r, wb) \
- ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
- & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) << WB_SHIFT)) & \
- (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
- + gdbarch_tdep (current_gdbarch)->ar_base)
-
/* ABI-independent macros. */
-#define ARG_NOF (gdbarch_tdep (current_gdbarch)->call_abi \
- == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS))
-#define ARG_1ST (gdbarch_tdep (current_gdbarch)->call_abi \
- == CallAbiCall0Only \
- ? (gdbarch_tdep (current_gdbarch)->a0_base + 0) + C0_ARGS \
- : (ARGS_FIRST_REG))
+#define ARG_NOF(gdbarch) \
+ (gdbarch_tdep (gdbarch)->call_abi \
+ == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS))
+#define ARG_1ST(gdbarch) \
+ (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only \
+ ? (gdbarch_tdep (gdbarch)->a0_base + 0) + C0_ARGS \
+ : (gdbarch_tdep (gdbarch)->a0_base + 6))
extern struct gdbarch_tdep *xtensa_config_tdep (struct gdbarch_info *);
extern int xtensa_config_byte_order (struct gdbarch_info *);
@@ -112,8 +104,8 @@ extern int xtensa_config_byte_order (str
/* XTENSA_IS_ENTRY tests whether the first byte of an instruction
indicates that the instruction is an ENTRY instruction. */
-#define XTENSA_IS_ENTRY(op1) \
- ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) \
+#define XTENSA_IS_ENTRY(gdbarch, op1) \
+ ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) \
? ((op1) == 0x6c) : ((op1) == 0x36))
#define XTENSA_ENTRY_LENGTH 3
@@ -125,6 +117,20 @@ extern int xtensa_config_byte_order (str
#define PS_WOE (1<<18)
#define PS_EXC (1<<4)
+/* Convert a live Ax register number to the corresponding Areg number. */
+static int
+areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
+{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ int areg;
+
+ areg = regnum - tdep->a0_base;
+ areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
+ areg &= tdep->num_aregs - 1;
+
+ return areg + tdep->ar_base;
+}
+
static inline int
windowing_enabled (CORE_ADDR ps)
{
@@ -143,7 +149,7 @@ windowing_enabled (CORE_ADDR ps)
method to call the inferior function. */
static int
-extract_call_winsize (CORE_ADDR pc)
+extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
{
int winsize = 4;
int insn;
@@ -163,7 +169,7 @@ extract_call_winsize (CORE_ADDR pc)
call{0,4,8,12} 0101 || {00,01,10,11} || OFFSET
callx{0,4,8,12} 0000 || {00,01,10,11} || 11 || OFFSET. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
{
if (((insn & 0xf) == 0x5) || ((insn & 0xcf) == 0xc0))
winsize = (insn & 0x30) >> 2; /* 0, 4, 8, 12. */
@@ -514,7 +520,7 @@ xtensa_pseudo_register_read (struct gdba
gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
- regnum = AREG_NUMBER (regnum, extract_unsigned_integer (buf, 4));
+ regnum = areg_number (gdbarch, regnum, extract_unsigned_integer (buf, 4));
}
/* We can always read non-pseudo registers. */
@@ -600,7 +606,7 @@ xtensa_pseudo_register_write (struct gdb
regcache_raw_read (regcache,
gdbarch_tdep (gdbarch)->wb_regnum, buf);
- regnum = AREG_NUMBER (regnum, extract_unsigned_integer (buf, 4));
+ regnum = areg_number (gdbarch, regnum, extract_unsigned_integer (buf, 4));
}
/* We can always write 'core' registers.
@@ -1061,7 +1067,7 @@ xtensa_frame_cache (struct frame_info *n
ps = frame_unwind_register_unsigned (next_frame, ps_regnum);
op1 = read_memory_integer (pc, 1);
- if (XTENSA_IS_ENTRY (op1))
+ if (XTENSA_IS_ENTRY (gdbarch, op1))
{
int callinc = CALLINC (ps);
ra = frame_unwind_register_unsigned
@@ -1135,8 +1141,8 @@ xtensa_frame_cache (struct frame_info *n
else
{
/* Read caller's frame SP directly from the previous window. */
- int regnum = AREG_NUMBER
- (gdbarch_tdep (gdbarch)->a0_base + 1,
+ int regnum = areg_number
+ (gdbarch, gdbarch_tdep (gdbarch)->a0_base + 1,
cache->wd.wb);
cache->prev_sp = xtensa_read_register (regnum);
@@ -1290,7 +1296,7 @@ xtensa_frame_prev_register (struct frame
/* Convert A-register numbers to AR-register numbers. */
if (regnum >= gdbarch_tdep (gdbarch)->a0_base + 0
&& regnum <= gdbarch_tdep (gdbarch)->a0_base + 15)
- regnum = AREG_NUMBER (regnum, cache->wd.wb);
+ regnum = areg_number (gdbarch, regnum, cache->wd.wb);
/* Check if AR-register has been saved to stack. */
if (regnum >= gdbarch_tdep (gdbarch)->ar_base
@@ -1417,7 +1423,7 @@ xtensa_extract_return_value (struct type
{
/* First, we have to find the caller window in the register file. */
regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc);
- callsize = extract_call_winsize (pc);
+ callsize = extract_call_winsize (gdbarch, pc);
/* On Xtensa, we can return up to 4 words (or 2 for call12). */
if (len > (callsize > 8 ? 8 : 16))
@@ -1428,7 +1434,8 @@ xtensa_extract_return_value (struct type
register (A2) in the caller window. */
regcache_raw_read_unsigned
(regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb);
- areg = AREG_NUMBER(gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
+ areg = areg_number (gdbarch,
+ gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
}
else
{
@@ -1471,13 +1478,14 @@ xtensa_store_return_value (struct type *
regcache_raw_read_unsigned
(regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb);
regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc);
- callsize = extract_call_winsize (pc);
+ callsize = extract_call_winsize (gdbarch, pc);
if (len > (callsize > 8 ? 8 : 16))
internal_error (__FILE__, __LINE__,
_("unimplemented for this length: %d"),
TYPE_LENGTH (type));
- areg = AREG_NUMBER (gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
+ areg = areg_number (gdbarch,
+ gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
DEBUGTRACE ("[xtensa_store_return_value] callsize %d wb %d\n",
callsize, (int) wb);
@@ -1658,7 +1666,7 @@ xtensa_push_dummy_call (struct gdbarch *
size = (size + info->align - 1) & ~(info->align - 1);
onstack_size = (onstack_size + info->align - 1) & ~(info->align - 1);
- if (size + info->length > REGISTER_SIZE * ARG_NOF)
+ if (size + info->length > REGISTER_SIZE * ARG_NOF (gdbarch))
{
info->onstack = 1;
info->u.offset = onstack_size;
@@ -1667,7 +1675,7 @@ xtensa_push_dummy_call (struct gdbarch *
else
{
info->onstack = 0;
- info->u.regno = ARG_1ST + size / REGISTER_SIZE;
+ info->u.regno = ARG_1ST (gdbarch) + size / REGISTER_SIZE;
}
size += info->length;
}
@@ -1688,7 +1696,7 @@ xtensa_push_dummy_call (struct gdbarch *
if (struct_return)
{
store_unsigned_integer (buf, REGISTER_SIZE, struct_addr);
- regcache_cooked_write (regcache, ARG_1ST, buf);
+ regcache_cooked_write (regcache, ARG_1ST (gdbarch), buf);
}
for (i = 0; i < nargs; i++)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-09 5:59 ` Markus Deuling
@ 2007-11-09 7:47 ` Maxim Grigoriev
0 siblings, 0 replies; 9+ messages in thread
From: Maxim Grigoriev @ 2007-11-09 7:47 UTC (permalink / raw)
To: Markus Deuling; +Cc: GDB Patches, Maxim Grigoriev, Ulrich Weigand
Hi Markus,
>> Ok to commit?
Xtensa testing looks fine on this update.
Unless there are any other issues, please, go ahead and check it in.
Thanks,
-- Maxim
Markus Deuling wrote:
> Maxim Grigoriev schrieb:
>> Ulrich Weigand wrote:
>>> Markus Deuling wrote:
>>>
>>>> -#define AREG_NUMBER(r, wb) \
>>>> - ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
>>>> - & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) <<
>>>> WB_SHIFT)) & \
>>>> - (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
>>>> - + gdbarch_tdep (current_gdbarch)->ar_base)
>>>> +/* Convert a live Ax register number to the corresponding Areg
>>>> number. */
>>>> +static int
>>>> +areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
>>>> +{
>>>> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>>>> + int areg;
>>>> +
>>>> + areg = regnum - tdep->a0_base + tdep->ar_base;
>>>> + areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
>>>> + areg &= tdep->num_aregs - 1;
>>>> +
>>>> + return areg;
>>>> +}
>>>>
>>>
>>> The function does not look equivalent to the macro, that should be
>>>
>>> areg = regnum - tdep->a0_base;
>>> areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
>>> areg &= tdep->num_aregs - 1;
>>>
>>> return areg + tdep->ar_base;
>>>
>> Ulrich is right. The function should look like he suggested :
>>
>> static int
>> areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
>> {
>> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
>> int areg;
>>
>> areg = regnum - tdep->a0_base;
>> areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
>> areg &= tdep->num_aregs - 1;
>>
>> return areg + tdep->ar_base;
>> }
>>
>> I applied Markus's patch, corrected areg_number(), and ran GDB
>> dejagnu tests.
>> No regression has been detected.
>>
>> -- Maxim
>
> Uli,
> Maxim,
>
> thank you very much for your review and test. I changed areg_number
> like suggested. Attached
> is the new version of the patch. ChangeLog stays the same.
>
> Ok to commit?
>
>
> ------------------------------------------------------------------------
>
> diff -urpN src/gdb/xtensa-tdep.c dev/gdb/xtensa-tdep.c
> --- src/gdb/xtensa-tdep.c 2007-11-07 07:33:01.000000000 +0100
> +++ dev/gdb/xtensa-tdep.c 2007-11-09 06:55:15.000000000 +0100
> @@ -78,7 +78,6 @@ static int xtensa_debug_level = 0;
>
> /* On Windowed ABI, we use a6 through a11 for passing arguments
> to a function called by GDB because CALL4 is used. */
> -#define ARGS_FIRST_REG gdbarch_tdep (current_gdbarch)->a0_base + 6
> #define ARGS_NUM_REGS 6
> #define REGISTER_SIZE 4
>
> @@ -89,21 +88,14 @@ static int xtensa_debug_level = 0;
> #define CALLINC(ps) (((ps) & PS_CALLINC_MASK) >> PS_CALLINC_SHIFT)
> #define WINSIZE(ra) (4 * (( (ra) >> 30) & 0x3))
>
> -
> -/* Convert a live Ax register number to the corresponding Areg number. */
> -#define AREG_NUMBER(r, wb) \
> - ((((r) - (gdbarch_tdep (current_gdbarch)->a0_base + 0) + (((wb) \
> - & ((gdbarch_tdep (current_gdbarch)->num_aregs - 1) >> 2)) << WB_SHIFT)) & \
> - (gdbarch_tdep (current_gdbarch)->num_aregs - 1)) \
> - + gdbarch_tdep (current_gdbarch)->ar_base)
> -
> /* ABI-independent macros. */
> -#define ARG_NOF (gdbarch_tdep (current_gdbarch)->call_abi \
> - == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS))
> -#define ARG_1ST (gdbarch_tdep (current_gdbarch)->call_abi \
> - == CallAbiCall0Only \
> - ? (gdbarch_tdep (current_gdbarch)->a0_base + 0) + C0_ARGS \
> - : (ARGS_FIRST_REG))
> +#define ARG_NOF(gdbarch) \
> + (gdbarch_tdep (gdbarch)->call_abi \
> + == CallAbiCall0Only ? C0_NARGS : (ARGS_NUM_REGS))
> +#define ARG_1ST(gdbarch) \
> + (gdbarch_tdep (gdbarch)->call_abi == CallAbiCall0Only \
> + ? (gdbarch_tdep (gdbarch)->a0_base + 0) + C0_ARGS \
> + : (gdbarch_tdep (gdbarch)->a0_base + 6))
>
> extern struct gdbarch_tdep *xtensa_config_tdep (struct gdbarch_info *);
> extern int xtensa_config_byte_order (struct gdbarch_info *);
> @@ -112,8 +104,8 @@ extern int xtensa_config_byte_order (str
> /* XTENSA_IS_ENTRY tests whether the first byte of an instruction
> indicates that the instruction is an ENTRY instruction. */
>
> -#define XTENSA_IS_ENTRY(op1) \
> - ((gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG) \
> +#define XTENSA_IS_ENTRY(gdbarch, op1) \
> + ((gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) \
> ? ((op1) == 0x6c) : ((op1) == 0x36))
>
> #define XTENSA_ENTRY_LENGTH 3
> @@ -125,6 +117,20 @@ extern int xtensa_config_byte_order (str
> #define PS_WOE (1<<18)
> #define PS_EXC (1<<4)
>
> +/* Convert a live Ax register number to the corresponding Areg number. */
> +static int
> +areg_number (struct gdbarch *gdbarch, int regnum, ULONGEST wb)
> +{
> + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> + int areg;
> +
> + areg = regnum - tdep->a0_base;
> + areg += (wb & ((tdep->num_aregs - 1) >> 2)) << WB_SHIFT;
> + areg &= tdep->num_aregs - 1;
> +
> + return areg + tdep->ar_base;
> +}
> +
> static inline int
> windowing_enabled (CORE_ADDR ps)
> {
> @@ -143,7 +149,7 @@ windowing_enabled (CORE_ADDR ps)
> method to call the inferior function. */
>
> static int
> -extract_call_winsize (CORE_ADDR pc)
> +extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
> {
> int winsize = 4;
> int insn;
> @@ -163,7 +169,7 @@ extract_call_winsize (CORE_ADDR pc)
> call{0,4,8,12} 0101 || {00,01,10,11} || OFFSET
> callx{0,4,8,12} 0000 || {00,01,10,11} || 11 || OFFSET. */
>
> - if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
> + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
> {
> if (((insn & 0xf) == 0x5) || ((insn & 0xcf) == 0xc0))
> winsize = (insn & 0x30) >> 2; /* 0, 4, 8, 12. */
> @@ -514,7 +520,7 @@ xtensa_pseudo_register_read (struct gdba
> gdb_byte *buf = (gdb_byte *) alloca (MAX_REGISTER_SIZE);
>
> regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
> - regnum = AREG_NUMBER (regnum, extract_unsigned_integer (buf, 4));
> + regnum = areg_number (gdbarch, regnum, extract_unsigned_integer (buf, 4));
> }
>
> /* We can always read non-pseudo registers. */
> @@ -600,7 +606,7 @@ xtensa_pseudo_register_write (struct gdb
>
> regcache_raw_read (regcache,
> gdbarch_tdep (gdbarch)->wb_regnum, buf);
> - regnum = AREG_NUMBER (regnum, extract_unsigned_integer (buf, 4));
> + regnum = areg_number (gdbarch, regnum, extract_unsigned_integer (buf, 4));
> }
>
> /* We can always write 'core' registers.
> @@ -1061,7 +1067,7 @@ xtensa_frame_cache (struct frame_info *n
> ps = frame_unwind_register_unsigned (next_frame, ps_regnum);
>
> op1 = read_memory_integer (pc, 1);
> - if (XTENSA_IS_ENTRY (op1))
> + if (XTENSA_IS_ENTRY (gdbarch, op1))
> {
> int callinc = CALLINC (ps);
> ra = frame_unwind_register_unsigned
> @@ -1135,8 +1141,8 @@ xtensa_frame_cache (struct frame_info *n
> else
> {
> /* Read caller's frame SP directly from the previous window. */
> - int regnum = AREG_NUMBER
> - (gdbarch_tdep (gdbarch)->a0_base + 1,
> + int regnum = areg_number
> + (gdbarch, gdbarch_tdep (gdbarch)->a0_base + 1,
> cache->wd.wb);
>
> cache->prev_sp = xtensa_read_register (regnum);
> @@ -1290,7 +1296,7 @@ xtensa_frame_prev_register (struct frame
> /* Convert A-register numbers to AR-register numbers. */
> if (regnum >= gdbarch_tdep (gdbarch)->a0_base + 0
> && regnum <= gdbarch_tdep (gdbarch)->a0_base + 15)
> - regnum = AREG_NUMBER (regnum, cache->wd.wb);
> + regnum = areg_number (gdbarch, regnum, cache->wd.wb);
>
> /* Check if AR-register has been saved to stack. */
> if (regnum >= gdbarch_tdep (gdbarch)->ar_base
> @@ -1417,7 +1423,7 @@ xtensa_extract_return_value (struct type
> {
> /* First, we have to find the caller window in the register file. */
> regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc);
> - callsize = extract_call_winsize (pc);
> + callsize = extract_call_winsize (gdbarch, pc);
>
> /* On Xtensa, we can return up to 4 words (or 2 for call12). */
> if (len > (callsize > 8 ? 8 : 16))
> @@ -1428,7 +1434,8 @@ xtensa_extract_return_value (struct type
> register (A2) in the caller window. */
> regcache_raw_read_unsigned
> (regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb);
> - areg = AREG_NUMBER(gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
> + areg = areg_number (gdbarch,
> + gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
> }
> else
> {
> @@ -1471,13 +1478,14 @@ xtensa_store_return_value (struct type *
> regcache_raw_read_unsigned
> (regcache, gdbarch_tdep (gdbarch)->wb_regnum, &wb);
> regcache_raw_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &pc);
> - callsize = extract_call_winsize (pc);
> + callsize = extract_call_winsize (gdbarch, pc);
>
> if (len > (callsize > 8 ? 8 : 16))
> internal_error (__FILE__, __LINE__,
> _("unimplemented for this length: %d"),
> TYPE_LENGTH (type));
> - areg = AREG_NUMBER (gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
> + areg = areg_number (gdbarch,
> + gdbarch_tdep (gdbarch)->a0_base + 2 + callsize, wb);
>
> DEBUGTRACE ("[xtensa_store_return_value] callsize %d wb %d\n",
> callsize, (int) wb);
> @@ -1658,7 +1666,7 @@ xtensa_push_dummy_call (struct gdbarch *
> size = (size + info->align - 1) & ~(info->align - 1);
> onstack_size = (onstack_size + info->align - 1) & ~(info->align - 1);
>
> - if (size + info->length > REGISTER_SIZE * ARG_NOF)
> + if (size + info->length > REGISTER_SIZE * ARG_NOF (gdbarch))
> {
> info->onstack = 1;
> info->u.offset = onstack_size;
> @@ -1667,7 +1675,7 @@ xtensa_push_dummy_call (struct gdbarch *
> else
> {
> info->onstack = 0;
> - info->u.regno = ARG_1ST + size / REGISTER_SIZE;
> + info->u.regno = ARG_1ST (gdbarch) + size / REGISTER_SIZE;
> }
> size += info->length;
> }
> @@ -1688,7 +1696,7 @@ xtensa_push_dummy_call (struct gdbarch *
> if (struct_return)
> {
> store_unsigned_integer (buf, REGISTER_SIZE, struct_addr);
> - regcache_cooked_write (regcache, ARG_1ST, buf);
> + regcache_cooked_write (regcache, ARG_1ST (gdbarch), buf);
> }
>
> for (i = 0; i < nargs; i++)
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-09 2:12 ` Maxim Grigoriev
2007-11-09 5:59 ` Markus Deuling
@ 2007-11-09 13:13 ` Ulrich Weigand
2007-11-12 6:44 ` Markus Deuling
1 sibling, 1 reply; 9+ messages in thread
From: Ulrich Weigand @ 2007-11-09 13:13 UTC (permalink / raw)
To: Maxim Grigoriev; +Cc: Markus Deuling, GDB Patches
Maxim Grigoriev wrote:
> I applied Markus's patch, corrected areg_number(), and ran GDB dejagnu
> tests.
> No regression has been detected.
Thanks for running the tests!
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
2007-11-09 13:13 ` Ulrich Weigand
@ 2007-11-12 6:44 ` Markus Deuling
0 siblings, 0 replies; 9+ messages in thread
From: Markus Deuling @ 2007-11-12 6:44 UTC (permalink / raw)
To: GDB Patches; +Cc: Ulrich Weigand, Maxim Grigoriev
Uli,
Maxim,
Ulrich Weigand schrieb:
> Maxim Grigoriev wrote:
>
>> I applied Markus's patch, corrected areg_number(), and ran GDB dejagnu
>> tests.
>> No regression has been detected.
>
> Thanks for running the tests!
>
> Bye,
> Ulrich
>
I'v committed this one now. Thank you very much!
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-11-12 6:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-07 11:13 [rfc] [05/05] Get rid of current_gdbarch in xtensa Markus Deuling
2007-11-08 21:55 ` Ulrich Weigand
2007-11-08 22:18 ` Daniel Jacobowitz
2007-11-08 22:30 ` Maxim Grigoriev
2007-11-09 2:12 ` Maxim Grigoriev
2007-11-09 5:59 ` Markus Deuling
2007-11-09 7:47 ` Maxim Grigoriev
2007-11-09 13:13 ` Ulrich Weigand
2007-11-12 6:44 ` Markus Deuling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox