================ @@ -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 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits