This repository has been archived by the owner on Oct 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathStandardTrace.h
61 lines (52 loc) · 1.7 KB
/
StandardTrace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Aleth: Ethereum C++ client, tools and libraries.
// Copyright 2014-2019 Aleth Authors.
// Licensed under the GNU General Public License, Version 3.
#pragma once
#include <json/json.h>
#include <libdevcore/Common.h>
#include <libevm/Instruction.h>
#include <libevm/VMFace.h>
#include <cstdint>
namespace Json
{
class Value;
}
namespace dev
{
namespace eth
{
class StandardTrace
{
public:
struct DebugOptions
{
bool disableStorage = false;
bool disableMemory = false;
bool disableStack = false;
bool fullStorage = false;
};
// Output json trace to stream, one line per op
explicit StandardTrace(std::ostream& _outStream) noexcept : m_outStream{&_outStream} {}
// Append json trace to given (array) value
explicit StandardTrace(Json::Value& _outValue) noexcept : m_outValue{&_outValue} {}
void operator()(uint64_t _steps, uint64_t _PC, Instruction _inst, bigint _newMemSize,
bigint _gasCost, bigint _gas, VMFace const* _vm, ExtVMFace const* _extVM);
void setShowMnemonics() { m_showMnemonics = true; }
void setOptions(DebugOptions _options) { m_options = _options; }
OnOpFunc onOp()
{
return [=](uint64_t _steps, uint64_t _PC, Instruction _inst, bigint _newMemSize,
bigint _gasCost, bigint _gas, VMFace const* _vm, ExtVMFace const* _extVM) {
(*this)(_steps, _PC, _inst, _newMemSize, _gasCost, _gas, _vm, _extVM);
};
}
private:
bool m_showMnemonics = false;
std::vector<Instruction> m_lastInst;
std::ostream* m_outStream = nullptr;
Json::Value* m_outValue = nullptr;
Json::FastWriter m_fastWriter;
DebugOptions m_options;
};
} // namespace eth
} // namespace dev