Re: Instrument at marked locations

"ThanhVu (Vu) Nguyen" <[email protected]> Wed, 29 Nov 2017 23:23:50 +0000
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CA+OL+Mh2CMQdy5ig=_wScu6c2eBrbjGS10TazqRvibRzaw72Kw@mail.gmail.com>
Eliot, thanks for the quick rely.  I want to be specify that I want the
trace of x and y at a location and the trace of say  a b c d at another
location.  For example,
somecode
//@trace:  int x, int y
some more code
//@trace:  int a, int b, int c
So a single static trace method wouldn't work.

Is there a way to "annotate" these information, e.g., a list of strings
["int x", "int y"] somehow ?



On Wed, Nov 29, 2017 at 5:10 PM Eliot Moss <[email protected]> wrote:

> On 11/29/2017 6:03 PM, ThanhVu (Vu) Nguyen wrote:
> > Hi all,
> > I want to use ASM to instrument program at certain marked locations.
> > For example, in my original program, I might have
> > ...
> > somecode
> > //@trace:  int x, int y, int z
> > some more code
> > ...
> >
> > I want to use ASM to instrument code at the trace locations,
> > ...
> > somecode
> > System.out.printf("trace: %d %d %d\n, x,y,z);
> > some more code
> > ...
> >
> > But I am not sure how I would "mark" the locations so that ASM can see
> them.  I cannot use comments
> > as above, e.g., //@trace, because they are not kept in the bytecode. I
> am thinking about using
> > annotation but not sure how that would work.  A potential solution is
> actually introducing some
> > trace method and instead of @trace I would call trace(x,y,z);   But I
> want to avoid this.
> >
> > Any suggestions ?
>
> Dear ThanhVu --
>
> I would come up with some new static method somewhere that takes no
> arguments and returns
> void.  Put calls of that method in your code.  Then, in asm, where you see
> an invokestatic
> of that method, you replace it with what you want.
>
> Regards - Eliot Moss
>
> --
> You receive this message as a subscriber of the [email protected] mailing list.
> To unsubscribe: mailto:[email protected]
> For general help: mailto:[email protected]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws