author | dcubed |
Thu, 12 Jun 2014 15:57:16 -0700 | |
changeset 25061 | b13d25e6a193 |
parent 24832 | 26a834fb508d |
child 29678 | dd2f3932c21e |
permissions | -rw-r--r-- |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
1 |
/* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
4 |
* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
8 |
* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
13 |
* accompanied this code). |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
14 |
* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
18 |
* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
21 |
* questions. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
22 |
*/ |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
23 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
24 |
/* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
25 |
* @test |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
26 |
* @bug 8036823 |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
27 |
* @bug 8046287 |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
28 |
* @summary Creates two threads contending for the same lock and checks |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
29 |
* whether jstack reports "locked" by more than one thread. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
30 |
* |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
31 |
* @library /testlibrary |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
32 |
* @run main/othervm TestThreadDumpMonitorContention |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
33 |
*/ |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
34 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
35 |
import java.io.BufferedReader; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
36 |
import java.io.InputStreamReader; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
37 |
import java.lang.management.ManagementFactory; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
38 |
import java.lang.management.RuntimeMXBean; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
39 |
import java.util.ArrayList; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
40 |
import java.util.List; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
41 |
import java.util.regex.Matcher; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
42 |
import java.util.regex.Pattern; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
43 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
44 |
import com.oracle.java.testlibrary.*; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
45 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
46 |
public class TestThreadDumpMonitorContention { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
47 |
// jstack tends to be closely bound to the VM that we are running |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
48 |
// so use getTestJDKTool() instead of getCompileJDKTool() or even |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
49 |
// getJDKTool() which can fall back to "compile.jdk". |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
50 |
final static String JSTACK = JDKToolFinder.getTestJDKTool("jstack"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
51 |
final static String PID = getPid(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
52 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
53 |
// looking for header lines with these patterns: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
54 |
// "ContendingThread-1" #19 prio=5 os_prio=64 tid=0x000000000079c000 nid=0x23 runnable [0xffff80ffb8b87000] |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
55 |
// "ContendingThread-2" #21 prio=5 os_prio=64 tid=0x0000000000780000 nid=0x2f waiting for monitor entry [0xfffffd7fc1111000] |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
56 |
// "ContendingThread-2" #24 prio=5 os_prio=64 tid=0x0000000000ec8800 nid=0x31 waiting on condition [0xfffffd7bbfffe000] |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
57 |
final static Pattern HEADER_PREFIX_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
58 |
"^\"ContendingThread-.*"); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
59 |
final static Pattern HEADER_WAITING_PATTERN1 = Pattern.compile( |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
60 |
"^\"ContendingThread-.* waiting for monitor entry .*"); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
61 |
final static Pattern HEADER_WAITING_PATTERN2 = Pattern.compile( |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
62 |
"^\"ContendingThread-.* waiting on condition .*"); |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
63 |
final static Pattern HEADER_RUNNABLE_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
64 |
"^\"ContendingThread-.* runnable .*"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
65 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
66 |
// looking for thread state lines with these patterns: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
67 |
// java.lang.Thread.State: RUNNABLE |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
68 |
// java.lang.Thread.State: BLOCKED (on object monitor) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
69 |
final static Pattern THREAD_STATE_PREFIX_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
70 |
" *java\\.lang\\.Thread\\.State: .*"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
71 |
final static Pattern THREAD_STATE_BLOCKED_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
72 |
" *java\\.lang\\.Thread\\.State: BLOCKED \\(on object monitor\\)"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
73 |
final static Pattern THREAD_STATE_RUNNABLE_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
74 |
" *java\\.lang\\.Thread\\.State: RUNNABLE"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
75 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
76 |
// looking for duplicates of this pattern: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
77 |
// - locked <0x000000076ac59e20> (a TestThreadDumpMonitorContention$1) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
78 |
final static Pattern LOCK_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
79 |
".* locked \\<.*\\(a TestThreadDumpMonitorContention.*"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
80 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
81 |
// sanity checking header and thread state lines associated |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
82 |
// with this pattern: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
83 |
// - waiting to lock <0x000000076ac59e20> (a TestThreadDumpMonitorContention$1) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
84 |
final static Pattern WAITING_PATTERN = Pattern.compile( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
85 |
".* waiting to lock \\<.*\\(a TestThreadDumpMonitorContention.*"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
86 |
|
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
87 |
final static Object barrier = new Object(); |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
88 |
volatile static boolean done = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
89 |
|
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
90 |
static int barrier_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
91 |
static int blank_line_match_cnt = 0; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
92 |
static int error_cnt = 0; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
93 |
static boolean have_header_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
94 |
static boolean have_thread_state_line = false; |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
95 |
static String header_line = null; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
96 |
static int header_prefix_match_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
97 |
static int locked_line_match_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
98 |
static String[] locked_match_list = new String[2]; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
99 |
static int n_samples = 15; |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
100 |
static int sum_both_running_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
101 |
static int sum_both_waiting_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
102 |
static int sum_contended_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
103 |
static int sum_locked_hdr_runnable_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
104 |
static int sum_locked_hdr_waiting1_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
105 |
static int sum_locked_hdr_waiting2_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
106 |
static int sum_locked_thr_state_blocked_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
107 |
static int sum_locked_thr_state_runnable_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
108 |
static int sum_one_waiting_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
109 |
static int sum_uncontended_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
110 |
static int sum_waiting_hdr_waiting1_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
111 |
static int sum_waiting_thr_state_blocked_cnt = 0; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
112 |
static String thread_state_line = null; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
113 |
static boolean verbose = false; |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
114 |
static int waiting_line_match_cnt = 0; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
115 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
116 |
public static void main(String[] args) throws Exception { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
117 |
if (args.length != 0) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
118 |
int arg_i = 0; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
119 |
if (args[arg_i].equals("-v")) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
120 |
verbose = true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
121 |
arg_i++; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
122 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
123 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
124 |
try { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
125 |
n_samples = Integer.parseInt(args[arg_i]); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
126 |
} catch (NumberFormatException nfe) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
127 |
System.err.println(nfe); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
128 |
usage(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
129 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
130 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
131 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
132 |
Runnable runnable = new Runnable() { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
133 |
public void run() { |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
134 |
synchronized (barrier) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
135 |
// let the main thread know we're running |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
136 |
barrier_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
137 |
barrier.notify(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
138 |
} |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
139 |
while (!done) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
140 |
synchronized (this) { } |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
141 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
142 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
143 |
}; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
144 |
Thread[] thread_list = new Thread[2]; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
145 |
thread_list[0] = new Thread(runnable, "ContendingThread-1"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
146 |
thread_list[1] = new Thread(runnable, "ContendingThread-2"); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
147 |
synchronized (barrier) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
148 |
thread_list[0].start(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
149 |
thread_list[1].start(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
150 |
|
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
151 |
// Wait until the contending threads are running so that |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
152 |
// we don't sample any thread init states. |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
153 |
while (barrier_cnt < 2) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
154 |
barrier.wait(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
155 |
} |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
156 |
} |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
157 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
158 |
doSamples(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
159 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
160 |
done = true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
161 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
162 |
thread_list[0].join(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
163 |
thread_list[1].join(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
164 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
165 |
if (error_cnt == 0) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
166 |
System.out.println("Test PASSED."); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
167 |
} else { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
168 |
System.out.println("Test FAILED."); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
169 |
throw new AssertionError("error_cnt=" + error_cnt); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
170 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
171 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
172 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
173 |
// Reached a blank line which is the end of the |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
174 |
// stack trace without matching either LOCK_PATTERN |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
175 |
// or WAITING_PATTERN. Rare, but it's not an error. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
176 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
177 |
// Example: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
178 |
// "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f runnable [0xfffffd7fc1111000] |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
179 |
// java.lang.Thread.State: RUNNABLE |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
180 |
// at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
181 |
// at java.lang.Thread.run(Thread.java:745) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
182 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
183 |
static boolean checkBlankLine(String line) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
184 |
if (line.length() == 0) { |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
185 |
blank_line_match_cnt++; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
186 |
have_header_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
187 |
have_thread_state_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
188 |
return true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
189 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
190 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
191 |
return false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
192 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
193 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
194 |
// Process the locked line here if we found one. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
195 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
196 |
// Example 1: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
197 |
// "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f runnable [0xfffffd7fc1111000] |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
198 |
// java.lang.Thread.State: RUNNABLE |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
199 |
// at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
200 |
// - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
201 |
// at java.lang.Thread.run(Thread.java:745) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
202 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
203 |
// Example 2: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
204 |
// "ContendingThread-1" #21 prio=5 os_prio=64 tid=0x00000000007b9000 nid=0x2f waiting for monitor entry [0xfffffd7fc1111000] |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
205 |
// java.lang.Thread.State: BLOCKED (on object monitor) |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
206 |
// at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
207 |
// - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
208 |
// at java.lang.Thread.run(Thread.java:745) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
209 |
// |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
210 |
// Example 3: |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
211 |
// "ContendingThread-2" #24 prio=5 os_prio=64 tid=0x0000000000ec8800 nid=0x31 waiting on condition [0xfffffd7bbfffe000] |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
212 |
// java.lang.Thread.State: RUNNABLE |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
213 |
// JavaThread state: _thread_blocked |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
214 |
// Thread: 0x0000000000ec8800 [0x31] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
215 |
// JavaThread state: _thread_blocked |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
216 |
// at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
217 |
// - locked <0xfffffd7e6d03eb28> (a TestThreadDumpMonitorContention$1) |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
218 |
// at java.lang.Thread.run(Thread.java:745) |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
219 |
// |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
220 |
static boolean checkLockedLine(String line) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
221 |
Matcher matcher = LOCK_PATTERN.matcher(line); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
222 |
if (matcher.matches()) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
223 |
if (verbose) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
224 |
System.out.println("locked_line='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
225 |
} |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
226 |
locked_match_list[locked_line_match_cnt] = new String(line); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
227 |
locked_line_match_cnt++; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
228 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
229 |
matcher = HEADER_RUNNABLE_PATTERN.matcher(header_line); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
230 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
231 |
sum_locked_hdr_runnable_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
232 |
} else { |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
233 |
// It's strange, but a locked line can also |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
234 |
// match the HEADER_WAITING_PATTERN{1,2}. |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
235 |
matcher = HEADER_WAITING_PATTERN1.matcher(header_line); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
236 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
237 |
sum_locked_hdr_waiting1_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
238 |
} else { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
239 |
matcher = HEADER_WAITING_PATTERN2.matcher(header_line); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
240 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
241 |
sum_locked_hdr_waiting2_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
242 |
} else { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
243 |
System.err.println(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
244 |
System.err.println("ERROR: header line does " + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
245 |
"not match runnable or waiting patterns."); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
246 |
System.err.println("ERROR: header_line='" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
247 |
header_line + "'"); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
248 |
System.err.println("ERROR: locked_line='" + line + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
249 |
"'"); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
250 |
error_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
251 |
} |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
252 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
253 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
254 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
255 |
matcher = THREAD_STATE_RUNNABLE_PATTERN.matcher(thread_state_line); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
256 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
257 |
sum_locked_thr_state_runnable_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
258 |
} else { |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
259 |
// It's strange, but a locked line can also |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
260 |
// match the THREAD_STATE_BLOCKED_PATTERN. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
261 |
matcher = THREAD_STATE_BLOCKED_PATTERN.matcher( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
262 |
thread_state_line); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
263 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
264 |
sum_locked_thr_state_blocked_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
265 |
} else { |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
266 |
System.err.println(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
267 |
System.err.println("ERROR: thread state line does not " + |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
268 |
"match runnable or waiting patterns."); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
269 |
System.err.println("ERROR: " + "thread_state_line='" + |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
270 |
thread_state_line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
271 |
System.err.println("ERROR: locked_line='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
272 |
error_cnt++; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
273 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
274 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
275 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
276 |
// Have everything we need from this thread stack |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
277 |
// that matches the LOCK_PATTERN. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
278 |
have_header_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
279 |
have_thread_state_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
280 |
return true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
281 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
282 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
283 |
return false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
284 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
285 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
286 |
// Process the waiting line here if we found one. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
287 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
288 |
// Example: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
289 |
// "ContendingThread-2" #22 prio=5 os_prio=64 tid=0x00000000007b9800 nid=0x30 waiting for monitor entry [0xfffffd7fc1010000] |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
290 |
// java.lang.Thread.State: BLOCKED (on object monitor) |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
291 |
// at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
292 |
// - waiting to lock <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
293 |
// at java.lang.Thread.run(Thread.java:745) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
294 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
295 |
static boolean checkWaitingLine(String line) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
296 |
Matcher matcher = WAITING_PATTERN.matcher(line); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
297 |
if (matcher.matches()) { |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
298 |
waiting_line_match_cnt++; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
299 |
if (verbose) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
300 |
System.out.println("waiting_line='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
301 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
302 |
|
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
303 |
matcher = HEADER_WAITING_PATTERN1.matcher(header_line); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
304 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
305 |
sum_waiting_hdr_waiting1_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
306 |
} else { |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
307 |
System.err.println(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
308 |
System.err.println("ERROR: header line does " + |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
309 |
"not match a waiting pattern."); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
310 |
System.err.println("ERROR: header_line='" + header_line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
311 |
System.err.println("ERROR: waiting_line='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
312 |
error_cnt++; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
313 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
314 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
315 |
matcher = THREAD_STATE_BLOCKED_PATTERN.matcher(thread_state_line); |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
316 |
if (matcher.matches()) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
317 |
sum_waiting_thr_state_blocked_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
318 |
} else { |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
319 |
System.err.println(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
320 |
System.err.println("ERROR: thread state line " + |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
321 |
"does not match a waiting pattern."); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
322 |
System.err.println("ERROR: thread_state_line='" + |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
323 |
thread_state_line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
324 |
System.err.println("ERROR: waiting_line='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
325 |
error_cnt++; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
326 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
327 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
328 |
// Have everything we need from this thread stack |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
329 |
// that matches the WAITING_PATTERN. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
330 |
have_header_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
331 |
have_thread_state_line = false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
332 |
return true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
333 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
334 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
335 |
return false; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
336 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
337 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
338 |
static void doSamples() throws Exception { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
339 |
for (int count = 0; count < n_samples; count++) { |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
340 |
blank_line_match_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
341 |
header_prefix_match_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
342 |
locked_line_match_cnt = 0; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
343 |
waiting_line_match_cnt = 0; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
344 |
// verbose mode or an error has a lot of output so add more space |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
345 |
if (verbose || error_cnt > 0) System.out.println(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
346 |
System.out.println("Sample #" + count); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
347 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
348 |
// We don't use the ProcessTools, OutputBuffer or |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
349 |
// OutputAnalyzer classes from the testlibrary because |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
350 |
// we have a complicated multi-line parse to perform |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
351 |
// on a narrow subset of the JSTACK output. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
352 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
353 |
// - we only care about stack traces that match |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
354 |
// HEADER_PREFIX_PATTERN; only two should match |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
355 |
// - we care about at most three lines from each stack trace |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
356 |
// - if both stack traces match LOCKED_PATTERN, then that's |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
357 |
// a failure and we report it |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
358 |
// - for a stack trace that matches LOCKED_PATTERN, we verify: |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
359 |
// - the header line matches HEADER_RUNNABLE_PATTERN |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
360 |
// or HEADER_WAITING_PATTERN{1,2} |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
361 |
// - the thread state line matches THREAD_STATE_BLOCKED_PATTERN |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
362 |
// or THREAD_STATE_RUNNABLE_PATTERN |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
363 |
// - we report any mismatches as failures |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
364 |
// - for a stack trace that matches WAITING_PATTERN, we verify: |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
365 |
// - the header line matches HEADER_WAITING_PATTERN1 |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
366 |
// - the thread state line matches THREAD_STATE_BLOCKED_PATTERN |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
367 |
// - we report any mismatches as failures |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
368 |
// - the stack traces that match HEADER_PREFIX_PATTERN may |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
369 |
// not match either LOCKED_PATTERN or WAITING_PATTERN |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
370 |
// because we might observe the thread outside of |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
371 |
// monitor operations; this is not considered a failure |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
372 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
373 |
// When we do observe LOCKED_PATTERN or WAITING_PATTERN, |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
374 |
// then we are checking the header and thread state patterns |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
375 |
// that occurred earlier in the current stack trace that |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
376 |
// matched HEADER_PREFIX_PATTERN. We don't use data from |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
377 |
// stack traces that don't match HEADER_PREFIX_PATTERN and |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
378 |
// we don't mix data between the two stack traces that do |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
379 |
// match HEADER_PREFIX_PATTERN. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
380 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
381 |
Process process = new ProcessBuilder(JSTACK, PID) |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
382 |
.redirectErrorStream(true).start(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
383 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
384 |
BufferedReader reader = new BufferedReader(new InputStreamReader( |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
385 |
process.getInputStream())); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
386 |
String line; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
387 |
while ((line = reader.readLine()) != null) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
388 |
Matcher matcher = null; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
389 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
390 |
// process the header line here |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
391 |
if (!have_header_line) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
392 |
matcher = HEADER_PREFIX_PATTERN.matcher(line); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
393 |
if (matcher.matches()) { |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
394 |
header_prefix_match_cnt++; |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
395 |
if (verbose) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
396 |
System.out.println(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
397 |
System.out.println("header='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
398 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
399 |
header_line = new String(line); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
400 |
have_header_line = true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
401 |
continue; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
402 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
403 |
continue; // skip until have a header line |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
404 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
405 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
406 |
// process the thread state line here |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
407 |
if (!have_thread_state_line) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
408 |
matcher = THREAD_STATE_PREFIX_PATTERN.matcher(line); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
409 |
if (matcher.matches()) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
410 |
if (verbose) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
411 |
System.out.println("thread_state='" + line + "'"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
412 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
413 |
thread_state_line = new String(line); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
414 |
have_thread_state_line = true; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
415 |
continue; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
416 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
417 |
continue; // skip until we have a thread state line |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
418 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
419 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
420 |
// process the locked line here if we find one |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
421 |
if (checkLockedLine(line)) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
422 |
continue; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
423 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
424 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
425 |
// process the waiting line here if we find one |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
426 |
if (checkWaitingLine(line)) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
427 |
continue; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
428 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
429 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
430 |
// process the blank line here if we find one |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
431 |
if (checkBlankLine(line)) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
432 |
continue; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
433 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
434 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
435 |
process.waitFor(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
436 |
|
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
437 |
if (header_prefix_match_cnt != 2) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
438 |
System.err.println(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
439 |
System.err.println("ERROR: should match exactly two headers."); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
440 |
System.err.println("ERROR: header_prefix_match_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
441 |
header_prefix_match_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
442 |
error_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
443 |
} |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
444 |
|
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
445 |
if (locked_line_match_cnt == 2) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
446 |
if (locked_match_list[0].equals(locked_match_list[1])) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
447 |
System.err.println(); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
448 |
System.err.println("ERROR: matching lock lines:"); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
449 |
System.err.println("ERROR: line[0]'" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
450 |
locked_match_list[0] + "'"); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
451 |
System.err.println("ERROR: line[1]'" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
452 |
locked_match_list[1] + "'"); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
453 |
error_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
454 |
} |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
455 |
} |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
456 |
|
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
457 |
if (locked_line_match_cnt == 1) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
458 |
// one thread has the lock |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
459 |
if (waiting_line_match_cnt == 1) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
460 |
// and the other contended for it |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
461 |
sum_contended_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
462 |
} else { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
463 |
// and the other is just running |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
464 |
sum_uncontended_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
465 |
} |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
466 |
} else if (waiting_line_match_cnt == 1) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
467 |
// one thread is waiting |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
468 |
sum_one_waiting_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
469 |
} else if (waiting_line_match_cnt == 2) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
470 |
// both threads are waiting |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
471 |
sum_both_waiting_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
472 |
} else { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
473 |
// both threads are running |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
474 |
sum_both_running_cnt++; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
475 |
} |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
476 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
477 |
// slight delay between jstack launches |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
478 |
Thread.sleep(500); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
479 |
} |
25061
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
480 |
|
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
481 |
if (error_cnt != 0) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
482 |
// skip summary info since there were errors |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
483 |
return; |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
484 |
} |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
485 |
|
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
486 |
System.out.println("INFO: Summary for all samples:"); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
487 |
System.out.println("INFO: both_running_cnt=" + sum_both_running_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
488 |
System.out.println("INFO: both_waiting_cnt=" + sum_both_waiting_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
489 |
System.out.println("INFO: contended_cnt=" + sum_contended_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
490 |
System.out.println("INFO: one_waiting_cnt=" + sum_one_waiting_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
491 |
System.out.println("INFO: uncontended_cnt=" + sum_uncontended_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
492 |
System.out.println("INFO: locked_hdr_runnable_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
493 |
sum_locked_hdr_runnable_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
494 |
System.out.println("INFO: locked_hdr_waiting1_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
495 |
sum_locked_hdr_waiting1_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
496 |
System.out.println("INFO: locked_hdr_waiting2_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
497 |
sum_locked_hdr_waiting2_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
498 |
System.out.println("INFO: locked_thr_state_blocked_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
499 |
sum_locked_thr_state_blocked_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
500 |
System.out.println("INFO: locked_thr_state_runnable_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
501 |
sum_locked_thr_state_runnable_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
502 |
System.out.println("INFO: waiting_hdr_waiting1_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
503 |
sum_waiting_hdr_waiting1_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
504 |
System.out.println("INFO: waiting_thr_state_blocked_cnt=" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
505 |
sum_waiting_thr_state_blocked_cnt); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
506 |
|
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
507 |
if (sum_contended_cnt == 0) { |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
508 |
System.err.println("WARNING: the primary scenario for 8036823" + |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
509 |
" has not been exercised by this test run."); |
b13d25e6a193
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
24832
diff
changeset
|
510 |
} |
24832
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
511 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
512 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
513 |
// This helper relies on RuntimeMXBean.getName() returning a string |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
514 |
// that looks like this: 5436@mt-haku |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
515 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
516 |
// The testlibrary has tryFindJvmPid(), but that uses a separate |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
517 |
// process which is much more expensive for finding out your own PID. |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
518 |
// |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
519 |
static String getPid() { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
520 |
RuntimeMXBean runtimebean = ManagementFactory.getRuntimeMXBean(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
521 |
String vmname = runtimebean.getName(); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
522 |
int i = vmname.indexOf('@'); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
523 |
if (i != -1) { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
524 |
vmname = vmname.substring(0, i); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
525 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
526 |
return vmname; |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
527 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
528 |
|
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
529 |
static void usage() { |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
530 |
System.err.println("Usage: " + |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
531 |
"java TestThreadDumpMonitorContention [-v] [n_samples]"); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
532 |
System.exit(1); |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
533 |
} |
26a834fb508d
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
534 |
} |