From c7e04bf4c3fc675d7a4011db93b6f8dcfb7da726 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Sun, 19 Feb 2017 22:59:06 +0100 Subject: [PATCH] core/vm: removed own concoction of a mem dumper Replaced custom implementation of memory dumper with hex.Dump which outputs exact same information as hexdump -C. --- cmd/easm/examples/string.asm | 2 ++ core/vm/logger.go | 20 ++------------------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/cmd/easm/examples/string.asm b/cmd/easm/examples/string.asm index f39ecb2457..b5d54cc3f9 100644 --- a/cmd/easm/examples/string.asm +++ b/cmd/easm/examples/string.asm @@ -1 +1,3 @@ push "hello" + push 0 + mstore diff --git a/core/vm/logger.go b/core/vm/logger.go index 3845b1073d..b301421677 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -17,10 +17,10 @@ package vm import ( + "encoding/hex" "fmt" "math/big" "os" - "unicode" "github.com/ethereum/go-ethereum/common" ) @@ -183,24 +183,8 @@ func StdErrFormat(logs []StructLog) { fmt.Fprintf(os.Stderr, "%04d: %x\n", len(log.Stack)-i-1, common.LeftPadBytes(log.Stack[i].Bytes(), 32)) } - const maxMem = 10 - addr := 0 fmt.Fprintln(os.Stderr, "MEM =", len(log.Memory)) - for i := 0; i+16 <= len(log.Memory) && addr < maxMem; i += 16 { - data := log.Memory[i : i+16] - str := fmt.Sprintf("%04d: % x ", addr*16, data) - for _, r := range data { - if r == 0 { - str += "." - } else if unicode.IsPrint(rune(r)) { - str += fmt.Sprintf("%s", string(r)) - } else { - str += "?" - } - } - addr++ - fmt.Fprintln(os.Stderr, str) - } + fmt.Fprintln(os.Stderr, hex.Dump(log.Memory)) fmt.Fprintln(os.Stderr, "STORAGE =", len(log.Storage)) for h, item := range log.Storage {