Mercurial > hg > graal-jvmci-8
annotate graal/GraalCompiler/src/com/sun/c1x/debug/IdealGraphPrinterObserver.java @ 2809:b003ea36fa12
Add block structure to ideal graph visualizer
author | Gilles Duboscq <gilles.duboscq@oracle.com> |
---|---|
date | Mon, 30 May 2011 14:55:09 +0200 |
parents | a51ef0310dad |
children |
rev | line source |
---|---|
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
1 /* |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
4 * |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
8 * |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
14 * |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
18 * |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
21 * questions. |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
22 */ |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
23 package com.sun.c1x.debug; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
24 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
25 import java.io.*; |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
26 import java.net.*; |
2692
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
27 import java.util.regex.*; |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
28 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.graph.*; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
30 import com.sun.c1x.*; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
31 import com.sun.c1x.observer.*; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
32 import com.sun.c1x.value.*; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
33 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
34 /** |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
35 * Observes compilation events and uses {@link IdealGraphPrinter} to generate a graph representation that can be |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
36 * inspected with the <a href="http://kenai.com/projects/igv">Ideal Graph Visualizer</a>. |
2692
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
37 * |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
38 * @author Peter Hofer |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
39 */ |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
40 public class IdealGraphPrinterObserver implements CompilationObserver { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
41 |
2692
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
42 private static final Pattern INVALID_CHAR = Pattern.compile("[^A-Za-z0-9_.-]"); |
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
43 |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
44 private final String host; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
45 private final int port; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
46 |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
47 private IdealGraphPrinter printer; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
48 private OutputStream stream; |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
49 private Socket socket; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
50 |
2699
a51ef0310dad
Document new IdealGraphPrinterObserver constructors
Peter Hofer <peter.hofer@jku.at>
parents:
2698
diff
changeset
|
51 /** |
a51ef0310dad
Document new IdealGraphPrinterObserver constructors
Peter Hofer <peter.hofer@jku.at>
parents:
2698
diff
changeset
|
52 * Creates a new {@link IdealGraphPrinterObserver} that writes output to a file named after the compiled method. |
a51ef0310dad
Document new IdealGraphPrinterObserver constructors
Peter Hofer <peter.hofer@jku.at>
parents:
2698
diff
changeset
|
53 */ |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
54 public IdealGraphPrinterObserver() { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
55 this(null, -1); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
56 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
57 |
2699
a51ef0310dad
Document new IdealGraphPrinterObserver constructors
Peter Hofer <peter.hofer@jku.at>
parents:
2698
diff
changeset
|
58 /** |
a51ef0310dad
Document new IdealGraphPrinterObserver constructors
Peter Hofer <peter.hofer@jku.at>
parents:
2698
diff
changeset
|
59 * Creates a new {@link IdealGraphPrinterObserver} that sends output to a remove IdealGraphVisualizer instance. |
a51ef0310dad
Document new IdealGraphPrinterObserver constructors
Peter Hofer <peter.hofer@jku.at>
parents:
2698
diff
changeset
|
60 */ |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
61 public IdealGraphPrinterObserver(String host, int port) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
62 this.host = host; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
63 this.port = port; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
64 } |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
65 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
66 @Override |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
67 public void compilationStarted(CompilationEvent event) { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
68 assert (stream == null && printer == null); |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
69 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
70 if (!TTY.isSuppressed()) { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
71 String name = event.getMethod().holder().name(); |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
72 name = name.substring(1, name.length() - 1).replace('/', '.'); |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
73 name = name + "." + event.getMethod().name(); |
2692
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
74 |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
75 if (host != null) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
76 openNetworkPrinter(name); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
77 } else { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
78 openFilePrinter(name); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
79 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
80 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
81 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
82 |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
83 private void openFilePrinter(String name) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
84 String filename = name + ".igv.xml"; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
85 filename = INVALID_CHAR.matcher(filename).replaceAll("_"); |
2692
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
86 |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
87 try { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
88 stream = new FileOutputStream(filename); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
89 printer = new IdealGraphPrinter(stream); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
90 if (C1XOptions.OmitDOTFrameStates) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
91 printer.addOmittedClass(FrameState.class); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
92 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
93 printer.begin(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
94 printer.beginGroup(name, name, -1); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
95 } catch (IOException e) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
96 e.printStackTrace(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
97 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
98 } |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
99 |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
100 private void openNetworkPrinter(String name) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
101 try { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
102 socket = new Socket(host, port); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
103 if (socket.getInputStream().read() == 'y') { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
104 stream = socket.getOutputStream(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
105 } else { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
106 // server currently does not accept any input |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
107 socket.close(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
108 socket = null; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
109 return; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
110 } |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
111 |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
112 printer = new IdealGraphPrinter(stream); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
113 if (C1XOptions.OmitDOTFrameStates) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
114 printer.addOmittedClass(FrameState.class); |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
115 } |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
116 printer.begin(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
117 printer.beginGroup(name, name, -1); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
118 printer.flush(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
119 if (socket.getInputStream().read() != 'y') { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
120 // server declines input for this method |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
121 socket.close(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
122 socket = null; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
123 stream = null; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
124 printer = null; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
125 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
126 } catch (IOException e) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
127 e.printStackTrace(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
128 |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
129 if (socket != null) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
130 try { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
131 socket.close(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
132 } catch (IOException ioe) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
133 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
134 socket = null; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
135 } |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
136 stream = null; |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
137 printer = null; |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
138 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
139 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
140 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
141 @Override |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
142 public void compilationEvent(CompilationEvent event) { |
2809
b003ea36fa12
Add block structure to ideal graph visualizer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2699
diff
changeset
|
143 if (printer != null && event.getGraph() != null) { |
b003ea36fa12
Add block structure to ideal graph visualizer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2699
diff
changeset
|
144 Graph graph = event.getGraph(); |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
145 printer.print(graph, event.getLabel(), true); |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
146 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
147 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
148 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
149 @Override |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
150 public void compilationFinished(CompilationEvent event) { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
151 if (printer != null) { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
152 try { |
2692
79590d6b4a7c
IdealGraphPrinterObserver, GraphvizPrinterObserver: replace possibly invalid characters in file names
Peter Hofer <peter.hofer@jku.at>
parents:
2684
diff
changeset
|
153 printer.endGroup(); |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
154 printer.end(); |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
155 |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
156 if (socket != null) { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
157 socket.close(); // also closes stream |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
158 } else { |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
159 stream.close(); |
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
160 } |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
161 } catch (IOException e) { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
162 e.printStackTrace(); |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
163 } finally { |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
164 printer = null; |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
165 stream = null; |
2698
b179be22a3db
Allow to submit graphs to IdealGraphVisualizer remotely with new options named after their counterparts in C2
Peter Hofer <peter.hofer@jku.at>
parents:
2692
diff
changeset
|
166 socket = null; |
2684
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
167 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
168 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
169 } |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
170 |
ed36daed4c43
Add new option PrintIdealGraphToFile and another printer/observer pair to generate a graph representation that can be visualized and inspected with the ideal graph visualizer
Peter Hofer <peter.hofer@jku.at>
parents:
diff
changeset
|
171 } |