I found an jstack() line in one of DTraceToolkit script.

DTraceToolkit at OpenSolaris.org
DTraceToolkit is a collection of useful documented scripts developed by the OpenSolaris DTrace community
$ ggrep -B 4 -A 1 jstack DTraceToolkit-0.99/Proc/crash.d
proc:::signal-send
/self->crash && execname == "java"/
{
        printf("\nJava Stack Backtrace,");
        jstack();
}
Here's from man page.
$ man -M DTraceToolkit-0.99/Man crash.d | ggrep -A 1 -B 1 SIG
Reformatting page.  Please Wait... done
     crash.d monitors for applications that crash. When  a  crash
     via a SIGSEGV or SIGBUS is detected, a report of the process
     state is printed out.
So, I guess this script is supposed to dump java stacktrace when JVM crashes. Unfortunately, I couldn't confirm it really does. Maybe, I should look our bugdb harder how I can cause JVM to SIGSEGV.

Meanwhile, I experimented how I can do it on Windows. I think there are several ways. I'll explain here which I think is the safest way.

  1. Download userdump from here and install.
  2. Download SendSignal and install.
    SendSignal
    it dumps a list of threads and all their held locks to stdout.

  3. Start "Process Dumper" from control panel. Add "java.exe" as an application to monitor.



  4. Add custom rule to java.exe.
    1. Notice that I chose "Divide by Zero". SIGSEGV, SIGBUS equivalent on Windows is "Access Violation". For now, I choose "Divide by Zero"(SIGFPE equivalent) because causing "Access Violation" is harder.
    2. Notice that I set "Switch the Dumper" option and specified SendSignal.



  5. Open NetBeans. Write "Divide by Zero" in try/catch block. Run.



  6. Thread dump appears in "Output" window.
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by Katsumi Inoue