Skip to content

Commit 36088ab

Browse files
debuginfo: Add a timeout for LLDB tests.
Fixes #18649.
1 parent 37a823b commit 36088ab

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/etc/lldb_batchmode.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import os
2929
import sys
3030
import threading
31+
import thread
3132
import re
3233
import atexit
3334
import time
@@ -131,6 +132,22 @@ def listen():
131132
target.GetBroadcaster().AddListener(listener, lldb.SBTarget.eBroadcastBitBreakpointChanged)
132133

133134

135+
def start_watchdog():
136+
"Starts a watchdog thread that will terminate the process after a certain period of time"
137+
watchdog_start_time = time.clock()
138+
watchdog_max_time = watchdog_start_time + 30
139+
140+
def watchdog():
141+
while time.clock() < watchdog_max_time:
142+
time.sleep(1)
143+
print("TIMEOUT: lldb_batchmode.py has been running for too long. Aborting!")
144+
thread.interrupt_main()
145+
146+
# Start the listener and let it run as a daemon
147+
watchdog_thread = threading.Thread(target = watchdog)
148+
watchdog_thread.daemon = True
149+
watchdog_thread.start()
150+
134151
####################################################################################################
135152
# ~main
136153
####################################################################################################
@@ -148,6 +165,9 @@ def listen():
148165
print("Target executable is '%s'." % target_path)
149166
print("Current working directory is '%s'" % os.getcwd())
150167

168+
# Start the timeout watchdog
169+
start_watchdog()
170+
151171
# Create a new debugger instance
152172
debugger = lldb.SBDebugger.Create()
153173

0 commit comments

Comments
 (0)