Repository: microsoft/ptvsd

Issue:
StackTrace request does not does not respect just-my-code
## Environment data

- PTVSD version: master
- OS and version: Windows
- Python version (& distribution if applicable, e.g. Anaconda): any
- Using VS Code or Visual Studio: vsc

## Actual behavior

With `"debugStdLib": true`, non-user code should be filtered out.
![image](https://user-images.githubusercontent.com/3840081/53530706-8eb8c780-3aa5-11e9-85d8-5e47e69e33d2.png)

## Expected  behavior

Frames in the screenshot above from `runpy.py` and `ptvsds_launcher.py` should not be seen.




Discussion:
With ptvsd 4.2.4:
![image](https://user-images.githubusercontent.com/3840081/53541696-e4a26500-3acf-11e9-987c-0345383e2605.png)

With latest master:
![image](https://user-images.githubusercontent.com/3840081/53541726-069be780-3ad0-11e9-8e3c-5e71b66826dc.png)

After this is fixed enable test:
`./tests/func/test_justmycode.py::test_justmycode_frames`

Resolving patch:
diff --git a/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py b/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py
--- a/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py
+++ b/src/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py
@@ -184,13 +184,19 @@ def make_get_thread_stack_message(self, py_db, seq, thread_id, topmost_frame, fm
 
                     module_events.extend(self.modules_manager.track_module(filename_in_utf8, module_name, frame))
 
-                    # TODO: presentationHint should be subtle if it's a filtered method.
+                    presentation_hint = None
+                    if not py_db.in_project_scope(filename_in_utf8):
+                        if py_db.get_use_libraries_filter():
+                            continue
+                        presentation_hint = 'subtle'
+
                     formatted_name = self._format_frame_name(fmt, method_name, module_name, lineno, filename_in_utf8)
                     frames.append(pydevd_schema.StackFrame(
                         frame_id, formatted_name, lineno, column=1, source={
                             'path': filename_in_utf8,
                             'sourceReference': pydevd_file_utils.get_client_filename_source_reference(filename_in_utf8),
-                        }).to_dict())
+                        },
+                        presentationHint=presentation_hint).to_dict())
             finally:
                 topmost_frame = None
 
diff --git a/src/ptvsd/_vendored/pydevd/pydevd.py b/src/ptvsd/_vendored/pydevd/pydevd.py
--- a/src/ptvsd/_vendored/pydevd/pydevd.py
+++ b/src/ptvsd/_vendored/pydevd/pydevd.py
@@ -763,6 +763,9 @@ def set_use_libraries_filter(self, use_libraries_filter):
         self._clear_skip_caches()
         self._clear_filters_caches()
 
+    def get_use_libraries_filter(self):
+        return self._files_filtering.use_libraries_filter()
+
     def has_threads_alive(self):
         for t in pydevd_utils.get_non_pydevd_threads():
             if isinstance(t, PyDBDaemonThread):
diff --git a/src/ptvsd/wrapper.py b/src/ptvsd/wrapper.py
--- a/src/ptvsd/wrapper.py
+++ b/src/ptvsd/wrapper.py
@@ -95,7 +95,7 @@ def dont_trace_ptvsd_files(file_path):
     """
     Returns true if the file should not be traced.
     """
-    return file_path.startswith(PTVSD_DIR_PATH)
+    return file_path.startswith(PTVSD_DIR_PATH) or file_path.endswith('ptvsd_launcher.py')
 
 
 original_get_file_type = pydevd.PyDB.get_file_type


Test patch:
diff --git a/tests/func/test_django.py b/tests/func/test_django.py
--- a/tests/func/test_django.py
+++ b/tests/func/test_django.py
@@ -60,7 +60,7 @@ def test_django_breakpoint_no_multiproc(bp_target, start_method):
         resp_stacktrace = session.send_request('stackTrace', arguments={
             'threadId': tid,
         }).wait_for_response()
-        assert resp_stacktrace.body['totalFrames'] > 1
+        assert resp_stacktrace.body['totalFrames'] >= 1
         frames = resp_stacktrace.body['stackFrames']
         assert frames[0] == {
             'id': ANY.int,
diff --git a/tests/func/test_justmycode.py b/tests/func/test_justmycode.py
--- a/tests/func/test_justmycode.py
+++ b/tests/func/test_justmycode.py
@@ -12,7 +12,6 @@
 from tests.helpers.pattern import ANY, Path
 
 @pytest.mark.parametrize('jmc', ['jmcOn', 'jmcOff'])
-@pytest.mark.skip(reason='https://github.com/Microsoft/ptvsd/issues/1187')
 def test_justmycode_frames(pyfile, run_as, start_method, jmc):
     @pyfile
     def code_to_debug():
diff --git a/tests/helpers/pathutils.py b/tests/helpers/pathutils.py
--- a/tests/helpers/pathutils.py
+++ b/tests/helpers/pathutils.py
@@ -22,7 +22,7 @@ def compare_path(left, right, show=True):
         if not isinstance(right, ptvsd.compat.unicode):
             right = right.decode(sys.getfilesystemencoding())
     elif isinstance(right, ptvsd.compat.unicode):
-        left = right.decode(sys.getfilesystemencoding())
+        right = right.decode(sys.getfilesystemencoding())
 
     n_left = os.path.normcase(left)
     n_right = os.path.normcase(right)