Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Removing breakpoints in remote debugging does not work #1126

Closed
DonJayamanne opened this issue Jan 28, 2019 · 8 comments
Closed

Removing breakpoints in remote debugging does not work #1126

DonJayamanne opened this issue Jan 28, 2019 · 8 comments

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Jan 28, 2019

@DonJayamanne commented on Mon Jan 28 2019

Launch python code for debugging:

  • Mac, Python3.6
  • Ptvsd version 4.2.2
import ptvsd
ptvsd.enable_attach(('localhost', 3000))

import time
for i in range(1000):
    time.sleep(1)
    print(i)
  • Launch program
  • Attach debugger
  • Add a breakpoint to the print line
  • Breakpoint hits
  • Remove breakpoint
  • Continue
  • Program stops at print line again, even when there are no breakpoints!!!
  • Disconnect debugger, program is stuck!!

Two problems:

  • Program stops at print line again, even when there are no breakpoints!!!
  • Disconnect debugger, program is stuck!!
@DonJayamanne
Copy link
Contributor Author

DonJayamanne commented Jan 28, 2019

This same bug can be reproduced in a simple launch scenario:
I.e. bug is not specific to remote debugging.

  • Start debugging following code:
import time
for i in range(1000):
    time.sleep(1)
    print(i)
  • Add breakpoint
  • Break point is hit,
  • Remove breakpoint and continue,
  • Code will stop again at line where previous breakpoint was hit!!

@karthiknadig
Copy link
Member

/cc @fabioz

@karthiknadig
Copy link
Member

Request response logs from VSC for the setBreakpoints command.
Setting break-point:

{"command":"setBreakpoints","arguments":{"source":{"name":"mytest.py","path":"C:\\GIT\\pyscratch2\\mytest.py"},"lines":[14],"breakpoints":[{"line":14}],"sourceModified":false},"type":"request","seq":4}
To Client:
Content-Length: 177

{"type": "response", "seq": 4, "request_seq": 4, "success": true, "command": "setBreakpoints", "message": "", "body": {"breakpoints": [{"id": 0, "verified": true, "line": 14}]}}
From Client:
Content-Length: 99

Removing break-point:

{"command":"setBreakpoints","arguments":{"source":{"path":"C:\\GIT\\pyscratch2\\mytest.py","sourceReference":0},"lines":[],"breakpoints":[],"sourceModified":false},"type":"request","seq":13}
To Client:
Content-Length: 140

{"type": "response", "seq": 22, "request_seq": 13, "success": true, "command": "setBreakpoints", "message": "", "body": {"breakpoints": []}}
From Client:
Content-Length: 75

@fabioz
Copy link
Contributor

fabioz commented Jan 28, 2019

I'll take a look at it (although I'll probably only be able to provide a fix tomorrow).

fabioz added a commit to fabioz/ptvsd that referenced this issue Jan 28, 2019
@fabioz
Copy link
Contributor

fabioz commented Jan 28, 2019

Actually, the issue was simpler than I thought, so, I've provided a fix for it already (but without tests for today -- see comments on #1127).

fabioz added a commit to fabioz/ptvsd that referenced this issue Jan 28, 2019
fabioz added a commit to fabioz/ptvsd that referenced this issue Jan 28, 2019
@karthiknadig
Copy link
Member

Reopening because resuming a run sometimes causes exception:
image

Repro steps:

import time
for x in range(10):
    time.sleep(1)
    print(x)
print('done')
  1. set breakpoint on line 4 and run
  2. when breakpoint is hit, remove breakpoint and resume.
    You should see this exception, but this does not happen every time.

FIY: use following configuration with latest VSC to run master version of the debugger.

        {
            "customDebugger": true,
            "name": "File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "env":{
                "PYTHONPATH":"C:\\ptvsd\\src",
            },
        },

@karthiknadig karthiknadig reopened this Jan 29, 2019
@karthiknadig
Copy link
Member

Found the issue, it is in the following function call:
Looks like _pydev_stop_at_break gets called even after removing all breakpoints. In that function, the following line sets breakpoints_for_file to None, breakpoints_for_file = debugger.breakpoints.get(filename) if there are no other breakpoints set in the file. Later this fails with 'NoneType' is not subscriptable.

/cc @fabioz

@fabioz
Copy link
Contributor

fabioz commented Jan 29, 2019

Fixed by #1134

@fabioz fabioz closed this as completed Jan 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants