Repository: microsoft/ptvsd

Issue:
Debugging in VS Code breaks with 'Unable to open <frozen importlib._bootstrap>' error
When debugging using the latest version of PTVSD I'm getting the following error:

`Unable to open '<frozen importlib._bootstrap>': File not found (file:///Users/donjayamanne/Desktop/Development/PythonStuff/IssueRepos/debuggerTests/`

Tested with yesterdays with a snapshot of yesterdays repo (around lunchtime) and it works.


Commenting out the following [line of code](https://github.com/Microsoft/ptvsd/blob/master/ptvsd/wrapper.py#L276) fixes the issue :
```python
            self.proc.pydevd_notify(
                pydevd_comm.CMD_ADD_EXCEPTION_BREAK, msg)
```

Possibly specific to Macs only, as this is required for VS.


Discussion:
Previous version probably worked because it was not setting exception breakpoints at all.
@karthiknadig 
I've tested the same changes in VS and I believe it doesn't work.
Here's what I've found
* Default behavior is for all exceptions raised to be handled and debugger to break into them
https://github.com/Microsoft/ptvsd/blob/master/ptvsd/wrapper.py#L481
```json
{
                    'filter': 'raised',
                    'label': 'Raised Exceptions',
                    'default': 'true'
                },
```
* VS Code uses the above setting 
* If i turn off the above setting, the the issue reported here goes away. So the problem is with `Raised Exceptions`
* Now, i checked VS, and it doesn't seem to be using the above at all
* Upon intercepting the breakpoint settings passed by VS, i can see that value for `notify_always` is `always 0`
I.e. the following line of code
`notify_always = 3 if break_raised else 0` always evaluates to `0`.
* I then modified the code (PTVSD), to force `notify_always = 3`

* Now VS code fails to launch the debugger, it just hangs at the terminal. I believe the problem is an exception has been raised and its not able to handle it. 

I.e. this same/similar behavior exists in VS, if the above flag is set.
I believe no one has encountered this because VS is ignoring this default value.

**We're planning on removing this setting completely from release 1 of VS Code debugger as it completely breaks it.**
VS does not use Filters. VS uses Exception options to work with exceptions. There is a separate window by the name Exception Settings where we can set these options. Actually setting them to default `false` should be ok.

Actually removing the defaults should be fine as well.
```
exceptionBreakpointFilters=[
                {
                    'filter': 'raised',
                    'label': 'Raised Exceptions'
                },
                {
                    'filter': 'uncaught',
                    'label': 'Uncaught Exceptions'
                },
```
> Actually removing the defaults should be fine as well.

Yes, as a temporary solution. 

> VS does not use Filters. VS uses Exception options to work with exceptions.

Either way, shouldn't VS respect the defaults provided by PTVSD?
Anyways, I'm not too concerned about VS. Just curious. Cuz I don't see the point in making them default to `true` if they aren't used.

At the end of the day, if VS uses the exception options, I believe this problem we're experiencing in VS code should also appear in VS. Do you agree?

> Either way, shouldn't VS respect the defaults provided by PTVSD?

I had set them to `true` as a way to allow catching and reporting exceptions VS before exception options feature in ptvsd was enabled. There isno UI in VS to work with filters. So setting the default was a way to force exception in VS. The defaults were only needed until exception options feature was enabled in ptvsd. Their impact on VSC was unknown at this point.

> At the end of the day, if VS uses the exception options, I believe this problem we're experiencing in VS code should also appear in VS. Do you agree?

No, I have not seen this repro with exceptions settings. We can try this on the VM tomorrow.
I think the problem might be that pydev is trying to hook every exception and it is causing the issue:
```self.exceptions_mgr.add_exception_break('BaseException', break_raised, break_uncaught)```
Since we use `ignore_library=0`, it is trying to hook exception in imported library modules. We should try setting that to 1 for VSC. VS, probably, does not run into this problem, because exception settings are for set for specific exceptions (say `ValueError`, `KeyError`) individually, unlike VSC where it is blanket set using `BaseException`.
> VS, probably, does not run into this problem, because exception settings are for set for specific exceptions (say ValueError, KeyError

VSC to supports this, however it's done through the config. Should look into that.

Resolving patch:
diff --git a/ptvsd/wrapper.py b/ptvsd/wrapper.py
--- a/ptvsd/wrapper.py
+++ b/ptvsd/wrapper.py
@@ -480,7 +480,7 @@ def on_initialize(self, request, args):
                 {
                     'filter': 'raised',
                     'label': 'Raised Exceptions',
-                    'default': 'true'
+                    'default': 'false'
                 },
                 {
                     'filter': 'uncaught',


Test patch: