'std::string displayed as <incomplete type> in the debugger

I want to debug my project using vscode, but when i debug all std::string values are shown as incomplete type. in the launch.json i have:

{
    // 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": "(gdb) Adapter CLI",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build-debug/cli/src/adapterCli",
            "args": ["${workspaceFolder}/cli/src/config.ini"],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable automatic structuring and indentation for gdb.",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "miDebuggerPath": "/usr/bin/gdb"
        }   
    ]
    
}


Solution 1:[1]

what should i do to solve the problem?

Since you are using clang you have 2 options to solve "incomplete type" problem:

  1. This is clang specific problem, so if you can use another compiler you can just use gcc instead of clang.
  2. You can continue using clang but you will have to install debug info for libstdc++ library. The exact way how to install it depends on the OS you are using. For Fedora/RedHat/CentOS use sudo dnf debuginfo-install libstdc++-<some_version_here>.x86_64, see https://stackoverflow.com/a/42031150/72178. For Ubuntu/Debian use sudo apt-get install libstdc++6-dbgsym, see https://stackoverflow.com/a/65565897/72178.
  3. You can also use clang with -fno-limit-debug-info option, see https://stackoverflow.com/a/58527425/72178.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1