// Copyright 2014 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Implements methods to remove frames from profiles.package profileimport ()// Prune removes all nodes beneath a node matching dropRx, and not// matching keepRx. If the root node of a Sample matches, the sample// will have an empty stack.func ( *Profile) (, *regexp.Regexp) { := make(map[uint64]bool) := make(map[uint64]bool)for , := range .Location {varintfor = len(.Line) - 1; >= 0; -- {if := .Line[].Function; != nil && .Name != "" { := .Name// Account for leading '.' on the PPC ELF v1 ABI.if [0] == '.' { = [1:] }if .MatchString() {if == nil || !.MatchString() {break } } } }if >= 0 {// Found matching entry to prune. [.ID] = true// Remove the matching location.if == len(.Line)-1 {// Matched the top entry: prune the whole location. [.ID] = true } else { .Line = .Line[+1:] } } }// Prune locs from each Samplefor , := range .Sample {// Scan from the root to the leaves to find the prune location. // Do not prune frames before the first user frame, to avoid // pruning everything. := falsefor := len(.Location) - 1; >= 0; -- { := .Location[].IDif ![] && ![] { = truecontinue }if ! {continue }if [] { .Location = .Location[+1:]break }if [] { .Location = .Location[:]break } } }}// RemoveUninteresting prunes and elides profiles using built-in// tables of uninteresting function names.func ( *Profile) () error {var , *regexp.Regexpvarerrorif .DropFrames != "" {if , = regexp.Compile("^(" + .DropFrames + ")$"); != nil {returnfmt.Errorf("failed to compile regexp %s: %v", .DropFrames, ) }if .KeepFrames != "" {if , = regexp.Compile("^(" + .KeepFrames + ")$"); != nil {returnfmt.Errorf("failed to compile regexp %s: %v", .KeepFrames, ) } } .Prune(, ) }returnnil}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.