147 }
148 int compiledJavaFrames = (int) frames.stream().filter(f -> f.startsWith("J ")).count();
149
150 Matcher matcherDisasm = Pattern.compile("\\[Disassembly\\].*\\[/Disassembly\\]", Pattern.DOTALL).matcher(hsErr);
151 if (matcherDisasm.find()) {
152 // Real disassembly is present, no MachCode is expected.
153 return;
154 }
155
156 String preCodeBlobSectionHeader = "Stack slot to memory mapping:";
157 if (!hsErr.contains(preCodeBlobSectionHeader) &&
158 System.getProperty("os.arch").equals("aarch64") &&
159 System.getProperty("os.name").toLowerCase().startsWith("mac")) {
160 // JDK-8282607: hs_err can be truncated. If the section preceding
161 // code blob dumping is missing, exit successfully.
162 System.out.println("Could not find \"" + preCodeBlobSectionHeader + "\" in " + hsErrPath);
163 System.out.println("Looks like hs-err is truncated - exiting with success");
164 return;
165 }
166
167 Matcher matcher = Pattern.compile("\\[MachCode\\]\\s*\\[Verified Entry Point\\]\\s* # \\{method\\} \\{[^}]*\\} '([^']+)' '([^']+)' in '([^']+)'", Pattern.DOTALL).matcher(hsErr);
168 List<String> machCodeHeaders = matcher.results().map(mr -> String.format("'%s' '%s' in '%s'", mr.group(1), mr.group(2), mr.group(3))).collect(Collectors.toList());
169 int minExpectedMachCodeSections = Math.max(1, compiledJavaFrames);
170 if (machCodeHeaders.size() < minExpectedMachCodeSections) {
171 Asserts.fail(machCodeHeaders.size() + " < " + minExpectedMachCodeSections);
172 }
173 }
174
175 /**
176 * Extracts the lines in {@code hsErr} below the line starting with
177 * "Native frame" or "Java frame" up to the next blank line
178 * and adds them to {@code frames}.
179 */
180 private static void extractFrames(String hsErr, Set<String> frames, boolean nativeStack) {
181 String marker = (nativeStack ? "Native" : "Java") + " frame";
182
183 boolean seenMarker = false;
184 for (String line : hsErr.split(System.lineSeparator())) {
185 if (line.startsWith(marker)) {
186 seenMarker = true;
187 } else if (seenMarker) {
|
147 }
148 int compiledJavaFrames = (int) frames.stream().filter(f -> f.startsWith("J ")).count();
149
150 Matcher matcherDisasm = Pattern.compile("\\[Disassembly\\].*\\[/Disassembly\\]", Pattern.DOTALL).matcher(hsErr);
151 if (matcherDisasm.find()) {
152 // Real disassembly is present, no MachCode is expected.
153 return;
154 }
155
156 String preCodeBlobSectionHeader = "Stack slot to memory mapping:";
157 if (!hsErr.contains(preCodeBlobSectionHeader) &&
158 System.getProperty("os.arch").equals("aarch64") &&
159 System.getProperty("os.name").toLowerCase().startsWith("mac")) {
160 // JDK-8282607: hs_err can be truncated. If the section preceding
161 // code blob dumping is missing, exit successfully.
162 System.out.println("Could not find \"" + preCodeBlobSectionHeader + "\" in " + hsErrPath);
163 System.out.println("Looks like hs-err is truncated - exiting with success");
164 return;
165 }
166
167 Matcher matcher = Pattern.compile("\\[MachCode\\]\\s[^{]+\\{method\\} \\{[^}]*\\} '([^']+)' '([^']+)' in '([^']+)'", Pattern.DOTALL).matcher(hsErr);
168 List<String> machCodeHeaders = matcher.results().map(mr -> String.format("'%s' '%s' in '%s'", mr.group(1), mr.group(2), mr.group(3))).collect(Collectors.toList());
169 int minExpectedMachCodeSections = Math.max(1, compiledJavaFrames);
170 if (machCodeHeaders.size() < minExpectedMachCodeSections) {
171 Asserts.fail(machCodeHeaders.size() + " < " + minExpectedMachCodeSections);
172 }
173 }
174
175 /**
176 * Extracts the lines in {@code hsErr} below the line starting with
177 * "Native frame" or "Java frame" up to the next blank line
178 * and adds them to {@code frames}.
179 */
180 private static void extractFrames(String hsErr, Set<String> frames, boolean nativeStack) {
181 String marker = (nativeStack ? "Native" : "Java") + " frame";
182
183 boolean seenMarker = false;
184 for (String line : hsErr.split(System.lineSeparator())) {
185 if (line.startsWith(marker)) {
186 seenMarker = true;
187 } else if (seenMarker) {
|