Visual Studio Code ignores debug symbols

2

I'm trying to debug C using visual studio code on a Mint VM, code is as follows:

#include <stdio.h>

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

Compiled with:

gcc test.c -g -o test

based on the output of ls -l, I can verify that gcc is adding symbols. When I attempt to debug this program using vs-code using the C/C++ extension, I receive the following error:

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 version: 5.4.0 20160609

vs-c version: 1.24.1

my launch.json file is as follows:

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

You may note that this is not a duplicate of Stopped due to shared library event - Visual Studio Code because I am already using the -g switch.

I would like to know how I can fix this. Thank you in advance.

c
linux
gcc
visual-studio-code
asked on Stack Overflow Jul 2, 2018 by Tom Collins • edited Jul 2, 2018 by Tom Collins

1 Answer

0

Assuming the use of "additionalSOLibSearchPath" option of launch.json did not help, the following setting might add a shared library into gdb's consideration:

"setupCommands":[
    {
        "description": "Additional libs for gdb",
        "text": "set solib-search-path sharedLibraryPath/lib"
    }
]

PS: gdb may still raise Stopped due to shared library event (no libraries added or removed) warning, nevertheless.

answered on Stack Overflow Feb 4, 2019 by KutalmisB

User contributions licensed under CC BY-SA 3.0