This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc] [05/05] Get rid of current_gdbarch in xtensa


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]