funcid.go raw

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