about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-11-06 13:35:56 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-11-06 13:53:27 -0800
commitf87ff765fe1eca989daf1909020ef1ba5cdb95c9 (patch)
tree24e1c64365b82ea4cbd98b6d2ba4e6263b36e4b9
parent3c81f33adaeb65cbc570b88881592b55ca4e647b (diff)
parent36088ab21fe0eb0f2c3d5e7636959d24ee6e8a41 (diff)
downloadrust-f87ff765fe1eca989daf1909020ef1ba5cdb95c9.tar.gz
rust-f87ff765fe1eca989daf1909020ef1ba5cdb95c9.zip
rollup merge of #18654 : michaelwoerister/lldb-test-timeout
-rw-r--r--mk/tests.mk4
-rw-r--r--src/etc/lldb_batchmode.py25
2 files changed, 28 insertions, 1 deletions
diff --git a/mk/tests.mk b/mk/tests.mk
index 45b618cb758..4433d780ded 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -677,7 +677,9 @@ CTEST_DEPS_cfail_$(1)-T-$(2)-H-$(3) = $$(CFAIL_TESTS)
 CTEST_DEPS_bench_$(1)-T-$(2)-H-$(3) = $$(BENCH_TESTS)
 CTEST_DEPS_perf_$(1)-T-$(2)-H-$(3) = $$(PERF_TESTS)
 CTEST_DEPS_debuginfo-gdb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_GDB_TESTS)
-CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS)
+CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
+                                               $(S)src/etc/lldb_batchmode.py \
+                                               $(S)src/etc/lldb_rust_formatters.py
 CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
 
 endef
diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py
index 467463a39c6..25e5661ca49 100644
--- a/src/etc/lldb_batchmode.py
+++ b/src/etc/lldb_batchmode.py
@@ -28,8 +28,10 @@ import lldb
 import os
 import sys
 import threading
+import thread
 import re
 import atexit
+import time
 
 # Set this to True for additional output
 DEBUG_OUTPUT = False
@@ -130,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
 ####################################################################################################
@@ -147,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()
 
@@ -175,6 +196,10 @@ try:
 
   for line in script_file:
     command = line.strip()
+    if command == "run" or command == "r" or re.match("^process\s+launch.*", command):
+      # Before starting to run the program, let the thread sleep a bit, so all
+      # breakpoint added events can be processed
+      time.sleep(0.5)
     if command != '':
       execute_command(command_interpreter, command)