Miras-P commited on
Commit
2f338c0
1 Parent(s): 9e459c4

initial commit

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.so* filter=lfs diff=lfs merge=lfs -text
37
+ *.so filter=lfs diff=lfs merge=lfs -text
my_env/lib/python3.10/site-packages/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.cpython-310-x86_64-linux-gnu.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46d028b5eaab7de62f3c52391a2c8cc2e7503c4f693519131b8c6d4530ac876a
3
+ size 1543024
my_env/lib/python3.10/site-packages/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pyx ADDED
@@ -0,0 +1,747 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import print_function
2
+ from _pydev_bundle._pydev_saved_modules import threading, thread
3
+ from _pydevd_bundle.pydevd_constants import GlobalDebuggerHolder
4
+ import dis
5
+ import sys
6
+ from _pydevd_frame_eval.pydevd_frame_tracing import update_globals_dict, dummy_tracing_holder
7
+ from _pydevd_frame_eval.pydevd_modify_bytecode import DebugHelper, insert_pydevd_breaks
8
+ from pydevd_file_utils import get_abs_path_real_path_and_base_from_frame, NORM_PATHS_AND_BASE_CONTAINER
9
+ from _pydevd_bundle.pydevd_trace_dispatch import fix_top_level_trace_and_get_trace_func
10
+
11
+ from _pydevd_bundle.pydevd_additional_thread_info import _set_additional_thread_info_lock
12
+ from _pydevd_bundle.pydevd_cython cimport PyDBAdditionalThreadInfo
13
+ from pydevd_tracing import SetTrace
14
+
15
+ _get_ident = threading.get_ident # Note this is py3 only, if py2 needed to be supported, _get_ident would be needed.
16
+ _thread_local_info = threading.local()
17
+ _thread_active = threading._active
18
+
19
+ def clear_thread_local_info():
20
+ global _thread_local_info
21
+ _thread_local_info = threading.local()
22
+
23
+
24
+ cdef class ThreadInfo:
25
+
26
+ cdef public PyDBAdditionalThreadInfo additional_info
27
+ cdef public bint is_pydevd_thread
28
+ cdef public int inside_frame_eval
29
+ cdef public bint fully_initialized
30
+ cdef public object thread_trace_func
31
+ cdef bint _can_create_dummy_thread
32
+
33
+ # Note: whenever get_func_code_info is called, this value is reset (we're using
34
+ # it as a thread-local value info).
35
+ # If True the debugger should not go into trace mode even if the new
36
+ # code for a function is None and there are breakpoints.
37
+ cdef public bint force_stay_in_untraced_mode
38
+
39
+ cdef initialize(self, PyFrameObject * frame_obj):
40
+ # Places that create a ThreadInfo should verify that
41
+ # a current Python frame is being executed!
42
+ assert frame_obj != NULL
43
+
44
+ self.additional_info = None
45
+ self.is_pydevd_thread = False
46
+ self.inside_frame_eval = 0
47
+ self.fully_initialized = False
48
+ self.thread_trace_func = None
49
+
50
+ # Get the root (if it's not a Thread initialized from the threading
51
+ # module, create the dummy thread entry so that we can debug it --
52
+ # otherwise, we have to wait for the threading module itself to
53
+ # create the Thread entry).
54
+ while frame_obj.f_back != NULL:
55
+ frame_obj = frame_obj.f_back
56
+
57
+ basename = <str> frame_obj.f_code.co_filename
58
+ i = basename.rfind('/')
59
+ j = basename.rfind('\\')
60
+ if j > i:
61
+ i = j
62
+ if i >= 0:
63
+ basename = basename[i + 1:]
64
+ # remove ext
65
+ i = basename.rfind('.')
66
+ if i >= 0:
67
+ basename = basename[:i]
68
+
69
+ co_name = <str> frame_obj.f_code.co_name
70
+
71
+ # In these cases we cannot create a dummy thread (an actual
72
+ # thread will be created later or tracing will already be set).
73
+ if basename == 'threading' and co_name in ('__bootstrap', '_bootstrap', '__bootstrap_inner', '_bootstrap_inner'):
74
+ self._can_create_dummy_thread = False
75
+ elif basename == 'pydev_monkey' and co_name == '__call__':
76
+ self._can_create_dummy_thread = False
77
+ elif basename == 'pydevd' and co_name in ('run', 'main', '_exec'):
78
+ self._can_create_dummy_thread = False
79
+ elif basename == 'pydevd_tracing':
80
+ self._can_create_dummy_thread = False
81
+ else:
82
+ self._can_create_dummy_thread = True
83
+
84
+ # print('Can create dummy thread for thread started in: %s %s' % (basename, co_name))
85
+
86
+ cdef initialize_if_possible(self):
87
+ # Don't call threading.currentThread because if we're too early in the process
88
+ # we may create a dummy thread.
89
+ self.inside_frame_eval += 1
90
+
91
+ try:
92
+ thread_ident = _get_ident()
93
+ t = _thread_active.get(thread_ident)
94
+ if t is None:
95
+ if self._can_create_dummy_thread:
96
+ # Initialize the dummy thread and set the tracing (both are needed to
97
+ # actually stop on breakpoints).
98
+ t = threading.current_thread()
99
+ SetTrace(dummy_trace_dispatch)
100
+ else:
101
+ return # Cannot initialize until thread becomes active.
102
+
103
+ if getattr(t, 'is_pydev_daemon_thread', False):
104
+ self.is_pydevd_thread = True
105
+ self.fully_initialized = True
106
+ else:
107
+ try:
108
+ additional_info = t.additional_info
109
+ if additional_info is None:
110
+ raise AttributeError()
111
+ except:
112
+ with _set_additional_thread_info_lock:
113
+ # If it's not there, set it within a lock to avoid any racing
114
+ # conditions.
115
+ additional_info = getattr(thread, 'additional_info', None)
116
+ if additional_info is None:
117
+ additional_info = PyDBAdditionalThreadInfo()
118
+ t.additional_info = additional_info
119
+ self.additional_info = additional_info
120
+ self.fully_initialized = True
121
+ finally:
122
+ self.inside_frame_eval -= 1
123
+
124
+
125
+ cdef class FuncCodeInfo:
126
+
127
+ cdef public str co_filename
128
+ cdef public str co_name
129
+ cdef public str canonical_normalized_filename
130
+ cdef bint always_skip_code
131
+ cdef public bint breakpoint_found
132
+ cdef public object new_code
133
+
134
+ # When breakpoints_mtime != PyDb.mtime the validity of breakpoints have
135
+ # to be re-evaluated (if invalid a new FuncCodeInfo must be created and
136
+ # tracing can't be disabled for the related frames).
137
+ cdef public int breakpoints_mtime
138
+
139
+ def __init__(self):
140
+ self.co_filename = ''
141
+ self.canonical_normalized_filename = ''
142
+ self.always_skip_code = False
143
+
144
+ # If breakpoints are found but new_code is None,
145
+ # this means we weren't able to actually add the code
146
+ # where needed, so, fallback to tracing.
147
+ self.breakpoint_found = False
148
+ self.new_code = None
149
+ self.breakpoints_mtime = -1
150
+
151
+
152
+ def dummy_trace_dispatch(frame, str event, arg):
153
+ if event == 'call':
154
+ if frame.f_trace is not None:
155
+ return frame.f_trace(frame, event, arg)
156
+ return None
157
+
158
+
159
+ def get_thread_info_py() -> ThreadInfo:
160
+ return get_thread_info(PyEval_GetFrame())
161
+
162
+
163
+ cdef ThreadInfo get_thread_info(PyFrameObject * frame_obj):
164
+ '''
165
+ Provides thread-related info.
166
+
167
+ May return None if the thread is still not active.
168
+ '''
169
+ cdef ThreadInfo thread_info
170
+ try:
171
+ # Note: changing to a `dict[thread.ident] = thread_info` had almost no
172
+ # effect in the performance.
173
+ thread_info = _thread_local_info.thread_info
174
+ except:
175
+ if frame_obj == NULL:
176
+ return None
177
+ thread_info = ThreadInfo()
178
+ thread_info.initialize(frame_obj)
179
+ thread_info.inside_frame_eval += 1
180
+ try:
181
+ _thread_local_info.thread_info = thread_info
182
+
183
+ # Note: _code_extra_index is not actually thread-related,
184
+ # but this is a good point to initialize it.
185
+ global _code_extra_index
186
+ if _code_extra_index == -1:
187
+ _code_extra_index = <int> _PyEval_RequestCodeExtraIndex(release_co_extra)
188
+
189
+ thread_info.initialize_if_possible()
190
+ finally:
191
+ thread_info.inside_frame_eval -= 1
192
+
193
+ return thread_info
194
+
195
+
196
+ def decref_py(obj):
197
+ '''
198
+ Helper to be called from Python.
199
+ '''
200
+ Py_DECREF(obj)
201
+
202
+
203
+ def get_func_code_info_py(thread_info, frame, code_obj) -> FuncCodeInfo:
204
+ '''
205
+ Helper to be called from Python.
206
+ '''
207
+ return get_func_code_info(<ThreadInfo> thread_info, <PyFrameObject *> frame, <PyCodeObject *> code_obj)
208
+
209
+
210
+ cdef int _code_extra_index = -1
211
+
212
+ cdef FuncCodeInfo get_func_code_info(ThreadInfo thread_info, PyFrameObject * frame_obj, PyCodeObject * code_obj):
213
+ '''
214
+ Provides code-object related info.
215
+
216
+ Stores the gathered info in a cache in the code object itself. Note that
217
+ multiple threads can get the same info.
218
+
219
+ get_thread_info() *must* be called at least once before get_func_code_info()
220
+ to initialize _code_extra_index.
221
+
222
+ '''
223
+ # f_code = <object> code_obj
224
+ # DEBUG = f_code.co_filename.endswith('_debugger_case_multiprocessing.py')
225
+ # if DEBUG:
226
+ # print('get_func_code_info', f_code.co_name, f_code.co_filename)
227
+
228
+ cdef object main_debugger = GlobalDebuggerHolder.global_dbg
229
+ thread_info.force_stay_in_untraced_mode = False # This is an output value of the function.
230
+
231
+ cdef PyObject * extra
232
+ _PyCode_GetExtra(<PyObject *> code_obj, _code_extra_index, & extra)
233
+ if extra is not NULL:
234
+ extra_obj = <PyObject *> extra
235
+ if extra_obj is not NULL:
236
+ func_code_info_obj = <FuncCodeInfo> extra_obj
237
+ if func_code_info_obj.breakpoints_mtime == main_debugger.mtime:
238
+ # if DEBUG:
239
+ # print('get_func_code_info: matched mtime', f_code.co_name, f_code.co_filename)
240
+
241
+ return func_code_info_obj
242
+
243
+ cdef str co_filename = <str> code_obj.co_filename
244
+ cdef str co_name = <str> code_obj.co_name
245
+ cdef dict cache_file_type
246
+ cdef tuple cache_file_type_key
247
+
248
+ func_code_info = FuncCodeInfo()
249
+ func_code_info.breakpoints_mtime = main_debugger.mtime
250
+
251
+ func_code_info.co_filename = co_filename
252
+ func_code_info.co_name = co_name
253
+
254
+ if not func_code_info.always_skip_code:
255
+ try:
256
+ abs_path_real_path_and_base = NORM_PATHS_AND_BASE_CONTAINER[co_filename]
257
+ except:
258
+ abs_path_real_path_and_base = get_abs_path_real_path_and_base_from_frame(<object>frame_obj)
259
+
260
+ func_code_info.canonical_normalized_filename = abs_path_real_path_and_base[1]
261
+
262
+ cache_file_type = main_debugger.get_cache_file_type()
263
+ # Note: this cache key must be the same from PyDB.get_file_type() -- see it for comments
264
+ # on the cache.
265
+ cache_file_type_key = (frame_obj.f_code.co_firstlineno, abs_path_real_path_and_base[0], <object>frame_obj.f_code)
266
+ try:
267
+ file_type = cache_file_type[cache_file_type_key] # Make it faster
268
+ except:
269
+ file_type = main_debugger.get_file_type(<object>frame_obj, abs_path_real_path_and_base) # we don't want to debug anything related to pydevd
270
+
271
+ if file_type is not None:
272
+ func_code_info.always_skip_code = True
273
+
274
+ if not func_code_info.always_skip_code:
275
+ if main_debugger is not None:
276
+
277
+ breakpoints: dict = main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename)
278
+ function_breakpoint: object = main_debugger.function_breakpoint_name_to_breakpoint.get(func_code_info.co_name)
279
+ # print('\n---')
280
+ # print(main_debugger.breakpoints)
281
+ # print(func_code_info.canonical_normalized_filename)
282
+ # print(main_debugger.breakpoints.get(func_code_info.canonical_normalized_filename))
283
+ code_obj_py: object = <object> code_obj
284
+ cached_code_obj_info: object = _cache.get(code_obj_py)
285
+ if cached_code_obj_info:
286
+ # The cache is for new code objects, so, in this case it's already
287
+ # using the new code and we can't change it as this is a generator!
288
+ # There's still a catch though: even though we don't replace the code,
289
+ # we may not want to go into tracing mode (as would usually happen
290
+ # when the new_code is None).
291
+ func_code_info.new_code = None
292
+ breakpoint_found, thread_info.force_stay_in_untraced_mode = \
293
+ cached_code_obj_info.compute_force_stay_in_untraced_mode(breakpoints)
294
+ func_code_info.breakpoint_found = breakpoint_found
295
+
296
+ elif function_breakpoint:
297
+ # Go directly into tracing mode
298
+ func_code_info.breakpoint_found = True
299
+ func_code_info.new_code = None
300
+
301
+ elif breakpoints:
302
+ # if DEBUG:
303
+ # print('found breakpoints', code_obj_py.co_name, breakpoints)
304
+
305
+ # Note: new_code can be None if unable to generate.
306
+ # It should automatically put the new code object in the cache.
307
+ breakpoint_found, func_code_info.new_code = generate_code_with_breakpoints(code_obj_py, breakpoints)
308
+ func_code_info.breakpoint_found = breakpoint_found
309
+
310
+ Py_INCREF(func_code_info)
311
+ _PyCode_SetExtra(<PyObject *> code_obj, _code_extra_index, <PyObject *> func_code_info)
312
+
313
+ return func_code_info
314
+
315
+
316
+ cdef class _CodeLineInfo:
317
+
318
+ cdef public dict line_to_offset
319
+ cdef public int first_line
320
+ cdef public int last_line
321
+
322
+ def __init__(self, dict line_to_offset, int first_line, int last_line):
323
+ self.line_to_offset = line_to_offset
324
+ self.first_line = first_line
325
+ self.last_line = last_line
326
+
327
+
328
+ # Note: this method has a version in pure-python too.
329
+ def _get_code_line_info(code_obj):
330
+ line_to_offset: dict = {}
331
+ first_line: int = None
332
+ last_line: int = None
333
+
334
+ cdef int offset
335
+ cdef int line
336
+
337
+ for offset, line in dis.findlinestarts(code_obj):
338
+ line_to_offset[line] = offset
339
+
340
+ if line_to_offset:
341
+ first_line = min(line_to_offset)
342
+ last_line = max(line_to_offset)
343
+ return _CodeLineInfo(line_to_offset, first_line, last_line)
344
+
345
+
346
+ # Note: this is a cache where the key is the code objects we create ourselves so that
347
+ # we always return the same code object for generators.
348
+ # (so, we don't have a cache from the old code to the new info -- that's actually
349
+ # handled by the cython side in `FuncCodeInfo get_func_code_info` by providing the
350
+ # same code info if the debugger mtime is still the same).
351
+ _cache: dict = {}
352
+
353
+ def get_cached_code_obj_info_py(code_obj_py):
354
+ '''
355
+ :return _CacheValue:
356
+ :note: on cython use _cache.get(code_obj_py) directly.
357
+ '''
358
+ return _cache.get(code_obj_py)
359
+
360
+
361
+ cdef class _CacheValue(object):
362
+
363
+ cdef public object code_obj_py
364
+ cdef public _CodeLineInfo code_line_info
365
+ cdef public set breakpoints_hit_at_lines
366
+ cdef public set code_lines_as_set
367
+
368
+ def __init__(self, object code_obj_py, _CodeLineInfo code_line_info, set breakpoints_hit_at_lines):
369
+ '''
370
+ :param code_obj_py:
371
+ :param _CodeLineInfo code_line_info:
372
+ :param set[int] breakpoints_hit_at_lines:
373
+ '''
374
+ self.code_obj_py = code_obj_py
375
+ self.code_line_info = code_line_info
376
+ self.breakpoints_hit_at_lines = breakpoints_hit_at_lines
377
+ self.code_lines_as_set = set(code_line_info.line_to_offset)
378
+
379
+ cpdef compute_force_stay_in_untraced_mode(self, breakpoints):
380
+ '''
381
+ :param breakpoints:
382
+ set(breakpoint_lines) or dict(breakpoint_line->breakpoint info)
383
+ :return tuple(breakpoint_found, force_stay_in_untraced_mode)
384
+ '''
385
+ cdef bint force_stay_in_untraced_mode
386
+ cdef bint breakpoint_found
387
+ cdef set target_breakpoints
388
+
389
+ force_stay_in_untraced_mode = False
390
+
391
+ target_breakpoints = self.code_lines_as_set.intersection(breakpoints)
392
+ breakpoint_found = bool(target_breakpoints)
393
+
394
+ if not breakpoint_found:
395
+ force_stay_in_untraced_mode = True
396
+ else:
397
+ force_stay_in_untraced_mode = self.breakpoints_hit_at_lines.issuperset(set(breakpoints))
398
+
399
+ return breakpoint_found, force_stay_in_untraced_mode
400
+
401
+ def generate_code_with_breakpoints_py(object code_obj_py, dict breakpoints):
402
+ return generate_code_with_breakpoints(code_obj_py, breakpoints)
403
+
404
+ # DEBUG = True
405
+ # debug_helper = DebugHelper()
406
+
407
+ cdef generate_code_with_breakpoints(object code_obj_py, dict breakpoints):
408
+ '''
409
+ :param breakpoints:
410
+ dict where the keys are the breakpoint lines.
411
+ :return tuple(breakpoint_found, new_code)
412
+ '''
413
+ # The cache is needed for generator functions, because after each yield a new frame
414
+ # is created but the former code object is used (so, check if code_to_modify is
415
+ # already there and if not cache based on the new code generated).
416
+
417
+ cdef bint success
418
+ cdef int breakpoint_line
419
+ cdef bint breakpoint_found
420
+ cdef _CacheValue cache_value
421
+ cdef set breakpoints_hit_at_lines
422
+ cdef dict line_to_offset
423
+
424
+ assert code_obj_py not in _cache, 'If a code object is cached, that same code object must be reused.'
425
+
426
+ # if DEBUG:
427
+ # initial_code_obj_py = code_obj_py
428
+
429
+ code_line_info = _get_code_line_info(code_obj_py)
430
+
431
+ success = True
432
+
433
+ breakpoints_hit_at_lines = set()
434
+ line_to_offset = code_line_info.line_to_offset
435
+
436
+ for breakpoint_line in breakpoints:
437
+ if breakpoint_line in line_to_offset:
438
+ breakpoints_hit_at_lines.add(breakpoint_line)
439
+
440
+ if breakpoints_hit_at_lines:
441
+ success, new_code = insert_pydevd_breaks(
442
+ code_obj_py,
443
+ breakpoints_hit_at_lines,
444
+ code_line_info
445
+ )
446
+
447
+ if not success:
448
+ code_obj_py = None
449
+ else:
450
+ code_obj_py = new_code
451
+
452
+ breakpoint_found = bool(breakpoints_hit_at_lines)
453
+ if breakpoint_found and success:
454
+ # if DEBUG:
455
+ # op_number = debug_helper.write_dis(
456
+ # 'inserting code, breaks at: %s' % (list(breakpoints),),
457
+ # initial_code_obj_py
458
+ # )
459
+ #
460
+ # debug_helper.write_dis(
461
+ # 'after inserting code, breaks at: %s' % (list(breakpoints,)),
462
+ # code_obj_py,
463
+ # op_number=op_number,
464
+ # )
465
+
466
+ cache_value = _CacheValue(code_obj_py, code_line_info, breakpoints_hit_at_lines)
467
+ _cache[code_obj_py] = cache_value
468
+
469
+ return breakpoint_found, code_obj_py
470
+
471
+ import sys
472
+
473
+ cdef bint IS_PY_39_OWNARDS = sys.version_info[:2] >= (3, 9)
474
+
475
+ def frame_eval_func():
476
+ cdef PyThreadState *state = PyThreadState_Get()
477
+ if IS_PY_39_OWNARDS:
478
+ state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39
479
+ else:
480
+ state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_38
481
+ dummy_tracing_holder.set_trace_func(dummy_trace_dispatch)
482
+
483
+
484
+ def stop_frame_eval():
485
+ cdef PyThreadState *state = PyThreadState_Get()
486
+ state.interp.eval_frame = _PyEval_EvalFrameDefault
487
+
488
+ # During the build we'll generate 2 versions of the code below so that we're compatible with
489
+ # Python 3.9, which receives a "PyThreadState* tstate" as the first parameter and Python 3.6-3.8
490
+ # which doesn't.
491
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
492
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
493
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
494
+ cdef PyObject * get_bytecode_while_frame_eval_38(PyFrameObject * frame_obj, int exc):
495
+ '''
496
+ This function makes the actual evaluation and changes the bytecode to a version
497
+ where programmatic breakpoints are added.
498
+ '''
499
+ if GlobalDebuggerHolder is None or _thread_local_info is None or exc:
500
+ # Sometimes during process shutdown these global variables become None
501
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
502
+
503
+ # co_filename: str = <str>frame_obj.f_code.co_filename
504
+ # if co_filename.endswith('threading.py'):
505
+ # return CALL_EvalFrameDefault_38(frame_obj, exc)
506
+
507
+ cdef ThreadInfo thread_info
508
+ cdef int STATE_SUSPEND = 2
509
+ cdef int CMD_STEP_INTO = 107
510
+ cdef int CMD_STEP_OVER = 108
511
+ cdef int CMD_STEP_OVER_MY_CODE = 159
512
+ cdef int CMD_STEP_INTO_MY_CODE = 144
513
+ cdef int CMD_STEP_INTO_COROUTINE = 206
514
+ cdef int CMD_SMART_STEP_INTO = 128
515
+ cdef bint can_skip = True
516
+ try:
517
+ thread_info = _thread_local_info.thread_info
518
+ except:
519
+ thread_info = get_thread_info(frame_obj)
520
+ if thread_info is None:
521
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
522
+
523
+ if thread_info.inside_frame_eval:
524
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
525
+
526
+ if not thread_info.fully_initialized:
527
+ thread_info.initialize_if_possible()
528
+ if not thread_info.fully_initialized:
529
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
530
+
531
+ # Can only get additional_info when fully initialized.
532
+ cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info
533
+ if thread_info.is_pydevd_thread or additional_info.is_tracing:
534
+ # Make sure that we don't trace pydevd threads or inside our own calls.
535
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
536
+
537
+ # frame = <object> frame_obj
538
+ # DEBUG = frame.f_code.co_filename.endswith('_debugger_case_tracing.py')
539
+ # if DEBUG:
540
+ # print('get_bytecode_while_frame_eval', frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename)
541
+
542
+ thread_info.inside_frame_eval += 1
543
+ additional_info.is_tracing = True
544
+ try:
545
+ main_debugger: object = GlobalDebuggerHolder.global_dbg
546
+ if main_debugger is None:
547
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
548
+ frame = <object> frame_obj
549
+
550
+ if thread_info.thread_trace_func is None:
551
+ trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame)
552
+ if apply_to_global:
553
+ thread_info.thread_trace_func = trace_func
554
+
555
+ if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \
556
+ main_debugger.break_on_caught_exceptions or \
557
+ main_debugger.break_on_user_uncaught_exceptions or \
558
+ main_debugger.has_plugin_exception_breaks or \
559
+ main_debugger.signature_factory or \
560
+ additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop:
561
+
562
+ # if DEBUG:
563
+ # print('get_bytecode_while_frame_eval enabled trace')
564
+ if thread_info.thread_trace_func is not None:
565
+ frame.f_trace = thread_info.thread_trace_func
566
+ else:
567
+ frame.f_trace = <object> main_debugger.trace_dispatch
568
+ else:
569
+ func_code_info: FuncCodeInfo = get_func_code_info(thread_info, frame_obj, frame_obj.f_code)
570
+ # if DEBUG:
571
+ # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code)
572
+ if not func_code_info.always_skip_code:
573
+
574
+ if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks:
575
+ can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj)
576
+
577
+ if not can_skip:
578
+ # if DEBUG:
579
+ # print('get_bytecode_while_frame_eval not can_skip')
580
+ if thread_info.thread_trace_func is not None:
581
+ frame.f_trace = thread_info.thread_trace_func
582
+ else:
583
+ frame.f_trace = <object> main_debugger.trace_dispatch
584
+
585
+ if can_skip and func_code_info.breakpoint_found:
586
+ # if DEBUG:
587
+ # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code)
588
+ if not thread_info.force_stay_in_untraced_mode:
589
+ # If breakpoints are found but new_code is None,
590
+ # this means we weren't able to actually add the code
591
+ # where needed, so, fallback to tracing.
592
+ if func_code_info.new_code is None:
593
+ if thread_info.thread_trace_func is not None:
594
+ frame.f_trace = thread_info.thread_trace_func
595
+ else:
596
+ frame.f_trace = <object> main_debugger.trace_dispatch
597
+ else:
598
+ # print('Using frame eval break for', <object> frame_obj.f_code.co_name)
599
+ update_globals_dict(<object> frame_obj.f_globals)
600
+ Py_INCREF(func_code_info.new_code)
601
+ old = <object> frame_obj.f_code
602
+ frame_obj.f_code = <PyCodeObject *> func_code_info.new_code
603
+ Py_DECREF(old)
604
+ else:
605
+ # When we're forcing to stay in traced mode we need to
606
+ # update the globals dict (because this means that we're reusing
607
+ # a previous code which had breakpoints added in a new frame).
608
+ update_globals_dict(<object> frame_obj.f_globals)
609
+
610
+ finally:
611
+ thread_info.inside_frame_eval -= 1
612
+ additional_info.is_tracing = False
613
+
614
+ return CALL_EvalFrameDefault_38(frame_obj, exc)
615
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
616
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
617
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
618
+
619
+
620
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
621
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
622
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
623
+ cdef PyObject * get_bytecode_while_frame_eval_39(PyThreadState* tstate, PyFrameObject * frame_obj, int exc):
624
+ '''
625
+ This function makes the actual evaluation and changes the bytecode to a version
626
+ where programmatic breakpoints are added.
627
+ '''
628
+ if GlobalDebuggerHolder is None or _thread_local_info is None or exc:
629
+ # Sometimes during process shutdown these global variables become None
630
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
631
+
632
+ # co_filename: str = <str>frame_obj.f_code.co_filename
633
+ # if co_filename.endswith('threading.py'):
634
+ # return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
635
+
636
+ cdef ThreadInfo thread_info
637
+ cdef int STATE_SUSPEND = 2
638
+ cdef int CMD_STEP_INTO = 107
639
+ cdef int CMD_STEP_OVER = 108
640
+ cdef int CMD_STEP_OVER_MY_CODE = 159
641
+ cdef int CMD_STEP_INTO_MY_CODE = 144
642
+ cdef int CMD_STEP_INTO_COROUTINE = 206
643
+ cdef int CMD_SMART_STEP_INTO = 128
644
+ cdef bint can_skip = True
645
+ try:
646
+ thread_info = _thread_local_info.thread_info
647
+ except:
648
+ thread_info = get_thread_info(frame_obj)
649
+ if thread_info is None:
650
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
651
+
652
+ if thread_info.inside_frame_eval:
653
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
654
+
655
+ if not thread_info.fully_initialized:
656
+ thread_info.initialize_if_possible()
657
+ if not thread_info.fully_initialized:
658
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
659
+
660
+ # Can only get additional_info when fully initialized.
661
+ cdef PyDBAdditionalThreadInfo additional_info = thread_info.additional_info
662
+ if thread_info.is_pydevd_thread or additional_info.is_tracing:
663
+ # Make sure that we don't trace pydevd threads or inside our own calls.
664
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
665
+
666
+ # frame = <object> frame_obj
667
+ # DEBUG = frame.f_code.co_filename.endswith('_debugger_case_tracing.py')
668
+ # if DEBUG:
669
+ # print('get_bytecode_while_frame_eval', frame.f_lineno, frame.f_code.co_name, frame.f_code.co_filename)
670
+
671
+ thread_info.inside_frame_eval += 1
672
+ additional_info.is_tracing = True
673
+ try:
674
+ main_debugger: object = GlobalDebuggerHolder.global_dbg
675
+ if main_debugger is None:
676
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
677
+ frame = <object> frame_obj
678
+
679
+ if thread_info.thread_trace_func is None:
680
+ trace_func, apply_to_global = fix_top_level_trace_and_get_trace_func(main_debugger, frame)
681
+ if apply_to_global:
682
+ thread_info.thread_trace_func = trace_func
683
+
684
+ if additional_info.pydev_step_cmd in (CMD_STEP_INTO, CMD_STEP_INTO_MY_CODE, CMD_STEP_INTO_COROUTINE, CMD_SMART_STEP_INTO) or \
685
+ main_debugger.break_on_caught_exceptions or \
686
+ main_debugger.break_on_user_uncaught_exceptions or \
687
+ main_debugger.has_plugin_exception_breaks or \
688
+ main_debugger.signature_factory or \
689
+ additional_info.pydev_step_cmd in (CMD_STEP_OVER, CMD_STEP_OVER_MY_CODE) and main_debugger.show_return_values and frame.f_back is additional_info.pydev_step_stop:
690
+
691
+ # if DEBUG:
692
+ # print('get_bytecode_while_frame_eval enabled trace')
693
+ if thread_info.thread_trace_func is not None:
694
+ frame.f_trace = thread_info.thread_trace_func
695
+ else:
696
+ frame.f_trace = <object> main_debugger.trace_dispatch
697
+ else:
698
+ func_code_info: FuncCodeInfo = get_func_code_info(thread_info, frame_obj, frame_obj.f_code)
699
+ # if DEBUG:
700
+ # print('get_bytecode_while_frame_eval always skip', func_code_info.always_skip_code)
701
+ if not func_code_info.always_skip_code:
702
+
703
+ if main_debugger.has_plugin_line_breaks or main_debugger.has_plugin_exception_breaks:
704
+ can_skip = main_debugger.plugin.can_skip(main_debugger, <object> frame_obj)
705
+
706
+ if not can_skip:
707
+ # if DEBUG:
708
+ # print('get_bytecode_while_frame_eval not can_skip')
709
+ if thread_info.thread_trace_func is not None:
710
+ frame.f_trace = thread_info.thread_trace_func
711
+ else:
712
+ frame.f_trace = <object> main_debugger.trace_dispatch
713
+
714
+ if can_skip and func_code_info.breakpoint_found:
715
+ # if DEBUG:
716
+ # print('get_bytecode_while_frame_eval new_code', func_code_info.new_code)
717
+ if not thread_info.force_stay_in_untraced_mode:
718
+ # If breakpoints are found but new_code is None,
719
+ # this means we weren't able to actually add the code
720
+ # where needed, so, fallback to tracing.
721
+ if func_code_info.new_code is None:
722
+ if thread_info.thread_trace_func is not None:
723
+ frame.f_trace = thread_info.thread_trace_func
724
+ else:
725
+ frame.f_trace = <object> main_debugger.trace_dispatch
726
+ else:
727
+ # print('Using frame eval break for', <object> frame_obj.f_code.co_name)
728
+ update_globals_dict(<object> frame_obj.f_globals)
729
+ Py_INCREF(func_code_info.new_code)
730
+ old = <object> frame_obj.f_code
731
+ frame_obj.f_code = <PyCodeObject *> func_code_info.new_code
732
+ Py_DECREF(old)
733
+ else:
734
+ # When we're forcing to stay in traced mode we need to
735
+ # update the globals dict (because this means that we're reusing
736
+ # a previous code which had breakpoints added in a new frame).
737
+ update_globals_dict(<object> frame_obj.f_globals)
738
+
739
+ finally:
740
+ thread_info.inside_frame_eval -= 1
741
+ additional_info.is_tracing = False
742
+
743
+ return CALL_EvalFrameDefault_39(tstate, frame_obj, exc)
744
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
745
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
746
+ ### WARNING: GENERATED CODE, DO NOT EDIT!
747
+