| 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 ( |
| 8 |
"internal/abi" |
| 9 |
"strings" |
| 10 |
) |
| 11 |
|
| 12 |
var funcIDs = map[string]abi.FuncID{ |
| 13 |
"abort": abi.FuncID_abort, |
| 14 |
"asmcgocall": abi.FuncID_asmcgocall, |
| 15 |
"asyncPreempt": abi.FuncID_asyncPreempt, |
| 16 |
"cgocallback": abi.FuncID_cgocallback, |
| 17 |
"corostart": abi.FuncID_corostart, |
| 18 |
"debugCallV2": abi.FuncID_debugCallV2, |
| 19 |
"gcBgMarkWorker": abi.FuncID_gcBgMarkWorker, |
| 20 |
"rt0_go": abi.FuncID_rt0_go, |
| 21 |
"goexit": abi.FuncID_goexit, |
| 22 |
"gogo": abi.FuncID_gogo, |
| 23 |
"gopanic": abi.FuncID_gopanic, |
| 24 |
"handleAsyncEvent": abi.FuncID_handleAsyncEvent, |
| 25 |
"main": abi.FuncID_runtime_main, |
| 26 |
"mcall": abi.FuncID_mcall, |
| 27 |
"morestack": abi.FuncID_morestack, |
| 28 |
"mstart": abi.FuncID_mstart, |
| 29 |
"panicwrap": abi.FuncID_panicwrap, |
| 30 |
"runFinalizers": abi.FuncID_runFinalizers, |
| 31 |
"runCleanups": abi.FuncID_runCleanups, |
| 32 |
"sigpanic": abi.FuncID_sigpanic, |
| 33 |
"systemstack_switch": abi.FuncID_systemstack_switch, |
| 34 |
"systemstack": abi.FuncID_systemstack, |
| 35 |
|
| 36 |
// Don't show in call stack but otherwise not special. |
| 37 |
"deferreturn": abi.FuncIDWrapper, |
| 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) abi.FuncID { |
| 43 |
if isWrapper { |
| 44 |
return abi.FuncIDWrapper |
| 45 |
} |
| 46 |
if strings.HasPrefix(name, "runtime.") { |
| 47 |
if id, ok := funcIDs[name[len("runtime."):]]; ok { |
| 48 |
return id |
| 49 |
} |
| 50 |
} |
| 51 |
return abi.FuncIDNormal |
| 52 |
} |