interp: show backtrace with error

This should make it much easier to figure out why and where an error
happens at package initialization time.
This commit is contained in:
Ayke van Laethem
2020-03-28 20:46:09 +01:00
committed by Ron Evans
parent 2501602b4f
commit cc4a4c755f
6 changed files with 70 additions and 73 deletions
+2 -1
View File
@@ -887,7 +887,8 @@ func (b *builder) createFunctionDefinition() {
if b.fn.Synthetic == "package initializer" {
// Package initializers have no debug info. Create some fake debug
// info to at least have *something*.
b.difunc = b.attachDebugInfoRaw(b.fn, b.fn.LLVMFn, "", "", 0)
filename := b.fn.Package().Pkg.Path() + "/<init>"
b.difunc = b.attachDebugInfoRaw(b.fn, b.fn.LLVMFn, "", filename, 0)
} else if b.fn.Syntax() != nil {
// Create debug info file if needed.
b.difunc = b.attachDebugInfo(b.fn)