From 36088ab21fe0eb0f2c3d5e7636959d24ee6e8a41 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 5 Nov 2014 11:44:46 +0100 Subject: [PATCH] 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 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()