1 /*
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
66
67 // Extract hs_err_pid file.
68 String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
69 if (hs_err_file == null) {
70 throw new RuntimeException("Did not find hs_err_pid file in output.\n");
71 }
72
73 File f = new File(hs_err_file);
74 if (!f.exists()) {
75 throw new RuntimeException("hs_err_pid file missing at "
76 + f.getAbsolutePath() + ".\n");
77 }
78
79 System.out.println("Found hs_err_pid file. Scanning...");
80
81 FileInputStream fis = new FileInputStream(f);
82 BufferedReader br = new BufferedReader(new InputStreamReader(fis));
83 String line = null;
84
85 Pattern [] pattern = new Pattern[] {
86 // The "Current thread" line should show a hazard ptr:
87 Pattern.compile("Current thread .* _threads_hazard_ptr=0x.*"),
88 // We should have a section of Threads class SMR info:
89 Pattern.compile("Threads class SMR info:"),
90 // The current thread (marked with '=>') in the threads list
91 // should show a hazard ptr:
92 Pattern.compile("=>.* JavaThread \"main\" .*_threads_hazard_ptr=0x.*"),
93 };
94 int currentPattern = 0;
95
96 String lastLine = null;
97 while ((line = br.readLine()) != null) {
98 if (currentPattern < pattern.length) {
99 if (pattern[currentPattern].matcher(line).matches()) {
100 System.out.println("Found: " + line + ".");
101 currentPattern++;
102 }
103 }
104 lastLine = line;
105 }
106 br.close();
107
108 if (currentPattern < pattern.length) {
109 throw new RuntimeException("hs_err_pid file incomplete (first missing pattern: " + currentPattern + ")");
110 }
111
112 if (!lastLine.equals("END.")) {
|
1 /*
2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
66
67 // Extract hs_err_pid file.
68 String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
69 if (hs_err_file == null) {
70 throw new RuntimeException("Did not find hs_err_pid file in output.\n");
71 }
72
73 File f = new File(hs_err_file);
74 if (!f.exists()) {
75 throw new RuntimeException("hs_err_pid file missing at "
76 + f.getAbsolutePath() + ".\n");
77 }
78
79 System.out.println("Found hs_err_pid file. Scanning...");
80
81 FileInputStream fis = new FileInputStream(f);
82 BufferedReader br = new BufferedReader(new InputStreamReader(fis));
83 String line = null;
84
85 Pattern [] pattern = new Pattern[] {
86 // The "Current thread" line should show a hazard ptr
87 // and no nested hazard ptrs:
88 Pattern.compile("Current thread .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=0.*"),
89 // We should have a section of Threads class SMR info:
90 Pattern.compile("Threads class SMR info:"),
91 // The current thread (marked with '=>') in the threads list
92 // should show a hazard ptr and no nested hazard ptrs:
93 Pattern.compile("=>.* JavaThread \"main\" .* _threads_hazard_ptr=0x[0-9A-Fa-f][0-9A-Fa-f]*, _nested_threads_hazard_ptr_cnt=0.*"),
94 };
95 int currentPattern = 0;
96
97 String lastLine = null;
98 while ((line = br.readLine()) != null) {
99 if (currentPattern < pattern.length) {
100 if (pattern[currentPattern].matcher(line).matches()) {
101 System.out.println("Found: " + line + ".");
102 currentPattern++;
103 }
104 }
105 lastLine = line;
106 }
107 br.close();
108
109 if (currentPattern < pattern.length) {
110 throw new RuntimeException("hs_err_pid file incomplete (first missing pattern: " + currentPattern + ")");
111 }
112
113 if (!lastLine.equals("END.")) {
|