microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

additionalSOLibSearchPath does not work for remote debugging #8344

Open pclausen opened 2 years ago

pclausen commented 2 years ago

Bug type: Debugger

Description additionalSOLibSearchPath is not respected in debuging session using remote debugger from windows to linux using ssh.

According to maintainer in vscode-remote-release the issue is in debugger, not in the remote extension, see https://github.com/microsoft/vscode-remote-release/issues/5748

Work around is to use "environment": [{ "name": "LD_LIBRARY_PATH", "value": "/path_to_libImportantLib/" },

Details

To Reproduce

  1. Compile an executable (exe_to_debug) on remote linux which depends on dynamic libraries in some path, eg /path_to_libImportantLib/ where libraries are found eg. libImportantLib.so
  2. Debug executable on remote linux with dynamic libraries but without setting additionalSOLibSearchPath --> gdb fails as expected, output in gdb terminal exe_to_debug: error while loading shared libraries: libImportantLib.so: cannot open shared object file: No such file or directory
  3. In Launch.json set "additionalSOLibSearchPath": "/path_to_libImportantLib/" Expected: Successful debugging Current Result: Same error as (2) `exe_to_debug: error while loading shared libraries: libImportantLib.so: cannot open shared object file: No such file or directory

Workaround: Debugging works if I add following to Launch.json:

  "environment": [
    {
      "name": "LD_LIBRARY_PATH",
      "value": "/path_to_libImportantLib/"
    },
WardenGnaw commented 2 years ago

The additionalSOLibSearchPath is used to send set solib-search-path [Directories] to GDB.

If GDB does not update the LD_LIBRARY_PATH with that command, I believe it expects the executable to be runnable without a debugger.

If the executable runs without setting LD_LIBRARY_PATH, then there will be an issue if it fails to run with the debugger in the same environment.