Finally give bugpoint -timeout support!
authorChris Lattner <sabre@nondot.org>
Sat, 24 Jul 2004 07:53:26 +0000 (07:53 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 24 Jul 2004 07:53:26 +0000 (07:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15163 91177308-0d34-0410-b5e6-96231b3b80d8

tools/bugpoint/BugDriver.cpp
tools/bugpoint/ExecutionDriver.cpp

index 1bac8da24373d6974e1e02c9d0a0a931b57d6e48..1826b7b780c1175215423149130a6b30287aaf3f 100644 (file)
@@ -156,7 +156,7 @@ bool BugDriver::run() {
   //
   bool CreatedOutput = false;
   if (ReferenceOutputFile.empty()) {
-    std::cout << "Generating reference output from raw program...";
+    std::cout << "Generating reference output from raw program";
     try {
       ReferenceOutputFile = executeProgramWithCBE("bugpoint.reference.out");
       CreatedOutput = true;
index 7d6c4aaaae295f3694440d4dcab4547278e4da91..62f0a242a6f40b44c42411c1cfc2294be7f9e7e7 100644 (file)
@@ -53,6 +53,11 @@ namespace {
   AdditionalSOs("additional-so",
                 cl::desc("Additional shared objects to load "
                          "into executing programs"));
+
+  cl::opt<unsigned>
+  TimeoutValue("timeout", cl::init(300), cl::value_desc("seconds"),
+               cl::desc("Number of seconds program is allowed to run before it "
+                        "is killed (default is 300s), 0 disables timeout"));
 }
 
 namespace llvm {
@@ -201,7 +206,20 @@ std::string BugDriver::executeProgram(std::string OutputFile,
 
   // Actually execute the program!
   int RetVal = AI->ExecuteProgram(BytecodeFile, InputArgv, InputFile,
-                                  OutputFile, SharedObjs);
+                                  OutputFile, SharedObjs, TimeoutValue);
+
+  if (RetVal == -1) {
+    std::cerr << "<timeout>";
+    static bool FirstTimeout = true;
+    if (FirstTimeout) {
+      std::cout << "\n"
+ "*** Program execution timed out!  This mechanism is designed to handle\n"
+ "    programs stuck in infinite loops gracefully.  The -timeout option\n"
+ "    can be used to change the timeout threshold or disable it completely\n"
+ "    (with -timeout=0).  This message is only displayed once.\n";
+      FirstTimeout = false;
+    }
+  }
 
   if (ProgramExitedNonzero != 0)
     *ProgramExitedNonzero = (RetVal != 0);