|
From: <sv...@va...> - 2005-05-16 19:33:44
|
Author: sewardj
Date: 2005-05-16 12:48:34 +0100 (Mon, 16 May 2005)
New Revision: 3738
Modified:
trunk/coregrind/vg_dwarf.c
Log:
CFI reader: partially handle DW_CFA_expression and
DW_CFA_def_cfa_expression in the sense that they are parsed correctly,
but the contained expression is ignored.
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-16 11:47:17 UTC (rev 3737)
+++ trunk/coregrind/vg_dwarf.c 2005-05-16 11:48:34 UTC (rev 3738)
@@ -862,6 +862,10 @@
=20
8 is the return address (EIP) */
=20
+/* Note that we don't support DWARF3 expressions (DW_CFA_expression,
+ DW_CFA_def_cfa_expression). The code just reads over them and
+ ignores them.=20
+*/
=20
/* --------------- Decls --------------- */
=20
@@ -906,6 +910,8 @@
DW_CFA_def_cfa =3D 0x0c,
DW_CFA_def_cfa_register =3D 0x0d,
DW_CFA_def_cfa_offset =3D 0x0e,
+ DW_CFA_def_cfa_expression =3D 0x0f, /* DWARF3 only */
+ DW_CFA_expression =3D 0x10, /* DWARF3 only */
DW_CFA_offset_extended_sf =3D 0x11, /* DWARF3 only */
DW_CFA_def_cfa_offset_sf =3D 0x13, /* DWARF3 only */
DW_CFA_lo_user =3D 0x1c,
@@ -940,7 +946,7 @@
=20
typedef
struct {
- enum { RR_Undef, RR_Same, RR_CFAoff, RR_Reg, RR_Arch } tag;
+ enum { RR_Undef, RR_Same, RR_CFAoff, RR_Reg, RR_Arch, RR_Expr } ta=
g;
=20
/* Note, .coff and .reg are never both in use. Therefore could
merge them into one. */
@@ -961,6 +967,7 @@
case RR_CFAoff: VG_(printf)("c%d ", reg->coff); break;
case RR_Reg: VG_(printf)("r%d ", reg->reg); break;
case RR_Arch: VG_(printf)("a "); break;
+ case RR_Expr: VG_(printf)("e "); break;
default: VG_(core_panic)("ppRegRule");
}
}
@@ -977,7 +984,7 @@
run_CF_instruction. */
/* The LOC entry */
Addr loc;
- /* The CFA entry */
+ /* The CFA entry. If -1, means we don't know (Dwarf3 Expression).=
*/
Int cfa_reg;
Int cfa_offset; /* in bytes */
/* register unwind rules */
@@ -1080,6 +1087,12 @@
initCfiSI(si);
=20
/* How to generate the CFA */
+ if (ctx->cfa_reg =3D=3D -1) {
+ /* it was set by DW_CFA_def_cfa_expression; we don't know what
+ it really is */
+ why =3D 6;
+ goto failed;
+ } else
if (ctx->cfa_reg =3D=3D SP_REG) {
si->cfa_sprel =3D True;
si->cfa_off =3D ctx->cfa_offset;
@@ -1132,7 +1145,7 @@
return True;
=20
failed:
- if (VG_(clo_verbosity) > 1) {
+ if (VG_(clo_verbosity) > 2 || VG_(clo_trace_cfi)) {
VG_(message)(Vg_DebugMsg,
"summarise_context(loc_start =3D %p)"
": cannot summarise(why=3D%d): ", loc_start, why);
@@ -1356,7 +1369,7 @@
UChar* instr,
UnwindContext* restore_ctx )
{
- Int off, reg, reg2, nleb;
+ Int off, reg, reg2, nleb, len;
UInt delta;
Int i =3D 0;
UChar hi2 =3D (instr[i] >> 6) & 3;
@@ -1474,6 +1487,32 @@
i +=3D nleb;
break;
=20
+ case DW_CFA_expression:
+ /* Too difficult to really handle; just skip over it and say
+ that we don't know what do to with the register. */
+ if (VG_(clo_trace_cfi))
+ VG_(printf)("DWARF2 CFI reader: "
+ "ignoring DW_CFA_expression\n");
+ reg =3D read_leb128( &instr[i], &nleb, 0 );
+ i +=3D nleb;
+ len =3D read_leb128( &instr[i], &nleb, 0 );
+ i +=3D nleb;
+ i +=3D len;
+ if (reg < 0 || reg >=3D N_CFI_REGS)=20
+ return 0; /* fail */
+ ctx->reg[reg].tag =3D RR_Expr;
+ break;
+
+ case DW_CFA_def_cfa_expression:
+ if (VG_(clo_trace_cfi))
+ VG_(printf)("DWARF2 CFI reader: "
+ "ignoring DW_CFA_def_cfa_expression\n");
+ len =3D read_leb128( &instr[i], &nleb, 0 );
+ i +=3D nleb;
+ i +=3D len;
+ ctx->cfa_reg =3D -1; /* indicating we don't know */
+ break;
+
default:=20
VG_(message)(Vg_DebugMsg, "DWARF2 CFI reader: unhandled CFI "
"instruction 0:%d", (Int)lo6);=20
@@ -1490,7 +1529,7 @@
static Int show_CF_instruction ( UChar* instr )
{
UInt delta;
- Int off, reg, reg2, nleb;
+ Int off, reg, reg2, nleb, len;
Addr loc;
Int i =3D 0;
UChar hi2 =3D (instr[i] >> 6) & 3;
@@ -1581,6 +1620,22 @@
VG_(printf)("DW_CFA_GNU_args_size(%d)\n", off );=20
break;
=20
+ case DW_CFA_def_cfa_expression:
+ len =3D read_leb128( &instr[i], &nleb, 0 );
+ i +=3D nleb;
+ i +=3D len;
+ VG_(printf)("DW_CFA_def_cfa_expression(length %d)\n", len);
+ break;
+
+ case DW_CFA_expression:
+ reg =3D read_leb128( &instr[i], &nleb, 0 );
+ i +=3D nleb;
+ len =3D read_leb128( &instr[i], &nleb, 0 );
+ i +=3D nleb;
+ i +=3D len;
+ VG_(printf)("DW_CFA_expression(r%d, length %d)\n", reg, len);
+ break;
+
default:=20
VG_(printf)("0:%d\n", (Int)lo6);=20
break;
|