[Lldb-commits] [lldb] 7730093 - Revert "[lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (#139170)"
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Thu Jun 5 17:47:09 PDT 2025
Author: Jason Molenda
Date: 2025-06-05T17:47:04-07:00
New Revision: 7730093596b898fa2773003f396da4b3ad1f3c0a
URL: https://github.com/llvm/llvm-project/commit/7730093596b898fa2773003f396da4b3ad1f3c0a
DIFF: https://github.com/llvm/llvm-project/commit/7730093596b898fa2773003f396da4b3ad1f3c0a.diff
LOG: Revert "[lldb] Don't create instance of `SymbolFileDWARFDebugMap` for non-Mach-O files (#139170)"
This reverts commit 3096f8768676bd64123270cc59b7cc904a72d875.
Reverting this commit because it depends on another PR
that was reverted, https://github.com/llvm/llvm-project/pull/142704
Both can be reapplied once we find a correct fix for that.
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
Removed:
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 83437c2db8778..f3a940b2ee396 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -246,10 +246,6 @@ llvm::StringRef SymbolFileDWARFDebugMap::GetPluginDescriptionStatic() {
}
SymbolFile *SymbolFileDWARFDebugMap::CreateInstance(ObjectFileSP objfile_sp) {
- assert(objfile_sp);
- // Don't create a debug map if the object file isn't a Mach-O.
- if (!objfile_sp->GetArchitecture().GetTriple().isAppleMachO())
- return nullptr;
return new SymbolFileDWARFDebugMap(std::move(objfile_sp));
}
diff --git a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
index 7408f88c5ab89..cf8702209a7c3 100644
--- a/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
+++ b/lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
@@ -4,7 +4,6 @@ add_lldb_unittest(SymbolFileDWARFTests
DWARFDIETest.cpp
DWARFIndexCachingTest.cpp
DWARFUnitTest.cpp
- SymbolFileDWARFDebugMapTests.cpp
SymbolFileDWARFTests.cpp
XcodeSDKModuleTests.cpp
diff --git a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp b/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
deleted file mode 100644
index 445304ad63110..0000000000000
--- a/lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFDebugMapTests.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-//===-- SymbolFileDWARFDebugMapTests.cpp ----------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "TestingSupport/SubsystemRAII.h"
-#include "TestingSupport/TestUtilities.h"
-
-#include "lldb/Core/Module.h"
-#include "llvm/Testing/Support/Error.h"
-
-#include "gtest/gtest.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::plugin::dwarf;
-
-class SymbolFileDWARFDebugMapTests : public testing::Test {
- SubsystemRAII<ObjectFileELF, ObjectFileMachO> subsystems;
-};
-
-TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNonNullForMachOFile) {
- // A Mach-O file built for arm64 CPU type and macOS platform.
- const char *yamldata = R"(
---- !mach-o
-FileHeader:
- magic: 0xFEEDFACF
- cputype: 0x0100000C
- cpusubtype: 0x00000000
- filetype: 0x00000001
- ncmds: 1
- sizeofcmds: 176
- flags: 0x00002000
- reserved: 0x00000000
-LoadCommands:
- - cmd: LC_BUILD_VERSION
- cmdsize: 24
- platform: 1
- minos: 658944
- sdk: 658944
- ntools: 0
- - cmd: LC_SEGMENT_64
- cmdsize: 152
- segname: __TEXT
- vmaddr: 0
- vmsize: 4
- fileoff: 208
- filesize: 4
- maxprot: 7
- initprot: 7
- nsects: 1
- flags: 0
- Sections:
- - sectname: __text
- segname: __TEXT
- addr: 0x0000000000000000
- content: 'AABBCCDD'
- size: 4
- offset: 208
- align: 0
- reloff: 0x00000000
- nreloc: 0
- flags: 0x80000400
- reserved1: 0x00000000
- reserved2: 0x00000000
- reserved3: 0x00000000
-...
-)";
-
- // Perform setup.
- llvm::Expected<TestFile> file = TestFile::fromYaml(yamldata);
- EXPECT_THAT_EXPECTED(file, llvm::Succeeded());
- auto module_sp = std::make_shared<Module>(file->moduleSpec());
- ASSERT_NE(module_sp, nullptr);
- auto object_file = module_sp->GetObjectFile();
- ASSERT_NE(object_file, nullptr);
-
- // The debug map should be non-null for Mach-O file.
- auto debug_map =
- SymbolFileDWARFDebugMap::CreateInstance(object_file->shared_from_this());
- ASSERT_NE(debug_map, nullptr);
-}
-
-TEST_F(SymbolFileDWARFDebugMapTests, CreateInstanceReturnNullForNonMachOFile) {
- // An ELF file.
- const char *yamldata = R"(
---- !ELF
-FileHeader:
- Class: ELFCLASS64
- Data: ELFDATA2LSB
- Type: ET_EXEC
- Machine: EM_386
-DWARF:
- debug_abbrev:
- - Table:
- - Code: 0x00000001
- Tag: DW_TAG_compile_unit
- Children: DW_CHILDREN_no
- Attributes:
- - Attribute: DW_AT_addr_base
- Form: DW_FORM_sec_offset
- debug_info:
- - Version: 5
- AddrSize: 4
- UnitType: DW_UT_compile
- Entries:
- - AbbrCode: 0x00000001
- Values:
- - Value: 0x8 # Offset of the first Address past the header
- - AbbrCode: 0x0
- debug_addr:
- - Version: 5
- AddressSize: 4
- Entries:
- - Address: 0x1234
- - Address: 0x5678
- debug_line:
- - Length: 42
- Version: 2
- PrologueLength: 36
- MinInstLength: 1
- DefaultIsStmt: 1
- LineBase: 251
- LineRange: 14
- OpcodeBase: 13
- StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ]
- IncludeDirs:
- - '/tmp'
- Files:
- - Name: main.cpp
- DirIdx: 1
- ModTime: 0
- Length: 0
-)";
-
- // Perform setup.
- llvm::Expected<TestFile> file = TestFile::fromYaml(yamldata);
- EXPECT_THAT_EXPECTED(file, llvm::Succeeded());
- auto module_sp = std::make_shared<Module>(file->moduleSpec());
- ASSERT_NE(module_sp, nullptr);
- auto object_file = module_sp->GetObjectFile();
- ASSERT_NE(object_file, nullptr);
-
- // The debug map should be null for non-Mach-O (ELF) file.
- auto debug_map =
- SymbolFileDWARFDebugMap::CreateInstance(object_file->shared_from_this());
- ASSERT_EQ(debug_map, nullptr);
-}
More information about the lldb-commits
mailing list