1 //===-- SourceReference.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 LLDB_TOOLS_LLDB_VSCODE_SOURCEREFERENCE_H 10 #define LLDB_TOOLS_LLDB_VSCODE_SOURCEREFERENCE_H 11 12 #include "lldb/lldb-types.h" 13 #include "llvm/ADT/DenseMap.h" 14 #include <string> 15 16 namespace lldb_vscode { 17 18 struct SourceReference { 19 std::string content; 20 llvm::DenseMap<lldb::addr_t, int64_t> addr_to_line; 21 GetLineForPCSourceReference22 int64_t GetLineForPC(lldb::addr_t pc) const { 23 auto addr_line = addr_to_line.find(pc); 24 if (addr_line != addr_to_line.end()) 25 return addr_line->second; 26 return 0; 27 } 28 }; 29 30 } // namespace lldb_vscode 31 32 #endif 33