1061da546Spatrick //===-- SourceReference.h ---------------------------------------*- C++ -*-===// 2061da546Spatrick // 3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information. 5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6061da546Spatrick // 7061da546Spatrick //===----------------------------------------------------------------------===// 8061da546Spatrick 9*dda28197Spatrick #ifndef LLDB_TOOLS_LLDB_VSCODE_SOURCEREFERENCE_H 10*dda28197Spatrick #define LLDB_TOOLS_LLDB_VSCODE_SOURCEREFERENCE_H 11061da546Spatrick 12061da546Spatrick #include "lldb/lldb-types.h" 13061da546Spatrick #include "llvm/ADT/DenseMap.h" 14061da546Spatrick #include <string> 15061da546Spatrick 16061da546Spatrick namespace lldb_vscode { 17061da546Spatrick 18061da546Spatrick struct SourceReference { 19061da546Spatrick std::string content; 20061da546Spatrick llvm::DenseMap<lldb::addr_t, int64_t> addr_to_line; 21061da546Spatrick GetLineForPCSourceReference22061da546Spatrick int64_t GetLineForPC(lldb::addr_t pc) const { 23061da546Spatrick auto addr_line = addr_to_line.find(pc); 24061da546Spatrick if (addr_line != addr_to_line.end()) 25061da546Spatrick return addr_line->second; 26061da546Spatrick return 0; 27061da546Spatrick } 28061da546Spatrick }; 29061da546Spatrick 30061da546Spatrick } // namespace lldb_vscode 31061da546Spatrick 32061da546Spatrick #endif 33