This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
- From: Maxim Grigoriev <maxim at tensilica dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: Markus Deuling <deuling at de dot ibm dot com>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Thu, 08 Nov 2007 18:12:20 -0800
- Subject: Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa
- References: <200711082155.lA8LtPjO001820@d12av02.megacenter.de.ibm.com>
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