Re: Instrument at marked locations
Eliot Moss <[email protected]> Wed, 29 Nov 2017 18:10:45 -0500
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
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