This commit is contained in:
obscuren 2014-10-14 11:49:15 +02:00
parent 03e082d4ac
commit 294b437414
6 changed files with 26 additions and 8 deletions

@ -3,11 +3,13 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"log"
"os" "os"
"os/user" "os/user"
"path" "path"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethvm"
) )
var ( var (
@ -37,6 +39,7 @@ var (
Dump bool Dump bool
DumpHash string DumpHash string
DumpNumber int DumpNumber int
VmType int
) )
// flags specific to cli client // flags specific to cli client
@ -59,6 +62,7 @@ func Init() {
flag.PrintDefaults() flag.PrintDefaults()
} }
flag.IntVar(&VmType, "vm", 0, "Virtual Machine type: 0-1: standard, debug")
flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&Identifier, "id", "", "Custom client identifier")
flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use")
flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)")
@ -91,5 +95,9 @@ func Init() {
flag.Parse() flag.Parse()
if VmType >= int(ethvm.MaxVmTy) {
log.Fatal("Invalid VM type ", VmType)
}
InputFile = flag.Arg(0) InputFile = flag.Arg(0)
} }

@ -31,7 +31,7 @@ func main() {
LogLevel = 0 LogLevel = 0
} }
utils.InitConfig(ConfigFile, Datadir, "ETH") utils.InitConfig(VmType, ConfigFile, Datadir, "ETH")
ethutil.Config.Diff = DiffTool ethutil.Config.Diff = DiffTool
ethutil.Config.DiffType = DiffType ethutil.Config.DiffType = DiffType

@ -20,7 +20,7 @@ type DebuggerWindow struct {
engine *qml.Engine engine *qml.Engine
lib *UiLib lib *UiLib
vm *ethvm.Vm vm *ethvm.DebugVm
Db *Debugger Db *Debugger
state *ethstate.State state *ethstate.State
@ -37,7 +37,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
win := component.CreateWindow(nil) win := component.CreateWindow(nil)
w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: &ethvm.Vm{}} w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: &ethvm.DebugVm{}}
w.Db = NewDebugger(w) w.Db = NewDebugger(w)
return w return w
@ -135,8 +135,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
callerClosure := ethvm.NewClosure(&ethstate.Message{}, account, contract, script, gas, gasPrice) callerClosure := ethvm.NewClosure(&ethstate.Message{}, account, contract, script, gas, gasPrice)
env := utils.NewEnv(state, block, account.Address(), value) env := utils.NewEnv(state, block, account.Address(), value)
vm := ethvm.New(env) vm := ethvm.NewDebugVm(env)
vm.Verbose = true
vm.Dbg = self.Db vm.Dbg = self.Db
self.vm = vm self.vm = vm

@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"log"
"os" "os"
"os/user" "os/user"
"path" "path"
@ -11,6 +12,7 @@ import (
"bitbucket.org/kardianos/osext" "bitbucket.org/kardianos/osext"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethvm"
) )
var ( var (
@ -35,6 +37,7 @@ var (
ConfigFile string ConfigFile string
DebugFile string DebugFile string
LogLevel int LogLevel int
VmType int
) )
// flags specific to gui client // flags specific to gui client
@ -78,6 +81,7 @@ func Init() {
flag.PrintDefaults() flag.PrintDefaults()
} }
flag.IntVar(&VmType, "vm", 0, "Virtual Machine type: 0-1: standard, debug")
flag.StringVar(&Identifier, "id", "", "Custom client identifier") flag.StringVar(&Identifier, "id", "", "Custom client identifier")
flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use")
flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)")
@ -101,4 +105,8 @@ func Init() {
flag.StringVar(&AssetPath, "asset_path", defaultAssetPath(), "absolute path to GUI assets directory") flag.StringVar(&AssetPath, "asset_path", defaultAssetPath(), "absolute path to GUI assets directory")
flag.Parse() flag.Parse()
if VmType >= int(ethvm.MaxVmTy) {
log.Fatal("Invalid VM type ", VmType)
}
} }

@ -21,7 +21,7 @@ func run() error {
// precedence: code-internal flag default < config file < environment variables < command line // precedence: code-internal flag default < config file < environment variables < command line
Init() // parsing command line Init() // parsing command line
config := utils.InitConfig(ConfigFile, Datadir, "ETH") config := utils.InitConfig(VmType, ConfigFile, Datadir, "ETH")
utils.InitDataDir(Datadir) utils.InitDataDir(Datadir)

@ -118,9 +118,12 @@ func InitLogging(Datadir string, LogFile string, LogLevel int, DebugFile string)
return sys return sys
} }
func InitConfig(ConfigFile string, Datadir string, EnvPrefix string) *ethutil.ConfigManager { func InitConfig(vmType int, ConfigFile string, Datadir string, EnvPrefix string) *ethutil.ConfigManager {
InitDataDir(Datadir) InitDataDir(Datadir)
return ethutil.ReadConfig(ConfigFile, Datadir, EnvPrefix) cfg := ethutil.ReadConfig(ConfigFile, Datadir, EnvPrefix)
cfg.VmType = vmType
return cfg
} }
func exit(err error) { func exit(err error) {