From ae9ed5c420dc7babc5754fbb88c7bfe893d5dcf0 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 6 May 2016 11:15:05 +0200 Subject: [PATCH 1/2] internal/debug: also rename debug_startTrace to debug_startGoTrace This was missing from the previous change. --- internal/debug/api.go | 6 +++--- internal/debug/flags.go | 4 ++-- internal/debug/trace.go | 6 +++--- internal/debug/trace_fallback.go | 4 ++-- internal/web3ext/web3ext.go | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/debug/api.go b/internal/debug/api.go index a0bff27680..96091541b5 100644 --- a/internal/debug/api.go +++ b/internal/debug/api.go @@ -51,7 +51,7 @@ type HandlerT struct { traceFile string } -// Verbosity sets the glog verbosity floor. +// Verbosity sets the glog verbosity ceiling. // The verbosity of individual packages and source files // can be raised using Vmodule. func (*HandlerT) Verbosity(level int) { @@ -134,11 +134,11 @@ func (h *HandlerT) StopCPUProfile() error { // GoTrace turns on tracing for nsec seconds and writes // trace data to file. func (h *HandlerT) GoTrace(file string, nsec uint) error { - if err := h.StartTrace(file); err != nil { + if err := h.StartGoTrace(file); err != nil { return err } time.Sleep(time.Duration(nsec) * time.Second) - h.StopTrace() + h.StopGoTrace() return nil } diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 76f32561ad..5b1a9b23c4 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -89,7 +89,7 @@ func Setup(ctx *cli.Context) error { runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name) Handler.SetBlockProfileRate(ctx.GlobalInt(blockprofilerateFlag.Name)) if traceFile := ctx.GlobalString(traceFlag.Name); traceFile != "" { - if err := Handler.StartTrace(traceFile); err != nil { + if err := Handler.StartGoTrace(traceFile); err != nil { return err } } @@ -114,5 +114,5 @@ func Setup(ctx *cli.Context) error { // respective file. func Exit() { Handler.StopCPUProfile() - Handler.StopTrace() + Handler.StopGoTrace() } diff --git a/internal/debug/trace.go b/internal/debug/trace.go index 45637977a8..c0cf921ff0 100644 --- a/internal/debug/trace.go +++ b/internal/debug/trace.go @@ -27,8 +27,8 @@ import ( "github.com/ethereum/go-ethereum/logger/glog" ) -// StartTrace turns on tracing, writing to the given file. -func (h *HandlerT) StartTrace(file string) error { +// StartGoTrace turns on tracing, writing to the given file. +func (h *HandlerT) StartGoTrace(file string) error { h.mu.Lock() defer h.mu.Unlock() if h.traceW != nil { @@ -49,7 +49,7 @@ func (h *HandlerT) StartTrace(file string) error { } // StopTrace stops an ongoing trace. -func (h *HandlerT) StopTrace() error { +func (h *HandlerT) StopGoTrace() error { h.mu.Lock() defer h.mu.Unlock() trace.Stop() diff --git a/internal/debug/trace_fallback.go b/internal/debug/trace_fallback.go index 3199459259..4118ff4087 100644 --- a/internal/debug/trace_fallback.go +++ b/internal/debug/trace_fallback.go @@ -22,10 +22,10 @@ package debug import "errors" -func (*HandlerT) StartTrace(string) error { +func (*HandlerT) StartGoTrace(string) error { return errors.New("tracing is not supported on Go < 1.5") } -func (*HandlerT) StopTrace() error { +func (*HandlerT) StopGoTrace() error { return errors.New("tracing is not supported on Go < 1.5") } diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 2a4698ee7f..64c1b5044b 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -371,13 +371,13 @@ web3._extend({ params: 2 }), new web3._extend.Method({ - name: 'startTrace', - call: 'debug_startTrace', + name: 'startGoTrace', + call: 'debug_startGoTrace', params: 1 }), new web3._extend.Method({ - name: 'stopTrace', - call: 'debug_stopTrace', + name: 'stopGoTrace', + call: 'debug_stopGoTrace', params: 0 }), new web3._extend.Method({ From 130bccc7630a6f6ec7990900bc9dc9bce410a6ad Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Fri, 6 May 2016 11:04:52 +0200 Subject: [PATCH 2/2] cmd/utils: flush trace and CPU profile data when force-qutting Also reduce log messages a little bit. --- cmd/utils/cmd.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index d331f762f6..9e2b14f567 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -73,15 +73,13 @@ func StartNode(stack *node.Node) { <-sigc glog.V(logger.Info).Infoln("Got interrupt, shutting down...") go stack.Stop() - logger.Flush() for i := 10; i > 0; i-- { <-sigc if i > 1 { - glog.V(logger.Info).Infoln("Already shutting down, please be patient.") - glog.V(logger.Info).Infoln("Interrupt", i-1, "more times to induce panic.") + glog.V(logger.Info).Infof("Already shutting down, interrupt %d more times for panic.", i-1) } } - glog.V(logger.Error).Infof("Force quitting: this might not end so well.") + debug.Exit() // ensure trace and CPU profile data is flushed. debug.LoudPanic("boom") }() }