[Lldb-commits] [PATCH] D145955: Refactor ObjectFilePlaceholder for sharing
labath added a comment. yay Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145955/new/ https://reviews.llvm.org/D145955 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D145955: Refactor ObjectFilePlaceholder for sharing
This revision was automatically updated to reflect the committed changes. Closed by commit rG46c2e4c4f347: Refactor ObjectFilePlaceholder for sharing (authored by yinghuitan). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145955/new/ https://reviews.llvm.org/D145955 Files: lldb/source/Plugins/ObjectFile/CMakeLists.txt lldb/source/Plugins/ObjectFile/Placeholder/CMakeLists.txt lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.cpp lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.h lldb/source/Plugins/Process/minidump/CMakeLists.txt lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp === --- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Threading.h" +#include "Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.h" #include "Plugins/Process/Utility/StopInfoMachException.h" #include @@ -47,84 +48,6 @@ namespace { -/// A minimal ObjectFile implementation providing a dummy object file for the -/// cases when the real module binary is not available. This allows the module -/// to show up in "image list" and symbols to be added to it. -class PlaceholderObjectFile : public ObjectFile { -public: - PlaceholderObjectFile(const lldb::ModuleSP _sp, -const ModuleSpec _spec, lldb::addr_t base, -lldb::addr_t size) - : ObjectFile(module_sp, _spec.GetFileSpec(), /*file_offset*/ 0, - /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0), -m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()), -m_base(base), m_size(size) { -m_symtab_up = std::make_unique(this); - } - - static ConstString GetStaticPluginName() { -return ConstString("placeholder"); - } - llvm::StringRef GetPluginName() override { -return GetStaticPluginName().GetStringRef(); - } - bool ParseHeader() override { return true; } - Type CalculateType() override { return eTypeUnknown; } - Strata CalculateStrata() override { return eStrataUnknown; } - uint32_t GetDependentModules(FileSpecList _list) override { return 0; } - bool IsExecutable() const override { return false; } - ArchSpec GetArchitecture() override { return m_arch; } - UUID GetUUID() override { return m_uuid; } - void ParseSymtab(lldb_private::Symtab ) override {} - bool IsStripped() override { return true; } - ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); } - - uint32_t GetAddressByteSize() const override { -return m_arch.GetAddressByteSize(); - } - - Address GetBaseAddress() override { -return Address(m_sections_up->GetSectionAtIndex(0), 0); - } - - void CreateSections(SectionList _section_list) override { -m_sections_up = std::make_unique(); -auto section_sp = std::make_shared( -GetModule(), this, /*sect_id*/ 0, ConstString(".module_image"), -eSectionTypeOther, m_base, m_size, /*file_offset*/ 0, /*file_size*/ 0, -/*log2align*/ 0, /*flags*/ 0); -section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable); -m_sections_up->AddSection(section_sp); -unified_section_list.AddSection(std::move(section_sp)); - } - - bool SetLoadAddress(Target , addr_t value, - bool value_is_offset) override { -assert(!value_is_offset); -assert(value == m_base); - -// Create sections if they haven't been created already. -GetModule()->GetSectionList(); -assert(m_sections_up->GetNumSections(0) == 1); - -target.GetSectionLoadList().SetSectionLoadAddress( -m_sections_up->GetSectionAtIndex(0), m_base); -return true; - } - - void Dump(Stream *s) override { -s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n", - GetFileSpec(), m_base, m_base + m_size); - } - - lldb::addr_t GetBaseImageAddress() const { return m_base; } -private: - ArchSpec m_arch; - UUID m_uuid; - lldb::addr_t m_base; - lldb::addr_t m_size; -}; - /// Duplicate the HashElfTextSection() from the breakpad sources. /// /// Breakpad, a Google crash log reporting tool suite, creates minidump files @@ -578,12 +501,12 @@ // Watch out for place holder modules that have different paths, but the // same UUID. If the base address is different, create a new module. If // we don't then we will end up setting the load address of a different - // PlaceholderObjectFile and an assertion will fire. + // ObjectFilePlaceholder and an assertion will fire. auto *objfile = module_sp->GetObjectFile(); if (objfile && objfile->GetPluginName() == - PlaceholderObjectFile::GetStaticPluginName().GetStringRef()) { -
[Lldb-commits] [PATCH] D145955: Refactor ObjectFilePlaceholder for sharing
yinghuitan created this revision. yinghuitan added reviewers: clayborg, labath, jingham, jdoerfert, JDevlieghere, kusmour, GeorgeHuyubo. Herald added a project: All. yinghuitan requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. This patch refactors PlaceholderObjectFile into ObjectFile plugin directory so that we can reuse it for other cases like coredump debugging with NT_FILE notes. PlaceholderObjectFile is also renamed to ObjectFilePlaceholder to be consistent with ObjectFile plugin naming convention. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D145955 Files: lldb/source/Plugins/ObjectFile/CMakeLists.txt lldb/source/Plugins/ObjectFile/Placeholder/CMakeLists.txt lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.cpp lldb/source/Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.h lldb/source/Plugins/Process/minidump/CMakeLists.txt lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp === --- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp +++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp @@ -34,6 +34,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Threading.h" +#include "Plugins/ObjectFile/Placeholder/ObjectFilePlaceholder.h" #include "Plugins/Process/Utility/StopInfoMachException.h" #include @@ -47,84 +48,6 @@ namespace { -/// A minimal ObjectFile implementation providing a dummy object file for the -/// cases when the real module binary is not available. This allows the module -/// to show up in "image list" and symbols to be added to it. -class PlaceholderObjectFile : public ObjectFile { -public: - PlaceholderObjectFile(const lldb::ModuleSP _sp, -const ModuleSpec _spec, lldb::addr_t base, -lldb::addr_t size) - : ObjectFile(module_sp, _spec.GetFileSpec(), /*file_offset*/ 0, - /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0), -m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()), -m_base(base), m_size(size) { -m_symtab_up = std::make_unique(this); - } - - static ConstString GetStaticPluginName() { -return ConstString("placeholder"); - } - llvm::StringRef GetPluginName() override { -return GetStaticPluginName().GetStringRef(); - } - bool ParseHeader() override { return true; } - Type CalculateType() override { return eTypeUnknown; } - Strata CalculateStrata() override { return eStrataUnknown; } - uint32_t GetDependentModules(FileSpecList _list) override { return 0; } - bool IsExecutable() const override { return false; } - ArchSpec GetArchitecture() override { return m_arch; } - UUID GetUUID() override { return m_uuid; } - void ParseSymtab(lldb_private::Symtab ) override {} - bool IsStripped() override { return true; } - ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); } - - uint32_t GetAddressByteSize() const override { -return m_arch.GetAddressByteSize(); - } - - Address GetBaseAddress() override { -return Address(m_sections_up->GetSectionAtIndex(0), 0); - } - - void CreateSections(SectionList _section_list) override { -m_sections_up = std::make_unique(); -auto section_sp = std::make_shared( -GetModule(), this, /*sect_id*/ 0, ConstString(".module_image"), -eSectionTypeOther, m_base, m_size, /*file_offset*/ 0, /*file_size*/ 0, -/*log2align*/ 0, /*flags*/ 0); -section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable); -m_sections_up->AddSection(section_sp); -unified_section_list.AddSection(std::move(section_sp)); - } - - bool SetLoadAddress(Target , addr_t value, - bool value_is_offset) override { -assert(!value_is_offset); -assert(value == m_base); - -// Create sections if they haven't been created already. -GetModule()->GetSectionList(); -assert(m_sections_up->GetNumSections(0) == 1); - -target.GetSectionLoadList().SetSectionLoadAddress( -m_sections_up->GetSectionAtIndex(0), m_base); -return true; - } - - void Dump(Stream *s) override { -s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n", - GetFileSpec(), m_base, m_base + m_size); - } - - lldb::addr_t GetBaseImageAddress() const { return m_base; } -private: - ArchSpec m_arch; - UUID m_uuid; - lldb::addr_t m_base; - lldb::addr_t m_size; -}; - /// Duplicate the HashElfTextSection() from the breakpad sources. /// /// Breakpad, a Google crash log reporting tool suite, creates minidump files @@ -578,12 +501,12 @@ // Watch out for place holder modules that have different paths, but the // same UUID. If the base address is different, create a new module. If // we don't then we will end up setting the load address of a