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