Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Add json-dap command line and debug options #1461

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ptvsd/_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


PYDEVD_DEFAULTS = {
'--json-dap',
'--qt-support=auto',
}

Expand Down
5 changes: 5 additions & 0 deletions src/ptvsd/_vendored/force_pydevd.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ def ptvsd_breakpointhook():


pydevd.install_breakpointhook(ptvsd_breakpointhook)

# Ensure that pydevd uses JSON protocol
from _pydevd_bundle.pydevd_constants import JSON_PROTOCOL
from _pydevd_bundle.pydevd_defaults import PydevdCustomization
PydevdCustomization.DEFAULT_PROTOCOL = JSON_PROTOCOL
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def handle_argv(self, argv, i, setup):
ArgHandlerBool('print-in-debugger-startup'),
ArgHandlerBool('cmd-line'),
ArgHandlerBool('module'),
ArgHandlerBool('json-dap'), # Protocol used by ptvsd to communicate with pydevd
]

ARGV_REP_TO_HANDLER = {}
Expand Down
7 changes: 7 additions & 0 deletions src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'''
This module holds the customization settings for the debugger.
'''
from _pydevd_bundle.pydevd_constants import QUOTED_LINE_PROTOCOL

class PydevdCustomization(object):
DEFAULT_PROTOCOL = QUOTED_LINE_PROTOCOL
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def __init__(self):
def make_version_message(self, seq):
return NULL_NET_COMMAND # Not a part of the debug adapter protocol

@overrides(NetCommandFactory.make_protocol_set_message)
def make_protocol_set_message(self, seq):
return NULL_NET_COMMAND # Not a part of the debug adapter protocol

@overrides(NetCommandFactory.make_thread_created_message)
def make_thread_created_message(self, thread):

Expand Down
10 changes: 9 additions & 1 deletion src/ptvsd/_vendored/pydevd/pydevd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
from _pydevd_bundle.pydevd_constants import (IS_JYTH_LESS25, get_thread_id, get_current_thread_id,
dict_keys, dict_iter_items, DebugInfoHolder, PYTHON_SUSPEND, STATE_SUSPEND, STATE_RUN, get_frame,
clear_cached_thread_id, INTERACTIVE_MODE_AVAILABLE, SHOW_DEBUG_INFO_ENV, IS_PY34_OR_GREATER, IS_PY2, NULL,
NO_FTRACE, IS_IRONPYTHON)
NO_FTRACE, IS_IRONPYTHON, JSON_PROTOCOL)
from _pydevd_bundle.pydevd_defaults import PydevdCustomization
from _pydevd_bundle.pydevd_custom_frames import CustomFramesContainer, custom_frames_container_init
from _pydevd_bundle.pydevd_dont_trace_files import DONT_TRACE, PYDEV_FILE
from _pydevd_bundle.pydevd_extension_api import DebuggerEventHandler
from _pydevd_bundle.pydevd_frame_utils import add_exception_to_frame, remove_exception_from_frame
from _pydevd_bundle.pydevd_kill_all_pydevd_threads import kill_all_pydev_threads
from _pydevd_bundle.pydevd_net_command_factory_xml import NetCommandFactory
from _pydevd_bundle.pydevd_net_command_factory_json import NetCommandFactoryJson
from _pydevd_bundle.pydevd_trace_dispatch import (
trace_dispatch as _trace_dispatch, global_cache_skips, global_cache_frame_skips, fix_top_level_trace_and_get_trace_func)
from _pydevd_bundle.pydevd_utils import save_main_module, is_current_thread_main_thread
Expand Down Expand Up @@ -397,6 +399,9 @@ def __init__(self, set_as_global=True):

self.breakpoints = {}

# Set communication protocol
PyDevdAPI().set_protocol(self, 0, PydevdCustomization.DEFAULT_PROTOCOL)

# mtime to be raised when breakpoints change
self.mtime = 0

Expand Down Expand Up @@ -2437,6 +2442,9 @@ def main():
is_module = setup['module']
patch_stdin(debugger)

if setup['json-dap']:
PyDevdAPI().set_protocol(debugger, 0, JSON_PROTOCOL)

if fix_app_engine_debug:
sys.stderr.write("pydev debugger: google app engine integration enabled\n")
curr_dir = os.path.dirname(__file__)
Expand Down
1 change: 0 additions & 1 deletion src/ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,6 @@ def _handle_launch_or_attach(self, request, args):

self._client_os_type = client_os_type

self.pydevd_request(pydevd_comm.CMD_SET_PROTOCOL, 'json')
dont_trace_request = self._get_new_setDebuggerProperty_request(
dontTraceStartPatterns=[PTVSD_DIR_PATH],
dontTraceEndPatterns=['ptvsd_launcher.py'],
Expand Down