diff --git a/mk/tests.mk b/mk/tests.mk index 45b618cb75841..4433d780dedf6 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 467463a39c646..25e5661ca49da 100644 --- a/src/etc/lldb_batchmode.py +++ b/src/etc/lldb_batchmode.py @@ -28,8 +28,10 @@ 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 listen(): 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 @@ def listen(): 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 @@ def listen(): 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)