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/SmallString.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/DataTypes.h"
26 /// DILineInfo - a format-neutral container for source line information.
28 SmallString<16> FileName;
29 SmallString<16> FunctionName;
34 : FileName("<invalid>"), FunctionName("<invalid>"),
36 DILineInfo(const SmallString<16> &fileName,
37 const SmallString<16> &functionName,
38 uint32_t line, uint32_t column)
39 : FileName(fileName), FunctionName(functionName),
40 Line(line), Column(column) {}
42 const char *getFileName() { return FileName.c_str(); }
43 const char *getFunctionName() { return FunctionName.c_str(); }
44 uint32_t getLine() const { return Line; }
45 uint32_t getColumn() const { return Column; }
47 bool operator==(const DILineInfo &RHS) const {
48 return Line == RHS.Line && Column == RHS.Column &&
49 FileName.equals(RHS.FileName) &&
50 FunctionName.equals(RHS.FunctionName);
52 bool operator!=(const DILineInfo &RHS) const {
53 return !(*this == RHS);
57 /// DILineInfoSpecifier - controls which fields of DILineInfo container
58 /// should be filled with data.
59 class DILineInfoSpecifier {
60 const uint32_t Flags; // Or'ed flags that set the info we want to fetch.
63 FileLineInfo = 1 << 0,
64 AbsoluteFilePath = 1 << 1,
67 // Use file/line info by default.
68 DILineInfoSpecifier(uint32_t flags = FileLineInfo) : Flags(flags) {}
69 bool needs(Specification spec) const {
70 return (Flags & spec) > 0;
78 /// getDWARFContext - get a context for binary DWARF data.
79 static DIContext *getDWARFContext(bool isLittleEndian,
80 StringRef infoSection,
81 StringRef abbrevSection,
82 StringRef aRangeSection = StringRef(),
83 StringRef lineSection = StringRef(),
84 StringRef stringSection = StringRef(),
85 StringRef rangeSection = StringRef());
87 virtual void dump(raw_ostream &OS) = 0;
89 virtual DILineInfo getLineInfoForAddress(uint64_t address,
90 DILineInfoSpecifier specifier = DILineInfoSpecifier()) = 0;