22#include "llvm/TargetParser/Triple.h"
42 return "Dynamic loader plug-in that watches for shared library "
43 "loads/unloads in Windows processes.";
48 bool should_create = force;
50 const llvm::Triple &triple_ref =
52 if (triple_ref.getOS() == llvm::Triple::Win32)
69 module_sp =
m_process->GetTarget().GetOrCreateModule(module_spec,
78 module_list.
Append(module_sp);
79 m_process->GetTarget().ModulesDidLoad(module_list);
84 if (!
m_process->GetTarget().ResolveLoadAddress(module_addr, resolved_addr))
92 module_list.
Append(module_sp);
93 m_process->GetTarget().ModulesDidUnload(module_list,
false);
107 FileSpec file_spec(executable->GetPlatformFileSpec());
108 bool is_loaded =
false;
110 m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
122 LLDB_LOGF(log,
"DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
126 if (!executable.get())
137 if (image_base == load_addr)
144 module_list.
Append(executable);
145 m_process->GetTarget().ModulesDidLoad(module_list);
152 LLDB_LOGF(log,
"DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
155 if (!executable.get())
164 module_list.
Append(executable);
165 m_process->GetTarget().ModulesDidLoad(module_list);
176 auto arch =
m_process->GetTarget().GetArchitecture();
177 if (arch.GetMachine() != llvm::Triple::x86) {
181 uint64_t
pc = thread.GetRegisterContext()->GetPC();
186 arch,
nullptr,
nullptr,
nullptr,
nullptr,
m_process->GetTarget(), range);
187 if (!disassembler_sp) {
192 if (insn_list ==
nullptr) {
206 if (first_insn ==
nullptr || second_insn ==
nullptr ||
207 strcmp(first_insn->GetMnemonic(&exe_ctx),
"jmpl") != 0 ||
208 strcmp(second_insn->GetMnemonic(&exe_ctx),
"nop") != 0) {
212 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.
A section + offset based address class.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
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.
std::map< lldb::ModuleWP, lldb::addr_t, std::owner_less< lldb::ModuleWP > > m_loaded_modules
void DidLaunch() override
Called after launching a process.
static llvm::StringRef GetPluginDescriptionStatic()
~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)
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)
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::shared_ptr< lldb_private::Disassembler > DisassemblerSP
std::shared_ptr< lldb_private::Module > ModuleSP