compiler: add debug information to []embed.file slice global
Этот коммит содержится в:
		
							родитель
							
								
									11a6c84ea5
								
							
						
					
					
						коммит
						d87e3ce330
					
				
					 2 изменённых файлов: 12 добавлений и 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|pack|string)(\.[0-9]+)?$`)
 | 
			
		||||
	packageSymbolRegexp = regexp.MustCompile(`\$(alloc|pack|string)(\.[0-9]+)?$`)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// readProgramSizeFromDWARF reads the source location for each line of code and
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1071,6 +1071,17 @@ func (c *compilerContext) createEmbedGlobal(member *ssa.Global, global llvm.Valu
 | 
			
		|||
		sliceGlobal.SetGlobalConstant(true)
 | 
			
		||||
		sliceGlobal.SetUnnamedAddr(true)
 | 
			
		||||
		sliceGlobal.SetAlignment(c.targetData.ABITypeAlignment(sliceInitializer.Type()))
 | 
			
		||||
		if c.Debug {
 | 
			
		||||
			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.NewSlice(embedFileStructType)),
 | 
			
		||||
				LocalToUnit: true,
 | 
			
		||||
				Expr:        c.dibuilder.CreateExpression(nil),
 | 
			
		||||
			})
 | 
			
		||||
			sliceGlobal.AddMetadata(0, diglobal)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Define the embed.FS struct. It has only one field: the files (as a
 | 
			
		||||
		// *[]embed.file).
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Загрузка…
	
	Создание таблицы
		
		Сослаться в новой задаче