From: Dan Gohman Date: Mon, 27 Sep 2010 16:28:34 +0000 (+0000) Subject: Add support for viewing graphviz graphs with xdot.py. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=48fd5a79e023bf6a647dfabb2bbb4c2f98617b81;p=oota-llvm.git 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 --- diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 949a74f7112..d4d0722eabf 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 0cd2d53ceea..1dec712f89b 100755 --- a/configure +++ b/configure @@ -729,6 +729,7 @@ TWOPI CIRCO GV DOTTY +XDOT_PY PERL HAVE_PERL INSTALL_PROGRAM @@ -7833,6 +7834,62 @@ cat >>confdefs.h <<_ACEOF #define LLVM_PATH_DOTTY "$DOTTY${EXEEXT}" _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 @@ -11394,7 +11451,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 6fd274d875d..1aeb5ce3376 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 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 header file. */ #undef HAVE_VALGRIND_VALGRIND_H -/* Define to 1 if you have the header file. */ -#undef HAVE_FENV_H - /* Define to 1 if you have the 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 fdd6285a8c5..47779eee0be 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 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;