gpt4 book ai didi

process - Visual Studio Code,调试子进程不起作用

转载 作者:行者123 更新时间:2023-12-03 23:56:14 24 4
gpt4 key购买 nike

我有这个确切的问题:
https://github.com/Microsoft/vscode-cpptools/issues/511

但是那里的解决方案不起作用。

我已经尝试了相同的简单示例代码,

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

int main()
{
pid_t pid = fork();
if (pid != 0) {
printf("Main process\n");
} else {
printf("Forked process\n");
}

return 0;
}

我使用-g 编译,我的launch.json 文件如下所示。

我单击调试,我将断点设置为第一行。在第一站,我输入 -exec set follow-fork-mode child在调试控制台下,它给了我 =cmd-param-changed,param="follow-fork-mode",value="child" .然后它就行不通了。它转到父进程(pid 不显示为 0)。我尝试使用 {"text": "-gdb-set follow-fork-mode child"} 在 launch.json 文件本身中设置它,但这也不起作用。
{
"version": "0.2.0",
"configurations": [

{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceRoot}/a.exe",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin64\\bin\\gdb.exe"
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\cygwin64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

最佳答案

我遇到了同样的问题,我解决了这个问题:


"setupCommands": [
{
"description": "Enable funcy printing to gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{ "description":"In this mode GDB will be attached to both processes after a call to fork() or vfork().",
"text": "-gdb-set detach-on-fork off",
"ignoreFailures": true
},
{ "description": "The new process is debugged after a fork. The parent process runs unimpeded.",
"text": "-gdb-set follow-fork-mode child",
"ignoreFailures": true
}
],

关于process - Visual Studio Code,调试子进程不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46627758/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com