Skip to content

Debugpy not hitting breakpoints #971

Closed

Description

@amizan-jaleel

Having trouble attaching a debugger to Python code that's running in a Docker instance.
Similar problem to this issue
But I followed the steps there and I'm still having issues.

Firstly, I made sure I'm running the Debug Adapter Protocol in debug mode, not in Run mode.

I also made sure the breakpoints I'm settings are getting set as DAP breakpoints, not as Python breakpoints.

The rub here is that I'm able to connect my debugger in VS Code just fine. This is the launch.json in my VS Code:

{
  "name": "Debug MyCode server",
  "type": "python",
  "request": "attach",
  "pathMappings": [
    {
      "localRoot": "/Users/amizanjaleel/src/mycode",
      "remoteRoot": "/usr/src/mycode"
    }
  ],
  "port": 9000,
  "host": "127.0.0.1"
}

In my Python code I have:

import debugpy 
debugpy.listen(("0.0.0.0", 9000))

When I run my run configuration in debug mode, I see it getting attached to the Python code running in Docker, because I see this getting printed out:

Attaching 'Python - Debugpy' at 127.0.0.1:9000
[Trace - 19:40:46] Sending request 'initialize - (1)'.
[Trace - 19:40:46] Received notification 'output'
ptvsd
[Trace - 19:40:46] Received notification 'output'
debugpy
[Trace - 19:40:46] Received notification 'debugpySockets'
[Trace - 19:40:46] Received response 'initialize - (1)' in 2ms.
[Trace - 19:40:46] Sending request 'attach - (2)'.
[Trace - 19:40:46] Received notification 'debugpyWaitingForServer'
[Trace - 19:40:46] Received notification 'initialized'
[Trace - 19:40:46] Sending request 'configurationDone - (3)'.
[Trace - 19:40:46] Received response 'configurationDone - (3)' in 44ms.
[Trace - 19:40:46] Received response 'attach - (2)' in 135ms.
[Trace - 19:40:46] Received notification 'process'
[Trace - 19:40:46] Received notification 'thread'
[Trace - 19:40:46] Received notification 'thread'
[Trace - 19:40:48] Sending request 'setBreakpoints - (4)'.
[Trace - 19:40:48] Received response 'setBreakpoints - (4)' in 5ms.

However, my breakpoints do not get hit.

