retracesoftware-proxy 0.1.19__py3-none-any.whl → 0.1.21__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- retracesoftware/install/patcher.py +34 -29
- retracesoftware/install/record.py +5 -0
- retracesoftware/install/replay.py +4 -0
- retracesoftware/proxy/proxysystem.py +3 -0
- retracesoftware/proxy/record.py +11 -1
- retracesoftware/proxy/replay.py +9 -1
- {retracesoftware_proxy-0.1.19.dist-info → retracesoftware_proxy-0.1.21.dist-info}/METADATA +1 -1
- {retracesoftware_proxy-0.1.19.dist-info → retracesoftware_proxy-0.1.21.dist-info}/RECORD +10 -10
- {retracesoftware_proxy-0.1.19.dist-info → retracesoftware_proxy-0.1.21.dist-info}/WHEEL +0 -0
- {retracesoftware_proxy-0.1.19.dist-info → retracesoftware_proxy-0.1.21.dist-info}/top_level.txt +0 -0
|
@@ -337,20 +337,20 @@ class Patcher:
|
|
|
337
337
|
@patch
|
|
338
338
|
def patch_exec(self, exec):
|
|
339
339
|
|
|
340
|
-
def
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
340
|
+
def is_module(source, *args):
|
|
341
|
+
return isinstance(source, types.CodeType) and source.co_name == '<module>'
|
|
342
|
+
|
|
343
|
+
def after_exec(source, globals = None, locals = None):
|
|
344
|
+
self(sys.modules[globals['__name__']])
|
|
344
345
|
|
|
345
346
|
def first(x): return x[0]
|
|
346
347
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return self.thread_state.dispatch(exec, internal = wrapped_exec)
|
|
348
|
+
def disable(func): return self.thread_state.wrap('disabled', func)
|
|
349
|
+
|
|
350
|
+
return self.thread_state.dispatch(
|
|
351
|
+
exec,
|
|
352
|
+
internal = functional.sequence(
|
|
353
|
+
functional.vector(exec, functional.when(is_module, disable(after_exec))), first))
|
|
354
354
|
|
|
355
355
|
# self.thread_state.wrap(desired_state = 'disabled', function = exec_wrapper)
|
|
356
356
|
|
|
@@ -416,14 +416,21 @@ class Patcher:
|
|
|
416
416
|
@patch
|
|
417
417
|
def patch_extension_exec(self, exec):
|
|
418
418
|
|
|
419
|
-
def
|
|
420
|
-
with self.thread_state.select('internal'):
|
|
421
|
-
res = exec(module)
|
|
419
|
+
def first(x): return x[0]
|
|
422
420
|
|
|
423
|
-
|
|
424
|
-
|
|
421
|
+
def disable(func): return self.thread_state.wrap('disabled', func)
|
|
422
|
+
|
|
423
|
+
return self.thread_state.dispatch(exec,
|
|
424
|
+
internal = functional.sequence(functional.vector(exec, disable(self)), first))
|
|
425
|
+
|
|
426
|
+
# def wrapper(module):
|
|
427
|
+
# with self.thread_state.select('internal'):
|
|
428
|
+
# res = exec(module)
|
|
429
|
+
|
|
430
|
+
# self(module)
|
|
431
|
+
# return res
|
|
425
432
|
|
|
426
|
-
return wrapper
|
|
433
|
+
# return wrapper
|
|
427
434
|
|
|
428
435
|
@patch
|
|
429
436
|
def path_predicates(self, func, param):
|
|
@@ -524,7 +531,7 @@ class Patcher:
|
|
|
524
531
|
self.post_commit(mod_name, updates)
|
|
525
532
|
|
|
526
533
|
def __call__(self, module):
|
|
527
|
-
|
|
534
|
+
|
|
528
535
|
if not hasattr(module, '__retrace__'):
|
|
529
536
|
|
|
530
537
|
configs = list(self.configs(module))
|
|
@@ -638,21 +645,19 @@ def install(mode):
|
|
|
638
645
|
|
|
639
646
|
threading.current_thread().__retrace__ = system
|
|
640
647
|
|
|
641
|
-
|
|
642
|
-
return frame.globals.get("__name__", None) == "__main__"
|
|
648
|
+
# original = atexit.register
|
|
643
649
|
|
|
644
|
-
|
|
650
|
+
# def atexit_register(function):
|
|
651
|
+
# return original(thread_state.wrap('internal', function))
|
|
645
652
|
|
|
646
|
-
def
|
|
647
|
-
if thread_state.value == 'internal':
|
|
648
|
-
return original(thread_state.wrap('internal', function))
|
|
649
|
-
else:
|
|
650
|
-
return original(function)
|
|
653
|
+
def wrap_internal(func): return thread_state.wrap('internal', func)
|
|
651
654
|
|
|
652
|
-
atexit.register =
|
|
655
|
+
atexit.register = \
|
|
656
|
+
thread_state.dispatch(atexit.register, internal = functional.sequence(wrap_internal, atexit.register))
|
|
653
657
|
|
|
654
658
|
def disable_after_main(frame):
|
|
655
|
-
if is_entry_frame(frame):
|
|
659
|
+
if system.is_entry_frame(frame):
|
|
660
|
+
print('enabling retrace!!!!')
|
|
656
661
|
# utils.intercept_frame_eval(None)
|
|
657
662
|
thread_state.value = 'internal'
|
|
658
663
|
|
|
@@ -669,5 +674,5 @@ def install(mode):
|
|
|
669
674
|
utils.intercept_frame_eval(disable_after_main)
|
|
670
675
|
|
|
671
676
|
# utils.sigtrap(None)
|
|
672
|
-
|
|
677
|
+
print(f'retrace installed: {thread_state}')
|
|
673
678
|
return system
|
|
@@ -70,6 +70,10 @@ def record_system(thread_state, immutable_types, config):
|
|
|
70
70
|
with open(recording_path / 'tracing_config.json', 'w') as f:
|
|
71
71
|
json.dump(tracing_config, f, indent=2)
|
|
72
72
|
|
|
73
|
+
def write_main_path(path):
|
|
74
|
+
with open(recording_path / 'mainscript', 'w') as f:
|
|
75
|
+
f.write(path)
|
|
76
|
+
|
|
73
77
|
# writer = stream.writer(path = recording_path / 'trace.bin')
|
|
74
78
|
|
|
75
79
|
# os.register_at_fork(
|
|
@@ -106,4 +110,5 @@ def record_system(thread_state, immutable_types, config):
|
|
|
106
110
|
return RecordProxySystem(thread_state = thread_state,
|
|
107
111
|
immutable_types = immutable_types,
|
|
108
112
|
tracing_config = tracing_config,
|
|
113
|
+
write_main_path = write_main_path,
|
|
109
114
|
path = recording_path / 'trace.bin')
|
|
@@ -48,7 +48,11 @@ def replay_system(thread_state, immutable_types, config):
|
|
|
48
48
|
with open(recording_path / "tracing_config.json", "r", encoding="utf-8") as f:
|
|
49
49
|
tracing_config = json.load(f)
|
|
50
50
|
|
|
51
|
+
with open(recording_path / "mainscript", "r", encoding="utf-8") as f:
|
|
52
|
+
mainscript = f.read()
|
|
53
|
+
|
|
51
54
|
return ReplayProxySystem(thread_state = thread_state,
|
|
52
55
|
immutable_types = immutable_types,
|
|
53
56
|
tracing_config = tracing_config,
|
|
57
|
+
mainscript = mainscript,
|
|
54
58
|
path = recording_path / 'trace.bin')
|
|
@@ -205,6 +205,9 @@ class ProxySystem:
|
|
|
205
205
|
|
|
206
206
|
return extended
|
|
207
207
|
|
|
208
|
+
def is_entry_frame(self, frame):
|
|
209
|
+
return frame.globals.get("__name__", None) == "__main__"
|
|
210
|
+
|
|
208
211
|
def __call__(self, obj):
|
|
209
212
|
assert not isinstance(obj, BaseException)
|
|
210
213
|
assert not isinstance(obj, Proxy)
|
retracesoftware/proxy/record.py
CHANGED
|
@@ -75,12 +75,20 @@ class RecordProxySystem(ProxySystem):
|
|
|
75
75
|
utils.set_thread_id(self.writer.handle(ThreadSwitch(id)))
|
|
76
76
|
# utils.set_thread_id(id)
|
|
77
77
|
|
|
78
|
+
def is_entry_frame(self, frame):
|
|
79
|
+
if super().is_entry_frame(frame):
|
|
80
|
+
self.write_main_path(frame.function.__code__.co_filename)
|
|
81
|
+
return True
|
|
82
|
+
return False
|
|
83
|
+
|
|
78
84
|
def __init__(self, thread_state,
|
|
79
85
|
immutable_types,
|
|
80
86
|
tracing_config,
|
|
87
|
+
write_main_path,
|
|
81
88
|
path):
|
|
82
89
|
|
|
83
90
|
self.fork_counter = 0
|
|
91
|
+
self.write_main_path = write_main_path
|
|
84
92
|
|
|
85
93
|
self.getpid = thread_state.wrap(
|
|
86
94
|
desired_state = 'disabled', function = os.getpid)
|
|
@@ -123,8 +131,10 @@ class RecordProxySystem(ProxySystem):
|
|
|
123
131
|
|
|
124
132
|
sync_handle = self.writer.handle('SYNC')
|
|
125
133
|
|
|
134
|
+
write_sync = thread_state.dispatch(utils.noop, internal = functional.lazy(sync_handle))
|
|
135
|
+
|
|
126
136
|
self.sync = lambda function: \
|
|
127
|
-
utils.observer(on_call =
|
|
137
|
+
utils.observer(on_call = write_sync, function = function)
|
|
128
138
|
|
|
129
139
|
error = self.writer.handle('ERROR')
|
|
130
140
|
|
retracesoftware/proxy/replay.py
CHANGED
|
@@ -230,15 +230,23 @@ class ReplayProxySystem(ProxySystem):
|
|
|
230
230
|
print(f'on_thread_exit!!!!')
|
|
231
231
|
self.reader.wake_pending()
|
|
232
232
|
|
|
233
|
+
def is_entry_frame(self, frame):
|
|
234
|
+
if super().is_entry_frame(frame) and frame.function.__code__.co_filename == self.mainscript:
|
|
235
|
+
return True
|
|
236
|
+
return False
|
|
237
|
+
|
|
233
238
|
def __init__(self,
|
|
234
239
|
thread_state,
|
|
235
240
|
immutable_types,
|
|
236
241
|
tracing_config,
|
|
242
|
+
mainscript,
|
|
237
243
|
path,
|
|
238
244
|
fork_path = []):
|
|
239
245
|
|
|
240
246
|
# self.messages_read = 0
|
|
241
247
|
|
|
248
|
+
self.mainscript = mainscript
|
|
249
|
+
|
|
242
250
|
self.reader = stream.reader(path,
|
|
243
251
|
thread = thread_id,
|
|
244
252
|
timeout_seconds = 60)
|
|
@@ -278,7 +286,7 @@ class ReplayProxySystem(ProxySystem):
|
|
|
278
286
|
self.reader.type_deserializer[StubRef] = self.stub_factory
|
|
279
287
|
self.reader.type_deserializer[GlobalRef] = lambda ref: ref()
|
|
280
288
|
|
|
281
|
-
read_sync = functional.lazy(thread_state.wrap('disabled', self.read_required), 'SYNC')
|
|
289
|
+
read_sync = thread_state.dispatch(utils.noop, internal = functional.lazy(thread_state.wrap('disabled', self.read_required), 'SYNC'))
|
|
282
290
|
|
|
283
291
|
self.sync = lambda function: utils.observer(on_call = read_sync, function = function)
|
|
284
292
|
|
|
@@ -6,24 +6,24 @@ retracesoftware/install/config.py,sha256=EzE5ifQF2lo--hu2njI4T0FJ-zlnWDJV6i7x0DM
|
|
|
6
6
|
retracesoftware/install/edgecases.py,sha256=NR3lyvad9sRsyeDv_Ya8V4xMgPsMPOi9rMcnFOJGOEA,6330
|
|
7
7
|
retracesoftware/install/globals.py,sha256=F8XvIoZQQ10gSRalk30dvdKllxlwxkaggYY6FogLDxY,510
|
|
8
8
|
retracesoftware/install/install.py,sha256=HCD_ji8XCr96b5fNzNdL_8qcEp0Jf05Em7T6GA6u8HU,4969
|
|
9
|
-
retracesoftware/install/patcher.py,sha256=
|
|
9
|
+
retracesoftware/install/patcher.py,sha256=XwpySyqaop3bnLc8ewtowxLchAC0mOtXWDfmk5zTE_s,22195
|
|
10
10
|
retracesoftware/install/predicate.py,sha256=tX7NQc0rGkyyHYO3mduYHcJHbw1wczT53m_Dpkzo6do,2679
|
|
11
|
-
retracesoftware/install/record.py,sha256=
|
|
11
|
+
retracesoftware/install/record.py,sha256=mjk4bien8uWp8c-vWNw3Y4BRR5xO4AWsZi1aodkW5yc,3590
|
|
12
12
|
retracesoftware/install/references.py,sha256=A-G651IDOfuo00MkbAdpbIQh_15ChvJ7uAVTSmE6zd4,1721
|
|
13
|
-
retracesoftware/install/replay.py,sha256=
|
|
13
|
+
retracesoftware/install/replay.py,sha256=36x40dk8pCmVjHz8zKd2OLY3B7UkP0NEb-1V1X8o3Rg,1992
|
|
14
14
|
retracesoftware/install/tracer.py,sha256=MiaTPlUwcRbgL4CTNhvC4Y5mUhkb--Y7_icTPhscSmY,9014
|
|
15
15
|
retracesoftware/install/typeutils.py,sha256=-oFzgUfq_nHeOkj3YKZiMLlMzQhCedg3qymLiEJNkVE,2253
|
|
16
16
|
retracesoftware/proxy/__init__.py,sha256=ntIyqKhBRkKEkcW_oOPodikh-mxYl8OXRnSaj-9-Xwc,178
|
|
17
17
|
retracesoftware/proxy/gateway.py,sha256=xESohWXkiNm4ZutU0RgWUwxjxcBWRQ4rQyxIGQXv_F4,1590
|
|
18
18
|
retracesoftware/proxy/globalref.py,sha256=yXtJsOeBHN9xoEgJWA3MJco-jD2SQUef_fDatA4A6rg,803
|
|
19
19
|
retracesoftware/proxy/proxyfactory.py,sha256=qhOqDfMJnLDNkQs26JqDB431MwjjRhGQi8xupJ45asg,12272
|
|
20
|
-
retracesoftware/proxy/proxysystem.py,sha256=
|
|
20
|
+
retracesoftware/proxy/proxysystem.py,sha256=zXrK4eMBJHZlmRJ2pQMltzYHF5CjnAZV6Z_teGH6DO8,8071
|
|
21
21
|
retracesoftware/proxy/proxytype.py,sha256=83y5rQRSts-5rLZu_k3tT90mwX2M-Ny6RZ91l-LTJ6k,13199
|
|
22
|
-
retracesoftware/proxy/record.py,sha256=
|
|
23
|
-
retracesoftware/proxy/replay.py,sha256=
|
|
22
|
+
retracesoftware/proxy/record.py,sha256=AsoVhuTX0pVVAqOih9-Mgh54psyggqfAXwAYYwy7umM,5818
|
|
23
|
+
retracesoftware/proxy/replay.py,sha256=mMb3jiCPS8W-Nev1JMaBIQSxRjV1sKTJYRPWAurw4i0,10264
|
|
24
24
|
retracesoftware/proxy/stubfactory.py,sha256=eHlbzWR1LoQVkIRX1HoLPPQSOpYhOO_5R_p3buD4o7s,5256
|
|
25
25
|
retracesoftware/proxy/thread.py,sha256=T1ME6DHB8O0xVnX3Rt1lMl7oCJ2Y0aoFT91D76yNICk,3073
|
|
26
|
-
retracesoftware_proxy-0.1.
|
|
27
|
-
retracesoftware_proxy-0.1.
|
|
28
|
-
retracesoftware_proxy-0.1.
|
|
29
|
-
retracesoftware_proxy-0.1.
|
|
26
|
+
retracesoftware_proxy-0.1.21.dist-info/METADATA,sha256=VgiJFRiDUgZhUA5wfe4TLOD62q0y2Dvu3jCGGuR2t4s,203
|
|
27
|
+
retracesoftware_proxy-0.1.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
28
|
+
retracesoftware_proxy-0.1.21.dist-info/top_level.txt,sha256=hYHsR6txLidmqvjBMITpIHvmJJbmoCAgr76-IpZPRz8,16
|
|
29
|
+
retracesoftware_proxy-0.1.21.dist-info/RECORD,,
|
|
File without changes
|
{retracesoftware_proxy-0.1.19.dist-info → retracesoftware_proxy-0.1.21.dist-info}/top_level.txt
RENAMED
|
File without changes
|