4

I am trying to debug my code in visual studio code in Linux - Ubuntu. 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. 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". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/. For help, type "help". Type "apropos word" to search for commands related to "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'. Symbols loaded. [Inferior 1 (process 18634) exited with code 0177] The program '/home/source/src/.libs/main' has exited with code 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"
                    }
                },
            ]
        }
3
  • The salient part of your error is Stopped due to shared library event (no libraries added or removed) Loaded '/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). Where it appears you are attempting to load and compile/run in gdb a Linux shared-object library under a VS compile. I don't know how that would work under WSL, but you cannot expect VS (at least the versions I've worked with) to use a .so instead of a windows .dll. Commented Jan 4, 2018 at 6:38
  • @DavidC.Rankin I'm facing the same problem, As you said VS cant use .so files. this mean I can't debug a program that uses .so files under VS, am I right? Commented Jun 1, 2019 at 16:56
  • 1
    @HMD You have options. WSL (whichever distro you choose) will provide gcc, so you can build your code with gcc (using the -g option to generate the gdb symbol file) Then you can debug with gdb. Commented Jun 2, 2019 at 1:41

2 Answers 2

4

Because not all libraries (.a, .so) are linked to you project. I had the same problem. gdb outputs this error when it encounters a library call to a library that is not linked.

Sign up to request clarification or add additional context in comments.

Comments

0

You have compiled your program without debugging information. Compile it with -g compiler and linker option.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.