1 //===-- DIContext.h ---------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines DIContext, an abstract data structure that holds
11 // debug information data.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_DEBUGINFO_DICONTEXT_H
16 #define LLVM_DEBUGINFO_DICONTEXT_H
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/DataTypes.h"
26 /// DILineInfo - a format-neutral container for source line information.
29 const char *FunctionName;
34 : FileName("<invalid>"), FunctionName("<invalid>"),
36 DILineInfo(const char *fileName, const char *functionName,
37 uint32_t line, uint32_t column)
38 : FileName(fileName), FunctionName(functionName),
39 Line(line), Column(column) {}
41 const char *getFileName() const { return FileName; }
42 const char *getFunctionName() const { return FunctionName; }
43 uint32_t getLine() const { return Line; }
44 uint32_t getColumn() const { return Column; }
46 bool operator==(const DILineInfo &RHS) const {
47 return Line == RHS.Line && Column == RHS.Column &&
48 std::strcmp(FileName, RHS.FileName) == 0 &&
49 std::strcmp(FunctionName, RHS.FunctionName) == 0;
51 bool operator!=(const DILineInfo &RHS) const {
52 return !(*this == RHS);
56 /// DILineInfoSpecifier - controls which fields of DILineInfo container
57 /// should be filled with data.
58 class DILineInfoSpecifier {
59 const uint32_t Flags; // Or'ed flags that set the info we want to fetch.
62 FileLineInfo = 1 << 0,
65 // Use file/line info by default.
66 DILineInfoSpecifier(uint32_t flags = FileLineInfo) : Flags(flags) {}
67 bool needs(Specification spec) const {
68 return (Flags & spec) > 0;
76 /// getDWARFContext - get a context for binary DWARF data.
77 static DIContext *getDWARFContext(bool isLittleEndian,
78 StringRef infoSection,
79 StringRef abbrevSection,
80 StringRef aRangeSection = StringRef(),
81 StringRef lineSection = StringRef(),
82 StringRef stringSection = StringRef());
84 virtual void dump(raw_ostream &OS) = 0;
86 virtual DILineInfo getLineInfoForAddress(uint64_t address,
87 DILineInfoSpecifier specifier = DILineInfoSpecifier()) = 0;