]> Cypherpunks repositories - gostls13.git/commitdiff
pprof: make it work on windows again
authorAlex Brainman <alex.brainman@gmail.com>
Sat, 18 Aug 2012 07:03:32 +0000 (17:03 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Sat, 18 Aug 2012 07:03:32 +0000 (17:03 +1000)
- 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

misc/pprof
src/cmd/go/tool.go

index 92009a1ce80d12e43a3a2a6162c3ed1bd65c5d44..2f386c3fab54cf9780c0b4dad2a6dd7061a0db1b 100755 (executable)
@@ -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) {
index cb463a2e7179e99897a1492a3b4ac599d500cdc0..01e8ff6bb8640d90d034031892235427d897cf70 100644 (file)
@@ -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:], " "))