aboutsummaryrefslogtreecommitdiff
path: root/src/debug/gosym/symtab.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/gosym/symtab.go')
-rw-r--r--src/debug/gosym/symtab.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/debug/gosym/symtab.go b/src/debug/gosym/symtab.go
index afc67198c3..d87b312b56 100644
--- a/src/debug/gosym/symtab.go
+++ b/src/debug/gosym/symtab.go
@@ -27,6 +27,8 @@ type Sym struct {
GoType uint64
// If this symbol is a function symbol, the corresponding Func
Func *Func
+
+ goVersion version
}
// Static reports whether this symbol is static (not visible outside its file).
@@ -55,9 +57,16 @@ func (s *Sym) nameWithoutInst() string {
func (s *Sym) PackageName() string {
name := s.nameWithoutInst()
- // A prefix of "type." and "go." is a compiler-generated symbol that doesn't belong to any package.
- // See variable reservedimports in cmd/compile/internal/gc/subr.go
- if strings.HasPrefix(name, "go.") || strings.HasPrefix(name, "type.") {
+ // Since go1.20, a prefix of "type:" and "go:" is a compiler-generated symbol,
+ // they do not belong to any package.
+ //
+ // See cmd/compile/internal/base/link.go:ReservedImports variable.
+ if s.goVersion >= ver120 && (strings.HasPrefix(name, "go:") || strings.HasPrefix(name, "type:")) {
+ return ""
+ }
+
+ // For go1.18 and below, the prefix are "type." and "go." instead.
+ if s.goVersion <= ver118 && (strings.HasPrefix(name, "go.") || strings.HasPrefix(name, "type.")) {
return ""
}
@@ -350,6 +359,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, error) {
ts.Type = s.typ
ts.Value = s.value
ts.GoType = s.gotype
+ ts.goVersion = pcln.version
switch s.typ {
default:
// rewrite name to use . instead of ยท (c2 b7)