Black Lives Matter. Support the Equal Justice Initiative.

Source file src/cmd/internal/objabi/funcid.go

Documentation: cmd/internal/objabi

     1  // Copyright 2018 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 objabi
     6  
     7  import "strings"
     8  
     9  // A FuncFlag records bits about a function, passed to the runtime.
    10  type FuncFlag uint8
    11  
    12  // Note: This list must match the list in runtime/symtab.go.
    13  const (
    14  	FuncFlag_TOPFRAME = 1 << iota
    15  	FuncFlag_SPWRITE
    16  )
    17  
    18  // A FuncID identifies particular functions that need to be treated
    19  // specially by the runtime.
    20  // Note that in some situations involving plugins, there may be multiple
    21  // copies of a particular special runtime function.
    22  type FuncID uint8
    23  
    24  // Note: this list must match the list in runtime/symtab.go.
    25  const (
    26  	FuncID_normal FuncID = iota // not a special function
    27  	FuncID_abort
    28  	FuncID_asmcgocall
    29  	FuncID_asyncPreempt
    30  	FuncID_cgocallback
    31  	FuncID_debugCallV2
    32  	FuncID_gcBgMarkWorker
    33  	FuncID_goexit
    34  	FuncID_gogo
    35  	FuncID_gopanic
    36  	FuncID_handleAsyncEvent
    37  	FuncID_jmpdefer
    38  	FuncID_mcall
    39  	FuncID_morestack
    40  	FuncID_mstart
    41  	FuncID_panicwrap
    42  	FuncID_rt0_go
    43  	FuncID_runfinq
    44  	FuncID_runtime_main
    45  	FuncID_sigpanic
    46  	FuncID_systemstack
    47  	FuncID_systemstack_switch
    48  	FuncID_wrapper // any autogenerated code (hash/eq algorithms, method wrappers, etc.)
    49  )
    50  
    51  var funcIDs = map[string]FuncID{
    52  	"abort":            FuncID_abort,
    53  	"asmcgocall":       FuncID_asmcgocall,
    54  	"asyncPreempt":     FuncID_asyncPreempt,
    55  	"cgocallback":      FuncID_cgocallback,
    56  	"debugCallV2":      FuncID_debugCallV2,
    57  	"gcBgMarkWorker":   FuncID_gcBgMarkWorker,
    58  	"go":               FuncID_rt0_go,
    59  	"goexit":           FuncID_goexit,
    60  	"gogo":             FuncID_gogo,
    61  	"gopanic":          FuncID_gopanic,
    62  	"handleAsyncEvent": FuncID_handleAsyncEvent,
    63  	"jmpdefer":         FuncID_jmpdefer,
    64  	"main":             FuncID_runtime_main,
    65  	"mcall":            FuncID_mcall,
    66  	"morestack":        FuncID_morestack,
    67  	"mstart":           FuncID_mstart,
    68  	"panicwrap":        FuncID_panicwrap,
    69  	"runfinq":          FuncID_runfinq,
    70  	"sigpanic":         FuncID_sigpanic,
    71  	"switch":           FuncID_systemstack_switch,
    72  	"systemstack":      FuncID_systemstack,
    73  
    74  	// Don't show in call stack but otherwise not special.
    75  	"deferreturn":       FuncID_wrapper,
    76  	"runOpenDeferFrame": FuncID_wrapper,
    77  	"reflectcallSave":   FuncID_wrapper,
    78  	"deferCallSave":     FuncID_wrapper,
    79  }
    80  
    81  // Get the function ID for the named function in the named file.
    82  // The function should be package-qualified.
    83  func GetFuncID(name string, isWrapper bool) FuncID {
    84  	if isWrapper {
    85  		return FuncID_wrapper
    86  	}
    87  	if strings.HasPrefix(name, "runtime.") {
    88  		if id, ok := funcIDs[name[len("runtime."):]]; ok {
    89  			return id
    90  		}
    91  	}
    92  	return FuncID_normal
    93  }
    94  

View as plain text