Browse Source

Fixes for state debugging.

cl-refactor
Gav Wood 11 years ago
parent
commit
5f62e249b0
  1. 2
      README.md
  2. 9
      alethzero/MainWin.cpp
  3. 1
      alethzero/MainWin.h

2
README.md

@ -12,7 +12,7 @@ See the [Wiki](https://github.com/ethereum/cpp-ethereum/wiki) for build instruct
### Testing ### 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 ### Yet To Do

9
alethzero/MainWin.cpp

@ -876,13 +876,13 @@ void Main::on_blocks_currentItemChanged()
Transaction t = st.pending()[txi]; Transaction t = st.pending()[txi];
auto r = t.rlp(); auto r = t.rlp();
m_pcWarp.clear(); debugFinished();
m_history.clear();
bool done = m_currentExecution->setup(&r); bool done = m_currentExecution->setup(&r);
if (!done) if (!done)
{ {
auto startGas = m_currentExecution->vm().gas();
for (; !done; done = m_currentExecution->go(1)) 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(); initDebugger();
updateDebugger(); updateDebugger();
} }
@ -1221,9 +1221,10 @@ void Main::on_debug_clicked()
m_pcWarp.clear(); m_pcWarp.clear();
m_history.clear(); m_history.clear();
bool ok = true; bool ok = true;
auto gasBegin = m_currentExecution->vm().gas();
while (ok) 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); ok = !m_currentExecution->go(1);
} }
initDebugger(); initDebugger();

1
alethzero/MainWin.h

@ -46,6 +46,7 @@ struct WorldState
{ {
eth::u256 curPC; eth::u256 curPC;
eth::u256 gas; eth::u256 gas;
eth::u256 gasUsed;
eth::u256s stack; eth::u256s stack;
eth::bytes memory; eth::bytes memory;
std::map<eth::u256, eth::u256> storage; std::map<eth::u256, eth::u256> storage;

Loading…
Cancel
Save