Skip to content

Commit 7993c99

Browse files
committed
Introduce filter_internal_frames option to control internal frame filtering
1 parent 6475f86 commit 7993c99

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

ipykernel/debugger.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class Debugger:
326326
]
327327

328328
def __init__(
329-
self, log, debugpy_stream, event_callback, shell_socket, session, kernel_modules, just_my_code=True
329+
self, log, debugpy_stream, event_callback, shell_socket, session, kernel_modules, just_my_code=False, filter_internal_frames=True
330330
):
331331
"""Initialize the debugger."""
332332
self.log = log
@@ -337,6 +337,7 @@ def __init__(
337337
self.event_callback = event_callback
338338
self.kernel_modules = kernel_modules
339339
self.just_my_code = just_my_code
340+
self.filter_internal_frames = filter_internal_frames
340341
self.stopped_queue: Queue[t.Any] = Queue()
341342

342343
self.started_debug_handlers = {}
@@ -577,8 +578,9 @@ async def attach(self, message):
577578
message["arguments"]["debugOptions"] = ["DebugStdLib"]
578579

579580
# Dynamic skip rules (computed at kernel startup)
580-
rules = [{"path": path, "include": False} for path in self.kernel_modules]
581-
message["arguments"]["rules"] = rules
581+
if self.filter_internal_frames:
582+
rules = [{"path": path, "include": False} for path in self.kernel_modules]
583+
message["arguments"]["rules"] = rules
582584

583585
return await self._forward_message(message)
584586

ipykernel/ipkernel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def __init__(self, **kwargs):
135135
self.session,
136136
self._kernel_modules,
137137
self.debug_just_my_code,
138+
self.filter_internal_frames,
138139
)
139140

140141
# Initialize the InteractiveShell subclass

ipykernel/kernelbase.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,18 @@ def _default_ident(self):
179179
# The ipykernel source is in the call stack, so the user
180180
# has to manipulate the step-over and step-into in a wize way.
181181
debug_just_my_code = Bool(
182-
True,
182+
False,
183183
help="""Set to False if you want to debug python standard and dependent libraries.
184184
""",
185185
).tag(config=True)
186186

187+
# Experimental option to filter internal frames from the stack trace and stepping.
188+
filter_internal_frames = Bool(
189+
True,
190+
help="""Set to False if you want to debug kernel modules.
191+
""",
192+
).tag(config=True)
193+
187194
# track associations with current request
188195
# Private interface
189196

0 commit comments

Comments
 (0)