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 
15 using namespace lldb;
16 using namespace lldb_private;
17 
18 ObjectContainer::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 spec
26  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 
33 ObjectContainerSP 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 =
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 }
LLDB_SCOPED_TIMERF
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
lldb_private::ModuleChild
Definition: ModuleChild.h:19
lldb_private::PluginManager::GetObjectContainerCreateMemoryCallbackAtIndex
static ObjectContainerCreateMemoryInstance GetObjectContainerCreateMemoryCallbackAtIndex(uint32_t idx)
Definition: PluginManager.cpp:765
Module.h
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::ObjectContainer::m_data
DataExtractor m_data
The data for this object file so things can be parsed lazily.
Definition: ObjectContainer.h:143
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::DataExtractor::SetData
lldb::offset_t SetData(const void *bytes, lldb::offset_t length, lldb::ByteOrder byte_order)
Set data with a buffer that is caller owned.
Definition: DataExtractor.cpp:223
Process.h
lldb_private::FileSpec
Definition: FileSpec.h:55
Timer.h
lldb_private::ObjectContainer::m_file
FileSpec m_file
The file that represents this container objects (which can be different from the module's file).
Definition: ObjectContainer.h:134
lldb_private::ObjectContainer::FindPlugin
static lldb::ObjectContainerSP FindPlugin(const lldb::ModuleSP &module_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, lldb::WritableDataBufferSP file_data_sp)
Definition: ObjectContainer.cpp:33
PluginManager.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
ObjectContainer.h
lldb
Definition: SBAddress.h:15