Skip to content

Commit

Permalink
Merge branch 'master' into disasm_demangle
Browse files Browse the repository at this point in the history
  • Loading branch information
kalyanac authored Mar 13, 2019
2 parents f77c42f + 7742615 commit c57d9b9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Tipp Moseley <tipp@google.com>
Hyoun Kyu Cho <netforce@google.com>
Martin Spier <spiermar@gmail.com>
Taco de Wolff <tacodewolff@gmail.com>
Andrew Hunter <andrewhhunter@gmail.com>
38 changes: 23 additions & 15 deletions internal/driver/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ type source struct {
DiffBase bool
Normalize bool

Seconds int
Timeout int
Symbolize string
HTTPHostport string
Comment string
Seconds int
Timeout int
Symbolize string
HTTPHostport string
HTTPDisableBrowser bool
Comment string
}

// parseFlags parses the command lines through the specified flags package
Expand Down Expand Up @@ -65,7 +66,8 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
flagMeanDelay := flag.Bool("mean_delay", false, "Display mean delay at each region")
flagTools := flag.String("tools", os.Getenv("PPROF_TOOLS"), "Path for object tool pathnames")

flagHTTP := flag.String("http", "", "Present interactive web based UI at the specified http host:port")
flagHTTP := flag.String("http", "", "Present interactive web UI at the specified http host:port")
flagNoBrowser := flag.Bool("no_browser", false, "Skip opening a browswer for the interactive web UI")

// Flags used during command processing
installedFlags := installFlags(flag)
Expand Down Expand Up @@ -118,6 +120,10 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
return nil, nil, errors.New("-http is not compatible with an output format on the command line")
}

if *flagNoBrowser && *flagHTTP == "" {
return nil, nil, errors.New("-no_browser only makes sense with -http")
}

si := pprofVariables["sample_index"].value
si = sampleIndex(flagTotalDelay, si, "delay", "-total_delay", o.UI)
si = sampleIndex(flagMeanDelay, si, "delay", "-mean_delay", o.UI)
Expand All @@ -133,14 +139,15 @@ func parseFlags(o *plugin.Options) (*source, []string, error) {
}

source := &source{
Sources: args,
ExecName: execName,
BuildID: *flagBuildID,
Seconds: *flagSeconds,
Timeout: *flagTimeout,
Symbolize: *flagSymbolize,
HTTPHostport: *flagHTTP,
Comment: *flagAddComment,
Sources: args,
ExecName: execName,
BuildID: *flagBuildID,
Seconds: *flagSeconds,
Timeout: *flagTimeout,
Symbolize: *flagSymbolize,
HTTPHostport: *flagHTTP,
HTTPDisableBrowser: *flagNoBrowser,
Comment: *flagAddComment,
}

if err := source.addBaseProfiles(*flagBase, *flagDiffBase); err != nil {
Expand Down Expand Up @@ -327,9 +334,10 @@ var usageMsgSrc = "\n\n" +

var usageMsgVars = "\n\n" +
" Misc options:\n" +
" -http Provide web based interface at host:port.\n" +
" -http Provide web interface at host:port.\n" +
" Host is optional and 'localhost' by default.\n" +
" Port is optional and a randomly available port by default.\n" +
" -no_browser Skip opening a browser for the interactive web UI.\n" +
" -tools Search path for object tools\n" +
"\n" +
" Legacy convenience options:\n" +
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func PProf(eo *plugin.Options) error {
}

if src.HTTPHostport != "" {
return serveWebInterface(src.HTTPHostport, p, o)
return serveWebInterface(src.HTTPHostport, p, o, src.HTTPDisableBrowser)
}
return interactive(p, o)
}
Expand Down
10 changes: 7 additions & 3 deletions internal/driver/webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type webArgs struct {
FlameGraph template.JS
}

func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) error {
func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, disableBrowser bool) error {
host, port, err := getHostAndPort(hostport)
if err != nil {
return err
Expand Down Expand Up @@ -117,8 +117,12 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options) e
},
}

if o.UI.WantBrowser() {
go openBrowser("http://"+args.Hostport, o)
url := "http://" + args.Hostport

o.UI.Print("Serving web UI on ", url)

if o.UI.WantBrowser() && !disableBrowser {
go openBrowser(url, o)
}
return server(args)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/webui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func TestWebInterface(t *testing.T) {
Obj: fakeObjTool{},
UI: &proftest.TestUI{},
HTTPServer: creator,
})
}, false)
<-serverCreated
defer server.Close()

Expand Down

0 comments on commit c57d9b9

Please sign in to comment.