github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/link/internal/ld/dwarf.go (about)

     1  // Copyright 2019 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // TODO/NICETOHAVE:
     6  //   - eliminate DW_CLS_ if not used
     7  //   - package info in compilation units
     8  //   - assign types to their packages
     9  //   - gdb uses c syntax, meaning clumsy quoting is needed for go identifiers. eg
    10  //     ptype struct '[]uint8' and qualifiers need to be quoted away
    11  //   - file:line info for variables
    12  //   - make strings a typedef so prettyprinters can see the underlying string type
    13  
    14  package ld
    15  
    16  // https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html
    17  // Each entry inside .debug_gdb_scripts section begins with a non-null prefix
    18  // byte that specifies the kind of entry. The following entries are supported:
    19  const (
    20  	GdbScriptPythonFileId = 1
    21  	GdbScriptSchemeFileId = 3
    22  	GdbScriptPythonTextId = 4
    23  	GdbScriptSchemeTextId = 6
    24  )
    25  
    26  /*
    27   * Generate a sequence of opcodes that is as short as possible.
    28   * See section 6.2.5
    29   */
    30  const (
    31  	LINE_BASE   = -4
    32  	LINE_RANGE  = 10
    33  	PC_RANGE    = (255 - OPCODE_BASE) / LINE_RANGE
    34  	OPCODE_BASE = 11
    35  )
    36  
    37  const (
    38  	COMPUNITHEADERSIZE = 4 + 2 + 4 + 1
    39  )