|
From: Michael E L. <me...@co...> - 2005-12-09 01:29:50
|
Hi folks,
I searched the mailing list for "unsafeIRDirty_0_N" and "mkIRExprVec" but
didn't come up with any hits.
I'm attempting to call a helper function from within lu_instrument() by
using unsafeIRDirty_0_N(). I'd like to pass a character array to the
helper function. I am converting the character array to an IRExpr** by
invoking mkIRExprVec_1() but when the data gets to the helper function, it
is garbled (looks like random chunks of mem). When I pass in a string
literal (e.g., "foobar" below), it gets to the helper function just fine.
I looked at the implementation of mkIRExpr_HWord() and I'm guessing that
it is expecting some kind of constant for the value of 'hw' ... none of
the other types seems to be relevant.
I can call my helper function directly, but this obviously doesn't=20
register it to 'instrument' the code...
Code below...any advice from those with more experience developing a tool
for VG is much appreciated.
Cheers,
Michael
---
//fnname is a local automatic Char array of size 100 (as defined in=20
// lackey's lu_instrument())
if(VG_(get_fnname_if_entry)(st->Ist.IMark.addr,
fnname, sizeof(fnname)))
{
IRExpr** argv;
argv =3D mkIRExprVec_1(mkIRExpr_HWord((HWord)fnname));
//argv =3D mkIRExprVec_1(mkIRExpr_HWord((HWord)"foobar"));
di =3D unsafeIRDirty_0_N( 0, "add_a_function_call",
&add_a_function_call,
argv);
addStmtToIRBB( bb, IRStmt_Dirty(di) );
}
when this code is invoked, my helper gets garbage for the function names.=
=20
For example:
=2E..
=3D=3D9048=3D=3D ;LUG_OUT; function [] called 92 times.
=3D=3D9048=3D=3D ;LUG_OUT; function [P=EF=BF=BD=EF=BF=BD@=EF=BF=BD=EF=BF=BD=
=EF=BF=BDlGb=EF=BF=BDlGb=EF=BFtime.
=3D=3D9048=3D=3D ;LUG_OUT; function [H=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=
=EF=BF=BD=EF=BF=BDlGb=EF=BF=BDlGbtime.
=3D=3D9048=3D=3D ;LUG_OUT; function [=EF=BF=BD=EF=BF=BDL=EF=BF=BD=EF=BF=BD=
=EF=BF=BDlGb=EF=BF=BD=EF=BF=BD=EF time.
=3D=3D9048=3D=3D ;LUG_OUT; function [=D8=B6=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=
=BF=BDlGb=EF=BF=BD=EF=BF=BD=EF=BF=BDtimes.
=3D=3D9048=3D=3D ;LUG_OUT; function [=D4=B8=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=
=BF=BDlGb=EF=BF=BD=EF=BF=BD=EF=BF=BDtime.
=2E..
when i replace fnname with a string literal, the data is fine:
=2E..
=3D=3D10328=3D=3D ;LUG_OUT; function [foobar] called 1,416 times.
=2E..
but that's not the kind of result I'm aiming for :) |