aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2012-09-22 05:54:39 +1000
committerAlex Brainman <alex.brainman@gmail.com>2012-09-22 05:54:39 +1000
commitbf68e33053339b3b21d02f43cbb90424ea22db17 (patch)
tree28500c218bcc997227c115f8adb813ef21d5b0ad
parent41f42120a5f9bdf45edabb64078235fc9e7bb004 (diff)
downloadgo-bf68e33053339b3b21d02f43cbb90424ea22db17.tar.gz
go-bf68e33053339b3b21d02f43cbb90424ea22db17.zip
[release-branch.go1] pprof: make it work on windows again
««« backport 7c5f4dad8fae pprof: make it work on windows again - pprof is a perl script, so go command should invoke perl instead of trying to run pprof directly; - pprof should use "go tool nm" unconditionally on windows, no one else can extract symbols from Go program; - pprof should use "go tool nm" instead of "6nm". Fixes #3879. R=golang-dev, r CC=golang-dev https://golang.org/cl/6445082 »»»
-rwxr-xr-xmisc/pprof18
-rw-r--r--src/cmd/go/tool.go12
2 files changed, 19 insertions, 11 deletions
diff --git a/misc/pprof b/misc/pprof
index 2fe56503c9..da4a35327c 100755
--- a/misc/pprof
+++ b/misc/pprof
@@ -4595,6 +4595,7 @@ sub ConfigureObjTools {
# in the same directory as pprof.
$obj_tool_map{"nm_pdb"} = "nm-pdb";
$obj_tool_map{"addr2line_pdb"} = "addr2line-pdb";
+ $obj_tool_map{"is_windows"} = "true";
}
if ($file_type =~ /Mach-O/) {
@@ -4802,16 +4803,13 @@ sub GetProcedureBoundaries {
" $image 2>/dev/null $cppfilt_flag",
"$nm -D -n $flatten_flag $demangle_flag" .
" $image 2>/dev/null $cppfilt_flag",
- # 6nm is for Go binaries
- "6nm $image 2>/dev/null | sort");
-
- # If the executable is an MS Windows PDB-format executable, we'll
- # have set up obj_tool_map("nm_pdb"). In this case, we actually
- # want to use both unix nm and windows-specific nm_pdb, since
- # PDB-format executables can apparently include dwarf .o files.
- if (exists $obj_tool_map{"nm_pdb"}) {
- my $nm_pdb = $obj_tool_map{"nm_pdb"};
- push(@nm_commands, "$nm_pdb --demangle $image 2>/dev/null");
+ # go tool nm is for Go binaries
+ "go tool nm $image 2>/dev/null | sort");
+
+ # If the executable is an MS Windows Go executable, we'll
+ # have set up obj_tool_map("is_windows").
+ if (exists $obj_tool_map{"is_windows"}) {
+ @nm_commands = ("go tool nm $image 2>/dev/null | sort");
}
foreach my $nm_command (@nm_commands) {
diff --git a/src/cmd/go/tool.go b/src/cmd/go/tool.go
index cb463a2e71..01e8ff6bb8 100644
--- a/src/cmd/go/tool.go
+++ b/src/cmd/go/tool.go
@@ -47,7 +47,7 @@ const toolWindowsExtension = ".exe"
func tool(name string) string {
p := filepath.Join(toolDir, name)
- if toolIsWindows {
+ if toolIsWindows && name != "pprof" {
p += toolWindowsExtension
}
return p
@@ -76,6 +76,16 @@ func runTool(cmd *Command, args []string) {
setExitStatus(3)
return
}
+ if toolIsWindows && toolName == "pprof" {
+ args = append([]string{"perl", toolPath}, args[1:]...)
+ var err error
+ toolPath, err = exec.LookPath("perl")
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "go tool: perl not found\n")
+ setExitStatus(3)
+ return
+ }
+ }
if toolN {
fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " "))