| 1 | // Copyright 2022 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ |
| 16 | |
| 17 | import ( |
| 18 | "path/filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/" |
| 19 | "regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/" |
| 20 | |
| 21 | "github.com/google/pprof/internal/graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/" |
| 22 | ) |
| 23 | |
| 24 | var ( |
| 25 | sepREscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/sepRE. = regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`::|\.`) |
| 26 | fileSepREscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/fileSepRE. = regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`/`) |
| 27 | ) |
| 28 | |
| 29 | // fileNameSuffixes returns a non-empty sequence of shortened file names |
| 30 | // (in decreasing preference) that can be used to represent name. |
| 31 | func fileNameSuffixesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/fileNameSuffixes().(name string) []string { |
| 32 | if name == "" { |
| 33 | // Avoid returning "." when symbol info is missing |
| 34 | return []string{""} |
| 35 | } |
| 36 | return allSuffixesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/allSuffixes().(filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/ToSlash().(filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Cleanscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Clean().(name)), fileSepREscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/fileSepRE.) |
| 37 | } |
| 38 | |
| 39 | // shortNameList returns a non-empty sequence of shortened names |
| 40 | // (in decreasing preference) that can be used to represent name. |
| 41 | func shortNameListscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/shortNameList().(name string) []string { |
| 42 | name = graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.ShortenFunctionNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/ShortenFunctionName().(name) |
| 43 | return allSuffixesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/allSuffixes().(name, sepREscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/sepRE.) |
| 44 | } |
| 45 | |
| 46 | // allSuffixes returns a list of suffixes (in order of decreasing length) |
| 47 | // found by splitting at re. |
| 48 | func allSuffixesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/allSuffixes().(name string, re *regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.Regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#) []string { |
| 49 | seps := re.FindAllStringIndexscip-go gomod github.com/golang/go/src go1.24.0 regexp/Regexp#FindAllStringIndex().(name, -1) |
| 50 | result := make([]string, 0, len(seps)+1) |
| 51 | result = append(result, name) |
| 52 | for _, sep := range seps { |
| 53 | // Suffix starting just after sep |
| 54 | if sep[1] < len(name) { |
| 55 | result = append(result, name[sep[1]:]) |
| 56 | } |
| 57 | } |
| 58 | return result |
| 59 | } |