From 1d6cc768e544807992d000f62973f11f2a9000d2 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Sat, 14 Mar 2015 03:46:40 +0000 Subject: [PATCH] [dsymutil] Identify each CompileUnit with a unique ID. The ID can eg. de used in MCSymbol names to differentiate the ones that need to be created for every unit. The ID is a constructor parameter and not a static class member so there is no issue with counter updates if we decide to thread that code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232245 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/dsymutil/DwarfLinker.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp index ff79fa8c5a8..4a474057824 100644 --- a/tools/dsymutil/DwarfLinker.cpp +++ b/tools/dsymutil/DwarfLinker.cpp @@ -72,8 +72,8 @@ public: bool InDebugMap; ///< Was this DIE's entity found in the map? }; - CompileUnit(DWARFUnit &OrigUnit) - : OrigUnit(OrigUnit), LowPc(UINT64_MAX), HighPc(0), RangeAlloc(), + CompileUnit(DWARFUnit &OrigUnit, unsigned ID) + : OrigUnit(OrigUnit), ID(ID), LowPc(UINT64_MAX), HighPc(0), RangeAlloc(), Ranges(RangeAlloc), UnitRangeAttribute(nullptr) { Info.resize(OrigUnit.getNumDIEs()); } @@ -89,6 +89,8 @@ public: DWARFUnit &getOrigUnit() const { return OrigUnit; } + unsigned getUniqueID() const { return ID; } + DIE *getOutputUnitDIE() const { return CUDie.get(); } void setOutputUnitDIE(DIE *Die) { CUDie.reset(Die); } @@ -133,6 +135,7 @@ public: private: DWARFUnit &OrigUnit; + unsigned ID; std::vector Info; ///< DIE info indexed by DIE index. std::unique_ptr CUDie; ///< Root of the linked DIE tree. @@ -1728,7 +1731,8 @@ bool DwarfLinker::link(const DebugMap &Map) { // Size of the DIEs (and headers) generated for the linked output. uint64_t OutputDebugInfoSize = 0; - + // A unique ID that identifies each compile unit. + unsigned UnitID = 0; for (const auto &Obj : Map.objects()) { CurrentDebugObject = Obj.get(); @@ -1759,7 +1763,7 @@ bool DwarfLinker::link(const DebugMap &Map) { outs() << "Input compilation unit:"; CUDie->dump(outs(), CU.get(), 0); } - Units.emplace_back(*CU); + Units.emplace_back(*CU, UnitID++); gatherDIEParents(CUDie, 0, Units.back()); } -- 2.34.1