compiler: add debug information to //go:embed slice data
Этот коммит содержится в:
родитель
1d86b3f425
коммит
11a6c84ea5
2 изменённых файлов: 14 добавлений и 1 удалений
|
@ -117,7 +117,7 @@ var (
|
|||
// alloc: heap allocations during init interpretation
|
||||
// pack: data created when storing a constant in an interface for example
|
||||
// string: buffer behind strings
|
||||
packageSymbolRegexp = regexp.MustCompile(`\$(alloc|embedfsslice|embedslice|pack|string)(\.[0-9]+)?$`)
|
||||
packageSymbolRegexp = regexp.MustCompile(`\$(alloc|embedfsslice|pack|string)(\.[0-9]+)?$`)
|
||||
)
|
||||
|
||||
// readProgramSizeFromDWARF reads the source location for each line of code and
|
||||
|
|
|
@ -970,6 +970,19 @@ func (c *compilerContext) createEmbedGlobal(member *ssa.Global, global llvm.Valu
|
|||
global.SetInitializer(sliceObj)
|
||||
global.SetVisibility(llvm.HiddenVisibility)
|
||||
|
||||
if c.Debug {
|
||||
// Add debug info to the slice backing array.
|
||||
position := c.program.Fset.Position(member.Pos())
|
||||
diglobal := c.dibuilder.CreateGlobalVariableExpression(llvm.Metadata{}, llvm.DIGlobalVariableExpression{
|
||||
File: c.getDIFile(position.Filename),
|
||||
Line: position.Line,
|
||||
Type: c.getDIType(types.NewArray(types.Typ[types.Byte], int64(len(file.Data)))),
|
||||
LocalToUnit: true,
|
||||
Expr: c.dibuilder.CreateExpression(nil),
|
||||
})
|
||||
bufferGlobal.AddMetadata(0, diglobal)
|
||||
}
|
||||
|
||||
case *types.Struct:
|
||||
// Assume this is an embed.FS struct:
|
||||
// https://cs.opensource.google/go/go/+/refs/tags/go1.18.2:src/embed/embed.go;l=148
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче