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-06-26 01:49:18 +00:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2009-07-28 19:55:13 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.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;
|
|
|
|
class LLVMContext;
|
2010-05-07 15:30:29 +00:00
|
|
|
class raw_ostream;
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-12-29 09:15:46 +00:00
|
|
|
/// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
|
|
|
|
/// This should not be stored in a container, because underly MDNode may
|
|
|
|
/// change in certain situations.
|
2008-11-10 02:56:27 +00:00
|
|
|
class DIDescriptor {
|
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;
|
|
|
|
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-06-11 20:08:44 +00:00
|
|
|
Function *getFunctionField(unsigned Elt) const;
|
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) {}
|
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
|
|
|
|
2010-05-07 15:30:29 +00:00
|
|
|
/// print - print descriptor.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print descriptor to dbgs() with a newline.
|
2009-05-05 22:19:25 +00:00
|
|
|
void dump() const;
|
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;
|
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;
|
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 {
|
|
|
|
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
|
|
|
|
2009-01-05 18:33:01 +00:00
|
|
|
int64_t getLo() const { return (int64_t)getUInt64Field(1); }
|
|
|
|
int64_t getHi() const { return (int64_t)getUInt64Field(2); }
|
|
|
|
};
|
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 {
|
|
|
|
public:
|
2010-05-07 20:54:48 +00:00
|
|
|
explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
|
2009-09-01 05:04:28 +00:00
|
|
|
virtual ~DIScope() {}
|
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 {
|
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
|
|
|
|
2009-02-17 21:23:59 +00:00
|
|
|
bool isMain() const { return getUnsignedField(6); }
|
|
|
|
bool isOptimized() const { return getUnsignedField(7); }
|
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
|
|
|
|
2009-01-19 23:21:49 +00:00
|
|
|
/// Verify - Verify that a compile unit is well formed.
|
|
|
|
bool Verify() const;
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2010-05-07 15:30:29 +00:00
|
|
|
/// print - print compile unit.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print compile unit to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() 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 {
|
|
|
|
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); }
|
|
|
|
DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
|
|
|
|
};
|
|
|
|
|
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 {
|
|
|
|
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 {
|
2009-01-20 22:27:02 +00:00
|
|
|
public:
|
|
|
|
enum {
|
2009-09-30 00:08:22 +00:00
|
|
|
FlagPrivate = 1 << 0,
|
|
|
|
FlagProtected = 1 << 1,
|
|
|
|
FlagFwdDecl = 1 << 2,
|
|
|
|
FlagAppleBlock = 1 << 3,
|
2009-12-03 19:11:07 +00:00
|
|
|
FlagBlockByrefStruct = 1 << 4,
|
2010-02-06 01:02:37 +00:00
|
|
|
FlagVirtual = 1 << 5,
|
|
|
|
FlagArtificial = 1 << 6 // To identify artificial arguments in
|
|
|
|
// a subroutine type. e.g. "this" in c++.
|
2009-01-20 22:27:02 +00:00
|
|
|
};
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
protected:
|
|
|
|
// 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-12 21:38:43 +00:00
|
|
|
|
2009-01-15 19:26:23 +00:00
|
|
|
public:
|
2009-01-12 21:38:43 +00:00
|
|
|
|
2009-01-19 23:21:49 +00:00
|
|
|
/// Verify - Verify that a type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
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
|
|
|
virtual ~DIType() {}
|
|
|
|
|
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); }
|
2010-03-09 00:44:10 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(3);
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(3);
|
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
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;
|
|
|
|
}
|
2010-03-08 20:52:55 +00:00
|
|
|
bool isValid() const {
|
|
|
|
return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
|
|
|
|
}
|
2010-03-08 22:02:50 +00:00
|
|
|
StringRef getFilename() const { return getCompileUnit().getFilename();}
|
|
|
|
StringRef getDirectory() const { return getCompileUnit().getDirectory();}
|
2010-05-07 15:30:29 +00:00
|
|
|
|
|
|
|
/// print - print type.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print type to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() 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
|
|
|
/// 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-05-07 15:30:29 +00:00
|
|
|
/// print - print basic type.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print basic type to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() 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 {
|
|
|
|
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
|
|
|
|
|
|
|
/// print - print derived type.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print derived type to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() const;
|
2009-07-22 18:23:44 +00:00
|
|
|
|
|
|
|
/// replaceAllUsesWith - Replace all uses of debug info referenced by
|
2010-07-21 18:54:18 +00:00
|
|
|
/// this descriptor.
|
2009-07-22 18:23:44 +00:00
|
|
|
void replaceAllUsesWith(DIDescriptor &D);
|
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 {
|
|
|
|
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);
|
|
|
|
}
|
2009-01-19 23:21:49 +00:00
|
|
|
|
|
|
|
/// Verify - Verify that a composite type descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2010-05-07 15:30:29 +00:00
|
|
|
/// print - print composite type.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print composite type to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() 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
|
|
|
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
|
2009-08-31 22:47:13 +00:00
|
|
|
class DISubprogram : public DIScope {
|
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); }
|
2010-03-09 00:44:10 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(6);
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(6);
|
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
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);
|
|
|
|
}
|
2010-02-03 19:57:19 +00:00
|
|
|
unsigned isArtificial() const { return getUnsignedField(14); }
|
2010-04-30 19:38:23 +00:00
|
|
|
unsigned isOptimized() const;
|
2009-12-03 19:11:07 +00:00
|
|
|
|
2010-03-24 18:48:00 +00:00
|
|
|
StringRef getFilename() const {
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getCompileUnit().getFilename();
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(6);
|
|
|
|
return F.getFilename();
|
|
|
|
}
|
|
|
|
|
|
|
|
StringRef getDirectory() const {
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getCompileUnit().getFilename();
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(6);
|
|
|
|
return F.getDirectory();
|
|
|
|
}
|
2009-09-01 00:53:21 +00:00
|
|
|
|
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
|
|
|
|
2010-05-07 15:30:29 +00:00
|
|
|
/// print - print subprogram.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print subprogram to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() const;
|
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); }
|
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 {
|
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); }
|
|
|
|
DICompileUnit getCompileUnit() const{
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(6);
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(6);
|
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
|
|
|
|
|
|
|
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); }
|
2009-01-19 23:21:49 +00:00
|
|
|
|
|
|
|
/// Verify - Verify that a global variable descriptor is well formed.
|
|
|
|
bool Verify() const;
|
2009-01-30 01:03:10 +00:00
|
|
|
|
2010-05-07 15:30:29 +00:00
|
|
|
/// print - print global variable.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print global variable to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() 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 {
|
|
|
|
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); }
|
2010-03-09 00:44:10 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(3);
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(3);
|
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned getLineNumber() const { return getUnsignedField(4); }
|
|
|
|
DIType getType() const { return getFieldAs<DIType>(5); }
|
2009-01-20 19:08:39 +00:00
|
|
|
|
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;
|
|
|
|
|
2009-09-30 00:08:22 +00:00
|
|
|
uint64_t getAddrElement(unsigned Idx) const {
|
|
|
|
return getUInt64Field(Idx+6);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2010-05-07 15:30:29 +00:00
|
|
|
/// print - print variable.
|
|
|
|
void print(raw_ostream &OS) const;
|
|
|
|
|
|
|
|
/// dump - print variable to dbgs() with a newline.
|
2009-01-30 01:03:10 +00:00
|
|
|
void dump() 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 {
|
|
|
|
DIFile F = getFieldAs<DIFile>(4);
|
|
|
|
StringRef dir = F.getDirectory();
|
|
|
|
return !dir.empty() ? dir : getContext().getDirectory();
|
|
|
|
}
|
|
|
|
StringRef getFilename() const {
|
|
|
|
DIFile F = getFieldAs<DIFile>(4);
|
|
|
|
StringRef filename = F.getFilename();
|
|
|
|
return !filename.empty() ? filename : getContext().getFilename();
|
|
|
|
}
|
2009-09-01 01:14:15 +00:00
|
|
|
};
|
2009-09-01 00:53:21 +00:00
|
|
|
|
2009-12-15 19:16:48 +00:00
|
|
|
/// DINameSpace - A wrapper for a C++ style name space.
|
|
|
|
class DINameSpace : public DIScope {
|
|
|
|
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); }
|
|
|
|
StringRef getDirectory() const { return getContext().getDirectory(); }
|
|
|
|
StringRef getFilename() const { return getContext().getFilename(); }
|
2010-03-09 00:44:10 +00:00
|
|
|
DICompileUnit getCompileUnit() const{
|
|
|
|
if (getVersion() == llvm::LLVMDebugVersion7)
|
|
|
|
return getFieldAs<DICompileUnit>(3);
|
|
|
|
|
|
|
|
DIFile F = getFieldAs<DIFile>(3);
|
|
|
|
return F.getCompileUnit();
|
|
|
|
}
|
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
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// DIFactory - This object assists with the construction of the various
|
|
|
|
/// descriptors.
|
|
|
|
class DIFactory {
|
|
|
|
Module &M;
|
2009-07-07 17:12:53 +00:00
|
|
|
LLVMContext& VMContext;
|
2009-09-19 20:40:05 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
Function *DeclareFn; // llvm.dbg.declare
|
2009-12-07 19:36:34 +00:00
|
|
|
Function *ValueFn; // llvm.dbg.value
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
DIFactory(const DIFactory &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const DIFactory&); // DO NOT IMPLEMENT
|
|
|
|
public:
|
2009-09-30 00:08:22 +00:00
|
|
|
enum ComplexAddrKind { OpPlus=1, OpDeref };
|
|
|
|
|
2008-11-10 04:10:34 +00:00
|
|
|
explicit DIFactory(Module &m);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-09-19 20:40:05 +00:00
|
|
|
/// GetOrCreateArray - Create an descriptor for an array of descriptors.
|
2008-11-10 02:56:27 +00:00
|
|
|
/// This implicitly uniques the arrays created.
|
|
|
|
DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
|
|
|
|
|
|
|
|
/// GetOrCreateSubrange - Create a descriptor for a value range. This
|
|
|
|
/// implicitly uniques the values returned.
|
|
|
|
DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateCompileUnit - Create a new descriptor for the specified compile
|
|
|
|
/// unit.
|
|
|
|
DICompileUnit CreateCompileUnit(unsigned LangID,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Filename,
|
|
|
|
StringRef Directory,
|
|
|
|
StringRef Producer,
|
2009-01-30 18:20:31 +00:00
|
|
|
bool isMain = false,
|
2009-01-23 22:33:47 +00:00
|
|
|
bool isOptimized = false,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Flags = "",
|
2009-02-17 22:43:44 +00:00
|
|
|
unsigned RunTimeVer = 0);
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2010-03-08 22:27:22 +00:00
|
|
|
/// CreateFile - Create a new descriptor for the specified file.
|
2010-07-13 05:50:08 +00:00
|
|
|
DIFile CreateFile(StringRef Filename, StringRef Directory,
|
|
|
|
DICompileUnit CU);
|
2010-03-08 22:27:22 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateEnumerator - Create a single enumerator value.
|
2009-11-25 17:36:49 +00:00
|
|
|
DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateBasicType - Create a basic type like int, float, etc.
|
2009-11-25 17:36:49 +00:00
|
|
|
DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F, unsigned LineNumber,
|
2008-11-10 02:56:27 +00:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
2009-01-30 18:20:31 +00:00
|
|
|
unsigned Encoding);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-10-26 16:54:35 +00:00
|
|
|
/// CreateBasicType - Create a basic type like int, float, etc.
|
2009-11-25 17:36:49 +00:00
|
|
|
DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F, unsigned LineNumber,
|
2009-10-26 16:54:35 +00:00
|
|
|
Constant *SizeInBits, Constant *AlignInBits,
|
|
|
|
Constant *OffsetInBits, unsigned Flags,
|
|
|
|
unsigned Encoding);
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateDerivedType - Create a derived type like const qualified type,
|
|
|
|
/// pointer, typedef, etc.
|
|
|
|
DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F,
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
2009-01-30 18:20:31 +00:00
|
|
|
DIType DerivedFrom);
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2009-10-26 16:54:35 +00:00
|
|
|
/// CreateDerivedType - Create a derived type like const qualified type,
|
|
|
|
/// pointer, typedef, etc.
|
|
|
|
DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
|
2010-03-09 00:44:10 +00:00
|
|
|
StringRef Name,
|
|
|
|
DIFile F,
|
|
|
|
unsigned LineNumber,
|
|
|
|
Constant *SizeInBits,
|
|
|
|
Constant *AlignInBits,
|
|
|
|
Constant *OffsetInBits, unsigned Flags,
|
|
|
|
DIType DerivedFrom);
|
2009-10-26 16:54:35 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateCompositeType - Create a composite type like array, struct, etc.
|
|
|
|
DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F,
|
2008-11-10 02:56:27 +00:00
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
|
|
|
DIType DerivedFrom,
|
2009-02-17 22:43:44 +00:00
|
|
|
DIArray Elements,
|
2010-01-26 21:14:59 +00:00
|
|
|
unsigned RunTimeLang = 0,
|
|
|
|
MDNode *ContainingType = 0);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2010-02-06 01:02:37 +00:00
|
|
|
/// CreateArtificialType - Create a new DIType with "artificial" flag set.
|
|
|
|
DIType CreateArtificialType(DIType Ty);
|
|
|
|
|
2009-10-26 16:54:35 +00:00
|
|
|
/// CreateCompositeType - Create a composite type like array, struct, etc.
|
|
|
|
DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
|
2010-03-09 00:44:10 +00:00
|
|
|
StringRef Name,
|
|
|
|
DIFile F,
|
|
|
|
unsigned LineNumber,
|
|
|
|
Constant *SizeInBits,
|
|
|
|
Constant *AlignInBits,
|
|
|
|
Constant *OffsetInBits,
|
|
|
|
unsigned Flags,
|
|
|
|
DIType DerivedFrom,
|
|
|
|
DIArray Elements,
|
|
|
|
unsigned RunTimeLang = 0);
|
2009-10-26 16:54:35 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateSubprogram - Create a new descriptor for the specified subprogram.
|
|
|
|
/// See comments in DISubprogram for descriptions of these fields.
|
2009-11-25 17:36:49 +00:00
|
|
|
DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef DisplayName,
|
|
|
|
StringRef LinkageName,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F, unsigned LineNo,
|
2010-01-23 00:26:28 +00:00
|
|
|
DIType Ty, bool isLocalToUnit,
|
2009-12-03 19:11:07 +00:00
|
|
|
bool isDefinition,
|
|
|
|
unsigned VK = 0,
|
|
|
|
unsigned VIndex = 0,
|
2010-02-03 19:57:19 +00:00
|
|
|
DIType = DIType(),
|
2010-04-30 19:38:23 +00:00
|
|
|
bool isArtificial = 0,
|
2010-06-11 20:08:44 +00:00
|
|
|
bool isOptimized = false,
|
|
|
|
Function *Fn = 0);
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2009-12-01 23:09:02 +00:00
|
|
|
/// CreateSubprogramDefinition - Create new subprogram descriptor for the
|
|
|
|
/// given declaration.
|
|
|
|
DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateGlobalVariable - Create a new descriptor for the specified global.
|
|
|
|
DIGlobalVariable
|
2009-11-25 17:36:49 +00:00
|
|
|
CreateGlobalVariable(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef DisplayName,
|
|
|
|
StringRef LinkageName,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F,
|
2010-01-23 00:26:28 +00:00
|
|
|
unsigned LineNo, DIType Ty, bool isLocalToUnit,
|
2009-01-30 18:20:31 +00:00
|
|
|
bool isDefinition, llvm::GlobalVariable *GV);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// CreateVariable - Create a new descriptor for the specified variable.
|
|
|
|
DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F, unsigned LineNo,
|
2010-05-20 20:35:24 +00:00
|
|
|
DIType Ty, bool AlwaysPreserve = false);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-09-30 00:08:22 +00:00
|
|
|
/// CreateComplexVariable - Create a new descriptor for the specified
|
|
|
|
/// variable which has a complex address expression for its address.
|
|
|
|
DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
|
|
|
|
const std::string &Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F, unsigned LineNo,
|
2010-01-23 00:26:28 +00:00
|
|
|
DIType Ty,
|
2009-09-30 00:08:22 +00:00
|
|
|
SmallVector<Value *, 9> &addr);
|
|
|
|
|
2009-09-19 20:40:05 +00:00
|
|
|
/// CreateLexicalBlock - This creates a descriptor for a lexical block
|
2009-08-31 22:00:15 +00:00
|
|
|
/// with the specified parent context.
|
2010-07-19 23:56:30 +00:00
|
|
|
DILexicalBlock CreateLexicalBlock(DIDescriptor Context, DIFile F,
|
|
|
|
unsigned Line = 0, unsigned Col = 0);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-12-15 19:16:48 +00:00
|
|
|
/// CreateNameSpace - This creates new descriptor for a namespace
|
|
|
|
/// with the specified parent context.
|
|
|
|
DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
|
2010-03-09 00:44:10 +00:00
|
|
|
DIFile F, unsigned LineNo);
|
2009-12-15 19:16:48 +00:00
|
|
|
|
2009-09-01 01:14:15 +00:00
|
|
|
/// CreateLocation - Creates a debug info location.
|
2009-09-19 20:40:05 +00:00
|
|
|
DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
|
2009-09-19 20:40:21 +00:00
|
|
|
DIScope S, DILocation OrigLoc);
|
2009-09-01 01:14:15 +00:00
|
|
|
|
2009-11-23 19:11:20 +00:00
|
|
|
/// CreateLocation - Creates a debug info location.
|
|
|
|
DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
|
|
|
|
DIScope S, MDNode *OrigLoc = 0);
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
2009-11-10 22:05:35 +00:00
|
|
|
Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
|
|
|
|
BasicBlock *InsertAtEnd);
|
2009-10-01 22:08:58 +00:00
|
|
|
|
|
|
|
/// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
2009-11-10 22:05:35 +00:00
|
|
|
Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
|
|
|
|
Instruction *InsertBefore);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-12-07 21:54:43 +00:00
|
|
|
/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
2010-01-11 07:45:19 +00:00
|
|
|
Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
|
2009-12-07 21:54:43 +00:00
|
|
|
DIVariable D, BasicBlock *InsertAtEnd);
|
2009-12-07 19:36:34 +00:00
|
|
|
|
2009-12-07 21:54:43 +00:00
|
|
|
/// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
2010-01-11 07:45:19 +00:00
|
|
|
Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
|
2009-12-07 21:54:43 +00:00
|
|
|
DIVariable D, Instruction *InsertBefore);
|
2008-11-10 02:56:27 +00:00
|
|
|
private:
|
|
|
|
Constant *GetTagConstant(unsigned TAG);
|
|
|
|
};
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-12-29 09:15:46 +00:00
|
|
|
bool getLocationInfo(const Value *V, std::string &DisplayName,
|
|
|
|
std::string &Type, unsigned &LineNo, std::string &File,
|
|
|
|
std::string &Dir);
|
2009-06-26 01:49:18 +00:00
|
|
|
|
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);
|
|
|
|
|
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.
|
2009-07-30 18:25:15 +00:00
|
|
|
void processModule(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.
|
|
|
|
void processDeclare(DbgDeclareInst *DDI);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// addSubprogram - Add subprgoram into SPs.
|
|
|
|
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
|