get stack trace of a detached jvm

To get the stack trace of a running java process the usual way is to hit Ctrl-\\ on the terminal.

The jvm then print out its current state and threads'stacks.


This become a problem when the Java program is detached from the terminal as all the outputs are then discarded.

Starting to JDK5, the jstack tool is here to help or when you own the code running into the jvm and/or you can change

the way the jvm is launched an easy way is to redirect the standard streams to log file and then to send the

QUIT signal to the jvm pid.


I had to deal with another situation in which jvm was running on jdk 4 and It was not possible to change anything about it.


The trick I then used was to write a small script which catch all the write calls on  stderr on the jvm .

The script use strace(1) on Linux and truss(1) on Solaris to catch what is passed to write calls on file descriptor 1.


This script is available here : catch_vm_dump.tcl


Here is an example of how to use it. Outputs are a little ugly but it works :-)
Once the script is launched, I send QUIT to the pid 1103.

oups


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Emmanuel Jannetti blog

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today