[Lldb-commits] [lldb] r307881 - Upstreaming a patch from Github: When evaluation user expressions, ignore InstrumentationRuntime breakpoints. (#235)
Kuba Mracek via lldb-commits
lldb-commits at lists.llvm.org
Wed Jul 12 21:35:27 PDT 2017
Author: kuba.brecka
Date: Wed Jul 12 21:35:27 2017
New Revision: 307881
URL: http://llvm.org/viewvc/llvm-project?rev=307881&view=rev
Log:
Upstreaming a patch from Github: When evaluation user expressions, ignore InstrumentationRuntime breakpoints. (#235)
Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/
lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c
Modified:
lldb/trunk/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
lldb/trunk/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
lldb/trunk/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
lldb/trunk/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile?rev=307881&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/Makefile Wed Jul 12 21:35:27 2017
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -fsanitize=undefined -g
+
+include $(LEVEL)/Makefile.rules
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py?rev=307881&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/TestUbsanUserExpression.py Wed Jul 12 21:35:27 2017
@@ -0,0 +1,49 @@
+"""
+Test that hitting a UBSan issue while running user expression doesn't break the evaluation.
+"""
+
+import os
+import time
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+import lldbsuite.test.lldbutil as lldbutil
+import json
+
+
+class UbsanUserExpressionTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipUnlessUndefinedBehaviorSanitizer
+ def test(self):
+ self.build()
+ self.ubsan_tests()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ self.line_breakpoint = line_number('main.c', '// breakpoint line')
+
+ def ubsan_tests(self):
+ # Load the test
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.expect(
+ "file " + exe,
+ patterns=["Current executable set to .*a.out"])
+
+ self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
+
+ self.runCmd("run")
+
+ process = self.dbg.GetSelectedTarget().process
+ thread = process.GetSelectedThread()
+ frame = thread.GetSelectedFrame()
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
+
+ self.expect("p foo()", substrs=["(int) $0 = 42"])
+
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs=['stopped', 'stop reason = breakpoint'])
Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c?rev=307881&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/ubsan/user-expression/main.c Wed Jul 12 21:35:27 2017
@@ -0,0 +1,9 @@
+int foo() {
+ int data[4];
+ int x = *(int *)(((char *)&data[0]) + 2);
+ return 42;
+}
+
+int main() {
+ return 0; // breakpoint line
+}
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp?rev=307881&r1=307880&r2=307881&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp Wed Jul 12 21:35:27 2017
@@ -247,12 +247,16 @@ bool AddressSanitizerRuntime::NotifyBrea
AddressSanitizerRuntime *const instance =
static_cast<AddressSanitizerRuntime *>(baton);
+ ProcessSP process_sp = instance->GetProcessSP();
+
+ if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
+ return false;
+
StructuredData::ObjectSP report = instance->RetrieveReportData();
std::string description;
if (report) {
description = instance->FormatDescription(report);
}
- ProcessSP process_sp = instance->GetProcessSP();
// Make sure this is the right process
if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP()) {
ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp?rev=307881&r1=307880&r2=307881&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp Wed Jul 12 21:35:27 2017
@@ -163,6 +163,9 @@ bool MainThreadCheckerRuntime::NotifyBre
process_sp != context->exe_ctx_ref.GetProcessSP())
return false;
+ if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
+ return false;
+
StructuredData::ObjectSP report =
instance->RetrieveReportData(context->exe_ctx_ref);
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp?rev=307881&r1=307880&r2=307881&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp Wed Jul 12 21:35:27 2017
@@ -803,6 +803,11 @@ bool ThreadSanitizerRuntime::NotifyBreak
ThreadSanitizerRuntime *const instance =
static_cast<ThreadSanitizerRuntime *>(baton);
+ ProcessSP process_sp = instance->GetProcessSP();
+
+ if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
+ return false;
+
StructuredData::ObjectSP report =
instance->RetrieveReportData(context->exe_ctx_ref);
std::string stop_reason_description;
@@ -851,7 +856,6 @@ bool ThreadSanitizerRuntime::NotifyBreak
all_addresses_are_same);
}
- ProcessSP process_sp = instance->GetProcessSP();
// Make sure this is the right process
if (process_sp && process_sp == context->exe_ctx_ref.GetProcessSP()) {
ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp?rev=307881&r1=307880&r2=307881&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp Wed Jul 12 21:35:27 2017
@@ -217,6 +217,9 @@ bool UndefinedBehaviorSanitizerRuntime::
process_sp != context->exe_ctx_ref.GetProcessSP())
return false;
+ if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
+ return false;
+
StructuredData::ObjectSP report =
instance->RetrieveReportData(context->exe_ctx_ref);
More information about the lldb-commits
mailing list