Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Nov 26, 2023
1 parent f0dd408 commit 435bbe3
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions pydevd.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def __init__(self, set_as_global=True):
# Note: when the source mapping is changed we also have to clear the file types cache
# (because if a given file is a part of the project or not may depend on it being
# defined in the source mapping).
self.source_mapping = SourceMapping(on_source_mapping_changed=self._clear_filters_caches)
self.source_mapping = SourceMapping(on_source_mapping_changed=self._clear_caches)

# Determines whether we should terminate child processes when asked to terminate.
self.terminate_child_processes = True
Expand Down Expand Up @@ -1136,6 +1136,11 @@ def on_breakpoints_changed(self, removed=False):
if not removed:
# When removing breakpoints we can leave tracing as was, but if a breakpoint was added
# we have to reset the tracing for the existing functions to be re-evaluated.

# The caches also need to be cleared because of django breakpoints use case,
# where adding a file needs to start tracking a context which was previously
# untracked.
self._clear_caches()
self.set_tracing_for_untraced_contexts(breakpoints_changed=True)

def set_tracing_for_untraced_contexts(self, breakpoints_changed=False):
Expand Down Expand Up @@ -1255,7 +1260,12 @@ def in_project_scope(self, frame, absolute_filename=None):
def in_project_roots_filename_uncached(self, absolute_filename):
return self._files_filtering.in_project_roots(absolute_filename)

def _clear_filters_caches(self):
def _clear_caches(self):
# Skip caches
global_cache_skips.clear()
global_cache_frame_skips.clear()

# Filter caches
self._in_project_scope_cache.clear()
self._exclude_by_filter_cache.clear()
self._apply_filter_cache.clear()
Expand All @@ -1274,8 +1284,7 @@ def clear_dont_trace_start_end_patterns_caches(self):
# as places which were traced may no longer need to be traced and vice-versa.
self.on_breakpoints_changed()
_CACHE_FILE_TYPE.clear()
self._clear_skip_caches()
self._clear_filters_caches()
self._clear_caches()

def _exclude_by_filter(self, frame, absolute_filename):
'''
Expand Down Expand Up @@ -1391,18 +1400,15 @@ def exclude_exception_by_filter(self, exception_breakpoint, trace):

def set_project_roots(self, project_roots):
self._files_filtering.set_project_roots(project_roots)
self._clear_skip_caches()
self._clear_filters_caches()
self._clear_caches()

def set_exclude_filters(self, exclude_filters):
self._files_filtering.set_exclude_filters(exclude_filters)
self._clear_skip_caches()
self._clear_filters_caches()
self._clear_caches()

def set_use_libraries_filter(self, use_libraries_filter):
self._files_filtering.set_use_libraries_filter(use_libraries_filter)
self._clear_skip_caches()
self._clear_filters_caches()
self._clear_caches()

def get_use_libraries_filter(self):
return self._files_filtering.use_libraries_filter()
Expand Down Expand Up @@ -1822,11 +1828,7 @@ def consolidate_breakpoints(self, canonical_normalized_filename, id_to_breakpoin
break_dict[pybreakpoint.line] = pybreakpoint

file_to_line_to_breakpoints[canonical_normalized_filename] = break_dict
self._clear_skip_caches()

def _clear_skip_caches(self):
global_cache_skips.clear()
global_cache_frame_skips.clear()
self._clear_caches()

def add_break_on_exception(
self,
Expand Down

0 comments on commit 435bbe3

Please sign in to comment.