aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objfile
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-11-06 19:56:55 -0500
committerRuss Cox <rsc@golang.org>2014-11-06 19:56:55 -0500
commit6bd0d0542ee15fda0da545c16af43fcfd34d6334 (patch)
tree2802dd7b5d6ee18daacc1558f7beb15dc0cfb2ed /src/cmd/internal/objfile
parent08b2cb4afe3eebd384c543986ca8ee9d4ce04ede (diff)
downloadgo-6bd0d0542ee15fda0da545c16af43fcfd34d6334.tar.xz
cmd/objdump, cmd/pprof: factor disassembly into cmd/internal/objfile
Moving so that new Go 1.4 pprof can use it. The old 'GNU objdump workalike' mode for 'go tool objdump' is now gone, as are the tests for that mode. It was used only by pre-Go 1.4 pprof. You can still specify an address range on the command line; you just get the same output format as you do when dumping the entire binary (without an address limitation). LGTM=r R=r CC=golang-codereviews, iant https://golang.org/cl/167320043
Diffstat (limited to 'src/cmd/internal/objfile')
-rw-r--r--src/cmd/internal/objfile/objfile.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cmd/internal/objfile/objfile.go b/src/cmd/internal/objfile/objfile.go
index 3d4a5d27cd..9227ef387f 100644
--- a/src/cmd/internal/objfile/objfile.go
+++ b/src/cmd/internal/objfile/objfile.go
@@ -9,6 +9,7 @@ import (
"debug/gosym"
"fmt"
"os"
+ "sort"
)
type rawFile interface {
@@ -62,9 +63,20 @@ func (f *File) Close() error {
}
func (f *File) Symbols() ([]Sym, error) {
- return f.raw.symbols()
+ syms, err := f.raw.symbols()
+ if err != nil {
+ return nil, err
+ }
+ sort.Sort(byAddr(syms))
+ return syms, nil
}
+type byAddr []Sym
+
+func (x byAddr) Less(i, j int) bool { return x[i].Addr < x[j].Addr }
+func (x byAddr) Len() int { return len(x) }
+func (x byAddr) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
+
func (f *File) PCLineTable() (*gosym.Table, error) {
textStart, symtab, pclntab, err := f.raw.pcln()
if err != nil {