[Lldb-commits] [lldb] [LLDB] Add integration test for libsanitizers trace collection (PR #134323)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 3 17:48:37 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
----------------
jimingham wrote:
Cool! I had to puzzle out why it was legit to call check_traces before and after the result. The point is you are stopping "before the report but after the allocation and deallocation" so the pointer history is the same. Might leave a comment to that effect to prevent some head scratching in the next person who comes through this.
https://github.com/llvm/llvm-project/pull/134323
More information about the lldb-commits
mailing list