Logging all method calls by modifying OpenJDK

Stefano Cristalli stefanocristalli at gmail.com
Mon Nov 13 15:37:38 UTC 2017


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