Commit 58064a7c authored by Alex Brainman's avatar Alex Brainman

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
parent 3ba0f6da
......@@ -4599,6 +4599,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/) {
......@@ -4806,16 +4807,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) {
......
......@@ -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:], " "))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment