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
This commit is contained in:
Russ Cox 2014-11-06 19:56:55 -05:00
parent 08b2cb4afe
commit 6bd0d0542e
4 changed files with 69 additions and 326 deletions

View file

@ -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 {