|
From: <sv...@va...> - 2005-08-01 23:26:26
|
Author: sewardj
Date: 2005-08-02 00:25:55 +0100 (Tue, 02 Aug 2005)
New Revision: 4303
Log:
When identifying stacks so as to decide whether or not to make a self
checking translation in the case --smc-check=3Dstack (the default),
don't use SF_GROWDOWN as an indication of stackness, since that only
is set for the main stack. Instead establish whether code is being
taken from a stack by seeing if the requesting thread's stack pointer
points into the same area that the translation is being taken from.
This makes trampolining work even for threaded programs.
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 2005-08-01 15:18:16 UTC (rev 4302)
+++ trunk/coregrind/m_translate.c 2005-08-01 23:25:55 UTC (rev 4303)
@@ -34,6 +34,7 @@
#include "pub_core_aspacemgr.h"
#include "pub_core_cpuid.h"
#include "pub_core_machine.h" // For VG_(cache_line_size_ppc32)
+ // and VG_(get_SP)
#include "pub_core_libcbase.h"
#include "pub_core_libcassert.h"
#include "pub_core_libcprint.h"
@@ -46,6 +47,7 @@
#include "pub_core_translate.h"
#include "pub_core_transtab.h"
=20
+
/*------------------------------------------------------------*/
/*--- Determining arch/subarch. ---*/
/*------------------------------------------------------------*/
@@ -384,8 +386,14 @@
=20
Also, we must stop Vex chasing into blocks for which we might want
to self checking.
+
+ This fn needs to know also the tid of the requesting thread, but
+ it can't be passed in as a parameter since this fn is passed to
+ Vex and that has no notion of tids. So we clumsily pass it as
+ a global, chase_into_ok__CLOSURE_tid.
*/
-static Bool chase_into_ok ( Addr64 addr64 )
+static ThreadId chase_into_ok__CLOSURE_tid;
+static Bool chase_into_ok ( Addr64 addr64 )
{
/* Work through a list of possibilities why we might not want to
allow a chase. */
@@ -399,8 +407,11 @@
would choose to have a self-check for the dest. Note, this must
match the logic at XXXYYYZZZ below. */
if (VG_(clo_smc_check) =3D=3D Vg_SmcStack) {
+ ThreadId tid =3D chase_into_ok__CLOSURE_tid;
Segment* seg =3D VG_(find_segment)(addr);
- if (seg && (seg->flags & SF_GROWDOWN))
+ if (seg=20
+ && seg->addr <=3D VG_(get_SP)(tid)
+ && VG_(get_SP)(tid) < seg->addr+seg->len)
goto dontchase;
}
=20
@@ -538,9 +549,15 @@
case Vg_SmcAll: do_self_check =3D True; break;
case Vg_SmcStack:=20
/* XXXYYYZZZ: must match the logic at AAABBBCCC above */
- do_self_check =3D seg ? toBool(seg->flags & SF_GROWDOWN) : Fals=
e;
+ do_self_check
+ /* =3D seg ? toBool(seg->flags & SF_GROWDOWN) : False; */
+ =3D seg=20
+ ? (seg->addr <=3D VG_(get_SP)(tid)
+ && VG_(get_SP)(tid) < seg->addr+seg->len)
+ : False;
break;
- default: vg_assert2(0, "unknown VG_(clo_smc_check) value");
+ default:=20
+ vg_assert2(0, "unknown VG_(clo_smc_check) value");
}
=20
/* True if a debug trans., or if bit N set in VG_(clo_trace_codegen).=
*/
@@ -559,6 +576,10 @@
/* Actually do the translation. */
tl_assert2(VG_(tdict).tool_instrument,
"you forgot to set VgToolInterface function 'tool_instrume=
nt'");
+
+ /* Set up closure arg for "chase_into_ok" */
+ chase_into_ok__CLOSURE_tid =3D tid;
+
tres =3D LibVEX_Translate (=20
vex_arch, &vex_archinfo,
vex_arch, &vex_archinfo,
|