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

View File

@@ -644,7 +644,9 @@ llvm::DIFile
SourcePos::GetDIFile() const { SourcePos::GetDIFile() const {
std::string directory, filename; std::string directory, filename;
GetDirectoryAndFileName(g->currentDirectory, name, &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) { if (diBuilder) {
llvm::DIFile file = pos.GetDIFile(); llvm::DIFile file = pos.GetDIFile();
diBuilder->createGlobalVariable(name, llvm::DIGlobalVariable var =
file, diBuilder->createGlobalVariable(name,
pos.first_line, file,
sym->type->GetDIType(file), pos.first_line,
(sym->storageClass == SC_STATIC), sym->type->GetDIType(file),
sym->storagePtr); (sym->storageClass == SC_STATIC),
sym->storagePtr);
Assert(var.Verify());
} }
} }