summaryrefslogtreecommitdiffstats
path: root/vm/Native.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-06-22 13:24:06 -0700
committerElliott Hughes <enh@google.com>2011-06-28 17:31:46 -0700
commit5719d5c79558ffdbbb863ddcf61836221aba922d (patch)
tree62242b50c2b1692813a05daaa59151aedcc14c8e /vm/Native.cpp
parent2e31bb77dccb07315ad1a794c064a52633adfa34 (diff)
downloadandroid_dalvik-5719d5c79558ffdbbb863ddcf61836221aba922d.tar.gz
android_dalvik-5719d5c79558ffdbbb863ddcf61836221aba922d.tar.bz2
android_dalvik-5719d5c79558ffdbbb863ddcf61836221aba922d.zip
Improve -verbose:jni.
The old output just told you what functions were being called and made no attempt to show you their arguments. The new output was sufficient to debug an actual problem with an app we don't have the source to. Still to do: 0. an easier way for third-party developers to enable this. 1. the primitive type arguments to SetIntField and so forth. 2. return values. A few examples of the new output... A decoded jclass: JNI: libcore.io.Posix.readBytes called IsInstanceOf((JNIEnv*)0x9618470, 0x28100015, java.lang.Class<byte[]>) A decoded jfieldID: JNI: libcore.io.Posix.ioctlInt called GetIntField((JNIEnv*)0x9618470, 0x5cb00011, java.io.FileDescriptor.descriptor) A decoded jmethodID (the FileDescriptor constructor): JNI: libcore.io.Posix.open called NewObject((JNIEnv*)0x9780480, java.lang.Class<java.io.FileDescriptor>, java.io.FileDescriptor.<init>()V, ...) A const char*: JNI: libcore.io.Posix.getsockoptLinger called NewStringUTF((JNIEnv*)0x9618470, "getsockopt") A jint release mode: JNI: libcore.io.Posix.writeBytes called ReleaseByteArrayElements((JNIEnv*)0x9780480, 0x2700009, (void*) 0xf5f623c4, JNI_ABORT) The -verbose:jni option now turns on a bit more output about JNI_OnLoad calls but no longer causes any logging of calls to JNIEnv or JavaVM functions. The old -Xjnitrace: option has been extended to enable this new tracing for the native methods that it covers. They go very well together for debugging purposes. I've also made us a bit more verbose if we fail to initialize. In the longer term I think we want to just abort if we hit any failure during startup, but my extra logging will save us a bit of time next time we have one of these failures (this one was caused for me by only having one half of the finalizer watchdog change; I was missing the libcore side). (Cherry pick of 6734b8224fb869c94e42e704ec03f2ce8483af2b from dalvik-dev.) Change-Id: I69b7620b20620e9f06576da244520d9d83f89ab8
Diffstat (limited to 'vm/Native.cpp')
-rw-r--r--vm/Native.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/vm/Native.cpp b/vm/Native.cpp
index 1974863ff..5132dcc35 100644
--- a/vm/Native.cpp
+++ b/vm/Native.cpp
@@ -430,7 +430,9 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader,
self->classLoaderOverride = classLoader;
oldStatus = dvmChangeStatus(self, THREAD_NATIVE);
- LOGV("+++ calling JNI_OnLoad(%s)", pathName);
+ if (gDvm.verboseJni) {
+ LOGI("[Calling JNI_OnLoad for \"%s\"]", pathName);
+ }
version = (*func)(gDvmJni.jniVm, NULL);
dvmChangeStatus(self, oldStatus);
self->classLoaderOverride = prevOverride;
@@ -451,7 +453,9 @@ bool dvmLoadNativeCode(const char* pathName, Object* classLoader,
*/
result = false;
} else {
- LOGV("+++ finished JNI_OnLoad %s", pathName);
+ if (gDvm.verboseJni) {
+ LOGI("[Returned from JNI_OnLoad for \"%s\"]", pathName);
+ }
}
}