Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable standard library debugging via config #863

Merged
merged 2 commits into from Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions ipykernel/debugger.py
Expand Up @@ -270,13 +270,14 @@ class Debugger:
'richInspectVariables', 'modules'
]

def __init__(self, log, debugpy_stream, event_callback, shell_socket, session):
blink1073 marked this conversation as resolved.
Show resolved Hide resolved
def __init__(self, log, debugpy_stream, event_callback, shell_socket, session, just_my_code):
self.log = log
self.debugpy_client = DebugpyClient(log, debugpy_stream, self._handle_event)
self.shell_socket = shell_socket
self.session = session
self.is_started = False
self.event_callback = event_callback
self.just_my_code = just_my_code
self.stopped_queue = Queue()

self.started_debug_handlers = {}
Expand Down Expand Up @@ -515,11 +516,12 @@ async def attach(self, message):
'port': port
}
message['arguments']['logToFile'] = True
# Reverts that option for now since it leads to spurious break of the code
# in ipykernel source and resuming the execution leads to several errors
# in the kernel.
# Experimental option to break in non-user code.
# The ipykernel source is in the call stack, so the user
# has to manipulate the step-over and step-into in a wize way.
# Set debugOptions for breakpoints in python standard library source.
# message['arguments']['debugOptions'] = [ 'DebugStdLib' ]
if not self.just_my_code:
message['arguments']['debugOptions'] = [ 'DebugStdLib' ]
return await self._forward_message(message)

async def configurationDone(self, message):
Expand Down
3 changes: 2 additions & 1 deletion ipykernel/ipkernel.py
Expand Up @@ -83,7 +83,8 @@ def __init__(self, **kwargs):
self.debugpy_stream,
self._publish_debug_event,
self.debug_shell_socket,
self.session)
self.session,
self.debug_just_my_code)

# Initialize the InteractiveShell subclass
self.shell = self.shell_class.instance(parent=self,
Expand Down
9 changes: 9 additions & 0 deletions ipykernel/kernelbase.py
Expand Up @@ -127,6 +127,15 @@ def _default_ident(self):
# any links that should go in the help menu
help_links = List()

# Experimental option to break in non-user code.
# The ipykernel source is in the call stack, so the user
# has to manipulate the step-over and step-into in a wize way.
debug_just_my_code = Bool(True,
help="""Set to False if you want to debug python standard and dependent libraries.
"""
).tag(config=True)

# track associations with current request
# Private interface

_darwin_app_nap = Bool(True,
Expand Down