2008-11-10 02:56:27 +00:00
|
|
|
//===--- llvm/Analysis/DebugInfo.h - Debug Information Helpers --*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines a bunch of datatypes that are useful for creating and
|
2009-05-14 18:26:15 +00:00
|
|
|
// walking debug info in LLVM IR form. They essentially provide wrappers around
|
|
|
|
// the information in the global variables that's needed when constructing the
|
|
|
|
// DWARF information.
|
2008-11-10 02:56:27 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-01-26 07:31:20 +00:00
|
|
|
#ifndef LLVM_ANALYSIS_DEBUGINFO_H
|
|
|
|
#define LLVM_ANALYSIS_DEBUGINFO_H
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2009-07-28 19:55:13 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2009-12-31 03:02:08 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2009-12-31 03:02:42 +00:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
2008-11-10 02:56:27 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class BasicBlock;
|
|
|
|
class Constant;
|
|
|
|
class Function;
|
|
|
|
class GlobalVariable;
|
|
|
|
class Module;
|
2008-11-10 04:10:34 +00:00
|
|
|
class Type;
|
2008-11-10 02:56:27 +00:00
|
|
|
class Value;
|
2010-01-06 17:16:00 +00:00
|
|
|
class DbgDeclareInst;
|
2008-12-16 09:07:36 +00:00
|
|
|
class Instruction;
|
2009-12-31 03:02:08 +00:00
|
|
|
class MDNode;
|
2010-11-10 22:19:21 +00:00
|
|
|
class NamedMDNode;
|
2009-12-31 03:02:08 +00:00
|
|
|
class LLVMContext;
|
2010-05-07 15:30:29 +00:00
|
|
|
class raw_ostream;
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2010-08-02 22:51:46 +00:00
|
|
|
class DIFile;
|
|
|
|
class DISubprogram;
|
|
|
|
class DILexicalBlock;
|
2011-10-11 22:59:11 +00:00
|
|
|
class DILexicalBlockFile;
|
2010-08-02 22:51:46 +00:00
|
|
|
class DIVariable;
|
|
|
|
class DIType;
|
2012-02-06 17:49:43 +00:00
|
|
|
class DIObjCProperty;
|
2010-08-02 22:51:46 +00:00
|
|
|
|
2009-12-29 09:15:46 +00:00
|
|
|
/// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
|
2012-05-08 18:55:57 +00:00
|
|
|
/// This should not be stored in a container, because the underlying MDNode
|
|
|
|
/// may change in certain situations.
|
2008-11-10 02:56:27 +00:00
|
|
|
class DIDescriptor {
|
2010-09-29 21:04:46 +00:00
|
|
|
public:
|
|
|
|
enum {
|
2011-05-12 19:06:16 +00:00
|
|
|
FlagPrivate = 1 << 0,
|
|
|
|
FlagProtected = 1 << 1,
|
|
|
|
FlagFwdDecl = 1 << 2,
|
|
|
|
FlagAppleBlock = 1 << 3,
|
|
|
|
FlagBlockByrefStruct = 1 << 4,
|
|
|
|
FlagVirtual = 1 << 5,
|
|
|
|
FlagArtificial = 1 << 6,
|
|
|
|
FlagExplicit = 1 << 7,
|
|
|
|
FlagPrototyped = 1 << 8,
|
2012-09-12 23:36:19 +00:00
|
|
|
FlagObjcClassComplete = 1 << 9,
|
|
|
|
FlagObjectPointer = 1 << 10
|
2010-09-29 21:04:46 +00:00
|
|
|
};
|
2009-09-19 20:40:05 +00:00
|
|
|
protected:
|
2010-05-07 20:54:48 +00:00
|
|
|
const MDNode *DbgNode;
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getStringField(unsigned Elt) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned getUnsignedField(unsigned Elt) const {
|
|
|
|
return (unsigned)getUInt64Field(Elt);
|
|
|
|
}
|
|
|
|
uint64_t getUInt64Field(unsigned Elt) const;
|
2012-12-03 19:44:25 +00:00
|
|
|
int64_t getInt64Field(unsigned Elt) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
DIDescriptor getDescriptorField(unsigned Elt) const;
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
template <typename DescTy>
|
|
|
|
DescTy getFieldAs(unsigned Elt) const {
|
2010-05-07 18:36:34 +00:00
|
|
|
return DescTy(getDescriptorField(Elt));
|
2008-11-10 02:56:27 +00:00
|
|
|
}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
GlobalVariable *getGlobalVariableField(unsigned Elt) const;
|
2010-08-09 21:39:24 +00:00
|
|
|
Constant *getConstantField(unsigned Elt) const;
|
2010-06-11 20:08:44 +00:00
|
|
|
Function *getFunctionField(unsigned Elt) const;
|
2012-10-09 08:13:15 +00:00
|
|
|
void replaceFunctionField(unsigned Elt, Function *F);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIDescriptor() : DbgNode(0) {}
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
|
2010-08-02 22:51:46 +00:00
|
|
|
explicit DIDescriptor(const DIFile F);
|
|
|
|
explicit DIDescriptor(const DISubprogram F);
|
2011-10-11 22:59:11 +00:00
|
|
|
explicit DIDescriptor(const DILexicalBlockFile F);
|
2010-08-02 22:51:46 +00:00
|
|
|
explicit DIDescriptor(const DILexicalBlock F);
|
|
|
|
explicit DIDescriptor(const DIVariable F);
|
|
|
|
explicit DIDescriptor(const DIType F);
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2010-03-08 20:52:55 +00:00
|
|
|
bool Verify() const { return DbgNode != 0; }
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2010-05-07 20:54:48 +00:00
|
|
|
operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
|
|
|
|
MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
|
2009-01-05 18:06:21 +00:00
|
|
|
|
2009-01-05 22:35:52 +00:00
|
|
|
unsigned getVersion() const {
|
2009-01-20 19:22:03 +00:00
|
|
|
return getUnsignedField(0) & LLVMDebugVersionMask;
|
2009-01-05 22:35:52 +00:00
|
|
|
}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-01-05 18:06:21 +00:00
|
|
|
unsigned getTag() const {
|
2009-01-20 19:22:03 +00:00
|
|
|
return getUnsignedField(0) & ~LLVMDebugVersionMask;
|
2009-01-05 18:06:21 +00:00
|
|
|
}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-08-31 18:49:10 +00:00
|
|
|
bool isDerivedType() const;
|
|
|
|
bool isCompositeType() const;
|
|
|
|
bool isBasicType() const;
|
|
|
|
bool isVariable() const;
|
|
|
|
bool isSubprogram() const;
|
|
|
|
bool isGlobalVariable() const;
|
2009-08-31 20:44:45 +00:00
|
|
|
bool isScope() const;
|
2010-03-08 22:27:22 +00:00
|
|
|
bool isFile() const;
|
2009-08-31 21:34:44 +00:00
|
|
|
bool isCompileUnit() const;
|
2009-12-15 19:16:48 +00:00
|
|
|
bool isNameSpace() const;
|
2011-10-11 22:59:11 +00:00
|
|
|
bool isLexicalBlockFile() const;
|
2009-08-31 22:00:15 +00:00
|
|
|
bool isLexicalBlock() const;
|
2009-09-30 22:34:41 +00:00
|
|
|
bool isSubrange() const;
|
|
|
|
bool isEnumerator() const;
|
|
|
|
bool isType() const;
|
|
|
|
bool isGlobal() const;
|
2010-10-06 20:50:40 +00:00
|
|
|
bool isUnspecifiedParameter() const;
|
2011-02-02 21:38:25 +00:00
|
|
|
bool isTemplateTypeParameter() const;
|
2011-02-02 22:35:53 +00:00
|
|
|
bool isTemplateValueParameter() const;
|
2012-02-04 00:59:25 +00:00
|
|
|
bool isObjCProperty() const;
|
2012-06-26 22:57:33 +00:00
|
|
|
|
|
|
|
/// print - print descriptor.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print descriptor to dbgs() with a newline.
|
|
|
|
void dump() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-01-05 18:33:01 +00:00
|
|
|
/// DISubrange - This is used to represent ranges, for array bounds.
|
|
|
|
class DISubrange : public DIDescriptor {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2009-01-05 18:33:01 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2011-11-17 23:43:15 +00:00
|
|
|
uint64_t getLo() const { return getUInt64Field(1); }
|
2012-12-04 21:34:03 +00:00
|
|
|
int64_t getCount() const { return getInt64Field(2); }
|
2009-01-05 18:33:01 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIArray - This descriptor holds an array of descriptors.
|
|
|
|
class DIArray : public DIDescriptor {
|
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIArray(const MDNode *N = 0)
|
2009-08-28 23:24:31 +00:00
|
|
|
: DIDescriptor(N) {}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned getNumElements() const;
|
2009-01-05 19:55:07 +00:00
|
|
|
DIDescriptor getElement(unsigned Idx) const {
|
|
|
|
return getDescriptorField(Idx);
|
2009-01-05 18:33:01 +00:00
|
|
|
}
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-08-31 20:44:45 +00:00
|
|
|
/// DIScope - A base class for various scopes.
|
|
|
|
class DIScope : public DIDescriptor {
|
2012-06-26 22:57:33 +00:00
|
|
|
protected:
|
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2009-08-31 20:44:45 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
|
2009-09-01 00:53:21 +00:00
|
|
|
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getFilename() const;
|
|
|
|
StringRef getDirectory() const;
|
2009-08-31 20:44:45 +00:00
|
|
|
};
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DICompileUnit - A wrapper for a compile unit.
|
2009-08-31 21:34:44 +00:00
|
|
|
class DICompileUnit : public DIScope {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2010-07-19 23:56:30 +00:00
|
|
|
unsigned getLanguage() const { return getUnsignedField(2); }
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getFilename() const { return getStringField(3); }
|
|
|
|
StringRef getDirectory() const { return getStringField(4); }
|
|
|
|
StringRef getProducer() const { return getStringField(5); }
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-01-30 18:20:31 +00:00
|
|
|
/// isMain - Each input file is encoded as a separate compile unit in LLVM
|
|
|
|
/// debugging information output. However, many target specific tool chains
|
2009-09-19 20:40:05 +00:00
|
|
|
/// prefer to encode only one compile unit in an object file. In this
|
2009-01-30 18:20:31 +00:00
|
|
|
/// situation, the LLVM code generator will include debugging information
|
2009-09-19 20:40:05 +00:00
|
|
|
/// entities in the compile unit that is marked as main compile unit. The
|
2009-01-30 18:20:31 +00:00
|
|
|
/// code generator accepts maximum one main compile unit per module. If a
|
2009-09-19 20:40:05 +00:00
|
|
|
/// module does not contain any main compile unit then the code generator
|
2009-01-30 18:20:31 +00:00
|
|
|
/// will emit multiple compile units in the output object file.
|
2009-02-17 22:43:44 +00:00
|
|
|
|
2010-09-25 20:27:36 +00:00
|
|
|
bool isMain() const { return getUnsignedField(6) != 0; }
|
|
|
|
bool isOptimized() const { return getUnsignedField(7) != 0; }
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getFlags() const { return getStringField(8); }
|
2009-02-17 22:43:44 +00:00
|
|
|
unsigned getRunTimeVersion() const { return getUnsignedField(9); }
|
2009-01-20 18:13:03 +00:00
|
|
|
|
2011-08-16 22:09:43 +00:00
|
|
|
DIArray getEnumTypes() const;
|
|
|
|
DIArray getRetainedTypes() const;
|
|
|
|
DIArray getSubprograms() const;
|
|
|
|
DIArray getGlobalVariables() const;
|
|
|
|
|
2009-01-19 23:21:49 +00:00
|
|
|
/// Verify - Verify that a compile unit is well formed.
|
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
|
|
|
|
2010-03-08 22:27:22 +00:00
|
|
|
/// DIFile - This is a wrapper for a file.
|
|
|
|
class DIFile : public DIScope {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const {} // FIXME: Output something?
|
2010-03-08 22:27:22 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIFile(const MDNode *N = 0) : DIScope(N) {
|
2010-03-08 22:27:22 +00:00
|
|
|
if (DbgNode && !isFile())
|
|
|
|
DbgNode = 0;
|
|
|
|
}
|
|
|
|
StringRef getFilename() const { return getStringField(1); }
|
|
|
|
StringRef getDirectory() const { return getStringField(2); }
|
2012-11-20 00:15:36 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
2011-08-16 22:09:43 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion10 && "Invalid CompileUnit!");
|
2012-11-20 00:15:36 +00:00
|
|
|
return getFieldAs<DICompileUnit>(3);
|
2011-08-16 22:09:43 +00:00
|
|
|
}
|
2010-03-08 22:27:22 +00:00
|
|
|
};
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
|
|
|
|
/// FIXME: it seems strange that this doesn't have either a reference to the
|
|
|
|
/// type/precision or a file/line pair for location info.
|
|
|
|
class DIEnumerator : public DIDescriptor {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getName() const { return getStringField(1); }
|
2009-09-29 18:40:58 +00:00
|
|
|
uint64_t getEnumValue() const { return getUInt64Field(2); }
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIType - This is a wrapper for a type.
|
|
|
|
/// FIXME: Types should be factored much better so that CV qualifiers and
|
|
|
|
/// others do not require a huge and empty descriptor full of zeros.
|
2010-03-08 22:02:50 +00:00
|
|
|
class DIType : public DIScope {
|
2008-11-10 02:56:27 +00:00
|
|
|
protected:
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
// This ctor is used when the Tag has already been validated by a derived
|
|
|
|
// ctor.
|
2010-05-07 20:54:48 +00:00
|
|
|
DIType(const MDNode *N, bool, bool) : DIScope(N) {}
|
2009-01-15 19:26:23 +00:00
|
|
|
public:
|
2009-01-19 23:21:49 +00:00
|
|
|
/// Verify - Verify that a type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIType(const MDNode *N);
|
2008-11-10 02:56:27 +00:00
|
|
|
explicit DIType() {}
|
2009-01-05 22:35:52 +00:00
|
|
|
|
2010-03-08 22:02:50 +00:00
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
2009-12-15 19:16:48 +00:00
|
|
|
StringRef getName() const { return getStringField(2); }
|
2012-11-20 00:15:36 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
2011-08-16 22:09:43 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");
|
2010-10-28 20:41:11 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(3);
|
2012-11-20 00:15:36 +00:00
|
|
|
|
2010-10-29 16:42:37 +00:00
|
|
|
return getFieldAs<DIFile>(3).getCompileUnit();
|
2010-03-09 00:44:10 +00:00
|
|
|
}
|
2010-11-04 14:56:34 +00:00
|
|
|
DIFile getFile() const { return getFieldAs<DIFile>(3); }
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned getLineNumber() const { return getUnsignedField(4); }
|
|
|
|
uint64_t getSizeInBits() const { return getUInt64Field(5); }
|
|
|
|
uint64_t getAlignInBits() const { return getUInt64Field(6); }
|
|
|
|
// FIXME: Offset is only used for DW_TAG_member nodes. Making every type
|
|
|
|
// carry this is just plain insane.
|
|
|
|
uint64_t getOffsetInBits() const { return getUInt64Field(7); }
|
|
|
|
unsigned getFlags() const { return getUnsignedField(8); }
|
2009-08-26 04:21:30 +00:00
|
|
|
bool isPrivate() const {
|
2009-09-19 20:40:05 +00:00
|
|
|
return (getFlags() & FlagPrivate) != 0;
|
2009-07-27 20:30:05 +00:00
|
|
|
}
|
2009-08-26 04:21:30 +00:00
|
|
|
bool isProtected() const {
|
2009-09-19 20:40:05 +00:00
|
|
|
return (getFlags() & FlagProtected) != 0;
|
2009-07-27 20:30:05 +00:00
|
|
|
}
|
2009-08-26 04:21:30 +00:00
|
|
|
bool isForwardDecl() const {
|
2009-09-19 20:40:05 +00:00
|
|
|
return (getFlags() & FlagFwdDecl) != 0;
|
2009-07-27 20:30:05 +00:00
|
|
|
}
|
2009-08-27 23:51:51 +00:00
|
|
|
// isAppleBlock - Return true if this is the Apple Blocks extension.
|
|
|
|
bool isAppleBlockExtension() const {
|
2009-09-19 20:40:05 +00:00
|
|
|
return (getFlags() & FlagAppleBlock) != 0;
|
2009-08-26 00:39:50 +00:00
|
|
|
}
|
2009-08-31 21:19:37 +00:00
|
|
|
bool isBlockByrefStruct() const {
|
|
|
|
return (getFlags() & FlagBlockByrefStruct) != 0;
|
|
|
|
}
|
2009-12-03 19:11:07 +00:00
|
|
|
bool isVirtual() const {
|
|
|
|
return (getFlags() & FlagVirtual) != 0;
|
|
|
|
}
|
2010-02-06 01:02:37 +00:00
|
|
|
bool isArtificial() const {
|
|
|
|
return (getFlags() & FlagArtificial) != 0;
|
|
|
|
}
|
2012-09-12 23:36:19 +00:00
|
|
|
bool isObjectPointer() const {
|
|
|
|
return (getFlags() & FlagObjectPointer) != 0;
|
|
|
|
}
|
2011-05-12 21:29:42 +00:00
|
|
|
bool isObjcClassComplete() const {
|
|
|
|
return (getFlags() & FlagObjcClassComplete) != 0;
|
2011-05-12 19:06:16 +00:00
|
|
|
}
|
2010-03-08 20:52:55 +00:00
|
|
|
bool isValid() const {
|
|
|
|
return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
|
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getDirectory() const {
|
2010-10-28 20:08:13 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getCompileUnit().getDirectory();
|
|
|
|
|
2010-10-29 16:42:37 +00:00
|
|
|
return getFieldAs<DIFile>(3).getDirectory();
|
2010-10-28 19:50:08 +00:00
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getFilename() const {
|
2010-10-28 20:08:13 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getCompileUnit().getFilename();
|
|
|
|
|
2010-10-29 16:42:37 +00:00
|
|
|
return getFieldAs<DIFile>(3).getFilename();
|
2010-10-28 19:50:08 +00:00
|
|
|
}
|
2010-05-07 15:30:29 +00:00
|
|
|
|
2011-08-15 17:57:41 +00:00
|
|
|
/// isUnsignedDIType - Return true if type encoding is unsigned.
|
|
|
|
bool isUnsignedDIType();
|
|
|
|
|
2010-08-20 22:02:26 +00:00
|
|
|
/// replaceAllUsesWith - Replace all uses of debug info referenced by
|
|
|
|
/// this descriptor.
|
|
|
|
void replaceAllUsesWith(DIDescriptor &D);
|
2010-12-08 20:18:20 +00:00
|
|
|
void replaceAllUsesWith(MDNode *D);
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIBasicType - A basic type, like 'int' or 'float'.
|
|
|
|
class DIBasicType : public DIType {
|
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
|
2009-05-14 18:26:15 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned getEncoding() const { return getUnsignedField(9); }
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2010-08-23 18:25:56 +00:00
|
|
|
/// Verify - Verify that a basic type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIDerivedType - A simple derived type, like a const qualified type,
|
|
|
|
/// a typedef, a pointer or reference, etc.
|
|
|
|
class DIDerivedType : public DIType {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
protected:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIDerivedType(const MDNode *N, bool, bool)
|
2009-08-28 23:24:31 +00:00
|
|
|
: DIType(N, true, true) {}
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIDerivedType(const MDNode *N = 0)
|
2010-03-08 21:32:10 +00:00
|
|
|
: DIType(N, true, true) {}
|
2009-05-14 18:26:15 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2009-02-17 21:23:59 +00:00
|
|
|
/// getOriginalTypeSize - If this type is derived from a base type then
|
|
|
|
/// return base type size.
|
|
|
|
uint64_t getOriginalTypeSize() const;
|
2010-05-07 15:30:29 +00:00
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
/// getObjCProperty - Return property node, if this ivar is
|
2012-02-06 17:49:43 +00:00
|
|
|
/// associated with one.
|
|
|
|
MDNode *getObjCProperty() const;
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getObjCPropertyName() const {
|
2012-02-04 01:30:01 +00:00
|
|
|
if (getVersion() > LLVMDebugVersion11)
|
2012-02-08 00:17:07 +00:00
|
|
|
return StringRef();
|
2012-11-20 00:15:36 +00:00
|
|
|
return getStringField(10);
|
2012-02-04 01:30:01 +00:00
|
|
|
}
|
2011-04-16 00:11:51 +00:00
|
|
|
StringRef getObjCPropertyGetterName() const {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return getStringField(11);
|
|
|
|
}
|
|
|
|
StringRef getObjCPropertySetterName() const {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return getStringField(12);
|
|
|
|
}
|
|
|
|
bool isReadOnlyObjCProperty() {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
|
|
|
|
}
|
|
|
|
bool isReadWriteObjCProperty() {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
|
|
|
|
}
|
|
|
|
bool isAssignObjCProperty() {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
|
|
|
|
}
|
|
|
|
bool isRetainObjCProperty() {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
|
|
|
|
}
|
|
|
|
bool isCopyObjCProperty() {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
|
|
|
|
}
|
|
|
|
bool isNonAtomicObjCProperty() {
|
2012-02-04 01:30:01 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion11 && "Invalid Request");
|
2011-04-16 00:11:51 +00:00
|
|
|
return (getUnsignedField(13) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
|
|
|
|
}
|
|
|
|
|
2010-08-23 18:25:56 +00:00
|
|
|
/// Verify - Verify that a derived type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// DICompositeType - This descriptor holds a type that can refer to multiple
|
|
|
|
/// other types, like a function or struct.
|
|
|
|
/// FIXME: Why is this a DIDerivedType??
|
|
|
|
class DICompositeType : public DIDerivedType {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DICompositeType(const MDNode *N = 0)
|
2009-08-28 23:24:31 +00:00
|
|
|
: DIDerivedType(N, true, true) {
|
2009-08-31 18:49:10 +00:00
|
|
|
if (N && !isCompositeType())
|
2009-08-28 23:24:31 +00:00
|
|
|
DbgNode = 0;
|
2009-05-14 18:26:15 +00:00
|
|
|
}
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
|
2009-02-17 22:43:44 +00:00
|
|
|
unsigned getRunTimeLang() const { return getUnsignedField(11); }
|
2010-01-26 21:14:59 +00:00
|
|
|
DICompositeType getContainingType() const {
|
|
|
|
return getFieldAs<DICompositeType>(12);
|
|
|
|
}
|
2011-02-02 21:38:25 +00:00
|
|
|
DIArray getTemplateParams() const { return getFieldAs<DIArray>(13); }
|
2009-01-19 23:21:49 +00:00
|
|
|
|
|
|
|
/// Verify - Verify that a composite type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2011-02-02 21:38:25 +00:00
|
|
|
/// DITemplateTypeParameter - This is a wrapper for template type parameter.
|
|
|
|
class DITemplateTypeParameter : public DIDescriptor {
|
|
|
|
public:
|
|
|
|
explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {}
|
|
|
|
|
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
|
|
|
StringRef getName() const { return getStringField(2); }
|
|
|
|
DIType getType() const { return getFieldAs<DIType>(3); }
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getFilename() const {
|
2011-02-02 21:38:25 +00:00
|
|
|
return getFieldAs<DIFile>(4).getFilename();
|
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getDirectory() const {
|
2011-02-02 21:38:25 +00:00
|
|
|
return getFieldAs<DIFile>(4).getDirectory();
|
|
|
|
}
|
|
|
|
unsigned getLineNumber() const { return getUnsignedField(5); }
|
|
|
|
unsigned getColumnNumber() const { return getUnsignedField(6); }
|
|
|
|
};
|
|
|
|
|
2011-02-02 22:35:53 +00:00
|
|
|
/// DITemplateValueParameter - This is a wrapper for template value parameter.
|
|
|
|
class DITemplateValueParameter : public DIDescriptor {
|
|
|
|
public:
|
|
|
|
explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {}
|
|
|
|
|
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
|
|
|
StringRef getName() const { return getStringField(2); }
|
|
|
|
DIType getType() const { return getFieldAs<DIType>(3); }
|
|
|
|
uint64_t getValue() const { return getUInt64Field(4); }
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getFilename() const {
|
2011-02-02 22:35:53 +00:00
|
|
|
return getFieldAs<DIFile>(5).getFilename();
|
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getDirectory() const {
|
2011-02-02 22:35:53 +00:00
|
|
|
return getFieldAs<DIFile>(5).getDirectory();
|
|
|
|
}
|
|
|
|
unsigned getLineNumber() const { return getUnsignedField(6); }
|
|
|
|
unsigned getColumnNumber() const { return getUnsignedField(7); }
|
|
|
|
};
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
|
2009-08-31 22:47:13 +00:00
|
|
|
class DISubprogram : public DIScope {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
|
2009-05-14 18:26:15 +00:00
|
|
|
|
2010-03-08 22:02:50 +00:00
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(2); }
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getName() const { return getStringField(3); }
|
|
|
|
StringRef getDisplayName() const { return getStringField(4); }
|
|
|
|
StringRef getLinkageName() const { return getStringField(5); }
|
2012-11-20 00:15:36 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
2011-08-16 22:09:43 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");
|
2010-03-09 00:44:10 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(6);
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
return getFieldAs<DIFile>(6).getCompileUnit();
|
2010-03-09 00:44:10 +00:00
|
|
|
}
|
2009-08-31 22:47:13 +00:00
|
|
|
unsigned getLineNumber() const { return getUnsignedField(7); }
|
2009-01-05 18:59:44 +00:00
|
|
|
DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
|
2009-01-19 23:21:49 +00:00
|
|
|
|
2009-06-23 22:07:48 +00:00
|
|
|
/// getReturnTypeName - Subprogram return types are encoded either as
|
|
|
|
/// DIType or as DICompositeType.
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getReturnTypeName() const {
|
2009-06-23 22:07:48 +00:00
|
|
|
DICompositeType DCT(getFieldAs<DICompositeType>(8));
|
2010-03-08 20:52:55 +00:00
|
|
|
if (DCT.Verify()) {
|
2009-06-23 22:07:48 +00:00
|
|
|
DIArray A = DCT.getTypeArray();
|
2010-05-07 18:11:54 +00:00
|
|
|
DIType T(A.getElement(0));
|
2009-09-29 18:40:58 +00:00
|
|
|
return T.getName();
|
2009-06-23 22:07:48 +00:00
|
|
|
}
|
|
|
|
DIType T(getFieldAs<DIType>(8));
|
2009-09-29 18:40:58 +00:00
|
|
|
return T.getName();
|
2009-06-23 22:07:48 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 22:47:13 +00:00
|
|
|
/// isLocalToUnit - Return true if this subprogram is local to the current
|
|
|
|
/// compile unit, like 'static' in C.
|
2009-09-29 18:40:58 +00:00
|
|
|
unsigned isLocalToUnit() const { return getUnsignedField(9); }
|
|
|
|
unsigned isDefinition() const { return getUnsignedField(10); }
|
2009-12-03 19:11:07 +00:00
|
|
|
|
2009-12-31 03:02:08 +00:00
|
|
|
unsigned getVirtuality() const { return getUnsignedField(11); }
|
|
|
|
unsigned getVirtualIndex() const { return getUnsignedField(12); }
|
2009-12-03 19:11:07 +00:00
|
|
|
|
|
|
|
DICompositeType getContainingType() const {
|
|
|
|
return getFieldAs<DICompositeType>(13);
|
|
|
|
}
|
2012-04-03 00:43:49 +00:00
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
unsigned isArtificial() const {
|
2010-09-29 21:04:46 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
2012-11-20 00:15:36 +00:00
|
|
|
return getUnsignedField(14);
|
2010-09-29 21:04:46 +00:00
|
|
|
return (getUnsignedField(14) & FlagArtificial) != 0;
|
|
|
|
}
|
2010-09-29 21:44:16 +00:00
|
|
|
/// isPrivate - Return true if this subprogram has "private"
|
|
|
|
/// access specifier.
|
2012-11-20 00:15:36 +00:00
|
|
|
bool isPrivate() const {
|
2010-09-29 21:44:16 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
|
|
|
return false;
|
|
|
|
return (getUnsignedField(14) & FlagPrivate) != 0;
|
|
|
|
}
|
|
|
|
/// isProtected - Return true if this subprogram has "protected"
|
|
|
|
/// access specifier.
|
2012-11-20 00:15:36 +00:00
|
|
|
bool isProtected() const {
|
2010-09-29 21:44:16 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
|
|
|
return false;
|
|
|
|
return (getUnsignedField(14) & FlagProtected) != 0;
|
|
|
|
}
|
2010-10-01 23:31:40 +00:00
|
|
|
/// isExplicit - Return true if this subprogram is marked as explicit.
|
2012-11-20 00:15:36 +00:00
|
|
|
bool isExplicit() const {
|
2010-10-01 23:31:40 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
|
|
|
return false;
|
|
|
|
return (getUnsignedField(14) & FlagExplicit) != 0;
|
|
|
|
}
|
2010-10-07 22:03:01 +00:00
|
|
|
/// isPrototyped - Return true if this subprogram is prototyped.
|
2012-11-20 00:15:36 +00:00
|
|
|
bool isPrototyped() const {
|
2010-10-07 22:03:01 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
|
|
|
return false;
|
|
|
|
return (getUnsignedField(14) & FlagPrototyped) != 0;
|
|
|
|
}
|
2010-10-01 23:31:40 +00:00
|
|
|
|
2010-04-30 19:38:23 +00:00
|
|
|
unsigned isOptimized() const;
|
2009-12-03 19:11:07 +00:00
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getFilename() const {
|
2010-03-24 18:48:00 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getCompileUnit().getFilename();
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
return getFieldAs<DIFile>(6).getFilename();
|
2010-03-24 18:48:00 +00:00
|
|
|
}
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getDirectory() const {
|
2010-03-24 18:48:00 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getCompileUnit().getFilename();
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
return getFieldAs<DIFile>(6).getDirectory();
|
2010-03-24 18:48:00 +00:00
|
|
|
}
|
2009-09-01 00:53:21 +00:00
|
|
|
|
2012-04-03 00:43:49 +00:00
|
|
|
/// getScopeLineNumber - Get the beginning of the scope of the
|
|
|
|
/// function, not necessarily where the name of the program
|
|
|
|
/// starts.
|
|
|
|
unsigned getScopeLineNumber() const { return getUnsignedField(20); }
|
|
|
|
|
2009-01-19 23:21:49 +00:00
|
|
|
/// Verify - Verify that a subprogram descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2009-04-15 00:06:07 +00:00
|
|
|
/// describes - Return true if this subprogram provides debugging
|
|
|
|
/// information for the function F.
|
|
|
|
bool describes(const Function *F);
|
2010-06-11 20:08:44 +00:00
|
|
|
|
|
|
|
Function *getFunction() const { return getFunctionField(16); }
|
2012-10-09 08:13:15 +00:00
|
|
|
void replaceFunction(Function *F) { replaceFunctionField(16, F); }
|
2011-04-05 22:52:06 +00:00
|
|
|
DIArray getTemplateParams() const { return getFieldAs<DIArray>(17); }
|
2011-04-22 23:10:17 +00:00
|
|
|
DISubprogram getFunctionDeclaration() const {
|
|
|
|
return getFieldAs<DISubprogram>(18);
|
|
|
|
}
|
2011-08-19 23:28:12 +00:00
|
|
|
MDNode *getVariablesNodes() const;
|
|
|
|
DIArray getVariables() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIGlobalVariable - This is a wrapper for a global variable.
|
2010-05-07 23:19:07 +00:00
|
|
|
class DIGlobalVariable : public DIDescriptor {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 23:19:07 +00:00
|
|
|
explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {}
|
|
|
|
|
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(2); }
|
|
|
|
StringRef getName() const { return getStringField(3); }
|
|
|
|
StringRef getDisplayName() const { return getStringField(4); }
|
|
|
|
StringRef getLinkageName() const { return getStringField(5); }
|
2012-11-20 00:15:36 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
2011-08-16 22:09:43 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");
|
2010-05-07 23:19:07 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(6);
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
DIFile F = getFieldAs<DIFile>(6);
|
2010-05-07 23:19:07 +00:00
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
2011-09-26 17:40:42 +00:00
|
|
|
StringRef getFilename() const {
|
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion10)
|
|
|
|
return getContext().getFilename();
|
|
|
|
return getFieldAs<DIFile>(6).getFilename();
|
2012-11-20 00:15:36 +00:00
|
|
|
}
|
2011-09-26 17:40:42 +00:00
|
|
|
StringRef getDirectory() const {
|
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion10)
|
|
|
|
return getContext().getDirectory();
|
|
|
|
return getFieldAs<DIFile>(6).getDirectory();
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
}
|
2010-05-07 23:19:07 +00:00
|
|
|
|
|
|
|
unsigned getLineNumber() const { return getUnsignedField(7); }
|
|
|
|
DIType getType() const { return getFieldAs<DIType>(8); }
|
|
|
|
unsigned isLocalToUnit() const { return getUnsignedField(9); }
|
|
|
|
unsigned isDefinition() const { return getUnsignedField(10); }
|
2009-05-14 18:26:15 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
|
2010-08-09 21:39:24 +00:00
|
|
|
Constant *getConstant() const { return getConstantField(11); }
|
2009-01-19 23:21:49 +00:00
|
|
|
|
|
|
|
/// Verify - Verify that a global variable descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
|
|
|
|
/// global etc).
|
|
|
|
class DIVariable : public DIDescriptor {
|
2012-06-26 22:57:33 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIVariable(const MDNode *N = 0)
|
2010-03-08 21:32:10 +00:00
|
|
|
: DIDescriptor(N) {}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2010-03-08 22:02:50 +00:00
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
|
|
|
StringRef getName() const { return getStringField(2); }
|
2012-11-20 00:15:36 +00:00
|
|
|
DICompileUnit getCompileUnit() const {
|
2011-08-16 22:09:43 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");
|
2010-03-09 00:44:10 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(3);
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
DIFile F = getFieldAs<DIFile>(3);
|
2010-03-09 00:44:10 +00:00
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
unsigned getLineNumber() const {
|
|
|
|
return (getUnsignedField(4) << 8) >> 8;
|
2011-03-01 22:58:13 +00:00
|
|
|
}
|
|
|
|
unsigned getArgNumber() const {
|
2012-11-20 00:15:36 +00:00
|
|
|
unsigned L = getUnsignedField(4);
|
2011-03-01 22:58:13 +00:00
|
|
|
return L >> 24;
|
|
|
|
}
|
2008-11-10 02:56:27 +00:00
|
|
|
DIType getType() const { return getFieldAs<DIType>(5); }
|
2012-11-20 00:15:36 +00:00
|
|
|
|
2010-09-29 23:07:21 +00:00
|
|
|
/// isArtificial - Return true if this variable is marked as "artificial".
|
2012-11-20 00:15:36 +00:00
|
|
|
bool isArtificial() const {
|
2010-09-29 23:07:21 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
|
|
|
return false;
|
|
|
|
return (getUnsignedField(6) & FlagArtificial) != 0;
|
|
|
|
}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2012-09-12 23:36:19 +00:00
|
|
|
bool isObjectPointer() const {
|
|
|
|
return (getUnsignedField(6) & FlagObjectPointer) != 0;
|
|
|
|
}
|
|
|
|
|
2011-07-20 22:18:50 +00:00
|
|
|
/// getInlinedAt - If this variable is inlined then return inline location.
|
2011-08-09 01:03:14 +00:00
|
|
|
MDNode *getInlinedAt() const;
|
2009-01-19 23:21:49 +00:00
|
|
|
|
|
|
|
/// Verify - Verify that a variable descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2009-09-30 00:08:22 +00:00
|
|
|
/// HasComplexAddr - Return true if the variable has a complex address.
|
|
|
|
bool hasComplexAddress() const {
|
|
|
|
return getNumAddrElements() > 0;
|
|
|
|
}
|
|
|
|
|
2009-12-31 03:02:08 +00:00
|
|
|
unsigned getNumAddrElements() const;
|
2012-11-20 00:15:36 +00:00
|
|
|
|
2009-09-30 00:08:22 +00:00
|
|
|
uint64_t getAddrElement(unsigned Idx) const {
|
2011-04-26 18:24:39 +00:00
|
|
|
if (getVersion() <= llvm::LLVMDebugVersion8)
|
|
|
|
return getUInt64Field(Idx+6);
|
2011-07-19 19:41:54 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion9)
|
|
|
|
return getUInt64Field(Idx+7);
|
|
|
|
return getUInt64Field(Idx+8);
|
2009-09-30 00:08:22 +00:00
|
|
|
}
|
|
|
|
|
2009-08-31 21:19:37 +00:00
|
|
|
/// isBlockByrefVariable - Return true if the variable was declared as
|
|
|
|
/// a "__block" variable (Apple Blocks).
|
2009-09-19 20:40:05 +00:00
|
|
|
bool isBlockByrefVariable() const {
|
|
|
|
return getType().isBlockByrefStruct();
|
2009-08-31 21:19:37 +00:00
|
|
|
}
|
|
|
|
|
2010-04-29 20:48:12 +00:00
|
|
|
/// isInlinedFnArgument - Return trule if this variable provides debugging
|
|
|
|
/// information for an inlined function arguments.
|
|
|
|
bool isInlinedFnArgument(const Function *CurFn);
|
|
|
|
|
2011-08-09 01:03:14 +00:00
|
|
|
void printExtendedName(raw_ostream &OS) const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-08-31 22:00:15 +00:00
|
|
|
/// DILexicalBlock - This is a wrapper for a lexical block.
|
|
|
|
class DILexicalBlock : public DIScope {
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
|
2010-02-16 21:39:34 +00:00
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
|
|
|
unsigned getLineNumber() const { return getUnsignedField(2); }
|
|
|
|
unsigned getColumnNumber() const { return getUnsignedField(3); }
|
2010-07-19 23:56:30 +00:00
|
|
|
StringRef getDirectory() const {
|
2010-10-29 16:42:37 +00:00
|
|
|
StringRef dir = getFieldAs<DIFile>(4).getDirectory();
|
2010-07-19 23:56:30 +00:00
|
|
|
return !dir.empty() ? dir : getContext().getDirectory();
|
|
|
|
}
|
|
|
|
StringRef getFilename() const {
|
2010-10-29 16:42:37 +00:00
|
|
|
StringRef filename = getFieldAs<DIFile>(4).getFilename();
|
2010-07-19 23:56:30 +00:00
|
|
|
return !filename.empty() ? filename : getContext().getFilename();
|
|
|
|
}
|
2009-09-01 01:14:15 +00:00
|
|
|
};
|
2009-09-01 00:53:21 +00:00
|
|
|
|
2011-10-11 22:59:11 +00:00
|
|
|
/// DILexicalBlockFile - This is a wrapper for a lexical block with
|
|
|
|
/// a filename change.
|
|
|
|
class DILexicalBlockFile : public DIScope {
|
|
|
|
public:
|
|
|
|
explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
|
2011-10-12 00:38:05 +00:00
|
|
|
DIScope getContext() const { return getScope().getContext(); }
|
2011-10-11 23:19:35 +00:00
|
|
|
unsigned getLineNumber() const { return getScope().getLineNumber(); }
|
|
|
|
unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
|
2011-10-11 22:59:11 +00:00
|
|
|
StringRef getDirectory() const {
|
|
|
|
StringRef dir = getFieldAs<DIFile>(2).getDirectory();
|
|
|
|
return !dir.empty() ? dir : getContext().getDirectory();
|
|
|
|
}
|
|
|
|
StringRef getFilename() const {
|
|
|
|
StringRef filename = getFieldAs<DIFile>(2).getFilename();
|
|
|
|
assert(!filename.empty() && "Why'd you create this then?");
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
DILexicalBlock getScope() const { return getFieldAs<DILexicalBlock>(1); }
|
|
|
|
};
|
|
|
|
|
2009-12-15 19:16:48 +00:00
|
|
|
/// DINameSpace - A wrapper for a C++ style name space.
|
2012-11-20 00:15:36 +00:00
|
|
|
class DINameSpace : public DIScope {
|
2009-12-15 19:16:48 +00:00
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
|
2009-12-15 19:16:48 +00:00
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
|
|
|
StringRef getName() const { return getStringField(2); }
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getDirectory() const {
|
2010-10-29 16:42:37 +00:00
|
|
|
return getFieldAs<DIFile>(3).getDirectory();
|
2010-10-28 19:14:28 +00:00
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
StringRef getFilename() const {
|
2010-10-29 16:42:37 +00:00
|
|
|
return getFieldAs<DIFile>(3).getFilename();
|
2010-10-28 19:14:28 +00:00
|
|
|
}
|
2012-11-20 00:15:36 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
2011-08-16 22:09:43 +00:00
|
|
|
assert (getVersion() <= LLVMDebugVersion10 && "Invalid getCompileUnit!");
|
2010-03-09 00:44:10 +00:00
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(3);
|
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
return getFieldAs<DIFile>(3).getCompileUnit();
|
2010-03-09 00:44:10 +00:00
|
|
|
}
|
2009-12-15 19:16:48 +00:00
|
|
|
unsigned getLineNumber() const { return getUnsignedField(4); }
|
2010-05-07 23:04:32 +00:00
|
|
|
bool Verify() const;
|
2009-12-15 19:16:48 +00:00
|
|
|
};
|
|
|
|
|
2009-09-01 01:14:15 +00:00
|
|
|
/// DILocation - This object holds location information. This object
|
|
|
|
/// is not associated with any DWARF tag.
|
|
|
|
class DILocation : public DIDescriptor {
|
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
|
2009-09-01 00:53:21 +00:00
|
|
|
|
2009-09-01 01:14:15 +00:00
|
|
|
unsigned getLineNumber() const { return getUnsignedField(0); }
|
|
|
|
unsigned getColumnNumber() const { return getUnsignedField(1); }
|
2009-09-29 18:40:58 +00:00
|
|
|
DIScope getScope() const { return getFieldAs<DIScope>(2); }
|
|
|
|
DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getFilename() const { return getScope().getFilename(); }
|
|
|
|
StringRef getDirectory() const { return getScope().getDirectory(); }
|
2010-03-08 20:52:55 +00:00
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2012-02-04 00:59:25 +00:00
|
|
|
class DIObjCProperty : public DIDescriptor {
|
2012-07-06 19:12:31 +00:00
|
|
|
friend class DIDescriptor;
|
|
|
|
void printInternal(raw_ostream &OS) const;
|
2012-02-04 00:59:25 +00:00
|
|
|
public:
|
|
|
|
explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { }
|
|
|
|
|
|
|
|
StringRef getObjCPropertyName() const { return getStringField(1); }
|
2012-03-29 08:42:56 +00:00
|
|
|
DIFile getFile() const { return getFieldAs<DIFile>(2); }
|
|
|
|
unsigned getLineNumber() const { return getUnsignedField(3); }
|
|
|
|
|
2012-02-04 00:59:25 +00:00
|
|
|
StringRef getObjCPropertyGetterName() const {
|
2012-03-29 08:42:56 +00:00
|
|
|
return getStringField(4);
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
StringRef getObjCPropertySetterName() const {
|
2012-03-29 08:42:56 +00:00
|
|
|
return getStringField(5);
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
bool isReadOnlyObjCProperty() {
|
2012-03-29 08:42:56 +00:00
|
|
|
return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0;
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
bool isReadWriteObjCProperty() {
|
2012-03-29 08:42:56 +00:00
|
|
|
return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0;
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
bool isAssignObjCProperty() {
|
2012-03-29 08:42:56 +00:00
|
|
|
return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0;
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
bool isRetainObjCProperty() {
|
2012-03-29 08:42:56 +00:00
|
|
|
return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0;
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
bool isCopyObjCProperty() {
|
2012-03-29 08:42:56 +00:00
|
|
|
return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0;
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
bool isNonAtomicObjCProperty() {
|
2012-03-29 08:42:56 +00:00
|
|
|
return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0;
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
|
2012-03-29 08:42:56 +00:00
|
|
|
DIType getType() const { return getFieldAs<DIType>(7); }
|
|
|
|
|
2012-02-04 00:59:25 +00:00
|
|
|
/// Verify - Verify that a derived type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
|
|
|
};
|
|
|
|
|
2009-11-24 01:14:22 +00:00
|
|
|
/// getDISubprogram - Find subprogram that is enclosing this scope.
|
2010-05-07 20:54:48 +00:00
|
|
|
DISubprogram getDISubprogram(const MDNode *Scope);
|
2009-11-24 01:14:22 +00:00
|
|
|
|
|
|
|
/// getDICompositeType - Find underlying composite type.
|
|
|
|
DICompositeType getDICompositeType(DIType T);
|
|
|
|
|
2011-08-15 17:57:41 +00:00
|
|
|
/// isSubprogramContext - Return true if Context is either a subprogram
|
|
|
|
/// or another context nested inside a subprogram.
|
|
|
|
bool isSubprogramContext(const MDNode *Context);
|
|
|
|
|
2010-11-10 22:19:21 +00:00
|
|
|
/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable
|
|
|
|
/// to hold function specific information.
|
2011-08-19 23:28:12 +00:00
|
|
|
NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP);
|
2010-11-10 22:19:21 +00:00
|
|
|
|
2012-11-20 00:15:36 +00:00
|
|
|
/// getFnSpecificMDNode - Return a NameMDNode, if available, that is
|
2010-11-10 22:19:21 +00:00
|
|
|
/// suitable to hold function specific information.
|
2011-08-19 23:28:12 +00:00
|
|
|
NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP);
|
2010-11-10 22:19:21 +00:00
|
|
|
|
2011-07-19 19:41:54 +00:00
|
|
|
/// createInlinedVariable - Create a new inlined variable based on current
|
|
|
|
/// variable.
|
|
|
|
/// @param DV Current Variable.
|
|
|
|
/// @param InlinedScope Location at current variable is inlined.
|
|
|
|
DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope,
|
|
|
|
LLVMContext &VMContext);
|
|
|
|
|
2011-08-10 21:50:54 +00:00
|
|
|
/// cleanseInlinedVariable - Remove inlined scope from the variable.
|
|
|
|
DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
|
|
|
|
|
2009-07-30 18:25:15 +00:00
|
|
|
class DebugInfoFinder {
|
2009-07-28 19:55:13 +00:00
|
|
|
public:
|
2009-07-30 18:25:15 +00:00
|
|
|
/// processModule - Process entire module and collect debug info
|
2009-07-28 19:55:13 +00:00
|
|
|
/// anchors.
|
2012-11-19 22:42:15 +00:00
|
|
|
void processModule(const Module &M);
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-07-28 19:55:13 +00:00
|
|
|
private:
|
2009-07-30 18:25:15 +00:00
|
|
|
/// processType - Process DIType.
|
|
|
|
void processType(DIType DT);
|
2009-07-28 19:55:13 +00:00
|
|
|
|
2009-10-07 22:04:08 +00:00
|
|
|
/// processLexicalBlock - Process DILexicalBlock.
|
|
|
|
void processLexicalBlock(DILexicalBlock LB);
|
|
|
|
|
|
|
|
/// processSubprogram - Process DISubprogram.
|
2009-07-30 18:25:15 +00:00
|
|
|
void processSubprogram(DISubprogram SP);
|
2009-07-28 19:55:13 +00:00
|
|
|
|
2009-07-31 18:18:52 +00:00
|
|
|
/// processDeclare - Process DbgDeclareInst.
|
2012-11-19 22:42:15 +00:00
|
|
|
void processDeclare(const DbgDeclareInst *DDI);
|
2009-07-31 18:18:52 +00:00
|
|
|
|
2009-11-10 22:05:35 +00:00
|
|
|
/// processLocation - Process DILocation.
|
|
|
|
void processLocation(DILocation Loc);
|
|
|
|
|
2009-07-28 19:55:13 +00:00
|
|
|
/// addCompileUnit - Add compile unit into CUs.
|
|
|
|
bool addCompileUnit(DICompileUnit CU);
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2009-07-28 19:55:13 +00:00
|
|
|
/// addGlobalVariable - Add global variable into GVs.
|
|
|
|
bool addGlobalVariable(DIGlobalVariable DIG);
|
|
|
|
|
2011-11-09 18:53:37 +00:00
|
|
|
// addSubprogram - Add subprogram into SPs.
|
2009-07-28 19:55:13 +00:00
|
|
|
bool addSubprogram(DISubprogram SP);
|
|
|
|
|
2009-08-10 22:09:58 +00:00
|
|
|
/// addType - Add type into Tys.
|
|
|
|
bool addType(DIType DT);
|
|
|
|
|
2009-07-28 19:55:13 +00:00
|
|
|
public:
|
2010-05-07 15:36:10 +00:00
|
|
|
typedef SmallVector<MDNode *, 8>::const_iterator iterator;
|
|
|
|
iterator compile_unit_begin() const { return CUs.begin(); }
|
|
|
|
iterator compile_unit_end() const { return CUs.end(); }
|
|
|
|
iterator subprogram_begin() const { return SPs.begin(); }
|
|
|
|
iterator subprogram_end() const { return SPs.end(); }
|
|
|
|
iterator global_variable_begin() const { return GVs.begin(); }
|
|
|
|
iterator global_variable_end() const { return GVs.end(); }
|
|
|
|
iterator type_begin() const { return TYs.begin(); }
|
|
|
|
iterator type_end() const { return TYs.end(); }
|
|
|
|
|
|
|
|
unsigned compile_unit_count() const { return CUs.size(); }
|
|
|
|
unsigned global_variable_count() const { return GVs.size(); }
|
|
|
|
unsigned subprogram_count() const { return SPs.size(); }
|
|
|
|
unsigned type_count() const { return TYs.size(); }
|
2009-07-28 19:55:13 +00:00
|
|
|
|
|
|
|
private:
|
2009-08-28 23:24:31 +00:00
|
|
|
SmallVector<MDNode *, 8> CUs; // Compile Units
|
|
|
|
SmallVector<MDNode *, 8> SPs; // Subprograms
|
|
|
|
SmallVector<MDNode *, 8> GVs; // Global Variables;
|
|
|
|
SmallVector<MDNode *, 8> TYs; // Types
|
|
|
|
SmallPtrSet<MDNode *, 64> NodesSeen;
|
2009-07-28 19:55:13 +00:00
|
|
|
};
|
2008-11-10 02:56:27 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|