1 //===- DWARF.h --------------------------------------------------*- C++ -*-===// 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 9 #ifndef LLD_DWARF_H 10 #define LLD_DWARF_H 11 12 #include "lld/Common/LLVM.h" 13 #include "llvm/ADT/DenseMap.h" 14 #include "llvm/ADT/StringRef.h" 15 #include "llvm/DebugInfo/DWARF/DWARFContext.h" 16 #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" 17 #include <memory> 18 #include <string> 19 20 namespace llvm { 21 struct DILineInfo; 22 } // namespace llvm 23 24 namespace lld { 25 26 class DWARFCache { 27 public: 28 DWARFCache(std::unique_ptr<llvm::DWARFContext> dwarf); 29 llvm::Optional<llvm::DILineInfo> getDILineInfo(uint64_t offset, 30 uint64_t sectionIndex); 31 llvm::Optional<std::pair<std::string, unsigned>> 32 getVariableLoc(StringRef name); 33 getContext()34 llvm::DWARFContext *getContext() { return dwarf.get(); } 35 36 private: 37 std::unique_ptr<llvm::DWARFContext> dwarf; 38 std::vector<const llvm::DWARFDebugLine::LineTable *> lineTables; 39 struct VarLoc { 40 const llvm::DWARFDebugLine::LineTable *lt; 41 unsigned file; 42 unsigned line; 43 }; 44 llvm::DenseMap<StringRef, VarLoc> variableLoc; 45 }; 46 47 } // namespace lld 48 49 #endif 50