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
42protected:
43 /// Returns the load address for the given executable module.
44 ///
45 /// The lookup proceeds in two stages:
46 ///
47 /// 1. **Cache lookup** – \c m_loaded_modules is scanned for an existing
48 /// entry whose \c ModuleSP matches \p executable. Because the same
49 /// \c ModuleSP can be inserted more than once under different base
50 /// addresses (e.g. a DLL loaded into several processes, or a module
51 /// that was unloaded and reloaded at a different address), the scan
52 /// returns the *first* valid (non-LLDB_INVALID_ADDRESS) entry it
53 /// finds.
54 ///
55 /// 2. **Process / platform query** – If no cached entry is found,
56 /// \c Process::GetFileLoadAddress is called. On a remote target the
57 /// remote platform is responsible for resolving the address. A
58 /// successful result is inserted into \c m_loaded_modules so that
59 /// subsequent calls hit the cache.
60 ///
61 /// \param executable The module whose load address is requested.
62 /// \return The load address, or \c LLDB_INVALID_ADDRESS if it
63 /// could not be determined.
65
66 /// Maps load addresses to their corresponding modules.
67 ///
68 /// Weak pointers are used intentionally: on Windows, a Module holds a
69 /// memory-mapped view of the DLL file, and an open memory mapping locks
70 /// the file on disk. Holding a strong reference (ModuleSP) here would
71 /// prevent the mapping from being released even after the Target drops
72 /// its own reference, keeping the file locked and blocking recompilation
73 /// during an active debug session.
74 llvm::DenseMap<lldb::addr_t, lldb::ModuleWP> m_loaded_modules;
75};
76
77} // namespace lldb_private
78
79#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
void DidAttach() override
Called after attaching a process.
void DidLaunch() override
Called after launching a process.
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.
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:354
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
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP