Re: Re: Re: Re: Question for using ASM to log the method invocation trace.
Paul Keeble <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Tomcat used to (might still) kill shutdown hooks if they took too long. Emma was one such user of shutdown hooks that suffered badly as it didn't get time to write out its coverage data before the thread was killed. I had to use Grobo with continuous writing instead to get complete coverage picture. So you don't want to spend a long time in the shutdown hook, but a couple of seconds of work is not unreasonable. Any more than a few seconds and you might want another mechanism (continuous writing with a small buffer that is cleared by the shutdown hook). PK ________________________________ From: Scott Vachalek <[email protected]> To: Sai Zhang <[email protected]> Cc: Paul Keeble <[email protected]>; Zhongxian Gu <[email protected]>; [email protected] Sent: Thu, 22 July, 2010 23:09:11 Subject: [asm] Re: Re: Re: Question for using ASM to log the method invocation trace. You can put anything into a shutdown hook but it's not really designed for doing much more than closing resources etc. I imagine if you take too long, you risk having things like the garbage collector go away before you are done. It's also not a very user-friendly model, to suddenly start doing a lot of work when the user is trying to quit the application. On Thu, Jul 22, 2010 at 1:14 PM, Sai Zhang <[email protected]> wrote: Hi all: > >Setting up a shutdown hook for "cleaning" the instrumentation tasks seems to be >a good practice. However, I am >wondering could I insert "any" code to the code block of the shutdown hook ? > >that is: > > > >Runtime.getRuntime().addShutdownHook(new Thread() { > public void run() { > > //Could i insert arbitrary code here as normal Java programs? > //Could I do some sophisticated post-execution program analysis tasks here >without producing a trace file? > > >}}); > > >It seems that the shutdown hook may have some "side-effect". I have a fairly >complex procedure m() which >throws no exception when calling directly from main. However, it behaves >strangely when putting into the hook code block. > >I am just guessing is there any special side-effects here? > >thanks. Any comments are highly appreciated. > >- >Sai > > > > >On Wed, Jun 30, 2010 at 3:13 AM, Paul Keeble <[email protected]> wrote: > >Say you have a class: >>class Tracer { >>public static void trace(String ) >> >> >>public static void close() >>} >> >> >>Then you can happily insert the calls to Tracer.trace for the instrumenting. You >>can also right at the beginning of the program (before you instrument anything >>and when you set-up the FileWriter to begin with) set-up a shutdown hook using >>something like: >> >> >>Runtime.getRuntime().addShutdownHook(new Thread() { >> public void run() { >> Tracer.close(); >>}}); >> >> >>Its not a concern of the tracing to get the file stream closed, it is for the >>shutdown of the program. >> >> >>PK >> >> >> ________________________________ From: Zhongxian Gu <[email protected]> >>To: [email protected] >>Sent: Wed, 30 June, 2010 5:10:33 >>Subject: [asm] Question for using ASM to log the method invocation trace. >> >> >>Hi all, >> >>I wish to use ASM to instrument the code and during the run, record the method >>invocation trace. I use AdviceAdapter to do that. To enhance the performance, >>I use BufferedWriter to print info to the log file. The problem is that I don't >>know how to instrument the code to close the BufferedWriter. I must call it >>until all the >> >>methods called which is only known at run-time. Without calling close method >>will cause information missing in the buffer. >> >> >>I wonder if some of you have also experienced this condition and could you give >>me some hints. Thanks >> >>Best >> >>Zhongxian >> >>-- >>Zhongxian Gu >>http://wwwcsif.cs.ucdavis.edu/~gu/ >>Ph.D. Student in Computer Science, UC Davis >>2249 Kemper Hall >> >> >> >> >>-- >>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 > >
message-footer.txt
(text/plain, 238 B)
-- 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