22#include "llvm/TargetParser/Triple.h"
44 return "Dynamic loader plug-in that watches for shared library "
45 "loads/unloads in Windows processes.";
50 bool should_create = force;
52 const llvm::Triple &triple_ref =
54 if (triple_ref.getOS() == llvm::Triple::Win32)
70 module_sp =
m_process->GetTarget().GetOrCreateModule(module_spec,
79 module_list.
Append(module_sp);
80 m_process->GetTarget().ModulesDidLoad(module_list);
88 ModuleSP module_sp = it->second.lock();
94 bool full_unload =
true;
96 ModuleSP other_sp = entry.second.lock();
97 if (other_sp == module_sp) {
106 module_list.
Append(module_sp);
107 m_process->GetTarget().ModulesDidUnload(module_list,
false);
123 FileSpec file_spec(executable->GetPlatformFileSpec());
124 bool is_loaded =
false;
126 m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
138 LLDB_LOGF(log,
"DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
142 if (!executable.get())
153 if (image_base == load_addr)
160 module_list.
Append(executable);
161 m_process->GetTarget().ModulesDidLoad(module_list);
168 LLDB_LOGF(log,
"DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
171 if (!executable.get())
180 module_list.
Append(executable);
181 m_process->GetTarget().ModulesDidLoad(module_list);
192 auto arch =
m_process->GetTarget().GetArchitecture();
193 if (arch.GetMachine() != llvm::Triple::x86) {
197 uint64_t
pc = thread.GetRegisterContext()->GetPC();
202 arch,
nullptr,
nullptr,
nullptr,
nullptr,
m_process->GetTarget(), range);
203 if (!disassembler_sp) {
208 if (insn_list ==
nullptr) {
222 if (first_insn ==
nullptr || second_insn ==
nullptr ||
223 strcmp(first_insn->GetMnemonic(&exe_ctx),
"jmpl") != 0 ||
224 strcmp(second_insn->GetMnemonic(&exe_ctx),
"nop") != 0) {
228 assert(first_insn->DoesBranch() && !second_insn->DoesBranch());
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define LLDB_PLUGIN_DEFINE(PluginName)
A section + offset based address range class.
llvm::Triple & GetTriple()
Architecture triple accessor.
static lldb::DisassemblerSP DisassembleRange(const ArchSpec &arch, const char *plugin_name, const char *flavor, const char *cpu, const char *features, Target &target, llvm::ArrayRef< AddressRange > disasm_ranges, bool force_live_memory=false)
void DidAttach() override
Called after attaching a process.
void DidLaunch() override
Called after launching a process.
static llvm::StringRef GetPluginDescriptionStatic()
llvm::DenseMap< lldb::addr_t, lldb::ModuleWP > m_loaded_modules
Maps load addresses to their corresponding modules.
~DynamicLoaderWindowsDYLD() override
Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
static llvm::StringRef GetPluginNameStatic()
void OnLoadModule(lldb::ModuleSP module_sp, const ModuleSpec module_spec, lldb::addr_t module_addr)
lldb::addr_t GetLoadAddress(lldb::ModuleSP executable)
Returns the load address for the given executable module.
DynamicLoaderWindowsDYLD(Process *process)
void OnUnloadModule(lldb::addr_t module_addr)
static DynamicLoader * CreateInstance(Process *process, bool force)
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, bool stop) override
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
Process * m_process
The process that this dynamic loader plug-in is tracking.
void UpdateLoadedSectionsCommon(lldb::ModuleSP module, lldb::addr_t base_addr, bool base_addr_is_offset)
lldb::ModuleSP GetTargetExecutable()
Checks to see if the target module has changed, updates the target accordingly and returns the target...
virtual void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr, lldb::addr_t base_addr, bool base_addr_is_offset)
Updates the load address of every allocatable section in module.
DynamicLoader(Process *process)
Construct with a process.
void UnloadSectionsCommon(const lldb::ModuleSP module)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
lldb::InstructionSP GetInstructionAtIndex(size_t idx) const
A collection class for Module objects.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A plug-in interface definition class for debugging a process.
Target & GetTarget()
Get the target object pointer for this module.
bool Success() const
Test for success condition.
const ArchSpec & GetArchitecture() const
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::weak_ptr< lldb_private::Module > ModuleWP
std::shared_ptr< lldb_private::Disassembler > DisassemblerSP
std::shared_ptr< lldb_private::Module > ModuleSP