Skip to content

Commit 3ebcf92

Browse files
dm4fjl
authored andcommitted
cmd/evm: print vm output when debug flag is on (#16326)
1 parent c43792a commit 3ebcf92

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cmd/evm/runner.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func runCmd(ctx *cli.Context) error {
7676
logconfig := &vm.LogConfig{
7777
DisableMemory: ctx.GlobalBool(DisableMemoryFlag.Name),
7878
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
79+
Debug: ctx.GlobalBool(DebugFlag.Name),
7980
}
8081

8182
var (
@@ -234,9 +235,7 @@ Gas used: %d
234235
235236
`, execTime, mem.HeapObjects, mem.Alloc, mem.TotalAlloc, mem.NumGC, initialGas-leftOverGas)
236237
}
237-
if tracer != nil {
238-
tracer.CaptureEnd(ret, initialGas-leftOverGas, execTime, err)
239-
} else {
238+
if tracer == nil {
240239
fmt.Printf("0x%x\n", ret)
241240
if err != nil {
242241
fmt.Printf(" error: %v\n", err)

core/vm/logger.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type LogConfig struct {
4545
DisableMemory bool // disable memory capture
4646
DisableStack bool // disable stack capture
4747
DisableStorage bool // disable storage capture
48+
Debug bool // print output during capture end
4849
Limit int // maximum length of output, but zero means unlimited
4950
}
5051

@@ -184,6 +185,12 @@ func (l *StructLogger) CaptureFault(env *EVM, pc uint64, op OpCode, gas, cost ui
184185
func (l *StructLogger) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) error {
185186
l.output = output
186187
l.err = err
188+
if l.cfg.Debug {
189+
fmt.Printf("0x%x\n", output)
190+
if err != nil {
191+
fmt.Printf(" error: %v\n", err)
192+
}
193+
}
187194
return nil
188195
}
189196

0 commit comments

Comments
 (0)