truffleruby
truffleruby copied to clipboard
Paths to C files from standard libraries wrong in VS Code debugger's "Loaded Scripts"
Possibly related to oracle/graal#5125, C files from standard libraries such as "zlib" appear in the "Loaded Scripts" section in the VS Code debugger, but the paths are wrong. As a result, clicking on any of those files results in an error saying "Could not load source '/bad/path/file.c': Could not retrieve content."
It looks like the path being used is the directory of the script I'm debugging, rather than the TruffleRuby home directory.
We do this: https://github.com/oracle/truffleruby/blob/788cb4c1ad98bcd275277aa59f53b029423af828/lib/truffle/rbconfig.rb#L112 So core C ext files paths are made relative to the ruby home.
So --inspect.SourcePath=TRUFFLERUBY_REPO should help.
Although --inspect.SourcePath is only for the Chrome Inspector protocol, I don't see the DAP equivalent option.
Maybe it's supposed to be configured in the IDE somehow? cc @entlicher
Currently, there is no option like --dap.SourcePath. We will add this.
A workaround until then is to remove the cppflags << relative_debug_paths line in rbconfig.rb if you build & debug on the same machine, then core C ext files will simply have absolute file names.
I may have had this issue too narrowly scoped. I've been trying to debug an issue with the commonmarker gem. The "Loaded Scripts" section correctly shows the extension source files under ext/commonmarker/ (e.g., ext/commonmarker/node.c), but the debugger tries to load them relative to the current working directory (e.g., <proj_root>/node.c).
I removed the relative_debug_paths line in rbconfig.rb and that fixed the native extension debugging as well. As I understand, --dap.SourcePath wouldn't fix this because we'd have multiple locations: the TruffleRuby checkout for stdlib and the gem source directory for each native extension.
I removed the
relative_debug_pathsline in rbconfig.rb and that fixed the native extension debugging as well.
That's very strange. relative_debug_paths is only used if Truffle::Boot.get_option 'building-core-cexts', so that should not apply to commonmarker C files which is not a core C ext.
--inspect.SourcePath supports multiple paths so this is not directly an issue, but --inspect.SourcePath should only be needed for core extensions, other extensions should simply use absolute paths and just work.
Maybe this is simply a bug in the path resolution of the DAP debugger? It doesn't explain why changing relative_debug_paths would change anything though.