prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Stop on entry hangs the debugger
  ## Environment data
  
  - PTVSD version: master
  - OS and version: windows
  - Python version (& distribution if applicable, e.g. Anaconda): 3.6
  - Using VS Code or Visual Studio: VS or VSC
  
  ## Actual behavior
  
  Note that you have to change the default for STOP_ON_ENTRY in wrapper.py#1198 to True.
  Repros almost always on VS, but infrequently on VSC.
  
  ## Expected  behavior
  
  Should run and break on entry
  
  ## Steps to reproduce:
  For VS:
  1. Change wrapper.py:1198 default for STOP_ON_ENTRY  to True.
  2. Use F5 to start the debugger.
  
  For VSC:
  1. Set `stopOnEntry` in launch json.
  
  
  
  </issue>
  <code>
  [start of src/ptvsd/debugger.py]
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License. See LICENSE in the project root
  3 # for license information.
  4 
  5 import sys
  6 
  7 import ptvsd.log
  8 from ptvsd._local import run_module, run_file, run_main
  9 
  10 
  11 # TODO: not needed?
  12 DONT_DEBUG = []
  13 
  14 LOCALHOST = 'localhost'
  15 
  16 RUNNERS = {
  17     'module': run_module,  # python -m spam
  18     'script': run_file,  # python spam.py
  19     'code': run_file,  # python -c 'print("spam")'
  20     None: run_file,  # catchall
  21 }
  22 
  23 
  24 def debug(filename, port_num, debug_id, debug_options, run_as,
  25           _runners=RUNNERS, _extra=None, *args, **kwargs):
  26 
  27     ptvsd.log.to_file()
  28     ptvsd.log.info('debug{0!r}', (filename, port_num, debug_id, debug_options, run_as))
  29 
  30     if _extra is None:
  31         _extra = sys.argv[1:]
  32     address = (LOCALHOST, port_num)
  33     try:
  34         run = _runners[run_as]
  35     except KeyError:
  36         # TODO: fail?
  37         run = _runners[None]
  38     if _extra:
  39         args = _extra + list(args)
  40     kwargs.setdefault('singlesession', True)
  41     run(address, filename, *args, **kwargs)
  42 
  43 
  44 def run(filename, port_num, run_as,
  45         *args, **kwargs):
  46 
  47     ptvsd.log.to_file()
  48     ptvsd.log.info('run{0!r}', (filename, port_num, run_as))
  49 
  50     address = (LOCALHOST, port_num)
  51     run_main(address, filename, run_as, *args, **kwargs)
  52
  [end of src/ptvsd/debugger.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/src/ptvsd/debugger.py b/src/ptvsd/debugger.py
  --- a/src/ptvsd/debugger.py
  +++ b/src/ptvsd/debugger.py
  @@ -2,50 +2,38 @@
   # Licensed under the MIT License. See LICENSE in the project root
   # for license information.
   
  -import sys
  -
   import ptvsd.log
  -from ptvsd._local import run_module, run_file, run_main
  -
  -
  -# TODO: not needed?
  -DONT_DEBUG = []
  +import ptvsd.options
  +from ptvsd.__main__ import run_file, run_module, run_code
   
  -LOCALHOST = 'localhost'
   
   RUNNERS = {
  -    'module': run_module,  # python -m spam
  -    'script': run_file,  # python spam.py
  -    'code': run_file,  # python -c 'print("spam")'
  -    None: run_file,  # catchall
  +    'module': run_module,
  +    'script': run_file,
  +    'code': run_code,
   }
   
  +# Not actually used, but VS will try to add entries to it.
  +DONT_DEBUG = []
   
  -def debug(filename, port_num, debug_id, debug_options, run_as,
  -          _runners=RUNNERS, _extra=None, *args, **kwargs):
   
  +# A legacy entrypoint for Visual Studio, to allow older versions to work with new ptvsd.
  +# All new code should use the entrypoints in __main__ directly.
  +def debug(filename, port_num, debug_id, debug_options, run_as):
       ptvsd.log.to_file()
       ptvsd.log.info('debug{0!r}', (filename, port_num, debug_id, debug_options, run_as))
   
  -    if _extra is None:
  -        _extra = sys.argv[1:]
  -    address = (LOCALHOST, port_num)
       try:
  -        run = _runners[run_as]
  +        run = RUNNERS[run_as]
       except KeyError:
  -        # TODO: fail?
  -        run = _runners[None]
  -    if _extra:
  -        args = _extra + list(args)
  -    kwargs.setdefault('singlesession', True)
  -    run(address, filename, *args, **kwargs)
  -
  +        raise ValueError('run_as must be one of: {0!r}'.format(tuple(RUNNERS.keys())))
   
  -def run(filename, port_num, run_as,
  -        *args, **kwargs):
  +    ptvsd.options.target_kind = 'file' if run_as == 'script' else run_as
  +    ptvsd.options.target = filename
  +    ptvsd.options.port = port_num
  +    ptvsd.options.client = True
   
  -    ptvsd.log.to_file()
  -    ptvsd.log.info('run{0!r}', (filename, port_num, run_as))
  +    # debug_id is ignored because it has no meaning in DAP.
  +    # debug_options are ignored, because they will be passed later via DAP "launch" request.
   
  -    address = (LOCALHOST, port_num)
  -    run_main(address, filename, run_as, *args, **kwargs)
  +    run()
  
verification_info: {"golden_diff": "diff --git a/src/ptvsd/debugger.py b/src/ptvsd/debugger.py\n--- a/src/ptvsd/debugger.py\n+++ b/src/ptvsd/debugger.py\n@@ -2,50 +2,38 @@\n # Licensed under the MIT License. See LICENSE in the project root\n # for license information.\n \n-import sys\n-\n import ptvsd.log\n-from ptvsd._local import run_module, run_file, run_main\n-\n-\n-# TODO: not needed?\n-DONT_DEBUG = []\n+import ptvsd.options\n+from ptvsd.__main__ import run_file, run_module, run_code\n \n-LOCALHOST = 'localhost'\n \n RUNNERS = {\n-    'module': run_module,  # python -m spam\n-    'script': run_file,  # python spam.py\n-    'code': run_file,  # python -c 'print(\"spam\")'\n-    None: run_file,  # catchall\n+    'module': run_module,\n+    'script': run_file,\n+    'code': run_code,\n }\n \n+# Not actually used, but VS will try to add entries to it.\n+DONT_DEBUG = []\n \n-def debug(filename, port_num, debug_id, debug_options, run_as,\n-          _runners=RUNNERS, _extra=None, *args, **kwargs):\n \n+# A legacy entrypoint for Visual Studio, to allow older versions to work with new ptvsd.\n+# All new code should use the entrypoints in __main__ directly.\n+def debug(filename, port_num, debug_id, debug_options, run_as):\n     ptvsd.log.to_file()\n     ptvsd.log.info('debug{0!r}', (filename, port_num, debug_id, debug_options, run_as))\n \n-    if _extra is None:\n-        _extra = sys.argv[1:]\n-    address = (LOCALHOST, port_num)\n     try:\n-        run = _runners[run_as]\n+        run = RUNNERS[run_as]\n     except KeyError:\n-        # TODO: fail?\n-        run = _runners[None]\n-    if _extra:\n-        args = _extra + list(args)\n-    kwargs.setdefault('singlesession', True)\n-    run(address, filename, *args, **kwargs)\n-\n+        raise ValueError('run_as must be one of: {0!r}'.format(tuple(RUNNERS.keys())))\n \n-def run(filename, port_num, run_as,\n-        *args, **kwargs):\n+    ptvsd.options.target_kind = 'file' if run_as == 'script' else run_as\n+    ptvsd.options.target = filename\n+    ptvsd.options.port = port_num\n+    ptvsd.options.client = True\n \n-    ptvsd.log.to_file()\n-    ptvsd.log.info('run{0!r}', (filename, port_num, run_as))\n+    # debug_id is ignored because it has no meaning in DAP.\n+    # debug_options are ignored, because they will be passed later via DAP \"launch\" request.\n \n-    address = (LOCALHOST, port_num)\n-    run_main(address, filename, run_as, *args, **kwargs)\n+    run()\n", "issue": "Stop on entry hangs the debugger\n## Environment data\r\n\r\n- PTVSD version: master\r\n- OS and version: windows\r\n- Python version (& distribution if applicable, e.g. Anaconda): 3.6\r\n- Using VS Code or Visual Studio: VS or VSC\r\n\r\n## Actual behavior\r\n\r\nNote that you have to change the default for STOP_ON_ENTRY in wrapper.py#1198 to True.\r\nRepros almost always on VS, but infrequently on VSC.\r\n\r\n## Expected  behavior\r\n\r\nShould run and break on entry\r\n\r\n## Steps to reproduce:\r\nFor VS:\r\n1. Change wrapper.py:1198 default for STOP_ON_ENTRY  to True.\r\n2. Use F5 to start the debugger.\r\n\r\nFor VSC:\r\n1. Set `stopOnEntry` in launch json.\r\n\r\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License. See LICENSE in the project root\n# for license information.\n\nimport sys\n\nimport ptvsd.log\nfrom ptvsd._local import run_module, run_file, run_main\n\n\n# TODO: not needed?\nDONT_DEBUG = []\n\nLOCALHOST = 'localhost'\n\nRUNNERS = {\n    'module': run_module,  # python -m spam\n    'script': run_file,  # python spam.py\n    'code': run_file,  # python -c 'print(\"spam\")'\n    None: run_file,  # catchall\n}\n\n\ndef debug(filename, port_num, debug_id, debug_options, run_as,\n          _runners=RUNNERS, _extra=None, *args, **kwargs):\n\n    ptvsd.log.to_file()\n    ptvsd.log.info('debug{0!r}', (filename, port_num, debug_id, debug_options, run_as))\n\n    if _extra is None:\n        _extra = sys.argv[1:]\n    address = (LOCALHOST, port_num)\n    try:\n        run = _runners[run_as]\n    except KeyError:\n        # TODO: fail?\n        run = _runners[None]\n    if _extra:\n        args = _extra + list(args)\n    kwargs.setdefault('singlesession', True)\n    run(address, filename, *args, **kwargs)\n\n\ndef run(filename, port_num, run_as,\n        *args, **kwargs):\n\n    ptvsd.log.to_file()\n    ptvsd.log.info('run{0!r}', (filename, port_num, run_as))\n\n    address = (LOCALHOST, port_num)\n    run_main(address, filename, run_as, *args, **kwargs)\n", "path": "src/ptvsd/debugger.py"}]}