Browse Source

Slider bar in debugger.

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

7
alethzero/Main.ui

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

72
alethzero/MainWin.cpp

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

13
alethzero/MainWin.h

@ -249,6 +249,15 @@ private:
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
{
Q_OBJECT
@ -289,8 +298,8 @@ private slots:
void on_quit_triggered() { close(); }
void on_urlEdit_editingFinished();
void on_debugStep_triggered();
void on_debugContinue_triggered();
void on_enableDebug_triggered();
void on_debugTimeline_valueChanged();
void refresh(bool _override = false);
void refreshNetwork();
@ -338,7 +347,9 @@ private:
eth::State m_executiveState;
std::unique_ptr<eth::Executive> m_currentExecution;
QMap<unsigned, unsigned> m_pcWarp;
QList<WorldState> m_history;
QNetworkAccessManager m_webCtrl;

Loading…
Cancel
Save