microsoft / vscode-cpptools

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

Unable to step out. Operation failed with error code 0x80004004. #9803

Open ekkkkki opened 2 years ago

ekkkkki commented 2 years ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary: I could "Step in" or "Step over" when debugging, while when I want to "Step out", errors occurs: "Unable to step out. Operation failed with error code 0x80004004.

Debugger Configurations

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活动文件",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C/C++: g++ 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: g++ 生成活动文件",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

Debugger Logs

No ogs or error messages were outputed in the terminal.
VSCode show error messages"Unable to step out. Operation failed with error code 0x80004004."

Other Extensions

No response

Additional Information

No response

WardenGnaw commented 2 years ago

Can you enable logging? You can do this by adding the following to your launch.json.

"logging": {
   "engineLogging": "true",
   "traceResponse": "true"
}

Then copy what appears in the Debug Console window here.

ekkkkki commented 2 years ago

@WardenGnaw Thanks for replying.

Here is the error in Debug Console when steping out: ERROR: Unexpected GDB output from command "-exec-finish". "finish" not meaningful in the outermost frame.

michael1735 commented 1 year ago

Hello, I'm currently facing the same problem, And my Environment is: OS and version : Windows 11 22h2 VS Code: 1.77.0 C/C++ extension: 1.14.5 GDB version: 13.1

Debugger Configurations

{
    "configurations": [
        {
            "name": "C/C++:g++.exe 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "internalConsoleOptions": "neverOpen",
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\msys64\\mingw64\\bin\\gdb.exe", // 调试器路径,如果您使用默认路径安装 UCRT64 则无需修改
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavorintel",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++:g++.exe 生成活动文件",

            "logging": {
                "engineLogging" : true,
                "traceResponse": true
            }
        }
    ],
    "version": "2.0.0"
}
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++:g++.exe 生成活动文件",
            "command": "D:\\msys64\\ucrt64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-fexec-charset=GBK"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build",
            "detail": "调试器生成的任务。"
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "D:\\msys64\\ucrt64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

Debugger Logs

=thread-group-added,id="i1" GNU gdb (GDB) 13.1 Copyright (C) 2023 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help".

Type "apropos word" to search for commands related to "word". Warning: Debuggee TargetArchitecture not detected, assuming x86_64. =cmd-param-changed,param="pagination",value="off" [New Thread 4004.0x471c] [New Thread 4004.0x57fc] [New Thread 4004.0x2868]

Thread 1 hit Breakpoint 1, main () at D:\vsCodeProjects\C++\Luogu\Fundamentals\string.cpp:11 11 cin >> input; Loaded 'C:\WINDOWS\SYSTEM32\ntdll.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\kernel32.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\KernelBase.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\ucrtbase.dll'. Symbols loaded. Loaded 'D:\msys64\ucrt64\bin\libstdc++-6.dll'. Symbols loaded. Loaded 'D:\msys64\ucrt64\bin\libwinpthread-1.dll'. Symbols loaded. Loaded 'D:\msys64\ucrt64\bin\libgcc_s_seh-1.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\advapi32.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\msvcrt.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\sechost.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\rpcrt4.dll'. Symbols loaded. Loaded 'C:\WINDOWS\SYSTEM32\cryptbase.dll'. Symbols loaded. Loaded 'C:\WINDOWS\System32\bcryptprimitives.dll'. Symbols loaded.

Thread 1 hit Breakpoint 2, main () at D:\CodeProjects\C++\A\Fundamentals\string.cpp:14 14 for (int i = 1; i < 10; i+=3) { Execute debugger commands using "-exec ", for example "-exec info registers" will list registers in use (when GDB is the debugger) ERROR: Unexpected GDB output from command "-exec-finish". "finish" not meaningful in the outermost frame. ERROR: Unexpected GDB output from command "-exec-finish". "finish" not meaningful in the outermost frame. Kill the program being debugged? (y or n) [answered Y; input not from terminal] [Inferior 1 (process 4004) killed] The program 'D:\CodeProjects\C++\A\Fundamentals\string.exe' has exited with code 0 (0x00000000).

iconicon111 commented 1 year ago

"step out "should not be applied to main function, which is not meaningful. you can use "step out " in other functions exclude main and it will never cause this error