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;
|
2009-07-02 01:15:24 +00:00
|
|
|
class DebugLoc;
|
2009-07-12 22:46:08 +00:00
|
|
|
struct DebugLocTracker;
|
2008-12-16 09:07:36 +00:00
|
|
|
class Instruction;
|
2009-12-31 03:02:08 +00:00
|
|
|
class MDNode;
|
|
|
|
class LLVMContext;
|
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:
|
2009-12-29 09:15:46 +00:00
|
|
|
MDNode *DbgNode;
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-08-28 23:24:31 +00:00
|
|
|
/// DIDescriptor constructor. If the specified node is non-null, check
|
2008-11-10 02:56:27 +00:00
|
|
|
/// to make sure that the tag in the descriptor matches 'RequiredTag'. If
|
|
|
|
/// not, the debug info is corrupt and we ignore it.
|
2009-08-28 23:24:31 +00:00
|
|
|
DIDescriptor(MDNode *N, unsigned RequiredTag);
|
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 {
|
2009-08-28 23:24:31 +00:00
|
|
|
return DescTy(getDescriptorField(Elt).getNode());
|
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;
|
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) {}
|
|
|
|
explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2009-08-28 23:24:31 +00:00
|
|
|
bool isNull() const { return DbgNode == 0; }
|
2008-11-10 02:56:27 +00:00
|
|
|
|
2009-08-28 23:24:31 +00:00
|
|
|
MDNode *getNode() const { return 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-28 23:24:31 +00:00
|
|
|
/// ValidDebugInfo - Return true if N represents valid debug info value.
|
2009-12-29 09:15:46 +00:00
|
|
|
static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
|
2009-05-03 08:50:41 +00:00
|
|
|
|
2009-05-05 22:19:25 +00:00
|
|
|
/// dump - print descriptor.
|
|
|
|
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;
|
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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DISubrange(MDNode *N = 0)
|
|
|
|
: DIDescriptor(N, dwarf::DW_TAG_subrange_type) {}
|
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:
|
2009-09-19 20:40:05 +00:00
|
|
|
explicit DIArray(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:
|
|
|
|
explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
|
|
|
|
if (DbgNode && !isScope())
|
|
|
|
DbgNode = 0;
|
|
|
|
}
|
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:
|
2009-09-19 20:40:28 +00:00
|
|
|
explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {
|
2009-08-31 21:34:44 +00:00
|
|
|
if (DbgNode && !isCompileUnit())
|
2009-09-19 20:40:21 +00:00
|
|
|
DbgNode = 0;
|
2009-08-31 21:34:44 +00:00
|
|
|
}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +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
|
|
|
|
|
|
|
/// dump - print compile unit.
|
|
|
|
void dump() const;
|
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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIEnumerator(MDNode *N = 0)
|
|
|
|
: DIDescriptor(N, dwarf::DW_TAG_enumerator) {}
|
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.
|
|
|
|
class DIType : public DIDescriptor {
|
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,
|
|
|
|
FlagVirtual = 1 << 5
|
2009-01-20 22:27:02 +00:00
|
|
|
};
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
protected:
|
2009-09-19 20:40:05 +00:00
|
|
|
DIType(MDNode *N, unsigned Tag)
|
2009-08-28 23:24:31 +00:00
|
|
|
: DIDescriptor(N, Tag) {}
|
2008-11-10 02:56:27 +00:00
|
|
|
// This ctor is used when the Tag has already been validated by a derived
|
|
|
|
// ctor.
|
2009-08-28 23:24:31 +00:00
|
|
|
DIType(MDNode *N, bool, bool) : DIDescriptor(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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIType(MDNode *N);
|
2008-11-10 02:56:27 +00:00
|
|
|
explicit DIType() {}
|
2009-01-05 22:35:52 +00:00
|
|
|
virtual ~DIType() {}
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
DIDescriptor getContext() const { return getDescriptorField(1); }
|
2009-12-15 19:16:48 +00:00
|
|
|
StringRef getName() const { return getStringField(2); }
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
|
|
|
|
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;
|
|
|
|
}
|
2009-01-05 22:35:52 +00:00
|
|
|
|
2009-01-30 01:03:10 +00:00
|
|
|
/// dump - print type.
|
|
|
|
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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIBasicType(MDNode *N = 0)
|
|
|
|
: DIType(N, dwarf::DW_TAG_base_type) {}
|
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
|
|
|
|
|
|
|
/// dump - print basic type.
|
|
|
|
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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIDerivedType(MDNode *N, bool, bool)
|
|
|
|
: DIType(N, true, true) {}
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIDerivedType(MDNode *N = 0)
|
|
|
|
: DIType(N, true, true) {
|
2009-08-31 18:49:10 +00:00
|
|
|
if (DbgNode && !isDerivedType())
|
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
|
|
|
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;
|
2009-01-30 01:03:10 +00:00
|
|
|
/// dump - print derived type.
|
|
|
|
void dump() const;
|
2009-07-22 18:23:44 +00:00
|
|
|
|
|
|
|
/// replaceAllUsesWith - Replace all uses of debug info referenced by
|
|
|
|
/// this descriptor. After this completes, the current debug info value
|
|
|
|
/// is erased.
|
|
|
|
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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DICompositeType(MDNode *N = 0)
|
|
|
|
: 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); }
|
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
|
|
|
|
|
|
|
/// dump - print composite type.
|
|
|
|
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
|
|
|
/// DIGlobal - This is a common class for global variables and subprograms.
|
|
|
|
class DIGlobal : public DIDescriptor {
|
|
|
|
protected:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIGlobal(MDNode *N, unsigned RequiredTag)
|
|
|
|
: DIDescriptor(N, RequiredTag) {}
|
2009-01-12 21:38:43 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
public:
|
2009-01-05 22:35:52 +00:00
|
|
|
virtual ~DIGlobal() {}
|
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
DIDescriptor getContext() const { return getDescriptorField(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); }
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
|
|
|
|
unsigned getLineNumber() const { return getUnsignedField(7); }
|
|
|
|
DIType getType() const { return getFieldAs<DIType>(8); }
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
/// isLocalToUnit - Return true if this subprogram is local to the current
|
|
|
|
/// compile unit, like 'static' in C.
|
|
|
|
unsigned isLocalToUnit() const { return getUnsignedField(9); }
|
|
|
|
unsigned isDefinition() const { return getUnsignedField(10); }
|
2009-01-05 22:35:52 +00:00
|
|
|
|
2009-01-30 01:03:10 +00:00
|
|
|
/// dump - print global.
|
|
|
|
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:
|
2009-09-19 20:40:28 +00:00
|
|
|
explicit DISubprogram(MDNode *N = 0) : DIScope(N) {
|
2009-08-31 22:47:13 +00:00
|
|
|
if (DbgNode && !isSubprogram())
|
2009-09-19 20:40:21 +00:00
|
|
|
DbgNode = 0;
|
2009-08-31 22:47:13 +00:00
|
|
|
}
|
2009-05-14 18:26:15 +00:00
|
|
|
|
2009-08-31 22:47:13 +00:00
|
|
|
DIDescriptor getContext() const { return getDescriptorField(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); }
|
2009-08-31 22:47:13 +00:00
|
|
|
DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
|
|
|
|
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));
|
|
|
|
if (!DCT.isNull()) {
|
|
|
|
DIArray A = DCT.getTypeArray();
|
2009-08-28 23:24:31 +00:00
|
|
|
DIType T(A.getElement(0).getNode());
|
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);
|
|
|
|
}
|
|
|
|
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getFilename() const { return getCompileUnit().getFilename();}
|
|
|
|
StringRef getDirectory() const { return getCompileUnit().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
|
|
|
|
|
|
|
/// dump - print subprogram.
|
|
|
|
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);
|
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.
|
|
|
|
class DIGlobalVariable : public DIGlobal {
|
|
|
|
public:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIGlobalVariable(MDNode *N = 0)
|
|
|
|
: DIGlobal(N, dwarf::DW_TAG_variable) {}
|
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
|
|
|
|
|
|
|
/// dump - print global variable.
|
|
|
|
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:
|
2009-08-28 23:24:31 +00:00
|
|
|
explicit DIVariable(MDNode *N = 0)
|
|
|
|
: DIDescriptor(N) {
|
2009-08-31 18:49:10 +00:00
|
|
|
if (DbgNode && !isVariable())
|
2009-08-28 23:24:31 +00:00
|
|
|
DbgNode = 0;
|
2009-05-14 18:26:15 +00:00
|
|
|
}
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2008-11-10 02:56:27 +00:00
|
|
|
DIDescriptor getContext() const { return getDescriptorField(1); }
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getName() const { return getStringField(2); }
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2009-01-30 01:03:10 +00:00
|
|
|
/// dump - print variable.
|
|
|
|
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:
|
2009-09-19 20:40:28 +00:00
|
|
|
explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {
|
2009-09-19 20:40:05 +00:00
|
|
|
if (DbgNode && !isLexicalBlock())
|
2009-09-19 20:40:21 +00:00
|
|
|
DbgNode = 0;
|
2009-08-31 22:00:15 +00:00
|
|
|
}
|
2009-09-29 18:40:58 +00:00
|
|
|
DIScope getContext() const { return getFieldAs<DIScope>(1); }
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef getDirectory() const { return getContext().getDirectory(); }
|
|
|
|
StringRef getFilename() const { return 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:
|
|
|
|
explicit DINameSpace(MDNode *N = 0) : DIScope(N) {
|
|
|
|
if (DbgNode && !isNameSpace())
|
|
|
|
DbgNode = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
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(); }
|
2009-12-29 09:15:46 +00:00
|
|
|
DICompileUnit getCompileUnit() const { return getFieldAs<DICompileUnit>(3);}
|
2009-12-15 19:16:48 +00:00
|
|
|
unsigned getLineNumber() const { return getUnsignedField(4); }
|
|
|
|
};
|
|
|
|
|
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-01-19 01:28:09 +00:00
|
|
|
explicit DILocation(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(); }
|
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
|
|
|
|
|
|
|
/// 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,
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit CompileUnit, unsigned LineNumber,
|
|
|
|
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,
|
2009-10-26 16:54:35 +00:00
|
|
|
DICompileUnit CompileUnit, unsigned LineNumber,
|
|
|
|
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,
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit CompileUnit,
|
|
|
|
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,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Name,
|
2009-10-26 16:54:35 +00:00
|
|
|
DICompileUnit CompileUnit,
|
|
|
|
unsigned LineNumber,
|
|
|
|
Constant *SizeInBits, Constant *AlignInBits,
|
|
|
|
Constant *OffsetInBits, unsigned Flags,
|
|
|
|
DIType DerivedFrom);
|
|
|
|
|
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,
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit CompileUnit,
|
|
|
|
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,
|
|
|
|
unsigned RunTimeLang = 0);
|
2009-01-20 19:08:39 +00:00
|
|
|
|
2009-10-26 16:54:35 +00:00
|
|
|
/// CreateCompositeType - Create a composite type like array, struct, etc.
|
|
|
|
DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
|
2009-11-25 17:36:49 +00:00
|
|
|
StringRef Name,
|
2009-10-26 16:54:35 +00:00
|
|
|
DICompileUnit CompileUnit,
|
|
|
|
unsigned LineNumber,
|
|
|
|
Constant *SizeInBits,
|
|
|
|
Constant *AlignInBits,
|
|
|
|
Constant *OffsetInBits, unsigned Flags,
|
|
|
|
DIType DerivedFrom,
|
|
|
|
DIArray Elements,
|
|
|
|
unsigned RunTimeLang = 0);
|
|
|
|
|
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,
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit CompileUnit, unsigned LineNo,
|
|
|
|
DIType Type, bool isLocalToUnit,
|
2009-12-03 19:11:07 +00:00
|
|
|
bool isDefinition,
|
|
|
|
unsigned VK = 0,
|
|
|
|
unsigned VIndex = 0,
|
|
|
|
DIType = DIType());
|
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,
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit CompileUnit,
|
|
|
|
unsigned LineNo, DIType Type, 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,
|
2008-11-10 02:56:27 +00:00
|
|
|
DICompileUnit CompileUnit, unsigned LineNo,
|
2009-01-30 18:20:31 +00:00
|
|
|
DIType Type);
|
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,
|
|
|
|
DICompileUnit CompileUnit, unsigned LineNo,
|
|
|
|
DIType Type,
|
|
|
|
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.
|
|
|
|
DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
|
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,
|
|
|
|
DICompileUnit CU, unsigned LineNo);
|
|
|
|
|
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-09-19 20:40:05 +00:00
|
|
|
/// ExtractDebugLocation - Extract debug location information
|
2009-09-16 18:20:05 +00:00
|
|
|
/// from DILocation.
|
|
|
|
DebugLoc ExtractDebugLocation(DILocation &Loc,
|
|
|
|
DebugLocTracker &DebugLocInfo);
|
|
|
|
|
2009-11-24 01:14:22 +00:00
|
|
|
/// getDISubprogram - Find subprogram that is enclosing this scope.
|
|
|
|
DISubprogram getDISubprogram(MDNode *Scope);
|
|
|
|
|
|
|
|
/// 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:
|
2009-08-28 23:24:31 +00:00
|
|
|
typedef SmallVector<MDNode *, 8>::iterator iterator;
|
2009-07-28 19:55:13 +00:00
|
|
|
iterator compile_unit_begin() { return CUs.begin(); }
|
|
|
|
iterator compile_unit_end() { return CUs.end(); }
|
|
|
|
iterator subprogram_begin() { return SPs.begin(); }
|
|
|
|
iterator subprogram_end() { return SPs.end(); }
|
|
|
|
iterator global_variable_begin() { return GVs.begin(); }
|
|
|
|
iterator global_variable_end() { return GVs.end(); }
|
2009-08-10 22:09:58 +00:00
|
|
|
iterator type_begin() { return TYs.begin(); }
|
|
|
|
iterator type_end() { return TYs.end(); }
|
2009-07-28 19:55:13 +00:00
|
|
|
|
|
|
|
unsigned compile_unit_count() { return CUs.size(); }
|
|
|
|
unsigned global_variable_count() { return GVs.size(); }
|
|
|
|
unsigned subprogram_count() { return SPs.size(); }
|
2009-08-10 22:09:58 +00:00
|
|
|
unsigned type_count() { 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
|