mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-20 14:29:27 +00:00
add support for Graphviz when viewing CFGs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22620 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0a3f677f09
commit
b06f677c53
@ -24,6 +24,7 @@
|
|||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/Support/CFG.h"
|
#include "llvm/Support/CFG.h"
|
||||||
#include "llvm/Support/GraphWriter.h"
|
#include "llvm/Support/GraphWriter.h"
|
||||||
|
#include "llvm/Config/config.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -137,6 +138,7 @@ namespace {
|
|||||||
/// being a 'dot' and 'gv' program in your path.
|
/// being a 'dot' and 'gv' program in your path.
|
||||||
///
|
///
|
||||||
void Function::viewCFG() const {
|
void Function::viewCFG() const {
|
||||||
|
#ifndef NDEBUG
|
||||||
std::string Filename = "/tmp/cfg." + getName() + ".dot";
|
std::string Filename = "/tmp/cfg." + getName() + ".dot";
|
||||||
std::cerr << "Writing '" << Filename << "'... ";
|
std::cerr << "Writing '" << Filename << "'... ";
|
||||||
std::ofstream F(Filename.c_str());
|
std::ofstream F(Filename.c_str());
|
||||||
@ -150,6 +152,17 @@ void Function::viewCFG() const {
|
|||||||
F.close();
|
F.close();
|
||||||
std::cerr << "\n";
|
std::cerr << "\n";
|
||||||
|
|
||||||
|
#ifdef HAVE_GRAPHVIZ
|
||||||
|
std::cerr << "Running 'Graphviz' program... " << std::flush;
|
||||||
|
if (system((LLVM_PATH_GRAPHVIZ " " + Filename).c_str())) {
|
||||||
|
std::cerr << "Error viewing graph: 'Graphviz' not in path?\n";
|
||||||
|
} else {
|
||||||
|
system(("rm " + Filename).c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_GV
|
||||||
std::cerr << "Running 'dot' program... " << std::flush;
|
std::cerr << "Running 'dot' program... " << std::flush;
|
||||||
if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename
|
if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename
|
||||||
+ " > /tmp/cfg.tempgraph.ps").c_str())) {
|
+ " > /tmp/cfg.tempgraph.ps").c_str())) {
|
||||||
@ -159,6 +172,13 @@ void Function::viewCFG() const {
|
|||||||
system("gv /tmp/cfg.tempgraph.ps");
|
system("gv /tmp/cfg.tempgraph.ps");
|
||||||
}
|
}
|
||||||
system(("rm " + Filename + " /tmp/cfg.tempgraph.ps").c_str());
|
system(("rm " + Filename + " /tmp/cfg.tempgraph.ps").c_str());
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
std::cerr << "Function::viewCFG is only available in debug builds on "
|
||||||
|
<< "systems with Graphviz or gv!\n";
|
||||||
|
|
||||||
|
system(("rm " + Filename).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// viewCFGOnly - This function is meant for use from the debugger. It works
|
/// viewCFGOnly - This function is meant for use from the debugger. It works
|
||||||
|
Loading…
x
Reference in New Issue
Block a user