aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/objfile
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2016-03-23 17:10:18 -0700
committerIan Lance Taylor <iant@golang.org>2016-03-31 04:05:06 +0000
commitb4117995e3e01a669be737c36033c2393858d555 (patch)
treec01edce64a80a4d284a398d3a94efc0873196113 /src/cmd/internal/objfile
parent4b209dbf0bf3e5fd4cffda1e11f11bf45ddf212d (diff)
downloadgo-b4117995e3e01a669be737c36033c2393858d555.tar.xz
cmd/pprof: use DWARF info to lookup unknown PC addresses
Test to follow in a separate CL that arranges for the runtime package to store non-Go addresses in a CPU profile. Change-Id: I33ce1d66b77340b1e62b54505fc9b1abcec108a9 Reviewed-on: https://go-review.googlesource.com/21055 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/internal/objfile')
-rw-r--r--src/cmd/internal/objfile/elf.go5
-rw-r--r--src/cmd/internal/objfile/goobj.go6
-rw-r--r--src/cmd/internal/objfile/macho.go5
-rw-r--r--src/cmd/internal/objfile/objfile.go8
-rw-r--r--src/cmd/internal/objfile/pe.go5
-rw-r--r--src/cmd/internal/objfile/plan9obj.go6
6 files changed, 35 insertions, 0 deletions
diff --git a/src/cmd/internal/objfile/elf.go b/src/cmd/internal/objfile/elf.go
index 6369f7e259..3bad034097 100644
--- a/src/cmd/internal/objfile/elf.go
+++ b/src/cmd/internal/objfile/elf.go
@@ -7,6 +7,7 @@
package objfile
import (
+ "debug/dwarf"
"debug/elf"
"fmt"
"os"
@@ -104,3 +105,7 @@ func (f *elfFile) goarch() string {
}
return ""
}
+
+func (f *elfFile) dwarf() (*dwarf.Data, error) {
+ return f.elf.DWARF()
+}
diff --git a/src/cmd/internal/objfile/goobj.go b/src/cmd/internal/objfile/goobj.go
index 46e5f4e866..5a084a94be 100644
--- a/src/cmd/internal/objfile/goobj.go
+++ b/src/cmd/internal/objfile/goobj.go
@@ -8,6 +8,8 @@ package objfile
import (
"cmd/internal/goobj"
+ "debug/dwarf"
+ "errors"
"fmt"
"os"
)
@@ -91,3 +93,7 @@ func (f *goobjFile) text() (textStart uint64, text []byte, err error) {
func (f *goobjFile) goarch() string {
return "GOARCH unimplemented for debug/goobj files"
}
+
+func (f *goobjFile) dwarf() (*dwarf.Data, error) {
+ return nil, errors.New("no DWARF data in go object file")
+}
diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go
index c98d9520c2..754674d757 100644
--- a/src/cmd/internal/objfile/macho.go
+++ b/src/cmd/internal/objfile/macho.go
@@ -7,6 +7,7 @@
package objfile
import (
+ "debug/dwarf"
"debug/macho"
"fmt"
"os"
@@ -123,3 +124,7 @@ type uint64s []uint64
func (x uint64s) Len() int { return len(x) }
func (x uint64s) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
func (x uint64s) Less(i, j int) bool { return x[i] < x[j] }
+
+func (f *machoFile) dwarf() (*dwarf.Data, error) {
+ return f.macho.DWARF()
+}
diff --git a/src/cmd/internal/objfile/objfile.go b/src/cmd/internal/objfile/objfile.go
index cf58e9c6aa..48ed9ed489 100644
--- a/src/cmd/internal/objfile/objfile.go
+++ b/src/cmd/internal/objfile/objfile.go
@@ -6,6 +6,7 @@
package objfile
import (
+ "debug/dwarf"
"debug/gosym"
"fmt"
"os"
@@ -17,6 +18,7 @@ type rawFile interface {
pcln() (textStart uint64, symtab, pclntab []byte, err error)
text() (textStart uint64, text []byte, err error)
goarch() string
+ dwarf() (*dwarf.Data, error)
}
// A File is an opened executable file.
@@ -92,3 +94,9 @@ func (f *File) Text() (uint64, []byte, error) {
func (f *File) GOARCH() string {
return f.raw.goarch()
}
+
+// DWARF returns DWARF debug data for the file, if any.
+// This is for cmd/pprof to locate cgo functions.
+func (f *File) DWARF() (*dwarf.Data, error) {
+ return f.raw.dwarf()
+}
diff --git a/src/cmd/internal/objfile/pe.go b/src/cmd/internal/objfile/pe.go
index 503d657647..1b319941ac 100644
--- a/src/cmd/internal/objfile/pe.go
+++ b/src/cmd/internal/objfile/pe.go
@@ -7,6 +7,7 @@
package objfile
import (
+ "debug/dwarf"
"debug/pe"
"fmt"
"os"
@@ -199,3 +200,7 @@ func (f *peFile) goarch() string {
}
return ""
}
+
+func (f *peFile) dwarf() (*dwarf.Data, error) {
+ return f.pe.DWARF()
+}
diff --git a/src/cmd/internal/objfile/plan9obj.go b/src/cmd/internal/objfile/plan9obj.go
index 45a6d02748..1d808f77eb 100644
--- a/src/cmd/internal/objfile/plan9obj.go
+++ b/src/cmd/internal/objfile/plan9obj.go
@@ -7,7 +7,9 @@
package objfile
import (
+ "debug/dwarf"
"debug/plan9obj"
+ "errors"
"fmt"
"os"
"sort"
@@ -144,3 +146,7 @@ func (f *plan9File) goarch() string {
}
return ""
}
+
+func (f *plan9File) dwarf() (*dwarf.Data, error) {
+ return nil, errors.New("no DWARF data in Plan 9 file")
+}