microsoft / vscode-cpptools

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

VS Code Debugging C/C++ creates a file called "2" in working directory #12639

Open sjd-home opened 3 months ago

sjd-home commented 3 months ago

Environment

Version: 1.85.2 (user setup) Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681 Date: 2024-01-18T06:40:10.514Z Electron: 25.9.7 ElectronBuildId: 26354273 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19045

Bug Summary and Steps to Reproduce

Create C program Run C program with debugger A file called "2" is generated in working directory. The file contents appear to be some sort of escape code.

Note, I am running VS Code on PC, and SSH into Linux server. The program is compiling on Linux server, using gcc. When debugging with VS Code, a file called "2" is created in the working directory (sometimes multiple places).

Debugger Configurations

{
    // 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": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/lib/runme",
            "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

N/A

Other Extensions

Microsoft C/C++

Additional Information

No response

starball5 commented 3 months ago

Related on Stack Overflow: https://stackoverflow.com/q/78914016/11107541

sean-mcmanus commented 3 months ago

@starball5 What version of the C/C++ extension are you using? Do you have other extensions installed that could be creating that file? Is the file always named 2? If you create your own file named 2, are the contents overwritten?

starball5 commented 3 months ago

(note: this is not an issue I'm experiencing. I just directed @sjd-home here from SO)

sean-mcmanus commented 3 months ago

Oh, yeah, I intended to message the original issue creator @sjd-home .

sjd-home commented 3 months ago

Thanks guys.

I am using: Microsoft C/C++ v1.21.6 Microsoft C/C++ Extension Pack v1.3.0 Microsoft C/C++ Themes v2.0.0

I do have a bunch of other extensions too - for Python, Code Spell Checker, etc. I don't think they are anything to do with it.

As @starball5 said on the StackOverflow link, I also believe it is probably to do with stream redirection when launching the program.

My code is built and run on Linux machine, and debugged with VS Code running over SSH onto that machine. For reasons beyond my control, the machine is using "CentOS Linux 7 (Core)" and I am using csh by default.

I wondered whether it was some how messing up the Linux stream redirection "2>&1" as is commonly used? I'm not sure if this redirection works in csh (should it be >&)?

The file is always called 2. The contents are -e c 1 (rendered as "-e ESCc1" in VS Code).

If the file exists already (I made my own with the contents "Hello world!") the file gets overwritten with -e c 1.