aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGav Wood <g@ethdev.com>2014-12-17 18:21:30 +0800
committerGav Wood <g@ethdev.com>2014-12-17 18:21:30 +0800
commitc83db9e6db720625242fb10afc63e6276945e6f9 (patch)
treea5ad8dca7c4f7e28134638baecd8d8819f99ea6f
parent0050a1a8f93e119ce0d3afc270783b97156a1393 (diff)
parent9e7fcbb7bd6ee28f1a35c8ef434788fbf6dc2fad (diff)
downloaddexon-solidity-c83db9e6db720625242fb10afc63e6276945e6f9.tar.gz
dexon-solidity-c83db9e6db720625242fb10afc63e6276945e6f9.tar.zst
dexon-solidity-c83db9e6db720625242fb10afc63e6276945e6f9.zip
Merge pull request #599 from wanderer/develop
changed output stacktrace format to json
-rw-r--r--vm.cpp40
-rw-r--r--vm.h2
2 files changed, 37 insertions, 5 deletions
diff --git a/vm.cpp b/vm.cpp
index 49d6ed10..010eb4d7 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -262,12 +262,44 @@ eth::OnOpFunc FakeExtVM::simpleTrace()
dev::LogOutputStream<eth::VMTraceChannel, false>(true) << o.str();
dev::LogOutputStream<eth::VMTraceChannel, false>(false) << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32" << " ]";
+ /*creates json stack trace*/
if (eth::VMTraceChannel::verbosity <= g_logVerbosity)
{
- std::ofstream f;
- f.open("./vmtrace.log", std::ofstream::app);
- f << o.str();
- f << " | " << std::dec << ext.depth << " | " << ext.myAddress << " | #" << steps << " | " << std::hex << std::setw(4) << std::setfill('0') << vm.curPC() << " : " << instructionInfo(inst).name << " | " << std::dec << vm.gas() << " | -" << std::dec << gasCost << " | " << newMemSize << "x32";
+ Object o_step;
+
+ /*add the stack*/
+ Array a_stack;
+ for (auto i: vm.stack())
+ a_stack.push_back((string)i);
+
+ o_step.push_back(Pair( "stack", a_stack ));
+
+ /*add the memory*/
+ Array a_mem;
+ for(auto i: vm.memory())
+ a_mem.push_back(i);
+
+ o_step.push_back(Pair("memory", a_mem));
+
+ /*add the storage*/
+ Object storage;
+ for (auto const& i: std::get<2>(ext.addresses.find(ext.myAddress)->second))
+ storage.push_back(Pair( (string)i.first , (string)i.second));
+
+ /*add all the other details*/
+ o_step.push_back(Pair("storage", storage));
+ o_step.push_back(Pair("depth", to_string(ext.depth)));
+ o_step.push_back(Pair("gas", (string)vm.gas()));
+ o_step.push_back(Pair("address", "0x" + toString(ext.myAddress )));
+ o_step.push_back(Pair("step", steps ));
+ o_step.push_back(Pair("pc", (int)vm.curPC()));
+ o_step.push_back(Pair("opcode", instructionInfo(inst).name ));
+
+ /*append the JSON object to the log file*/
+ Value v(o_step);
+ ofstream os( "./stackTrace.json", ofstream::app);
+ os << write_string(v, true) << ",";
+ os.close();
}
};
}
diff --git a/vm.h b/vm.h
index ff948cbf..0a5b5fb4 100644
--- a/vm.h
+++ b/vm.h
@@ -26,7 +26,7 @@ along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
#include <fstream>
#include <cstdint>
#include <boost/test/unit_test.hpp>
-#include "JsonSpiritHeaders.h"
+#include <json_spirit/json_spirit.h>
#include <libdevcore/Log.h>
#include <libdevcore/CommonIO.h>
#include <libevmcore/Instruction.h>