debug symbols switch

This commit is contained in:
Li Jie
2024-09-13 17:15:36 +08:00
parent 3e5338c902
commit 4c5f37db0f
7 changed files with 76 additions and 28 deletions

View File

@@ -338,8 +338,6 @@ func (p Program) tyComplex128() llvm.Type {
// NewPackage creates a new package.
func (p Program) NewPackage(name, pkgPath string) Package {
mod := p.ctx.NewModule(pkgPath)
di := newDIBuilder(p, mod)
cu := di.CreateCompileUnit(name, pkgPath)
// TODO(xsw): Finalize may cause panic, so comment it.
// mod.Finalize()
gbls := make(map[string]Global)
@@ -354,7 +352,7 @@ func (p Program) NewPackage(name, pkgPath string) Package {
// p.needPyInit = false
ret := &aPackage{
mod: mod, vars: gbls, fns: fns, stubs: stubs,
pyobjs: pyobjs, pymods: pymods, strs: strs, named: named, Prog: p, di: di, cu: cu}
pyobjs: pyobjs, pymods: pymods, strs: strs, named: named, Prog: p, di: nil, cu: nil}
ret.abi.Init(pkgPath)
return ret
}
@@ -711,13 +709,20 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) {
}
func (p Package) Finalize() {
p.di.Finalize()
if p.di != nil {
p.di.Finalize()
}
}
func (p Package) DIBuilder() diBuilder {
return p.di
}
func (p Package) EnableDebugSymbols(name, pkgPath string) {
p.di = newDIBuilder(p.Prog, p.mod)
p.cu = p.di.createCompileUnit(name, pkgPath)
}
// -----------------------------------------------------------------------------
/*