-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tortoise: tracer to debug execution interactively (#4447)
tortoise provides EnableTracer option, if enabled it will dump to stderr all inputs and outputs from tortoise consensus using zap library. this logs will be available in cloud and can be downloaded either with grafana or logcli. if downloaded from grafana, next post processing script is useful: > jq -c '.[].line | fromjson | {"t": .t, "o": .o}' ./EXAMPLE.json note that traces are verbose and should be decreased in size, as an example i added tortoise/data/failed_nodes.json from one of the nodes. once trace is collected it can be used as a regression test, and also for interactive debugging. for interactive debugging: 1. install delve https://github.com/go-delve/delve/tree/master/Documentation/installation 2. run delve with selected trace `dlv exec ./trace -- -breakpoint -level=debug ./tortoise/data/failed_nodes.json` 3. continue will stop after every step, debug log will also print what happened during that step ``` > (dlv) continue 2023-05-30T11:42:03.864+0200 DEBUG trace using trace {"path": "./tortoise/data/failed_nodes.json", "name": ""} > [hardcoded-breakpoint] github.com/spacemeshos/go-spacemesh/tortoise.RunTrace() ./tortoise/tracer.go:101 (hits total:0) (PC: 0xdf038f) Warning: debugging optimized function 96: return err 97: } 98: if err := ev.Run(runner); err != nil { 99: return err 100: } => 101: if breakpoint != nil { 102: breakpoint() 103: } 104: } 105: } 106: ```
- Loading branch information
Showing
8 changed files
with
711 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ temp.js | |
/go-hare | ||
/cp.out | ||
/cover-all.out | ||
/trace | ||
cover.out | ||
coverage.html | ||
gcloud.json | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"runtime" | ||
|
||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
|
||
"github.com/spacemeshos/go-spacemesh/log" | ||
"github.com/spacemeshos/go-spacemesh/tortoise" | ||
) | ||
|
||
var ( | ||
level = zap.LevelFlag("level", zapcore.ErrorLevel, "set verbosity level for execution") | ||
bpoint = flag.Bool("breakpoint", false, "enable breakpoint after every step") | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
atom := zap.NewAtomicLevelAt(*level) | ||
logger := log.NewWithLevel("trace", atom) | ||
logger.With().Debug("using trace", log.String("path", flag.Arg(0))) | ||
var breakpoint func() | ||
if *bpoint { | ||
breakpoint = runtime.Breakpoint | ||
} | ||
if err := tortoise.RunTrace(flag.Arg(0), breakpoint, tortoise.WithLogger(logger)); err != nil { | ||
logger.With().Fatal("run trace failed", log.Err(err)) | ||
} | ||
} |
Oops, something went wrong.