aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2018-02-12 16:34:48 +0000
committerDaniel Martí <mvdan@mvdan.cc>2018-02-15 16:25:43 +0000
commite7cbbbe9bb878b6ca4ce04fde645df1c8f1845bd (patch)
treef84255198234eb4870c48228cdb4828de1f4f8c5 /src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go
parentafb9fc1de922a4ead9d2d787613255a7ba3490f7 (diff)
downloadgo-e7cbbbe9bb878b6ca4ce04fde645df1c8f1845bd.tar.xz
cmd/vendor/github.com/google/pprof: refresh from upstream
Updating to commit 0e0e5b7254e076a62326ab7305ba49e8515f0c91 from github.com/google/pprof Recent modifications to the vendored pprof, such as skipping TestWebInterface to avoid starting a web browser, have all been fixed upstream. Change-Id: I72e11108c438e1573bf2f9216e76d157378e8d45 Reviewed-on: https://go-review.googlesource.com/93375 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go b/src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go
index 1a3b6f8d6a..28c89aa163 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/binutils/disasm.go
@@ -34,24 +34,48 @@ var (
func findSymbols(syms []byte, file string, r *regexp.Regexp, address uint64) ([]*plugin.Sym, error) {
// Collect all symbols from the nm output, grouping names mapped to
// the same address into a single symbol.
+
+ // The symbols to return.
var symbols []*plugin.Sym
+
+ // The current group of symbol names, and the address they are all at.
names, start := []string{}, uint64(0)
+
buf := bytes.NewBuffer(syms)
- for symAddr, name, err := nextSymbol(buf); err == nil; symAddr, name, err = nextSymbol(buf) {
+
+ for {
+ symAddr, name, err := nextSymbol(buf)
+ if err == io.EOF {
+ // Done. If there was an unfinished group, append it.
+ if len(names) != 0 {
+ if match := matchSymbol(names, start, symAddr-1, r, address); match != nil {
+ symbols = append(symbols, &plugin.Sym{Name: match, File: file, Start: start, End: symAddr - 1})
+ }
+ }
+
+ // And return the symbols.
+ return symbols, nil
+ }
+
if err != nil {
+ // There was some kind of serious error reading nm's output.
return nil, err
}
- if start == symAddr {
+
+ // If this symbol is at the same address as the current group, add it to the group.
+ if symAddr == start {
names = append(names, name)
continue
}
+
+ // Otherwise append the current group to the list of symbols.
if match := matchSymbol(names, start, symAddr-1, r, address); match != nil {
symbols = append(symbols, &plugin.Sym{Name: match, File: file, Start: start, End: symAddr - 1})
}
+
+ // And start a new group.
names, start = []string{name}, symAddr
}
-
- return symbols, nil
}
// matchSymbol checks if a symbol is to be selected by checking its
@@ -62,7 +86,7 @@ func matchSymbol(names []string, start, end uint64, r *regexp.Regexp, address ui
return names
}
for _, name := range names {
- if r.MatchString(name) {
+ if r == nil || r.MatchString(name) {
return []string{name}
}