microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
40 stars 17 forks source link

Can't step into external code files while debugging #362

Closed scruel closed 2 weeks ago

scruel commented 3 weeks ago
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false,
        }
    ]
}

Logs:

2024-06-10 00:57:09.404 [info] Send text to terminal: 
2024-06-10 00:57:09.605 [info] Send text to terminal:  cd /home/scruel/Code/Python/xtorch ; /usr/bin/env /home/scruel/mambaforge/envs/xtorch/bin/python /home/scruel/.vscode-server/extensions/ms-python.debugpy-2024.6.0/bundled/libs/debugpy/adapter/../../debugpy/launcher 56247 -- /home/scruel/Code/Python/xtorch/main.py
2024-06-10 00:57:09.154 [info] DAP Server launched with command: /home/scruel/mambaforge/envs/xtorch/bin/python /home/scruel/.vscode-server/extensions/ms-python.debugpy-2024.6.0/bundled/libs/debugpy/adapter

image

I can manually click to call stack to jump, and the active code line is green rather than yellow: image

Clark-G commented 3 weeks ago

I have the exactly same issue, hope to fix this quickly

Andrej730 commented 3 weeks ago

Got the same issue lately.

Even if you manually select "from_pretrained" in a call stack and then do F10 it will jump back to .

Sometimes it's getting even more in the way when there are one more external level - you won't be able to select the layer right away, first you'll need to click "Show N more stack frames" to see "from_pretrained" entry. And on each step layers get hidden and you need to reload them again.

As a current workaround, you can open the layer you need to keep it in a separate VS Code window - so you'll have both and "from_pretrained" files on the screen, then atleast you'll be able to follow the debugger steps. But it doesn't help with variables/watch sections.

My version:

Version: 1.91.0-insider (user setup)
Commit: fec18ef7d6793521c4683e67e569579ea970cc6d
Date: 2024-06-10T05:48:36.787Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22635
Python Debugger: v2024.7.11591013 (pre-release)

A way to reproduce this

Disable "justmycode" in user settings: image

import inspect
import sys
inspect.getmembers(sys) # set breakpoint here and do step in with F11

Launch debugger without launch.json: image

yasserben commented 3 weeks ago

I am encountering the same issue as well

avishek-mondal commented 3 weeks ago

Hi, I am encountering the same issue as well.

This is my minimum reproducible example:

from transformers import BertTokenizerFast, BertModel

def main():
    model_name = "google-bert/bert-base-uncased"
    tokenizer = BertTokenizerFast.from_pretrained(model_name)
    model = BertModel.from_pretrained(model_name)

    words = [
        ["word1*word2|word3"],
        ["word1*", "word2|", "word3"],
    ]

    tokenizer_out = tokenizer(
        text=words,
        is_split_into_words=True,
        return_offsets_mapping=True,
        return_overflowing_tokens=True,
        truncation="longest_first",
        padding="max_length",
        return_tensors="pt",
        max_length=512,
        stride=0,
        return_length=True,
    )
    # Input IDs and attention mask
    input_ids = tokenizer_out["input_ids"]
    attention_mask = tokenizer_out["attention_mask"]

    # Inference with the mask
    model.eval()
    outputs = model(input_ids, attention_mask=attention_mask)

    print(outputs)

if __name__ == "__main__":
    main()
image

and every time I try and step into the code from the transformers library, I get brought back to my own masking_exploration.py module. I have to click the Show 2 More Stack Frames under the Call Stack, and then go back into the code in the transformers library.

Ujifman commented 3 weeks ago

Got the same issue after update VSCode to 1.90.0. Workaround: downgrade VSCode to 1.89.1 Here is full VSCode about screen of version where step in other libraries is working

Version: 1.89.1 (system setup)
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:13:33.891Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.22631
BriceBoy commented 3 weeks ago

Same problem here

VS Code Version 1.90.0
Debugpy Version v2024.6.0
Python Version 3.12.2
OS Windows
dyitzchaki-roku commented 3 weeks ago

downgrading just the extension doesn't help

d-biehl commented 3 weeks ago

very good! Thanks for the info!

Andrej730 commented 3 weeks ago

Is there way to safely downgrade to VS Code 1.89.1 besides just uninstalling and installing it? Is there any chance to lose some settings/data during reinstall?

avishek-mondal commented 2 weeks ago

Is there way to safely downgrade to VS Code 1.89.1 besides just uninstalling and installing it? Is there any chance to lose some settings/data during reinstall?

I don't think there is :( I kept a copy of ~/Library/Application\ Support/Code/User and ~/.vscode/extensions (I use a Mac) to preserve my settings and keybindings before I deleted VSCode 1.9 and installed 1.89

avi-nextvestment commented 2 weeks ago

I am running into the same issue. Making it impossible to debug anything

Even with this extension setting disabled:

image
VS Code Version 1.90.0
Debugpy Version v2024.6.0
Python extension v2024.8.0
Python Version 3.10.11
OS Windows
avi-nextvestment commented 2 weeks ago

Found this is a duplicate of https://github.com/microsoft/debugpy/issues/1598 and ultimately a VS Code issue that's documented here: https://github.com/microsoft/vscode/issues/214433'

FYI: A fix has been released in v1.90.1 which is available here: https://code.visualstudio.com/insiders/ but note this is not a stable release yet

paulacamargo25 commented 2 weeks ago

Closed in: #214433

Andrej730 commented 2 weeks ago

I'm on insiders version, can confirm that it now seems to work as before.

Version: 1.91.0-insider (user setup)
Commit: 0a417782b1781d39803b8f1791cfb22f8835ddae
Date: 2024-06-13T05:48:47.964Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22635