funcid.go 2.8 KB

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