c - Visual Studio Code 忽略调试符号

标签 c linux gcc visual-studio-code

我正在尝试在 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/

相关文章:

linux - 导致用户注销的 Bash 脚本

c++ - 如何使用 GCC 4.3 在 -std=gnu++98 模式下使用 C99 数学函数?

在 Windows 中使用 Eclipse 编译 ARM

c++ - 将 C 程序更改为 C++ 程序 - 编译错误

linux - 解决 Git 索引太小的错误

c - 如何编写终端矩阵效果?

linux - 如何查找 Linux 上安装的 ODBC 驱动程序列表

gcc - "compiler option"-auxbase-strip 有什么作用?

c++ - 需要简单的指针数组相等解释

c - C 中整数的 NOT