LLDB mainline
ObjectContainer.cpp
Go to the documentation of this file.
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-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Module.h"
12#include "lldb/Target/Process.h"
13#include "lldb/Utility/Timer.h"
14
15using namespace lldb;
16using namespace lldb_private;
17
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 spec
26 m_offset(file_offset), m_length(length),
27 m_extractor_sp(std::make_shared<DataExtractor>()) {
28 if (file)
29 m_file = *file;
30 if (data_sp) {
31 m_extractor_sp->SetData(data_sp, data_offset, length);
32 }
33}
34
36 const ProcessSP &process_sp,
37 lldb::addr_t header_addr,
38 WritableDataBufferSP data_sp) {
39 if (!module_sp)
40 return {};
41
42 LLDB_SCOPED_TIMERF("ObjectContainer::FindPlugin (module = "
43 "%s, process = %p, header_addr = "
44 "0x%" PRIx64 ")",
45 module_sp->GetFileSpec().GetPath().c_str(),
46 static_cast<void *>(process_sp.get()), header_addr);
47
49 for (size_t idx = 0;
50 (create_callback =
52 idx)) != nullptr;
53 ++idx) {
54 ObjectContainerSP object_container_sp(
55 create_callback(module_sp, data_sp, process_sp, header_addr));
56 if (object_container_sp)
57 return object_container_sp;
58 }
59
60 return {};
61}
#define LLDB_SCOPED_TIMERF(...)
Definition Timer.h:86
An data extractor class.
A file utility class.
Definition FileSpec.h:57
ModuleChild(const lldb::ModuleSP &module_sp)
Construct with owning module.
lldb::DataExtractorSP m_extractor_sp
The data for this object file so things can be parsed lazily.
static lldb::ObjectContainerSP FindPlugin(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, lldb::WritableDataBufferSP file_data_sp)
FileSpec m_file
The file that represents this container objects (which can be different from the module's file).
lldb::addr_t m_offset
The offset in bytes into the file, or the address in memory.
ObjectContainer(const lldb::ModuleSP &module_sp, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataBufferSP data_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
lldb::addr_t m_length
The size in bytes if known (can be zero).
static ObjectContainerCreateMemoryInstance GetObjectContainerCreateMemoryCallbackAtIndex(uint32_t idx)
A class that represents a running process on the host machine.
ObjectContainer *(* ObjectContainerCreateMemoryInstance)(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t offset)
std::shared_ptr< lldb_private::ObjectContainer > ObjectContainerSP
uint64_t offset_t
Definition lldb-types.h:85
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP