|
From: <sv...@va...> - 2005-05-13 12:17:42
|
Author: sewardj
Date: 2005-05-13 13:17:33 +0100 (Fri, 13 May 2005)
New Revision: 3690
Modified:
trunk/coregrind/vg_dwarf.c
Log:
CFI reader: don't assume RA_REG is anything in particular; instead use
what's specified in the currenty applicable CIE.
Modified: trunk/coregrind/vg_dwarf.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/vg_dwarf.c 2005-05-12 23:25:43 UTC (rev 3689)
+++ trunk/coregrind/vg_dwarf.c 2005-05-13 12:17:33 UTC (rev 3690)
@@ -918,13 +918,13 @@
/* --------------- Decls --------------- */
=20
#if defined(VGP_x86_linux)
-#define FP_COL 5
-#define SP_COL 4
-#define RA_COL 8
+#define FP_REG 5
+#define SP_REG 4
+#define RA_REG_DEFAULT 8
#elif defined(VGP_amd64_linux)
-#define FP_COL 6
-#define SP_COL 7
-#define RA_COL 16
+#define FP_REG 6
+#define SP_REG 7
+#define RA_REG_DEFAULT 16
#endif
=20
/* the number of regs we are prepared to unwind */
@@ -1017,10 +1017,11 @@
=20
typedef
struct {
- /* Read-only fields. */
+ /* Read-only fields (set by the CIE) */
Int code_a_f;
Int data_a_f;
Addr initloc;
+ Int ra_reg;
/* The rest of these fields can be modifed by
run_CF_instruction. */
/* The LOC entry */
@@ -1046,10 +1047,12 @@
static void initUnwindContext ( /*OUT*/UnwindContext* ctx )
{
Int i;
- ctx->code_a_f =3D 0;
- ctx->data_a_f =3D 0;
- ctx->loc =3D 0;
- ctx->cfa_reg =3D 0;
+ ctx->code_a_f =3D 0;
+ ctx->data_a_f =3D 0;
+ ctx->initloc =3D 0;
+ ctx->ra_reg =3D RA_REG_DEFAULT;
+ ctx->loc =3D 0;
+ ctx->cfa_reg =3D 0;
ctx->cfa_offset =3D 0;
for (i =3D 0; i < N_CFI_REGS; i++) {
ctx->reg[i].tag =3D RR_Undef;
@@ -1074,11 +1077,11 @@
initCfiSI(si);
=20
/* How to generate the CFA */
- if (ctx->cfa_reg =3D=3D SP_COL) {
+ if (ctx->cfa_reg =3D=3D SP_REG) {
si->cfa_sprel =3D True;
si->cfa_off =3D ctx->cfa_offset;
} else
- if (ctx->cfa_reg =3D=3D FP_COL) {
+ if (ctx->cfa_reg =3D=3D FP_REG) {
si->cfa_sprel =3D False;
si->cfa_off =3D ctx->cfa_offset;
} else {
@@ -1094,8 +1097,8 @@
default: { why =3D 2; goto failed; } /* otherwise give up *=
/ \
}
=20
- SUMMARISE_HOW(si->ra_how, si->ra_off, ctx->reg[RA_COL] );
- SUMMARISE_HOW(si->fp_how, si->fp_off, ctx->reg[FP_COL] );
+ SUMMARISE_HOW(si->ra_how, si->ra_off, ctx->reg[ctx->ra_reg] );
+ SUMMARISE_HOW(si->fp_how, si->fp_off, ctx->reg[FP_REG] );
=20
# undef SUMMARISE_HOW
=20
@@ -1106,7 +1109,7 @@
=20
/* also, gcc says "Undef" for %{e,r}bp when it is unchanged. So
.. */
- if (ctx->reg[FP_COL].tag =3D=3D RR_Undef)
+ if (ctx->reg[FP_REG].tag =3D=3D RR_Undef)
si->fp_how =3D CFIR_SAME;
=20
/* knock out some obviously stupid cases */
@@ -1139,20 +1142,20 @@
{
VG_(printf)("0x%llx-1: ", (ULong)ctx->loc);
=20
- if (ctx->cfa_reg =3D=3D SP_COL) {
+ if (ctx->cfa_reg =3D=3D SP_REG) {
VG_(printf)("SP/CFA=3D%d+SP ", ctx->cfa_offset);
} else
- if (ctx->cfa_reg =3D=3D FP_COL) {
+ if (ctx->cfa_reg =3D=3D FP_REG) {
VG_(printf)("SP/CFA=3D%d+FP ", ctx->cfa_offset);
} else {
VG_(printf)("SP/CFA=3Dunknown ", ctx->cfa_offset);
}
=20
VG_(printf)("RA=3D");
- ppRegRule( &ctx->reg[RA_COL] );
+ ppRegRule( &ctx->reg[ctx->ra_reg] );
=20
VG_(printf)("FP=3D");
- ppRegRule( &ctx->reg[FP_COL] );
+ ppRegRule( &ctx->reg[FP_REG] );
VG_(printf)("\n");
}
=20
@@ -1647,6 +1650,7 @@
HChar* how =3D NULL;
Int cie_codeaf =3D 0;
Int cie_dataaf =3D 0;
+ Int cie_rareg =3D 0;
Bool ok;
=20
UChar* current_cie =3D NULL;
@@ -1697,7 +1701,7 @@
if (ciefde_len =3D=3D 0) {
if (data =3D=3D ehframe + ehframe_sz)
return;
- how =3D "zero-sized CIE/FDE but not at section end\n";
+ how =3D "zero-sized CIE/FDE but not at section end";
goto bad;
}
=20
@@ -1743,11 +1747,11 @@
if (VG_(clo_trace_cfi))=20
VG_(printf)("cie.data_af =3D %d\n", cie_dataaf);
=20
- UChar cie_rareg =3D read_UChar(data); data +=3D sizeof(UChar);
+ cie_rareg =3D read_UChar(data); data +=3D sizeof(UChar);
if (VG_(clo_trace_cfi))=20
VG_(printf)("cie.ra_reg =3D %d\n", (Int)cie_rareg);
- if (cie_rareg !=3D RA_COL) {
- how =3D "cie.ra_reg does not match RA_COL";
+ if (cie_rareg < 0 || cie_rareg >=3D N_CFI_REGS) {
+ how =3D "cie.ra_reg has implausible value";
goto bad;
}
=20
@@ -1865,6 +1869,7 @@
ctx.code_a_f =3D cie_codeaf;
ctx.data_a_f =3D cie_dataaf;
ctx.initloc =3D fde_initloc;
+ ctx.ra_reg =3D cie_rareg;
=20
initUnwindContext(&restore_ctx);
=20
|