c# - VSCode dbg附加本地进程来调试C# dll使用的C dll

标签 c# c debugging visual-studio-code mingw-w64

我想在 VSCode 中调试由 MinGW64 使用 -g(调试符号)编译的 C DLL quickfuncs.dll。该 DLL 由 C# DLL 使用(也使用调试符号编译),其运行方式为: "C:\Program Files\dotnet\dotnet.exe"exec "D:\Server\bin\Debug\netcoreapp2.0\Server.dll"Parameter1=test

我已根据 https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md 配置了 launch.json

{
    // 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) Attach to process",
            "type": "cppdbg",
            "request": "attach",
            "program": "C:/Program Files/dotnet/dotnet.exe",
            "processId": "${command:pickProcess}",
            "MIMode": "gdb",
            "miDebuggerPath": "c:/msys2/mingw64/bin/gdb.exe",
            "targetArchitecture": "x64",
            "additionalSOLibSearchPath": "${workspaceFolder}/bin/Debug/win64/;d:\\Server\\src\\Server\\WorkingDirectory\\",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false,
                }
            ],
            "logging": { 
                "trace": true, 
                "traceResponse": true
                },
        }
    ]
}

附加进程后,无法使用此日志设置断点:

C setBreakpoints: {"source":{"name":"api.c","path":"D:\\c_code\\quickfuncs\\api.c"},"lines":[246],"breakpoints":[{"line":246}],"sourceModified":false}
 R: {"success":true,"message":null,"request_seq":11,"command":"setBreakpoints","body":{"breakpoints":[{"id":3,"verified":true,"line":246,"message":null}]},"running":false,"refs":null,"seq":0,"type":"response"}
E breakpoint: {"reason":"changed","breakpoint":{"id":3,"verified":false,"line":246,"message":"Attempting to bind the breakpoint...."},"type":"breakpoint"}

你能帮我一下吗?

最佳答案

我在 https://github.com/Microsoft/vscode-cpptools/issues/2452 上找到了解决方案.

馅饼和蛋糕写道:

With MinGW you have to send Ctrl+C to the debuggee to pause. The pause button doesn't work because we can't send SIGINT through gdb's MI protocol. The command we typically use is -exec-interrupt but that doesn't work. The procedure (unfortunately) is:

  1. Hit pause in the UI
  2. Go to the debuggee and press Ctrl+c.

At that point the debuggee should stop. It is only then that the breakpoints bind.

这个解决方案适合我。非常感谢。

关于c# - VSCode dbg附加本地进程来调试C# dll使用的C dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52000716/

相关文章:

android - android 中的 c++/Java,将 ReferenceTables 转储到 logcat

ios - Metal Shader 调试 - 捕获 GPU 帧

c# - 从 Scheduled Agent 保存图像时出现 System.UnauthorizedAccessException

c# - 没有属性名称的 JSON.NET 序列化字典

c - 从哪里获得/usr/include中所有的C头文件?

c++ - 用户模式应用程序的 Nt* api header

debugging - 如何配置 Aptana 3 以在 Debug模式下运行我的 Rails 服务器,以便它在断点处停止?

c# - .NET ServiceController.WaitForStatus 忽略超时

c# - 通过反射调用带有 params 参数的泛型方法

python - 在 Windows 上的 VSCode 中调试 Python C/C++ 扩展