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
50 return lldb_private::Address(m_sections_up->GetSectionAtIndex(0), 0);
51}
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
63 m_sections_up->GetSectionAtIndex(0), m_base);
64 return true;
65}
66
68 s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n",
70}
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:32
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::Address GetBaseAddress() override
Returns base address of this object file.
void CreateSections(lldb_private::SectionList &unified_section_list) override
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.
Definition: ModuleChild.cpp:24
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:44
std::unique_ptr< lldb_private::SectionList > m_sections_up
Definition: ObjectFile.h:762
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:275
size_t AddSection(const lldb::SectionSP &section_sp)
Definition: Section.cpp:475
bool SetSectionLoadAddress(const lldb::SectionSP &section_sp, lldb::addr_t load_addr, bool warn_multiple=false)
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:353
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1143
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
uint64_t addr_t
Definition: lldb-types.h:80
@ eSectionTypeOther
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371