|
31 | 31 | import static com.oracle.graal.pointsto.reports.ReportUtils.invokeComparator;
|
32 | 32 | import static com.oracle.graal.pointsto.reports.ReportUtils.methodComparator;
|
33 | 33 |
|
| 34 | +import java.io.IOException; |
34 | 35 | import java.io.PrintWriter;
|
| 36 | +import java.nio.file.Files; |
| 37 | +import java.nio.file.LinkOption; |
| 38 | +import java.nio.file.Path; |
| 39 | +import java.nio.file.Paths; |
35 | 40 | import java.util.ArrayDeque;
|
36 | 41 | import java.util.ArrayList;
|
37 | 42 | import java.util.Arrays;
|
|
46 | 51 | import java.util.Objects;
|
47 | 52 | import java.util.Set;
|
48 | 53 | import java.util.concurrent.atomic.AtomicInteger;
|
| 54 | +import java.util.function.Consumer; |
49 | 55 | import java.util.regex.Matcher;
|
50 | 56 | import java.util.regex.Pattern;
|
51 | 57 | import java.util.stream.Collectors;
|
@@ -333,26 +339,33 @@ private static void printCsvFiles(Map<AnalysisMethod, MethodNode> methodToNode,
|
333 | 339 | walkNodes(node, directEdges, virtualEdges, overridenByEdges, virtualNodes, nonVirtualNodes, virtualNodeId);
|
334 | 340 | }
|
335 | 341 |
|
336 |
| - ReportUtils.report("call tree for vm entry point", reportsPath, "csv_call_tree_vm_" + reportName, "csv", |
337 |
| - CallTreePrinter::printVMEntryPoint); |
338 |
| - |
339 |
| - ReportUtils.report("call tree for methods", reportsPath, "csv_call_tree_methods_" + reportName, "csv", |
340 |
| - writer -> printMethodNodes(methodToNode.values(), writer)); |
341 |
| - |
342 |
| - ReportUtils.report("call tree for virtual methods", reportsPath, "csv_call_tree_virtual_methods_" + reportName, "csv", |
343 |
| - writer -> printVirtualNodes(virtualNodes, writer)); |
344 |
| - |
345 |
| - ReportUtils.report("call tree for entry points", reportsPath, "csv_call_tree_entry_points_" + reportName, "csv", |
346 |
| - writer -> printEntryPointIds(entryPointIds, writer)); |
347 |
| - |
348 |
| - ReportUtils.report("call tree for direct edges", reportsPath, "csv_call_tree_direct_edges_" + reportName, "csv", |
349 |
| - writer -> printBciEdges(directEdges, writer)); |
350 |
| - |
351 |
| - ReportUtils.report("call tree for overriden by edges", reportsPath, "csv_call_tree_override_by_edges_" + reportName, "csv", |
352 |
| - writer -> printNonBciEdges(overridenByEdges, writer)); |
| 342 | + toCsvFile("call tree for vm entry point", reportsPath, "csv_call_tree_vm", reportName, CallTreePrinter::printVMEntryPoint); |
| 343 | + toCsvFile("call tree for methods", reportsPath, "csv_call_tree_methods", reportName, writer -> printMethodNodes(methodToNode.values(), writer)); |
| 344 | + toCsvFile("call tree for virtual methods", reportsPath, "csv_call_tree_virtual_methods", reportName, writer -> printVirtualNodes(virtualNodes, writer)); |
| 345 | + toCsvFile("call tree for entry points", reportsPath, "csv_call_tree_entry_points", reportName, writer -> printEntryPointIds(entryPointIds, writer)); |
| 346 | + toCsvFile("call tree for direct edges", reportsPath, "csv_call_tree_direct_edges", reportName, writer -> printBciEdges(directEdges, writer)); |
| 347 | + toCsvFile("call tree for overriden by edges", reportsPath, "csv_call_tree_override_by_edges", reportName, writer -> printNonBciEdges(overridenByEdges, writer)); |
| 348 | + toCsvFile("call tree for virtual edges", reportsPath, "csv_call_tree_virtual_edges", reportName, writer -> printBciEdges(virtualEdges, writer)); |
| 349 | + } |
| 350 | + |
| 351 | + private static void toCsvFile(String description, String reportsPath, String prefix, String reportName, Consumer<PrintWriter> reporter) { |
| 352 | + final String name = prefix + "_" + reportName; |
| 353 | + final String csvFile = ReportUtils.report(description, reportsPath, name, "csv", reporter); |
| 354 | + final Path csvLink = Paths.get(reportsPath).resolve(prefix + ".csv"); |
| 355 | + |
| 356 | + if (Files.exists(csvLink, LinkOption.NOFOLLOW_LINKS)) { |
| 357 | + try { |
| 358 | + Files.delete(csvLink); |
| 359 | + } catch (IOException e) { |
| 360 | + // Ignore |
| 361 | + } |
| 362 | + } |
353 | 363 |
|
354 |
| - ReportUtils.report("call tree for virtual edges", reportsPath, "csv_call_tree_virtual_edges_" + reportName, "csv", |
355 |
| - writer -> printBciEdges(virtualEdges, writer)); |
| 364 | + try { |
| 365 | + Files.createSymbolicLink(csvLink, Paths.get(csvFile)); |
| 366 | + } catch (IOException e) { |
| 367 | + throw new RuntimeException(e); |
| 368 | + } |
356 | 369 | }
|
357 | 370 |
|
358 | 371 | private static void printVMEntryPoint(PrintWriter writer) {
|
|
0 commit comments