merging Java thread dump and native thread dump

If you have a native thread dump which look like this,
  74  Id: ec0.d48 Suspend: 1 Teb: 7ff5b000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 327aecb0 7c977d29 719c1af5 0000183c 00000001 ntdll!KiFastSystemCallRet
01 327aecb4 719c1af5 0000183c 00000001 327aecdc ntdll!ZwWaitForSingleObject+0xc
02 327aecf0 719c1a03 0000183c 00001818 00000000 mswsock!SockWaitForSingleObject+0x19d
03 327aede0 71aa283c 00001819 327aee4c 00000000 mswsock!WSPSelect+0x380
\*\*\* ERROR: Symbol file could not be found.  Defaulted to export symbols for D:\\Program Files\\Java\\jdk1.6.0_07\\jre\\bin\\net.dll - 
04 327aee30 6d627b91 00001819 327aee4c 00000000 WS2_32!select+0xb9
WARNING: Stack unwind information not available. Following frames may be wrong.
05 327aef58 6d62701d 00001818 000003e8 2f138800 net!NET_Timeout+0x4a
06 327af778 009c9c91 2fc49008 327af7ec 327af7e8 net!Java_java_net_SocketInputStream_socketRead0+0xba
07 327af87c 6d8c5c8f 6d8c5ca7 2f138800 6d9344b9 0x9c9c91
08 327af880 6d8c5ca7 2f138800 6d9344b9 6d9344c7 jvm!JVM_EnqueueOperation+0x3ccbf
Above is taken in Windows windbg/cdb.

You can sort of merge it with Java thread dump with this perl script.
Now the remaining problem is how you take Java thread dump and native dump at the same time.
I'm guessing JRockit already has it.

Running Diagnostic Commands
nativestack=true will print C-level stacktraces as well as Java traces.

#!/usr/bin/perl -w
use strict;
use warnings;
my %callstack;
my $threadid;

open(JAVATD, $ARGV[0]) or die ($!);
open(NATIVETD, $ARGV[1]) or die ($!);

while (<JAVATD>) {
    if (/nid=0x([[:xdigit:]]+)/) {
        $threadid = $1;
        $callstack{$threadid} = $_;
    } elsif ($threadid && ! /\^$/) {
        $callstack{$threadid} .= $_;
    }
}
close JAVATD;

while (<NATIVETD>) {
    if (/Id: [[:xdigit:]]+.([[:xdigit:]]+)/ && exists $callstack{$1}) {
        print "= = = = java thread dump = = = =\\n";
        print $callstack{$1};
        print "= = = =\\n";
        delete $callstack{$1};
    }
    print;
}
close NATIVETD;
print "\\n= = = = java thread without matching native dump = = = =\\n";
print values %callstack;
print "= = = =\\n";

You give Java thread file as 1st arg and native thread dump file as 2nd arg.
= = = = java thread dump = = = =
"JMS AsyncWireDedicatedThread S0C0W1" daemon prio=6 tid=0x2f138800 nid=0xd48 runnable [0x327af000..0x327afa98]   java.lang.Thread.State: RUNNABLE
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
        - locked <0x0f75a1b0> (a java.io.BufferedInputStream)
        at java.io.FilterInputStream.read(FilterInputStream.java:66)
        at java.io.PushbackInputStream.read(PushbackInputStream.java:122)
        at com.stc.jms.sockets.AsyncWireDedicatedThread.triggerRead(AsyncWireDedicatedThread.java:124)
        - locked <0x0f75a1d0> (a com.stc.jms.sockets.AsyncWireDedicatedThread)
        at com.stc.jms.sockets.AsyncWireDedicatedThread.access$300(AsyncWireDedicatedThread.java:52)
        at com.stc.jms.sockets.AsyncWireDedicatedThread$AsyncTask.isDone(AsyncWireDedicatedThread.java:187)
        - locked <0x0f75a1d0> (a com.stc.jms.sockets.AsyncWireDedicatedThread)
        at com.stc.jms.sockets.AsyncWireDedicatedThread$AsyncTask.run(AsyncWireDedicatedThread.java:210)
        at java.lang.Thread.run(Thread.java:619)
= = = =
  74  Id: ec0.d48 Suspend: 1 Teb: 7ff5b000 Unfrozen
 # ChildEBP RetAddr  Args to Child              
00 327aecb0 7c977d29 719c1af5 0000183c 00000001 ntdll!KiFastSystemCallRet
01 327aecb4 719c1af5 0000183c 00000001 327aecdc ntdll!ZwWaitForSingleObject+0xc
02 327aecf0 719c1a03 0000183c 00001818 00000000 mswsock!SockWaitForSingleObject+0x19d
03 327aede0 71aa283c 00001819 327aee4c 00000000 mswsock!WSPSelect+0x380



Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
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
31
  
       
Today