LLDB mainline
ObjectFilePlaceholder.cpp
Go to the documentation of this file.
1//===-- ObjectFilePlaceholder.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
11#include "lldb/Core/Module.h"
14#include "lldb/Core/Section.h"
16#include "lldb/Target/Target.h"
17
18#include <memory>
19
20using namespace lldb;
21using namespace lldb_private;
22
24
26 const lldb::ModuleSP &module_sp,
27 const lldb_private::ModuleSpec &module_spec, lldb::addr_t base,
28 lldb::addr_t size)
29 : ObjectFile(module_sp, &module_spec.GetFileSpec(), /*file_offset*/ 0,
30 /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
31 m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()),
32 m_base(base), m_size(size) {
33 m_symtab_up = std::make_unique<lldb_private::Symtab>(this);
34}
35
37 lldb_private::SectionList &unified_section_list) {
38 m_sections_up = std::make_unique<lldb_private::SectionList>();
39 auto section_sp = std::make_shared<lldb_private::Section>(
40 GetModule(), this, /*sect_id*/ 0,
42 m_size, /*file_offset*/ 0, /*file_size*/ 0,
43 /*log2align*/ 0, /*flags*/ 0);
44 section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable);
45 m_sections_up->AddSection(section_sp);
46 unified_section_list.AddSection(std::move(section_sp));
47}
48
52
54 bool value_is_offset) {
55 assert(!value_is_offset);
56 assert(value == m_base);
57
58 // Create sections if they haven't been created already.
59 GetModule()->GetSectionList();
60 assert(m_sections_up->GetNumSections(0) == 1);
61
62 target.SetSectionLoadAddress(m_sections_up->GetSectionAtIndex(0), m_base);
63 return true;
64}
65
67 s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n",
69}
#define LLDB_PLUGIN_DEFINE(PluginName)
A minimal ObjectFile implementation providing a dummy object file for the cases when the real module ...
bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value, bool value_is_offset) override
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
void CreateSections(lldb_private::SectionList &unified_section_list) override
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
lldb_private::ArchSpec m_arch
ObjectFilePlaceholder(const lldb::ModuleSP &module_sp, const lldb_private::ModuleSpec &module_spec, lldb::addr_t base, lldb::addr_t size)
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
A section + offset based address class.
Definition Address.h:62
A uniqued constant string class.
Definition ConstString.h:40
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
std::unique_ptr< lldb_private::SectionList > m_sections_up
Definition ObjectFile.h:788
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, 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.
std::unique_ptr< lldb_private::Symtab > m_symtab_up
Definition ObjectFile.h:789
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition ObjectFile.h:281
size_t AddSection(const lldb::SectionSP &section_sp)
Definition Section.cpp:482
A stream class that can stream formatted output to a file.
Definition Stream.h:28
void Format(const char *format, Args &&... args)
Definition Stream.h:352
bool SetSectionLoadAddress(const lldb::SectionSP &section, lldb::addr_t load_addr, bool warn_multiple=false)
Definition Target.cpp:3296
A class that represents a running process on the host machine.
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP