[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)
Julian Lettner via lldb-commits
lldb-commits at lists.llvm.org
Fri Apr 4 14:50:31 PDT 2025
================
@@ -36,34 +42,61 @@ def setUp(self):
self.line_breakpoint = line_number("main.c", "// break line")
# Test line numbers: rdar://126237493
- def libsanitizer_tests(self):
- target = self.createTestTarget()
+ # for libsanitizers and remove `skip_line_numbers` parameter
+ def check_traces(self, skip_line_numbers):
+ self.expect(
+ "memory history 'pointer'",
+ substrs=[
+ "Memory deallocated by Thread",
+ "a.out`f2",
+ "main.c" if skip_line_numbers else f"main.c:{self.line_free}",
+ "Memory allocated by Thread",
+ "a.out`f1",
+ "main.c" if skip_line_numbers else f"main.c:{self.line_malloc}",
+ ],
+ )
+
+ def libsanitizers_traces_tests(self):
+ self.createTestTarget()
+
+ self.runCmd("env SanitizersAllocationTraces=all")
- self.runCmd(
- "env SanitizersAddress=1 MallocSanitizerZone=1 MallocSecureAllocator=0"
+ self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
+ self.runCmd("run")
+
+ # Stop on breakpoint, before report
+ self.expect(
+ "thread list",
+ STOPPED_DUE_TO_BREAKPOINT,
+ substrs=["stopped", "stop reason = breakpoint"],
)
+ self.check_traces(skip_line_numbers=True)
+
+ def libsanitizers_asan_tests(self):
+ self.createTestTarget()
+
+ self.runCmd("env SanitizersAddress=1 MallocSanitizerZone=1")
+ self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
self.runCmd("run")
- # In libsanitizers, memory history is not supported until a report has been generated
----------------
yln wrote:
Extracted common functions `set_breakpoint()` and `run_to_breakpoint()` and added comment:
```
# Set breakpoint after free, but before bug
def set_breakpoint(self):
```
https://github.com/llvm/llvm-project/pull/134323
More information about the lldb-commits
mailing list