MCPcopy Index your code
hub / github.com/tinygo-org/tinygo / setDebugLocation

Method setDebugLocation

compiler/compiler.go:697–739  ·  view source on GitHub ↗

setDebugLocation sets the current debug location for the builder.

(pos token.Pos)

Source from the content-addressed store, hash-verified

695
696// setDebugLocation sets the current debug location for the builder.
697func (b *builder) setDebugLocation(pos token.Pos) {
698 if pos == token.NoPos {
699 // No debug information available for this instruction.
700 b.SetCurrentDebugLocation(0, 0, b.difunc, llvm.Metadata{})
701 return
702 }
703
704 position := b.program.Fset.Position(pos)
705 if b.fn.Synthetic == "package initializer" {
706 // Package initializers are treated specially, because while individual
707 // Go SSA instructions have file/line/col information, the parent
708 // function does not. LLVM doesn't store filename information per
709 // instruction, only per function. We work around this difference by
710 // creating a fake DIFunction for each Go file and say that the
711 // instruction really came from that (fake) function but was inlined in
712 // the package initializer function.
713 position := b.program.Fset.Position(pos)
714 name := filepath.Base(position.Filename)
715 difunc, ok := b.initPseudoFuncs[name]
716 if !ok {
717 diFuncType := b.dibuilder.CreateSubroutineType(llvm.DISubroutineType{
718 File: b.getDIFile(position.Filename),
719 })
720 difunc = b.dibuilder.CreateFunction(b.getDIFile(position.Filename), llvm.DIFunction{
721 Name: b.fn.RelString(nil) + "#" + name,
722 File: b.getDIFile(position.Filename),
723 Line: 0,
724 Type: diFuncType,
725 LocalToUnit: true,
726 IsDefinition: true,
727 ScopeLine: 0,
728 Flags: llvm.FlagPrototyped,
729 Optimized: true,
730 })
731 b.initPseudoFuncs[name] = difunc
732 }
733 b.SetCurrentDebugLocation(uint(position.Line), uint(position.Column), difunc, b.initInlinedAt)
734 return
735 }
736
737 // Regular debug information.
738 b.SetCurrentDebugLocation(uint(position.Line), uint(position.Column), b.difunc, llvm.Metadata{})
739}
740
741// getLocalVariable returns a debug info entry for a local variable, which may
742// either be a parameter or a regular variable. It will create a new metadata

Callers 3

createFunctionStartMethod · 0.95
createInstructionMethod · 0.95
createWasmExportMethod · 0.80

Calls 1

getDIFileMethod · 0.45

Tested by

no test coverage detected