Jakub Jelinek fcbcff
--- valgrind/coregrind/m_debuginfo/readdwarf.c.jj	2009-07-13 15:18:35.596080042 +0200
Jakub Jelinek fcbcff
+++ valgrind/coregrind/m_debuginfo/readdwarf.c	2009-07-13 15:54:43.576955651 +0200
Jakub Jelinek fcbcff
@@ -1939,17 +1939,20 @@ typedef
Jakub Jelinek fcbcff
          run_CF_instruction. */
Jakub Jelinek fcbcff
       /* The LOC entry */
Jakub Jelinek fcbcff
       Addr    loc;
Jakub Jelinek fcbcff
-      /* The CFA entry.  This can be either reg+/-offset or an expr. */
Jakub Jelinek fcbcff
-      Bool    cfa_is_regoff; /* True=>is reg+offset; False=>is expr */
Jakub Jelinek fcbcff
-      Int     cfa_reg;
Jakub Jelinek fcbcff
-      Int     cfa_off;  /* in bytes */
Jakub Jelinek fcbcff
-      Int     cfa_expr_ix; /* index into cfa_exprs */
Jakub Jelinek fcbcff
-      /* A stack of register unwind rules.  We need a stack of them,
Jakub Jelinek fcbcff
-         rather than just one set of rules, in order to handle
Jakub Jelinek fcbcff
+      /* We need a stack of these in order to handle
Jakub Jelinek fcbcff
          DW_CFA_{remember,restore}_state. */
Jakub Jelinek fcbcff
-      RegRule reg[N_RR_STACK][N_CFI_REGS];
Jakub Jelinek fcbcff
-      Int     reg_sp; /* 0 <= reg_sp < N_RR_STACK; points at the
Jakub Jelinek fcbcff
-                         currently-in-use rule set. */
Jakub Jelinek fcbcff
+      struct UnwindContextState {
Jakub Jelinek fcbcff
+          /* The CFA entry.  This can be either reg+/-offset or an expr. */
Jakub Jelinek fcbcff
+          Bool    cfa_is_regoff; /* True=>is reg+offset; False=>is expr */
Jakub Jelinek fcbcff
+          Int     cfa_reg;
Jakub Jelinek fcbcff
+          Int     cfa_off;  /* in bytes */
Jakub Jelinek fcbcff
+          Int     cfa_expr_ix; /* index into cfa_exprs */
Jakub Jelinek fcbcff
+          /* Register unwind rules.  */
Jakub Jelinek fcbcff
+          RegRule reg[N_CFI_REGS];
Jakub Jelinek fcbcff
+      }
Jakub Jelinek fcbcff
+      state[N_RR_STACK];
Jakub Jelinek fcbcff
+      Int     state_sp; /* 0 <= state_sp < N_RR_STACK; points at the
Jakub Jelinek fcbcff
+                           currently-in-use rule set. */
Jakub Jelinek fcbcff
       /* array of CfiExpr, shared by reg[] and cfa_expr_ix */
