< prev index next >

test/hotspot/jtreg/runtime/ErrorHandling/MachCodeFramesInErrorFile.java

Print this page

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

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