OSDN Git Service

Tracing for developers of native methods.
authorElliott Hughes <enh@google.com>
Wed, 7 Jul 2010 21:47:25 +0000 (14:47 -0700)
committerElliott Hughes <enh@google.com>
Thu, 15 Jul 2010 23:03:09 +0000 (16:03 -0700)
commit8afa9dfe04354e5b3917e31e3e2772885f507580
treed96eab4a9f89da1615c07ee54e255d4dcff77c23
parent8e7704d14f6f756f7b1ff8a0eeaff52717ad8009
Tracing for developers of native methods.

The existing -verbose:jni is mainly useful for VM developers hacking on the JNI
implementation; this is intended to replace the ad hoc logging developers of
native methods need to write.

Use "-Xint:portable -Xjnitrace:ClassNameSubstring" on the command line. To
trace all native methods (mainly useful for testing the tracing), use
"-Xjnitrace:"; to trace just methods in java.util.regex.Matcher, use
"-Xjnitrace:Matcher" or "-Xjnitrace:Ljava/util/regex/Matcher;" or whatever.
To trace all the methods in Matcher and Pattern, you have to use something
like "-Xjnitrace:java/util/regex/". There's no facility for tracing an
individual method or group of methods because I haven't needed such a thing.

Here's a basic example:

 -> Ljava/nio/charset/Charsets;.toUtf8Bytes([CII)[B (0x400474b8, 0, 5)
 <- Ljava/nio/charset/Charsets;.toUtf8Bytes([CII)[B returned 0x40047548

Here's an example of a non-static native method:

 -> Lorg/apache/harmony/luni/platform/OSFileSystem;.writeImpl(I[BII)J this=0x40012e78 (1, 0x400476d0, 0, 5)
 <- Lorg/apache/harmony/luni/platform/OSFileSystem;.writeImpl(I[BII)J returned 5

Here's an interesting example showing another native method being called, and
an exception being thrown by a native method:

 -> Ljava/lang/VMClassLoader;.loadClass(Ljava/lang/String;Z)Ljava/lang/Class; (0x400466b8, false)
 -> Ljava/lang/Throwable;.nativeFillInStackTrace()Ljava/lang/Object; ()
 <- Ljava/lang/Throwable;.nativeFillInStackTrace()Ljava/lang/Object; returned 0x400467c8
 <- Ljava/lang/VMClassLoader;.loadClass(Ljava/lang/String;Z)Ljava/lang/Class; threw Ljava/lang/ClassNotFoundException;

(This functionality needs to be enabled at compile time. A later patch will
address that.)

Change-Id: I6da8930bd4b4f228e07b05cc59a3aea331c5cee1
14 files changed:
vm/CheckJni.c
vm/Dvm.mk
vm/Globals.h
vm/Init.c
vm/Native.c
vm/Native.h
vm/arch/x86-atom/Call386ABI.S
vm/interp/Interp.c
vm/mterp/c/gotoTargets.c
vm/mterp/out/InterpC-allstubs.c
vm/mterp/out/InterpC-portdbg.c
vm/mterp/out/InterpC-portstd.c
vm/mterp/out/InterpC-x86-atom.c
vm/mterp/out/InterpC-x86.c