summaryrefslogtreecommitdiffstats
path: root/src/cmd/internal/objabi/funcid.go
blob: d9b47f1ec916e9eb93973f845073d7e892ec1c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package objabi

import (
	"internal/abi"
	"strings"
)

var funcIDs = map[string]abi.FuncID{
	"abort":              abi.FuncID_abort,
	"asmcgocall":         abi.FuncID_asmcgocall,
	"asyncPreempt":       abi.FuncID_asyncPreempt,
	"cgocallback":        abi.FuncID_cgocallback,
	"corostart":          abi.FuncID_corostart,
	"debugCallV2":        abi.FuncID_debugCallV2,
	"gcBgMarkWorker":     abi.FuncID_gcBgMarkWorker,
	"rt0_go":             abi.FuncID_rt0_go,
	"goexit":             abi.FuncID_goexit,
	"gogo":               abi.FuncID_gogo,
	"gopanic":            abi.FuncID_gopanic,
	"handleAsyncEvent":   abi.FuncID_handleAsyncEvent,
	"main":               abi.FuncID_runtime_main,
	"mcall":              abi.FuncID_mcall,
	"morestack":          abi.FuncID_morestack,
	"mstart":             abi.FuncID_mstart,
	"panicwrap":          abi.FuncID_panicwrap,
	"runfinq":            abi.FuncID_runfinq,
	"sigpanic":           abi.FuncID_sigpanic,
	"systemstack_switch": abi.FuncID_systemstack_switch,
	"systemstack":        abi.FuncID_systemstack,

	// Don't show in call stack but otherwise not special.
	"deferreturn": abi.FuncIDWrapper,
}

// Get the function ID for the named function in the named file.
// The function should be package-qualified.
func GetFuncID(name string, isWrapper bool) abi.FuncID {
	if isWrapper {
		return abi.FuncIDWrapper
	}
	if strings.HasPrefix(name, "runtime.") {
		if id, ok := funcIDs[name[len("runtime."):]]; ok {
			return id
		}
	}
	return abi.FuncIDNormal
}