aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-09-27 16:28:34 +0000
committerDan Gohman <gohman@apple.com>2010-09-27 16:28:34 +0000
commit48fd5a79e023bf6a647dfabb2bbb4c2f98617b81 (patch)
treeb0ca2b5657873c23b7cf0e9eb762b45122918e0a
parent520163c98bbfcaa3a82fccd3ca27446ffc2c53cd (diff)
Add support for viewing graphviz graphs with xdot.py.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114832 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--autoconf/configure.ac10
-rwxr-xr-xconfigure62
-rw-r--r--include/llvm/Config/config.h.in12
-rw-r--r--lib/Support/GraphWriter.cpp26
4 files changed, 105 insertions, 5 deletions
diff --git a/autoconf/configure.ac b/autoconf/configure.ac
index 949a74f711..d4d0722eab 100644
--- a/autoconf/configure.ac
+++ b/autoconf/configure.ac
@@ -979,6 +979,16 @@ if test "$DOTTY" != "echo dotty" ; then
AC_DEFINE_UNQUOTED([LLVM_PATH_DOTTY],"$DOTTY${EXEEXT}",
[Define to path to dotty program if found or 'echo dotty' otherwise])
fi
+AC_PATH_PROG(XDOT_PY, [xdot.py], [echo xdot.py])
+if test "$XDOT_PY" != "echo xdot.py" ; then
+ AC_DEFINE([HAVE_XDOT_PY],[1],[Define if the xdot.py program is available])
+ dnl If we're targeting for mingw we should emit windows paths, not msys
+ if test "$llvm_cv_os_type" = "MingW" ; then
+ XDOT_PY=`echo $XDOT_PY | sed 's/^\/\([[A-Za-z]]\)\//\1:\//' `
+ fi
+ AC_DEFINE_UNQUOTED([LLVM_PATH_XDOT_PY],"$XDOT_PY${EXEEXT}",
+ [Define to path to xdot.py program if found or 'echo xdot.py' otherwise])
+fi
dnl Look for a sufficiently recent version of Perl.
LLVM_PROG_PERL([5.006])
diff --git a/configure b/configure
index 0cd2d53cee..1dec712f89 100755
--- a/configure
+++ b/configure
@@ -729,6 +729,7 @@ TWOPI
CIRCO
GV
DOTTY
+XDOT_PY
PERL
HAVE_PERL
INSTALL_PROGRAM
@@ -7834,6 +7835,62 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
fi
+# Extract the first word of "xdot.py", so it can be a program name with args.
+set dummy xdot.py; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_XDOT_PY+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $XDOT_PY in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_XDOT_PY="$XDOT_PY" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_XDOT_PY="$as_dir/$ac_word$ac_exec_ext"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_path_XDOT_PY" && ac_cv_path_XDOT_PY="echo xdot.py"
+ ;;
+esac
+fi
+XDOT_PY=$ac_cv_path_XDOT_PY
+if test -n "$XDOT_PY"; then
+ { echo "$as_me:$LINENO: result: $XDOT_PY" >&5
+echo "${ECHO_T}$XDOT_PY" >&6; }
+else
+ { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+if test "$XDOT_PY" != "echo xdot.py" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XDOT_PY 1
+_ACEOF
+
+ if test "$llvm_cv_os_type" = "MingW" ; then
+ XDOT_PY=`echo $XDOT_PY | sed 's/^\/\([A-Za-z]\)\//\1:\//' `
+ fi
+
+cat >>confdefs.h <<_ACEOF
+#define LLVM_PATH_XDOT_PY "$XDOT_PY${EXEEXT}"
+_ACEOF
+
+fi
# Extract the first word of "perl", so it can be a program name with args.
@@ -11394,7 +11451,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
-#line 11397 "configure"
+#line 11454 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -21640,6 +21697,7 @@ TWOPI!$TWOPI$ac_delim
CIRCO!$CIRCO$ac_delim
GV!$GV$ac_delim
DOTTY!$DOTTY$ac_delim
+XDOT_PY!$XDOT_PY$ac_delim
PERL!$PERL$ac_delim
HAVE_PERL!$HAVE_PERL$ac_delim
INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
@@ -21705,7 +21763,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
- if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 93; then
+ if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 94; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in
index 6fd274d875..1aeb5ce337 100644
--- a/include/llvm/Config/config.h.in
+++ b/include/llvm/Config/config.h.in
@@ -118,6 +118,9 @@
/* Define if the neat program is available */
#undef HAVE_FDP
+/* Define to 1 if you have the <fenv.h> header file. */
+#undef HAVE_FENV_H
+
/* Define if libffi is available on this platform. */
#undef HAVE_FFI_CALL
@@ -455,12 +458,12 @@
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
#undef HAVE_VALGRIND_VALGRIND_H
-/* Define to 1 if you have the <fenv.h> header file. */
-#undef HAVE_FENV_H
-
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
+/* Define if the xdot.py program is available */
+#undef HAVE_XDOT_PY
+
/* Define to 1 if you have the `__dso_handle' function. */
#undef HAVE___DSO_HANDLE
@@ -542,6 +545,9 @@
/* Define to path to twopi program if found or 'echo twopi' otherwise */
#undef LLVM_PATH_TWOPI
+/* Define to path to xdot.py program if found or 'echo xdot.py' otherwise */
+#undef LLVM_PATH_XDOT_PY
+
/* Installation prefix directory */
#undef LLVM_PREFIX
diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp
index fdd6285a8c..47779eee0b 100644
--- a/lib/Support/GraphWriter.cpp
+++ b/lib/Support/GraphWriter.cpp
@@ -69,6 +69,32 @@ void llvm::DisplayGraph(const sys::Path &Filename, bool wait,
else
Filename.eraseFromDisk();
+#elif HAVE_XDOT_PY
+ sys::Path XDotPy();
+
+ std::vector<const char*> args;
+ args.push_back(LLVM_PATH_XDOT_PY);
+ args.push_back(Filename.c_str());
+
+ switch (program) {
+ case GraphProgram::DOT: args.push_back("-f"); args.push_back("dot"); break;
+ case GraphProgram::FDP: args.push_back("-f"); args.push_back("fdp"); break;
+ case GraphProgram::NEATO: args.push_back("-f"); args.push_back("neato");break;
+ case GraphProgram::TWOPI: args.push_back("-f"); args.push_back("twopi");break;
+ case GraphProgram::CIRCO: args.push_back("-f"); args.push_back("circo");break;
+ default: errs() << "Unknown graph layout name; using default.\n";
+ }
+
+ args.push_back(0);
+
+ errs() << "Running 'xdot.py' program... ";
+ if (sys::Program::ExecuteAndWait(sys::Path(LLVM_PATH_XDOT_PY),
+ &args[0],0,0,0,0,&ErrMsg))
+ errs() << "Error viewing graph " << Filename.str() << ": " << ErrMsg
+ << "\n";
+ else
+ Filename.eraseFromDisk();
+
#elif (HAVE_GV && (HAVE_DOT || HAVE_FDP || HAVE_NEATO || \
HAVE_TWOPI || HAVE_CIRCO))
sys::Path PSFilename = Filename;