我正在尝试在 Mint VM 上使用 visual studio 代码调试 C,代码如下:
#include <stdio.h>
int main(int numargs, char* argvector[])
{
printf("test\n");
return(0);
}
编译:
gcc test.c -g -o test
根据 ls -l 的输出,我可以验证 gcc 正在添加符号。 当我尝试使用 C/C++ 扩展使用 vs-code 调试此程序时,我收到以下错误:
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
Stopped due to shared library event (no libraries added or removed)
Loaded '/lib64/ld-linux-x86-64.so.2'. Symbols loaded.
Breakpoint 1, main (numargs=1, argvector=0x7fffffffdd18) at test.c:5
5 printf("test\n");
[Inferior 1 (process 8322) exited normally]
The program '/home/ccsd/test/test' has exited with code 0 (0x00000000).
gcc 版本:5.4.0 20160609
vs-c版本:1.24.1
我的launch.json文件如下:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/grow",
"processName": "grow",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
您可能会注意到这不是 Stopped due to shared library event - Visual Studio Code 的副本因为我已经在使用 -g 开关。
我想知道如何解决这个问题。提前谢谢你。
最佳答案
假设 launch.json
的 "additionalSOLibSearchPath"
选项没有帮助,以下设置可能将共享库添加到 gdb
的考虑:
"setupCommands":[
{
"description": "Additional libs for gdb",
"text": "set solib-search-path sharedLibraryPath/lib"
}
]
PS:gdb
可能仍会发出 Stopped due to shared library event (no libraries added or removed)
警告,尽管如此。
关于c - Visual Studio Code 忽略调试符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51142887/