|
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 :) |
|
From: Michael E L. <me...@co...> - 2005-12-09 01:40:49
|
I should clarify that lu_instrument() is the instrumentation function=20
(like lk_instrument() for lackey). I'm also working with the current=20
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" 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, i=
t
> 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 regist=
er=20
> 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.=
For=20
> example:
>
> ...
> =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.
> ...
>
> 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 :) |
|
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 :)
|
|
From: Michael E L. <me...@co...> - 2005-12-09 02:24:35
|
Thanks for the help...I was passing it through mkIRExpr_HWord() already,=20
which is why I couldn't understand why things weren't working.
The issue was that fnname is a local automatic var and keeps being=20
overwritten as BB's are instrumented, so I'm guessing the registered
instrumentation kept referring to the wrong stuff... I just made it global=
=20
and it seems to work fine.
Cheers,
Michael
On Fri, 9 Dec 2005, Julian Seward wrote:
>
> 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
>
> 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 strin=
g
>>> 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 tha=
t
>>> 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=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.
>>> ...
>>>
>>> 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 :)
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi=
les
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_idv37&alloc_id=16865&op?k
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
> |