From 2f215f644f3c0d5dc02859a125c4c060736bd250 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 5 Nov 2014 10:53:07 +0100 Subject: [PATCH 1/3] debuginfo: Make LLDB test make targets dependent on lldb python scripts. --- mk/tests.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 37a823b223007da79da5c067782f6494b4771c4a Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 5 Nov 2014 10:54:16 +0100 Subject: [PATCH 2/3] debuginfo: Add timeout before running executable in LLDB tests. This should help with a potential race condition. --- src/etc/lldb_batchmode.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py index 467463a39c646..94c7af5e1065c 100644 --- a/src/etc/lldb_batchmode.py +++ b/src/etc/lldb_batchmode.py @@ -30,6 +30,7 @@ import threading import re import atexit +import time # Set this to True for additional output DEBUG_OUTPUT = False @@ -175,6 +176,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) From 36088ab21fe0eb0f2c3d5e7636959d24ee6e8a41 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 5 Nov 2014 11:44:46 +0100 Subject: [PATCH 3/3] debuginfo: Add a timeout for LLDB tests. Fixes #18649. --- src/etc/lldb_batchmode.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py index 94c7af5e1065c..25e5661ca49da 100644 --- a/src/etc/lldb_batchmode.py +++ b/src/etc/lldb_batchmode.py @@ -28,6 +28,7 @@ import os import sys import threading +import thread import re import atexit import time @@ -131,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 #################################################################################################### @@ -148,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()