Visual Studio代码忽略调试符号

问题描述 投票:2回答:1

我试图调试C上使用薄荷VM Visual Studio代码,代码如下:

#include <stdio.h>

int main(int numargs, char* argvector[])
{
   printf("test\n");
  return(0);
}

编译:

gcc test.c -g -o test

基于LS的输出-l,我可以验证的gcc添加符号。当我尝试使用VS-代码使用C / C ++扩展调试该程序时,收到以下错误:

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
                }
             ]
        }
    ]
}

你可能注意到这一点,因为我已经使用-g开关不是Stopped due to shared library event - Visual Studio Code的副本。

我想知道我怎么能解决这个问题。先感谢您。

c linux gcc visual-studio-code
1个回答
0
投票

假设使用"additionalSOLibSearchPath"没有帮助的launch.json选项,以下设置可以添加一个共享库到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)警告,不过。

© www.soinside.com 2019 - 2024. All rights reserved.