ssa: debug info of global variable

This commit is contained in:
Li Jie
2024-09-18 22:05:41 +08:00
parent 90a83c8f11
commit 87f6c8087f
3 changed files with 28 additions and 2 deletions

View File

@@ -90,7 +90,7 @@ func (b diBuilder) createFile(filename string) DIFile {
return &aDIFile{ll: b.di.CreateFile(file, dir)}
}
func (f DIFile) scopeMeta(b diBuilder, cu CompilationUnit, pos token.Position) DIScopeMeta {
func (f DIFile) scopeMeta(b diBuilder, pos token.Position) DIScopeMeta {
return &aDIScopeMeta{b.file(pos.Filename).ll}
}
@@ -633,6 +633,18 @@ func (b Builder) DIVarAuto(f Function, pos token.Position, varName string, vt Ty
return b.Pkg.diBuilder().varAuto(f, pos, varName, t)
}
func (b Builder) DIGlobal(v Expr, name string, pos token.Position) {
gv := b.Pkg.diBuilder().createGlobalVariableExpression(
b.Pkg.diBuilder().file(pos.Filename),
pos,
name,
name,
b.Pkg.diBuilder().diType(v.Type, pos),
false,
)
v.impl.AddMetadata(0, gv.ll)
}
func (b Builder) DISetCurrentDebugLocation(f Function, pos token.Position) {
b.impl.SetCurrentDebugLocation(
uint(pos.Line),