Browse Source

Initial debugger work.

cl-refactor
Gav Wood 11 years ago
parent
commit
53e4a2140a
  1. 244
      alethzero/Main.ui
  2. 55
      alethzero/MainWin.cpp
  3. 8
      alethzero/MainWin.h
  4. 6
      libethereum/State.cpp
  5. 11
      libethereum/State.h

244
alethzero/Main.ui

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1504</width>
<height>798</height>
<width>1711</width>
<height>1138</height>
</rect>
</property>
<property name="windowTitle">
@ -91,7 +91,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1504</width>
<width>1711</width>
<height>20</height>
</rect>
</property>
@ -123,9 +123,18 @@
</property>
<addaction name="about"/>
</widget>
<widget class="QMenu" name="menu_Debug">
<property name="title">
<string>&amp;Debug</string>
</property>
<addaction name="enableDebug"/>
<addaction name="actionStep"/>
<addaction name="actionContinue"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Network"/>
<addaction name="menu_Tools"/>
<addaction name="menu_Debug"/>
<addaction name="menu_Help"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
@ -395,7 +404,7 @@
</property>
<property name="minimumSize">
<size>
<width>442</width>
<width>510</width>
<height>360</height>
</size>
</property>
@ -429,29 +438,26 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label5_2">
<property name="text">
<string>&amp;Amount</string>
</property>
<property name="buddy">
<cstring>value</cstring>
<item row="5" column="0" colspan="4">
<widget class="QSplitter" name="splitter_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QPlainTextEdit" name="data"/>
<widget class="QTextEdit" name="code">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</widget>
</item>
<item row="3" column="3">
<widget class="QComboBox" name="gasPriceUnits"/>
</item>
<item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="value">
<property name="suffix">
<string/>
</property>
<property name="maximum">
<number>430000000</number>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Gas</string>
</property>
<property name="value">
<number>0</number>
<property name="buddy">
<cstring>gas</cstring>
</property>
</widget>
</item>
@ -471,32 +477,6 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<widget class="QSplitter" name="splitter_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QPlainTextEdit" name="data"/>
<widget class="QTextEdit" name="code">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="gasPrice">
<property name="prefix">
<string>@ </string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>430000000</number>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="gas">
<property name="suffix">
@ -513,21 +493,11 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QComboBox" name="valueUnits"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>&amp;Gas</string>
</property>
<property name="buddy">
<cstring>gas</cstring>
</property>
</widget>
<item row="3" column="3">
<widget class="QComboBox" name="gasPriceUnits"/>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLabel" name="fee">
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="total">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -537,28 +507,34 @@
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QPushButton" name="send">
<property name="text">
<string>&amp;Send</string>
<item row="2" column="3">
<widget class="QComboBox" name="valueUnits"/>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="gasPrice">
<property name="prefix">
<string>@ </string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>430000000</number>
</property>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QLabel" name="total">
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="destination">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
<property name="placeholderText">
<string>(Create Contract)</string>
</property>
</widget>
</item>
@ -575,16 +551,49 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="destination">
<item row="6" column="3">
<widget class="QPushButton" name="send">
<property name="text">
<string>&amp;Execute</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QSpinBox" name="value">
<property name="suffix">
<string/>
</property>
<property name="maximum">
<number>430000000</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label5_2">
<property name="text">
<string>&amp;Amount</string>
</property>
<property name="buddy">
<cstring>value</cstring>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLabel" name="fee">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>(Create Contract)</string>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -812,6 +821,53 @@
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="dockWidget_9">
<property name="features">
<set>QDockWidget::DockWidgetFeatureMask</set>
</property>
<property name="windowTitle">
<string>Debugger</string>
</property>
<attribute name="dockWidgetArea">
<number>8</number>
</attribute>
<widget class="QWidget" name="debugPanel">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QSplitter" name="splitter_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="debugCode"/>
<widget class="QListWidget" name="debugStack"/>
<widget class="QSplitter" name="splitter_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QPlainTextEdit" name="debugMemory"/>
<widget class="QPlainTextEdit" name="debugStorage"/>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="debugStateInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<action name="quit">
<property name="text">
<string>&amp;Quit</string>
@ -867,6 +923,30 @@
<string>&amp;Preview</string>
</property>
</action>
<action name="enableDebug">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Debug EVM Execution</string>
</property>
</action>
<action name="actionStep">
<property name="text">
<string>&amp;Single Step</string>
</property>
<property name="shortcut">
<string>F10</string>
</property>
</action>
<action name="actionContinue">
<property name="text">
<string>&amp;Continue</string>
</property>
<property name="shortcut">
<string>F5</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

55
alethzero/MainWin.cpp

@ -939,9 +939,17 @@ void Main::on_send_clicked()
m_client->unlock();
Secret s = i.secret();
if (isCreation())
m_client->transact(s, value(), m_data, m_init, ui->gas->value(), gasPrice());
if (ui->enableDebug->checked())
{
}
else
m_client->transact(s, value(), m_data, m_init, ui->gas->value(), gasPrice());
else
m_client->transact(s, value(), fromString(ui->destination->text()), m_data, ui->gas->value(), gasPrice());
if (ui->enableDebug->checked())
{
}
else
m_client->transact(s, value(), fromString(ui->destination->text()), m_data, ui->gas->value(), gasPrice());
refresh();
return;
}
@ -955,6 +963,49 @@ void Main::on_create_triggered()
m_keysChanged = true;
}
class ExecutionContext
{
public:
bool go(unsigned _steps = (unsigned)-1);
};
bool ExecutionContext::go(unsigned _steps)
{
}
void Main::on_enableDebug_triggered()
{
ui->debugPanel->setEnabled(ui->enableDebug->checked());
ui->debugStep->setEnabled(ui->enableDebug->checked());
ui->debugContinue->setEnabled(ui->enableDebug->checked());
ui->send->setText(ui->enableDebug->checked() ? "D&ebug" : "&Execute");
}
void Main::on_step_triggered()
{
if (!m_currentExecution)
return;
if (m_currentExecution->go(1))
finished();
else
updateExecution();
}
void Main::on_continue_triggered()
{
if (!m_currentExecution)
return;
if (m_currentExecution->go())
finished();
else
updateExecution();
}
void Main::updateExecution()
{
}
// extra bits needed to link on VS
#ifdef _MSC_VER

8
alethzero/MainWin.h

@ -191,6 +191,8 @@ private:
Q_PROPERTY(QEthereum* ethereum READ ethereum WRITE setEthereum NOTIFY ethChanged)
};
class ExecutionContext;
class QEthereum: public QObject
{
Q_OBJECT
@ -287,6 +289,9 @@ private slots:
void on_preview_triggered() { refresh(true); }
void on_quit_triggered() { close(); }
void on_urlEdit_editingFinished();
void on_debugStep_triggered();
void on_debugContinue_triggered();
void on_enableDebug_triggered();
void refresh(bool _override = false);
void refreshNetwork();
@ -297,6 +302,7 @@ signals:
private:
QString pretty(eth::Address _a) const;
void updateExecution();
QString render(eth::Address _a) const;
eth::Address fromString(QString const& _a) const;
@ -329,6 +335,8 @@ private:
unsigned m_backupGas;
std::shared_ptr<ExecutionContext> m_currentExecution;
QNetworkAccessManager m_webCtrl;
QEthereum* m_ethereum;

6
libethereum/State.cpp

@ -601,6 +601,10 @@ bytes const& State::contractCode(Address _contract) const
return m_cache[_contract].code();
}
void State::prepExecution(bytesConstRef _rlp)
{
}
void State::execute(bytesConstRef _rlp)
{
// Entry point for a user-executed transaction.
@ -616,7 +620,7 @@ void State::execute(bytesConstRef _rlp)
throw InvalidNonce(nonceReq, t.nonce);
}
// Don't like transactions whose gas price is too low. NOTE: this won't stay here forever - it's just until we get a proper gas proce discovery protocol going.
// Don't like transactions whose gas price is too low. NOTE: this won't stay here forever - it's just until we get a proper gas price discovery protocol going.
if (t.gasPrice < 10 * szabo)
{
clog(StateChat) << "Offered gas-price is too low.";

11
libethereum/State.h

@ -52,6 +52,15 @@ struct StateChat: public LogChannel { static const char* name() { return "=S=";
class ExtVM;
class ExecutionState
{
public:
ExecutionState(State& _s): m_s(_s) {}
private:
State& m_s;
};
/**
* @brief Model of the current state of the ledger.
* Maintains current ledger (m_current) as a fast hash-map. This is hashed only when required (i.e. to create or verify a block).
@ -125,6 +134,8 @@ public:
void execute(bytes const& _rlp) { return execute(&_rlp); }
void execute(bytesConstRef _rlp);
void prepExecution(bytesConstRef _rlp);
/// Check if the address is a valid normal (non-contract) account address.
bool isNormalAddress(Address _address) const;

Loading…
Cancel
Save