Call Verify() methods of various debugging llvm::DI* types after creation.

This commit is contained in:
Matt Pharr
2012-04-25 06:17:05 -10:00
parent 12706cd37f
commit d5cc2ad643
3 changed files with 33 additions and 20 deletions

35
ctx.cpp
View File

@@ -313,27 +313,32 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
flags,
g->opt.level > 0,
llvmFunction);
Assert(diFile.Verify());
/* And start a scope representing the initial function scope */
StartScope();
llvm::DIFile file = funcStartPos.GetDIFile();
Symbol *programIndexSymbol = m->symbolTable->LookupVariable("programIndex");
Assert(programIndexSymbol && programIndexSymbol->storagePtr);
m->diBuilder->createGlobalVariable(programIndexSymbol->name,
file,
funcStartPos.first_line,
programIndexSymbol->type->GetDIType(file),
true /* static */,
programIndexSymbol->storagePtr);
llvm::DIGlobalVariable var =
m->diBuilder->createGlobalVariable(programIndexSymbol->name,
file,
funcStartPos.first_line,
programIndexSymbol->type->GetDIType(file),
true /* static */,
programIndexSymbol->storagePtr);
Assert(var.Verify());
Symbol *programCountSymbol = m->symbolTable->LookupVariable("programCount");
Assert(programCountSymbol);
m->diBuilder->createGlobalVariable(programCountSymbol->name,
file,
funcStartPos.first_line,
programCountSymbol->type->GetDIType(file),
true /* static */,
programCountSymbol->storagePtr);
var =
m->diBuilder->createGlobalVariable(programCountSymbol->name,
file,
funcStartPos.first_line,
programCountSymbol->type->GetDIType(file),
true /* static */,
programCountSymbol->storagePtr);
Assert(var.Verify());
}
}
@@ -1440,6 +1445,7 @@ FunctionEmitContext::StartScope() {
m->diBuilder->createLexicalBlock(parentScope, diFile,
currentPos.first_line,
currentPos.first_column);
Assert(lexicalBlock.Verify());
debugScopes.push_back(lexicalBlock);
}
}
@@ -1467,14 +1473,17 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
return;
llvm::DIScope scope = GetDIScope();
llvm::DIType diType = sym->type->GetDIType(scope);
Assert(diType.Verify());
llvm::DIVariable var =
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
scope,
sym->name,
sym->pos.GetDIFile(),
sym->pos.first_line,
sym->type->GetDIType(scope),
diType,
true /* preserve through opts */);
Assert(var.Verify());
llvm::Instruction *declareInst =
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
AddDebugPos(declareInst, &sym->pos, &scope);

View File

@@ -644,7 +644,9 @@ llvm::DIFile
SourcePos::GetDIFile() const {
std::string directory, filename;
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
return m->diBuilder->createFile(filename, directory);
llvm::DIFile ret = m->diBuilder->createFile(filename, directory);
Assert(ret.Verify());
return ret;
}

View File

@@ -395,12 +395,14 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
if (diBuilder) {
llvm::DIFile file = pos.GetDIFile();
diBuilder->createGlobalVariable(name,
file,
pos.first_line,
sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC),
sym->storagePtr);
llvm::DIGlobalVariable var =
diBuilder->createGlobalVariable(name,
file,
pos.first_line,
sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC),
sym->storagePtr);
Assert(var.Verify());
}
}