2005-12-16 22:45:29 +00:00
|
|
|
//===-- llvm/CodeGen/MachineDebugInfo.h -------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by James M. Laskey and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Collect debug information for a module. This information should be in a
|
|
|
|
// neutral form that can be used by different debugging schemes.
|
|
|
|
//
|
2006-01-17 17:31:53 +00:00
|
|
|
// The organization of information is primarily clustered around the source
|
2006-02-06 19:12:02 +00:00
|
|
|
// compile units. The main exception is source line correspondence where
|
2006-01-17 17:31:53 +00:00
|
|
|
// inlining may interleave code from various compile units.
|
|
|
|
//
|
|
|
|
// The following information can be retrieved from the MachineDebugInfo.
|
|
|
|
//
|
|
|
|
// -- Source directories - Directories are uniqued based on their canonical
|
2006-02-06 15:33:21 +00:00
|
|
|
// string and assigned a sequential numeric ID (base 1.)
|
2006-01-17 17:31:53 +00:00
|
|
|
// -- Source files - Files are also uniqued based on their name and directory
|
2006-02-06 15:33:21 +00:00
|
|
|
// ID. A file ID is sequential number (base 1.)
|
2006-10-17 21:51:44 +00:00
|
|
|
// -- Source line correspondence - A vector of file ID, line#, column# triples.
|
2006-01-17 17:31:53 +00:00
|
|
|
// A DEBUG_LOCATION instruction is generated by the DAG Legalizer
|
|
|
|
// corresponding to each entry in the source line list. This allows a debug
|
2006-02-06 19:12:02 +00:00
|
|
|
// emitter to generate labels referenced by debug information tables.
|
2006-01-17 17:31:53 +00:00
|
|
|
//
|
2005-12-16 22:45:29 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINEDEBUGINFO_H
|
|
|
|
#define LLVM_CODEGEN_MACHINEDEBUGINFO_H
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
2006-02-24 02:52:40 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2006-01-17 17:31:53 +00:00
|
|
|
#include "llvm/ADT/UniqueVector.h"
|
2006-02-11 01:01:30 +00:00
|
|
|
#include "llvm/GlobalValue.h"
|
2006-02-06 15:33:21 +00:00
|
|
|
#include "llvm/Pass.h"
|
2005-12-16 22:45:29 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
2006-01-17 17:31:53 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-01-26 20:21:46 +00:00
|
|
|
// Forward declarations.
|
2006-02-11 01:01:30 +00:00
|
|
|
class Constant;
|
2006-02-06 15:33:21 +00:00
|
|
|
class DebugInfoDesc;
|
2006-01-26 20:21:46 +00:00
|
|
|
class GlobalVariable;
|
2006-04-07 16:34:46 +00:00
|
|
|
class MachineFunction;
|
|
|
|
class MachineMove;
|
2006-01-26 20:21:46 +00:00
|
|
|
class Module;
|
2006-02-06 15:33:21 +00:00
|
|
|
class PointerType;
|
|
|
|
class StructType;
|
2006-01-26 20:21:46 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2006-02-06 15:33:21 +00:00
|
|
|
// Debug info constants.
|
2006-02-06 19:12:02 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
enum {
|
2006-07-11 15:58:09 +00:00
|
|
|
LLVMDebugVersion = (5 << 16), // Current version of debug information.
|
|
|
|
LLVMDebugVersion4 = (4 << 16), // Constant for version 4.
|
2006-06-16 13:14:03 +00:00
|
|
|
LLVMDebugVersionMask = 0xffff0000 // Mask for version number.
|
2006-02-06 15:33:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2006-02-06 19:12:02 +00:00
|
|
|
/// DIVisitor - Subclasses of this class apply steps to each of the fields in
|
|
|
|
/// the supplied DebugInfoDesc.
|
|
|
|
class DIVisitor {
|
2006-02-06 15:33:21 +00:00
|
|
|
public:
|
2006-02-06 19:12:02 +00:00
|
|
|
DIVisitor() {}
|
|
|
|
virtual ~DIVisitor() {}
|
2006-02-13 16:56:43 +00:00
|
|
|
|
2006-02-06 19:12:02 +00:00
|
|
|
/// ApplyToFields - Target the visitor to each field of the debug information
|
2006-02-06 15:33:21 +00:00
|
|
|
/// descriptor.
|
|
|
|
void ApplyToFields(DebugInfoDesc *DD);
|
|
|
|
|
|
|
|
/// Apply - Subclasses override each of these methods to perform the
|
|
|
|
/// appropriate action for the type of field.
|
|
|
|
virtual void Apply(int &Field) = 0;
|
|
|
|
virtual void Apply(unsigned &Field) = 0;
|
2006-03-01 17:53:02 +00:00
|
|
|
virtual void Apply(int64_t &Field) = 0;
|
2006-02-23 16:58:18 +00:00
|
|
|
virtual void Apply(uint64_t &Field) = 0;
|
2006-02-06 15:33:21 +00:00
|
|
|
virtual void Apply(bool &Field) = 0;
|
|
|
|
virtual void Apply(std::string &Field) = 0;
|
|
|
|
virtual void Apply(DebugInfoDesc *&Field) = 0;
|
|
|
|
virtual void Apply(GlobalVariable *&Field) = 0;
|
2006-02-28 20:15:07 +00:00
|
|
|
virtual void Apply(std::vector<DebugInfoDesc *> &Field) = 0;
|
2006-02-06 15:33:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DebugInfoDesc - This class is the base class for debug info descriptors.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-06 15:33:21 +00:00
|
|
|
class DebugInfoDesc {
|
|
|
|
private:
|
|
|
|
unsigned Tag; // Content indicator. Dwarf values are
|
|
|
|
// used but that does not limit use to
|
|
|
|
// Dwarf writers.
|
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
protected:
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc(unsigned T) : Tag(T | LLVMDebugVersion) {}
|
2006-01-26 20:21:46 +00:00
|
|
|
|
|
|
|
public:
|
2006-02-06 15:33:21 +00:00
|
|
|
virtual ~DebugInfoDesc() {}
|
|
|
|
|
|
|
|
// Accessors
|
2006-06-16 13:14:03 +00:00
|
|
|
unsigned getTag() const { return Tag & ~LLVMDebugVersionMask; }
|
|
|
|
unsigned getVersion() const { return Tag & LLVMDebugVersionMask; }
|
|
|
|
void setTag(unsigned T) { Tag = T | LLVMDebugVersion; }
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-06-14 14:45:39 +00:00
|
|
|
/// TagFromGlobal - Returns the tag number from a debug info descriptor
|
|
|
|
/// GlobalVariable. Return DIIValid if operand is not an unsigned int.
|
2006-02-06 19:12:02 +00:00
|
|
|
static unsigned TagFromGlobal(GlobalVariable *GV);
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-06-14 14:45:39 +00:00
|
|
|
/// VersionFromGlobal - Returns the version number from a debug info
|
|
|
|
/// descriptor GlobalVariable. Return DIIValid if operand is not an unsigned
|
|
|
|
/// int.
|
|
|
|
static unsigned VersionFromGlobal(GlobalVariable *GV);
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
/// DescFactory - Create an instance of debug info descriptor based on Tag.
|
|
|
|
/// Return NULL if not a recognized Tag.
|
|
|
|
static DebugInfoDesc *DescFactory(unsigned Tag);
|
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getLinkage - get linkage appropriate for this type of descriptor.
|
|
|
|
///
|
|
|
|
virtual GlobalValue::LinkageTypes getLinkage() const;
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Subclasses should supply the following static methods.
|
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
2006-03-01 17:53:02 +00:00
|
|
|
static bool classof(const DebugInfoDesc *) { return true; }
|
2006-02-06 15:33:21 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Subclasses should supply the following virtual methods.
|
|
|
|
|
2006-02-06 19:12:02 +00:00
|
|
|
/// ApplyToFields - Target the vistor to the fields of the descriptor.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual const char *getDescString() const = 0;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const = 0;
|
2006-02-06 15:33:21 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump() = 0;
|
|
|
|
#endif
|
2006-01-26 20:21:46 +00:00
|
|
|
};
|
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// AnchorDesc - Descriptors of this class act as markers for identifying
|
|
|
|
/// descriptors of certain groups.
|
2006-03-07 20:53:47 +00:00
|
|
|
class AnchoredDesc;
|
2006-02-11 01:01:30 +00:00
|
|
|
class AnchorDesc : public DebugInfoDesc {
|
2006-03-07 20:53:47 +00:00
|
|
|
private:
|
|
|
|
unsigned AnchorTag; // Tag number of descriptors anchored
|
|
|
|
// by this object.
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
public:
|
2006-03-01 20:39:36 +00:00
|
|
|
AnchorDesc();
|
2006-03-07 20:53:47 +00:00
|
|
|
AnchorDesc(AnchoredDesc *D);
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
// Accessors
|
2006-03-07 20:53:47 +00:00
|
|
|
unsigned getAnchorTag() const { return AnchorTag; }
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const AnchorDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
/// getLinkage - get linkage appropriate for this type of descriptor.
|
|
|
|
///
|
|
|
|
virtual GlobalValue::LinkageTypes getLinkage() const;
|
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the AnchorDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// AnchoredDesc - This class manages anchors for a variety of top level
|
|
|
|
/// descriptors.
|
|
|
|
class AnchoredDesc : public DebugInfoDesc {
|
|
|
|
private:
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *Anchor; // Anchor for all descriptors of the
|
2006-02-11 01:01:30 +00:00
|
|
|
// same type.
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
AnchoredDesc(unsigned T);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Accessors.
|
2006-06-16 13:14:03 +00:00
|
|
|
AnchorDesc *getAnchor() const { return static_cast<AnchorDesc *>(Anchor); }
|
|
|
|
void setAnchor(AnchorDesc *A) { Anchor = static_cast<DebugInfoDesc *>(A); }
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Subclasses should supply the following virtual methods.
|
|
|
|
|
2006-03-07 20:53:47 +00:00
|
|
|
/// getAnchorString - Return a string used to label descriptor's anchor.
|
|
|
|
///
|
|
|
|
virtual const char *getAnchorString() const = 0;
|
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the AnchoredDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
};
|
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-02-06 15:33:21 +00:00
|
|
|
/// CompileUnitDesc - This class packages debug information associated with a
|
|
|
|
/// source/header file.
|
2006-02-11 01:01:30 +00:00
|
|
|
class CompileUnitDesc : public AnchoredDesc {
|
2006-02-06 15:33:21 +00:00
|
|
|
private:
|
|
|
|
unsigned Language; // Language number (ex. DW_LANG_C89.)
|
|
|
|
std::string FileName; // Source file name.
|
|
|
|
std::string Directory; // Source file directory.
|
|
|
|
std::string Producer; // Compiler string.
|
2006-01-27 15:20:54 +00:00
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
public:
|
2006-02-11 01:01:30 +00:00
|
|
|
CompileUnitDesc();
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-03-07 20:53:47 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
// Accessors
|
|
|
|
unsigned getLanguage() const { return Language; }
|
|
|
|
const std::string &getFileName() const { return FileName; }
|
|
|
|
const std::string &getDirectory() const { return Directory; }
|
|
|
|
const std::string &getProducer() const { return Producer; }
|
|
|
|
void setLanguage(unsigned L) { Language = L; }
|
|
|
|
void setFileName(const std::string &FN) { FileName = FN; }
|
|
|
|
void setDirectory(const std::string &D) { Directory = D; }
|
|
|
|
void setProducer(const std::string &P) { Producer = P; }
|
2006-02-11 01:01:30 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
// FIXME - Need translation unit getter/setter.
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const CompileUnitDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-06 19:12:02 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the CompileUnitDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
2006-02-06 15:33:21 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
/// getAnchorString - Return a string used to label this descriptor's anchor.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-03-07 20:53:47 +00:00
|
|
|
static const char *AnchorString;
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual const char *getAnchorString() const;
|
2006-02-06 15:33:21 +00:00
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-02-23 16:58:18 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// TypeDesc - This class packages debug information associated with a type.
|
|
|
|
///
|
|
|
|
class TypeDesc : public DebugInfoDesc {
|
|
|
|
private:
|
2006-07-11 15:58:09 +00:00
|
|
|
enum {
|
|
|
|
FlagPrivate = 1 << 0,
|
|
|
|
FlagProtected = 1 << 1
|
|
|
|
};
|
2006-02-23 16:58:18 +00:00
|
|
|
DebugInfoDesc *Context; // Context debug descriptor.
|
2006-02-24 16:46:40 +00:00
|
|
|
std::string Name; // Type name (may be empty.)
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *File; // Defined compile unit (may be NULL.)
|
2006-03-15 19:09:58 +00:00
|
|
|
unsigned Line; // Defined line# (may be zero.)
|
2006-03-03 15:06:57 +00:00
|
|
|
uint64_t Size; // Type bit size (may be zero.)
|
2006-03-09 17:30:53 +00:00
|
|
|
uint64_t Align; // Type bit alignment (may be zero.)
|
2006-03-03 15:06:57 +00:00
|
|
|
uint64_t Offset; // Type bit offset (may be zero.)
|
2006-07-11 15:58:09 +00:00
|
|
|
unsigned Flags; // Miscellaneous flags.
|
2006-02-23 16:58:18 +00:00
|
|
|
|
2006-03-03 15:06:57 +00:00
|
|
|
public:
|
2006-02-23 16:58:18 +00:00
|
|
|
TypeDesc(unsigned T);
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
DebugInfoDesc *getContext() const { return Context; }
|
|
|
|
const std::string &getName() const { return Name; }
|
2006-06-16 13:14:03 +00:00
|
|
|
CompileUnitDesc *getFile() const {
|
|
|
|
return static_cast<CompileUnitDesc *>(File);
|
|
|
|
}
|
2006-03-15 19:09:58 +00:00
|
|
|
unsigned getLine() const { return Line; }
|
2006-02-23 16:58:18 +00:00
|
|
|
uint64_t getSize() const { return Size; }
|
2006-03-09 17:30:53 +00:00
|
|
|
uint64_t getAlign() const { return Align; }
|
2006-03-03 15:06:57 +00:00
|
|
|
uint64_t getOffset() const { return Offset; }
|
2006-07-11 15:58:09 +00:00
|
|
|
bool isPrivate() const {
|
|
|
|
return (Flags & FlagPrivate) != 0;
|
|
|
|
}
|
|
|
|
bool isProtected() const {
|
|
|
|
return (Flags & FlagProtected) != 0;
|
|
|
|
}
|
2006-02-23 16:58:18 +00:00
|
|
|
void setContext(DebugInfoDesc *C) { Context = C; }
|
|
|
|
void setName(const std::string &N) { Name = N; }
|
2006-06-16 13:14:03 +00:00
|
|
|
void setFile(CompileUnitDesc *U) {
|
|
|
|
File = static_cast<DebugInfoDesc *>(U);
|
|
|
|
}
|
2006-03-15 19:09:58 +00:00
|
|
|
void setLine(unsigned L) { Line = L; }
|
2006-02-23 16:58:18 +00:00
|
|
|
void setSize(uint64_t S) { Size = S; }
|
2006-03-09 17:30:53 +00:00
|
|
|
void setAlign(uint64_t A) { Align = A; }
|
2006-03-03 15:06:57 +00:00
|
|
|
void setOffset(uint64_t O) { Offset = O; }
|
2006-07-11 15:58:09 +00:00
|
|
|
void setIsPrivate() { Flags |= FlagPrivate; }
|
|
|
|
void setIsProtected() { Flags |= FlagProtected; }
|
2006-02-23 16:58:18 +00:00
|
|
|
|
2006-03-23 18:07:55 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the TypeDesc.
|
2006-02-23 16:58:18 +00:00
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// BasicTypeDesc - This class packages debug information associated with a
|
|
|
|
/// basic type (eg. int, bool, double.)
|
|
|
|
class BasicTypeDesc : public TypeDesc {
|
|
|
|
private:
|
|
|
|
unsigned Encoding; // Type encoding.
|
|
|
|
|
|
|
|
public:
|
|
|
|
BasicTypeDesc();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getEncoding() const { return Encoding; }
|
|
|
|
void setEncoding(unsigned E) { Encoding = E; }
|
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
2006-03-01 17:53:02 +00:00
|
|
|
static bool classof(const BasicTypeDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-02-23 16:58:18 +00:00
|
|
|
|
2006-03-23 18:07:55 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the BasicTypeDesc.
|
2006-02-23 16:58:18 +00:00
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
2006-03-01 17:53:02 +00:00
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
2006-02-23 16:58:18 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-02-23 22:37:30 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2006-02-24 16:46:40 +00:00
|
|
|
/// DerivedTypeDesc - This class packages debug information associated with a
|
|
|
|
/// derived types (eg., typedef, pointer, reference.)
|
|
|
|
class DerivedTypeDesc : public TypeDesc {
|
2006-02-23 22:37:30 +00:00
|
|
|
private:
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *FromType; // Type derived from.
|
2006-02-23 22:37:30 +00:00
|
|
|
|
|
|
|
public:
|
2006-02-24 16:46:40 +00:00
|
|
|
DerivedTypeDesc(unsigned T);
|
2006-02-23 22:37:30 +00:00
|
|
|
|
|
|
|
// Accessors
|
2006-06-16 13:14:03 +00:00
|
|
|
TypeDesc *getFromType() const {
|
|
|
|
return static_cast<TypeDesc *>(FromType);
|
|
|
|
}
|
|
|
|
void setFromType(TypeDesc *F) {
|
|
|
|
FromType = static_cast<DebugInfoDesc *>(F);
|
|
|
|
}
|
2006-02-23 22:37:30 +00:00
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
2006-03-01 17:53:02 +00:00
|
|
|
static bool classof(const DerivedTypeDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-02-23 22:37:30 +00:00
|
|
|
|
2006-03-23 18:07:55 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the DerivedTypeDesc.
|
2006-02-23 22:37:30 +00:00
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
2006-03-01 17:53:02 +00:00
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// CompositeTypeDesc - This class packages debug information associated with a
|
|
|
|
/// array/struct types (eg., arrays, struct, union, enums.)
|
|
|
|
class CompositeTypeDesc : public DerivedTypeDesc {
|
|
|
|
private:
|
|
|
|
std::vector<DebugInfoDesc *> Elements;// Information used to compose type.
|
|
|
|
|
|
|
|
public:
|
|
|
|
CompositeTypeDesc(unsigned T);
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
std::vector<DebugInfoDesc *> &getElements() { return Elements; }
|
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const CompositeTypeDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-03-01 17:53:02 +00:00
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the CompositeTypeDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// SubrangeDesc - This class packages debug information associated with integer
|
|
|
|
/// value ranges.
|
|
|
|
class SubrangeDesc : public DebugInfoDesc {
|
|
|
|
private:
|
2006-03-03 15:06:57 +00:00
|
|
|
int64_t Lo; // Low value of range.
|
|
|
|
int64_t Hi; // High value of range.
|
2006-03-01 17:53:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
SubrangeDesc();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
int64_t getLo() const { return Lo; }
|
|
|
|
int64_t getHi() const { return Hi; }
|
|
|
|
void setLo(int64_t L) { Lo = L; }
|
|
|
|
void setHi(int64_t H) { Hi = H; }
|
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const SubrangeDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-03-01 17:53:02 +00:00
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the SubrangeDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
2006-02-23 22:37:30 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-03-01 23:52:37 +00:00
|
|
|
/// EnumeratorDesc - This class packages debug information associated with
|
|
|
|
/// named integer constants.
|
|
|
|
class EnumeratorDesc : public DebugInfoDesc {
|
|
|
|
private:
|
|
|
|
std::string Name; // Enumerator name.
|
|
|
|
int64_t Value; // Enumerator value.
|
|
|
|
|
|
|
|
public:
|
|
|
|
EnumeratorDesc();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
const std::string &getName() const { return Name; }
|
|
|
|
int64_t getValue() const { return Value; }
|
|
|
|
void setName(const std::string &N) { Name = N; }
|
|
|
|
void setValue(int64_t V) { Value = V; }
|
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const EnumeratorDesc *) { return true; }
|
|
|
|
static bool classof(const DebugInfoDesc *D);
|
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the EnumeratorDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-03-23 18:07:55 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// VariableDesc - This class packages debug information associated with a
|
|
|
|
/// subprogram variable.
|
|
|
|
///
|
|
|
|
class VariableDesc : public DebugInfoDesc {
|
|
|
|
private:
|
|
|
|
DebugInfoDesc *Context; // Context debug descriptor.
|
|
|
|
std::string Name; // Type name (may be empty.)
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *File; // Defined compile unit (may be NULL.)
|
2006-03-23 18:07:55 +00:00
|
|
|
unsigned Line; // Defined line# (may be zero.)
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *TyDesc; // Type of variable.
|
2006-03-23 18:07:55 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
VariableDesc(unsigned T);
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
DebugInfoDesc *getContext() const { return Context; }
|
|
|
|
const std::string &getName() const { return Name; }
|
2006-06-16 13:14:03 +00:00
|
|
|
CompileUnitDesc *getFile() const {
|
|
|
|
return static_cast<CompileUnitDesc *>(File);
|
|
|
|
}
|
2006-03-23 18:07:55 +00:00
|
|
|
unsigned getLine() const { return Line; }
|
2006-06-16 13:14:03 +00:00
|
|
|
TypeDesc *getType() const {
|
|
|
|
return static_cast<TypeDesc *>(TyDesc);
|
|
|
|
}
|
2006-03-23 18:07:55 +00:00
|
|
|
void setContext(DebugInfoDesc *C) { Context = C; }
|
|
|
|
void setName(const std::string &N) { Name = N; }
|
2006-06-16 13:14:03 +00:00
|
|
|
void setFile(CompileUnitDesc *U) {
|
|
|
|
File = static_cast<DebugInfoDesc *>(U);
|
|
|
|
}
|
2006-03-23 18:07:55 +00:00
|
|
|
void setLine(unsigned L) { Line = L; }
|
2006-06-16 13:14:03 +00:00
|
|
|
void setType(TypeDesc *T) {
|
|
|
|
TyDesc = static_cast<DebugInfoDesc *>(T);
|
|
|
|
}
|
2006-03-23 18:07:55 +00:00
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const VariableDesc *) { return true; }
|
|
|
|
static bool classof(const DebugInfoDesc *D);
|
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the VariableDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-03-01 23:52:37 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2006-02-11 01:01:30 +00:00
|
|
|
/// GlobalDesc - This class is the base descriptor for global functions and
|
|
|
|
/// variables.
|
|
|
|
class GlobalDesc : public AnchoredDesc {
|
2006-02-06 15:33:21 +00:00
|
|
|
private:
|
|
|
|
DebugInfoDesc *Context; // Context debug descriptor.
|
|
|
|
std::string Name; // Global name.
|
2006-07-11 15:58:09 +00:00
|
|
|
std::string DisplayName; // C++ unmangled name.
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *File; // Defined compile unit (may be NULL.)
|
2006-03-15 19:09:58 +00:00
|
|
|
unsigned Line; // Defined line# (may be zero.)
|
2006-06-16 13:14:03 +00:00
|
|
|
DebugInfoDesc *TyDesc; // Type debug descriptor.
|
2006-02-06 15:33:21 +00:00
|
|
|
bool IsStatic; // Is the global a static.
|
|
|
|
bool IsDefinition; // Is the global defined in context.
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
protected:
|
|
|
|
GlobalDesc(unsigned T);
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
public:
|
|
|
|
// Accessors
|
|
|
|
DebugInfoDesc *getContext() const { return Context; }
|
|
|
|
const std::string &getName() const { return Name; }
|
2006-07-11 15:58:09 +00:00
|
|
|
const std::string &getDisplayName() const { return DisplayName; }
|
2006-06-16 13:14:03 +00:00
|
|
|
CompileUnitDesc *getFile() const {
|
|
|
|
return static_cast<CompileUnitDesc *>(File);
|
|
|
|
}
|
2006-03-15 19:09:58 +00:00
|
|
|
unsigned getLine() const { return Line; }
|
2006-06-16 13:14:03 +00:00
|
|
|
TypeDesc *getType() const {
|
|
|
|
return static_cast<TypeDesc *>(TyDesc);
|
|
|
|
}
|
2006-02-06 15:33:21 +00:00
|
|
|
bool isStatic() const { return IsStatic; }
|
|
|
|
bool isDefinition() const { return IsDefinition; }
|
2006-02-11 01:01:30 +00:00
|
|
|
void setContext(DebugInfoDesc *C) { Context = C; }
|
2006-02-06 15:33:21 +00:00
|
|
|
void setName(const std::string &N) { Name = N; }
|
2006-07-11 15:58:09 +00:00
|
|
|
void setDisplayName(const std::string &N) { DisplayName = N; }
|
2006-06-16 13:14:03 +00:00
|
|
|
void setFile(CompileUnitDesc *U) {
|
|
|
|
File = static_cast<DebugInfoDesc *>(U);
|
|
|
|
}
|
2006-03-15 19:09:58 +00:00
|
|
|
void setLine(unsigned L) { Line = L; }
|
2006-06-16 13:14:03 +00:00
|
|
|
void setType(TypeDesc *T) {
|
|
|
|
TyDesc = static_cast<DebugInfoDesc *>(T);
|
|
|
|
}
|
2006-02-06 15:33:21 +00:00
|
|
|
void setIsStatic(bool IS) { IsStatic = IS; }
|
|
|
|
void setIsDefinition(bool ID) { IsDefinition = ID; }
|
2006-09-18 14:47:26 +00:00
|
|
|
bool hasMangledName() const {
|
|
|
|
return !DisplayName.empty();
|
|
|
|
}
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the GlobalDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// GlobalVariableDesc - This class packages debug information associated with a
|
|
|
|
/// GlobalVariable.
|
|
|
|
class GlobalVariableDesc : public GlobalDesc {
|
|
|
|
private:
|
|
|
|
GlobalVariable *Global; // llvm global.
|
|
|
|
|
|
|
|
public:
|
|
|
|
GlobalVariableDesc();
|
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
GlobalVariable *getGlobalVariable() const { return Global; }
|
2006-02-06 15:33:21 +00:00
|
|
|
void setGlobalVariable(GlobalVariable *GV) { Global = GV; }
|
2006-02-22 19:02:11 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
// Implement isa/cast/dyncast.
|
2006-03-01 17:53:02 +00:00
|
|
|
static bool classof(const GlobalVariableDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-02-06 15:33:21 +00:00
|
|
|
|
2006-02-06 19:12:02 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the
|
2006-02-06 15:33:21 +00:00
|
|
|
/// GlobalVariableDesc.
|
2006-02-06 19:12:02 +00:00
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
2006-02-06 15:33:21 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual const char *getDescString() const;
|
2006-02-06 15:33:21 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
/// getAnchorString - Return a string used to label this descriptor's anchor.
|
|
|
|
///
|
2006-03-07 20:53:47 +00:00
|
|
|
static const char *AnchorString;
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual const char *getAnchorString() const;
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
2006-01-26 20:21:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2006-02-06 15:33:21 +00:00
|
|
|
/// SubprogramDesc - This class packages debug information associated with a
|
|
|
|
/// subprogram/function.
|
2006-02-11 01:01:30 +00:00
|
|
|
class SubprogramDesc : public GlobalDesc {
|
2006-01-27 15:20:54 +00:00
|
|
|
private:
|
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
public:
|
2006-02-11 01:01:30 +00:00
|
|
|
SubprogramDesc();
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
// Accessors
|
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
2006-03-01 17:53:02 +00:00
|
|
|
static bool classof(const SubprogramDesc *) { return true; }
|
2006-03-01 20:39:36 +00:00
|
|
|
static bool classof(const DebugInfoDesc *D);
|
2006-02-06 15:33:21 +00:00
|
|
|
|
2006-03-15 19:09:58 +00:00
|
|
|
/// ApplyToFields - Target the visitor to the fields of the SubprogramDesc.
|
2006-02-06 19:12:02 +00:00
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual const char *getDescString() const;
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-11 01:01:30 +00:00
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
/// getAnchorString - Return a string used to label this descriptor's anchor.
|
|
|
|
///
|
2006-03-07 20:53:47 +00:00
|
|
|
static const char *AnchorString;
|
2006-02-11 01:01:30 +00:00
|
|
|
virtual const char *getAnchorString() const;
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-03-15 19:09:58 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// BlockDesc - This descriptor groups variables and blocks nested in a block.
|
|
|
|
///
|
|
|
|
class BlockDesc : public DebugInfoDesc {
|
|
|
|
private:
|
2006-03-23 18:07:55 +00:00
|
|
|
DebugInfoDesc *Context; // Context debug descriptor.
|
|
|
|
|
2006-03-15 19:09:58 +00:00
|
|
|
public:
|
|
|
|
BlockDesc();
|
|
|
|
|
|
|
|
// Accessors
|
2006-03-23 18:07:55 +00:00
|
|
|
DebugInfoDesc *getContext() const { return Context; }
|
|
|
|
void setContext(DebugInfoDesc *C) { Context = C; }
|
2006-03-15 19:09:58 +00:00
|
|
|
|
|
|
|
// Implement isa/cast/dyncast.
|
|
|
|
static bool classof(const BlockDesc *) { return true; }
|
|
|
|
static bool classof(const DebugInfoDesc *D);
|
|
|
|
|
|
|
|
/// ApplyToFields - Target the visitor to the fields of the BlockDesc.
|
|
|
|
///
|
|
|
|
virtual void ApplyToFields(DIVisitor *Visitor);
|
|
|
|
|
|
|
|
/// getDescString - Return a string used to compose global names and labels.
|
|
|
|
///
|
|
|
|
virtual const char *getDescString() const;
|
|
|
|
|
|
|
|
/// getTypeString - Return a string used to label this descriptor's type.
|
|
|
|
///
|
|
|
|
virtual const char *getTypeString() const;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
virtual void dump();
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DIDeserializer - This class is responsible for casting GlobalVariables
|
|
|
|
/// into DebugInfoDesc objects.
|
|
|
|
class DIDeserializer {
|
|
|
|
private:
|
|
|
|
std::map<GlobalVariable *, DebugInfoDesc *> GlobalDescs;
|
|
|
|
// Previously defined gloabls.
|
|
|
|
|
|
|
|
public:
|
2006-06-14 14:45:39 +00:00
|
|
|
DIDeserializer() {}
|
2006-02-06 15:33:21 +00:00
|
|
|
~DIDeserializer() {}
|
|
|
|
|
|
|
|
/// Deserialize - Reconstitute a GlobalVariable into it's component
|
|
|
|
/// DebugInfoDesc objects.
|
|
|
|
DebugInfoDesc *Deserialize(Value *V);
|
|
|
|
DebugInfoDesc *Deserialize(GlobalVariable *GV);
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DISerializer - This class is responsible for casting DebugInfoDesc objects
|
|
|
|
/// into GlobalVariables.
|
|
|
|
class DISerializer {
|
|
|
|
private:
|
|
|
|
Module *M; // Definition space module.
|
|
|
|
PointerType *StrPtrTy; // A "sbyte *" type. Created lazily.
|
|
|
|
PointerType *EmptyStructPtrTy; // A "{ }*" type. Created lazily.
|
|
|
|
std::map<unsigned, StructType *> TagTypes;
|
|
|
|
// Types per Tag. Created lazily.
|
|
|
|
std::map<DebugInfoDesc *, GlobalVariable *> DescGlobals;
|
|
|
|
// Previously defined descriptors.
|
2006-02-11 01:01:30 +00:00
|
|
|
std::map<const std::string, Constant *> StringCache;
|
2006-02-06 15:33:21 +00:00
|
|
|
// Previously defined strings.
|
2006-02-11 01:01:30 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
public:
|
2006-02-11 01:01:30 +00:00
|
|
|
DISerializer()
|
|
|
|
: M(NULL)
|
|
|
|
, StrPtrTy(NULL)
|
|
|
|
, EmptyStructPtrTy(NULL)
|
|
|
|
, TagTypes()
|
|
|
|
, DescGlobals()
|
|
|
|
, StringCache()
|
|
|
|
{}
|
2006-02-06 15:33:21 +00:00
|
|
|
~DISerializer() {}
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
Module *getModule() const { return M; };
|
|
|
|
void setModule(Module *module) { M = module; }
|
|
|
|
|
|
|
|
/// getStrPtrType - Return a "sbyte *" type.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-06 15:33:21 +00:00
|
|
|
const PointerType *getStrPtrType();
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
/// getEmptyStructPtrType - Return a "{ }*" type.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-06 15:33:21 +00:00
|
|
|
const PointerType *getEmptyStructPtrType();
|
|
|
|
|
|
|
|
/// getTagType - Return the type describing the specified descriptor (via
|
|
|
|
/// tag.)
|
|
|
|
const StructType *getTagType(DebugInfoDesc *DD);
|
|
|
|
|
|
|
|
/// getString - Construct the string as constant string global.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-11 01:01:30 +00:00
|
|
|
Constant *getString(const std::string &String);
|
2006-02-06 15:33:21 +00:00
|
|
|
|
|
|
|
/// Serialize - Recursively cast the specified descriptor into a
|
|
|
|
/// GlobalVariable so that it can be serialized to a .bc or .ll file.
|
|
|
|
GlobalVariable *Serialize(DebugInfoDesc *DD);
|
|
|
|
};
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DIVerifier - This class is responsible for verifying the given network of
|
|
|
|
/// GlobalVariables are valid as DebugInfoDesc objects.
|
|
|
|
class DIVerifier {
|
|
|
|
private:
|
2006-03-26 22:45:20 +00:00
|
|
|
enum {
|
|
|
|
Unknown = 0,
|
|
|
|
Invalid,
|
|
|
|
Valid
|
|
|
|
};
|
|
|
|
std::map<GlobalVariable *, unsigned> Validity;// Tracks prior results.
|
2006-02-06 15:33:21 +00:00
|
|
|
std::map<unsigned, unsigned> Counts; // Count of fields per Tag type.
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-02-06 15:33:21 +00:00
|
|
|
public:
|
2006-03-26 22:45:20 +00:00
|
|
|
DIVerifier()
|
2006-06-14 14:45:39 +00:00
|
|
|
: Validity()
|
2006-03-26 22:45:20 +00:00
|
|
|
, Counts()
|
|
|
|
{}
|
2006-02-06 15:33:21 +00:00
|
|
|
~DIVerifier() {}
|
|
|
|
|
|
|
|
/// Verify - Return true if the GlobalVariable appears to be a valid
|
|
|
|
/// serialization of a DebugInfoDesc.
|
2006-02-11 01:01:30 +00:00
|
|
|
bool Verify(Value *V);
|
2006-02-06 15:33:21 +00:00
|
|
|
bool Verify(GlobalVariable *GV);
|
2006-01-26 20:21:46 +00:00
|
|
|
};
|
|
|
|
|
2006-01-17 17:31:53 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// SourceLineInfo - This class is used to record source line correspondence.
|
|
|
|
///
|
|
|
|
class SourceLineInfo {
|
|
|
|
private:
|
|
|
|
unsigned Line; // Source line number.
|
|
|
|
unsigned Column; // Source column.
|
|
|
|
unsigned SourceID; // Source ID number.
|
2006-03-23 18:07:55 +00:00
|
|
|
unsigned LabelID; // Label in code ID number.
|
2006-01-17 17:31:53 +00:00
|
|
|
|
|
|
|
public:
|
2006-03-23 18:07:55 +00:00
|
|
|
SourceLineInfo(unsigned L, unsigned C, unsigned S, unsigned I)
|
|
|
|
: Line(L), Column(C), SourceID(S), LabelID(I) {}
|
2006-01-17 17:31:53 +00:00
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getLine() const { return Line; }
|
|
|
|
unsigned getColumn() const { return Column; }
|
|
|
|
unsigned getSourceID() const { return SourceID; }
|
2006-03-23 18:07:55 +00:00
|
|
|
unsigned getLabelID() const { return LabelID; }
|
2006-01-17 17:31:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// SourceFileInfo - This class is used to track source information.
|
|
|
|
///
|
|
|
|
class SourceFileInfo {
|
|
|
|
private:
|
|
|
|
unsigned DirectoryID; // Directory ID number.
|
|
|
|
std::string Name; // File name (not including directory.)
|
|
|
|
|
|
|
|
public:
|
|
|
|
SourceFileInfo(unsigned D, const std::string &N) : DirectoryID(D), Name(N) {}
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getDirectoryID() const { return DirectoryID; }
|
|
|
|
const std::string &getName() const { return Name; }
|
|
|
|
|
|
|
|
/// operator== - Used by UniqueVector to locate entry.
|
|
|
|
///
|
|
|
|
bool operator==(const SourceFileInfo &SI) const {
|
|
|
|
return getDirectoryID() == SI.getDirectoryID() && getName() == SI.getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// operator< - Used by UniqueVector to locate entry.
|
|
|
|
///
|
|
|
|
bool operator<(const SourceFileInfo &SI) const {
|
|
|
|
return getDirectoryID() < SI.getDirectoryID() ||
|
|
|
|
(getDirectoryID() == SI.getDirectoryID() && getName() < SI.getName());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2006-03-23 18:07:55 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DebugVariable - This class is used to track local variable information.
|
|
|
|
///
|
|
|
|
class DebugVariable {
|
|
|
|
private:
|
|
|
|
VariableDesc *Desc; // Variable Descriptor.
|
|
|
|
unsigned FrameIndex; // Variable frame index.
|
|
|
|
|
|
|
|
public:
|
|
|
|
DebugVariable(VariableDesc *D, unsigned I)
|
|
|
|
: Desc(D)
|
|
|
|
, FrameIndex(I)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
VariableDesc *getDesc() const { return Desc; }
|
|
|
|
unsigned getFrameIndex() const { return FrameIndex; }
|
|
|
|
};
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// DebugScope - This class is used to track scope information.
|
|
|
|
///
|
|
|
|
class DebugScope {
|
|
|
|
private:
|
|
|
|
DebugScope *Parent; // Parent to this scope.
|
|
|
|
DebugInfoDesc *Desc; // Debug info descriptor for scope.
|
|
|
|
// Either subprogram or block.
|
|
|
|
unsigned StartLabelID; // Label ID of the beginning of scope.
|
|
|
|
unsigned EndLabelID; // Label ID of the end of scope.
|
|
|
|
std::vector<DebugScope *> Scopes; // Scopes defined in scope.
|
|
|
|
std::vector<DebugVariable *> Variables;// Variables declared in scope.
|
|
|
|
|
|
|
|
public:
|
|
|
|
DebugScope(DebugScope *P, DebugInfoDesc *D)
|
|
|
|
: Parent(P)
|
|
|
|
, Desc(D)
|
|
|
|
, StartLabelID(0)
|
|
|
|
, EndLabelID(0)
|
|
|
|
, Scopes()
|
|
|
|
, Variables()
|
|
|
|
{}
|
|
|
|
~DebugScope();
|
|
|
|
|
|
|
|
// Accessors.
|
|
|
|
DebugScope *getParent() const { return Parent; }
|
|
|
|
DebugInfoDesc *getDesc() const { return Desc; }
|
|
|
|
unsigned getStartLabelID() const { return StartLabelID; }
|
|
|
|
unsigned getEndLabelID() const { return EndLabelID; }
|
|
|
|
std::vector<DebugScope *> &getScopes() { return Scopes; }
|
|
|
|
std::vector<DebugVariable *> &getVariables() { return Variables; }
|
|
|
|
void setStartLabelID(unsigned S) { StartLabelID = S; }
|
|
|
|
void setEndLabelID(unsigned E) { EndLabelID = E; }
|
|
|
|
|
|
|
|
/// AddScope - Add a scope to the scope.
|
|
|
|
///
|
|
|
|
void AddScope(DebugScope *S) { Scopes.push_back(S); }
|
|
|
|
|
|
|
|
/// AddVariable - Add a variable to the scope.
|
|
|
|
///
|
|
|
|
void AddVariable(DebugVariable *V) { Variables.push_back(V); }
|
|
|
|
};
|
|
|
|
|
2005-12-16 22:45:29 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/// MachineDebugInfo - This class contains debug information specific to a
|
|
|
|
/// module. Queries can be made by different debugging schemes and reformated
|
|
|
|
/// for specific use.
|
|
|
|
///
|
2006-01-04 13:46:37 +00:00
|
|
|
class MachineDebugInfo : public ImmutablePass {
|
2005-12-16 22:45:29 +00:00
|
|
|
private:
|
2006-03-23 18:07:55 +00:00
|
|
|
// Use the same deserializer/verifier for the module.
|
2006-02-06 15:33:21 +00:00
|
|
|
DIDeserializer DR;
|
2006-03-23 18:07:55 +00:00
|
|
|
DIVerifier VR;
|
2006-02-06 15:33:21 +00:00
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
// CompileUnits - Uniquing vector for compile units.
|
2006-02-06 15:33:21 +00:00
|
|
|
UniqueVector<CompileUnitDesc *> CompileUnits;
|
2006-01-26 20:21:46 +00:00
|
|
|
|
|
|
|
// Directories - Uniquing vector for directories.
|
2006-01-17 17:31:53 +00:00
|
|
|
UniqueVector<std::string> Directories;
|
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
// SourceFiles - Uniquing vector for source files.
|
2006-01-17 17:31:53 +00:00
|
|
|
UniqueVector<SourceFileInfo> SourceFiles;
|
|
|
|
|
|
|
|
// Lines - List of of source line correspondence.
|
2006-10-17 22:06:46 +00:00
|
|
|
std::vector<SourceLineInfo> Lines;
|
2006-03-23 18:07:55 +00:00
|
|
|
|
2006-11-07 19:33:46 +00:00
|
|
|
// LabelIDList - One entry per assigned label. Normally the entry is equal to
|
|
|
|
// the list index(+1). If the entry is zero then the label has been deleted.
|
|
|
|
// Any other value indicates the label has been deleted by is mapped to
|
|
|
|
// another label.
|
|
|
|
std::vector<unsigned> LabelIDList;
|
2006-03-23 18:07:55 +00:00
|
|
|
|
|
|
|
// ScopeMap - Tracks the scopes in the current function.
|
|
|
|
std::map<DebugInfoDesc *, DebugScope *> ScopeMap;
|
|
|
|
|
|
|
|
// RootScope - Top level scope for the current function.
|
|
|
|
//
|
|
|
|
DebugScope *RootScope;
|
2006-04-07 16:34:46 +00:00
|
|
|
|
|
|
|
// FrameMoves - List of moves done by a function's prolog. Used to construct
|
|
|
|
// frame maps by debug consumers.
|
|
|
|
std::vector<MachineMove *> FrameMoves;
|
2005-12-16 22:45:29 +00:00
|
|
|
|
|
|
|
public:
|
2006-01-26 20:21:46 +00:00
|
|
|
MachineDebugInfo();
|
|
|
|
~MachineDebugInfo();
|
2005-12-16 22:45:29 +00:00
|
|
|
|
2006-01-17 17:31:53 +00:00
|
|
|
/// doInitialization - Initialize the debug state for a new module.
|
2006-01-04 14:29:26 +00:00
|
|
|
///
|
2006-01-17 17:31:53 +00:00
|
|
|
bool doInitialization();
|
|
|
|
|
|
|
|
/// doFinalization - Tear down the debug state after completion of a module.
|
2005-12-16 22:45:29 +00:00
|
|
|
///
|
2006-01-17 17:31:53 +00:00
|
|
|
bool doFinalization();
|
|
|
|
|
2006-04-07 16:34:46 +00:00
|
|
|
/// BeginFunction - Begin gathering function debug information.
|
|
|
|
///
|
|
|
|
void BeginFunction(MachineFunction *MF);
|
|
|
|
|
|
|
|
/// EndFunction - Discard function debug information.
|
|
|
|
///
|
|
|
|
void EndFunction();
|
|
|
|
|
2006-02-13 12:50:39 +00:00
|
|
|
/// getDescFor - Convert a Value to a debug information descriptor.
|
2006-02-11 01:01:30 +00:00
|
|
|
///
|
2006-02-13 12:50:39 +00:00
|
|
|
// FIXME - use new Value type when available.
|
|
|
|
DebugInfoDesc *getDescFor(Value *V);
|
2006-02-11 01:01:30 +00:00
|
|
|
|
|
|
|
/// Verify - Verify that a Value is debug information descriptor.
|
|
|
|
///
|
|
|
|
bool Verify(Value *V);
|
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
/// AnalyzeModule - Scan the module for global debug information.
|
|
|
|
///
|
|
|
|
void AnalyzeModule(Module &M);
|
|
|
|
|
|
|
|
/// hasInfo - Returns true if valid debug info is present.
|
2006-01-17 17:31:53 +00:00
|
|
|
///
|
2006-01-26 20:21:46 +00:00
|
|
|
bool hasInfo() const { return !CompileUnits.empty(); }
|
2006-01-04 13:46:37 +00:00
|
|
|
|
2006-03-23 18:07:55 +00:00
|
|
|
/// NextLabelID - Return the next unique label id.
|
|
|
|
///
|
2006-11-07 19:33:46 +00:00
|
|
|
unsigned NextLabelID() {
|
|
|
|
unsigned ID = LabelIDList.size() + 1;
|
|
|
|
LabelIDList.push_back(ID);
|
|
|
|
return ID;
|
|
|
|
}
|
2006-03-23 18:07:55 +00:00
|
|
|
|
2006-01-05 01:25:28 +00:00
|
|
|
/// RecordLabel - Records location information and associates it with a
|
2006-01-17 17:31:53 +00:00
|
|
|
/// debug label. Returns a unique label ID used to generate a label and
|
|
|
|
/// provide correspondence to the source line list.
|
2006-03-23 18:07:55 +00:00
|
|
|
unsigned RecordLabel(unsigned Line, unsigned Column, unsigned Source);
|
2006-01-05 01:25:28 +00:00
|
|
|
|
2006-10-23 14:56:37 +00:00
|
|
|
/// InvalidateLabel - Inhibit use of the specified label # from
|
|
|
|
/// MachineDebugInfo, for example because the code was deleted.
|
2006-11-07 19:33:46 +00:00
|
|
|
void InvalidateLabel(unsigned LabelID) {
|
|
|
|
// Remap to zero to indicate deletion.
|
|
|
|
RemapLabel(LabelID, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// RemapLabel - Indicate that a label has been merged into another.
|
|
|
|
///
|
|
|
|
void RemapLabel(unsigned OldLabelID, unsigned NewLabelID) {
|
2006-11-08 14:16:39 +00:00
|
|
|
assert(0 < OldLabelID && OldLabelID <= LabelIDList.size() &&
|
|
|
|
"Old debug label ID out of range.");
|
|
|
|
assert(NewLabelID <= LabelIDList.size() &&
|
|
|
|
"New debug label ID out of range.");
|
2006-11-07 19:33:46 +00:00
|
|
|
LabelIDList[OldLabelID - 1] = NewLabelID;
|
|
|
|
}
|
2006-10-17 23:16:42 +00:00
|
|
|
|
2006-11-07 19:33:46 +00:00
|
|
|
/// MappedLabel - Find out the label's final ID. Zero indicates deletion.
|
|
|
|
/// ID != Mapped ID indicates that the label was folded into another label.
|
|
|
|
unsigned MappedLabel(unsigned LabelID) const {
|
2006-11-08 14:16:39 +00:00
|
|
|
assert(LabelID <= LabelIDList.size() && "Debug label ID out of range.");
|
|
|
|
return LabelID ? LabelIDList[LabelID - 1] : 0;
|
2006-11-07 19:33:46 +00:00
|
|
|
}
|
2006-10-23 14:56:37 +00:00
|
|
|
|
2006-01-17 17:31:53 +00:00
|
|
|
/// RecordSource - Register a source file with debug info. Returns an source
|
|
|
|
/// ID.
|
|
|
|
unsigned RecordSource(const std::string &Directory,
|
2006-03-23 18:07:55 +00:00
|
|
|
const std::string &Source);
|
|
|
|
unsigned RecordSource(const CompileUnitDesc *CompileUnit);
|
2006-01-04 22:28:25 +00:00
|
|
|
|
2006-01-17 17:31:53 +00:00
|
|
|
/// getDirectories - Return the UniqueVector of std::string representing
|
|
|
|
/// directories.
|
|
|
|
const UniqueVector<std::string> &getDirectories() const {
|
|
|
|
return Directories;
|
|
|
|
}
|
2006-01-04 22:28:25 +00:00
|
|
|
|
2006-01-17 17:31:53 +00:00
|
|
|
/// getSourceFiles - Return the UniqueVector of source files.
|
2006-01-04 22:28:25 +00:00
|
|
|
///
|
2006-01-17 17:31:53 +00:00
|
|
|
const UniqueVector<SourceFileInfo> &getSourceFiles() const {
|
|
|
|
return SourceFiles;
|
|
|
|
}
|
|
|
|
|
2006-06-23 12:51:53 +00:00
|
|
|
/// getSourceLines - Return a vector of source lines.
|
|
|
|
///
|
2006-10-17 22:06:46 +00:00
|
|
|
const std::vector<SourceLineInfo> &getSourceLines() const {
|
2006-01-17 17:31:53 +00:00
|
|
|
return Lines;
|
|
|
|
}
|
2005-12-16 22:45:29 +00:00
|
|
|
|
2006-10-17 22:06:46 +00:00
|
|
|
// FIXME: nuke this.
|
|
|
|
void ClearLineInfo() {
|
|
|
|
Lines.clear();
|
|
|
|
}
|
|
|
|
|
2006-01-26 20:21:46 +00:00
|
|
|
/// SetupCompileUnits - Set up the unique vector of compile units.
|
|
|
|
///
|
2006-01-29 09:52:11 +00:00
|
|
|
void SetupCompileUnits(Module &M);
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2006-01-26 21:22:49 +00:00
|
|
|
/// getCompileUnits - Return a vector of debug compile units.
|
|
|
|
///
|
2006-02-06 15:33:21 +00:00
|
|
|
const UniqueVector<CompileUnitDesc *> getCompileUnits() const;
|
2006-02-22 19:02:11 +00:00
|
|
|
|
|
|
|
/// getGlobalVariablesUsing - Return all of the GlobalVariables that use the
|
|
|
|
/// named GlobalVariable.
|
|
|
|
std::vector<GlobalVariable*>
|
|
|
|
getGlobalVariablesUsing(Module &M, const std::string &RootName);
|
2006-01-26 21:22:49 +00:00
|
|
|
|
2006-02-22 19:02:11 +00:00
|
|
|
/// getAnchoredDescriptors - Return a vector of anchored debug descriptors.
|
2006-01-26 20:21:46 +00:00
|
|
|
///
|
2006-02-22 19:02:11 +00:00
|
|
|
template <class T>std::vector<T *> getAnchoredDescriptors(Module &M) {
|
|
|
|
T Desc;
|
|
|
|
std::vector<GlobalVariable *> Globals =
|
|
|
|
getGlobalVariablesUsing(M, Desc.getAnchorString());
|
|
|
|
std::vector<T *> AnchoredDescs;
|
|
|
|
for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
|
2006-03-01 20:39:36 +00:00
|
|
|
GlobalVariable *GV = Globals[i];
|
2006-03-23 18:07:55 +00:00
|
|
|
|
2006-06-14 14:45:39 +00:00
|
|
|
// FIXME - In the short term, changes are too drastic to continue.
|
|
|
|
if (DebugInfoDesc::TagFromGlobal(GV) == Desc.getTag() &&
|
|
|
|
DebugInfoDesc::VersionFromGlobal(GV) == LLVMDebugVersion) {
|
2006-03-01 20:39:36 +00:00
|
|
|
AnchoredDescs.push_back(cast<T>(DR.Deserialize(GV)));
|
|
|
|
}
|
2006-02-22 19:02:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return AnchoredDescs;
|
|
|
|
}
|
2006-03-23 18:07:55 +00:00
|
|
|
|
|
|
|
/// RecordRegionStart - Indicate the start of a region.
|
|
|
|
///
|
|
|
|
unsigned RecordRegionStart(Value *V);
|
|
|
|
|
|
|
|
/// RecordRegionEnd - Indicate the end of a region.
|
|
|
|
///
|
|
|
|
unsigned RecordRegionEnd(Value *V);
|
|
|
|
|
|
|
|
/// RecordVariable - Indicate the declaration of a local variable.
|
|
|
|
///
|
|
|
|
void RecordVariable(Value *V, unsigned FrameIndex);
|
|
|
|
|
|
|
|
/// getRootScope - Return current functions root scope.
|
|
|
|
///
|
|
|
|
DebugScope *getRootScope() { return RootScope; }
|
|
|
|
|
|
|
|
/// getOrCreateScope - Returns the scope associated with the given descriptor.
|
|
|
|
///
|
|
|
|
DebugScope *getOrCreateScope(DebugInfoDesc *ScopeDesc);
|
2006-04-07 16:34:46 +00:00
|
|
|
|
|
|
|
/// getFrameMoves - Returns a reference to a list of moves done in the current
|
|
|
|
/// function's prologue. Used to construct frame maps for debug comsumers.
|
|
|
|
std::vector<MachineMove *> &getFrameMoves() { return FrameMoves; }
|
2006-01-26 20:21:46 +00:00
|
|
|
|
2005-12-16 22:45:29 +00:00
|
|
|
}; // End class MachineDebugInfo
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|