|
From: <sv...@va...> - 2006-01-22 01:15:39
|
Author: sewardj
Date: 2006-01-22 01:15:36 +0000 (Sun, 22 Jan 2006)
New Revision: 5583
Log:
Two unrelated changes:
- create an IMark at the start of the IR for the ppc64 magic return stub
as cachegrind will barf if it doesn't find one in a BB
- ppc64: for the same reason that _NRADDR is set to zero at the start of
redirect block which is a function replacement entry (as opposed to a
function wrapper entry), also set _NRADDR_GPR2 to zero.
Modified:
trunk/coregrind/m_translate.c
Modified: trunk/coregrind/m_translate.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/m_translate.c 2006-01-22 01:12:51 UTC (rev 5582)
+++ trunk/coregrind/m_translate.c 2006-01-22 01:15:36 UTC (rev 5583)
@@ -568,13 +568,13 @@
=20
/* --------------- ppc64-linux specific helpers --------------- */
=20
-#if defined(VGP_ppc64_linux)
static IRExpr* mkU64 ( ULong n ) {
return IRExpr_Const(IRConst_U64(n));
}
static IRExpr* mkU32 ( UInt n ) {
return IRExpr_Const(IRConst_U32(n));
}
+#if defined(VGP_ppc64_linux)
static IRExpr* mkU8 ( UChar n ) {
return IRExpr_Const(IRConst_U8(n));
}
@@ -727,6 +727,16 @@
static
Bool mk_preamble__ppc64_magic_return_stub ( void* closureV, IRBB* bb )
{
+ VgCallbackClosure* closure =3D (VgCallbackClosure*)closureV;
+ /* Since we're creating the entire IRBB right here, give it a
+ proper IMark, as it won't get one any other way, and cachegrind
+ will barf if it doesn't have one (fair enough really). */
+ addStmtToIRBB( bb, IRStmt_IMark( closure->readdr, 4 ) );
+ /* Generate the magic sequence:
+ pop R2 from hidden stack
+ pop LR from hidden stack
+ goto LR
+ */
gen_pop_R2_LR_then_bLR(bb);
return True; /* True =3D=3D this is the entire BB; don't disassemble =
any
real insns into it - just hand it directly to
@@ -737,9 +747,11 @@
/* --------------- END ppc64-linux specific helpers --------------- */
=20
/* This is an the IR preamble generators used for replacement
- functions. It adds code to set the guest_NRADDR to zero
+ functions. It adds code to set the guest_NRADDR{_GPR2} to zero
(technically not necessary, but facilitates detecting mixups in
- which the wrong preamble generator has been used).
+ which a replacement function has been erroneously declared using
+ VG_REPLACE_FUNCTION_Z{U,Z} when instead it should have been written
+ using VG_WRAP_FUNCTION_Z{U,Z}).
=20
On ppc64-linux the follow hacks are also done: LR and R2 are pushed
onto a hidden stack, sets R2 to the correct value for the
@@ -754,7 +766,6 @@
static=20
Bool mk_preamble__set_NRADDR_to_zero ( void* closureV, IRBB* bb )
{
- VgCallbackClosure* closure =3D (VgCallbackClosure*)closureV;
Int nraddr_szB
=3D sizeof(((VexGuestArchState*)0)->guest_NRADDR);
vg_assert(nraddr_szB =3D=3D 4 || nraddr_szB =3D=3D 8);
@@ -762,13 +773,20 @@
bb,
IRStmt_Put(=20
offsetof(VexGuestArchState,guest_NRADDR),
- nraddr_szB =3D=3D 8
- ? IRExpr_Const(IRConst_U64(0))
- : IRExpr_Const(IRConst_U32(0))
+ nraddr_szB =3D=3D 8 ? mkU64(0) : mkU32(0)
)
);
# if defined(VGP_ppc64_linux)
- gen_push_and_set_LR_R2 ( bb, VG_(get_tocptr)( closure->readdr ) );
+ { VgCallbackClosure* closure =3D (VgCallbackClosure*)closureV;
+ addStmtToIRBB(
+ bb,
+ IRStmt_Put(
+ offsetof(VexGuestArchState,guest_NRADDR_GPR2),
+ mkU64(0)
+ )
+ );
+ gen_push_and_set_LR_R2 ( bb, VG_(get_tocptr)( closure->readdr ) );
+ }
# endif
return False;
}
|