[asan] Display ASan history threads in reverse chronological order

For use-after-free bugs caught by ASan, we show an allocation and a deallocation stack trace. Let's display them in a "most recent event first" order, this patch does that.

Differential Revision: http://reviews.llvm.org/D11295

llvm-svn: 242902
This commit is contained in:
Kuba Brecka 2015-07-22 14:30:56 +00:00
parent 322deb911e
commit 5e73d2523f
2 changed files with 4 additions and 4 deletions

View File

@ -176,8 +176,8 @@ MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address)
HistoryThreads result;
CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result);
CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free", "Memory deallocated at", result);
CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc", "Memory allocated at", result);
return result;
}

View File

@ -86,18 +86,18 @@ class AsanTestCase(TestBase):
history_thread = threads.GetThreadAtIndex(0)
self.assertTrue(history_thread.num_frames >= 2)
self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc)
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_free)
history_thread = threads.GetThreadAtIndex(1)
self.assertTrue(history_thread.num_frames >= 2)
self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_free)
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc)
# let's free the container (SBThreadCollection) and see if the SBThreads still live
threads = None
self.assertTrue(history_thread.num_frames >= 2)
self.assertEqual(history_thread.frames[1].GetLineEntry().GetFileSpec().GetFilename(), "main.c")
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_free)
self.assertEqual(history_thread.frames[1].GetLineEntry().GetLine(), self.line_malloc)
# now let's break when an ASan report occurs and try the API then
self.runCmd("breakpoint set -n __asan_report_error")