LLDB mainline
DynamicLoaderWindowsDYLD.h
Go to the documentation of this file.
1//===-- DynamicLoaderWindowsDYLD.h ------------------------------*- C++ -*-===//
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#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
10#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
11
13#include "lldb/lldb-forward.h"
14
15namespace lldb_private {
16
18public:
20
22
23 static void Initialize();
24 static void Terminate();
25 static llvm::StringRef GetPluginNameStatic() { return "windows-dyld"; }
26 static llvm::StringRef GetPluginDescriptionStatic();
27
28 static DynamicLoader *CreateInstance(Process *process, bool force);
29
30 void OnLoadModule(lldb::ModuleSP module_sp, const ModuleSpec module_spec,
31 lldb::addr_t module_addr);
32 void OnUnloadModule(lldb::addr_t module_addr);
33
34 void DidAttach() override;
35 void DidLaunch() override;
36 Status CanLoadImage() override;
38 bool stop) override;
39
40 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
41
43 const lldb::ThreadSP thread,
44 lldb::addr_t tls_file_addr) override;
45
46protected:
47 /// Returns the load address for the given executable module.
48 ///
49 /// The lookup proceeds in two stages:
50 ///
51 /// 1. **Cache lookup** – \c m_loaded_modules is scanned for an existing
52 /// entry whose \c ModuleSP matches \p executable. Because the same
53 /// \c ModuleSP can be inserted more than once under different base
54 /// addresses (e.g. a DLL loaded into several processes, or a module
55 /// that was unloaded and reloaded at a different address), the scan
56 /// returns the *first* valid (non-LLDB_INVALID_ADDRESS) entry it
57 /// finds.
58 ///
59 /// 2. **Process / platform query** – If no cached entry is found,
60 /// \c Process::GetFileLoadAddress is called. On a remote target the
61 /// remote platform is responsible for resolving the address. A
62 /// successful result is inserted into \c m_loaded_modules so that
63 /// subsequent calls hit the cache.
64 ///
65 /// \param executable The module whose load address is requested.
66 /// \return The load address, or \c LLDB_INVALID_ADDRESS if it
67 /// could not be determined.
69
70 /// Maps load addresses to their corresponding modules.
71 ///
72 /// Weak pointers are used intentionally: on Windows, a Module holds a
73 /// memory-mapped view of the DLL file, and an open memory mapping locks
74 /// the file on disk. Holding a strong reference (ModuleSP) here would
75 /// prevent the mapping from being released even after the Target drops
76 /// its own reference, keeping the file locked and blocking recompilation
77 /// during an active debug session.
78 llvm::DenseMap<lldb::addr_t, lldb::ModuleWP> m_loaded_modules;
79
80private:
82 Address &addr) const;
83};
84
85} // namespace lldb_private
86
87#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
A section + offset based address class.
Definition Address.h:62
void DidAttach() override
Called after attaching a process.
void DidLaunch() override
Called after launching a process.
lldb::addr_t GetThreadLocalData(const lldb::ModuleSP module, const lldb::ThreadSP thread, lldb::addr_t tls_file_addr) override
Retrieves the per-module TLS block for a given thread.
llvm::DenseMap< lldb::addr_t, lldb::ModuleWP > m_loaded_modules
Maps load addresses to their corresponding modules.
Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
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.
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.
bool GetTlsIndexAddressForModule(const lldb::ModuleSP &module, Address &addr) const
A plug-in interface definition class for dynamic loaders.
DynamicLoader(Process *process)
Construct with a process.
A plug-in interface definition class for debugging a process.
Definition Process.h:369
An error handling class.
Definition Status.h:118
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Thread > ThreadSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP