Logging all method calls by modifying OpenJDK

David Holmes david.holmes at oracle.com
Mon Nov 13 21:36:27 UTC 2017


Hi Stefano,

It sounds like javaCalls::call is used primarily on interpreted code 
paths, so once code has been running long enough and gets compiled you 
no longer go through your logging code. If you run with -Xint you should 
see all logging; if you run with -Xcomp you should see much less.

Modifying the JIT compiler to include the additional logging is probably 
quite complicated - and that's not even taking inlining into account.

David

On 14/11/2017 1:37 AM, Stefano Cristalli wrote:
> Hello everyone,
> 
> please pardon the duplicated request
> (https://stackoverflow.com/questions/47267178/logging-all-method-calls-by-modifying-openjdk)
> from StackOverflow, but I thought I'd also post here considering how
> specific the questions are.
> 
> I'm trying to modify the OpenJDK 9 in order to log every method called
> by a Java program, in particular I'm experimenting with a very simple
> class with a main that calls one of its own static methods that prints
> a line on stdout once every two seconds (waiting done with
> Thread.sleep) After reading a blog post (https://gbenson.net/?p=118),
> I've put logging code inside javaCalls::call. It works, logging lots
> of calls from the JVM start up to the call to Myclass.main, then it
> stops (my program keeps printing). After exiting the program with
> CTRL^C, the logging resumes and logs methods such as Thread.exit. I
> then tried another way: to instrument
> hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp at every
> bytecode for invoke. Worse than before, this doesn't print anything.
> 
> At first I was relying on the new JDK 9 logging feature, but then I
> decided to append directly to file to exclude the possibility that the
> log was disabled at some point.
> 
> I have two questions:
> 
> - Have I misinterpreted the cited blog? Shouldn't my first attempt be
> enough to log everything?
> - Do you have any suggestion for a point where I have better chances
> of accomplishing my goal?
> 
> Am I missing something?
> Thank you in advance for your time.
> 
> Best regards.
> 
> Stefano Cristalli
> 


More information about the hotspot-dev mailing list