Mercurial > hg > truffle
annotate test/runtime/Thread/TestThreadDumpMonitorContention.java @ 20286:631c3a4ea10c
8043301: Duplicate definitions in vm/runtime/sharedRuntimeTrans.cpp versus math.h in VS2013
Summary: Factor out definitions of copysignA and scalbnA into new file sharedRuntimeMath.hpp
Reviewed-by: kvn
author | lfoltan |
---|---|
date | Thu, 22 May 2014 11:36:23 -0400 |
parents | 22146594cd5a |
children |
rev | line source |
---|---|
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
1 /* |
4a1062dc52d1
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. |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
4 * |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
8 * |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
13 * accompanied this code). |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
14 * |
4a1062dc52d1
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 |
4a1062dc52d1
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, |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
18 * |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
21 * questions. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
22 */ |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
23 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
24 /* |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
25 * @test |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
26 * @bug 8036823 |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
27 * @bug 8046287 |
17965
4a1062dc52d1
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 |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
30 * |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
31 * @library /testlibrary |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
32 * @run main/othervm TestThreadDumpMonitorContention |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
33 */ |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
34 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
35 import java.io.BufferedReader; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
36 import java.io.InputStreamReader; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
37 import java.lang.management.ManagementFactory; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
38 import java.lang.management.RuntimeMXBean; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
39 import java.util.ArrayList; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
40 import java.util.List; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
41 import java.util.regex.Matcher; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
42 import java.util.regex.Pattern; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
43 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
44 import com.oracle.java.testlibrary.*; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
45 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
46 public class TestThreadDumpMonitorContention { |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
48 // so use getTestJDKTool() instead of getCompileJDKTool() or even |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
49 // getJDKTool() which can fall back to "compile.jdk". |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
50 final static String JSTACK = JDKToolFinder.getTestJDKTool("jstack"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
51 final static String PID = getPid(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
52 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
53 // looking for header lines with these patterns: |
4a1062dc52d1
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] |
4a1062dc52d1
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] |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
56 // "ContendingThread-2" #24 prio=5 os_prio=64 tid=0x0000000000ec8800 nid=0x31 waiting on condition [0xfffffd7bbfffe000] |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
57 final static Pattern HEADER_PREFIX_PATTERN = Pattern.compile( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
58 "^\"ContendingThread-.*"); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
59 final static Pattern HEADER_WAITING_PATTERN1 = Pattern.compile( |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
60 "^\"ContendingThread-.* waiting for monitor entry .*"); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
61 final static Pattern HEADER_WAITING_PATTERN2 = Pattern.compile( |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
62 "^\"ContendingThread-.* waiting on condition .*"); |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
63 final static Pattern HEADER_RUNNABLE_PATTERN = Pattern.compile( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
64 "^\"ContendingThread-.* runnable .*"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
65 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
66 // looking for thread state lines with these patterns: |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
67 // java.lang.Thread.State: RUNNABLE |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
68 // java.lang.Thread.State: BLOCKED (on object monitor) |
4a1062dc52d1
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( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
70 " *java\\.lang\\.Thread\\.State: .*"); |
4a1062dc52d1
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( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
72 " *java\\.lang\\.Thread\\.State: BLOCKED \\(on object monitor\\)"); |
4a1062dc52d1
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( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
74 " *java\\.lang\\.Thread\\.State: RUNNABLE"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
75 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
76 // looking for duplicates of this pattern: |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
77 // - locked <0x000000076ac59e20> (a TestThreadDumpMonitorContention$1) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
78 final static Pattern LOCK_PATTERN = Pattern.compile( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
79 ".* locked \\<.*\\(a TestThreadDumpMonitorContention.*"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
80 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
81 // sanity checking header and thread state lines associated |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
82 // with this pattern: |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
83 // - waiting to lock <0x000000076ac59e20> (a TestThreadDumpMonitorContention$1) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
84 final static Pattern WAITING_PATTERN = Pattern.compile( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
85 ".* waiting to lock \\<.*\\(a TestThreadDumpMonitorContention.*"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
86 |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
87 final static Object barrier = new Object(); |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
88 volatile static boolean done = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
89 |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
90 static int barrier_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
91 static int blank_line_match_cnt = 0; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
92 static int error_cnt = 0; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
93 static boolean have_header_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
94 static boolean have_thread_state_line = false; |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
95 static String header_line = null; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
96 static int header_prefix_match_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
97 static int locked_line_match_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
98 static String[] locked_match_list = new String[2]; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
99 static int n_samples = 15; |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
100 static int sum_both_running_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
101 static int sum_both_waiting_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
102 static int sum_contended_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
103 static int sum_locked_hdr_runnable_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
104 static int sum_locked_hdr_waiting1_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
105 static int sum_locked_hdr_waiting2_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
106 static int sum_locked_thr_state_blocked_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
107 static int sum_locked_thr_state_runnable_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
108 static int sum_one_waiting_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
109 static int sum_uncontended_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
110 static int sum_waiting_hdr_waiting1_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
111 static int sum_waiting_thr_state_blocked_cnt = 0; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
112 static String thread_state_line = null; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
113 static boolean verbose = false; |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
114 static int waiting_line_match_cnt = 0; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
115 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
116 public static void main(String[] args) throws Exception { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
117 if (args.length != 0) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
118 int arg_i = 0; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
119 if (args[arg_i].equals("-v")) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
120 verbose = true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
121 arg_i++; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
122 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
123 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
124 try { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
125 n_samples = Integer.parseInt(args[arg_i]); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
126 } catch (NumberFormatException nfe) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
127 System.err.println(nfe); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
128 usage(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
129 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
130 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
131 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
132 Runnable runnable = new Runnable() { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
133 public void run() { |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
134 synchronized (barrier) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
135 // let the main thread know we're running |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
136 barrier_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
137 barrier.notify(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
138 } |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
139 while (!done) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
140 synchronized (this) { } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
141 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
142 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
143 }; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
144 Thread[] thread_list = new Thread[2]; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
145 thread_list[0] = new Thread(runnable, "ContendingThread-1"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
146 thread_list[1] = new Thread(runnable, "ContendingThread-2"); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
147 synchronized (barrier) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
148 thread_list[0].start(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
149 thread_list[1].start(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
150 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
151 // Wait until the contending threads are running so that |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
152 // we don't sample any thread init states. |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
153 while (barrier_cnt < 2) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
154 barrier.wait(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
155 } |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
156 } |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
157 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
158 doSamples(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
159 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
160 done = true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
161 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
162 thread_list[0].join(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
163 thread_list[1].join(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
164 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
165 if (error_cnt == 0) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
166 System.out.println("Test PASSED."); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
167 } else { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
168 System.out.println("Test FAILED."); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
169 throw new AssertionError("error_cnt=" + error_cnt); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
170 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
171 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
172 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
174 // stack trace without matching either LOCK_PATTERN |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
176 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
177 // Example: |
4a1062dc52d1
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] |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
179 // java.lang.Thread.State: RUNNABLE |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
180 // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
181 // at java.lang.Thread.run(Thread.java:745) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
182 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
183 static boolean checkBlankLine(String line) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
184 if (line.length() == 0) { |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
185 blank_line_match_cnt++; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
186 have_header_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
187 have_thread_state_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
188 return true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
189 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
190 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
191 return false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
192 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
193 |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
195 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
196 // Example 1: |
4a1062dc52d1
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] |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
198 // java.lang.Thread.State: RUNNABLE |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
199 // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
200 // - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
201 // at java.lang.Thread.run(Thread.java:745) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
202 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
203 // Example 2: |
4a1062dc52d1
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] |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
205 // java.lang.Thread.State: BLOCKED (on object monitor) |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
206 // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
207 // - locked <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
208 // at java.lang.Thread.run(Thread.java:745) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
209 // |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
210 // Example 3: |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
211 // "ContendingThread-2" #24 prio=5 os_prio=64 tid=0x0000000000ec8800 nid=0x31 waiting on condition [0xfffffd7bbfffe000] |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
212 // java.lang.Thread.State: RUNNABLE |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
213 // JavaThread state: _thread_blocked |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
214 // Thread: 0x0000000000ec8800 [0x31] State: _at_safepoint _has_called_back 0 _at_poll_safepoint 0 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
215 // JavaThread state: _thread_blocked |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
216 // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
217 // - locked <0xfffffd7e6d03eb28> (a TestThreadDumpMonitorContention$1) |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
218 // at java.lang.Thread.run(Thread.java:745) |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
219 // |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
220 static boolean checkLockedLine(String line) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
221 Matcher matcher = LOCK_PATTERN.matcher(line); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
222 if (matcher.matches()) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
223 if (verbose) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
224 System.out.println("locked_line='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
225 } |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
226 locked_match_list[locked_line_match_cnt] = new String(line); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
227 locked_line_match_cnt++; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
228 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
229 matcher = HEADER_RUNNABLE_PATTERN.matcher(header_line); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
230 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
231 sum_locked_hdr_runnable_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
232 } else { |
17965
4a1062dc52d1
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 |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
234 // match the HEADER_WAITING_PATTERN{1,2}. |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
235 matcher = HEADER_WAITING_PATTERN1.matcher(header_line); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
236 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
237 sum_locked_hdr_waiting1_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
238 } else { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
239 matcher = HEADER_WAITING_PATTERN2.matcher(header_line); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
240 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
241 sum_locked_hdr_waiting2_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
242 } else { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
243 System.err.println(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
244 System.err.println("ERROR: header line does " + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
245 "not match runnable or waiting patterns."); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
246 System.err.println("ERROR: header_line='" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
247 header_line + "'"); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
248 System.err.println("ERROR: locked_line='" + line + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
249 "'"); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
250 error_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
251 } |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
252 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
253 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
254 |
4a1062dc52d1
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); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
256 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
257 sum_locked_thr_state_runnable_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
258 } else { |
17965
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
260 // match the THREAD_STATE_BLOCKED_PATTERN. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
261 matcher = THREAD_STATE_BLOCKED_PATTERN.matcher( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
262 thread_state_line); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
263 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
264 sum_locked_thr_state_blocked_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
265 } else { |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
266 System.err.println(); |
4a1062dc52d1
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 " + |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
268 "match runnable or waiting patterns."); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
269 System.err.println("ERROR: " + "thread_state_line='" + |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
270 thread_state_line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
271 System.err.println("ERROR: locked_line='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
272 error_cnt++; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
273 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
274 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
275 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
276 // Have everything we need from this thread stack |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
277 // that matches the LOCK_PATTERN. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
278 have_header_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
279 have_thread_state_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
280 return true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
281 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
282 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
283 return false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
284 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
285 |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
287 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
288 // Example: |
4a1062dc52d1
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] |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
290 // java.lang.Thread.State: BLOCKED (on object monitor) |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
291 // at TestThreadDumpMonitorContention$1.run(TestThreadDumpMonitorContention.java:140) |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
292 // - waiting to lock <0xfffffd7e6a2912f8> (a TestThreadDumpMonitorContention$1) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
293 // at java.lang.Thread.run(Thread.java:745) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
294 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
295 static boolean checkWaitingLine(String line) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
296 Matcher matcher = WAITING_PATTERN.matcher(line); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
297 if (matcher.matches()) { |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
298 waiting_line_match_cnt++; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
299 if (verbose) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
300 System.out.println("waiting_line='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
301 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
302 |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
303 matcher = HEADER_WAITING_PATTERN1.matcher(header_line); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
304 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
305 sum_waiting_hdr_waiting1_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
306 } else { |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
307 System.err.println(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
308 System.err.println("ERROR: header line does " + |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
309 "not match a waiting pattern."); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
310 System.err.println("ERROR: header_line='" + header_line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
311 System.err.println("ERROR: waiting_line='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
312 error_cnt++; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
313 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
314 |
4a1062dc52d1
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); |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
316 if (matcher.matches()) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
317 sum_waiting_thr_state_blocked_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
318 } else { |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
319 System.err.println(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
320 System.err.println("ERROR: thread state line " + |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
321 "does not match a waiting pattern."); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
322 System.err.println("ERROR: thread_state_line='" + |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
323 thread_state_line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
324 System.err.println("ERROR: waiting_line='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
325 error_cnt++; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
326 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
327 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
328 // Have everything we need from this thread stack |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
329 // that matches the WAITING_PATTERN. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
330 have_header_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
331 have_thread_state_line = false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
332 return true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
333 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
334 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
335 return false; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
336 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
337 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
338 static void doSamples() throws Exception { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
339 for (int count = 0; count < n_samples; count++) { |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
340 blank_line_match_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
341 header_prefix_match_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
342 locked_line_match_cnt = 0; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
343 waiting_line_match_cnt = 0; |
17965
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
345 if (verbose || error_cnt > 0) System.out.println(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
346 System.out.println("Sample #" + count); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
347 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
348 // We don't use the ProcessTools, OutputBuffer or |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
349 // OutputAnalyzer classes from the testlibrary because |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
351 // on a narrow subset of the JSTACK output. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
352 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
353 // - we only care about stack traces that match |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
354 // HEADER_PREFIX_PATTERN; only two should match |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
357 // a failure and we report it |
4a1062dc52d1
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: |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
359 // - the header line matches HEADER_RUNNABLE_PATTERN |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
360 // or HEADER_WAITING_PATTERN{1,2} |
17965
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
362 // or THREAD_STATE_RUNNABLE_PATTERN |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
363 // - we report any mismatches as failures |
4a1062dc52d1
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: |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
365 // - the header line matches HEADER_WAITING_PATTERN1 |
17965
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
367 // - we report any mismatches as failures |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
369 // not match either LOCKED_PATTERN or WAITING_PATTERN |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
370 // because we might observe the thread outside of |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
371 // monitor operations; this is not considered a failure |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
372 // |
4a1062dc52d1
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, |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
379 // match HEADER_PREFIX_PATTERN. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
380 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
381 Process process = new ProcessBuilder(JSTACK, PID) |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
382 .redirectErrorStream(true).start(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
383 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
384 BufferedReader reader = new BufferedReader(new InputStreamReader( |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
385 process.getInputStream())); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
386 String line; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
387 while ((line = reader.readLine()) != null) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
388 Matcher matcher = null; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
389 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
390 // process the header line here |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
391 if (!have_header_line) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
392 matcher = HEADER_PREFIX_PATTERN.matcher(line); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
393 if (matcher.matches()) { |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
394 header_prefix_match_cnt++; |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
395 if (verbose) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
396 System.out.println(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
397 System.out.println("header='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
398 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
399 header_line = new String(line); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
400 have_header_line = true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
401 continue; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
402 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
403 continue; // skip until have a header line |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
404 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
405 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
406 // process the thread state line here |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
407 if (!have_thread_state_line) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
408 matcher = THREAD_STATE_PREFIX_PATTERN.matcher(line); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
409 if (matcher.matches()) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
410 if (verbose) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
411 System.out.println("thread_state='" + line + "'"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
412 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
413 thread_state_line = new String(line); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
414 have_thread_state_line = true; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
415 continue; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
416 } |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
418 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
419 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
421 if (checkLockedLine(line)) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
422 continue; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
423 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
424 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
426 if (checkWaitingLine(line)) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
427 continue; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
428 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
429 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
431 if (checkBlankLine(line)) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
432 continue; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
433 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
434 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
435 process.waitFor(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
436 |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
437 if (header_prefix_match_cnt != 2) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
438 System.err.println(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
439 System.err.println("ERROR: should match exactly two headers."); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
440 System.err.println("ERROR: header_prefix_match_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
441 header_prefix_match_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
442 error_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
443 } |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
444 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
445 if (locked_line_match_cnt == 2) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
446 if (locked_match_list[0].equals(locked_match_list[1])) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
447 System.err.println(); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
448 System.err.println("ERROR: matching lock lines:"); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
449 System.err.println("ERROR: line[0]'" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
450 locked_match_list[0] + "'"); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
451 System.err.println("ERROR: line[1]'" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
452 locked_match_list[1] + "'"); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
453 error_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
454 } |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
455 } |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
456 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
457 if (locked_line_match_cnt == 1) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
458 // one thread has the lock |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
459 if (waiting_line_match_cnt == 1) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
460 // and the other contended for it |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
461 sum_contended_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
462 } else { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
463 // and the other is just running |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
464 sum_uncontended_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
465 } |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
466 } else if (waiting_line_match_cnt == 1) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
467 // one thread is waiting |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
468 sum_one_waiting_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
469 } else if (waiting_line_match_cnt == 2) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
470 // both threads are waiting |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
471 sum_both_waiting_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
472 } else { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
473 // both threads are running |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
474 sum_both_running_cnt++; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
475 } |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
476 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
477 // slight delay between jstack launches |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
478 Thread.sleep(500); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
479 } |
17984
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
480 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
481 if (error_cnt != 0) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
482 // skip summary info since there were errors |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
483 return; |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
484 } |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
485 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
486 System.out.println("INFO: Summary for all samples:"); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
487 System.out.println("INFO: both_running_cnt=" + sum_both_running_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
488 System.out.println("INFO: both_waiting_cnt=" + sum_both_waiting_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
489 System.out.println("INFO: contended_cnt=" + sum_contended_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
490 System.out.println("INFO: one_waiting_cnt=" + sum_one_waiting_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
491 System.out.println("INFO: uncontended_cnt=" + sum_uncontended_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
492 System.out.println("INFO: locked_hdr_runnable_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
493 sum_locked_hdr_runnable_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
494 System.out.println("INFO: locked_hdr_waiting1_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
495 sum_locked_hdr_waiting1_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
496 System.out.println("INFO: locked_hdr_waiting2_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
497 sum_locked_hdr_waiting2_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
498 System.out.println("INFO: locked_thr_state_blocked_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
499 sum_locked_thr_state_blocked_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
500 System.out.println("INFO: locked_thr_state_runnable_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
501 sum_locked_thr_state_runnable_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
502 System.out.println("INFO: waiting_hdr_waiting1_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
503 sum_waiting_hdr_waiting1_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
504 System.out.println("INFO: waiting_thr_state_blocked_cnt=" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
505 sum_waiting_thr_state_blocked_cnt); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
506 |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
507 if (sum_contended_cnt == 0) { |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
508 System.err.println("WARNING: the primary scenario for 8036823" + |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
509 " has not been exercised by this test run."); |
22146594cd5a
8046287: [TESTBUG] runtime/Thread/TestThreadDumpMonitorContention.java failed error_cnt=12
dcubed
parents:
17965
diff
changeset
|
510 } |
17965
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
511 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
512 |
4a1062dc52d1
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 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
514 // that looks like this: 5436@mt-haku |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
515 // |
4a1062dc52d1
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 |
4a1062dc52d1
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. |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
518 // |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
519 static String getPid() { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
520 RuntimeMXBean runtimebean = ManagementFactory.getRuntimeMXBean(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
521 String vmname = runtimebean.getName(); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
522 int i = vmname.indexOf('@'); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
523 if (i != -1) { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
524 vmname = vmname.substring(0, i); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
525 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
526 return vmname; |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
527 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
528 |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
529 static void usage() { |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
530 System.err.println("Usage: " + |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
531 "java TestThreadDumpMonitorContention [-v] [n_samples]"); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
532 System.exit(1); |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
533 } |
4a1062dc52d1
8036823: Stack trace sometimes shows 'locked' instead of 'waiting to lock'
dcubed
parents:
diff
changeset
|
534 } |