Index: include/llvm/DebugInfo/PDB/DIA/DIASession.h =================================================================== --- include/llvm/DebugInfo/PDB/DIA/DIASession.h +++ include/llvm/DebugInfo/PDB/DIA/DIASession.h @@ -42,6 +42,9 @@ const IPDBSourceFile &File) const override; std::unique_ptr findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override; + std::unique_ptr + findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const override; std::unique_ptr findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, Index: include/llvm/DebugInfo/PDB/IPDBSession.h =================================================================== --- include/llvm/DebugInfo/PDB/IPDBSession.h +++ include/llvm/DebugInfo/PDB/IPDBSession.h @@ -45,6 +45,9 @@ const IPDBSourceFile &File) const = 0; virtual std::unique_ptr findLineNumbersByAddress(uint64_t Address, uint32_t Length) const = 0; + virtual std::unique_ptr + findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const = 0; virtual std::unique_ptr findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, Index: include/llvm/DebugInfo/PDB/Native/NativeSession.h =================================================================== --- include/llvm/DebugInfo/PDB/Native/NativeSession.h +++ include/llvm/DebugInfo/PDB/Native/NativeSession.h @@ -61,6 +61,9 @@ const IPDBSourceFile &File) const override; std::unique_ptr findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override; + std::unique_ptr + findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const override; std::unique_ptr findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, Index: lib/DebugInfo/PDB/DIA/DIASession.cpp =================================================================== --- lib/DebugInfo/PDB/DIA/DIASession.cpp +++ lib/DebugInfo/PDB/DIA/DIASession.cpp @@ -182,6 +182,8 @@ ULONGLONG LoadAddr = 0; if (S_OK != Session->get_loadAddress(&LoadAddr)) return nullptr; + if (Address < LoadAddr) + return nullptr; DWORD RVA = static_cast(Address - LoadAddr); if (S_OK != Session->findSymbolByRVA(RVA, EnumVal, &Symbol)) return nullptr; @@ -209,7 +211,24 @@ std::unique_ptr DIASession::findLineNumbersByAddress(uint64_t Address, uint32_t Length) const { CComPtr LineNumbers; - if (S_OK != Session->findLinesByVA(Address, Length, &LineNumbers)) + if (S_OK != Session->findLinesByVA(Address, Length, &LineNumbers)) { + ULONGLONG LoadAddr = 0; + if (S_OK != Session->get_loadAddress(&LoadAddr)) + return nullptr; + if (Address < LoadAddr) + return nullptr; + DWORD RVA = static_cast(Address - LoadAddr); + if (S_OK != Session->findLinesByRVA(RVA, Length, &LineNumbers)) + return nullptr; + } + return llvm::make_unique(LineNumbers); +} + +std::unique_ptr +DIASession::findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const { + CComPtr LineNumbers; + if (S_OK != Session->findLinesByAddr(Section, Offset, Length, &LineNumbers)) return nullptr; return llvm::make_unique(LineNumbers); Index: lib/DebugInfo/PDB/Native/NativeSession.cpp =================================================================== --- lib/DebugInfo/PDB/Native/NativeSession.cpp +++ lib/DebugInfo/PDB/Native/NativeSession.cpp @@ -202,6 +202,12 @@ return nullptr; } +std::unique_ptr +NativeSession::findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const { + return nullptr; +} + std::unique_ptr NativeSession::findSourceFiles(const PDBSymbolCompiland *Compiland, StringRef Pattern, Index: unittests/DebugInfo/PDB/PDBApiTest.cpp =================================================================== --- unittests/DebugInfo/PDB/PDBApiTest.cpp +++ unittests/DebugInfo/PDB/PDBApiTest.cpp @@ -87,6 +87,11 @@ findLineNumbersByAddress(uint64_t Address, uint32_t Length) const override { return nullptr; } + std::unique_ptr + findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset, + uint32_t Length) const override { + return nullptr; + } std::unique_ptr findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern, PDB_NameSearchFlags Flags) const override {