Files
llvm-project/lldb/test/Shell/Expr/TestClangModuleLoadError_InvalidSearchPath.test
Michael Buch d5b62fabd1 [lldb][ClangModulesDeclVendor] Print Clang module loading errors to expression log instead of console (#166964)
Depends on:
* https://github.com/llvm/llvm-project/pull/166917
* https://github.com/llvm/llvm-project/pull/166940

While these errors can contribute to an expression failing, they are
never *the* reason the expression failed. I.e., they are always just
'note:' diagnostics that we hand-emit. Because they are quite noisy (and
we potentially have many of them if we auto-load all modules in a CU),
this patch logs the errors to the `expr` log, instead of the console.

Previously these errors would only get omitted when the expression
itself failed. Meaning if the expression failed, we'd dump these 'note'
module load errors in next to the actual expression error, obscuring the
output. Moreover, if the expression succeeded, any module load errors
would be dropped. Now we always log all module loading errors to the
expression log, regardless of whether the expression fails or not.
2025-11-08 00:21:03 +00:00

60 lines
1.7 KiB
Plaintext

## Tests the case where the DW_AT_LLVM_include_path of the module is invalid.
## We forces this by just removing that directory (which in our case is 'sources').
#
# REQUIRES: system-darwin
#
# RUN: split-file %s %t/sources
# RUN: %clang_host -g %t/sources/main.m -fmodules -fcxx-modules \
# RUN: -fmodule-map-file=%t/sources/module.modulemap \
# RUN: -fmodules-cache-path=%t/ModuleCache -o %t.out
#
# RUN: cp %t/sources/commands.input %t/commands.input
# RUN: cp %t/sources/commands-with-log.input %t/commands-with-log.input
# RUN: rm -r %t/sources
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/commands.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=NO_LOG
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG
#--- main.m
@import foo;
@import bar;
int main() { __builtin_debugtrap(); }
#--- foo.h
struct foo {};
#--- bar.h
struct bar {};
#--- module.modulemap
module foo {
header "foo.h"
export *
}
module bar {
header "bar.h"
export *
}
#--- commands.input
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah
# NO_LOG-NOT: couldn't find module search path directory {{.*}}sources
# NO_LOG-NOT: couldn't find module search path directory {{.*}}sources
#--- commands-with-log.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah
# LOG: couldn't find module search path directory {{.*}}sources
# LOG: couldn't find module search path directory {{.*}}sources