|
From: Julian S. <js...@ac...> - 2005-12-09 01:57:57
|
The args to mkIRExprVec_N need themselves to be IRExpr*s. So you
need to promote your pointers to that:
mkIRExprVec_1( IRExpr_Const(IRConst_U32(W))) on a 32-bit machine,or
mkIRExprVec_1(IRExpr_Const(IRConst_U64(W))) on a 64-bit target. I think
mkIRExpr_HWord does the word size and IRExpr_Const steps for you, so
you should be able to do=20
mkIExprVec_1( mkIRExpr_HWord(W) )
J
On Friday 09 December 2005 01:40, Michael E Locasto wrote:
> I should clarify that lu_instrument() is the instrumentation function
> (like lk_instrument() for lackey). I'm also working with the current
> source from svn.
>
> On Thu, 8 Dec 2005, Michael E Locasto wrote:
> > Hi folks,
> >
> > I searched the mailing list for "unsafeIRDirty_0_N" and "mkIRExprVec" b=
ut
> > 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 fin=
e.
> >
> > 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
> > register it to 'instrument' the code...
> >
> > Code below...any advice from those with more experience developing a to=
ol
> > for VG is much appreciated.
> >
> > Cheers,
> > Michael
> >
> > ---
> >
> > //fnname is a local automatic Char array of size 100 (as defined in //
> > 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 name=
s.
> > For example:
> >
> > ...
> > =3D=3D9048=3D=3D ;LUG_OUT; function [] called 92 times.
> > =3D=3D9048=3D=3D ;LUG_OUT; function [P=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=
=BD@=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BDlGb=C3=AF=C2=BF=
=C2=BDlGb=C3=AF=C2=BFtime.
> > =3D=3D9048=3D=3D ;LUG_OUT; function [H=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=
=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=
lGb=C3=AF=C2=BF=C2=BDlGbtime.
> > =3D=3D9048=3D=3D ;LUG_OUT; function [=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=
=BDL=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BDlGb=C3=AF=C2=BF=
=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF time.
> > =3D=3D9048=3D=3D ;LUG_OUT; function [=C3=98=C2=B6=C3=AF=C2=BF=C2=BD=C3=
=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BDlGb=C3=AF=C2=BF=C2=BD=C3=
=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BDtimes.
> > =3D=3D9048=3D=3D ;LUG_OUT; function [=C3=94=C2=B8=C3=AF=C2=BF=C2=BD=C3=
=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BDlGb=C3=AF=C2=BF=C2=BD=C3=
=AF=C2=BF=C2=BD=C3=AF=C2=BF=C2=BDtime.
> > ...
> >
> > when i replace fnname with a string literal, the data is fine:
> >
> > ...
> > =3D=3D10328=3D=3D ;LUG_OUT; function [foobar] called 1,416 times.
> > ...
> >
> > but that's not the kind of result I'm aiming for :)
|