You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Within both contexts, our program is single thread.
208
208
#
209
209
# The only fail safe: **Never give up control in Unicorn context.**
210
-
#
210
+
#
211
211
# In Unicorn context, in other words, in Unicorn callbacks, we do:
212
212
# - Implement non-blocking syscalls directly.
213
213
# - Prepare sched_cb for non-unicorn context.
@@ -219,7 +219,7 @@ def _run(self):
219
219
self.ql.arch.regs.arch_pc=self.start_address
220
220
ifnotself._saved_context:
221
221
self.save()
222
-
222
+
223
223
whileself.status!=THREAD_STATUS_TERMINATED:
224
224
# Rewrite our status and the current thread.
225
225
self.status=THREAD_STATUS_RUNNING
@@ -235,7 +235,7 @@ def _run(self):
235
235
# Run and log the run event
236
236
start_address=getattr(self.ql.arch, 'effective_pc', self.ql.arch.regs.arch_pc) # For arm thumb.
237
237
self.sched_cb=QlLinuxThread._default_sched_cb
238
-
238
+
239
239
self.ql.log.debug(f"Scheduled from {hex(start_address)}.")
240
240
try:
241
241
# Known issue for timeout: https://github.com/unicorn-engine/unicorn/issues/1355
@@ -246,7 +246,7 @@ def _run(self):
246
246
raisee
247
247
self.ql.log.debug(f"Suspended at {hex(self.ql.arch.regs.arch_pc)}")
248
248
self.save()
249
-
249
+
250
250
# Note that this callback may be set by UC callbacks.
251
251
# Some thought on this design:
252
252
# 1. Never give up control during a UC callback.
@@ -275,16 +275,16 @@ def restore(self):
275
275
@abstractmethod
276
276
defset_thread_tls(self, tls_addr):
277
277
pass
278
-
278
+
279
279
@abstractmethod
280
280
defclone(self):
281
281
# This is a workaround to implement our thread based on gevent greenlet.
282
282
# Core idea:
283
283
# A gevent greenlet can't re-run if it has finished _run method but our framework requires threads to be resumed anytime. Therefore, a workaround is to
284
284
# use multiple greenlets to represent a single qiling thread.
285
-
#
285
+
#
286
286
# Of course we can make the greenlet run forever and wait for notifications to resume but that would make the design much more complicated.
287
-
#
287
+
#
288
288
# Caveat:
289
289
# Don't use thread id to identify the thread object.
0 commit comments