File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 28
28
import os
29
29
import sys
30
30
import threading
31
+ import thread
31
32
import re
32
33
import atexit
33
34
import time
@@ -131,6 +132,22 @@ def listen():
131
132
target .GetBroadcaster ().AddListener (listener , lldb .SBTarget .eBroadcastBitBreakpointChanged )
132
133
133
134
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
+
134
151
####################################################################################################
135
152
# ~main
136
153
####################################################################################################
@@ -148,6 +165,9 @@ def listen():
148
165
print ("Target executable is '%s'." % target_path )
149
166
print ("Current working directory is '%s'" % os .getcwd ())
150
167
168
+ # Start the timeout watchdog
169
+ start_watchdog ()
170
+
151
171
# Create a new debugger instance
152
172
debugger = lldb .SBDebugger .Create ()
153
173
You can’t perform that action at this time.
0 commit comments