60 lines · cpp
1//===-- ObjectContainer.cpp -----------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Symbol/ObjectContainer.h"10#include "lldb/Core/Module.h"11#include "lldb/Core/PluginManager.h"12#include "lldb/Target/Process.h"13#include "lldb/Utility/Timer.h"14 15using namespace lldb;16using namespace lldb_private;17 18ObjectContainer::ObjectContainer(const lldb::ModuleSP &module_sp,19 const FileSpec *file,20 lldb::offset_t file_offset,21 lldb::offset_t length,22 lldb::DataBufferSP data_sp,23 lldb::offset_t data_offset)24 : ModuleChild(module_sp),25 m_file(), // This file can be different than the module's file spec26 m_offset(file_offset), m_length(length) {27 if (file)28 m_file = *file;29 if (data_sp)30 m_data.SetData(data_sp, data_offset, length);31}32 33ObjectContainerSP ObjectContainer::FindPlugin(const lldb::ModuleSP &module_sp,34 const ProcessSP &process_sp,35 lldb::addr_t header_addr,36 WritableDataBufferSP data_sp) {37 if (!module_sp)38 return {};39 40 LLDB_SCOPED_TIMERF("ObjectContainer::FindPlugin (module = "41 "%s, process = %p, header_addr = "42 "0x%" PRIx64 ")",43 module_sp->GetFileSpec().GetPath().c_str(),44 static_cast<void *>(process_sp.get()), header_addr);45 46 ObjectContainerCreateMemoryInstance create_callback;47 for (size_t idx = 0;48 (create_callback =49 PluginManager::GetObjectContainerCreateMemoryCallbackAtIndex(50 idx)) != nullptr;51 ++idx) {52 ObjectContainerSP object_container_sp(53 create_callback(module_sp, data_sp, process_sp, header_addr));54 if (object_container_sp)55 return object_container_sp;56 }57 58 return {};59}60