简体   繁体   English

调试基于 Linux 的 C++ 代码 Visual Studio 代码时出现问题

[英]Issue while debugging Linux based C++ code visual studio code

I am trying to debug my code in visual studio code in Linux - Ubuntu.我正在尝试在 Linux - Ubuntu 的Visual Studio 代码中调试我的代码。 I have configured the debugging configurations according to the specification.我已经按照规范配置了调试配置。 But when trying to debug I am getting the following error.但是在尝试调试时,我收到以下错误。

=thread-group-added,id="i1" GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. =thread-group- added,id="i1" GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1 版权所有 (C) 2016 Free Software Foundation, Inc. 许可证 GPLv3+:GNU GPL 版本 3 或更高版本http:// /gnu.org/licenses/gpl.html这是免费软件:您可以自由更改和重新分发它。 There is NO WARRANTY, to the extent permitted by law.在法律允许的范围内,不提供任何保证。 Type "show copying" and "show warranty" for details.输入“显示复制”和“显示保修”了解详细信息。 This GDB was configured as "x86_64-linux-gnu".这个 GDB 被配置为“x86_64-linux-gnu”。 Type "show configuration" for configuration details.键入“show configuration”以获取配置详细信息。 For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/ .有关错误报告的说明,请参阅: http : //www.gnu.org/software/gdb/bugs/ Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/ .在线查找 GDB 手册和其他文档资源: http : //www.gnu.org/software/gdb/documentation/ For help, type "help".如需帮助,请键入“帮助”。 Type "apropos word" to search for commands related to "word".输入“apropos word”以搜索与“word”相关的命令。 =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'. =cmd-param-changed,param="pagination",value="off" 由于共享库事件(没有添加或删除库)而停止加载'/lib64/ld-linux-x86-64.so.2'。 Symbols loaded.符号加载。 [Inferior 1 (process 18634) exited with code 0177] The program '/home/source/src/.libs/main' has exited with code 177 (0x000000b1). [Inferior 1 (process 18634) exited with code 0177] 程序“/home/source/src/.libs/main”已退出,代码为 177 (0x000000b1)。

   launch.json

        {
            // Use IntelliSense to learn about possible attributes.
            // Hover to view descriptions of existing attributes.
            // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
            "version": "0.2.0",
            "configurations": 
            [
                {
                    "name": "C++ Launch",
                    "type": "cppdbg",
                    "request": "launch",
                    "targetArchitecture": "x64",
                    "program": "${workspaceFolder}/src/.libs/main",
                    "args": [],
                    "stopAtEntry": false,
                    "cwd": "${workspaceRoot}",
                    "environment": [],
                    "externalConsole": true,
                    "linux": {
                        "MIMode": "gdb"
                    },
                    "osx": {
                        "MIMode": "lldb"
                    },
                    "windows": {
                        "MIMode": "gdb"
                    }
                },
            ]
        }

Because not all libraries (.a, .so) are linked to you project.因为并非所有库(.a、.so)都链接到您的项目。 I had the same problem.我有同样的问题。 gdb outputs this error when it encounters a library call to a library that is not linked. gdb 在遇到对未链接库的库调用时会输出此错误。

You have compiled your program without debugging information.您在没有调试信息的情况下编译了程序。 Compile it with -g compiler and linker option.使用-g编译器和链接器选项编译它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM