Mercurial > hg > truffle
changeset 5815:272f9da7ce78
Put Binary and xml dumpers behing a common interface and use the same dumphandler for them
Dumping to files should now work even with mutiple dumping threads
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Wed, 11 Jul 2012 14:36:32 +0200 |
parents | d241f8b2e6f9 |
children | b3d3a2fcba3d |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BasicIdealGraphPrinter.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinterDumpHandler.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinter.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinterDumpHandler.java |
diffstat | 8 files changed, 270 insertions(+), 380 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java Wed Jul 11 14:13:38 2012 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotDebugConfig.java Wed Jul 11 14:36:32 2012 +0200 @@ -64,18 +64,10 @@ if (logFilter != null || meterFilter != null || timerFilter != null || dumpFilter != null || methodFilter != null) { TTY.println(Thread.currentThread().getName() + ": " + toString()); } - if (GraalOptions.PrintBinaryGraphs) { - if (GraalOptions.PrintIdealGraphFile) { - dumpHandlers.add(new BinaryGraphPrinterDumpHandler()); - } else { - dumpHandlers.add(new BinaryGraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintBinaryGraphPort)); - } + if (GraalOptions.PrintIdealGraphFile) { + dumpHandlers.add(new GraphPrinterDumpHandler()); } else { - if (GraalOptions.PrintIdealGraphFile) { - dumpHandlers.add(new IdealGraphPrinterDumpHandler()); - } else { - dumpHandlers.add(new IdealGraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintIdealGraphPort)); - } + dumpHandlers.add(new GraphPrinterDumpHandler(GraalOptions.PrintIdealGraphAddress, GraalOptions.PrintBinaryGraphPort)); } if (GraalOptions.PrintCFG) { dumpHandlers.add(new CFGPrinterObserver());
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BasicIdealGraphPrinter.java Wed Jul 11 14:13:38 2012 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BasicIdealGraphPrinter.java Wed Jul 11 14:36:32 2012 +0200 @@ -85,7 +85,13 @@ */ protected BasicIdealGraphPrinter(OutputStream stream) { try { - this.stream = new PrintStream(stream, false, "US-ASCII"); + OutputStream buffered; + if (stream instanceof BufferedOutputStream) { + buffered = stream; + } else { + buffered = new BufferedOutputStream(stream, 256 * 1024); + } + this.stream = new PrintStream(buffered, false, "US-ASCII"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } @@ -251,7 +257,7 @@ /** * Ends the current group. */ - protected void endGroup() { + public void endGroup() { stream.println("</group>"); }
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java Wed Jul 11 14:13:38 2012 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java Wed Jul 11 14:36:32 2012 +0200 @@ -36,7 +36,7 @@ import com.oracle.graal.lir.cfg.*; import com.oracle.graal.nodes.*; -public class BinaryGraphPrinter { +public class BinaryGraphPrinter implements GraphPrinter{ private static final int CONSTANT_POOL_MAX_SIZE = 2000; private static final int BEGIN_GROUP = 0x00;
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinterDumpHandler.java Wed Jul 11 14:13:38 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.printer; - -import java.io.*; -import java.net.*; -import java.nio.channels.*; -import java.util.*; - -import com.oracle.max.criutils.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; - -/** - * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be - * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. - */ -public class BinaryGraphPrinterDumpHandler implements DebugDumpHandler { - - private static final String DEFAULT_FILE_NAME = "output.gvb"; - - private BinaryGraphPrinter printer; - private List<String> previousInlineContext = new ArrayList<>(); - private String fileName; - private String host; - private int port; - private int failuresCount; - - /** - * Creates a new {@link BinaryGraphPrinterDumpHandler} that writes output to a file named after the compiled method. - */ - public BinaryGraphPrinterDumpHandler() { - this.fileName = DEFAULT_FILE_NAME; - } - - /** - * Creates a new {@link BinaryGraphPrinterDumpHandler} that sends output to a remote IdealGraphVisualizer instance. - */ - public BinaryGraphPrinterDumpHandler(String host, int port) { - this.host = host; - this.port = port; - } - - private void ensureInitialized() { - if (printer == null) { - if (failuresCount > 8) { - return; - } - previousInlineContext.clear(); - if (fileName != null) { - initializeFilePrinter(); - } else { - initializeNetworkPrinter(); - } - } - } - - private void initializeFilePrinter() { - try { - printer = new BinaryGraphPrinter(FileChannel.open(new File(fileName).toPath())); - } catch (IOException e) { - failuresCount++; - printer = null; - } - } - - private void initializeNetworkPrinter() { - try { - SocketChannel channel = SocketChannel.open(new InetSocketAddress(host, port)); - printer = new BinaryGraphPrinter(channel); - TTY.println("Connected to the IGV on port %d", port); - } catch (IOException e) { - TTY.println("Could not connect to the IGV on port %d: %s", port, e); - failuresCount++; - printer = null; - } - } - - @Override - public void dump(Object object, final String message) { - if (object instanceof Graph) { - ensureInitialized(); - if (printer == null) { - return; - } - final Graph graph = (Graph) object; - - if (printer != null) { - // Get all current RiResolvedMethod instances in the context. - List<String> inlineContext = getInlineContext(); - - // Reverse list such that inner method comes after outer method. - Collections.reverse(inlineContext); - - // Check for method scopes that must be closed since the previous dump. - for (int i = 0; i < previousInlineContext.size(); ++i) { - if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) { - for (int j = previousInlineContext.size() - 1; j >= i; --j) { - closeScope(); - } - break; - } - } - - // Check for method scopes that must be opened since the previous dump. - for (int i = 0; i < inlineContext.size(); ++i) { - if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) { - for (int j = i; j < inlineContext.size(); ++j) { - openScope(inlineContext.get(j), j == 0); - } - break; - } - } - - // Save inline context for next dump. - previousInlineContext = inlineContext; - - Debug.sandbox("PrintingGraph", new Runnable() { - - @Override - public void run() { - // Finally, output the graph. - try { - printer.print(graph, message, null); - } catch (IOException e) { - failuresCount++; - printer = null; - } - } - }); - } - } - } - - private static List<String> getInlineContext() { - List<String> result = new ArrayList<>(); - for (Object o : Debug.context()) { - if (o instanceof ResolvedJavaMethod) { - ResolvedJavaMethod method = (ResolvedJavaMethod) o; - result.add(MetaUtil.format("%H::%n(%p)", method)); - } else if (o instanceof DebugDumpScope) { - DebugDumpScope debugDumpScope = (DebugDumpScope) o; - if (debugDumpScope.decorator && !result.isEmpty()) { - result.set(result.size() - 1, debugDumpScope.name + ":" + result.get(result.size() - 1)); - } else { - result.add(debugDumpScope.name); - } - } - } - return result; - } - - private void openScope(String name, boolean showThread) { - String prefix = showThread ? Thread.currentThread().getName() + ":" : ""; - try { - printer.beginGroup(prefix + name, name, Debug.contextLookup(ResolvedJavaMethod.class), -1); - } catch (IOException e) { - failuresCount++; - printer = null; - } - } - - private void closeScope() { - try { - printer.endGroup(); - } catch (IOException e) { - failuresCount++; - printer = null; - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinter.java Wed Jul 11 14:36:32 2012 +0200 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.printer; + +import java.io.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.schedule.*; +import com.oracle.graal.graph.*; + +interface GraphPrinter { + /** + * Starts a new group of graphs with the given name, short name and method byte code index (BCI) as properties. + */ + void beginGroup(String name, String shortName, ResolvedJavaMethod method, int bci) throws IOException; + + /** + * Prints an entire {@link Graph} with the specified title, optionally using short names for nodes. + */ + void print(Graph graph, String title, SchedulePhase predefinedSchedule) throws IOException; + + /** + * Ends the current group. + */ + void endGroup() throws IOException; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/GraphPrinterDumpHandler.java Wed Jul 11 14:36:32 2012 +0200 @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.printer; + +import java.io.*; +import java.net.*; +import java.nio.channels.*; +import java.text.*; +import java.util.*; + +import com.oracle.max.criutils.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; + +/** + * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be + * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. + */ +public class GraphPrinterDumpHandler implements DebugDumpHandler { + private static final SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd-HHmm"); + + private GraphPrinter printer; + private List<String> previousInlineContext = new ArrayList<>(); + private String host; + private int port; + private int failuresCount; + + /** + * Creates a new {@link GraphPrinterDumpHandler} that writes output to a file. + */ + public GraphPrinterDumpHandler() { + } + + /** + * Creates a new {@link GraphPrinterDumpHandler} that sends output to a remote IdealGraphVisualizer instance. + */ + public GraphPrinterDumpHandler(String host, int port) { + this.host = host; + this.port = port; + } + + private void ensureInitialized() { + if (printer == null) { + if (failuresCount > 8) { + return; + } + previousInlineContext.clear(); + if (host == null) { + initializeFilePrinter(); + } else { + initializeNetworkPrinter(); + } + } + } + + private void initializeFilePrinter() { + try { + String ext; + if (GraalOptions.PrintBinaryGraphs) { + ext = ".bgv"; + } else { + ext = ".gv.xml"; + } + String fileName = "Graphs-" + Thread.currentThread().getName() + "-" + sdf.format(new Date()) + ext; + if (GraalOptions.PrintBinaryGraphs) { + printer = new BinaryGraphPrinter(FileChannel.open(new File(fileName).toPath())); + } else { + printer = new IdealGraphPrinter(new FileOutputStream(fileName)); + } + TTY.println("Dumping IGV graphs to %s", fileName); + } catch (IOException e) { + failuresCount++; + printer = null; + } + } + + private void initializeNetworkPrinter() { + try { + + if (GraalOptions.PrintBinaryGraphs) { + printer = new BinaryGraphPrinter(SocketChannel.open(new InetSocketAddress(host, port))); + } else { + IdealGraphPrinter xmlPrinter = new IdealGraphPrinter(new Socket(host, port).getOutputStream()); + xmlPrinter.begin(); + printer = xmlPrinter; + } + TTY.println("Connected to the IGV on %s:%d", host, port); + } catch (IOException e) { + TTY.println("Could not connect to the IGV on %s:%d: %s", host, port, e); + failuresCount++; + printer = null; + } + } + + @Override + public void dump(Object object, final String message) { + if (object instanceof Graph) { + ensureInitialized(); + if (printer == null) { + return; + } + final Graph graph = (Graph) object; + + if (printer != null) { + // Get all current RiResolvedMethod instances in the context. + List<String> inlineContext = getInlineContext(); + + // Reverse list such that inner method comes after outer method. + Collections.reverse(inlineContext); + + // Check for method scopes that must be closed since the previous dump. + for (int i = 0; i < previousInlineContext.size(); ++i) { + if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) { + for (int j = previousInlineContext.size() - 1; j >= i; --j) { + closeScope(); + } + break; + } + } + + // Check for method scopes that must be opened since the previous dump. + for (int i = 0; i < inlineContext.size(); ++i) { + if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) { + for (int j = i; j < inlineContext.size(); ++j) { + openScope(inlineContext.get(j), j == 0); + } + break; + } + } + + // Save inline context for next dump. + previousInlineContext = inlineContext; + + Debug.sandbox("PrintingGraph", new Runnable() { + + @Override + public void run() { + // Finally, output the graph. + try { + printer.print(graph, message, null); + } catch (IOException e) { + failuresCount++; + printer = null; + } + } + }); + } + } + } + + private static List<String> getInlineContext() { + List<String> result = new ArrayList<>(); + for (Object o : Debug.context()) { + if (o instanceof ResolvedJavaMethod) { + ResolvedJavaMethod method = (ResolvedJavaMethod) o; + result.add(MetaUtil.format("%H::%n(%p)", method)); + } else if (o instanceof DebugDumpScope) { + DebugDumpScope debugDumpScope = (DebugDumpScope) o; + if (debugDumpScope.decorator && !result.isEmpty()) { + result.set(result.size() - 1, debugDumpScope.name + ":" + result.get(result.size() - 1)); + } else { + result.add(debugDumpScope.name); + } + } + } + return result; + } + + private void openScope(String name, boolean showThread) { + String prefix = showThread ? Thread.currentThread().getName() + ":" : ""; + try { + printer.beginGroup(prefix + name, name, Debug.contextLookup(ResolvedJavaMethod.class), -1); + } catch (IOException e) { + failuresCount++; + printer = null; + } + } + + private void closeScope() { + try { + printer.endGroup(); + } catch (IOException e) { + failuresCount++; + printer = null; + } + } +}
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java Wed Jul 11 14:13:38 2012 +0200 +++ b/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinter.java Wed Jul 11 14:36:32 2012 +0200 @@ -40,7 +40,7 @@ * Generates a representation of {@link Graph Graphs} that can be visualized and inspected with the <a * href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. */ -class IdealGraphPrinter extends BasicIdealGraphPrinter { +class IdealGraphPrinter extends BasicIdealGraphPrinter implements GraphPrinter { /** * Creates a new {@link IdealGraphPrinter} that writes to the specified output stream. */ @@ -51,6 +51,7 @@ /** * Starts a new group of graphs with the given name, short name and method byte code index (BCI) as properties. */ + @Override public void beginGroup(String name, String shortName, ResolvedJavaMethod method, int bci) { beginGroup(); beginProperties(); @@ -70,6 +71,7 @@ /** * Prints an entire {@link Graph} with the specified title, optionally using short names for nodes. */ + @Override public void print(Graph graph, String title, SchedulePhase predefinedSchedule) { beginGraph(title); Set<Node> noBlockNodes = new HashSet<>();
--- a/graal/com.oracle.graal.printer/src/com/oracle/graal/printer/IdealGraphPrinterDumpHandler.java Wed Jul 11 14:13:38 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.printer; - -import java.io.*; -import java.net.*; -import java.util.*; - -import com.oracle.max.criutils.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; - -/** - * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be - * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. - */ -public class IdealGraphPrinterDumpHandler implements DebugDumpHandler { - - private static final String DEFAULT_FILE_NAME = "output.igv.xml"; - - private IdealGraphPrinter printer; - private List<String> previousInlineContext = new ArrayList<>(); - private String fileName; - private String host; - private int port; - private boolean initialized; - - /** - * Creates a new {@link IdealGraphPrinterDumpHandler} that writes output to a file named after the compiled method. - */ - public IdealGraphPrinterDumpHandler() { - this.fileName = DEFAULT_FILE_NAME; - } - - /** - * Creates a new {@link IdealGraphPrinterDumpHandler} that sends output to a remote IdealGraphVisualizer instance. - */ - public IdealGraphPrinterDumpHandler(String host, int port) { - this.host = host; - this.port = port; - } - - private void ensureInitialized() { - if (!initialized) { - initialized = true; - if (fileName != null) { - initializeFilePrinter(); - } else { - initializeNetworkPrinter(); - } - } - } - - private void initializeFilePrinter() { - try { - FileOutputStream stream = new FileOutputStream(fileName); - printer = new IdealGraphPrinter(stream); - printer.begin(); - } catch (IOException e) { - printer = null; - } - } - - private void initializeNetworkPrinter() { - try { - Socket socket = new Socket(host, port); - BufferedOutputStream stream = new BufferedOutputStream(socket.getOutputStream(), 0x4000); - printer = new IdealGraphPrinter(stream); - printer.begin(); - TTY.println("Connected to the IGV on port %d", port); - } catch (IOException e) { - TTY.println("Could not connect to the IGV on port %d: %s", port, e); - printer = null; - } - } - - @Override - public void dump(Object object, final String message) { - if (object instanceof Graph) { - ensureInitialized(); - final Graph graph = (Graph) object; - - if (printer != null && printer.isValid()) { - // Get all current ResolvedJavaMethod instances in the context. - List<String> inlineContext = getInlineContext(); - - // Reverse list such that inner method comes after outer method. - Collections.reverse(inlineContext); - - // Check for method scopes that must be closed since the previous dump. - for (int i = 0; i < previousInlineContext.size(); ++i) { - if (i >= inlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) { - for (int j = previousInlineContext.size() - 1; j >= i; --j) { - closeScope(); - } - break; - } - } - - // Check for method scopes that must be opened since the previous dump. - for (int i = 0; i < inlineContext.size(); ++i) { - if (i >= previousInlineContext.size() || !inlineContext.get(i).equals(previousInlineContext.get(i))) { - for (int j = i; j < inlineContext.size(); ++j) { - openScope(inlineContext.get(j), j == 0); - } - break; - } - } - - // Save inline context for next dump. - previousInlineContext = inlineContext; - - Debug.sandbox("PrintingGraph", new Runnable() { - - @Override - public void run() { - // Finally, output the graph. - printer.print(graph, message); - - } - }); - } - } - } - - private static List<String> getInlineContext() { - List<String> result = new ArrayList<>(); - for (Object o : Debug.context()) { - if (o instanceof ResolvedJavaMethod) { - ResolvedJavaMethod method = (ResolvedJavaMethod) o; - result.add(MetaUtil.format("%H::%n(%p)", method)); - } else if (o instanceof DebugDumpScope) { - DebugDumpScope debugDumpScope = (DebugDumpScope) o; - if (debugDumpScope.decorator && !result.isEmpty()) { - result.set(result.size() - 1, debugDumpScope.name + ":" + result.get(result.size() - 1)); - } else { - result.add(debugDumpScope.name); - } - } - } - return result; - } - - private void openScope(String name, boolean showThread) { - String prefix = showThread ? Thread.currentThread().getName() + ":" : ""; - printer.beginGroup(prefix + name, name, Debug.contextLookup(ResolvedJavaMethod.class), -1); - } - - private void closeScope() { - printer.endGroup(); - } -}