diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_frame.py b/python/helpers/pydev/_pydevd_bundle/pydevd_frame.py index 154cbce32fab..b449dee9c89d 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_frame.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_frame.py @@ -453,11 +453,15 @@ class PyDBFrame: # No longer cdef because object was dying when only a reference stop = False main_debugger.first_breakpoint_reached = True else: - pass # if the frame is traced after breakpoint stop, # but the file should be ignored while stepping because of filters - if step_cmd != -1 and main_debugger.is_filter_enabled and main_debugger.is_ignored_by_filters(filename): - return self.trace_dispatch + if step_cmd != -1: + if main_debugger.is_filter_enabled and main_debugger.is_ignored_by_filters(filename): + # ignore files matching stepping filters + return self.trace_dispatch + if main_debugger.is_filter_libraries and main_debugger.not_in_scope(filename): + # ignore library files while stepping + return self.trace_dispatch if stop: self.set_suspend(thread, CMD_SET_BREAK) elif flag and plugin_manager is not None: diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch_regular.py b/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch_regular.py index aeadccf514e2..ec5f12d19c30 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch_regular.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch_regular.py @@ -118,10 +118,13 @@ class ThreadTracer: # print('skipped: trace_dispatch', base, frame.f_lineno, event, frame.f_code.co_name, file_type) return None - # ignore files matching stepping filters - if additional_info.pydev_step_cmd != -1 and py_db.is_filter_enabled and \ - py_db.is_ignored_by_filters(abs_path_real_path_and_base[1]): - return None + if additional_info.pydev_step_cmd != -1: + if py_db.is_filter_enabled and py_db.is_ignored_by_filters(abs_path_real_path_and_base[1]): + # ignore files matching stepping filters + return None + if py_db.is_filter_libraries and py_db.not_in_scope(abs_path_real_path_and_base[1]): + # ignore library files while stepping + return None # print('trace_dispatch', base, frame.f_lineno, event, frame.f_code.co_name, file_type) if additional_info.is_tracing: diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_utils.py b/python/helpers/pydev/_pydevd_bundle/pydevd_utils.py index 5bd86964720a..4fe32e1cb496 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_utils.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_utils.py @@ -154,6 +154,10 @@ def is_filter_enabled(): return os.getenv('PYDEVD_FILTERS') is not None +def is_filter_libraries(): + return os.getenv('PYDEVD_FILTER_LIBRARIES') is not None + + def _get_stepping_filters(filters_cache=[]): if not filters_cache: filters = os.getenv('PYDEVD_FILTERS', '').split(';') diff --git a/python/helpers/pydev/pydevd.py b/python/helpers/pydev/pydevd.py index 3baeb59fa417..baeadb3601e5 100644 --- a/python/helpers/pydev/pydevd.py +++ b/python/helpers/pydev/pydevd.py @@ -248,6 +248,7 @@ class PyDB: self._filename_to_not_in_scope = {} self.first_breakpoint_reached = False self.is_filter_enabled = pydevd_utils.is_filter_enabled() + self.is_filter_libraries = pydevd_utils.is_filter_libraries() def get_plugin_lazy_init(self): if self.plugin is None and SUPPORT_PLUGINS: diff --git a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java index 8d8391ba417a..fb2270d17bd2 100644 --- a/python/src/com/jetbrains/python/debugger/PyDebugRunner.java +++ b/python/src/com/jetbrains/python/debugger/PyDebugRunner.java @@ -72,6 +72,7 @@ public class PyDebugRunner extends GenericProgramRunner { @SuppressWarnings("SpellCheckingInspection") public static final String GEVENT_SUPPORT = "GEVENT_SUPPORT"; public static final String PYDEVD_FILTERS = "PYDEVD_FILTERS"; + public static final String PYDEVD_FILTER_LIBRARIES = "PYDEVD_FILTER_LIBRARIES"; public static boolean isModule = false; @Override @@ -295,6 +296,9 @@ public class PyDebugRunner extends GenericProgramRunner { if (debuggerSettings.isSteppingFiltersEnabled()) { cmd.getEnvironment().put(PYDEVD_FILTERS, debuggerSettings.getSteppingFiltersForProject(project)); } + if (debuggerSettings.isLibrariesFilterEnabled()) { + cmd.getEnvironment().put(PYDEVD_FILTER_LIBRARIES, "True"); + } addProjectRootsToEnv(project, cmd); diff --git a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java index 958242057457..7e338c47b436 100644 --- a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java +++ b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSettings.java @@ -34,6 +34,7 @@ import static java.util.Collections.singletonList; public class PyDebuggerSettings extends XDebuggerSettings implements Getter { + private boolean myLibrariesFilterEnabled; private boolean mySteppingFiltersEnabled; private @NotNull List mySteppingFilters; public static final String FILTERS_DIVIDER = ";"; @@ -47,6 +48,14 @@ public class PyDebuggerSettings extends XDebuggerSettings im return getInstance(PyDebuggerSettings.class); } + public boolean isLibrariesFilterEnabled() { + return myLibrariesFilterEnabled; + } + + public void setLibrariesFilterEnabled(boolean librariesFilterEnabled) { + myLibrariesFilterEnabled = librariesFilterEnabled; + } + public boolean isSteppingFiltersEnabled() { return mySteppingFiltersEnabled; } diff --git a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.form b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.form index 5081987dd934..e08a878f48cd 100644 --- a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.form +++ b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.form @@ -1,6 +1,6 @@
- + @@ -10,26 +10,36 @@ - + + - + - + + + + + + + + + + diff --git a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java index 941dd96749a2..0b3b2dad9069 100644 --- a/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java +++ b/python/src/com/jetbrains/python/debugger/settings/PyDebuggerSteppingConfigurableUi.java @@ -35,9 +35,10 @@ public class PyDebuggerSteppingConfigurableUi implements ConfigurableUi myPySteppingFilterEditor; public PyDebuggerSteppingConfigurableUi() { @@ -58,6 +59,7 @@ public class PyDebuggerSteppingConfigurableUi implements ConfigurableUi