aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/logger.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-16 01:28:48 +0800
committerobscuren <geffobscura@gmail.com>2015-06-16 01:28:48 +0800
commit5daf8729be88eca87b302ebf7a46fc69cad0f6d0 (patch)
tree0053cb5b84978645b3c83895a651c512e081a183 /core/vm/logger.go
parentbac9a94ddf20dc530966cbf6cd384aaf94aedc77 (diff)
parent4673b04503742de9b1622557b44135d6a4934ad6 (diff)
downloadgo-tangerine-0.9.30.tar
go-tangerine-0.9.30.tar.gz
go-tangerine-0.9.30.tar.bz2
go-tangerine-0.9.30.tar.lz
go-tangerine-0.9.30.tar.xz
go-tangerine-0.9.30.tar.zst
go-tangerine-0.9.30.zip
Merge branch 'release/0.9.30'v0.9.30
Diffstat (limited to 'core/vm/logger.go')
-rw-r--r--core/vm/logger.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/vm/logger.go b/core/vm/logger.go
new file mode 100644
index 000000000..0e2a417ae
--- /dev/null
+++ b/core/vm/logger.go
@@ -0,0 +1,51 @@
+package vm
+
+import (
+ "fmt"
+ "os"
+ "unicode"
+
+ "github.com/ethereum/go-ethereum/common"
+)
+
+func StdErrFormat(logs []StructLog) {
+ fmt.Fprintf(os.Stderr, "VM STAT %d OPs\n", len(logs))
+ for _, log := range logs {
+ fmt.Fprintf(os.Stderr, "PC %08d: %s GAS: %v COST: %v", log.Pc, log.Op, log.Gas, log.GasCost)
+ if log.Err != nil {
+ fmt.Fprintf(os.Stderr, " ERROR: %v", log.Err)
+ }
+ fmt.Fprintf(os.Stderr, "\n")
+
+ fmt.Fprintln(os.Stderr, "STACK =", len(log.Stack))
+
+ for i := len(log.Stack) - 1; i >= 0; i-- {
+ 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, "STORAGE =", len(log.Storage))
+ for h, item := range log.Storage {
+ fmt.Fprintf(os.Stderr, "%x: %x\n", h, common.LeftPadBytes(item, 32))
+ }
+ fmt.Fprintln(os.Stderr)
+ }
+}