robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
168 stars 13 forks source link

[QUESTION] How to attach python debugger properly ? #264

Closed BriceBoy closed 4 weeks ago

BriceBoy commented 4 weeks ago

I would like to know how to configure python debugger properly. Before, I could just debug tests and use breakpoints in python code but I can't seem to do it properly. When it hits a breakpoint it does not open the file the breakpoint is in and I can't see variables values.

I can see that it's stopped on a breakpoint : image

If I go to the file it's stopped in, I can't seem to see variables values : image

Here is my actual configuration

"launch": {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "RobotCode: Run Current",
                "type": "robotcode",
                "request": "launch",
                "cwd": "${workspaceFolder}",
                "target": "${file}"
            },
            {
                "name": "RobotCode: Run All",
                "type": "robotcode",
                "request": "launch",
                "cwd": "${workspaceFolder}",
                "target": "."
            },
            {
                "name": "RobotCode: Default",
                "type": "robotcode",
                "request": "launch",
                "purpose": "default",
                "presentation": {
                    "hidden": true
                },
                "attachPython": true,
                "pythonConfiguration": "RobotCode: Python",
                "args": [
                    "--debugFile", "debug",
                    "--loglevel", "TRACE"
                ],
            },
            {
                "name": "RobotCode: Python",
                "type": "debugpy",
                "request": "attach",
                "presentation": {
                    "hidden": true
                },
                "justMyCode": false,
            }
        ]
    }
d-biehl commented 4 weeks ago

Normally you don't need a launch.config, just search for robotcode.debug.attachPython in VSCode settings an enable it. If you want debug also python system libraries or python libraries that are not part of the workspace, enable the debugpy.debugJustMyCode setting.

BriceBoy commented 4 weeks ago

Thank you for your time !

Apparently you are right I don't need the launch config but if I can remember right I made it to use breakpoints correctly. Maybe I'm wrong. However the debugger still doesn't open file in which breakpoint is set when it reaches it.

BriceBoy commented 4 weeks ago

I just saw this, it might be related to my problem :

0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
BriceBoy commented 4 weeks ago

I finally found the solution to my problem, I downgraded to VSCode v1.89.1 (Python Debugger Issue)

d-biehl commented 4 weeks ago

very good! Thanks for the info!