Re: [PATCH v8 2/4] perf inject: add jitdump mmap injection support

From: Arnaldo Carvalho de Melo
Date: Fri Feb 05 2016 - 08:51:29 EST


Em Fri, Feb 05, 2016 at 10:47:31AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Feb 04, 2016 at 03:02:59PM -0800, Stephane Eranian escreveu:
> > > I'm keeping what I have a perf/jit branch in my git tree.
>
> What am I doing wrong? Continuing to investigate...
> #7 0x00007fef53f31b3a in strlen () from /lib64/libc.so.6
> #8 0x00007fef51e8e4c1 in compiled_method_load_cb (jvmti=0x7fef4c003ef0, method=<optimized out>, code_size=520, code_addr=0x7fef3d0ffd00, map_length=<optimized out>,
> map=0x0, compile_info=0x7fef04019e80) at libjvmti.c:85


Ok, this bandaid cured the segfault:


-------------------------------------------------------------
diff --git a/tools/perf/jvmti/libjvmti.c b/tools/perf/jvmti/libjvmti.c
index 745f20c7b4bd..92ffbe4ff160 100644
--- a/tools/perf/jvmti/libjvmti.c
+++ b/tools/perf/jvmti/libjvmti.c
@@ -82,7 +82,7 @@ compiled_method_load_cb(jvmtiEnv *jvmti,
* append file name, we use loops and not string ops to avoid modifying
* class_sign which is used later for the symbol name
*/
- for (j = 0; i < (PATH_MAX - 1) && j < strlen(file_name); j++, i++)
+ for (j = 0; i < (PATH_MAX - 1) && file_name && j < strlen(file_name); j++, i++)
fn[i] = file_name[j];
fn[i] = '\0';
} else {
-------------------------------------------------------------

Now:

[acme@jouet java]$ java -agentpath:/home/acme/git/linux/tools/perf/jvmti/libjvmti.so hello.java
java: jvmti: jitdump in /home/acme/.debug/jit/java-jit-20160205.XXdDr2Wr/jit-28322.dump
Error: Could not find or load main class hello.java
[acme@jouet java]$

Do I need to set CLASSPATH or something? /me tries...



> #9 0x00007fef536982b1 in JvmtiExport::post_compiled_method_load (nm=nm@entry=0x7fef3d0ffb90)
> at /usr/src/debug/java-1.8.0-openjdk-1.8.0.71-1.b15.fc23.x86_64/openjdk/hotspot/src/share/vm/prims/jvmtiExport.cpp:1793
> #10 0x00007fef536a68d4 in JvmtiDeferredEvent::post (this=<optimized out>)
> at /usr/src/debug/java-1.8.0-openjdk-1.8.0.71-1.b15.fc23.x86_64/openjdk/hotspot/src/share/vm/prims/jvmtiImpl.cpp:957
> #11 0x00007fef538c54a8 in ServiceThread::service_thread_entry (jt=0x7fef4c0d0000, __the_thread__=0x7fef4c0d0000)
> at /usr/src/debug/java-1.8.0-openjdk-1.8.0.71-1.b15.fc23.x86_64/openjdk/hotspot/src/share/vm/runtime/serviceThread.cpp:120
> #12 0x00007fef53976343 in JavaThread::thread_main_inner (this=this@entry=0x7fef4c0d0000)
> at /usr/src/debug/java-1.8.0-openjdk-1.8.0.71-1.b15.fc23.x86_64/openjdk/hotspot/src/share/vm/runtime/thread.cpp:1699
> #13 0x00007fef53976814 in JavaThread::run (this=0x7fef4c0d0000)
> at /usr/src/debug/java-1.8.0-openjdk-1.8.0.71-1.b15.fc23.x86_64/openjdk/hotspot/src/share/vm/runtime/thread.cpp:1679
> #14 0x00007fef5381ffc2 in java_start (thread=0x7fef4c0d0000)
> at /usr/src/debug/java-1.8.0-openjdk-1.8.0.71-1.b15.fc23.x86_64/openjdk/hotspot/src/os/linux/vm/os_linux.cpp:782
> #15 0x00007fef5489860a in start_thread () from /lib64/libpthread.so.0
> #16 0x00007fef53fa9a4d in clone () from /lib64/libc.so.6
> (gdb)
>
>
> And it generates this file:
>
> /home/acme/.debug/jit/java-jit-20160205.XXIKKHRA/jit-27730.dump
>
> Continuing...
>
> - Arnaldo