| 1 |
//===-- OperatingSystemPlugin.h ---------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#include "lldb/Core/PluginManager.h" |
| 10 |
#include "lldb/Target/OperatingSystem.h" |
| 11 |
#include "lldb/Target/Thread.h" |
| 12 |
#include "lldb/Target/ThreadList.h" |
| 13 |
|
| 14 |
/// An operating system plugin that does nothing: simply keeps the thread lists |
| 15 |
/// as they are. |
| 16 |
class OperatingSystemIdentityMap : public lldb_private::OperatingSystem { |
| 17 |
public: |
| 18 |
OperatingSystemIdentityMap(lldb_private::Process *process) |
| 19 |
: OperatingSystem(process) {} |
| 20 |
|
| 21 |
static OperatingSystem *CreateInstance(lldb_private::Process *process, |
| 22 |
bool force) { |
| 23 |
return new OperatingSystemIdentityMap(process); |
| 24 |
} |
| 25 |
static llvm::StringRef GetPluginNameStatic() { return "identity map"; } |
| 26 |
static llvm::StringRef GetPluginDescriptionStatic() { return ""; } |
| 27 |
|
| 28 |
static void Initialize() { |
| 29 |
lldb_private::PluginManager::RegisterPlugin(GetPluginNameStatic(), |
| 30 |
GetPluginDescriptionStatic(), |
| 31 |
CreateInstance, nullptr); |
| 32 |
} |
| 33 |
static void Terminate() { |
| 34 |
lldb_private::PluginManager::UnregisterPlugin(CreateInstance); |
| 35 |
} |
| 36 |
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); } |
| 37 |
|
| 38 |
// Simply adds the threads from real_thread_list into new_thread_list. |
| 39 |
bool UpdateThreadList(lldb_private::ThreadList &old_thread_list, |
| 40 |
lldb_private::ThreadList &real_thread_list, |
| 41 |
lldb_private::ThreadList &new_thread_list) override { |
| 42 |
for (const auto &real_thread : real_thread_list.Threads()) |
| 43 |
new_thread_list.AddThread(real_thread); |
| 44 |
return true; |
| 45 |
} |
| 46 |
|
| 47 |
void ThreadWasSelected(lldb_private::Thread *thread) override {} |
| 48 |
|
| 49 |
lldb::RegisterContextSP |
| 50 |
CreateRegisterContextForThread(lldb_private::Thread *thread, |
| 51 |
lldb::addr_t reg_data_addr) override { |
| 52 |
return thread->GetRegisterContext(); |
| 53 |
} |
| 54 |
|
| 55 |
lldb::StopInfoSP |
| 56 |
CreateThreadStopReason(lldb_private::Thread *thread) override { |
| 57 |
return thread->GetStopInfo(); |
| 58 |
} |
| 59 |
}; |