Browse Source

- Hide mapping type from debugger.

- Better highlighting if debugger in external source.
 - Always use pendingBlock when making call and transact MixClient.
 - Compilation errors not kept in logs history.
cl-refactor
yann300 10 years ago
parent
commit
5681467247
  1. 11
      mix/ClientModel.cpp
  2. 6
      mix/DebuggingStateWrapper.h
  3. 16
      mix/MixClient.cpp
  4. 3
      mix/MixClient.h
  5. 21
      mix/qml/CodeEditorView.qml
  6. 25
      mix/qml/LogsPane.qml
  7. 1
      mix/qml/StatusPane.qml

11
mix/ClientModel.cpp

@ -350,10 +350,6 @@ void ClientModel::showDebuggerForTransaction(ExecutionResult const& _t)
CompiledContract const* contract = contracts[s.codeIndex]; CompiledContract const* contract = contracts[s.codeIndex];
AssemblyItem const& instruction = codeItems[s.codeIndex][instructionIndex]; AssemblyItem const& instruction = codeItems[s.codeIndex][instructionIndex];
std::stringstream str;
str << instruction.getLocation().sourceName;
qDebug() << QString::fromStdString(str.str());
if (instruction.type() == dev::eth::Push && !instruction.data()) if (instruction.type() == dev::eth::Push && !instruction.data())
{ {
//register new local variable initialization //register new local variable initialization
@ -380,8 +376,11 @@ void ClientModel::showDebuggerForTransaction(ExecutionResult const& _t)
for(auto l: solLocals) for(auto l: solLocals)
if (l.first < (int)s.stack.size()) if (l.first < (int)s.stack.size())
{ {
if (l.second->type()->name().startsWith("mapping"))
break; //mapping type not yet managed
localDeclarations.push_back(QVariant::fromValue(l.second)); localDeclarations.push_back(QVariant::fromValue(l.second));
localValues[l.second->name()] = formatValue(l.second->type()->type(), s.stack[l.first]); localValues[l.second->name()] = formatValue(l.second->type()->type(), s.stack[l.first]);
} }
locals["variables"] = localDeclarations; locals["variables"] = localDeclarations;
locals["values"] = localValues; locals["values"] = localValues;
@ -404,6 +403,8 @@ void ClientModel::showDebuggerForTransaction(ExecutionResult const& _t)
storageDec = new QVariableDeclaration(debugData, storageIter.value().name.toStdString(), storageIter.value().type); storageDec = new QVariableDeclaration(debugData, storageIter.value().name.toStdString(), storageIter.value().type);
storageDeclarations[storageDec->name()] = storageDec; storageDeclarations[storageDec->name()] = storageDec;
} }
if (storageDec->type()->name().startsWith("mapping"))
break; //mapping type not yet managed
storageDeclarationList.push_back(QVariant::fromValue(storageDec)); storageDeclarationList.push_back(QVariant::fromValue(storageDec));
storageValues[storageDec->name()] = formatValue(storageDec->type()->type(), st.second); storageValues[storageDec->name()] = formatValue(storageDec->type()->type(), st.second);
} }
@ -412,7 +413,7 @@ void ClientModel::showDebuggerForTransaction(ExecutionResult const& _t)
storage["values"] = storageValues; storage["values"] = storageValues;
prevInstructionIndex = instructionIndex; prevInstructionIndex = instructionIndex;
solState = new QSolState(debugData, std::move(storage), std::move(solCallStack), std::move(locals), instruction.getLocation().start, instruction.getLocation().end); solState = new QSolState(debugData, std::move(storage), std::move(solCallStack), std::move(locals), instruction.getLocation().start, instruction.getLocation().end, QString::fromUtf8(instruction.getLocation().sourceName->c_str()));
} }
states.append(QVariant::fromValue(new QMachineState(debugData, instructionIndex, s, codes[s.codeIndex], data[s.dataIndex], solState))); states.append(QVariant::fromValue(new QMachineState(debugData, instructionIndex, s, codes[s.codeIndex], data[s.dataIndex], solState)));

6
mix/DebuggingStateWrapper.h

