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

     1  // Copyright 2021 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  package dwtest
     6  
     7  import (
     8  	"github.com/shogo82148/std/debug/dwarf"
     9  )
    10  
    11  type Examiner struct {
    12  	dies        []*dwarf.Entry
    13  	idxByOffset map[dwarf.Offset]int
    14  	kids        map[int][]int
    15  	parent      map[int]int
    16  	byname      map[string][]int
    17  }
    18  
    19  // Populate the Examiner using the DIEs read from rdr.
    20  func (ex *Examiner) Populate(rdr *dwarf.Reader) error
    21  
    22  func (ex *Examiner) DIEs() []*dwarf.Entry
    23  
    24  // For debugging new tests
    25  func (ex *Examiner) DumpEntry(idx int, dumpKids bool, ilevel int)
    26  
    27  // Given a DIE offset, return the previously read dwarf.Entry, or nil
    28  func (ex *Examiner) EntryFromOffset(off dwarf.Offset) *dwarf.Entry
    29  
    30  // Return the ID that Examiner uses to refer to the DIE at offset off
    31  func (ex *Examiner) IdxFromOffset(off dwarf.Offset) int
    32  
    33  // Returns a list of child entries for a die with ID 'idx'
    34  func (ex *Examiner) Children(idx int) []*dwarf.Entry
    35  
    36  // Returns parent DIE for DIE 'idx', or nil if the DIE is top level
    37  func (ex *Examiner) Parent(idx int) *dwarf.Entry
    38  
    39  // ParentCU returns the enclosing compilation unit DIE for the DIE
    40  // with a given index, or nil if for some reason we can't establish a
    41  // parent.
    42  func (ex *Examiner) ParentCU(idx int) *dwarf.Entry
    43  
    44  // FileRef takes a given DIE by index and a numeric file reference
    45  // (presumably from a decl_file or call_file attribute), looks up the
    46  // reference in the .debug_line file table, and returns the proper
    47  // string for it. We need to know which DIE is making the reference
    48  // so as to find the right compilation unit.
    49  func (ex *Examiner) FileRef(dw *dwarf.Data, dieIdx int, fileRef int64) (string, error)
    50  
    51  // Return a list of all DIEs with name 'name'. When searching for DIEs
    52  // by name, keep in mind that the returned results will include child
    53  // DIEs such as params/variables. For example, asking for all DIEs named
    54  // "p" for even a small program will give you 400-500 entries.
    55  func (ex *Examiner) Named(name string) []*dwarf.Entry