ssa: debug info of global variable
This commit is contained in:
@@ -140,6 +140,9 @@ func main() {
|
|||||||
pad1: 100,
|
pad1: 100,
|
||||||
pad2: 200,
|
pad2: 200,
|
||||||
}
|
}
|
||||||
|
globalStructPtr = &s
|
||||||
|
globalStruct = s
|
||||||
|
println("globalInt:", globalInt)
|
||||||
println("s:", &s)
|
println("s:", &s)
|
||||||
FuncWithAllTypeStructParam(s)
|
FuncWithAllTypeStructParam(s)
|
||||||
println("called function with struct")
|
println("called function with struct")
|
||||||
@@ -159,5 +162,11 @@ func main() {
|
|||||||
)
|
)
|
||||||
println(i, err)
|
println(i, err)
|
||||||
println("called function with types")
|
println("called function with types")
|
||||||
|
println(globalStructPtr)
|
||||||
|
println(&globalStruct)
|
||||||
println("done")
|
println("done")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var globalInt int = 301
|
||||||
|
var globalStruct StructWithAllTypeFields
|
||||||
|
var globalStructPtr *StructWithAllTypeFields
|
||||||
|
|||||||
@@ -797,7 +797,12 @@ func (p *context) compileValue(b llssa.Builder, v ssa.Value) llssa.Expr {
|
|||||||
}
|
}
|
||||||
return pyFn.Expr
|
return pyFn.Expr
|
||||||
case *ssa.Global:
|
case *ssa.Global:
|
||||||
return p.varOf(b, v)
|
val := p.varOf(b, v)
|
||||||
|
if debugSymbols {
|
||||||
|
pos := p.fset.Position(v.Pos())
|
||||||
|
b.DIGlobal(val, v.Name(), pos)
|
||||||
|
}
|
||||||
|
return val
|
||||||
case *ssa.Const:
|
case *ssa.Const:
|
||||||
t := types.Default(v.Type())
|
t := types.Default(v.Type())
|
||||||
bg := llssa.InGo
|
bg := llssa.InGo
|
||||||
|
|||||||
14
ssa/di.go
14
ssa/di.go
@@ -90,7 +90,7 @@ func (b diBuilder) createFile(filename string) DIFile {
|
|||||||
return &aDIFile{ll: b.di.CreateFile(file, dir)}
|
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}
|
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)
|
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) {
|
func (b Builder) DISetCurrentDebugLocation(f Function, pos token.Position) {
|
||||||
b.impl.SetCurrentDebugLocation(
|
b.impl.SetCurrentDebugLocation(
|
||||||
uint(pos.Line),
|
uint(pos.Line),
|
||||||
|
|||||||
Reference in New Issue
Block a user