Ch.*_*Pla 6 gdb fork process visual-studio-code
我有这个确切的问题: 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;
}
Run Code Online (Sandbox Code Playgroud)
我使用 -g 进行编译,我的 launch.json 文件如下所示。
我单击“调试”,将断点设置到第一行。在第一站,我进入-exec set follow-fork-mode child调试控制台,它给了我返回=cmd-param-changed,param="follow-fork-mode",value="child"。那么它就行不通了。它转到父进程(pid 显示不为 0)。我尝试使用 来将其设置在 launch.json 文件本身中{"text": "-gdb-set follow-fork-mode child"},但这也不起作用。
{
"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
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
小智 9
我遇到了同样的问题,我解决了这个问题:
"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
}
],
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7086 次 |
| 最近记录: |