diff options
author | Kuba Brecka <kuba.brecka@gmail.com> | 2014-09-06 01:33:13 +0000 |
---|---|---|
committer | Kuba Brecka <kuba.brecka@gmail.com> | 2014-09-06 01:33:13 +0000 |
commit | a51ea3822a47e0f873261af8a684eba8308abeff (patch) | |
tree | 58d4bbccd61e6545ca66e1cbd0867791c2ec8d42 | |
parent | edc44140947e4e3721e2a44e527b8b538451271d (diff) | |
download | bcm5719-llvm-a51ea3822a47e0f873261af8a684eba8308abeff.tar.gz bcm5719-llvm-a51ea3822a47e0f873261af8a684eba8308abeff.zip |
Implement ASan history threads in SB API
Reviewed at
http://reviews.llvm.org/D5219
and
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140901/012809.html
llvm-svn: 217300
-rw-r--r-- | lldb/include/lldb/API/SBProcess.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Process.h | 3 | ||||
-rw-r--r-- | lldb/scripts/Python/interface/SBProcess.i | 3 | ||||
-rw-r--r-- | lldb/source/API/SBProcess.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Target/Process.cpp | 17 | ||||
-rw-r--r-- | lldb/test/functionalities/asan/TestAsan.py | 18 |
6 files changed, 57 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4b59462ca3f..5ddb0290998 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -316,6 +316,9 @@ public: //------------------------------------------------------------------ const char * GetExtendedBacktraceTypeAtIndex (uint32_t idx); + + lldb::SBThreadCollection + GetHistoryThreads (addr_t addr); protected: friend class SBAddress; diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 9d08541a21a..96885b609b1 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -2922,6 +2922,9 @@ public: Error return_error ("Sending an event is not supported for this process."); return return_error; } + + lldb::ThreadCollectionSP + GetHistoryThreads(lldb::addr_t addr); protected: diff --git a/lldb/scripts/Python/interface/SBProcess.i b/lldb/scripts/Python/interface/SBProcess.i index 5cd99c0296c..dce930c350b 100644 --- a/lldb/scripts/Python/interface/SBProcess.i +++ b/lldb/scripts/Python/interface/SBProcess.i @@ -389,6 +389,9 @@ public: const char * GetExtendedBacktraceTypeAtIndex (uint32_t idx); + lldb::SBThreadCollection + GetHistoryThreads (addr_t addr); + %pythoncode %{ def __get_is_alive__(self): '''Returns "True" if the process is currently alive, "False" otherwise''' diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 41efd86177d..7b519b16bd1 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -38,6 +38,7 @@ #include "lldb/API/SBEvent.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBThread.h" +#include "lldb/API/SBThreadCollection.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBStringList.h" #include "lldb/API/SBUnixSignals.h" @@ -1381,3 +1382,15 @@ SBProcess::GetExtendedBacktraceTypeAtIndex (uint32_t idx) } return NULL; } + +SBThreadCollection +SBProcess::GetHistoryThreads (addr_t addr) +{ + ProcessSP process_sp(GetSP()); + SBThreadCollection threads; + if (process_sp) + { + threads = SBThreadCollection(process_sp->GetHistoryThreads(addr)); + } + return threads; +} diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 02f96358433..28f02359b74 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -32,6 +32,7 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/JITLoader.h" +#include "lldb/Target/MemoryHistory.h" #include "lldb/Target/OperatingSystem.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/CPPLanguageRuntime.h" @@ -6022,3 +6023,19 @@ Process::ModulesDidLoad (ModuleList &module_list) GetJITLoaders().ModulesDidLoad (module_list); } + +ThreadCollectionSP +Process::GetHistoryThreads(lldb::addr_t addr) +{ + ThreadCollectionSP threads; + + const MemoryHistorySP &memory_history = MemoryHistory::FindPlugin(shared_from_this()); + + if (! memory_history.get()) { + return threads; + } + + threads.reset(new ThreadCollection(memory_history->GetHistoryThreads(addr))); + + return threads; +} diff --git a/lldb/test/functionalities/asan/TestAsan.py b/lldb/test/functionalities/asan/TestAsan.py index ba4b4e72e52..a687e268752 100644 --- a/lldb/test/functionalities/asan/TestAsan.py +++ b/lldb/test/functionalities/asan/TestAsan.py @@ -70,6 +70,24 @@ class AsanTestCase(TestBase): 'Memory allocated at', 'a.out`f1', 'main.c:%d' % self.line_malloc, 'Memory deallocated at', 'a.out`f2', 'main.c:%d' % self.line_free]) + # do the same using SB API + process = self.dbg.GetSelectedTarget().process + val = process.GetSelectedThread().GetSelectedFrame().EvaluateExpression("pointer") + addr = val.GetValueAsUnsigned() + threads = process.GetHistoryThreads(addr); + self.assertEqual(threads.GetSize(), 2) + + 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) + + 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) + + # now let's break when an ASan report occurs and try the API then self.runCmd("breakpoint set -n __asan_report_error") self.runCmd("continue") |