dtrace, jstack and lang/openjdk7 or 8

Johannes Dieterich dieterich.joh at gmail.com
Mon Apr 6 12:40:59 UTC 2015


Hi,

sorry for the late response!

On Thu, Mar 26, 2015 at 9:42 PM, Jung-uk Kim <jkim at freebsd.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> On 03/25/2015 19:02, Johannes Dieterich wrote:
>> Hi,
>>
>> I am currently trying to get dtrace to work with either
>> java/openjdk7 or java/openjdk8 (as per Brendan Gregg's howto:
>> http://www.brendangregg.com/blog/2014-06-12/java-flame-graphs.html).
>>
>>  Unfortunately, I get exactly what he describes: I am missing
>> everything inside the JVM. I suspect this has to do with jstack()
>> not working. The bundled jstack executable (yes, I know that they
>> are only vaguely related) also seems to work only so-so. Basically,
>> I can get a working stack trace without a variable, with -l, but
>> not with -m, and not with -F. It causes exceptions like this:
>>
>> $ /usr/local/openjdk7/bin/jstack -m 84749
> ...
>> So, what I am asking is: anybody out there got a working setup for
>> dtrace+openjdk on FreeBSD? If so, it would be fantastic if you
>> could post the necessary steps!
>
> jstack from java/openjdk8 works fine AFAICT.  Unfortunately, dtrace is
> unimplemented for FreeBSD.
I did a bit of research and found this in the hotspot sources:
http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/os/bsd/dtrace/jhelper.d
. Do I interpret this (and the entire directory) correctly that there
are at least the stubs available in openJDK8? Is so, what is missing
for dtrace to work?

> BTW, 'jstack -m <pid>' is invalid command, i.e., it does not work with
> a running process.  You need to set '-F' option to force it.
>
> % /usr/local/openjdk8/bin/jstack
> Usage:
>     jstack [-l] <pid>
>         (to connect to running process)
>     jstack -F [-m] [-l] <pid>
>         (to connect to a hung process)
>     jstack [-m] [-l] <executable> <core>
>         (to connect to a core file)
>     jstack [-m] [-l] [server_id@]<remote server IP or hostname>
>         (to connect to a remote debug server)
>
> Options:
>     -F  to force a thread dump. Use when jstack <pid> does not respond
> (process is hung)
>     -m  to print both java and native frames (mixed mode)
>     -l  long listing. Prints additional information about locks
>     -h or -help to print this help message
Thanks, it seems Dmitry below thinks -m should imply -F (so did I).
Indeed, jstack -m -F $PID also throws a stack for me. I attached the
full one, in case it helps?

Thanks again for all the responses!

Johannes

> Jung-uk Kim
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2
>
> iQEcBAEBCAAGBQJVFG9MAAoJEHyflib82/FG4F0H/3Z+5fTXMzQYBCeWGMZicjMB
> 092HOaXctRZ5P+I5HZO199bfFLffV6Pu1pd2/jjguOqkmF4eVL6AXwQBglg19RPs
> BEwhSLRLhuWc11XyikE2RG3PvvDRvhXl6AeqtKkcUi4LedjS3BlqmlGpTorJzpO3
> OqarnzGMyAHPS5QxPPUcASG4B+la6o1sVn94UiynUWnd3yXTe4uE4Ed4YeV2oBXh
> BGVLhTdsWoamNpMwX9JrOMNwRPahYpoDCjeC2jlKPGPCXQiTWthlupLidXuKUI/a
> OJi+VSAzNPMx5s1p2JSKwAp+tT6oX8BaFK0zA+J6cyBcBqqbWvA6LV+v9f8c/5A=
> =x1pC
> -----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: full_stack
Type: application/octet-stream
Size: 30850 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-java/attachments/20150406/bedb43f9/attachment.obj>


More information about the freebsd-java mailing list