Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Log EVMC trace messages to vmtrace channel
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Aug 2, 2018
1 parent 86801a9 commit 0e83df0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libevm/EVMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ EVMC::EVMC(evmc_instance* _instance) : EVM(_instance)
// TODO: It might be easier to just pass instruction from VM.
char const* name = evmc->m_instructionNames[evmc->m_code[_codeOffset]];

std::cerr << "EVMC "
<< " " << evmc->m_step++ << " " << _codeOffset << " " << name << " "
<< _statusCode << " " << _gasLeft << " " << _stackNumItems;
std::ostringstream logMessage;
logMessage << "EVMC "
<< " " << evmc->m_step++ << " " << _codeOffset << " " << name << " "
<< _statusCode << " " << _gasLeft << " " << _stackNumItems;

if (_pushedStackItem)
std::cerr << " +[" << fromEvmC(*_pushedStackItem) << "]";
logMessage << " +[" << fromEvmC(*_pushedStackItem) << "]";

std::cerr << " " << _memorySize << "\n";
logMessage << " " << _memorySize;

LOG(evmc->m_vmTraceLogger) << logMessage.str();
};

_instance->set_tracer(_instance, tracer, reinterpret_cast<evmc_tracer_context*>(this));
Expand Down
2 changes: 2 additions & 0 deletions libevm/EVMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class EVMC : public EVM, public VMFace
bytesConstRef m_code;
int m_step = 0;
char const* const* m_instructionNames = nullptr;

Logger m_vmTraceLogger{createLogger(VerbosityTrace, "vmtrace")};
};
}
}

0 comments on commit 0e83df0

Please sign in to comment.