llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) <details> <summary>Changes</summary> The utility expressions in the `InstrumentationRuntime` plugins are just plain C code, but we run them as `ObjC++`. That meant we were doing redundant work (like looking up decls in the Objective-C runtime). The sanitizer tests sporadically time out while looking up function symbols in the Objective-C runtime. This patch switches the expression language to `C`. Didn't find a great way of testing this other than looking at the expression log. rdar://165656320 --- Full diff: https://github.com/llvm/llvm-project/pull/172019.diff 6 Files Affected: - (modified) lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp (+1-1) - (modified) lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp (+1-1) - (modified) lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp (+1-1) - (added) lldb/test/Shell/Expr/TestASanReportExprNoObjC.test (+22) - (added) lldb/test/Shell/Expr/TestTSanReportExprNoObjC.test (+34) - (added) lldb/test/Shell/Expr/TestUBSanReportExprNoObjC.test (+24) ``````````diff diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp index 498da3ffe5a4a..7db971556a2f0 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp @@ -319,7 +319,7 @@ StructuredData::ObjectSP InstrumentationRuntimeTSan::RetrieveReportData( options.SetTimeout(process_sp->GetUtilityExpressionTimeout()); options.SetPrefix(thread_sanitizer_retrieve_report_data_prefix); options.SetAutoApplyFixIts(false); - options.SetLanguage(eLanguageTypeObjC_plus_plus); + options.SetLanguage(eLanguageTypeC); ValueObjectSP main_value; ExecutionContext exe_ctx; diff --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp index 565fd353a98e5..1db85e6815636 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp @@ -124,7 +124,7 @@ StructuredData::ObjectSP InstrumentationRuntimeUBSan::RetrieveReportData( options.SetTimeout(process_sp->GetUtilityExpressionTimeout()); options.SetPrefix(ub_sanitizer_retrieve_report_data_prefix); options.SetAutoApplyFixIts(false); - options.SetLanguage(eLanguageTypeObjC_plus_plus); + options.SetLanguage(eLanguageTypeC); ValueObjectSP main_value; ExecutionContext exe_ctx; diff --git a/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp b/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp index 3642cb18c7a97..85852ba40c61c 100644 --- a/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp +++ b/lldb/source/Plugins/InstrumentationRuntime/Utility/ReportRetriever.cpp @@ -81,7 +81,7 @@ ReportRetriever::RetrieveReportData(const ProcessSP process_sp) { options.SetTimeout(process_sp->GetUtilityExpressionTimeout()); options.SetPrefix(address_sanitizer_retrieve_report_data_prefix); options.SetAutoApplyFixIts(false); - options.SetLanguage(eLanguageTypeObjC_plus_plus); + options.SetLanguage(eLanguageTypeC); if (auto [m, _] = GetPreferredAsanModule(process_sp->GetTarget()); m) { SymbolContextList sc_list; diff --git a/lldb/test/Shell/Expr/TestASanReportExprNoObjC.test b/lldb/test/Shell/Expr/TestASanReportExprNoObjC.test new file mode 100644 index 0000000000000..6d50ca264b107 --- /dev/null +++ b/lldb/test/Shell/Expr/TestASanReportExprNoObjC.test @@ -0,0 +1,22 @@ +# Tests that the ASan Instrumentation Runtime's utility expression +# runs as C (and doesn't try to find decls in the ObjC runtime). +# +# RUN: split-file %s %t +# RUN: %clangxx_host -g %t/main.cpp -fsanitize=address -o %t.out +# +# RUN: %lldb -s %t/commands.input %t.out -o exit \ +# RUN: | FileCheck %s --implicit-check-not="AppleObjCVendor" + +#--- main.cpp + +int main() { + int a[5] = {0}; + + return a[10]; +} + +#--- commands.input +log enable lldb expr +run + +# CHECK: Picked c for expression evaluation. diff --git a/lldb/test/Shell/Expr/TestTSanReportExprNoObjC.test b/lldb/test/Shell/Expr/TestTSanReportExprNoObjC.test new file mode 100644 index 0000000000000..fe1ea3f4f28f4 --- /dev/null +++ b/lldb/test/Shell/Expr/TestTSanReportExprNoObjC.test @@ -0,0 +1,34 @@ +# Tests that the TSan Instrumentation Runtime's utility expression +# runs as C (and doesn't try to find decls in the ObjC runtime). +# +# RUN: split-file %s %t +# RUN: %clangxx_host -std=c++11 -g %t/main.cpp -fsanitize=thread -o %t.out +# +# RUN: %lldb -s %t/commands.input %t.out -o exit \ +# RUN: | FileCheck %s --implicit-check-not="AppleObjCVendor" + +#--- main.cpp + +#include <thread> + +char c = '\0'; + +void f() { + c = 'x'; +} + +int main() { + std::thread t1(f); + std::thread t2(f); + + t1.join(); + t2.join(); +} + +#--- commands.input +log enable lldb expr +run + +# CHECK: Picked c for expression evaluation. + + diff --git a/lldb/test/Shell/Expr/TestUBSanReportExprNoObjC.test b/lldb/test/Shell/Expr/TestUBSanReportExprNoObjC.test new file mode 100644 index 0000000000000..39fb9b41a5fed --- /dev/null +++ b/lldb/test/Shell/Expr/TestUBSanReportExprNoObjC.test @@ -0,0 +1,24 @@ +# Tests that the UBSan Instrumentation Runtime's utility expression +# runs as C (and doesn't try to find decls in the ObjC runtime). +# Tests that the UBSan Instrumentation Runtime's utility expression +# runs as C (and doesn't try to find decls in the ObjC runtime). +# +# RUN: split-file %s %t +# RUN: %clangxx_host -g %t/main.cpp -fsanitize=undefined -o %t.out +# +# RUN: %lldb -s %t/commands.input %t.out -o exit \ +# RUN: | FileCheck %s --implicit-check-not="AppleObjCVendor" + +#--- main.cpp + +int main() { + int *p = nullptr; + + return *p; +} + +#--- commands.input +log enable lldb expr +run + +# CHECK: Picked c for expression evaluation. `````````` </details> https://github.com/llvm/llvm-project/pull/172019 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