Jakub Jelinek fcbcff
       XArray* exprs;
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
@@ -1959,18 +1962,20 @@ static void ppUnwindContext ( UnwindCont
Jakub Jelinek fcbcff
 {
Jakub Jelinek fcbcff
    Int j, i;
Jakub Jelinek fcbcff
    VG_(printf)("0x%llx: ", (ULong)ctx->loc);
Jakub Jelinek fcbcff
-   if (ctx->cfa_is_regoff) {
Jakub Jelinek fcbcff
-      VG_(printf)("%d(r%d) ",  ctx->cfa_off, ctx->cfa_reg);
Jakub Jelinek fcbcff
-   } else {
Jakub Jelinek fcbcff
-      vg_assert(ctx->exprs);
Jakub Jelinek fcbcff
-      VG_(printf)("{");
Jakub Jelinek fcbcff
-      ML_(ppCfiExpr)( ctx->exprs, ctx->cfa_expr_ix );
Jakub Jelinek fcbcff
-      VG_(printf)("} ");
Jakub Jelinek fcbcff
-   }
Jakub Jelinek fcbcff
-   for (j = 0; j <= ctx->reg_sp; j++) {
Jakub Jelinek fcbcff
+   for (j = 0; j <= ctx->state_sp; j++) {
Jakub Jelinek fcbcff
+      struct UnwindContextState* ctxs = &ctx->state[j];
Jakub Jelinek fcbcff
       VG_(printf)("%s[%d]={ ", j > 0 ? " " : "", j);
Jakub Jelinek fcbcff
+      if (ctxs->cfa_is_regoff) {
Jakub Jelinek fcbcff
+         VG_(printf)("%d(r%d) ", ctxs->cfa_off, ctxs->cfa_reg);
Jakub Jelinek fcbcff
+      } else {
Jakub Jelinek fcbcff
+         vg_assert(ctx->exprs);
Jakub Jelinek fcbcff
+         VG_(printf)("{");
Jakub Jelinek fcbcff
+         ML_(ppCfiExpr)( ctx->exprs, ctxs->cfa_expr_ix );
Jakub Jelinek fcbcff
+         VG_(printf)("} ");
Jakub Jelinek fcbcff
+      }
Jakub Jelinek fcbcff
+      VG_(printf)("{ ");
Jakub Jelinek fcbcff
       for (i = 0; i < N_CFI_REGS; i++)
Jakub Jelinek fcbcff
-         ppRegRule(ctx->exprs, &ctx->reg[j][i]);
Jakub Jelinek fcbcff
+         ppRegRule(ctx->exprs, &ctxs->reg[i]);
Jakub Jelinek fcbcff
       VG_(printf)("}");
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
    VG_(printf)("\n");
Jakub Jelinek fcbcff
@@ -1980,21 +1985,22 @@ static void initUnwindContext ( /*OUT*/U
Jakub Jelinek fcbcff
 {
Jakub Jelinek fcbcff
    Int j, i;
Jakub Jelinek fcbcff
    VG_(memset)(ctx, 0, sizeof(*ctx));
Jakub Jelinek fcbcff
-   ctx->code_a_f      = 0;
Jakub Jelinek fcbcff
+   /* ctx->code_a_f   = 0;
Jakub Jelinek fcbcff
    ctx->data_a_f      = 0;
Jakub Jelinek fcbcff
-   ctx->initloc       = 0;
Jakub Jelinek fcbcff
+   ctx->initloc       = 0; */
Jakub Jelinek fcbcff
    ctx->ra_reg        = RA_REG_DEFAULT;
Jakub Jelinek fcbcff
-   ctx->loc           = 0;
Jakub Jelinek fcbcff
-   ctx->cfa_is_regoff = True;
Jakub Jelinek fcbcff
-   ctx->cfa_reg       = 0;
Jakub Jelinek fcbcff
-   ctx->cfa_off       = 0;
Jakub Jelinek fcbcff
-   ctx->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
+   /* ctx->loc        = 0;
Jakub Jelinek fcbcff
    ctx->exprs         = NULL;
Jakub Jelinek fcbcff
-   ctx->reg_sp        = 0;
Jakub Jelinek fcbcff
+   ctx->state_sp        = 0; */
Jakub Jelinek fcbcff
    for (j = 0; j < N_RR_STACK; j++) {
Jakub Jelinek fcbcff
+      ctx->state[j].cfa_is_regoff = True;
Jakub Jelinek fcbcff
+      /* ctx->state[j].cfa_reg    = 0;
Jakub Jelinek fcbcff
+      ctx->state[j].cfa_off       = 0;
Jakub Jelinek fcbcff
+      ctx->state[j].cfa_expr_ix   = 0; */
Jakub Jelinek fcbcff
       for (i = 0; i < N_CFI_REGS; i++) {
Jakub Jelinek fcbcff
-         ctx->reg[j][i].tag = RR_Undef;
Jakub Jelinek fcbcff
-         ctx->reg[j][i].arg = 0;
Jakub Jelinek fcbcff
+         if (RR_Undef != 0)
Jakub Jelinek fcbcff
+           ctx->state[j].reg[i].tag = RR_Undef;
Jakub Jelinek fcbcff
+         /* ctx->state[j].reg[i].arg = 0; */
Jakub Jelinek fcbcff
       }
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
 }
Jakub Jelinek fcbcff
@@ -2048,10 +2054,17 @@ static Bool summarise_context( /*OUT*/Di
Jakub Jelinek fcbcff
                                struct _DebugInfo* debuginfo )
Jakub Jelinek fcbcff
 {
Jakub Jelinek fcbcff
    Int why = 0;
Jakub Jelinek fcbcff
+   struct UnwindContextState* ctxs;
Jakub Jelinek fcbcff
    initCfiSI(si);
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
+   /* Guard against obviously stupid settings of the reg-rule stack
Jakub Jelinek fcbcff
+      pointer. */
Jakub Jelinek fcbcff
+   if (ctx->state_sp < 0)           { why = 8; goto failed; }
Jakub Jelinek fcbcff
+   if (ctx->state_sp >= N_RR_STACK) { why = 9; goto failed; }
Jakub Jelinek fcbcff
+   ctxs = &ctx->state[ctx->state_sp];
Jakub Jelinek fcbcff
+
Jakub Jelinek fcbcff
    /* How to generate the CFA */
Jakub Jelinek fcbcff
-   if (!ctx->cfa_is_regoff) {
Jakub Jelinek fcbcff
+   if (!ctxs->cfa_is_regoff) {
Jakub Jelinek fcbcff
       /* it was set by DW_CFA_def_cfa_expression; try to convert */
Jakub Jelinek fcbcff
       XArray *src, *dst;
Jakub Jelinek fcbcff
       Int    conv;
Jakub Jelinek fcbcff
@@ -2064,7 +2077,7 @@ static Bool summarise_context( /*OUT*/Di
Jakub Jelinek fcbcff
          debuginfo->cfsi_exprs = dst;
Jakub Jelinek fcbcff
       }
Jakub Jelinek fcbcff
       conv = copy_convert_CfiExpr_tree
Jakub Jelinek fcbcff
-                    ( dst, ctx, ctx->cfa_expr_ix );
Jakub Jelinek fcbcff
+                    ( dst, ctx, ctxs->cfa_expr_ix );
Jakub Jelinek fcbcff
       vg_assert(conv >= -1);
Jakub Jelinek fcbcff
       if (conv == -1) { why = 6; goto failed; }
Jakub Jelinek fcbcff
       si->cfa_how = CFIC_EXPR;
Jakub Jelinek fcbcff
@@ -2072,13 +2085,13 @@ static Bool summarise_context( /*OUT*/Di
Jakub Jelinek fcbcff
       if (0 && debuginfo->ddump_frames)
Jakub Jelinek fcbcff
          ML_(ppCfiExpr)(dst, conv);
Jakub Jelinek fcbcff
    } else
Jakub Jelinek fcbcff
-   if (ctx->cfa_is_regoff && ctx->cfa_reg == SP_REG) {
Jakub Jelinek fcbcff
+   if (ctxs->cfa_is_regoff && ctxs->cfa_reg == SP_REG) {
Jakub Jelinek fcbcff
       si->cfa_how = CFIC_SPREL;
Jakub Jelinek fcbcff
-      si->cfa_off = ctx->cfa_off;
Jakub Jelinek fcbcff
+      si->cfa_off = ctxs->cfa_off;
Jakub Jelinek fcbcff
    } else
Jakub Jelinek fcbcff
-   if (ctx->cfa_is_regoff && ctx->cfa_reg == FP_REG) {
Jakub Jelinek fcbcff
+   if (ctxs->cfa_is_regoff && ctxs->cfa_reg == FP_REG) {
Jakub Jelinek fcbcff
       si->cfa_how = CFIC_FPREL;
Jakub Jelinek fcbcff
-      si->cfa_off = ctx->cfa_off;
Jakub Jelinek fcbcff
+      si->cfa_off = ctxs->cfa_off;
Jakub Jelinek fcbcff
    } else {
Jakub Jelinek fcbcff
       why = 1;
Jakub Jelinek fcbcff
       goto failed;
Jakub Jelinek fcbcff
@@ -2121,15 +2134,10 @@ static Bool summarise_context( /*OUT*/Di
Jakub Jelinek fcbcff
          why = 2; goto failed; /* otherwise give up */        \
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
-   /* Guard against obviously stupid settings of the reg-rule stack
Jakub Jelinek fcbcff
-      pointer. */
Jakub Jelinek fcbcff
-   if (ctx->reg_sp < 0)           { why = 8; goto failed; }
Jakub Jelinek fcbcff
-   if (ctx->reg_sp >= N_RR_STACK) { why = 9; goto failed; }
Jakub Jelinek fcbcff
-
Jakub Jelinek fcbcff
    SUMMARISE_HOW(si->ra_how, si->ra_off,
Jakub Jelinek fcbcff
-                             ctx->reg[ctx->reg_sp][ctx->ra_reg] );
Jakub Jelinek fcbcff
+                             ctxs->reg[ctx->ra_reg] );
Jakub Jelinek fcbcff
    SUMMARISE_HOW(si->fp_how, si->fp_off,
Jakub Jelinek fcbcff
-                             ctx->reg[ctx->reg_sp][FP_REG] );
Jakub Jelinek fcbcff
+                             ctxs->reg[FP_REG] );
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
 #  undef SUMMARISE_HOW
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
@@ -2140,7 +2148,7 @@ static Bool summarise_context( /*OUT*/Di
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    /* also, gcc says "Undef" for %{e,r}bp when it is unchanged.  So
Jakub Jelinek fcbcff
       .. */
Jakub Jelinek fcbcff
-   if (ctx->reg[ctx->reg_sp][FP_REG].tag == RR_Undef)
Jakub Jelinek fcbcff
+   if (ctxs->reg[FP_REG].tag == RR_Undef)
Jakub Jelinek fcbcff
       si->fp_how = CFIR_SAME;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    /* knock out some obviously stupid cases */
Jakub Jelinek fcbcff
@@ -2227,22 +2235,24 @@ static Int copy_convert_CfiExpr_tree ( X
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
 static void ppUnwindContext_summary ( UnwindContext* ctx )
Jakub Jelinek fcbcff
 {
Jakub Jelinek fcbcff
+   struct UnwindContextState* ctxs = &ctx->state[ctx->state_sp];
Jakub Jelinek fcbcff
+
Jakub Jelinek fcbcff
    VG_(printf)("0x%llx-1: ", (ULong)ctx->loc);
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
-   if (ctx->cfa_reg == SP_REG) {
Jakub Jelinek fcbcff
-      VG_(printf)("SP/CFA=%d+SP   ", ctx->cfa_off);
Jakub Jelinek fcbcff
+   if (ctxs->cfa_reg == SP_REG) {
Jakub Jelinek fcbcff
+      VG_(printf)("SP/CFA=%d+SP   ", ctxs->cfa_off);
Jakub Jelinek fcbcff
    } else
Jakub Jelinek fcbcff
-   if (ctx->cfa_reg == FP_REG) {
Jakub Jelinek fcbcff
-      VG_(printf)("SP/CFA=%d+FP   ", ctx->cfa_off);
Jakub Jelinek fcbcff
+   if (ctxs->cfa_reg == FP_REG) {
Jakub Jelinek fcbcff
+      VG_(printf)("SP/CFA=%d+FP   ", ctxs->cfa_off);
Jakub Jelinek fcbcff
    } else {
Jakub Jelinek fcbcff
       VG_(printf)("SP/CFA=unknown  ");
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    VG_(printf)("RA=");
Jakub Jelinek fcbcff
-   ppRegRule( ctx->exprs, &ctx->reg[ctx->reg_sp][ctx->ra_reg] );
Jakub Jelinek fcbcff
+   ppRegRule( ctx->exprs, &ctxs->reg[ctx->ra_reg] );
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    VG_(printf)("FP=");
Jakub Jelinek fcbcff
-   ppRegRule( ctx->exprs, &ctx->reg[ctx->reg_sp][FP_REG] );
Jakub Jelinek fcbcff
+   ppRegRule( ctx->exprs, &ctxs->reg[FP_REG] );
Jakub Jelinek fcbcff
    VG_(printf)("\n");
Jakub Jelinek fcbcff
 }
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
@@ -2510,6 +2520,7 @@ static Int dwarfexpr_to_dag ( UnwindCont
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    Int sp; /* # of top element: valid is -1 .. N_EXPR_STACK-1 */
Jakub Jelinek fcbcff
    Int stack[N_EXPR_STACK];  /* indices into ctx->exprs */
Jakub Jelinek fcbcff
+   struct UnwindContextState* ctxs = &ctx->state[ctx->state_sp];
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    XArray* dst   = ctx->exprs;
Jakub Jelinek fcbcff
    UChar*  limit = expr + exprlen;
Jakub Jelinek fcbcff
@@ -2521,17 +2532,17 @@ static Int dwarfexpr_to_dag ( UnwindCont
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
    /* Synthesise the CFA as a CfiExpr */
Jakub Jelinek fcbcff
    if (push_cfa_at_start) {
Jakub Jelinek fcbcff
-      if (ctx->cfa_is_regoff) {
Jakub Jelinek fcbcff
+      if (ctxs->cfa_is_regoff) {
Jakub Jelinek fcbcff
          /* cfa is reg +/- offset */
Jakub Jelinek fcbcff
          ix = ML_(CfiExpr_Binop)( dst,
Jakub Jelinek fcbcff
                  Cop_Add,
Jakub Jelinek fcbcff
-                 ML_(CfiExpr_DwReg)( dst, ctx->cfa_reg ),
Jakub Jelinek fcbcff
-                 ML_(CfiExpr_Const)( dst, (UWord)(Word)ctx->cfa_off )
Jakub Jelinek fcbcff
+                 ML_(CfiExpr_DwReg)( dst, ctxs->cfa_reg ),
Jakub Jelinek fcbcff
+                 ML_(CfiExpr_Const)( dst, (UWord)(Word)ctxs->cfa_off )
Jakub Jelinek fcbcff
               );
Jakub Jelinek fcbcff
          PUSH(ix);
Jakub Jelinek fcbcff
       } else {
Jakub Jelinek fcbcff
          /* CFA is already an expr; use its root node */
Jakub Jelinek fcbcff
-         PUSH(ctx->cfa_expr_ix);
Jakub Jelinek fcbcff
+         PUSH(ctxs->cfa_expr_ix);
Jakub Jelinek fcbcff
       }
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
@@ -2686,11 +2697,13 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
    UChar  hi2 = (instr[i] >> 6) & 3;
Jakub Jelinek fcbcff
    UChar  lo6 = instr[i] & 0x3F;
Jakub Jelinek fcbcff
    Addr   printing_bias = ((Addr)ctx->initloc) - ((Addr)di->text_bias);
Jakub Jelinek fcbcff
+   struct UnwindContextState* ctxs;
Jakub Jelinek fcbcff
    i++;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
-   if (ctx->reg_sp < 0 || ctx->reg_sp >= N_RR_STACK)
Jakub Jelinek fcbcff
+   if (ctx->state_sp < 0 || ctx->state_sp >= N_RR_STACK)
Jakub Jelinek fcbcff
       return 0; /* bogus reg-rule stack pointer */
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
+   ctxs = &ctx->state[ctx->state_sp];
Jakub Jelinek fcbcff
    if (hi2 == DW_CFA_advance_loc) {
Jakub Jelinek fcbcff
       delta = (UInt)lo6;
Jakub Jelinek fcbcff
       ctx->loc += delta;
Jakub Jelinek fcbcff
@@ -2707,13 +2720,13 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
       reg = (Int)lo6;
Jakub Jelinek fcbcff
       if (reg < 0 || reg >= N_CFI_REGS) 
Jakub Jelinek fcbcff
          return 0; /* fail */
Jakub Jelinek fcbcff
-      ctx->reg[ctx->reg_sp][reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
-      ctx->reg[ctx->reg_sp][reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+      ctxs->reg[reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
+      ctxs->reg[reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
       if (di->ddump_frames)
Jakub Jelinek fcbcff
          VG_(printf)("  DW_CFA_offset: r%d at cfa%s%d\n",
Jakub Jelinek fcbcff
                      (Int)reg,
Jakub Jelinek fcbcff
-                     ctx->reg[ctx->reg_sp][reg].arg < 0 ? "" : "+", 
Jakub Jelinek fcbcff
-                     (Int)ctx->reg[ctx->reg_sp][reg].arg );
Jakub Jelinek fcbcff
+                     ctxs->reg[reg].arg < 0 ? "" : "+", 
Jakub Jelinek fcbcff
+                     (Int)ctxs->reg[reg].arg );
Jakub Jelinek fcbcff
       return i;
Jakub Jelinek fcbcff
    }
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
@@ -2723,7 +2736,7 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          return 0; /* fail */
Jakub Jelinek fcbcff
       if (restore_ctx == NULL)
Jakub Jelinek fcbcff
          return 0; /* fail */
Jakub Jelinek fcbcff
-      ctx->reg[ctx->reg_sp][reg] = restore_ctx->reg[ctx->reg_sp][reg];
Jakub Jelinek fcbcff
+      ctxs->reg[reg] = restore_ctx->state[restore_ctx->state_sp].reg[reg];
Jakub Jelinek fcbcff
       if (di->ddump_frames)
Jakub Jelinek fcbcff
          VG_(printf)("  DW_CFA_restore: r%d\n", (Int)reg);
Jakub Jelinek fcbcff
       return i;
Jakub Jelinek fcbcff
@@ -2777,10 +2791,10 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS) 
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->cfa_is_regoff = True;
Jakub Jelinek fcbcff
-         ctx->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
-         ctx->cfa_reg       = reg;
Jakub Jelinek fcbcff
-         ctx->cfa_off       = off;
Jakub Jelinek fcbcff
+         ctxs->cfa_is_regoff = True;
Jakub Jelinek fcbcff
+         ctxs->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_reg       = reg;
Jakub Jelinek fcbcff
+         ctxs->cfa_off       = off;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_def_cfa: r%d ofs %d\n", (Int)reg, (Int)off);
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2792,10 +2806,10 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS)
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->cfa_is_regoff = True;
Jakub Jelinek fcbcff
-         ctx->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
-         ctx->cfa_reg       = reg;
Jakub Jelinek fcbcff
-         ctx->cfa_off       = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->cfa_is_regoff = True;
Jakub Jelinek fcbcff
+         ctxs->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_reg       = reg;
Jakub Jelinek fcbcff
+         ctxs->cfa_off       = off * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_def_cfa_sf\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2809,8 +2823,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
          if (reg2 < 0 || reg2 >= N_CFI_REGS) 
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_Reg;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = reg2;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_Reg;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = reg2;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_register: r%d in r%d\n", 
Jakub Jelinek fcbcff
                         (Int)reg, (Int)reg2);
Jakub Jelinek fcbcff
@@ -2823,8 +2837,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS)
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_offset_extended\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2836,13 +2850,13 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS) 
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_offset_extended_sf: r%d at cfa%s%d\n", 
Jakub Jelinek fcbcff
                         reg,
Jakub Jelinek fcbcff
-                        ctx->reg[ctx->reg_sp][reg].arg < 0 ? "" : "+", 
Jakub Jelinek fcbcff
-                        (Int)ctx->reg[ctx->reg_sp][reg].arg);
Jakub Jelinek fcbcff
+                        ctxs->reg[reg].arg < 0 ? "" : "+", 
Jakub Jelinek fcbcff
+                        (Int)ctxs->reg[reg].arg);
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
       case DW_CFA_GNU_negative_offset_extended:
Jakub Jelinek fcbcff
@@ -2852,8 +2866,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS)
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = (-off) * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_CFAOff;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = (-off) * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_GNU_negative_offset_extended\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2865,7 +2879,7 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
 	 if (restore_ctx == NULL)
Jakub Jelinek fcbcff
 	    return 0; /* fail */
Jakub Jelinek fcbcff
-	 ctx->reg[ctx->reg_sp][reg] = restore_ctx->reg[ctx->reg_sp][reg];
Jakub Jelinek fcbcff
+	 ctxs->reg[reg] = restore_ctx->state[restore_ctx->state_sp].reg[reg];
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_restore_extended\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2877,8 +2891,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS)
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_CFAValOff;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_CFAValOff;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_val_offset\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2890,8 +2904,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS)
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_CFAValOff;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_CFAValOff;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = off * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_val_offset_sf\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2901,9 +2915,9 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS) 
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->cfa_is_regoff = True;
Jakub Jelinek fcbcff
-         ctx->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
-         ctx->cfa_reg       = reg;
Jakub Jelinek fcbcff
+         ctxs->cfa_is_regoff = True;
Jakub Jelinek fcbcff
+         ctxs->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_reg       = reg;
Jakub Jelinek fcbcff
          /* ->cfa_off unchanged */
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_def_cfa_reg: r%d\n", (Int)reg );
Jakub Jelinek fcbcff
@@ -2912,10 +2926,10 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
       case DW_CFA_def_cfa_offset:
Jakub Jelinek fcbcff
          off = read_leb128( &instr[i], &nleb, 0);
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
-         ctx->cfa_is_regoff = True;
Jakub Jelinek fcbcff
-         ctx->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_is_regoff = True;
Jakub Jelinek fcbcff
+         ctxs->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
          /* ->reg is unchanged */
Jakub Jelinek fcbcff
-         ctx->cfa_off       = off;
Jakub Jelinek fcbcff
+         ctxs->cfa_off       = off;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_def_cfa_offset: %d\n", (Int)off);
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2923,12 +2937,12 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
       case DW_CFA_def_cfa_offset_sf:
Jakub Jelinek fcbcff
          off = read_leb128( &instr[i], &nleb, 1);
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
-         ctx->cfa_is_regoff = True;
Jakub Jelinek fcbcff
-         ctx->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_is_regoff = True;
Jakub Jelinek fcbcff
+         ctxs->cfa_expr_ix   = 0;
Jakub Jelinek fcbcff
          /* ->reg is unchanged */
Jakub Jelinek fcbcff
-         ctx->cfa_off       = off * ctx->data_a_f;
Jakub Jelinek fcbcff
+         ctxs->cfa_off       = off * ctx->data_a_f;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
-            VG_(printf)("  DW_CFA_def_cfa_offset_sf: %d\n", ctx->cfa_off);
Jakub Jelinek fcbcff
+            VG_(printf)("  DW_CFA_def_cfa_offset_sf: %d\n", ctxs->cfa_off);
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
       case DW_CFA_undefined:
Jakub Jelinek fcbcff
@@ -2936,8 +2950,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          i += nleb;
Jakub Jelinek fcbcff
          if (reg < 0 || reg >= N_CFI_REGS) 
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_Undef;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = 0;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_Undef;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = 0;
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  rci:DW_CFA_undefined\n");
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
@@ -2981,8 +2995,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
          /* Add an extra dereference */
Jakub Jelinek fcbcff
          j = ML_(CfiExpr_Deref)( ctx->exprs, j );
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_ValExpr;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = j;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_ValExpr;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = j;
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
       case DW_CFA_val_expression:
Jakub Jelinek fcbcff
@@ -3010,8 +3024,8 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          }
Jakub Jelinek fcbcff
          if (j == -1)
Jakub Jelinek fcbcff
             return 0; /* fail */
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].tag = RR_ValExpr;
Jakub Jelinek fcbcff
-         ctx->reg[ctx->reg_sp][reg].arg = j;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].tag = RR_ValExpr;
Jakub Jelinek fcbcff
+         ctxs->reg[reg].arg = j;
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
       case DW_CFA_def_cfa_expression:
Jakub Jelinek fcbcff
@@ -3027,10 +3041,10 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
                                 di->ddump_frames);
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)(")\n");
Jakub Jelinek fcbcff
-         ctx->cfa_is_regoff = False;
Jakub Jelinek fcbcff
-         ctx->cfa_reg       = 0;
Jakub Jelinek fcbcff
-         ctx->cfa_off       = 0;
Jakub Jelinek fcbcff
-         ctx->cfa_expr_ix   = j;
Jakub Jelinek fcbcff
+         ctxs->cfa_is_regoff = False;
Jakub Jelinek fcbcff
+         ctxs->cfa_reg       = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_off       = 0;
Jakub Jelinek fcbcff
+         ctxs->cfa_expr_ix   = j;
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
       case DW_CFA_GNU_window_save:
Jakub Jelinek fcbcff
@@ -3044,17 +3058,17 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_remember_state\n");
Jakub Jelinek fcbcff
          /* we just checked this at entry, so: */
Jakub Jelinek fcbcff
-         vg_assert(ctx->reg_sp >= 0 && ctx->reg_sp < N_RR_STACK);
Jakub Jelinek fcbcff
-         ctx->reg_sp++;
Jakub Jelinek fcbcff
-         if (ctx->reg_sp == N_RR_STACK) {
Jakub Jelinek fcbcff
+         vg_assert(ctx->state_sp >= 0 && ctx->state_sp < N_RR_STACK);
Jakub Jelinek fcbcff
+         ctx->state_sp++;
Jakub Jelinek fcbcff
+         if (ctx->state_sp == N_RR_STACK) {
Jakub Jelinek fcbcff
             /* stack overflow.  We're hosed. */
Jakub Jelinek fcbcff
             VG_(message)(Vg_DebugMsg, "DWARF2 CFI reader: N_RR_STACK is "
Jakub Jelinek fcbcff
                                       "too low; increase and recompile.");
Jakub Jelinek fcbcff
             i = 0; /* indicate failure */
Jakub Jelinek fcbcff
          } else {
Jakub Jelinek fcbcff
-            VG_(memcpy)(/*dst*/&ctx->reg[ctx->reg_sp],
Jakub Jelinek fcbcff
-                        /*src*/&ctx->reg[ctx->reg_sp - 1],
Jakub Jelinek fcbcff
-                        sizeof(ctx->reg[ctx->reg_sp]) );
Jakub Jelinek fcbcff
+            VG_(memcpy)(/*dst*/&ctx->state[ctx->state_sp],
Jakub Jelinek fcbcff
+                        /*src*/&ctx->state[ctx->state_sp - 1],
Jakub Jelinek fcbcff
+                        sizeof(ctx->state[ctx->state_sp]) );
Jakub Jelinek fcbcff
          }
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff
 
Jakub Jelinek fcbcff
@@ -3062,13 +3076,13 @@ static Int run_CF_instruction ( /*MOD*/U
Jakub Jelinek fcbcff
          if (di->ddump_frames)
Jakub Jelinek fcbcff
             VG_(printf)("  DW_CFA_restore_state\n");
Jakub Jelinek fcbcff
          /* we just checked this at entry, so: */
Jakub Jelinek fcbcff
-         vg_assert(ctx->reg_sp >= 0 && ctx->reg_sp < N_RR_STACK);
Jakub Jelinek fcbcff
-         if (ctx->reg_sp == 0) {
Jakub Jelinek fcbcff
+         vg_assert(ctx->state_sp >= 0 && ctx->state_sp < N_RR_STACK);
Jakub Jelinek fcbcff
+         if (ctx->state_sp == 0) {
Jakub Jelinek fcbcff
             /* stack overflow.  Give up. */
Jakub Jelinek fcbcff
             i = 0; /* indicate failure */
Jakub Jelinek fcbcff
          } else {
Jakub Jelinek fcbcff
             /* simply fall back to previous entry */
Jakub Jelinek fcbcff
-            ctx->reg_sp--;
Jakub Jelinek fcbcff
+            ctx->state_sp--;
Jakub Jelinek fcbcff
          }
Jakub Jelinek fcbcff
          break;
Jakub Jelinek fcbcff