Re: Instrument at marked locations
Eliot Moss <[email protected]> Wed, 29 Nov 2017 21:45:03 -0500
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
On 11/29/2017 6:23 PM, ThanhVu (Vu) Nguyen wrote: > 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 ? I would write however many methods you need, with different signatures, and include the variables you want to trace as arguments to the call. Thus: Tracer.trace(x, y); Tracer.trace(a, b, c); You will then see the code to push these locals followed by the call to Tracer.trace. It is possible to figure things out, but a bit more complicated. You could also do: Tracer.startTrace(); Tracer.trace(a, b, c); Here the startTrace calls clues you to what is coming, making it easier to pick it out. And you could support only single variable trace() calls, thus: Tracer.startTrace(); Tracer.trace(a); Tracer.trace(b); Tracer.trace(c); Tracer.endTrace(); You could even figure out a "varargs" call, which generates more complex bytecode. Of course, these could do the actual tracing work, and you could use your tool to cut out the bytecodes when you want to turn tracing off. But maybe we should step back and have you tell us what your overall goal is here. Usually that helps get better answers to what you're trying to figure out! 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