Debian Codegraph @

profile/filter_test.go

raw symbols SCIP
1 // Copyright 2018 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 profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/
16
17 import (
18 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
19 "regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/"
20 "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/"
21 "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/"
22
23 "github.com/google/pprof/internal/proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/"
24 )
25
26 var mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings. = []*Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{
27 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 1, Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.: 0x10000, Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.: 0x40000, Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.: "map0", HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions.: true, HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames.: true, HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers.: true, HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames.: true},
28 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 2, Startscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Start.: 0x50000, Limitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#Limit.: 0x70000, Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#File.: "map1", HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions.: true, HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames.: true, HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers.: true, HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames.: true},
29 }
30
31 var functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions. = []*Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{
32 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 1, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun0", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun0", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file0"},
33 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 2, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun1", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun1", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file1"},
34 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 3, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun2", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun2", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file2"},
35 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 4, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun3", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun3", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file3"},
36 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 5, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun4", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun4", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file4"},
37 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 6, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun5", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun5", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file5"},
38 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 7, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun6", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun6", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file6"},
39 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 8, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun7", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun7", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file7"},
40 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 9, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun8", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun8", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file8"},
41 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 10, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun9", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun9", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file9"},
42 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 11, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun10", SystemNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#SystemName.: "fun10", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "file10"},
43 }
44
45 var noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs. = []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{
46 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 1, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x1000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[0], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
47 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 2, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x2000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[1], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
48 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 3, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x3000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[2], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
49 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 4, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x4000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[3], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
50 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 5, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x5000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[4], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
51 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 6, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x6000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[5], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
52 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 7, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x7000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[6], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
53 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 8, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x8000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[7], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
54 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 9, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x9000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[8], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
55 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 10, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x10000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[9], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
56 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 11, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[1], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x11000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[10], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
57 }
58
59 var noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile. = &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{
60 TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos.: 10000,
61 PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.: &ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cpu", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "milliseconds"},
62 Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period.: 1,
63 DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.: 10e9,
64 SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "samples", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "count"}},
65 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.,
66 Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.,
67 Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.: noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.,
68 Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{
69 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[0], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[1], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[2], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[3]}},
70 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{2}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[4], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[5], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[1], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[6]}},
71 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{3}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[7], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[8]}},
72 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{4}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[9], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[4], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[10], noInlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesLocs.[7]}},
73 },
74 }
75
76 var allNoInlinesSampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/allNoInlinesSampleFuncs. = []string{
77 "fun0 fun1 fun2 fun3: 1",
78 "fun4 fun5 fun1 fun6: 2",
79 "fun7 fun8: 3",
80 "fun9 fun4 fun10 fun7: 4",
81 }
82
83 var inlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesLocs. = []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{
84 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 1, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x1000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[0], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}, {Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[1], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
85 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 2, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x2000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[2], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}, {Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[3], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
86 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 3, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x3000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[4], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}, {Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[5], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}, {Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[6], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
87 }
88
89 var inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile. = &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{
90 TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos.: 10000,
91 PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.: &ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cpu", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "milliseconds"},
92 Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period.: 1,
93 DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.: 10e9,
94 SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "samples", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "count"}},
95 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.,
96 Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.,
97 Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.: inlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesLocs.,
98 Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{
99 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{inlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesLocs.[0], inlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesLocs.[1]}},
100 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{2}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{inlinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesLocs.[2]}},
101 },
102 }
103
104 var emptyLinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesLocs. = []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{
105 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 1, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x1000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{{Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[0], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}, {Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.[1], Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 1}}},
106 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 2, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[0], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x2000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{}},
107 {IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 3, Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.[1], Addressscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Address.: 0x2000, Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{}},
108 }
109
110 var emptyLinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesProfile. = &Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{
111 TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos.: 10000,
112 PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.: &ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cpu", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "milliseconds"},
113 Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period.: 1,
114 DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.: 10e9,
115 SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "samples", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "count"}},
116 Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.: mappingsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/mappings.,
117 Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function.: functionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/functions.,
118 Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.: emptyLinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesLocs.,
119 Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{
120 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{emptyLinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesLocs.[0], emptyLinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesLocs.[1]}},
121 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{2}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{emptyLinesLocsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesLocs.[2]}},
122 {Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{3}, Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{}},
123 },
124 }
125
126 func TestFilterSamplesByNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestFilterSamplesByName().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
127 for _, tc := range []struct {
128 // name is the name of the test case.
129 name string
130 // profile is the profile that gets filtered.
131 profile *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#
132 // These are the inputs to FilterSamplesByName().
133 focus, ignore, hide, show *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#
134 // want{F,I,S,H}m are expected return values from FilterSamplesByName.
135 wantFm, wantIm, wantSm, wantHm bool
136 // wantSampleFuncs contains expected stack functions and sample value after
137 // filtering, in the same order as in the profile. The format is as
138 // returned by sampleFuncs function below, which is "callee caller: <num>".
139 wantSampleFuncs []string
140 }{
141 // No Filters
142 {
143 name: "empty filters keep all frames",
144 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
145 wantFm: true,
146 wantSampleFuncs: allNoInlinesSampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/allNoInlinesSampleFuncs.,
147 },
148 // Focus
149 {
150 name: "focus with no matches",
151 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
152 focus: 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().("unknown"),
153 },
154 {
155 name: "focus matches function names",
156 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
157 focus: 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().("fun1"),
158 wantFm: true,
159 wantSampleFuncs: []string{
160 "fun0 fun1 fun2 fun3: 1",
161 "fun4 fun5 fun1 fun6: 2",
162 "fun9 fun4 fun10 fun7: 4",
163 },
164 },
165 {
166 name: "focus matches file names",
167 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
168 focus: 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().("file1"),
169 wantFm: true,
170 wantSampleFuncs: []string{
171 "fun0 fun1 fun2 fun3: 1",
172 "fun4 fun5 fun1 fun6: 2",
173 "fun9 fun4 fun10 fun7: 4",
174 },
175 },
176 {
177 name: "focus matches mapping names",
178 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
179 focus: 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().("map1"),
180 wantFm: true,
181 wantSampleFuncs: []string{
182 "fun9 fun4 fun10 fun7: 4",
183 },
184 },
185 {
186 name: "focus matches inline functions",
187 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
188 focus: 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().("fun5"),
189 wantFm: true,
190 wantSampleFuncs: []string{
191 "fun4 fun5 fun6: 2",
192 },
193 },
194 // Ignore
195 {
196 name: "ignore with no matches matches all samples",
197 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
198 ignore: 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().("unknown"),
199 wantFm: true,
200 wantSampleFuncs: allNoInlinesSampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/allNoInlinesSampleFuncs.,
201 },
202 {
203 name: "ignore matches function names",
204 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
205 ignore: 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().("fun1"),
206 wantFm: true,
207 wantIm: true,
208 wantSampleFuncs: []string{
209 "fun7 fun8: 3",
210 },
211 },
212 {
213 name: "ignore matches file names",
214 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
215 ignore: 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().("file1"),
216 wantFm: true,
217 wantIm: true,
218 wantSampleFuncs: []string{
219 "fun7 fun8: 3",
220 },
221 },
222 {
223 name: "ignore matches mapping names",
224 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
225 ignore: 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().("map1"),
226 wantFm: true,
227 wantIm: true,
228 wantSampleFuncs: []string{
229 "fun0 fun1 fun2 fun3: 1",
230 "fun4 fun5 fun1 fun6: 2",
231 "fun7 fun8: 3",
232 },
233 },
234 {
235 name: "ignore matches inline functions",
236 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
237 ignore: 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().("fun5"),
238 wantFm: true,
239 wantIm: true,
240 wantSampleFuncs: []string{
241 "fun0 fun1 fun2 fun3: 1",
242 },
243 },
244 // Show
245 {
246 name: "show with no matches",
247 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
248 show: 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().("unknown"),
249 wantFm: true,
250 },
251 {
252 name: "show matches function names",
253 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
254 show: 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().("fun1|fun2"),
255 wantFm: true,
256 wantSm: true,
257 wantSampleFuncs: []string{
258 "fun1 fun2: 1",
259 "fun1: 2",
260 "fun10: 4",
261 },
262 },
263 {
264 name: "show matches file names",
265 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
266 show: 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().("file1|file3"),
267 wantFm: true,
268 wantSm: true,
269 wantSampleFuncs: []string{
270 "fun1 fun3: 1",
271 "fun1: 2",
272 "fun10: 4",
273 },
274 },
275 {
276 name: "show matches mapping names",
277 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
278 show: 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().("map1"),
279 wantFm: true,
280 wantSm: true,
281 wantSampleFuncs: []string{
282 "fun10: 4",
283 },
284 },
285 {
286 name: "show matches inline functions",
287 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
288 show: 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().("fun[03]"),
289 wantFm: true,
290 wantSm: true,
291 wantSampleFuncs: []string{
292 "fun0 fun3: 1",
293 },
294 },
295 {
296 name: "show keeps all lines when matching both mapping and function",
297 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
298 show: 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().("map0|fun5"),
299 wantFm: true,
300 wantSm: true,
301 wantSampleFuncs: []string{
302 "fun0 fun1 fun2 fun3: 1",
303 "fun4 fun5 fun6: 2",
304 },
305 },
306 // Hide
307 {
308 name: "hide with no matches",
309 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
310 hide: 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().("unknown"),
311 wantFm: true,
312 wantSampleFuncs: allNoInlinesSampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/allNoInlinesSampleFuncs.,
313 },
314 {
315 name: "hide matches function names",
316 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
317 hide: 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().("fun1|fun2"),
318 wantFm: true,
319 wantHm: true,
320 wantSampleFuncs: []string{
321 "fun0 fun3: 1",
322 "fun4 fun5 fun6: 2",
323 "fun7 fun8: 3",
324 "fun9 fun4 fun7: 4",
325 },
326 },
327 {
328 name: "hide matches file names",
329 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
330 hide: 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().("file1|file3"),
331 wantFm: true,
332 wantHm: true,
333 wantSampleFuncs: []string{
334 "fun0 fun2: 1",
335 "fun4 fun5 fun6: 2",
336 "fun7 fun8: 3",
337 "fun9 fun4 fun7: 4",
338 },
339 },
340 {
341 name: "hide matches mapping names",
342 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
343 hide: 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().("map1"),
344 wantFm: true,
345 wantHm: true,
346 wantSampleFuncs: []string{
347 "fun0 fun1 fun2 fun3: 1",
348 "fun4 fun5 fun1 fun6: 2",
349 "fun7 fun8: 3",
350 "fun9 fun4 fun7: 4",
351 },
352 },
353 {
354 name: "hide matches inline functions",
355 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
356 hide: 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().("fun[125]"),
357 wantFm: true,
358 wantHm: true,
359 wantSampleFuncs: []string{
360 "fun0 fun3: 1",
361 "fun4 fun6: 2",
362 },
363 },
364 {
365 name: "hide drops all lines when matching both mapping and function",
366 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
367 hide: 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().("map0|fun5"),
368 wantFm: true,
369 wantHm: true,
370 },
371 // Compound filters
372 {
373 name: "hides a stack matched by both focus and ignore",
374 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
375 focus: 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().("fun1|fun7"),
376 ignore: 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().("fun1"),
377 wantFm: true,
378 wantIm: true,
379 wantSampleFuncs: []string{
380 "fun7 fun8: 3",
381 },
382 },
383 {
384 name: "hides a function if both show and hide match it",
385 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
386 show: 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().("fun1"),
387 hide: 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().("fun10"),
388 wantFm: true,
389 wantSm: true,
390 wantHm: true,
391 wantSampleFuncs: []string{
392 "fun1: 1",
393 "fun1: 2",
394 },
395 },
396 } {
397 t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
398 p := tc.profile.Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().()
399 fm, im, hm, sm := p.FilterSamplesByNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#FilterSamplesByName().(tc.focus, tc.ignore, tc.hide, tc.show)
400
401 type match struct{ fm, im, hm, sm bool }
402 if got, want := (match{fm: fm, im: im, hm: hm, sm: sm}), (match{fm: tc.wantFm, im: tc.wantIm, hm: tc.wantHm, sm: tc.wantSm}); got != want {
403 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("match got %+v want %+v", got, want)
404 }
405
406 if got, want := stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(sampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/sampleFuncs().(p), "\n")+"\n", stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(tc.wantSampleFuncs, "\n")+"\n"; got != want {
407 diff, err := proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/.Diffscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/Diff().([]byte(want), []byte(got))
408 if err != nil {
409 t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("failed to get diff: %v", err)
410 }
411 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("FilterSamplesByName: got diff(want->got):\n%s", diff)
412 }
413 })
414 }
415 }
416
417 func TestShowFromscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestShowFrom().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
418 for _, tc := range []struct {
419 name string
420 profile *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#
421 showFrom *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#
422 // wantMatch is the expected return value.
423 wantMatch bool
424 // wantSampleFuncs contains expected stack functions and sample value after
425 // filtering, in the same order as in the profile. The format is as
426 // returned by sampleFuncs function below, which is "callee caller: <num>".
427 wantSampleFuncs []string
428 }{
429 {
430 name: "nil showFrom keeps all frames",
431 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
432 wantMatch: false,
433 wantSampleFuncs: allNoInlinesSampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/allNoInlinesSampleFuncs.,
434 },
435 {
436 name: "showFrom with no matches drops all samples",
437 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
438 showFrom: 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().("unknown"),
439 wantMatch: false,
440 },
441 {
442 name: "showFrom matches function names",
443 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
444 showFrom: 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().("fun1"),
445 wantMatch: true,
446 wantSampleFuncs: []string{
447 "fun0 fun1: 1",
448 "fun4 fun5 fun1: 2",
449 "fun9 fun4 fun10: 4",
450 },
451 },
452 {
453 name: "showFrom matches file names",
454 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
455 showFrom: 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().("file1"),
456 wantMatch: true,
457 wantSampleFuncs: []string{
458 "fun0 fun1: 1",
459 "fun4 fun5 fun1: 2",
460 "fun9 fun4 fun10: 4",
461 },
462 },
463 {
464 name: "showFrom matches mapping names",
465 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
466 showFrom: 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().("map1"),
467 wantMatch: true,
468 wantSampleFuncs: []string{
469 "fun9 fun4 fun10: 4",
470 },
471 },
472 {
473 name: "showFrom drops frames above highest of multiple matches",
474 profile: noInlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/noInlinesProfile.,
475 showFrom: 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().("fun[12]"),
476 wantMatch: true,
477 wantSampleFuncs: []string{
478 "fun0 fun1 fun2: 1",
479 "fun4 fun5 fun1: 2",
480 "fun9 fun4 fun10: 4",
481 },
482 },
483 {
484 name: "showFrom matches inline functions",
485 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
486 showFrom: 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().("fun0|fun5"),
487 wantMatch: true,
488 wantSampleFuncs: []string{
489 "fun0: 1",
490 "fun4 fun5: 2",
491 },
492 },
493 {
494 name: "showFrom drops frames above highest of multiple inline matches",
495 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
496 showFrom: 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().("fun[1245]"),
497 wantMatch: true,
498 wantSampleFuncs: []string{
499 "fun0 fun1 fun2: 1",
500 "fun4 fun5: 2",
501 },
502 },
503 {
504 name: "showFrom keeps all lines when matching mapping and function",
505 profile: inlinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/inlinesProfile.,
506 showFrom: 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().("map0|fun5"),
507 wantMatch: true,
508 wantSampleFuncs: []string{
509 "fun0 fun1 fun2 fun3: 1",
510 "fun4 fun5 fun6: 2",
511 },
512 },
513 {
514 name: "showFrom matches location with empty lines",
515 profile: emptyLinesProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/emptyLinesProfile.,
516 showFrom: 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().("map1"),
517 wantMatch: true,
518 wantSampleFuncs: []string{
519 ": 2",
520 },
521 },
522 } {
523 t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
524 p := tc.profile.Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().()
525
526 if gotMatch := p.ShowFromscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#ShowFrom().(tc.showFrom); gotMatch != tc.wantMatch {
527 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("match got %+v, want %+v", gotMatch, tc.wantMatch)
528 }
529
530 if got, want := stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(sampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/sampleFuncs().(p), "\n")+"\n", stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(tc.wantSampleFuncs, "\n")+"\n"; got != want {
531 diff, err := proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/.Diffscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/Diff().([]byte(want), []byte(got))
532 if err != nil {
533 t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("failed to get diff: %v", err)
534 }
535 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("profile samples got diff(want->got):\n%s", diff)
536 }
537 })
538 }
539 }
540
541 // sampleFuncs returns a slice of strings where each string represents one
542 // profile sample in the format "<fun1> <fun2> <fun3>: <value>". This allows
543 // the expected values for test cases to be specified in human-readable
544 // strings.
545 func sampleFuncsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/sampleFuncs().(p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) []string {
546 var ret []string
547 for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
548 var funcs []string
549 for _, loc := range s.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location. {
550 for _, line := range loc.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line. {
551 funcs = append(funcs, line.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.)
552 }
553 }
554 ret = append(ret, fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%s: %d", stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.24.0 strings/Join().(funcs, " "), s.Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.[0]))
555 }
556 return ret
557 }
558
559 func TestTagFilterscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/TestTagFilter().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
560 // Perform several forms of tag filtering on the test profile.
561
562 type filterTestcase struct {
563 include, exclude *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#
564 im, em bool
565 count int
566 }
567
568 countTags := func(p *Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#) map[string]bool {
569 tags := make(map[string]bool)
570
571 for _, s := range p.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. {
572 for l := range s.Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label. {
573 tags[l] = true
574 }
575 for l := range s.NumLabelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#NumLabel. {
576 tags[l] = true
577 }
578 }
579 return tags
580 }
581
582 for tx, tc := range []filterTestcase{
583 {nil, nil, true, false, 3},
584 {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().("notfound"), nil, false, false, 0},
585 {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().("key1"), nil, true, false, 1},
586 {nil, 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().("key[12]"), true, true, 1},
587 } {
588 prof := testProfile1scip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/testProfile1..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().()
589 gim, gem := prof.FilterTagsByNamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#FilterTagsByName().(tc.include, tc.exclude)
590 if gim != tc.im {
591 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Filter #%d, got include match=%v, want %v", tx, gim, tc.im)
592 }
593 if gem != tc.em {
594 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Filter #%d, got exclude match=%v, want %v", tx, gem, tc.em)
595 }
596 if tags := countTags(prof); len(tags) != tc.count {
597 t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Filter #%d, got %d tags[%v], want %d", tx, len(tags), tags, tc.count)
598 }
599 }
600 }