DIContext.h revision 226584
1131702Smbr//===-- DIContext.h ---------------------------------------------*- C++ -*-===//
2131702Smbr//
3131702Smbr//                     The LLVM Compiler Infrastructure
4131702Smbr//
5131702Smbr// This file is distributed under the University of Illinois Open Source
6131702Smbr// License. See LICENSE.TXT for details.
7131702Smbr//
8131702Smbr//===----------------------------------------------------------------------===//
9131702Smbr//
10131702Smbr// This file defines DIContext, an abstract data structure that holds
11131702Smbr// debug information data.
12131702Smbr//
13131702Smbr//===----------------------------------------------------------------------===//
14131702Smbr
15131702Smbr#ifndef LLVM_DEBUGINFO_DICONTEXT_H
16131702Smbr#define LLVM_DEBUGINFO_DICONTEXT_H
17131702Smbr
18131702Smbr#include "llvm/ADT/StringRef.h"
19131702Smbr#include "llvm/Support/DataTypes.h"
20131702Smbr#include <cstring>
21131702Smbr
22131702Smbrnamespace llvm {
23131702Smbr
24131702Smbrclass raw_ostream;
25131702Smbr
26131702Smbr/// DILineInfo - a format-neutral container for source line information.
27131702Smbrclass DILineInfo {
28131702Smbr  const char *FileName;
29131702Smbr  uint32_t Line;
30131702Smbr  uint32_t Column;
31131702Smbrpublic:
32131702Smbr  DILineInfo() : FileName("<invalid>"), Line(0), Column(0) {}
33131702Smbr  DILineInfo(const char *fileName, uint32_t line, uint32_t column)
34131702Smbr    : FileName(fileName), Line(line), Column(column) {}
35131702Smbr
36131702Smbr  const char *getFileName() const { return FileName; }
37131702Smbr  uint32_t getLine() const { return Line; }
38131702Smbr  uint32_t getColumn() const { return Column; }
39131702Smbr
40131702Smbr  bool operator==(const DILineInfo &RHS) const {
41131702Smbr    return Line == RHS.Line && Column == RHS.Column &&
42131702Smbr           std::strcmp(FileName, RHS.FileName) == 0;
43131702Smbr  }
44131702Smbr  bool operator!=(const DILineInfo &RHS) const {
45131702Smbr    return !(*this == RHS);
46131702Smbr  }
47131702Smbr};
48131702Smbr
49131702Smbrclass DIContext {
50131702Smbrpublic:
51131702Smbr  virtual ~DIContext();
52131702Smbr
53131702Smbr  /// getDWARFContext - get a context for binary DWARF data.
54131702Smbr  static DIContext *getDWARFContext(bool isLittleEndian,
55131702Smbr                                    StringRef infoSection,
56131702Smbr                                    StringRef abbrevSection,
57131702Smbr                                    StringRef aRangeSection = StringRef(),
58131702Smbr                                    StringRef lineSection = StringRef(),
59131702Smbr                                    StringRef stringSection = StringRef());
60131702Smbr
61  virtual void dump(raw_ostream &OS) = 0;
62
63  virtual DILineInfo getLineInfoForAddress(uint64_t address) = 0;
64};
65
66}
67
68#endif
69