Browse Source

Slider bar in debugger.

cl-refactor
Gav Wood 11 years ago
parent
commit
54f980cf80
  1. 7
      alethzero/Main.ui
  2. 60
      alethzero/MainWin.cpp
  3. 13
      alethzero/MainWin.h

7
alethzero/Main.ui

@ -901,6 +901,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QSlider" name="debugTimeline">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

60
alethzero/MainWin.cpp

@ -900,7 +900,7 @@ void Main::on_data_textChanged()
bool Main::isCreation() const bool Main::isCreation() const
{ {
return ui->destination->currentText().isEmpty()/* || !ui->destination->currentText().toInt()*/; return ui->destination->currentText().isEmpty() || ui->destination->currentText() == "(Create Contract)";
} }
u256 Main::fee() const u256 Main::fee() const
@ -1032,7 +1032,17 @@ void Main::on_send_clicked()
t.sign(s); t.sign(s);
auto r = t.rlp(); auto r = t.rlp();
m_currentExecution->setup(&r); m_currentExecution->setup(&r);
m_pcWarp.clear();
m_history.clear();
bool ok = true;
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().contractStorage(m_currentExecution->ext().myAddress)}));
ok = !m_currentExecution->go(1);
}
initDebugger(); initDebugger();
m_currentExecution.reset();
updateDebugger(); updateDebugger();
} }
else else
@ -1059,31 +1069,19 @@ void Main::on_enableDebug_triggered()
{ {
ui->debugPanel->setEnabled(ui->enableDebug->isChecked()); ui->debugPanel->setEnabled(ui->enableDebug->isChecked());
ui->send->setText(ui->enableDebug->isChecked() ? "D&ebug" : "&Execute"); ui->send->setText(ui->enableDebug->isChecked() ? "D&ebug" : "&Execute");
if (!ui->enableDebug->isChecked())
debugFinished();
} }
void Main::on_debugStep_triggered() void Main::on_debugStep_triggered()
{ {
if (!m_currentExecution) ui->debugTimeline->setValue(ui->debugTimeline->value() + 1);
return;
if (m_currentExecution->go(1))
debugFinished();
else
updateDebugger();
}
void Main::on_debugContinue_triggered()
{
if (!m_currentExecution)
return;
if (m_currentExecution->go())
debugFinished();
else
updateDebugger();
} }
void Main::debugFinished() void Main::debugFinished()
{ {
m_currentExecution.reset(); m_pcWarp.clear();
m_history.clear();
ui->debugCode->clear(); ui->debugCode->clear();
ui->debugStack->clear(); ui->debugStack->clear();
ui->debugMemory->setHtml(""); ui->debugMemory->setHtml("");
@ -1104,6 +1102,9 @@ void Main::initDebugger()
ui->debugContinue->setEnabled(true); ui->debugContinue->setEnabled(true);
ui->debugPanel->setEnabled(true); ui->debugPanel->setEnabled(true);
ui->debugCode->setEnabled(false); ui->debugCode->setEnabled(false);
ui->debugTimeline->setMinimum(0);
ui->debugTimeline->setMaximum(m_history.size() - 1);
ui->debugTimeline->setValue(0);
QListWidget* dc = ui->debugCode; QListWidget* dc = ui->debugCode;
dc->clear(); dc->clear();
@ -1128,27 +1129,30 @@ void Main::initDebugger()
} }
} }
void Main::on_debugTimeline_valueChanged()
{
updateDebugger();
}
void Main::updateDebugger() void Main::updateDebugger()
{ {
QListWidget* ds = ui->debugStack; QListWidget* ds = ui->debugStack;
ds->clear(); ds->clear();
if (m_currentExecution)
{ WorldState const& ws = m_history[ui->debugTimeline->value()];
eth::VM const& vm = m_currentExecution->vm();
for (auto i: vm.stack()) for (auto i: ws.stack)
ds->insertItem(0, QString::fromStdString(toHex(((h256)i).asArray()))); ds->insertItem(0, QString::fromStdString(toHex(((h256)i).asArray())));
ui->debugMemory->setHtml(QString::fromStdString(htmlDump(vm.memory(), 16))); ui->debugMemory->setHtml(QString::fromStdString(htmlDump(ws.memory, 16)));
ui->debugCode->setCurrentRow(m_pcWarp[(unsigned)vm.curPC()]); ui->debugCode->setCurrentRow(m_pcWarp[(unsigned)ws.curPC]);
ostringstream ss; ostringstream ss;
ss << hex << "PC: 0x" << vm.curPC() << " | GAS: 0x" << vm.gas(); ss << hex << "PC: 0x" << ws.curPC << " | GAS: 0x" << ws.gas;
ui->debugStateInfo->setText(QString::fromStdString(ss.str())); ui->debugStateInfo->setText(QString::fromStdString(ss.str()));
stringstream s; stringstream s;
auto storage = m_currentExecution->state().contractStorage(m_currentExecution->ext().myAddress); for (auto const& i: ws.storage)
for (auto const& i: storage)
s << "@" << showbase << hex << i.first << "&nbsp;&nbsp;&nbsp;&nbsp;" << showbase << hex << i.second << "<br/>"; s << "@" << showbase << hex << i.first << "&nbsp;&nbsp;&nbsp;&nbsp;" << showbase << hex << i.second << "<br/>";
ui->debugStorage->setHtml(QString::fromStdString(s.str())); ui->debugStorage->setHtml(QString::fromStdString(s.str()));
}
} }
// extra bits needed to link on VS // extra bits needed to link on VS

13
alethzero/MainWin.h

@ -249,6 +249,15 @@ private:
Q_PROPERTY(bool mining READ isMining WRITE setMining) Q_PROPERTY(bool mining READ isMining WRITE setMining)
}; };
struct WorldState
{
eth::u256 curPC;
eth::u256 gas;
eth::u256s stack;
eth::bytes memory;
std::map<eth::u256, eth::u256> storage;
};
class Main : public QMainWindow class Main : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -289,8 +298,8 @@ private slots:
void on_quit_triggered() { close(); } void on_quit_triggered() { close(); }
void on_urlEdit_editingFinished(); void on_urlEdit_editingFinished();
void on_debugStep_triggered(); void on_debugStep_triggered();
void on_debugContinue_triggered();
void on_enableDebug_triggered(); void on_enableDebug_triggered();
void on_debugTimeline_valueChanged();
void refresh(bool _override = false); void refresh(bool _override = false);
void refreshNetwork(); void refreshNetwork();
@ -338,7 +347,9 @@ private:
eth::State m_executiveState; eth::State m_executiveState;
std::unique_ptr<eth::Executive> m_currentExecution; std::unique_ptr<eth::Executive> m_currentExecution;
QMap<unsigned, unsigned> m_pcWarp; QMap<unsigned, unsigned> m_pcWarp;
QList<WorldState> m_history;
QNetworkAccessManager m_webCtrl; QNetworkAccessManager m_webCtrl;

Loading…
Cancel
Save