diff options
author | dm4 <sunrisedm4@gmail.com> | 2018-04-06 18:43:36 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-04-06 18:43:36 +0800 |
commit | 3ebcf92b423e67b58a72a3fc126449e4e97bc4c8 (patch) | |
tree | 2e01dc3042fd6fbbeed7ef9c983744629acb5527 | |
parent | c43792a42cad46a15ee00417d52bd3859a98500c (diff) | |
download | dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.tar dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.tar.gz dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.tar.bz2 dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.tar.lz dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.tar.xz dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.tar.zst dexon-3ebcf92b423e67b58a72a3fc126449e4e97bc4c8.zip |
cmd/evm: print vm output when debug flag is on (#16326)
-rw-r--r-- | cmd/evm/runner.go | 5 | ||||
-rw-r--r-- | core/vm/logger.go | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 8a7399840..c13e9fb33 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -76,6 +76,7 @@ func runCmd(ctx *cli.Context) error { logconfig := &vm.LogConfig{ DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name), DisableStack: ctx.GlobalBool(DisableStackFlag.Name), + Debug: ctx.GlobalBool(DebugFlag.Name), } var ( @@ -234,9 +235,7 @@ Gas used: %d `, execTime, mem.HeapObjects, mem.Alloc, mem.TotalAlloc, mem.NumGC, initialGas-leftOverGas) } - if tracer != nil { - tracer.CaptureEnd(ret, initialGas-leftOverGas, execTime, err) - } else { + if tracer == nil { fmt.Printf("0x%x\n", ret) if err != nil { fmt.Printf(" error: %v\n", err) diff --git a/core/vm/logger.go b/core/vm/logger.go index 4c820d8b5..dde1903bf 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -45,6 +45,7 @@ type LogConfig struct { DisableMemory bool // disable memory capture DisableStack bool // disable stack capture DisableStorage bool // disable storage capture + Debug bool // print output during capture end Limit int // maximum length of output, but zero means unlimited } @@ -184,6 +185,12 @@ func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost ui func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error { l.output = output l.err = err + if l.cfg.Debug { + fmt.Printf("0x%x\n", output) + if err != nil { + fmt.Printf(" error: %v\n", err) + } + } return nil } |