kubamracek created this revision.
kubamracek added a project: Sanitizers.
Herald added a subscriber: mgorny.
There is currently a single MemoryHistory plugin, which is for
AddressSanitizer. Let's merge the feature into InstrumentationRuntime plugins.
I'm thinking of implementing another provider of memory history, which would
be for ThreadSanitizer -- and it would be weird to implement two separate
plugins (MemoryHistory and InstrumentationRuntime) to each sanitizer.
https://reviews.llvm.org/D30006
Files:
include/lldb/Core/PluginManager.h
include/lldb/Target/InstrumentationRuntime.h
include/lldb/Target/MemoryHistory.h
include/lldb/lldb-forward.h
include/lldb/lldb-private-interfaces.h
lldb.xcodeproj/project.pbxproj
source/API/SystemInitializerFull.cpp
source/Commands/CommandObjectMemory.cpp
source/Core/PluginManager.cpp
source/Plugins/CMakeLists.txt
source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
source/Plugins/MemoryHistory/CMakeLists.txt
source/Plugins/MemoryHistory/asan/CMakeLists.txt
source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
source/Target/CMakeLists.txt
source/Target/InstrumentationRuntime.cpp
source/Target/MemoryHistory.cpp
source/Target/Process.cpp
Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -47,7 +47,6 @@
#include "lldb/Target/JITLoader.h"
#include "lldb/Target/JITLoaderList.h"
#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/Target/MemoryHistory.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/OperatingSystem.h"
@@ -5983,14 +5982,14 @@
ThreadCollectionSP Process::GetHistoryThreads(lldb::addr_t addr) {
ThreadCollectionSP threads;
- const MemoryHistorySP &memory_history =
- MemoryHistory::FindPlugin(shared_from_this());
+ const InstrumentationRuntimeSP &runtime =
+ InstrumentationRuntime::FindMemoryHistoryPlugin(shared_from_this());
- if (!memory_history) {
+ if (!runtime) {
return threads;
}
- threads.reset(new ThreadCollection(memory_history->GetHistoryThreads(addr)));
+ threads.reset(new ThreadCollection(runtime->GetHistoryThreads(addr)));
return threads;
}
Index: source/Target/MemoryHistory.cpp
===================================================================
--- source/Target/MemoryHistory.cpp
+++ source/Target/MemoryHistory.cpp
@@ -1,33 +0,0 @@
-//===-- MemoryHistory.cpp ---------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Target/MemoryHistory.h"
-#include "lldb/Core/PluginManager.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-lldb::MemoryHistorySP MemoryHistory::FindPlugin(const ProcessSP process) {
- MemoryHistoryCreateInstance create_callback = nullptr;
-
- for (uint32_t idx = 0;
- (create_callback = PluginManager::GetMemoryHistoryCreateCallbackAtIndex(
- idx)) != nullptr;
- ++idx) {
- MemoryHistorySP memory_history_sp(create_callback(process));
- if (memory_history_sp)
- return memory_history_sp;
- }
-
- return MemoryHistorySP();
-}
Index: source/Target/InstrumentationRuntime.cpp
===================================================================
--- source/Target/InstrumentationRuntime.cpp
+++ source/Target/InstrumentationRuntime.cpp
@@ -78,3 +78,19 @@
StructuredData::ObjectSP info) {
return ThreadCollectionSP(new ThreadCollection());
}
+
+lldb::InstrumentationRuntimeSP
+InstrumentationRuntime::FindMemoryHistoryPlugin(const ProcessSP process) {
+ for (uint32_t idx = 0;; ++idx) {
+ InstrumentationRuntimeGetType get_type_callback =
+ PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(idx);
+ if (get_type_callback == nullptr)
+ break;
+ InstrumentationRuntimeType type = get_type_callback();
+ InstrumentationRuntimeSP runtime = process->GetInstrumentationRuntime(type);
+ if (runtime->CanProvideMemoryHistory())
+ return runtime;
+ }
+
+ return InstrumentationRuntimeSP();
+}
Index: source/Target/CMakeLists.txt
===================================================================
--- source/Target/CMakeLists.txt
+++ source/Target/CMakeLists.txt
@@ -12,7 +12,6 @@
Language.cpp
LanguageRuntime.cpp
Memory.cpp
- MemoryHistory.cpp
ModuleCache.cpp
ObjCLanguageRuntime.cpp
OperatingSystem.cpp
Index: source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
===================================================================
--- source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
+++ source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
@@ -1,53 +0,0 @@
-//===-- MemoryHistoryASan.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_MemoryHistoryASan_h_
-#define liblldb_MemoryHistoryASan_h_
-
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Target/ABI.h"
-#include "lldb/Target/MemoryHistory.h"
-#include "lldb/Target/Process.h"
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-
-class MemoryHistoryASan : public lldb_private::MemoryHistory {
-public:
- ~MemoryHistoryASan() override = default;
-
- static lldb::MemoryHistorySP
- CreateInstance(const lldb::ProcessSP &process_sp);
-
- static void Initialize();
-
- static void Terminate();
-
- static lldb_private::ConstString GetPluginNameStatic();
-
- lldb_private::ConstString GetPluginName() override {
- return GetPluginNameStatic();
- }
-
- uint32_t GetPluginVersion() override { return 1; }
-
- lldb_private::HistoryThreads GetHistoryThreads(lldb::addr_t address) override;
-
-private:
- MemoryHistoryASan(const lldb::ProcessSP &process_sp);
-
- lldb::ProcessWP m_process_wp;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_MemoryHistoryASan_h_
Index: source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
===================================================================
--- source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -1,204 +0,0 @@
-//===-- MemoryHistoryASan.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "MemoryHistoryASan.h"
-
-#include "lldb/Target/MemoryHistory.h"
-
-#include "Plugins/Process/Utility/HistoryThread.h"
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginInterface.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Target/ThreadList.h"
-#include "lldb/lldb-private.h"
-
-#include <sstream>
-
-using namespace lldb;
-using namespace lldb_private;
-
-MemoryHistorySP MemoryHistoryASan::CreateInstance(const ProcessSP &process_sp) {
- if (!process_sp.get())
- return NULL;
-
- Target &target = process_sp->GetTarget();
-
- const ModuleList &target_modules = target.GetImages();
- std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
- const size_t num_modules = target_modules.GetSize();
- for (size_t i = 0; i < num_modules; ++i) {
- Module *module_pointer = target_modules.GetModulePointerAtIndexUnlocked(i);
-
- const Symbol *symbol = module_pointer->FindFirstSymbolWithNameAndType(
- ConstString("__asan_get_alloc_stack"), lldb::eSymbolTypeAny);
-
- if (symbol != nullptr)
- return MemoryHistorySP(new MemoryHistoryASan(process_sp));
- }
-
- return MemoryHistorySP();
-}
-
-void MemoryHistoryASan::Initialize() {
- PluginManager::RegisterPlugin(
- GetPluginNameStatic(), "ASan memory history provider.", CreateInstance);
-}
-
-void MemoryHistoryASan::Terminate() {
- PluginManager::UnregisterPlugin(CreateInstance);
-}
-
-ConstString MemoryHistoryASan::GetPluginNameStatic() {
- static ConstString g_name("asan");
- return g_name;
-}
-
-MemoryHistoryASan::MemoryHistoryASan(const ProcessSP &process_sp) {
- if (process_sp)
- m_process_wp = process_sp;
-}
-
-const char *memory_history_asan_command_prefix = R"(
- extern "C"
- {
- size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, int *thread_id);
- size_t __asan_get_free_stack(void *addr, void **trace, size_t size, int *thread_id);
- }
-
- struct data {
- void *alloc_trace[256];
- size_t alloc_count;
- int alloc_tid;
-
- void *free_trace[256];
- size_t free_count;
- int free_tid;
- };
-)";
-
-const char *memory_history_asan_command_format =
- R"(
- data t;
-
- t.alloc_count = __asan_get_alloc_stack((void *)0x%)" PRIx64
- R"(, t.alloc_trace, 256, &t.alloc_tid);
- t.free_count = __asan_get_free_stack((void *)0x%)" PRIx64
- R"(, t.free_trace, 256, &t.free_tid);
-
- t;
-)";
-
-static void CreateHistoryThreadFromValueObject(ProcessSP process_sp,
- ValueObjectSP return_value_sp,
- const char *type,
- const char *thread_name,
- HistoryThreads &result) {
- std::string count_path = "." + std::string(type) + "_count";
- std::string tid_path = "." + std::string(type) + "_tid";
- std::string trace_path = "." + std::string(type) + "_trace";
-
- ValueObjectSP count_sp =
- return_value_sp->GetValueForExpressionPath(count_path.c_str());
- ValueObjectSP tid_sp =
- return_value_sp->GetValueForExpressionPath(tid_path.c_str());
-
- if (!count_sp || !tid_sp)
- return;
-
- int count = count_sp->GetValueAsUnsigned(0);
- tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1;
-
- if (count <= 0)
- return;
-
- ValueObjectSP trace_sp =
- return_value_sp->GetValueForExpressionPath(trace_path.c_str());
-
- if (!trace_sp)
- return;
-
- std::vector<lldb::addr_t> pcs;
- for (int i = 0; i < count; i++) {
- addr_t pc = trace_sp->GetChildAtIndex(i, true)->GetValueAsUnsigned(0);
- if (pc == 0 || pc == 1 || pc == LLDB_INVALID_ADDRESS)
- continue;
- pcs.push_back(pc);
- }
-
- HistoryThread *history_thread =
- new HistoryThread(*process_sp, tid, pcs, 0, false);
- ThreadSP new_thread_sp(history_thread);
- std::ostringstream thread_name_with_number;
- thread_name_with_number << thread_name << " Thread " << tid;
- history_thread->SetThreadName(thread_name_with_number.str().c_str());
- // Save this in the Process' ExtendedThreadList so a strong pointer retains
- // the object
- process_sp->GetExtendedThreadList().AddThread(new_thread_sp);
- result.push_back(new_thread_sp);
-}
-
-static constexpr std::chrono::seconds g_get_stack_function_timeout(2);
-
-HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) {
- HistoryThreads result;
-
- ProcessSP process_sp = m_process_wp.lock();
- if (!process_sp)
- return result;
-
- ThreadSP thread_sp =
- process_sp->GetThreadList().GetExpressionExecutionThread();
- if (!thread_sp)
- return result;
-
- StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
- if (!frame_sp)
- return result;
-
- ExecutionContext exe_ctx(frame_sp);
- ValueObjectSP return_value_sp;
- StreamString expr;
- Error eval_error;
- expr.Printf(memory_history_asan_command_format, address, address);
-
- EvaluateExpressionOptions options;
- options.SetUnwindOnError(true);
- options.SetTryAllThreads(true);
- options.SetStopOthers(true);
- options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_get_stack_function_timeout);
- options.SetPrefix(memory_history_asan_command_prefix);
- options.SetAutoApplyFixIts(false);
- options.SetLanguage(eLanguageTypeObjC_plus_plus);
-
- ExpressionResults expr_result = UserExpression::Evaluate(
- exe_ctx, options, expr.GetString(), "", return_value_sp, eval_error);
- if (expr_result != eExpressionCompleted) {
- process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf(
- "Warning: Cannot evaluate AddressSanitizer expression:\n%s\n",
- eval_error.AsCString());
- return result;
- }
-
- if (!return_value_sp)
- return result;
-
- CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free",
- "Memory deallocated by", result);
- CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc",
- "Memory allocated by", result);
-
- return result;
-}
Index: source/Plugins/MemoryHistory/asan/CMakeLists.txt
===================================================================
--- source/Plugins/MemoryHistory/asan/CMakeLists.txt
+++ source/Plugins/MemoryHistory/asan/CMakeLists.txt
@@ -1,9 +0,0 @@
-add_lldb_library(lldbPluginMemoryHistoryASan PLUGIN
- MemoryHistoryASan.cpp
-
- LINK_LIBS
- lldbCore
- lldbExpression
- lldbTarget
- lldbPluginProcessUtility
- )
Index: source/Plugins/MemoryHistory/CMakeLists.txt
===================================================================
--- source/Plugins/MemoryHistory/CMakeLists.txt
+++ source/Plugins/MemoryHistory/CMakeLists.txt
@@ -1 +0,0 @@
-add_subdirectory(asan)
Index: source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
===================================================================
--- source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
+++ source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h
@@ -43,6 +43,10 @@
virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
uint32_t GetPluginVersion() override { return 1; }
+
+ bool CanProvideMemoryHistory() override { return true; }
+
+ HistoryThreads GetHistoryThreads(lldb::addr_t address) override;
private:
AddressSanitizerRuntime(const lldb::ProcessSP &process_sp)
Index: source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
===================================================================
--- source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
+++ source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
@@ -25,9 +25,12 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
#include "llvm/ADT/StringSwitch.h"
+#include <sstream>
+
using namespace lldb;
using namespace lldb_private;
@@ -328,3 +331,137 @@
}
SetActive(false);
}
+
+
+const char *memory_history_asan_command_prefix = R"(
+extern "C"
+{
+ size_t __asan_get_alloc_stack(void *addr, void **trace, size_t size, int *thread_id);
+ size_t __asan_get_free_stack(void *addr, void **trace, size_t size, int *thread_id);
+}
+
+struct data {
+ void *alloc_trace[256];
+ size_t alloc_count;
+ int alloc_tid;
+
+ void *free_trace[256];
+ size_t free_count;
+ int free_tid;
+};
+)";
+
+const char *memory_history_asan_command_format =
+R"(
+data t;
+
+t.alloc_count = __asan_get_alloc_stack((void *)0x%)" PRIx64
+R"(, t.alloc_trace, 256, &t.alloc_tid);
+t.free_count = __asan_get_free_stack((void *)0x%)" PRIx64
+R"(, t.free_trace, 256, &t.free_tid);
+
+t;
+)";
+
+static void CreateHistoryThreadFromValueObject(ProcessSP process_sp,
+ ValueObjectSP return_value_sp,
+ const char *type,
+ const char *thread_name,
+ HistoryThreads &result) {
+ std::string count_path = "." + std::string(type) + "_count";
+ std::string tid_path = "." + std::string(type) + "_tid";
+ std::string trace_path = "." + std::string(type) + "_trace";
+
+ ValueObjectSP count_sp =
+ return_value_sp->GetValueForExpressionPath(count_path.c_str());
+ ValueObjectSP tid_sp =
+ return_value_sp->GetValueForExpressionPath(tid_path.c_str());
+
+ if (!count_sp || !tid_sp)
+ return;
+
+ int count = count_sp->GetValueAsUnsigned(0);
+ tid_t tid = tid_sp->GetValueAsUnsigned(0) + 1;
+
+ if (count <= 0)
+ return;
+
+ ValueObjectSP trace_sp =
+ return_value_sp->GetValueForExpressionPath(trace_path.c_str());
+
+ if (!trace_sp)
+ return;
+
+ std::vector<lldb::addr_t> pcs;
+ for (int i = 0; i < count; i++) {
+ addr_t pc = trace_sp->GetChildAtIndex(i, true)->GetValueAsUnsigned(0);
+ if (pc == 0 || pc == 1 || pc == LLDB_INVALID_ADDRESS)
+ continue;
+ pcs.push_back(pc);
+ }
+
+ HistoryThread *history_thread =
+ new HistoryThread(*process_sp, tid, pcs, 0, false);
+ ThreadSP new_thread_sp(history_thread);
+ std::ostringstream thread_name_with_number;
+ thread_name_with_number << thread_name << " Thread " << tid;
+ history_thread->SetThreadName(thread_name_with_number.str().c_str());
+ // Save this in the Process' ExtendedThreadList so a strong pointer retains
+ // the object
+ process_sp->GetExtendedThreadList().AddThread(new_thread_sp);
+ result.push_back(new_thread_sp);
+}
+
+static constexpr std::chrono::seconds g_get_stack_function_timeout(2);
+
+HistoryThreads AddressSanitizerRuntime::GetHistoryThreads(lldb::addr_t address) {
+ HistoryThreads result;
+
+ ProcessSP process_sp = GetProcessSP();
+ if (!process_sp)
+ return result;
+
+ ThreadSP thread_sp =
+ process_sp->GetThreadList().GetExpressionExecutionThread();
+ if (!thread_sp)
+ return result;
+
+ StackFrameSP frame_sp = thread_sp->GetSelectedFrame();
+ if (!frame_sp)
+ return result;
+
+ ExecutionContext exe_ctx(frame_sp);
+ ValueObjectSP return_value_sp;
+ StreamString expr;
+ Error eval_error;
+ expr.Printf(memory_history_asan_command_format, address, address);
+
+ EvaluateExpressionOptions options;
+ options.SetUnwindOnError(true);
+ options.SetTryAllThreads(true);
+ options.SetStopOthers(true);
+ options.SetIgnoreBreakpoints(true);
+ options.SetTimeout(g_get_stack_function_timeout);
+ options.SetPrefix(memory_history_asan_command_prefix);
+ options.SetAutoApplyFixIts(false);
+ options.SetLanguage(eLanguageTypeObjC_plus_plus);
+
+ ExpressionResults expr_result = UserExpression::Evaluate(
+ exe_ctx, options, expr.GetString(), "", return_value_sp, eval_error);
+ if (expr_result != eExpressionCompleted) {
+ process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf(
+ "Warning: Cannot evaluate AddressSanitizer expression:\n%s\n",
+ eval_error.AsCString());
+ return result;
+ }
+
+ if (!return_value_sp)
+ return result;
+
+ CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "free",
+ "Memory deallocated by", result);
+ CreateHistoryThreadFromValueObject(process_sp, return_value_sp, "alloc",
+ "Memory allocated by", result);
+
+ return result;
+}
Index: source/Plugins/CMakeLists.txt
===================================================================
--- source/Plugins/CMakeLists.txt
+++ source/Plugins/CMakeLists.txt
@@ -7,7 +7,6 @@
add_subdirectory(JITLoader)
add_subdirectory(Language)
add_subdirectory(LanguageRuntime)
-add_subdirectory(MemoryHistory)
add_subdirectory(ObjectContainer)
add_subdirectory(ObjectFile)
add_subdirectory(OperatingSystem)
Index: source/Core/PluginManager.cpp
===================================================================
--- source/Core/PluginManager.cpp
+++ source/Core/PluginManager.cpp
@@ -1915,86 +1915,6 @@
return nullptr;
}
-#pragma mark MemoryHistory
-
-struct MemoryHistoryInstance {
- MemoryHistoryInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- MemoryHistoryCreateInstance create_callback;
-};
-
-typedef std::vector<MemoryHistoryInstance> MemoryHistoryInstances;
-
-static std::recursive_mutex &GetMemoryHistoryMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
-
-static MemoryHistoryInstances &GetMemoryHistoryInstances() {
- static MemoryHistoryInstances g_instances;
- return g_instances;
-}
-
-bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
- MemoryHistoryCreateInstance create_callback) {
- if (create_callback) {
- MemoryHistoryInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- GetMemoryHistoryInstances().push_back(instance);
- }
- return false;
-}
-
-bool PluginManager::UnregisterPlugin(
- MemoryHistoryCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
-
- MemoryHistoryInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->create_callback == create_callback) {
- instances.erase(pos);
- return true;
- }
- }
- }
- return false;
-}
-
-MemoryHistoryCreateInstance
-PluginManager::GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-MemoryHistoryCreateInstance
-PluginManager::GetMemoryHistoryCreateCallbackForPluginName(
- const ConstString &name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
-
- MemoryHistoryInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
-}
-
#pragma mark InstrumentationRuntime
struct InstrumentationRuntimeInstance {
Index: source/Commands/CommandObjectMemory.cpp
===================================================================
--- source/Commands/CommandObjectMemory.cpp
+++ source/Commands/CommandObjectMemory.cpp
@@ -36,7 +36,6 @@
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
-#include "lldb/Target/MemoryHistory.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
@@ -1645,16 +1644,16 @@
Stream *output_stream = &result.GetOutputStream();
const ProcessSP &process_sp = m_exe_ctx.GetProcessSP();
- const MemoryHistorySP &memory_history =
- MemoryHistory::FindPlugin(process_sp);
+ const InstrumentationRuntimeSP &runtime =
+ InstrumentationRuntime::FindMemoryHistoryPlugin(process_sp);
- if (!memory_history) {
+ if (!runtime) {
result.AppendError("no available memory history provider");
result.SetStatus(eReturnStatusFailed);
return false;
}
- HistoryThreads thread_list = memory_history->GetHistoryThreads(addr);
+ HistoryThreads thread_list = runtime->GetHistoryThreads(addr);
const bool stop_format = false;
for (auto thread : thread_list) {
Index: source/API/SystemInitializerFull.cpp
===================================================================
--- source/API/SystemInitializerFull.cpp
+++ source/API/SystemInitializerFull.cpp
@@ -64,7 +64,6 @@
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
-#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
#include "Plugins/OperatingSystem/Go/OperatingSystemGo.h"
#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
#include "Plugins/Platform/Android/PlatformAndroid.h"
@@ -305,7 +304,6 @@
JITLoaderGDB::Initialize();
ProcessElfCore::Initialize();
minidump::ProcessMinidump::Initialize();
- MemoryHistoryASan::Initialize();
AddressSanitizerRuntime::Initialize();
ThreadSanitizerRuntime::Initialize();
@@ -428,7 +426,6 @@
JITLoaderGDB::Terminate();
ProcessElfCore::Terminate();
minidump::ProcessMinidump::Terminate();
- MemoryHistoryASan::Terminate();
AddressSanitizerRuntime::Terminate();
ThreadSanitizerRuntime::Terminate();
SymbolVendorELF::Terminate();
Index: lldb.xcodeproj/project.pbxproj
===================================================================
--- lldb.xcodeproj/project.pbxproj
+++ lldb.xcodeproj/project.pbxproj
@@ -768,8 +768,6 @@
6D9AB3DD1BB2B74E003F2289 /* TypeMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6D9AB3DC1BB2B74E003F2289 /* TypeMap.cpp */; };
6DEC6F391BD66D750091ABA6 /* TaskPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6DEC6F381BD66D750091ABA6 /* TaskPool.cpp */; };
8C26C4261C3EA5F90031DF7C /* ThreadSanitizerRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C26C4241C3EA4340031DF7C /* ThreadSanitizerRuntime.cpp */; };
- 8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */; };
- 8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */; };
8CCB017E19BA28A80009FD44 /* ThreadCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB017A19BA283D0009FD44 /* ThreadCollection.cpp */; };
8CCB018219BA4E270009FD44 /* SBThreadCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CCB018119BA4E210009FD44 /* SBThreadCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
8CCB018319BA51BF0009FD44 /* SBThreadCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8CCB017F19BA4DD00009FD44 /* SBThreadCollection.cpp */; };
@@ -2615,10 +2613,6 @@
6DEC6F3A1BD66D950091ABA6 /* TaskPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaskPool.h; path = include/lldb/Utility/TaskPool.h; sourceTree = "<group>"; };
8C26C4241C3EA4340031DF7C /* ThreadSanitizerRuntime.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadSanitizerRuntime.cpp; path = ThreadSanitizer/ThreadSanitizerRuntime.cpp; sourceTree = "<group>"; };
8C26C4251C3EA4340031DF7C /* ThreadSanitizerRuntime.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadSanitizerRuntime.h; path = ThreadSanitizer/ThreadSanitizerRuntime.h; sourceTree = "<group>"; };
- 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MemoryHistory.cpp; path = source/Target/MemoryHistory.cpp; sourceTree = "<group>"; };
- 8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MemoryHistory.h; path = include/lldb/Target/MemoryHistory.h; sourceTree = "<group>"; };
- 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryHistoryASan.cpp; sourceTree = "<group>"; };
- 8C2D6A5B197A1FDC006989C9 /* MemoryHistoryASan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryHistoryASan.h; sourceTree = "<group>"; };
8CCB017A19BA283D0009FD44 /* ThreadCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadCollection.cpp; path = source/Target/ThreadCollection.cpp; sourceTree = "<group>"; };
8CCB017C19BA289B0009FD44 /* ThreadCollection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadCollection.h; path = include/lldb/Target/ThreadCollection.h; sourceTree = "<group>"; };
8CCB017F19BA4DD00009FD44 /* SBThreadCollection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = SBThreadCollection.cpp; path = source/API/SBThreadCollection.cpp; sourceTree = "<group>"; };
@@ -3549,7 +3543,6 @@
isa = PBXGroup;
children = (
8CF02ADD19DCBEC200B14BE0 /* InstrumentationRuntime */,
- 8C2D6A58197A1FB9006989C9 /* MemoryHistory */,
26DB3E051379E7AD0080DC73 /* ABI */,
260C897210F57C5600BB2B04 /* Disassembler */,
260C897810F57C5600BB2B04 /* DynamicLoader */,
@@ -5206,8 +5199,6 @@
4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */,
2690B36F1381D5B600ECFBAE /* Memory.h */,
2690B3701381D5C300ECFBAE /* Memory.cpp */,
- 8C2D6A54197A1EBE006989C9 /* MemoryHistory.h */,
- 8C2D6A52197A1EAF006989C9 /* MemoryHistory.cpp */,
2360092C193FB21500189DB1 /* MemoryRegionInfo.h */,
2654A6811E54D5A200DA1013 /* ModuleCache.h */,
2654A67F1E54D59400DA1013 /* ModuleCache.cpp */,
@@ -5929,23 +5920,6 @@
name = ThreadSanitizer;
sourceTree = "<group>";
};
- 8C2D6A58197A1FB9006989C9 /* MemoryHistory */ = {
- isa = PBXGroup;
- children = (
- 8C2D6A59197A1FCD006989C9 /* asan */,
- );
- path = MemoryHistory;
- sourceTree = "<group>";
- };
- 8C2D6A59197A1FCD006989C9 /* asan */ = {
- isa = PBXGroup;
- children = (
- 8C2D6A5A197A1FDC006989C9 /* MemoryHistoryASan.cpp */,
- 8C2D6A5B197A1FDC006989C9 /* MemoryHistoryASan.h */,
- );
- path = asan;
- sourceTree = "<group>";
- };
8CF02ADD19DCBEC200B14BE0 /* InstrumentationRuntime */ = {
isa = PBXGroup;
children = (
@@ -7176,7 +7150,6 @@
2689005B13353E0400698AC0 /* ValueObjectRegister.cpp in Sources */,
2689005C13353E0400698AC0 /* ValueObjectVariable.cpp in Sources */,
264A58EE1A7DBCAD00A6B1B0 /* OptionValueFormatEntity.cpp in Sources */,
- 8C2D6A53197A1EAF006989C9 /* MemoryHistory.cpp in Sources */,
6D95DC021B9DC057000E318A /* SymbolFileDWARFDwo.cpp in Sources */,
942612F71B95000000EF842E /* LanguageCategory.cpp in Sources */,
2689005D13353E0400698AC0 /* VMRange.cpp in Sources */,
@@ -7483,7 +7456,6 @@
26DB3E161379E7AD0080DC73 /* ABIMacOSX_arm.cpp in Sources */,
26DB3E191379E7AD0080DC73 /* ABIMacOSX_arm64.cpp in Sources */,
2374D7531D4BB2FF005C9575 /* GDBRemoteClientBase.cpp in Sources */,
- 8C2D6A5E197A250F006989C9 /* MemoryHistoryASan.cpp in Sources */,
26F006561B4DD86700B872E5 /* DynamicLoaderWindowsDYLD.cpp in Sources */,
26DB3E1C1379E7AD0080DC73 /* ABIMacOSX_i386.cpp in Sources */,
26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */,
Index: include/lldb/lldb-private-interfaces.h
===================================================================
--- include/lldb/lldb-private-interfaces.h
+++ include/lldb/lldb-private-interfaces.h
@@ -88,8 +88,6 @@
ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation,
void *baton);
typedef UnwindAssembly *(*UnwindAssemblyCreateInstance)(const ArchSpec &arch);
-typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance)(
- const lldb::ProcessSP &process_sp);
typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType)();
typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance)(
const lldb::ProcessSP &process_sp);
Index: include/lldb/lldb-forward.h
===================================================================
--- include/lldb/lldb-forward.h
+++ include/lldb/lldb-forward.h
@@ -130,7 +130,6 @@
class LogChannel;
class Mangled;
class Materializer;
-class MemoryHistory;
class Module;
class ModuleList;
class ModuleSpec;
@@ -363,7 +362,6 @@
typedef std::shared_ptr<lldb_private::Listener> ListenerSP;
typedef std::weak_ptr<lldb_private::Listener> ListenerWP;
typedef std::shared_ptr<lldb_private::LogChannel> LogChannelSP;
-typedef std::shared_ptr<lldb_private::MemoryHistory> MemoryHistorySP;
typedef std::shared_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoSP;
typedef std::unique_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoUP;
typedef std::shared_ptr<lldb_private::Module> ModuleSP;
Index: include/lldb/Target/MemoryHistory.h
===================================================================
--- include/lldb/Target/MemoryHistory.h
+++ include/lldb/Target/MemoryHistory.h
@@ -1,38 +0,0 @@
-//===-- MemoryHistory.h ---------------------------------------------------*-
-//C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_MemoryHistory_h_
-#define liblldb_MemoryHistory_h_
-
-// C Includes
-// C++ Includes
-#include <vector>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Core/PluginInterface.h"
-#include "lldb/lldb-private.h"
-#include "lldb/lldb-types.h"
-
-namespace lldb_private {
-
-typedef std::vector<lldb::ThreadSP> HistoryThreads;
-
-class MemoryHistory : public std::enable_shared_from_this<MemoryHistory>,
- public PluginInterface {
-public:
- static lldb::MemoryHistorySP FindPlugin(const lldb::ProcessSP process);
-
- virtual HistoryThreads GetHistoryThreads(lldb::addr_t address) = 0;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_MemoryHistory_h_
Index: include/lldb/Target/InstrumentationRuntime.h
===================================================================
--- include/lldb/Target/InstrumentationRuntime.h
+++ include/lldb/Target/InstrumentationRuntime.h
@@ -28,6 +28,8 @@
typedef std::map<lldb::InstrumentationRuntimeType,
lldb::InstrumentationRuntimeSP>
InstrumentationRuntimeCollection;
+
+typedef std::vector<lldb::ThreadSP> HistoryThreads;
class InstrumentationRuntime
: public std::enable_shared_from_this<InstrumentationRuntime>,
@@ -93,6 +95,15 @@
virtual lldb::ThreadCollectionSP
GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info);
+
+ virtual bool CanProvideMemoryHistory() { return false; }
+
+ virtual HistoryThreads GetHistoryThreads(lldb::addr_t address) {
+ return HistoryThreads();
+ }
+
+ static lldb::InstrumentationRuntimeSP
+ FindMemoryHistoryPlugin(const lldb::ProcessSP process);
};
} // namespace lldb_private
Index: include/lldb/Core/PluginManager.h
===================================================================
--- include/lldb/Core/PluginManager.h
+++ include/lldb/Core/PluginManager.h
@@ -383,20 +383,6 @@
GetUnwindAssemblyCreateCallbackForPluginName(const ConstString &name);
//------------------------------------------------------------------
- // MemoryHistory
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
- MemoryHistoryCreateInstance create_callback);
-
- static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
-
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
-
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackForPluginName(const ConstString &name);
-
- //------------------------------------------------------------------
// InstrumentationRuntime
//------------------------------------------------------------------
static bool
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits