Kaynağa Gözat

Merge pull request #43 from rauls5382/golang

Upstream minor changes from golang version of pprof
Josef Jelinek 8 yıl önce
ebeveyn
işleme
2abe7148c6

+ 1
- 1
driver/driver.go Dosyayı Görüntüle

@@ -123,7 +123,7 @@ type MappingSources map[string][]struct {
123 123
 
124 124
 // An ObjTool inspects shared libraries and executable files.
125 125
 type ObjTool interface {
126
-	// Open opens the named object file.  If the object is a shared
126
+	// Open opens the named object file. If the object is a shared
127 127
 	// library, start/limit/offset are the addresses where it is mapped
128 128
 	// into memory in the address space being inspected.
129 129
 	Open(file string, start, limit, offset uint64) (ObjFile, error)

+ 2
- 2
internal/binutils/addr2liner.go Dosyayı Görüntüle

@@ -129,7 +129,7 @@ func (d *addr2Liner) readFrame() (plugin.Frame, bool) {
129 129
 	}
130 130
 	if strings.HasPrefix(funcname, "0x") {
131 131
 		// If addr2line returns a hex address we can assume it is the
132
-		// sentinel.  Read and ignore next two lines of output from
132
+		// sentinel. Read and ignore next two lines of output from
133 133
 		// addr2line
134 134
 		d.readString()
135 135
 		d.readString()
@@ -204,7 +204,7 @@ func (d *addr2Liner) addrInfo(addr uint64) ([]plugin.Frame, error) {
204 204
 		nm, err := d.nm.addrInfo(addr)
205 205
 		if err == nil && len(nm) > 0 {
206 206
 			// Last entry in frame list should match since
207
-			// it is non-inlined.  As a simple heuristic,
207
+			// it is non-inlined. As a simple heuristic,
208 208
 			// we only switch to the nm-based name if it
209 209
 			// is longer.
210 210
 			nmName := nm[len(nm)-1].Func

+ 3
- 3
internal/binutils/binutils.go Dosyayı Görüntüle

@@ -164,10 +164,10 @@ func (b *Binutils) openELF(name string, start, limit, offset uint64) (plugin.Obj
164 164
 	var pageAligned = func(addr uint64) bool { return addr%4096 == 0 }
165 165
 	if strings.Contains(name, "vmlinux") || !pageAligned(start) || !pageAligned(limit) || !pageAligned(offset) {
166 166
 		// Reading all Symbols is expensive, and we only rarely need it so
167
-		// we don't want to do it every time.  But if _stext happens to be
167
+		// we don't want to do it every time. But if _stext happens to be
168 168
 		// page-aligned but isn't the same as Vaddr, we would symbolize
169
-		// wrong.  So if the name the addresses aren't page aligned, or if
170
-		// the name is "vmlinux" we read _stext.  We can be wrong if: (1)
169
+		// wrong. So if the name the addresses aren't page aligned, or if
170
+		// the name is "vmlinux" we read _stext. We can be wrong if: (1)
171 171
 		// someone passes a kernel path that doesn't contain "vmlinux" AND
172 172
 		// (2) _stext is page-aligned AND (3) _stext is not at Vaddr
173 173
 		symbols, err := ef.Symbols()

+ 4
- 0
internal/driver/driver.go Dosyayı Görüntüle

@@ -107,6 +107,10 @@ func generateReport(p *profile.Profile, cmd []string, vars variables, o *plugin.
107 107
 		}
108 108
 	}
109 109
 
110
+	if len(p.Sample) == 0 {
111
+		return fmt.Errorf("profile is empty")
112
+	}
113
+
110 114
 	if err := aggregate(p, vars); err != nil {
111 115
 		return err
112 116
 	}

+ 2
- 2
internal/driver/testdata/pprof.cpu.flat.addresses.weblist Dosyayı Görüntüle

@@ -67,7 +67,7 @@ function pprof_toggle_asm(e) {
67 67
 <div class="legend">File: testbinary<br>
68 68
 Type: cpu<br>
69 69
 Duration: 10s, Total samples = 1.12s (11.20%)<br>Total: 1.12s</div><h1>line1000</h1>testdata/file1000.src
70
-<pre onClick="pprof_toggle_asm()">
70
+<pre onClick="pprof_toggle_asm(event)">
71 71
   Total:       1.10s      1.10s (flat, cum) 98.21%
72 72
 <span class=line>      1</span> <span class=deadsrc>       1.10s      1.10s line1 </span><span class=asm>               1.10s      1.10s     1000: instruction one                                  <span class=disasmloc>testdata/file1000.src:1</span>
73 73
                    .          .     1001: instruction two                                  <span class=disasmloc></span>
@@ -81,7 +81,7 @@ Duration: 10s, Total samples = 1.12s (11.20%)<br>Total: 1.12s</div><h1>line1000<
81 81
 <span class=line>      6</span> <span class=nop>           .          . line6 </span>
82 82
 </pre>
83 83
 <h1>line3000</h1>testdata/file3000.src
84
-<pre onClick="pprof_toggle_asm()">
84
+<pre onClick="pprof_toggle_asm(event)">
85 85
   Total:        10ms      1.12s (flat, cum)   100%
86 86
 <span class=line>      1</span> <span class=nop>           .          . line1 </span>
87 87
 <span class=line>      2</span> <span class=nop>           .          . line2 </span>

+ 9
- 9
internal/elfexec/elfexec.go Dosyayı Görüntüle

@@ -166,10 +166,10 @@ func GetBuildID(binary io.ReaderAt) ([]byte, error) {
166 166
 }
167 167
 
168 168
 // GetBase determines the base address to subtract from virtual
169
-// address to get symbol table address.  For an executable, the base
170
-// is 0.  Otherwise, it's a shared library, and the base is the
171
-// address where the mapping starts.  The kernel is special, and may
172
-// use the address of the _stext symbol as the mmap start.  _stext
169
+// address to get symbol table address. For an executable, the base
170
+// is 0. Otherwise, it's a shared library, and the base is the
171
+// address where the mapping starts. The kernel is special, and may
172
+// use the address of the _stext symbol as the mmap start. _stext
173 173
 // offset can be obtained with `nm vmlinux | grep _stext`
174 174
 func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint64, start, limit, offset uint64) (uint64, error) {
175 175
 	const (
@@ -193,8 +193,8 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
193 193
 			return 0, nil
194 194
 		}
195 195
 		if start == 0 && limit != 0 {
196
-			// ChromeOS remaps its kernel to 0.  Nothing else should come
197
-			// down this path.  Empirical values:
196
+			// ChromeOS remaps its kernel to 0. Nothing else should come
197
+			// down this path. Empirical values:
198 198
 			//       VADDR=0xffffffff80200000
199 199
 			// stextOffset=0xffffffff80200198
200 200
 			if stextOffset != nil {
@@ -217,7 +217,7 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
217 217
 			//      Offset=0 (0xc000000000000000 for PowerPC64)
218 218
 			// So the base should be:
219 219
 			if stextOffset != nil && (start%pageSize) == (*stextOffset%pageSize) {
220
-				// perf uses the address of _stext as start.  Some tools may
220
+				// perf uses the address of _stext as start. Some tools may
221 221
 				// adjust for this before calling GetBase, in which case the the page
222 222
 				// alignment should be different from that of stextOffset.
223 223
 				return start - *stextOffset, nil
@@ -225,8 +225,8 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
225 225
 
226 226
 			return start - loadSegment.Vaddr, nil
227 227
 		} else if start < loadSegment.Vaddr && start%pageSize != 0 && stextOffset != nil && *stextOffset%pageSize == start%pageSize {
228
-			// ChromeOS remaps its kernel to 0 + start%pageSize.  Nothing
229
-			// else should come down this path.  Empirical values:
228
+			// ChromeOS remaps its kernel to 0 + start%pageSize. Nothing
229
+			// else should come down this path. Empirical values:
230 230
 			//       start=0x198 limit=0x2f9fffff offset=0
231 231
 			//       VADDR=0xffffffff81000000
232 232
 			// stextOffset=0xffffffff81000198

+ 1
- 1
internal/graph/dotgraph.go Dosyayı Görüntüle

@@ -313,7 +313,7 @@ func (b *builder) addEdge(edge *Edge, from, to int, hasNodelets bool) {
313 313
 
314 314
 // dotColor returns a color for the given score (between -1.0 and
315 315
 // 1.0), with -1.0 colored red, 0.0 colored grey, and 1.0 colored
316
-// green.  If isBackground is true, then a light (low-saturation)
316
+// green. If isBackground is true, then a light (low-saturation)
317 317
 // color is returned (suitable for use as a background color);
318 318
 // otherwise, a darker color is returned (suitable for use as a
319 319
 // foreground color).

+ 2
- 2
internal/graph/graph.go Dosyayı Görüntüle

@@ -55,7 +55,7 @@ type Node struct {
55 55
 	// Info describes the source location associated to this node.
56 56
 	Info NodeInfo
57 57
 
58
-	// Function represents the function that this node belongs to.  On
58
+	// Function represents the function that this node belongs to. On
59 59
 	// graphs with sub-function resolution (eg line number or
60 60
 	// addresses), two nodes in a NodeMap that are part of the same
61 61
 	// function have the same value of Node.Function. If the Node
@@ -508,7 +508,7 @@ func isNegative(n *Node) bool {
508 508
 	}
509 509
 }
510 510
 
511
-// CreateNodes creates graph nodes for all locations in a profile.  It
511
+// CreateNodes creates graph nodes for all locations in a profile. It
512 512
 // returns set of all nodes, plus a mapping of each location to the
513 513
 // set of corresponding nodes (one per location.Line). If kept is
514 514
 // non-nil, only nodes in that set are included; nodes that do not

+ 1
- 1
internal/measurement/measurement.go Dosyayı Görüntüle

@@ -115,7 +115,7 @@ func compatibleValueTypes(v1, v2 *profile.ValueType) bool {
115 115
 }
116 116
 
117 117
 // Scale a measurement from an unit to a different unit and returns
118
-// the scaled value and the target unit.  The returned target unit
118
+// the scaled value and the target unit. The returned target unit
119 119
 // will be empty if uninteresting (could be skipped).
120 120
 func Scale(value int64, fromUnit, toUnit string) (float64, string) {
121 121
 	// Avoid infinite recursion on overflow.

+ 2
- 2
internal/plugin/plugin.go Dosyayı Görüntüle

@@ -73,7 +73,7 @@ type FlagSet interface {
73 73
 	Parse(usage func()) []string
74 74
 }
75 75
 
76
-// A Fetcher reads and returns the profile named by src.  src can be a
76
+// A Fetcher reads and returns the profile named by src. src can be a
77 77
 // local file path or a URL. duration and timeout are units specified
78 78
 // by the end user, or 0 by default. duration refers to the length of
79 79
 // the profile collection, if applicable, and timeout is the amount of
@@ -98,7 +98,7 @@ type MappingSources map[string][]struct {
98 98
 
99 99
 // An ObjTool inspects shared libraries and executable files.
100 100
 type ObjTool interface {
101
-	// Open opens the named object file.  If the object is a shared
101
+	// Open opens the named object file. If the object is a shared
102 102
 	// library, start/limit/offset are the addresses where it is mapped
103 103
 	// into memory in the address space being inspected.
104 104
 	Open(file string, start, limit, offset uint64) (ObjFile, error)

+ 5
- 31
internal/report/report.go Dosyayı Görüntüle

@@ -20,7 +20,6 @@ import (
20 20
 	"fmt"
21 21
 	"io"
22 22
 	"math"
23
-	"os"
24 23
 	"path/filepath"
25 24
 	"regexp"
26 25
 	"sort"
@@ -419,11 +418,13 @@ func nodesPerSymbol(ns graph.Nodes, symbols []*objSymbol) map[*objSymbol]graph.N
419 418
 }
420 419
 
421 420
 // annotateAssembly annotates a set of assembly instructions with a
422
-// set of samples. It returns a set of nodes to display.  base is an
421
+// set of samples. It returns a set of nodes to display. base is an
423 422
 // offset to adjust the sample addresses.
424 423
 func annotateAssembly(insns []plugin.Inst, samples graph.Nodes, base uint64) graph.Nodes {
425 424
 	// Add end marker to simplify printing loop.
426
-	insns = append(insns, plugin.Inst{^uint64(0), "", "", 0})
425
+	insns = append(insns, plugin.Inst{
426
+		Addr: ^uint64(0),
427
+	})
427 428
 
428 429
 	// Ensure samples are sorted by address.
429 430
 	samples.Sort(graph.AddressOrder)
@@ -467,14 +468,6 @@ func valueOrDot(value int64, rpt *Report) string {
467 468
 	return rpt.formatValue(value)
468 469
 }
469 470
 
470
-// canAccessFile determines if the filename can be opened for reading.
471
-func canAccessFile(path string) bool {
472
-	if fi, err := os.Stat(path); err == nil {
473
-		return fi.Mode().Perm()&0400 != 0
474
-	}
475
-	return false
476
-}
477
-
478 471
 // printTags collects all tags referenced in the profile and prints
479 472
 // them in a sorted table.
480 473
 func printTags(w io.Writer, rpt *Report) error {
@@ -725,7 +718,7 @@ func getDisambiguatedNames(g *graph.Graph) map[*graph.Node]string {
725 718
 
726 719
 // callgrindName implements the callgrind naming compression scheme.
727 720
 // For names not previously seen returns "(N) name", where N is a
728
-// unique index.  For names previously seen returns "(N)" where N is
721
+// unique index. For names previously seen returns "(N)" where N is
729 722
 // the index returned the first time.
730 723
 func callgrindName(names map[string]int, name string) string {
731 724
 	if name == "" {
@@ -1051,25 +1044,6 @@ type Report struct {
1051 1044
 	formatValue func(int64) string
1052 1045
 }
1053 1046
 
1054
-func (rpt *Report) formatTags(s *profile.Sample) (string, bool) {
1055
-	var labels []string
1056
-	for key, vals := range s.Label {
1057
-		for _, v := range vals {
1058
-			labels = append(labels, key+":"+v)
1059
-		}
1060
-	}
1061
-	for key, nvals := range s.NumLabel {
1062
-		for _, v := range nvals {
1063
-			labels = append(labels, measurement.Label(v, key))
1064
-		}
1065
-	}
1066
-	if len(labels) == 0 {
1067
-		return "", false
1068
-	}
1069
-	sort.Strings(labels)
1070
-	return strings.Join(labels, `\n`), true
1071
-}
1072
-
1073 1047
 func abs64(i int64) int64 {
1074 1048
 	if i < 0 {
1075 1049
 		return -i

+ 1
- 1
internal/report/source.go Dosyayı Görüntüle

@@ -281,7 +281,7 @@ func printHeader(w io.Writer, rpt *Report) {
281 281
 // printFunctionHeader prints a function header for a weblist report.
282 282
 func printFunctionHeader(w io.Writer, name, path string, flatSum, cumSum int64, rpt *Report) {
283 283
 	fmt.Fprintf(w, `<h1>%s</h1>%s
284
-<pre onClick="pprof_toggle_asm()">
284
+<pre onClick="pprof_toggle_asm(event)">
285 285
   Total:  %10s %10s (flat, cum) %s
286 286
 `,
287 287
 		template.HTMLEscapeString(name), template.HTMLEscapeString(path),

+ 1
- 1
internal/symbolz/symbolz.go Dosyayı Görüntüle

@@ -36,7 +36,7 @@ var (
36 36
 
37 37
 // Symbolize symbolizes profile p by parsing data returned by a
38 38
 // symbolz handler. syms receives the symbolz query (hex addresses
39
-// separated by '+') and returns the symbolz output in a string.  It
39
+// separated by '+') and returns the symbolz output in a string. It
40 40
 // symbolizes all locations based on their addresses, regardless of
41 41
 // mapping.
42 42
 func Symbolize(sources plugin.MappingSources, syms func(string, string) ([]byte, error), p *profile.Profile, ui plugin.UI) error {

+ 1
- 0
pprof.go Dosyayı Görüntüle

@@ -26,5 +26,6 @@ import (
26 26
 func main() {
27 27
 	if err := driver.PProf(&driver.Options{}); err != nil {
28 28
 		fmt.Fprintf(os.Stderr, "pprof: %v\n", err)
29
+		os.Exit(2)
29 30
 	}
30 31
 }

+ 1
- 1
profile/encode.go Dosyayı Görüntüle

@@ -24,7 +24,7 @@ func (p *Profile) decoder() []decoder {
24 24
 }
25 25
 
26 26
 // preEncode populates the unexported fields to be used by encode
27
-// (with suffix X) from the corresponding exported fields.  The
27
+// (with suffix X) from the corresponding exported fields. The
28 28
 // exported fields are cleared up to facilitate testing.
29 29
 func (p *Profile) preEncode() {
30 30
 	strings := make(map[string]int)

+ 10
- 10
profile/legacy_profile.go Dosyayı Görüntüle

@@ -78,7 +78,7 @@ func parseGoCount(b []byte) (*Profile, error) {
78 78
 	if m == nil {
79 79
 		return nil, errUnrecognized
80 80
 	}
81
-	profileType := string(m[1])
81
+	profileType := m[1]
82 82
 	p := &Profile{
83 83
 		PeriodType: &ValueType{Type: profileType, Unit: "count"},
84 84
 		Period:     1,
@@ -103,11 +103,11 @@ func parseGoCount(b []byte) (*Profile, error) {
103 103
 		if m == nil {
104 104
 			return nil, errMalformed
105 105
 		}
106
-		n, err := strconv.ParseInt(string(m[1]), 0, 64)
106
+		n, err := strconv.ParseInt(m[1], 0, 64)
107 107
 		if err != nil {
108 108
 			return nil, errMalformed
109 109
 		}
110
-		fields := strings.Fields(string(m[2]))
110
+		fields := strings.Fields(m[2])
111 111
 		locs := make([]*Location, 0, len(fields))
112 112
 		for _, stk := range fields {
113 113
 			addr, err := strconv.ParseUint(stk, 0, 64)
@@ -407,7 +407,7 @@ func cleanupDuplicateLocations(p *Profile) {
407 407
 //   3rd word -- 0
408 408
 //
409 409
 // Addresses from stack traces may point to the next instruction after
410
-// each call.  Optionally adjust by -1 to land somewhere on the actual
410
+// each call. Optionally adjust by -1 to land somewhere on the actual
411 411
 // call (except for the leaf, which is not a call).
412 412
 func parseCPUSamples(b []byte, parse func(b []byte) (uint64, []byte), adjust bool, p *Profile) ([]byte, map[uint64]*Location, error) {
413 413
 	locs := make(map[uint64]*Location)
@@ -444,7 +444,7 @@ func parseCPUSamples(b []byte, parse func(b []byte) (uint64, []byte), adjust boo
444 444
 		}
445 445
 		p.Sample = append(p.Sample,
446 446
 			&Sample{
447
-				Value:    []int64{int64(count), int64(count) * int64(p.Period)},
447
+				Value:    []int64{int64(count), int64(count) * p.Period},
448 448
 				Location: sloc,
449 449
 			})
450 450
 	}
@@ -526,7 +526,7 @@ func parseHeap(b []byte) (p *Profile, err error) {
526 526
 		var sloc []*Location
527 527
 		for _, addr := range addrs {
528 528
 			// Addresses from stack traces point to the next instruction after
529
-			// each call.  Adjust by -1 to land somewhere on the actual call.
529
+			// each call. Adjust by -1 to land somewhere on the actual call.
530 530
 			addr--
531 531
 			loc := locs[addr]
532 532
 			if locs[addr] == nil {
@@ -542,7 +542,7 @@ func parseHeap(b []byte) (p *Profile, err error) {
542 542
 		p.Sample = append(p.Sample, &Sample{
543 543
 			Value:    value,
544 544
 			Location: sloc,
545
-			NumLabel: map[string][]int64{"bytes": []int64{blocksize}},
545
+			NumLabel: map[string][]int64{"bytes": {blocksize}},
546 546
 		})
547 547
 	}
548 548
 
@@ -559,7 +559,7 @@ func parseHeapHeader(line string) (sampling string, period int64, hasAlloc bool,
559 559
 	}
560 560
 
561 561
 	if len(header[6]) > 0 {
562
-		if period, err = strconv.ParseInt(string(header[6]), 10, 64); err != nil {
562
+		if period, err = strconv.ParseInt(header[6], 10, 64); err != nil {
563 563
 			return "", 0, false, errUnrecognized
564 564
 		}
565 565
 	}
@@ -765,7 +765,7 @@ func parseContention(b []byte) (p *Profile, err error) {
765 765
 		var sloc []*Location
766 766
 		for _, addr := range addrs {
767 767
 			// Addresses from stack traces point to the next instruction after
768
-			// each call.  Adjust by -1 to land somewhere on the actual call.
768
+			// each call. Adjust by -1 to land somewhere on the actual call.
769 769
 			addr--
770 770
 			loc := locs[addr]
771 771
 			if locs[addr] == nil {
@@ -905,7 +905,7 @@ func parseThread(b []byte) (*Profile, error) {
905 905
 		var sloc []*Location
906 906
 		for i, addr := range addrs {
907 907
 			// Addresses from stack traces point to the next instruction after
908
-			// each call.  Adjust by -1 to land somewhere on the actual call
908
+			// each call. Adjust by -1 to land somewhere on the actual call
909 909
 			// (except for the leaf, which is not a call).
910 910
 			if i > 0 {
911 911
 				addr--

+ 1
- 1
profile/merge.go Dosyayı Görüntüle

@@ -61,7 +61,7 @@ func Merge(srcs []*Profile) (*Profile, error) {
61 61
 
62 62
 		if len(pm.mappings) == 0 && len(src.Mapping) > 0 {
63 63
 			// The Mapping list has the property that the first mapping
64
-			// represents the main binary.  Take the first Mapping we see,
64
+			// represents the main binary. Take the first Mapping we see,
65 65
 			// otherwise the operations below will add mappings in an
66 66
 			// arbitrary order.
67 67
 			pm.mapMapping(srcs[0].Mapping[0])

+ 2
- 2
profile/profile.go Dosyayı Görüntüle

@@ -128,7 +128,7 @@ type Function struct {
128 128
 	filenameX   int64
129 129
 }
130 130
 
131
-// Parse parses a profile and checks for its validity.  The input
131
+// Parse parses a profile and checks for its validity. The input
132 132
 // may be a gzip-compressed encoded protobuf or one of many legacy
133 133
 // profile formats which may be unsupported in the future.
134 134
 func Parse(r io.Reader) (*Profile, error) {
@@ -280,7 +280,7 @@ func (p *Profile) WriteUncompressed(w io.Writer) error {
280 280
 	return err
281 281
 }
282 282
 
283
-// CheckValid tests whether the profile is valid.  Checks include, but are
283
+// CheckValid tests whether the profile is valid. Checks include, but are
284 284
 // not limited to:
285 285
 //   - len(Profile.Sample[n].value) == len(Profile.value_unit)
286 286
 //   - Sample.id has a corresponding Profile.Location

+ 26
- 26
profile/profile_test.go Dosyayı Görüntüle

@@ -91,7 +91,7 @@ func TestParse(t *testing.T) {
91 91
 }
92 92
 
93 93
 // leaveTempfile leaves |b| in a temporary file on disk and returns the
94
-// temp filename.  This is useful to recover a profile when the test
94
+// temp filename. This is useful to recover a profile when the test
95 95
 // fails.
96 96
 func leaveTempfile(b []byte) string {
97 97
 	f1, err := ioutil.TempFile("", "profile_test")
@@ -508,28 +508,28 @@ func TestFilter(t *testing.T) {
508 508
 }
509 509
 
510 510
 func TestTagFilter(t *testing.T) {
511
-     // Perform several forms of tag filtering on the test profile.
511
+	// Perform several forms of tag filtering on the test profile.
512 512
 
513 513
 	type filterTestcase struct {
514 514
 		include, exclude *regexp.Regexp
515
-		im, em bool
516
-		count int
517
-	}
518
-
519
-	countTags := func (p *Profile) map[string]bool {
520
-		  tags := make(map[string]bool)
521
-
522
-		  for _, s := range p.Sample {
523
-		      for l := range s.Label {
524
-		      	  tags[l] = true
525
-		      }		      
526
-		      for l := range s.NumLabel {
527
-		      	  tags[l] = true
528
-		      }		      
529
-		  }
530
-		  return tags
531
-	}	
532
-	
515
+		im, em           bool
516
+		count            int
517
+	}
518
+
519
+	countTags := func(p *Profile) map[string]bool {
520
+		tags := make(map[string]bool)
521
+
522
+		for _, s := range p.Sample {
523
+			for l := range s.Label {
524
+				tags[l] = true
525
+			}
526
+			for l := range s.NumLabel {
527
+				tags[l] = true
528
+			}
529
+		}
530
+		return tags
531
+	}
532
+
533 533
 	for tx, tc := range []filterTestcase{
534 534
 		{nil, nil, true, false, 3},
535 535
 		{regexp.MustCompile("notfound"), nil, false, false, 0},
@@ -538,15 +538,15 @@ func TestTagFilter(t *testing.T) {
538 538
 	} {
539 539
 		prof := testProfile.Copy()
540 540
 		gim, gem := prof.FilterTagsByName(tc.include, tc.exclude)
541
-		if  gim != tc.im {
541
+		if gim != tc.im {
542 542
 			t.Errorf("Filter #%d, got include match=%v, want %v", tx, gim, tc.im)
543
-		}		
544
-		if  gem != tc.em {
543
+		}
544
+		if gem != tc.em {
545 545
 			t.Errorf("Filter #%d, got exclude match=%v, want %v", tx, gem, tc.em)
546
-		}		
547
-		if  tags := countTags(prof) ; len(tags) != tc.count {
546
+		}
547
+		if tags := countTags(prof); len(tags) != tc.count {
548 548
 			t.Errorf("Filter #%d, got %d tags[%v], want %d", tx, len(tags), tags, tc.count)
549
-		}		
549
+		}
550 550
 	}
551 551
 }
552 552
 

+ 1
- 1
profile/prune.go Dosyayı Görüntüle

@@ -23,7 +23,7 @@ import (
23 23
 )
24 24
 
25 25
 // Prune removes all nodes beneath a node matching dropRx, and not
26
-// matching keepRx.  If the root node of a Sample matches, the sample
26
+// matching keepRx. If the root node of a Sample matches, the sample
27 27
 // will have an empty stack.
28 28
 func (p *Profile) Prune(dropRx, keepRx *regexp.Regexp) {
29 29
 	prune := make(map[uint64]bool)