Java thread dump on signal. Solaris vs. Windows
I found an jstack() line in one of DTraceToolkit script.
DTraceToolkit at OpenSolaris.org
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.
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.
- Download userdump from here and install.
- Download SendSignal and install.
SendSignal
it dumps a list of threads and all their held locks to stdout.
- Start "Process Dumper" from control panel. Add "java.exe" as an application to monitor.

- Add custom rule to java.exe.
- 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.
- Notice that I set "Switch the Dumper" option and specified SendSignal.
- 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.
- Open NetBeans. Write "Divide by Zero" in try/catch block. Run.

- Thread dump appears in "Output" window.
