67 std::shared_ptr<TargetGroupCPUAndAccelerators> group_sp =
69 TargetSP native_target_sp = group_sp ? group_sp->GetCPUTarget() :
nullptr;
71 native_target_sp ? native_target_sp->GetProcessSP() :
nullptr;
73 std::optional<LLDBSettings> process_settings =
75 if (process_settings && !process_settings->send_dyld_packet_to_accelerator) {
76 if (process_settings->accelerator_plugin_name.empty()) {
77 LLDB_LOG(log,
"cannot route dynamic-loader request through the native "
78 "connection without an accelerator plugin name");
82 if (!native_process_sp || native_process_sp->GetPluginName() !=
84 LLDB_LOG(log,
"cannot route dynamic-loader request through the native "
85 "connection: no native gdb-remote process");
90 args.
plugin_name = process_settings->accelerator_plugin_name;
94 std::optional<AcceleratorDynamicLoaderResponse> response =
98 LLDB_LOG(log,
"failed to get dynamic loader info from the GDB server");
103 response->library_infos) {
104 std::shared_ptr<DataBufferHeap> data_sp;
106 LLDB_LOG(log,
"reading \"{0}\" from native memory at {1:x}",
108 if (native_process_sp) {
111 const size_t bytes_read = native_process_sp->ReadMemory(
113 data_sp->GetByteSize(),
error);
116 "failed to read \"{0}\" from native memory at {1:x}: {2}",
121 LLDB_LOG(log,
"no native process available to read \"{0}\" at {1:x}",
132 extractor_sp = std::make_shared<DataExtractor>(data_sp);
159 bool changed =
false;
165 if (sect.
names.empty())
168 for (
const std::string &name : sect.
names) {
172 section_sp->GetChildren().FindSectionByName(section_name);
175 module_sp->GetSectionList()->FindSectionByName(section_name);
185 module_sp->SetLoadAddress(target, 0,
true, changed);
197 Thread &thread,
bool stop_others) {
216 return "Dynamic loader plug-in that gets shared library loads/unloads from "
217 "an lldb-server accelerator plugin.";
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_PLUGIN_DEFINE(PluginName)
Dynamic loader for accelerator targets whose library changes are reported by the remote server instea...
void DidLaunch() override
Called after launching a process.
bool HandleStopReasonDynamicLoader() override
Allow the dynamic loader to handle a request to update loaded modules.
static llvm::StringRef GetPluginNameStatic()
void DidAttach() override
Called after attaching a process.
static llvm::StringRef GetPluginDescriptionStatic()
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, bool stop_others) override
Provides a plan to step through the dynamic loader trampoline for the current state of thread.
DynamicLoaderAcceleratorGDBRemote(lldb_private::Process *process)
bool LoadModulesFromGDBServer(bool full)
Returns true if the server answered the packet.
static lldb_private::DynamicLoader * CreateInstance(lldb_private::Process *process, bool force)
lldb_private::Status CanLoadImage() override
Ask if it is ok to try and load or unload an shared library (image).
A uniqued constant string class.
A plug-in interface definition class for dynamic loaders.
Process * m_process
The process that this dynamic loader plug-in is tracking.
DynamicLoader(Process *process)
Construct with a process.
virtual void UnloadSections(const lldb::ModuleSP module)
Removes the loaded sections from the target in module.
A collection class for Module objects.
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
void FindModules(const ModuleSpec &module_spec, ModuleList &matching_module_list) const
Finds modules whose file specification matches module_spec.
void ForEach(std::function< IterationAction(const lldb::ModuleSP &module_sp)> const &callback) const
Applies 'callback' to each module in this ModuleList.
void SetObjectSize(uint64_t object_size)
void SetObjectOffset(uint64_t object_offset)
virtual llvm::StringRef GetPluginName()=0
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.
static Status FromErrorString(const char *str)
A group that accepts a CPU target as its first member, followed by accelerator targets.
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr, bool invoke_symbol_locators=true)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
void ModulesDidUnload(ModuleList &module_list, bool delete_locations)
const ModuleList & GetImages() const
Get accessor for the images for this process.
std::shared_ptr< GroupT > GetFirstTargetGroupOfType() const
Return the first target group that can be cast to GroupT.
bool SetSectionLoadAddress(const lldb::SectionSP §ion, lldb::addr_t load_addr, bool warn_multiple=false)
Represents UUID's of various sizes.
bool SetFromStringRef(llvm::StringRef str)
std::optional< LLDBSettings > GetLLDBSettings()
Return LLDB-specific settings for this GDB-remote process.
std::optional< AcceleratorDynamicLoaderResponse > GetAcceleratorDynamicLoaderLibraryInfos(const AcceleratorDynamicLoaderArgs &args)
Returns std::nullopt if the packet failed or the response did not parse.
GDBRemoteCommunicationClient & GetGDBRemote()
static llvm::StringRef GetPluginNameStatic()
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.
IterationAction
Useful for callbacks whose return type indicates whether to continue iteration or short-circuit.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
Arguments for the jAcceleratorPluginGetDynamicLoaderLibraryInfo packet.
bool full
If false, return only what changed since the last query.
bool load
False means unload.
std::optional< uint64_t > native_memory_size
std::string pathname
Path to the object file, or a unique name identifying the module in the target when it has no file on...
std::optional< std::string > uuid_str
UUID of the object file, when the plugin knows it.
std::optional< uint64_t > native_memory_address
Where the image can be read in the native process, meaning the host process driving the accelerator,...
std::vector< AcceleratorSectionInfo > loaded_sections
Used when sections load at independent addresses.
std::optional< uint64_t > file_size
std::optional< uint64_t > file_offset
Slice of pathname holding the object file, when embedded in a container.
std::optional< uint64_t > load_address
Slides the whole object file.
std::vector< std::string > names
A list of section names.
uint64_t load_address
Address the section named by names is loaded at.