================ @@ -36,35 +42,59 @@ def setUp(self): self.line_breakpoint = line_number("main.c", "// break line") # Test line numbers: rdar://126237493 - def libsanitizer_tests(self): - target = self.createTestTarget() - - self.runCmd( - "env SanitizersAddress=1 MallocSanitizerZone=1 MallocSecureAllocator=0" - ) - - self.runCmd("run") - - # In libsanitizers, memory history is not supported until a report has been generated - self.expect( - "thread list", - "Process should be stopped due to ASan report", - substrs=["stopped", "stop reason = Use of deallocated memory"], - ) - - # test the 'memory history' command + # for libsanitizers and remove `skip_line_numbers` parameter + def check_traces(self, skip_line_numbers=False): self.expect( "memory history 'pointer'", substrs=[ "Memory deallocated by Thread", "a.out`f2", - "main.c", + "main.c" if skip_line_numbers else f"main.c:{self.line_free}", "Memory allocated by Thread", "a.out`f1", - "main.c", + "main.c" if skip_line_numbers else f"main.c:{self.line_malloc}", ], ) + # Set breakpoint after free, but before bug + def set_breakpoint(self): + self.runCmd(f"breakpoint set -f main.c -l {self.line_breakpoint}") ---------------- jimingham wrote:
It's better for your sanity to set breakpoints like: # Now set a breakpoint that we will hit by running our scripted step. bkpt = target.BreakpointCreateBySourceRegex( "// break here", lldb.SBFileSpec("main.c") ) self.assertGreater( bkpt.GetNumLocations(), 0, "Set the breakpoint successfully" ) The reason being that runCmd will only fail if the command you are running fails but setting a breakpoint almost never fails - since all lldb breakpoints are the equivalent of gdb "future-break". So some day your test will fail because you accidentally changed the that comment, and you'll waste some time wondering how that could possibly have happened. Whereas this version will tell you right away what went wrong. 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