summaryrefslogtreecommitdiffstats
path: root/lldb/tools/lldb-vscode/SourceReference.h
blob: f047143e6c8439182a36c6c2b4459d9ba31ff4c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//===-- SourceReference.h ---------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLDBVSCODE_SOURCEREFERENCE_H_
#define LLDBVSCODE_SOURCEREFERENCE_H_

#include "lldb/lldb-types.h"
#include "llvm/ADT/DenseMap.h"
#include <string>

namespace lldb_vscode {

struct SourceReference {
  std::string content;
  llvm::DenseMap<lldb::addr_t, int64_t> addr_to_line;

  int64_t GetLineForPC(lldb::addr_t pc) const {
    auto addr_line = addr_to_line.find(pc);
    if (addr_line != addr_to_line.end())
      return addr_line->second;
    return 0;
  }
};

} // namespace lldb_vscode

#endif
OpenPOWER on IntegriCloud