Activity

  1. angelozerr commented on Apr 17, 2025

    @angelozerr
    Contributor

    @amizan-jaleel coud you share your full DAP log with verbose. Thanks.

  2. amizan-jaleel commented on Apr 17, 2025

    @amizan-jaleel
    Author

    @angelozerr Thanks for the tip, I can see the error now:

    [Trace - 12:25:53] Received response 'setBreakpoints - (6)' in 4ms.
    Result: {
      "breakpoints": [
        {
          "id": 3,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "code.py",
            "path": "/Users/amizanjaleel/src/.../code.py"
          },
          "line": 44
        },
    

    However, I can't fathom why this would come up. I'm certain the remoteRoot is set properly. It is the same remoteRoot that is set for VS Code, and that one works just fine

  3. angelozerr commented on Apr 17, 2025

    @angelozerr
    Contributor

    Could you share your full trace please.

  4. added a commit that references this issue on Apr 17, 2025
  5. angelozerr commented on Apr 17, 2025

    @angelozerr
    Contributor

    Your path uses ../,please share your trace to understand why you have that.

  6. amizan-jaleel commented on Apr 17, 2025

    @amizan-jaleel
    Author

    No no sorry for the confusion, I left out some of the directory structure since I think it's not pertinent, let me share the full stacktrace

  7. amizan-jaleel commented on Apr 17, 2025

    @amizan-jaleel
    Author
    Attaching 'Python - Debugpy' at 127.0.0.1:9000
    [Trace - 17:17:59] Received notification 'output'
    Params: {
      "category": "telemetry",
      "output": "ptvsd",
      "data": {
        "packageVersion": "1.8.2"
      }
    }
    
    
    ptvsd
    [Trace - 17:17:59] Received notification 'output'
    Params: {
      "category": "telemetry",
      "output": "debugpy",
      "data": {
        "packageVersion": "1.8.2"
      }
    }
    
    
    debugpy
    [Trace - 17:17:59] Received notification 'debugpySockets'
    Params: {
      "sockets": [
        {
          "host": "0.0.0.0",
          "port": 9000,
          "internal": false
        },
        {
          "host": "127.0.0.1",
          "port": 48779,
          "internal": true
        }
      ]
    }
    
    
    [Trace - 17:17:59] Sending request 'initialize - (1)'.
    Params: {
      "clientID": "lsp4ij.debug",
      "clientName": "IntelliJ IDEA 2024.3.5",
      "adapterID": "python",
      "linesStartAt1": true,
      "columnsStartAt1": true,
      "pathFormat": "path",
      "supportsVariableType": true,
      "supportsVariablePaging": false,
      "supportsStartDebuggingRequest": true
    }
    
    
    [Trace - 17:17:59] Received response 'initialize - (1)' in 2ms.
    Result: {
      "supportsConfigurationDoneRequest": true,
      "supportsFunctionBreakpoints": true,
      "supportsConditionalBreakpoints": true,
      "supportsHitConditionalBreakpoints": true,
      "supportsEvaluateForHovers": true,
      "exceptionBreakpointFilters": [
        {
          "filter": "raised",
          "label": "Raised Exceptions",
          "description": "Break whenever any exception is raised.",
          "default": false
        },
        {
          "filter": "uncaught",
          "label": "Uncaught Exceptions",
          "description": "Break when the process is exiting due to unhandled exception.",
          "default": true
        },
        {
          "filter": "userUnhandled",
          "label": "User Uncaught Exceptions",
          "description": "Break when exception escapes into library code.",
          "default": false
        }
      ],
      "supportsSetVariable": true,
      "supportsGotoTargetsRequest": true,
      "supportsStepInTargetsRequest": true,
      "supportsCompletionsRequest": true,
      "supportsModulesRequest": true,
      "supportsExceptionOptions": true,
      "supportsValueFormattingOptions": true,
      "supportsExceptionInfoRequest": true,
      "supportsDelayedStackTraceLoading": true,
      "supportsLogPoints": true,
      "supportsSetExpression": true,
      "supportsTerminateRequest": true,
      "supportsClipboardContext": true
    }
    
    
    [Trace - 17:17:59] Sending request 'attach - (2)'.
    Params: {
      "name": "Debug mycode server",
      "host": "127.0.0.1",
      "request": "attach",
      "type": "python",
      "port": 9000.0,
      "pathMappings": [
        {
          "localRoot": "/Users/amizanjaleel/src/mycode",
          "remoteRoot": "/usr/src/mycode"
        }
      ]
    }
    
    
    [Trace - 17:17:59] Received notification 'debugpyWaitingForServer'
    Params: {
      "host": "127.0.0.1",
      "port": 48779
    }
    
    
    [Trace - 17:17:59] Received notification 'initialized'
    Params: null
    
    
    [Trace - 17:17:59] Sending request 'setBreakpoints - (3)'.
    Params: {
      "source": {
        "name": "tasks_input.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/tasks_input.py"
      },
      "breakpoints": [
        {
          "line": 1
        }
      ],
      "lines": [
        1
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:17:59] Sending request 'setBreakpoints - (4)'.
    Params: {
      "source": {
        "name": "chat_api.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_chatbot/api/chat_api.py"
      },
      "breakpoints": [
        {
          "line": 277
        }
      ],
      "lines": [
        277
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:17:59] Sending request 'setBreakpoints - (5)'.
    Params: {
      "source": {
        "name": "inventoryearch.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/inventoryearch.py"
      },
      "breakpoints": [
        {
          "line": 84
        }
      ],
      "lines": [
        84
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:17:59] Received response 'setBreakpoints - (3)' in 43ms.
    Result: {
      "breakpoints": [
        {
          "id": 0,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "tasks_input.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/tasks_input.py"
          },
          "line": 1
        }
      ]
    }
    
    
    [Trace - 17:17:59] Received response 'setBreakpoints - (4)' in 86ms.
    Result: {
      "breakpoints": [
        {
          "id": 1,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "chat_api.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_chatbot/api/chat_api.py"
          },
          "line": 277
        }
      ]
    }
    
    
    [Trace - 17:17:59] Received response 'setBreakpoints - (5)' in 129ms.
    Result: {
      "breakpoints": [
        {
          "id": 2,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "inventoryearch.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/inventoryearch.py"
          },
          "line": 84
        }
      ]
    }
    
    
    [Trace - 17:17:59] Sending request 'configurationDone - (6)'.
    Params: {}
    
    
    [Trace - 17:17:59] Received response 'configurationDone - (6)' in 43ms.
    No response returned.
    
    
    [Trace - 17:17:59] Received response 'attach - (2)' in 262ms.
    No response returned.
    
    
    [Trace - 17:17:59] Received notification 'process'
    Params: {
      "name": "manage.py",
      "systemProcessId": 15,
      "isLocalProcess": true,
      "startMethod": 1
    }
    
    
    [Trace - 17:17:59] Received notification 'thread'
    Params: {
      "reason": "started",
      "threadId": 1
    }
    
    
    [Trace - 17:17:59] Received notification 'thread'
    Params: {
      "reason": "started",
      "threadId": 2
    }
    
    
    [Trace - 17:18:14] Sending request 'setBreakpoints - (7)'.
    Params: {
      "source": {
        "name": "tasks_input.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/tasks_input.py"
      },
      "breakpoints": [
        {
          "line": 1
        }
      ],
      "lines": [
        1
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:18:14] Sending request 'setBreakpoints - (8)'.
    Params: {
      "source": {
        "name": "chat_api.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_chatbot/api/chat_api.py"
      },
      "breakpoints": [
        {
          "line": 277
        }
      ],
      "lines": [
        277
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:18:14] Sending request 'setBreakpoints - (9)'.
    Params: {
      "source": {
        "name": "ranker.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_triprank/ranker.py"
      },
      "breakpoints": [
        {
          "line": 297
        }
      ],
      "lines": [
        297
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:18:14] Sending request 'setBreakpoints - (10)'.
    Params: {
      "source": {
        "name": "inventoryearch.py",
        "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/inventoryearch.py"
      },
      "breakpoints": [
        {
          "line": 84
        }
      ],
      "lines": [
        84
      ],
      "sourceModified": false
    }
    
    
    [Trace - 17:18:14] Received response 'setBreakpoints - (7)' in 4ms.
    Result: {
      "breakpoints": [
        {
          "id": 3,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "tasks_input.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/tasks_input.py"
          },
          "line": 1
        }
      ]
    }
    
    
    [Trace - 17:18:14] Received response 'setBreakpoints - (8)' in 46ms.
    Result: {
      "breakpoints": [
        {
          "id": 4,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "chat_api.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_chatbot/api/chat_api.py"
          },
          "line": 277
        }
      ]
    }
    
    
    [Trace - 17:18:14] Received response 'setBreakpoints - (9)' in 88ms.
    Result: {
      "breakpoints": [
        {
          "id": 5,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "ranker.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_triprank/ranker.py"
          },
          "line": 297
        }
      ]
    }
    
    
    [Trace - 17:18:14] Received response 'setBreakpoints - (10)' in 141ms.
    Result: {
      "breakpoints": [
        {
          "id": 6,
          "verified": false,
          "message": "Breakpoint in file that does not exist.",
          "source": {
            "name": "inventoryearch.py",
            "path": "/Users/amizanjaleel/src/mycode/mycode/mycode_inventory/inventoryearch.py"
          },
          "line": 84
        }
      ]
    }
    
    
    
    
  8. angelozerr commented on Apr 17, 2025

    @angelozerr
    Contributor

    It seems that the problem is when breakoints are sent to debugpy server.

    The path /Users/amizanjaleel/src/mycode/mycode/mycode_inventory/tasks_input.py is wrong and should be /Users/amizanjaleel/src/mycode/mycode_inventory/tasks_input.py, right?

  9. amizan-jaleel commented on Apr 17, 2025

    @amizan-jaleel
    Author

    No, that's actually the right path heh

  10. angelozerr commented on Apr 17, 2025

    @angelozerr
    Contributor

    Having mycode/mycode was suspicious but it seems it is ok.

    It
    II have no idea why you have this issue if you tell me that path is correct

  11. amizan-jaleel commented on Apr 17, 2025

    @amizan-jaleel
    Author

    Yeah it's for certain that path is correct. When it's printed in my debug window, I see a hyperlink and when I click it it opens that file in my IDE. That's why I was thinking when it says it can't find the file, it meant on the remote side. But I'm sure my remoteRoot is correct as well.

    I'm sure the process is connecting correctly too. When I add print statements in my Python code, I see that getting printed out in my debug console, even though the code is running in Docker.

  12. angelozerr commented on Apr 17, 2025

    @angelozerr
    Contributor

    Yeah it's for certain that path is correct. When it's printed in my debug window, I see a hyperlink and when I click it it opens that file in my IDE. That's why I was thinking when it says it can't find the file, it meant on the remote side. But I'm sure my remoteRoot is correct as well.

    I'm sure the process is connecting correctly too. When I add print statements in my Python code, I see that getting printed out in my debug console, even though the code is running in Docker.

    Is it working with simple debugging like described in https://github.com/redhat-developer/lsp4ij/blob/main/docs%2Fdap%2Fuser-defined-dap%2Fpython-debugpy.md

  13. angelozerr commented on Apr 18, 2025

    @angelozerr
    Contributor

    Yeah it's for certain that path is correct. When it's printed in my debug window, I see a hyperlink and when I click it it opens that file in my IDE. That's why I was thinking when it says it can't find the file, it meant on the remote side. But I'm sure my remoteRoot is correct as well.

    Your config is working on vscode, right?

    I'm sure the process is connecting correctly too. When I add print statements in my Python code, I see that getting printed out in my debug console, even though the code is running in Docker.

  14. added
    bug
    dap
    on May 1, 2025
  15. angelozerr commented on May 2, 2025

    @angelozerr
    Contributor

    @amizan-jaleel I have improved DAP breakpoint support, I don't know if it could fix your issue.

    Could you please install https://github.com/redhat-developer/lsp4ij?tab=readme-ov-file#testing-nightly-builds and give me feedback.

    Thanks.

  16. angelozerr commented on May 14, 2025

    @angelozerr
    Contributor

    @amizan-jaleel could you install LSP4IJ 0.13.0 which has been released and tell me if it is working better? Thanks!

  17. angelozerr commented on May 21, 2025

    @angelozerr
    Contributor

    @amizan-jaleel I close this issue because LSP4IJ have fixed a lot of problem with breakpoints.

    Please reopen it if it doesn't work. Thanks.

  18. added this to the 0.13.0 milestone on May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdap

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions