Browse Source

State dumping in UI.

cl-refactor
Gav Wood 11 years ago
parent
commit
e45c154586
  1. 21
      alethzero/Main.ui
  2. 35
      alethzero/MainWin.cpp
  3. 2
      alethzero/MainWin.h

21
alethzero/Main.ui

@ -168,6 +168,10 @@
<addaction name="dumpTrace"/>
<addaction name="dumpTraceStorage"/>
</widget>
<addaction name="debugCurrent"/>
<addaction name="debugDumpState"/>
<addaction name="debugDumpStatePre"/>
<addaction name="separator"/>
<addaction name="debugStep"/>
<addaction name="debugStepInto"/>
<addaction name="debugStepOut"/>
@ -180,7 +184,6 @@
<addaction name="killBlockchain"/>
<addaction name="inject"/>
<addaction name="clearPending"/>
<addaction name="debugCurrent"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Network"/>
@ -1621,6 +1624,22 @@ font-size: 14pt</string>
<string>Debu&amp;g Current Transaction</string>
</property>
</action>
<action name="debugDumpState">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>D&amp;ump Current Transaction State (post)</string>
</property>
</action>
<action name="debugDumpStatePre">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>D&amp;ump Current Transaction State (pre)</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

35
alethzero/MainWin.cpp

@ -840,6 +840,8 @@ void Main::on_blocks_currentItemChanged()
{
ui->info->clear();
ui->debugCurrent->setEnabled(false);
ui->debugDumpState->setEnabled(false);
ui->debugDumpStatePre->setEnabled(false);
eth::ClientGuard g(m_client.get());
if (auto item = ui->blocks->currentItem())
{
@ -910,12 +912,11 @@ void Main::on_blocks_currentItemChanged()
eth::State before = st.fromPending(txi);
eth::State after = st.fromPending(txi + 1);
s << renderDiff(before.diff(after));
// cerr << "State dump *********************************" << endl << after << "*********************************************" << endl;
ui->debugCurrent->setEnabled(true);
ui->debugDumpState->setEnabled(true);
ui->debugDumpStatePre->setEnabled(true);
}
ui->info->appendHtml(QString::fromStdString(s.str()));
}
}
@ -943,6 +944,34 @@ void Main::on_debugCurrent_triggered()
}
}
void Main::on_debugDumpState_triggered(int _add)
{
eth::ClientGuard g(m_client.get());
if (auto item = ui->blocks->currentItem())
{
auto hba = item->data(Qt::UserRole).toByteArray();
assert(hba.size() == 32);
auto h = h256((byte const*)hba.data(), h256::ConstructFromPointer);
if (!item->data(Qt::UserRole + 1).isNull())
{
QString fn = QFileDialog::getSaveFileName(this, "Select file to output state dump");
ofstream f(fn.toStdString());
if (f.is_open())
{
eth::State st(m_client->state().db(), m_client->blockChain(), h);
unsigned txi = item->data(Qt::UserRole + 1).toInt();
f << st.fromPending(txi + _add) << endl;
}
}
}
}
void Main::on_debugDumpStatePre_triggered()
{
on_debugDumpState_triggered(0);
}
void Main::populateDebugger(eth::bytesConstRef _r)
{
bool done = m_currentExecution->setup(_r);

2
alethzero/MainWin.h

@ -131,6 +131,8 @@ private slots:
void on_debugStepBackInto_triggered();
void on_callStack_currentItemChanged();
void on_debugCurrent_triggered();
void on_debugDumpState_triggered(int _add = 1);
void on_debugDumpStatePre_triggered();
void refresh(bool _override = false);
void refreshNetwork();

Loading…
Cancel
Save