JNI functions "CallNonvirtual*" probe is incorrect
Yasumasa Suenaga
suenaga.yasumasa at oss.ntt.co.jp
Thu Apr 7 00:24:39 PDT 2011
Hi,
I've tried to test my program with SystemTap.
When I probed CallNonvirtualVoidMethod(), I seem to get incorrect value through "hotspot_jni.stp".
My test program result(attached it to this email: test.tar.gz) as following:
------------
[root at RHEL6 nonvirtual]# gcc -shared -fPIC -I$JAVA_HOME/include -I$JAVA_HOME/include/linux -o libnonvirtual.so jni.c
[root at RHEL6 nonvirtual]# javac Main.java
[root at RHEL6 nonvirtual]# stap -c 'java -Djava.library.path=. Main' ../tapset/jnifunc.stp
from JNI: env = 0x7fb99c0071b8, obj = 0x7fb9a0d638c0, clazz = 0x7fb99c068950, methodID = 0x9c064290
from CallStub!
CallNonvirtualVoidMethod(env=0x7fb99c0071b8,obj=0x7fb9a0d638c0,methodid=0x7fb99c068950), arg4=0x7fb99c064290
------------
"from ..." is printed from JNI code.
"CallNonvirtualVoidMethod( ..." is printed from SystemTap probepoint (through "probestr").
"clazz" does not exist in hotspot_jni.stp, and methodid points clazz.
In HotSpot source code (hotspot/src/share/vm/prims/jni.cpp) defines CallNonvirtual functions as folllowing:
------------
#define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \
\
DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\
DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType);\
DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType);\
\
JNI_ENTRY(ResultType, \
jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \
JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \
\
DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##Method__entry, env, obj, cls, methodID);\
------------
$arg3 points cls, $arg4 points methodID.
In order to fix this problem, I made a patch for "hotspot_jni.stp.in" .
The patch that attached this mail(hotspot_jni.patch) works well on RHEL6.
------------
[root at RHEL6 nonvirtual]# stap -c 'java -Djava.library.path=. Main' ../tapset/jnifunc.stp
from JNI: env = 0x7fbbcc0071b8, obj = 0x7fbbd18e18c0, clazz = 0x7fbbcc068950, methodID = 0xcc064290
from CallStub!
CallNonvirtualVoidMethod(env=0x7fbbcc0071b8,obj=0x7fbbd18e18c0,clazz=0x7fbbcc068950,methodid=0x7fbbcc064290), arg4=0x7fbbcc064290
------------
Please merge this patch if you don't fix this problem yet.
Best regards,
Yasumasa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tar.gz
Type: application/x-gzip-compressed
Size: 820 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20110407/a63011ff/test.tar.gz
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hotspot_jni.patch
Url: http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20110407/a63011ff/hotspot_jni.patch
More information about the distro-pkg-dev
mailing list