本文整理汇总了C++中DISubprogram::getNode方法的典型用法代码示例。如果您正苦于以下问题:C++ DISubprogram::getNode方法的具体用法?C++ DISubprogram::getNode怎么用?C++ DISubprogram::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DISubprogram
的用法示例。
在下文中一共展示了DISubprogram::getNode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSubprogram
// addSubprogram - Add subprgoram into SPs.
bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
if (SP.isNull())
return false;
if (!NodesSeen.insert(SP.getNode()))
return false;
SPs.push_back(SP.getNode());
return true;
}
示例2: EmitFunctionStart
/// EmitFunctionStart - Constructs the debug code for entering a function -
/// "llvm.dbg.func.start."
void DebugInfo::EmitFunctionStart(tree FnDecl) {
setCurrentLexicalBlock(FnDecl);
DISubprogram SP = CreateSubprogramFromFnDecl(FnDecl);
// Push function on region stack.
RegionStack.push_back(WeakVH(SP.getNode()));
}
示例3: createStructType
/// createStructType - Create StructType for struct or union or class.
DIType DebugInfo::createStructType(tree type) {
// struct { a; b; ... z; }; | union { a; b; ... z; };
unsigned Tag = TREE_CODE(type) == RECORD_TYPE ? DW_TAG_structure_type :
DW_TAG_union_type;
unsigned RunTimeLang = 0;
if (TYPE_LANG_SPECIFIC (type)
&& lang_hooks.types.is_runtime_specific_type (type))
{
unsigned CULang = TheCU.getLanguage();
switch (CULang) {
case DW_LANG_ObjC_plus_plus :
RunTimeLang = DW_LANG_ObjC_plus_plus;
break;
case DW_LANG_ObjC :
RunTimeLang = DW_LANG_ObjC;
break;
case DW_LANG_C_plus_plus :
RunTimeLang = DW_LANG_C_plus_plus;
break;
default:
break;
}
}
// Records and classes and unions can all be recursive. To handle them,
// we first generate a debug descriptor for the struct as a forward
// declaration. Then (if it is a definition) we go through and get debug
// info for all of its members. Finally, we create a descriptor for the
// complete type (which may refer to the forward decl if the struct is
// recursive) and replace all uses of the forward declaration with the
// final definition.
expanded_location Loc = GetNodeLocation(TREE_CHAIN(type), false);
// FIXME: findRegion() is not able to find context all the time. This
// means when type names in different context match then FwdDecl is
// reused because MDNodes are uniqued. To avoid this, use type context
/// also while creating FwdDecl for now.
std::string FwdName;
if (TYPE_CONTEXT(type)) {
StringRef TypeContextName = GetNodeName(TYPE_CONTEXT(type));
if (!TypeContextName.empty())
FwdName = TypeContextName;
}
StringRef TypeName = GetNodeName(type);
if (!TypeName.empty())
FwdName = FwdName + TypeName.data();
unsigned SFlags = 0;
if (TYPE_BLOCK_IMPL_STRUCT(type))
SFlags |= llvm::DIType::FlagAppleBlock;
if (type_is_block_byref_struct(type))
SFlags |= llvm::DIType::FlagBlockByrefStruct;
DIDescriptor TyContext = findRegion(TYPE_CONTEXT(type));
// Check if this type is created while creating context information
// descriptor.
std::map<tree_node *, WeakVH >::iterator I = TypeCache.find(type);
if (I != TypeCache.end())
if (MDNode *TN = dyn_cast_or_null<MDNode>(I->second))
return DIType(TN);
llvm::DICompositeType FwdDecl =
DebugFactory.CreateCompositeType(Tag,
TyContext,
FwdName.c_str(),
getOrCreateFile(Loc.file),
Loc.line,
0, 0, 0, SFlags | llvm::DIType::FlagFwdDecl,
llvm::DIType(), llvm::DIArray(),
RunTimeLang);
// forward declaration,
if (TYPE_SIZE(type) == 0)
return FwdDecl;
// Insert into the TypeCache so that recursive uses will find it.
llvm::TrackingVH<llvm::MDNode> FwdDeclNode = FwdDecl.getNode();
TypeCache[type] = WeakVH(FwdDecl.getNode());
// Push the struct on region stack.
RegionStack.push_back(WeakVH(FwdDecl.getNode()));
RegionMap[type] = WeakVH(FwdDecl.getNode());
// Convert all the elements.
llvm::SmallVector<llvm::DIDescriptor, 16> EltTys;
if (tree binfo = TYPE_BINFO(type)) {
VEC(tree,gc) *accesses = BINFO_BASE_ACCESSES (binfo);
for (unsigned i = 0, e = BINFO_N_BASE_BINFOS(binfo); i != e; ++i) {
tree BInfo = BINFO_BASE_BINFO(binfo, i);
tree BInfoType = BINFO_TYPE (BInfo);
DIType BaseClass = getOrCreateType(BInfoType);
unsigned BFlags = 0;
if (BINFO_VIRTUAL_P (BInfo))
BFlags = llvm::DIType::FlagVirtual;
if (accesses) {
tree access = VEC_index (tree, accesses, i);
if (access == access_protected_node)
//.........这里部分代码省略.........
示例4: CreateSubprogramFromFnDecl
/// CreateSubprogramFromFnDecl - Constructs the debug code for
/// entering a function - "llvm.dbg.func.start."
DISubprogram DebugInfo::CreateSubprogramFromFnDecl(tree FnDecl) {
DISubprogram SPDecl;
bool SPDeclIsSet = false;
// True if we're currently generating LLVM for this function.
bool definition = llvm_set_decl_p(FnDecl);
DIType FNType = getOrCreateType(TREE_TYPE(FnDecl));
std::map<tree_node *, WeakVH >::iterator I = SPCache.find(FnDecl);
if (I != SPCache.end()) {
SPDecl = DISubprogram(cast<MDNode>(I->second));
SPDeclIsSet = true;
// If we've already created the defining instance, OR this
// invocation won't create the defining instance, return what we
// already have.
if (SPDecl.isDefinition() || !definition)
return SPDecl;
}
bool ArtificialFnWithAbstractOrigin = false;
// If this artificial function has abstract origin then put this function
// at module scope. The abstract copy will be placed in appropriate region.
if (DECL_ARTIFICIAL (FnDecl)
&& DECL_ABSTRACT_ORIGIN (FnDecl)
&& DECL_ABSTRACT_ORIGIN (FnDecl) != FnDecl)
ArtificialFnWithAbstractOrigin = true;
DIDescriptor SPContext = ArtificialFnWithAbstractOrigin ?
getOrCreateFile(main_input_filename) :
findRegion (DECL_CONTEXT(FnDecl));
// Declare block_invoke functions at file scope for GDB.
if (BLOCK_SYNTHESIZED_FUNC(FnDecl))
SPContext = findRegion(NULL_TREE);
// Creating context may have triggered creation of this SP descriptor. So
// check the cache again.
if (!SPDeclIsSet) {
I = SPCache.find(FnDecl);
if (I != SPCache.end()) {
SPDecl = DISubprogram(cast<MDNode>(I->second));
DISubprogram SP =
DebugFactory.CreateSubprogramDefinition(SPDecl);
SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
// Push function on region stack.
RegionStack.push_back(WeakVH(SP.getNode()));
RegionMap[FnDecl] = WeakVH(SP.getNode());
return SP;
}
}
// Gather location information.
expanded_location Loc = GetNodeLocation(FnDecl, false);
// If the name isn't public, omit the linkage name. Adding a
// linkage name to a class method can confuse GDB.
StringRef LinkageName = TREE_PUBLIC(FnDecl) ?
getLinkageName(FnDecl) : StringRef();
unsigned lineno = LOCATION_LINE(Loc);
if (isCopyOrDestroyHelper(FnDecl))
lineno = 0;
unsigned Virtuality = 0;
unsigned VIndex = 0;
DIType ContainingType;
if (DECL_VINDEX (FnDecl)) {
if (host_integerp (DECL_VINDEX (FnDecl), 0))
VIndex = tree_low_cst (DECL_VINDEX (FnDecl), 0);
Virtuality = dwarf::DW_VIRTUALITY_virtual;
ContainingType = getOrCreateType(DECL_CONTEXT (FnDecl));
}
StringRef FnName = getFunctionName(FnDecl);
// If the Function * hasn't been created yet, use a bogus value for
// the debug internal linkage bit.
bool hasInternalLinkage = true;
Function *Fn = 0;
if (GET_DECL_LLVM_INDEX(FnDecl)) {
Fn = cast<Function>DECL_LLVM(FnDecl);
if (Fn)
hasInternalLinkage = Fn->hasInternalLinkage();
}
DISubprogram SP =
DebugFactory.CreateSubprogram(SPContext,
FnName, FnName,
LinkageName,
getOrCreateFile(Loc.file), lineno,
FNType,
hasInternalLinkage,
definition,
Virtuality, VIndex, ContainingType,
DECL_ARTIFICIAL (FnDecl), optimize,
Fn);
SPCache[FnDecl] = WeakVH(SP.getNode());
RegionMap[FnDecl] = WeakVH(SP.getNode());
if (SPDeclIsSet && SPDecl.getNode() != SP.getNode())
SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
return SP;
//.........这里部分代码省略.........