microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.55k forks source link

GDB selected frame is not updated when changing frame #12892

Open maxmarsc opened 5 days ago

maxmarsc commented 5 days ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: When selecting a new frame using the VSCode interface, it does not always update the frame scope from within GDB.

Steps to reproduce:

  1. Configuration This simple C++ files is enough to reproduce the error :
    
    // ccp_tools_bug.cpp
    #include <iostream>

void bar() { std::cout << "bar" << std::endl; }

int main() { bar(); return 0; }


**Put a breakpoint on the bar function**

2. Starts the debugger, when stopped on the bar function, you can check the current selected frame using this command :

-exec info frame


![Image](https://github.com/user-attachments/assets/a7b77964-6461-4a2c-8f10-bb2972027aa9)

Then, use the vscode interface to select the top frame and rerun the command :
![Image](https://github.com/user-attachments/assets/2fb1b8d7-3d58-4032-9634-85db3eda4d3d)
![Image](https://github.com/user-attachments/assets/ae5687ed-58fa-4a84-a4ec-dc8547c94226)

You can see the selected frame was updated with success.

Now select the `bar` frame again and recheck the selected frame :
![Image](https://github.com/user-attachments/assets/85c3be38-9902-4474-bec2-e8292856420d)
![Image](https://github.com/user-attachments/assets/b3bad9be-c94e-44f9-9c49-e14c122f385d)

Here you can see the selected frame is no longer updated.

---

This is a bug I encountered while developing a plugin for GDB. Unfortunately this bug breaks an important feature for VScode users , and requires to starts gdb manually from a terminal

### Debugger Configurations

    {
      "name": "(gdb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "${workspaceFolder}/build/examples/cpp_tools_bug",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${fileDirname}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        },
        {
          "description": "Set Disassembly Flavor to Intel",
          "text": "-gdb-set disassembly-flavor intel",
          "ignoreFailures": true
        }
      ]
    },

### Debugger Logs

Too much output, the log comes attached

### Other Extensions

- autoDocstring
- Black Formatter
- Clang-Format
- clangd
- Cmajor-tools
- CMake
- Cmake tools
- cmake-format
- Docker
- CS 128 clang tidy
- graphical debugging

The issue persists after disabling all these extensions

Here is the log of the debug console : [cpp_tools_bug.log](https://github.com/user-attachments/files/17534622/cpp_tools_bug.log)

### Additional Information

_No response_
maxmarsc commented 5 days ago

I just tested with gdb-14.2 built from sources and the issues it the same

github-actions[bot] commented 3 days ago

Thank you for reporting this issue. We’ll let you know if we need more information to investigate it. Additionally, if you're working with GDB/LLDB, please note that the code is open source at https://github.com/microsoft/MIEngine/wiki/Contributing-Code . Your contributions are always welcome and appreciated.