Call Verify() methods of various debugging llvm::DI* types after creation.
This commit is contained in:
11
ctx.cpp
11
ctx.cpp
@@ -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);
|
||||||
|
llvm::DIGlobalVariable var =
|
||||||
m->diBuilder->createGlobalVariable(programIndexSymbol->name,
|
m->diBuilder->createGlobalVariable(programIndexSymbol->name,
|
||||||
file,
|
file,
|
||||||
funcStartPos.first_line,
|
funcStartPos.first_line,
|
||||||
programIndexSymbol->type->GetDIType(file),
|
programIndexSymbol->type->GetDIType(file),
|
||||||
true /* static */,
|
true /* static */,
|
||||||
programIndexSymbol->storagePtr);
|
programIndexSymbol->storagePtr);
|
||||||
|
Assert(var.Verify());
|
||||||
|
|
||||||
Symbol *programCountSymbol = m->symbolTable->LookupVariable("programCount");
|
Symbol *programCountSymbol = m->symbolTable->LookupVariable("programCount");
|
||||||
Assert(programCountSymbol);
|
Assert(programCountSymbol);
|
||||||
|
var =
|
||||||
m->diBuilder->createGlobalVariable(programCountSymbol->name,
|
m->diBuilder->createGlobalVariable(programCountSymbol->name,
|
||||||
file,
|
file,
|
||||||
funcStartPos.first_line,
|
funcStartPos.first_line,
|
||||||
programCountSymbol->type->GetDIType(file),
|
programCountSymbol->type->GetDIType(file),
|
||||||
true /* static */,
|
true /* static */,
|
||||||
programCountSymbol->storagePtr);
|
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);
|
||||||
|
|||||||
4
ispc.cpp
4
ispc.cpp
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
llvm::DIGlobalVariable var =
|
||||||
diBuilder->createGlobalVariable(name,
|
diBuilder->createGlobalVariable(name,
|
||||||
file,
|
file,
|
||||||
pos.first_line,
|
pos.first_line,
|
||||||
sym->type->GetDIType(file),
|
sym->type->GetDIType(file),
|
||||||
(sym->storageClass == SC_STATIC),
|
(sym->storageClass == SC_STATIC),
|
||||||
sym->storagePtr);
|
sym->storagePtr);
|
||||||
|
Assert(var.Verify());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user