|
From: Huanghao (A. SingleAS) <ale...@hu...> - 2014-04-28 11:57:32
|
Hi Valarind team,
I have one question to your team, you may help me a lot.
I want to get the stored value that Store IR stores in the Store IR's help function.
And I write code as following in blue:
static
IRSB* xxx_instrument ( VgCallbackClosure* closure,
IRSB* sbIn,
VexGuestLayout* layout,
VexGuestExtents* vge,
IRType gWordTy, IRType hWordTy )
{
...
case Ist_Store: {
IRExpr* data = st->Ist.Store.data;
IRExpr* aexpr = st->Ist.Store.addr;
addMemEvent( sbOut,
aexpr, data, goff_sp );
break;
}
...
}
static
void addMemEvent(IRSB* sbOut, IRExpr* addr, IRExpr* data,
Int goff_sp)
{
...
hName = "xxx_handle_write";
hAddr = &xxx_handle_write;
argv = mkIRExprVec_2( addr, data);
di = unsafeIRDirty_0_N( 2/*regparms*/,
hName, VG_(fnptr_to_fnentry)( hAddr ),
argv );
addStmtToIRSB( sbOut, IRStmt_Dirty(di) );
...
}
static VG_REGPARM(2)
void xxx_handle_write ( Addr addr, ULong data )
{
...
}
But I get failure when I execute it.
vex: priv/host_amd64_isel.c:627 (doHelperCall): Assertion `typeOfIRExpr(env->type_env, args[i]) == Ity_I64' failed.
vex storage: T total 734792 bytes allocated
vex storage: P total 640 bytes allocated
valgrind: the 'impossible' happened:
LibVEX called failure_exit().
==19901== at 0x3808AD7F: report_and_quit (m_libcassert.c:260)
==19901== by 0x3808ADE9: panic (m_libcassert.c:350)
==19901== by 0x3808AE38: vgPlain_core_panic_at (m_libcassert.c:355)
==19901== by 0x3808AE4A: vgPlain_core_panic (m_libcassert.c:360)
==19901== by 0x38016762: failure_exit (m_translate.c:731)
==19901== by 0x380B8408: vex_assert_fail (main_util.c:219)
==19901== by 0x382715D3: doHelperCall (host_amd64_isel.c:627)
==19901== by 0x38276B96: iselSB_AMD64 (host_amd64_isel.c:4457)
==19901== by 0x380B693F: LibVEX_Translate (main_main.c:823)
==19901== by 0x3801435E: vgPlain_translate (m_translate.c:1602)
==19901== by 0x380478ED: handle_chain_me (scheduler.c:1032)
==19901== by 0x38049445: vgPlain_scheduler (scheduler.c:1330)
==19901== by 0x38074477: run_a_thread_NORETURN (syswrap-linux.c:103)
Cound you please help me that how to make the functionality to be available?
Thanks in advance!
Best Regards
Alex
|
|
From: Josef W. <Jos...@gm...> - 2014-04-28 13:00:19
|
Am 28.04.2014 13:57, schrieb Huanghao (Alex, SingleAS): > / argv = mkIRExprVec_2( addr, data);/ > / di = unsafeIRDirty_0_N( 2/*regparms*/,/ > / hName, VG_(fnptr_to_fnentry)( hAddr ),/ > / argv ); / > / addStmtToIRSB( sbOut, IRStmt_Dirty(di) );/ > /vex: priv/host_amd64_isel.c:627 (doHelperCall): Assertion > `typeOfIRExpr(env->type_env, args[i]) == Ity_I64' failed./ >From the error: obviously, a dirty helper on amd64 only accepts arguments which have a size of 64 bit. For addresses, this is correct. But data may have different size. You must add a VEX instruction which extends your data to 64bit before using it as argument for a dirty helper. Josef |
|
From: Josef W. <Jos...@gm...> - 2014-04-29 15:57:18
|
Am 29.04.2014 03:31, schrieb Huanghao (Alex, SingleAS): > Could you please tell me what is the VEX instruction exactly? Or any information I can refer to. In general, the VEX instructions are documented in the comments of the header file VEX/pub/libvex_ir.h Search for "Widening conversions", i.e. Iop_XXto64 with XX depending on the type of your data. As example, a widening instruction is used in the instrumentation in cachegrind/cg_main.c, case "Ist_Exit". I put this back on the mailing list. It is always a good idea to have this in archive for other people. Best, Josef > > Best Regards > Alex > > -----Original Message----- > From: Josef Weidendorfer [mailto:Jos...@gm...] > Sent: Monday, April 28, 2014 9:00 PM > To: val...@li... > Subject: Re: [Valgrind-developers] How to get the data of Store IR in the IR's helper > > Am 28.04.2014 13:57, schrieb Huanghao (Alex, SingleAS): >> / argv = mkIRExprVec_2( addr, data);/ >> / di = unsafeIRDirty_0_N( 2/*regparms*/,/ >> / hName, VG_(fnptr_to_fnentry)( hAddr ),/ >> / argv ); / >> / addStmtToIRSB( sbOut, IRStmt_Dirty(di) );/ > > >> /vex: priv/host_amd64_isel.c:627 (doHelperCall): Assertion >> `typeOfIRExpr(env->type_env, args[i]) == Ity_I64' failed./ > >>From the error: obviously, a dirty helper on amd64 only > accepts arguments which have a size of 64 bit. > For addresses, this is correct. But data may have different size. You must add a VEX instruction which extends your data to 64bit before using it as argument for a dirty helper. > > Josef > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available. > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > _______________________________________________ > Valgrind-developers mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-developers > |