-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[lldb][InstrumentationRuntime] Run sanitizer utility expressions as C #172019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][InstrumentationRuntime] Run sanitizer utility expressions as C #172019
Conversation
|
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesThe utility expressions in the 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:
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.
|
|
Might need a |
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
9e1ab2a to
764d04c
Compare
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
adrian-prantl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frankly, I probably wouldn't even have bothered with a test for this...
| @@ -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 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: double pasted comment here.
DanBlackwell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Yea removed the tests because we don't have Shell test infrastructure to require presence of |
…llvm#172019) 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 (cherry picked from commit d7cbc7f)
…llvm#172019) 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 (cherry picked from commit d7cbc7f)
…llvm#172019) 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
The utility expressions in the
InstrumentationRuntimeplugins are just plain C code, but we run them asObjC++. 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 toC.Didn't find a great way of testing this other than looking at the expression log.
rdar://165656320