1 //===-- ObjectContainer.cpp -----------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
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"
16 using namespace lldb_private
;
18 ObjectContainer::ObjectContainer(const lldb::ModuleSP
&module_sp
,
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
) {
30 m_data
.SetData(data_sp
, data_offset
, length
);
33 ObjectContainerSP
ObjectContainer::FindPlugin(const lldb::ModuleSP
&module_sp
,
34 const ProcessSP
&process_sp
,
35 lldb::addr_t header_addr
,
36 WritableDataBufferSP data_sp
) {
40 LLDB_SCOPED_TIMERF("ObjectContainer::FindPlugin (module = "
41 "%s, process = %p, header_addr = "
43 module_sp
->GetFileSpec().GetPath().c_str(),
44 static_cast<void *>(process_sp
.get()), header_addr
);
46 ObjectContainerCreateMemoryInstance create_callback
;
49 PluginManager::GetObjectContainerCreateMemoryCallbackAtIndex(
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
;