about summary refs log tree commit diff
path: root/src/etc/lldb_batchmode.py
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2014-11-05 11:44:46 +0100
committerMichael Woerister <michaelwoerister@posteo>2014-11-05 18:35:24 +0100
commit36088ab21fe0eb0f2c3d5e7636959d24ee6e8a41 (patch)
tree665b569e59dea64294fd82dfe4769824e12a4fb0 /src/etc/lldb_batchmode.py
parent37a823b223007da79da5c067782f6494b4771c4a (diff)
downloadrust-36088ab21fe0eb0f2c3d5e7636959d24ee6e8a41.tar.gz
rust-36088ab21fe0eb0f2c3d5e7636959d24ee6e8a41.zip
debuginfo: Add a timeout for LLDB tests.
Fixes #18649.
Diffstat (limited to 'src/etc/lldb_batchmode.py')
-rw-r--r--src/etc/lldb_batchmode.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py
index 94c7af5e106..25e5661ca49 100644
--- a/src/etc/lldb_batchmode.py
+++ b/src/etc/lldb_batchmode.py
@@ -28,6 +28,7 @@ import lldb
 import os
 import sys
 import threading
+import thread
 import re
 import atexit
 import time
@@ -131,6 +132,22 @@ def start_breakpoint_listener(target):
   target.GetBroadcaster().AddListener(listener, lldb.SBTarget.eBroadcastBitBreakpointChanged)
 
 
+def start_watchdog():
+  "Starts a watchdog thread that will terminate the process after a certain period of time"
+  watchdog_start_time = time.clock()
+  watchdog_max_time = watchdog_start_time + 30
+
+  def watchdog():
+    while time.clock() < watchdog_max_time:
+      time.sleep(1)
+    print("TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!")
+    thread.interrupt_main()
+
+  # Start the listener and let it run as a daemon
+  watchdog_thread = threading.Thread(target = watchdog)
+  watchdog_thread.daemon = True
+  watchdog_thread.start()
+
 ####################################################################################################
 # ~main
 ####################################################################################################
@@ -148,6 +165,9 @@ print("Debugger commands script is '%s'." % script_path)
 print("Target executable is '%s'." % target_path)
 print("Current working directory is '%s'" % os.getcwd())
 
+# Start the timeout watchdog
+start_watchdog()
+
 # Create a new debugger instance
 debugger = lldb.SBDebugger.Create()