|
@@ -25,6 +25,7 @@ import (
|
25
|
25
|
"os"
|
26
|
26
|
"os/exec"
|
27
|
27
|
"path/filepath"
|
|
28
|
+ "runtime"
|
28
|
29
|
"strconv"
|
29
|
30
|
"strings"
|
30
|
31
|
"sync"
|
|
@@ -214,13 +215,24 @@ type profileSource struct {
|
214
|
215
|
err error
|
215
|
216
|
}
|
216
|
217
|
|
|
218
|
+func homeEnv() string {
|
|
219
|
+ switch runtime.GOOS {
|
|
220
|
+ case "windows":
|
|
221
|
+ return "USERPROFILE"
|
|
222
|
+ case "plan9":
|
|
223
|
+ return "home"
|
|
224
|
+ default:
|
|
225
|
+ return "HOME"
|
|
226
|
+ }
|
|
227
|
+}
|
|
228
|
+
|
217
|
229
|
// setTmpDir prepares the directory to use to save profiles retrieved
|
218
|
230
|
// remotely. It is selected from PPROF_TMPDIR, defaults to $HOME/pprof.
|
219
|
231
|
func setTmpDir(ui plugin.UI) (string, error) {
|
220
|
232
|
if profileDir := os.Getenv("PPROF_TMPDIR"); profileDir != "" {
|
221
|
233
|
return profileDir, nil
|
222
|
234
|
}
|
223
|
|
- for _, tmpDir := range []string{os.Getenv("HOME") + "/pprof", os.TempDir()} {
|
|
235
|
+ for _, tmpDir := range []string{os.Getenv(homeEnv()) + "/pprof", os.TempDir()} {
|
224
|
236
|
if err := os.MkdirAll(tmpDir, 0755); err != nil {
|
225
|
237
|
ui.PrintErr("Could not use temp dir ", tmpDir, ": ", err.Error())
|
226
|
238
|
continue
|
|
@@ -315,7 +327,7 @@ func locateBinaries(p *profile.Profile, s *source, obj plugin.ObjTool, ui plugin
|
315
|
327
|
searchPath := os.Getenv("PPROF_BINARY_PATH")
|
316
|
328
|
if searchPath == "" {
|
317
|
329
|
// Use $HOME/pprof/binaries as default directory for local symbolization binaries
|
318
|
|
- searchPath = filepath.Join(os.Getenv("HOME"), "pprof", "binaries")
|
|
330
|
+ searchPath = filepath.Join(os.Getenv(homeEnv()), "pprof", "binaries")
|
319
|
331
|
}
|
320
|
332
|
mapping:
|
321
|
333
|
for _, m := range p.Mapping {
|