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.
This commit is contained in:
Jeffrey Wilcke 2017-02-19 22:59:06 +01:00
parent 4e5ae46e74
commit c7e04bf4c3
No known key found for this signature in database
GPG key ID: 63FF149CD6945F9E
2 changed files with 4 additions and 18 deletions

View file

@ -1 +1,3 @@
push "hello"
push 0
mstore

View file

@ -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 {