Skip to content

Commit

Permalink
1664 adding call trace
Browse files Browse the repository at this point in the history
  • Loading branch information
kladkogex committed Oct 15, 2023
1 parent 375f872 commit 7586a22
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions libevm/LegacyVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class LegacyVM : public VMFace {
/// RETURNDATA buffer for memory returned from direct subcalls.
bytes m_returnData;

public:
const bytes& getMReturnData() const;

private:
// space for data stack, grows towards smaller addresses from the end
u256 m_stack[1024];
u256* m_stackEnd = &m_stack[1024];
Expand Down
3 changes: 3 additions & 0 deletions libevm/LegacyVMCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,6 @@ evmc_status_code LegacyVM::getAndClearLastCallStatus() const {
return ret;

}
const bytes& LegacyVM::getMReturnData() const {
return m_returnData;
}
6 changes: 4 additions & 2 deletions libhistoric/AlethTraceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void AlethTraceBase::processFunctionCallOrReturnIfHappened(
functionCalled( _ext.caller, _ext.myAddress, _gasRemaining, data, _ext.value );
} else if ( currentDepth == m_lastOp.m_depth - 1 ) {
auto status = _vm->getAndClearLastCallStatus();
functionReturned( status );
functionReturned( status, _vm->getMReturnData() );
} else {
// we should not have skipped frames
STATE_CHECK( currentDepth == m_lastOp.m_depth )
Expand Down Expand Up @@ -228,11 +228,13 @@ void AlethTraceBase::functionCalled( const Address& _from, const Address& _to, u
}


void AlethTraceBase::functionReturned( evmc_status_code _status ) {
void AlethTraceBase::functionReturned( evmc_status_code _status, const vector< uint8_t >& _returnData ) {
STATE_CHECK( m_lastOp.m_gasRemaining >= m_lastOp.m_opGas )

uint64_t gasRemainingOnReturn = m_lastOp.m_gasRemaining - m_lastOp.m_opGas;

m_lastOp.m_returnData = _returnData;

if ( m_lastOp.m_op == Instruction::INVALID ) {
// invalid instruction consumers all gas
gasRemainingOnReturn = 0;
Expand Down

0 comments on commit 7586a22

Please sign in to comment.