aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/Printer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-02-10 18:17:07 +0000
committerChris Lattner <sabre@nondot.org>2003-02-10 18:17:07 +0000
commite79eaa9b4994cd4fb5be42792e6de35376e5c045 (patch)
tree26f2e4cecff01c26554121628245a2dec567fabc /lib/Analysis/DataStructure/Printer.cpp
parent4f2cfc0d746683aaf91801ff93306c51bbfc6e3c (diff)
Implement a new "viewGraph" method which can be used to instantly view a graph from gdb
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5528 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/Printer.cpp')
-rw-r--r--lib/Analysis/DataStructure/Printer.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp
index d862264dcf..09748ff839 100644
--- a/lib/Analysis/DataStructure/Printer.cpp
+++ b/lib/Analysis/DataStructure/Printer.cpp
@@ -179,6 +179,23 @@ void DSGraph::writeGraphToFile(std::ostream &O,
}
}
+/// viewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
+/// then cleanup. For use from the debugger.
+///
+void DSGraph::viewGraph() const {
+ std::ofstream F("/tmp/tempgraph.dot");
+ if (!F.good()) {
+ std::cerr << "Error opening '/tmp/tempgraph.dot' for temporary graph!\n";
+ return;
+ }
+ print(F);
+ if (system("dot -Tps /tmp/tempgraph.dot > /tmp/tempgraph.ps"))
+ std::cerr << "Error running dot: 'dot' not in path?\n";
+ system("gv /tmp/tempgraph.ps");
+ system("rm /tmp/tempgraph.dot /tmp/tempgraph.ps");
+}
+
+
template <typename Collection>
static void printCollection(const Collection &C, std::ostream &O,
const Module *M, const std::string &Prefix) {