@ -65,10 +65,11 @@ class QSolState: public QObject
Q_PROPERTY(QVariantMap locals MEMBER m_locals CONSTANT) Q_PROPERTY(QVariantMap locals MEMBER m_locals CONSTANT)
Q_PROPERTY(int start MEMBER m_start CONSTANT) Q_PROPERTY(int start MEMBER m_start CONSTANT)
Q_PROPERTY(int end MEMBER m_end CONSTANT) Q_PROPERTY(int end MEMBER m_end CONSTANT)
Q_PROPERTY(QString sourceName MEMBER m_sourceName CONSTANT)
public: public:
QSolState(QObject* _parent, QVariantMap&& _storage, QVariantList&& _callStack, QVariantMap&& _locals, int _start, int _end): QSolState(QObject* _parent, QVariantMap&& _storage, QVariantList&& _callStack, QVariantMap&& _locals, int _start, int _end, QString _sourceName):
QObject(_parent), m_storage(_storage), m_callStack(_callStack), m_locals(_locals), m_start(_start), m_end(_end) QObject(_parent), m_storage(_storage), m_callStack(_callStack), m_locals(_locals), m_start(_start), m_end(_end), m_sourceName(_sourceName)
{ } { }
private: private:
@ -77,6 +78,7 @@ private:
QVariantMap m_locals; QVariantMap m_locals;
int m_start; int m_start;
int m_end; int m_end;
QString m_sourceName;
}; };
/** /**

16
mix/MixClient.cpp

@ -235,15 +235,10 @@ ExecutionResult MixClient::execution(unsigned _index) const
return m_executions.at(_index); return m_executions.at(_index);
} }
State MixClient::asOf(BlockNumber _h) const State MixClient::asOf(h256 const& _block) const
{ {
ReadGuard l(x_state); ReadGuard l(x_state);
if (_h == PendingBlock) return State(m_stateDB, bc(), _block);
return m_startState;
else if (_h == LatestBlock)
return m_state;
else
return State(m_stateDB, bc(), bc().numberHash(_h));
} }
void MixClient::submitTransaction(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice) void MixClient::submitTransaction(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice)
@ -266,8 +261,8 @@ Address MixClient::submitTransaction(Secret _secret, u256 _endowment, bytes cons
dev::eth::ExecutionResult MixClient::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber) dev::eth::ExecutionResult MixClient::call(Secret _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber)
{ {
(void)_blockNumber;
State temp = asOf(_blockNumber); State temp = asOf(eth::PendingBlock);
u256 n = temp.transactionsFrom(toAddress(_secret)); u256 n = temp.transactionsFrom(toAddress(_secret));
Transaction t(_value, _gasPrice, _gas, _dest, _data, n, _secret); Transaction t(_value, _gasPrice, _gas, _dest, _data, n, _secret);
bytes rlp = t.rlp(); bytes rlp = t.rlp();
@ -278,11 +273,12 @@ dev::eth::ExecutionResult MixClient::call(Secret _secret, u256 _value, Address _
dev::eth::ExecutionResult MixClient::create(Secret _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber) dev::eth::ExecutionResult MixClient::create(Secret _secret, u256 _value, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber)
{ {
(void)_blockNumber;
u256 n; u256 n;
State temp; State temp;
{ {
ReadGuard lr(x_state); ReadGuard lr(x_state);
temp = asOf(_blockNumber); temp = asOf(eth::PendingBlock);
n = temp.transactionsFrom(toAddress(_secret)); n = temp.transactionsFrom(toAddress(_secret));
} }
Transaction t(_value, _gasPrice, _gas, _data, n, _secret); Transaction t(_value, _gasPrice, _gas, _data, n, _secret);

3
mix/MixClient.h

@ -88,9 +88,6 @@ protected:
private: private:
void executeTransaction(dev::eth::Transaction const& _t, eth::State& _state, bool _call); void executeTransaction(dev::eth::Transaction const& _t, eth::State& _state, bool _call);
void noteChanged(h256Set const& _filters); void noteChanged(h256Set const& _filters);
dev::eth::State asOf(eth::BlockNumber _block) const;
MixBlockChain& bc() { return *m_bc; }
MixBlockChain const& bc() const { return *m_bc; }
std::vector<KeyPair> m_userAccounts; std::vector<KeyPair> m_userAccounts;
eth::State m_state; eth::State m_state;

21
mix/qml/CodeEditorView.qml

@ -68,9 +68,28 @@ Item {
} }
function highlightExecution(documentId, location) { function highlightExecution(documentId, location) {
var editor = getEditor(documentId); var editor = getEditor(documentId);
if (editor) if (editor)
editor.highlightExecution(location); {
if (documentId !== location.sourceName)
findAndHightlight(location.start, location.end, location.sourceName)
else
editor.highlightExecution(location);
}
}
// Execution is not in the current document. Try:
// Open targeted document and hightlight (TODO) or
// Relevant hightlighting on the current document
function findAndHightlight(start, end, sourceName)
{
var editor = getEditor(currentDocumentId);
if (editor)
{
var sourceIndex = editor.getText().indexOf(sourceName);
highlightExecution(currentDocumentId, { start: sourceIndex, end: sourceIndex + sourceName.length, sourceName: currentDocumentId });
}
} }
function editingContract() { function editingContract() {

25
mix/qml/LogsPane.qml

@ -153,31 +153,6 @@ Rectangle
} }
} }
ToolButton {
id: compilationButton
checkable: true
height: LogsPaneStyle.generic.layout.headerButtonHeight
anchors.verticalCenter: parent.verticalCenter
checked: false
onCheckedChanged: {
proxyModel.toogleFilter("compilation")
}
tooltip: qsTr("Compilation")
style:
ButtonStyle {
label:
Item {
DefaultLabel {
font.family: LogsPaneStyle.generic.layout.logLabelFont
font.pointSize: Style.absoluteSize(-3)
color: "#5391d8"
anchors.centerIn: parent
text: qsTr("Compilation")
}
}
}
}
DefaultTextField DefaultTextField
{ {
id: searchBox id: searchBox

1
mix/qml/StatusPane.qml

@ -24,7 +24,6 @@ Rectangle {
var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true); var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true);
status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail; status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail;
debugImg.state = ""; debugImg.state = "";
errorMessage(status.text, "Compilation");
} }
debugRunActionIcon.enabled = codeModel.hasContract; debugRunActionIcon.enabled = codeModel.hasContract;
} }

Loading…
Cancel
Save