Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,12 @@ static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target,
if (!err)
return;

// FIXME: should we be dumping these to the error log instead of as
// diagnostics? They are non-fatal and are usually quite noisy.
llvm::handleAllErrors(
std::move(err), [&diagnostic_manager](const llvm::StringError &e) {
diagnostic_manager.PutString(lldb::eSeverityInfo, e.getMessage());
});
// Module load errors aren't fatal to the expression evaluator. Printing
// them as diagnostics to the console would be too noisy and misleading
// Hence just print them to the expression log.
llvm::handleAllErrors(std::move(err), [](const llvm::StringError &e) {
LLDB_LOG(GetLog(LLDBLog::Expressions), "{0}", e.getMessage());
});
}

ClangExpressionSourceCode::WrapKind ClangUserExpression::GetWrapKind() const {
Expand Down
5 changes: 0 additions & 5 deletions lldb/test/API/lang/objc/modules-compile-error/Makefile

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions lldb/test/API/lang/objc/modules-compile-error/main.m

This file was deleted.

5 changes: 0 additions & 5 deletions lldb/test/API/lang/objc/modules-compile-error/module.h

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
## Tests the case where module compilation fails.
#
# REQUIRES: system-darwin
#
# RUN: split-file %s %t/sources
# RUN: %clang_host -g %t/sources/main.m -fmodules -fcxx-modules \
# RUN: -DSHOULD_COMPILE=1 \
# RUN: -fmodule-map-file=%t/sources/module.modulemap \
# RUN: -fmodules-cache-path=%t/ModuleCache -o %t.out
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s

#--- main.m
@import foo;

int main() { __builtin_debugtrap(); }

#--- foo.h
struct foo {};

#ifndef SHOULD_COMPILE
#error "Compilation failure."
#endif

#--- module.modulemap
module foo {
header "foo.h"
export *
}

#--- commands.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: Finished building Clang module foo
# CHECK: couldn't load top-level module foo:
# CHECK: While building module 'foo' imported from LLDBModulesMemoryBuffer
# CHEKC: {{.*}}sources/foo.h{{.*}}: error: "Compilation failure."
# CHECK: LLDBModulesMemoryBuffer:1:1: fatal error: could not build module 'foo'

# CHECK: Error while loading hand-imported modules:
# CHECK: couldn't load top-level module foo:
# CHECK-NOT: Compilation failure
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
# RUN: sed -i '' -e 's/module qux/module quz/' %t/sources/module.modulemap
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s
# RUN: -s %t/sources/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/sources/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG

#--- main.m
@import foo.baz.qux;
Expand Down Expand Up @@ -56,4 +59,12 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: couldn't load submodule 'qux' of module 'foo.baz'
# NO_LOG-NOT: couldn't load submodule 'qux' of module 'foo.baz'

#--- commands-with-log.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# LOG: couldn't load submodule 'qux' of module 'foo.baz'
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
# 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
# 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;
Expand Down Expand Up @@ -42,5 +46,14 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: couldn't find module search path directory {{.*}}sources
# CHECK: note: couldn't find module search path directory {{.*}}sources
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
# RUN: sed -i '' -e 's/module baz/module qux/' %t/sources/module.modulemap
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s
# RUN: -s %t/sources/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/sources/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG

#--- main.m
@import foo.baz;
Expand Down Expand Up @@ -48,4 +51,12 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: couldn't load submodule 'baz' of module 'foo'
# NO_LOG-NOT: couldn't load submodule 'baz' of module 'foo'

#--- commands-with-log.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# LOG: couldn't load submodule 'baz' of module 'foo'
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# RUN: sed -i '' -e 's/bar\.h/qux\.h/' %t/sources/module.modulemap
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s
# RUN: -s %t/sources/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/sources/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG

#--- main.m
@import foo;
Expand Down Expand Up @@ -41,9 +44,16 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: couldn't load top-level module foo
## FIXME: clang error diagnostic shouldn't be dumped to the console.
# CHECK: error:
# CHECK: note: couldn't load top-level module bar
## FIXME: clang error diagnostic shouldn't be dumped to the console.
# CHECK: error:
# NO_LOG-NOT: couldn't load top-level module foo
# NO_LOG-NOT: error: header

#--- commands-with-log.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# LOG: couldn't load top-level module foo
# LOG: error: header 'baz.h'
# LOG: couldn't load top-level module bar
# LOG: error: header 'qux.h'
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# RUN: sed -i '' -e 's/module foo/module bar/' %t/sources/module.modulemap
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s
# RUN: -s %t/sources/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/sources/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG

#--- main.m
@import foo;
Expand Down Expand Up @@ -41,5 +44,14 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: failed to parse and load modulemap file in {{.*}}sources
# CHECK: note: failed to parse and load modulemap file in {{.*}}sources
# NO_LOG-NOT: failed to parse and load
# NO_LOG-NOT: failed to parse and load

#--- commands-with-log.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# LOG: failed to parse and load modulemap file in {{.*}}sources
# LOG: failed to parse and load modulemap file in {{.*}}sources
18 changes: 15 additions & 3 deletions lldb/test/Shell/Expr/TestClangModuleLoadError_NoModule.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# RUN: sed -i '' -e 's/module bar/module qux/' %t/sources/module.modulemap
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s
# RUN: -s %t/sources/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/sources/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG

#--- main.m
@import foo;
Expand Down Expand Up @@ -42,5 +45,14 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: header search couldn't locate module 'foo'
# CHECK: note: header search couldn't locate module 'bar'
# NO_LOG-NOT: header search couldn't locate module 'foo'
# NO_LOG-NOT: header search couldn't locate module 'bar'

#--- commands-with-log.input
log enable lldb expr
run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# LOG: header search couldn't locate module 'foo'
# LOG: header search couldn't locate module 'bar'
18 changes: 15 additions & 3 deletions lldb/test/Shell/Expr/TestClangModuleLoadError_NoModuleMap.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
# RUN: rm %t/sources/module.modulemap
#
# RUN: %lldb -x -o "settings set interpreter.stop-command-source-on-error false" \
# RUN: -s %t/sources/commands.input %t.out -o exit 2>&1 | FileCheck %s
# RUN: -s %t/sources/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/sources/commands-with-log.input %t.out -o exit 2>&1 | FileCheck %s --check-prefix=LOG

#--- main.m
@import foo;
Expand Down Expand Up @@ -37,5 +40,14 @@ run
## Make sure expression fails so the 'note' diagnostics get printed.
expr blah

# CHECK: note: couldn't find modulemap file in {{.*}}sources
# CHECK: note: couldn't find modulemap file in {{.*}}sources
# NO_LOG-NOT: couldn't find modulemap
# NO_LOG-NOT: couldn't find modulemap

#--- 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 modulemap file in {{.*}}sources
# LOG: couldn't find modulemap file in {{.*}}sources
Loading