Repository: microsoft/ptvsd

Issue:
DAP: pathMappings should be passed to pydevd in launch request and not through pydevd_file_utils.setup_client_server_paths



Discussion:

Resolving patch:
diff --git a/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py b/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py
--- a/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py
+++ b/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py
@@ -239,6 +239,13 @@ def on_completions_request(self, py_db, request):
 
         self.api.request_completions(py_db, seq, thread_id, frame_id, text, line=line, column=column)
 
+    def _resolve_remote_root(self, local_root, remote_root):
+        if remote_root == '.':
+            cwd = os.getcwd()
+            append_pathsep = local_root.endswith('\\') or local_root.endswith('/')
+            return cwd + (os.path.sep if append_pathsep else '')
+        return remote_root
+
     def _set_debug_options(self, py_db, args):
         rules = args.get('rules')
         exclude_filters = []
@@ -258,6 +265,17 @@ def _set_debug_options(self, py_db, args):
         debug_stdlib = self._debug_options.get('DEBUG_STDLIB', False)
         self.api.set_use_libraries_filter(py_db, not debug_stdlib)
 
+        path_mappings = []
+        for pathMapping in args.get('pathMappings', []):
+            localRoot = pathMapping.get('localRoot', '')
+            remoteRoot = pathMapping.get('remoteRoot', '')
+            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
+            if (localRoot != '') and (remoteRoot != ''):
+                path_mappings.append((localRoot, remoteRoot))
+
+        if bool(path_mappings):
+            pydevd_file_utils.setup_client_server_paths(path_mappings)
+
     def on_launch_request(self, py_db, request):
         '''
         :param LaunchRequest request:
diff --git a/src/ptvsd/wrapper.py b/src/ptvsd/wrapper.py
--- a/src/ptvsd/wrapper.py
+++ b/src/ptvsd/wrapper.py
@@ -10,7 +10,6 @@
 import os
 import re
 import platform
-import pydevd_file_utils
 import socket
 import sys
 import threading
@@ -1055,7 +1054,6 @@ def __init__(
         self.is_process_created = False
         self.is_process_created_lock = threading.Lock()
         self.thread_map = IDMap()
-        self._path_mappings = []
         self._success_exitcodes = []
         self.internals_filter = InternalsFilter()
         self.new_thread_lock = threading.Lock()
@@ -1245,27 +1243,6 @@ def _is_just_my_code_stepping_enabled(self):
         dbg_stdlib = self.debug_options.get('DEBUG_STDLIB', False)
         return not dbg_stdlib
 
-    def _resolve_remote_root(self, local_root, remote_root):
-        if remote_root == '.':
-            cwd = os.getcwd()
-            append_pathsep = local_root.endswith('\\') or local_root.endswith('/')
-            return cwd + (os.path.sep if append_pathsep else '')
-        return remote_root
-
-    def _initialize_path_maps(self, args):
-        self._path_mappings = []
-        for pathMapping in args.get('pathMappings', []):
-            localRoot = pathMapping.get('localRoot', '')
-            remoteRoot = pathMapping.get('remoteRoot', '')
-            remoteRoot = self._resolve_remote_root(localRoot, remoteRoot)
-            if (len(localRoot) > 0 and len(remoteRoot) > 0):
-                self._path_mappings.append((localRoot, remoteRoot))
-
-        if len(self._path_mappings) > 0:
-            pydevd_file_utils.setup_client_server_paths(self._path_mappings)
-
-        self._path_mappings_applied = True
-
     def _send_cmd_version_command(self):
         cmd = pydevd_comm.CMD_VERSION
 
@@ -1313,7 +1290,7 @@ def _handle_launch_or_attach(self, request, args):
         del pydevd_request['seq']  # A new seq should be created for pydevd.
         yield self.pydevd_request(-1, pydevd_request, is_json=True)
 
-        self._initialize_path_maps(args)
+        self._path_mappings_applied = True
 
         default_success_exitcodes = [0]
         if self.debug_options.get('DJANGO_DEBUG', False):


Test patch: