From 5f62e249b072ab84f2bb44f6e70213b6490d510c Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 27 Jun 2014 16:55:38 +0200 Subject: [PATCH] Fixes for state debugging. --- README.md | 2 +- alethzero/MainWin.cpp | 9 +++++---- alethzero/MainWin.h | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f370b2309..7529fed50 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ See the [Wiki](https://github.com/ethereum/cpp-ethereum/wiki) for build instruct ### Testing -To run the tests, make sure you clone the tests repository from github.com/ethereum to tests is a sibling to cpp-ethereum-build. +To run the tests, make sure you clone the tests repository from github.com/ethereum to tests as a sibling to cpp-ethereum. ### Yet To Do diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 11a32e40b..d45599cd3 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -876,13 +876,13 @@ void Main::on_blocks_currentItemChanged() Transaction t = st.pending()[txi]; auto r = t.rlp(); - m_pcWarp.clear(); - m_history.clear(); + debugFinished(); bool done = m_currentExecution->setup(&r); if (!done) { + auto startGas = m_currentExecution->vm().gas(); for (; !done; done = m_currentExecution->go(1)) - m_history.append(WorldState({m_currentExecution->vm().curPC(), m_currentExecution->vm().gas(), m_currentExecution->vm().stack(), m_currentExecution->vm().memory(), m_currentExecution->state().storage(m_currentExecution->ext().myAddress)})); + m_history.append(WorldState({m_currentExecution->vm().curPC(), m_currentExecution->vm().gas(), startGas - m_currentExecution->vm().gas(), m_currentExecution->vm().stack(), m_currentExecution->vm().memory(), m_currentExecution->state().storage(m_currentExecution->ext().myAddress)})); initDebugger(); updateDebugger(); } @@ -1221,9 +1221,10 @@ void Main::on_debug_clicked() m_pcWarp.clear(); m_history.clear(); bool ok = true; + auto gasBegin = m_currentExecution->vm().gas(); while (ok) { - m_history.append(WorldState({m_currentExecution->vm().curPC(), m_currentExecution->vm().gas(), m_currentExecution->vm().stack(), m_currentExecution->vm().memory(), m_currentExecution->state().storage(m_currentExecution->ext().myAddress)})); + m_history.append(WorldState({m_currentExecution->vm().curPC(), m_currentExecution->vm().gas(), gasBegin - m_currentExecution->vm().gas(), m_currentExecution->vm().stack(), m_currentExecution->vm().memory(), m_currentExecution->state().storage(m_currentExecution->ext().myAddress)})); ok = !m_currentExecution->go(1); } initDebugger(); diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index ff8a02aff..c372a7b5a 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -46,6 +46,7 @@ struct WorldState { eth::u256 curPC; eth::u256 gas; + eth::u256 gasUsed; eth::u256s stack; eth::bytes memory; std::map storage;