This is an archive of the discontinued LLVM Phabricator instance.

[lldb][import-std-module] Do some basic file checks before trying to import a module
ClosedPublic

Authored by teemperor on Jan 20 2021, 2:36 PM.

Details

Summary

Currently when LLDB has enough data in the debug information to import the std module,
it will just try to import it. However when debugging libraries where the sources aren't
available anymore, importing the module will generate a confusing diagnostic that
the module couldn't be built.

For the fallback mode (where we retry failed expressions with the loaded module), this
will cause the second expression to fail with a module built error instead of the
actual parsing issue in the user expression.

This patch adds checks that ensures that we at least have any source files in the found
include paths before we try to import the module. This prevents the module from being
loaded in the situation described above which means we don't emit the bogus 'can't
import module' diagnostic and also don't waste any time retrying the expression in the
fallback mode.

For the unit tests I did some refactoring as they now require a VFS with the files in it
and not just the paths. The Python test just builds a binary with a fake C++ module,
then deletes the module before debugging.

Fixes rdar://73264458

Diff Detail

Event Timeline

teemperor requested review of this revision.Jan 20 2021, 2:36 PM
teemperor created this revision.
teemperor edited the summary of this revision. (Show Details)Jan 20 2021, 2:47 PM
JDevlieghere requested changes to this revision.Jan 20 2021, 3:20 PM
JDevlieghere added inline comments.
lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
78

llvm::sys::path::append

88

The policy is that you should use the FileSystem instance unless (1) you're passing off the VFS to clang/swift (which tracks its own dependencies) or (2) when you explicitly want to bypass it for the reproducers. To spoof things in the unittests you can initialize the FileSystem with a custom VFS to achieve the same result.

This revision now requires changes to proceed.Jan 20 2021, 3:20 PM

LGTM, I will let Jonas approve since he has some issues that need addressing.

teemperor updated this revision to Diff 318068.Jan 20 2021, 5:04 PM
  • using llvm's path::append
  • Now initializing and using the global FileSystem instance
  • Added some stub files to tests with fake libc++ roots to make them pass the new detection mechanism.
This revision is now accepted and ready to land.Jan 20 2021, 8:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2021, 3:33 AM