Repository: microsoft/ptvsd

Issue:
Breakpoints not hitting when used in conjunction with exceptions
* Here's the program
```python
1. for i in range(10):
2.     print("one")
3.     try:
4.         raise AttributeError()
5.     except:
6.         pass
```
* Add a breakpoint to line 2 and line 4
* Start debugging
* First loop, both break points are hit
* Second loop, only the fist breakpoint is hit

![breakpoint_not_working](https://user-images.githubusercontent.com/1948812/38763875-9f848196-3f59-11e8-981f-ec9f7d2f100e.gif)



Discussion:
Setting a milestone of VSC Stable, as this could be an edge case and might not be crucial for VSC Preview (@brettcannon @int19h please feel free to change).
However this should be fixed for VSC Stable, as this could be a symptom of a more serious issue (won't know until we check this out).
This is the fix that is needed : https://github.com/fabioz/Pydev/commit/f29d29f257a382e1da3af107865fcda1eb656662

Resolving patch:
diff --git a/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py b/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py
--- a/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py
+++ b/ptvsd/_vendored/pydevd/_pydevd_bundle/pydevd_frame.py
@@ -621,7 +621,7 @@ def trace_dispatch(self, frame, event, arg):
                     self.do_wait_suspend(thread, frame, event, arg)
                     return self.trace_dispatch
                 else:
-                    if not breakpoint and not is_return:
+                    if not breakpoint and is_line:
                         # No stop from anyone and no breakpoint found in line (cache that).
                         frame_skips_cache[line_cache_key] = 0
 


Test patch:
diff --git a/ptvsd/_vendored/pydevd/tests_python/_debugger_case_skip_breakpoint_in_exceptions.py b/ptvsd/_vendored/pydevd/tests_python/_debugger_case_skip_breakpoint_in_exceptions.py
new file mode 100644
--- /dev/null
+++ b/ptvsd/_vendored/pydevd/tests_python/_debugger_case_skip_breakpoint_in_exceptions.py
@@ -0,0 +1,8 @@
+if __name__ == '__main__':
+    for i in range(2):
+        print("one")
+        try:
+            raise AttributeError() # Breakpoint here
+        except:
+            pass
+    print('TEST SUCEEDED!')
\ No newline at end of file
diff --git a/ptvsd/_vendored/pydevd/tests_python/test_debugger.py b/ptvsd/_vendored/pydevd/tests_python/test_debugger.py
--- a/ptvsd/_vendored/pydevd/tests_python/test_debugger.py
+++ b/ptvsd/_vendored/pydevd/tests_python/test_debugger.py
@@ -1269,6 +1269,29 @@ def get_environ(self):
         env["VERIFY_EVENT_TEST"] = "1"
         return env
 
+#=======================================================================================================================
+# WriterThreadCaseSkipBreakpointInExceptions - fix case where breakpoint is skipped after an exception is raised over it 
+#======================================================================================================================
+class WriterThreadCaseSkipBreakpointInExceptions(debugger_unittest.AbstractWriterThread):
+
+    TEST_FILE = debugger_unittest._get_debugger_test_file('_debugger_case_skip_breakpoint_in_exceptions.py')
+
+    def run(self):
+        self.start_socket()
+        self.write_add_breakpoint(5, None)
+        self.write_make_initial_run()
+
+        thread_id, frame_id, line = self.wait_for_breakpoint_hit('111', True)
+        assert line == 5, 'Expected return to be in line 5, was: %s' % line
+        self.write_run_thread(thread_id)
+
+        thread_id, frame_id, line = self.wait_for_breakpoint_hit('111', True)
+        assert line == 5, 'Expected return to be in line 5, was: %s' % line
+        self.write_run_thread(thread_id)
+
+
+        self.finished_ok = True
+
 #=======================================================================================================================
 # Test
 #=======================================================================================================================
@@ -1444,6 +1467,9 @@ def test_case_type_ext(self):
     def test_case_event_ext(self):
         self.check_case(WriterThreadCaseEventExt)
 
+    def test_case_skip_breakpoints_in_exceptions(self):
+        self.check_case(WriterThreadCaseSkipBreakpointInExceptions)
+
 @pytest.mark.skipif(not IS_CPYTHON, reason='CPython only test.')
 class TestPythonRemoteDebugger(unittest.TestCase, debugger_unittest.DebuggerRunner):