diff options
author | Chris Lattner <sabre@nondot.org> | 2003-02-10 18:17:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-02-10 18:17:07 +0000 |
commit | 75007f16de5d3d96399bb41a3bc675508274aabd (patch) | |
tree | ddf8ee0f3d7087693ddd9f5dbd0c52fb22d7ea2b | |
parent | b96f2123abbbe26fa6b10335fd735e7488f0bea7 (diff) | |
download | bcm5719-llvm-75007f16de5d3d96399bb41a3bc675508274aabd.tar.gz bcm5719-llvm-75007f16de5d3d96399bb41a3bc675508274aabd.zip |
Implement a new "viewGraph" method which can be used to instantly view a graph from gdb
llvm-svn: 5528
-rw-r--r-- | llvm/lib/Analysis/DataStructure/Printer.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DataStructure/Printer.cpp b/llvm/lib/Analysis/DataStructure/Printer.cpp index d862264dcfc..09748ff8397 100644 --- a/llvm/lib/Analysis/DataStructure/Printer.cpp +++ b/llvm/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) { |