diff options
Diffstat (limited to 'libgo/go/debug/gosym/symtab.go')
-rw-r--r-- | libgo/go/debug/gosym/symtab.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libgo/go/debug/gosym/symtab.go b/libgo/go/debug/gosym/symtab.go index a84b7f6def1..3be612e1df7 100644 --- a/libgo/go/debug/gosym/symtab.go +++ b/libgo/go/debug/gosym/symtab.go @@ -35,13 +35,21 @@ func (s *Sym) Static() bool { return s.Type >= 'a' } // PackageName returns the package part of the symbol name, // or the empty string if there is none. func (s *Sym) PackageName() string { - pathend := strings.LastIndex(s.Name, "/") + name := s.Name + + // 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.") { + return "" + } + + pathend := strings.LastIndex(name, "/") if pathend < 0 { pathend = 0 } - if i := strings.Index(s.Name[pathend:], "."); i != -1 { - return s.Name[:pathend+i] + if i := strings.Index(name[pathend:], "."); i != -1 { + return name[:pathend+i] } return "" } |