mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Enable more verbose TVM stack dump (#669)
* Verbose stack dump * Move vm::VmLog::DumpStack and vm::VmLog::DumpStackVerbose to the next verbosity levels
This commit is contained in:
parent
506cd5ee36
commit
86623b4cea
8 changed files with 116 additions and 17 deletions
|
@ -22,6 +22,8 @@
|
|||
#include "vm/log.h"
|
||||
#include "vm/vm.h"
|
||||
#include "vm/vmstate.h"
|
||||
#include "vm/boc.h"
|
||||
#include "td/utils/misc.h"
|
||||
|
||||
namespace vm {
|
||||
|
||||
|
@ -254,6 +256,16 @@ bool Continuation::deserialize_to(Ref<Cell> cell, Ref<Continuation>& cont, int m
|
|||
return deserialize_to(cs, cont, mode & ~0x1000) && cs.empty_ext();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Continuation& cont) {
|
||||
CellBuilder cb;
|
||||
if (cont.serialize(cb)) {
|
||||
auto boc = vm::std_boc_serialize(cb.finalize());
|
||||
if (boc.is_ok()) {
|
||||
os << td::buffer_to_hex(boc.move_as_ok().as_slice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool QuitCont::serialize(CellBuilder& cb) const {
|
||||
// vmc_quit$1000 exit_code:int32 = VmCont;
|
||||
return cb.store_long_bool(8, 4) && cb.store_long_bool(exit_code, 32);
|
||||
|
@ -269,6 +281,10 @@ Ref<QuitCont> QuitCont::deserialize(CellSlice& cs, int mode) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string QuitCont::type() const {
|
||||
return "vmc_quit";
|
||||
}
|
||||
|
||||
int ExcQuitCont::jump(VmState* st) const & {
|
||||
int n = 0;
|
||||
try {
|
||||
|
@ -280,6 +296,10 @@ int ExcQuitCont::jump(VmState* st) const & {
|
|||
return ~n;
|
||||
}
|
||||
|
||||
std::string ExcQuitCont::type() const {
|
||||
return "vmc_quit_exc";
|
||||
}
|
||||
|
||||
bool ExcQuitCont::serialize(CellBuilder& cb) const {
|
||||
// vmc_quit_exc$1001 = VmCont;
|
||||
return cb.store_long_bool(9, 4);
|
||||
|
@ -302,6 +322,10 @@ int PushIntCont::jump_w(VmState* st) & {
|
|||
return st->jump(std::move(next));
|
||||
}
|
||||
|
||||
std::string PushIntCont::type() const {
|
||||
return "vmc_pushint";
|
||||
}
|
||||
|
||||
bool PushIntCont::serialize(CellBuilder& cb) const {
|
||||
// vmc_pushint$1111 value:int32 next:^VmCont = VmCont;
|
||||
return cb.store_long_bool(15, 4) && cb.store_long_bool(push_val, 32) && next->serialize_ref(cb);
|
||||
|
@ -353,6 +377,10 @@ Ref<ArgContExt> ArgContExt::deserialize(CellSlice& cs, int mode) {
|
|||
: Ref<ArgContExt>{};
|
||||
}
|
||||
|
||||
std::string ArgContExt::type() const {
|
||||
return "vmc_envelope";
|
||||
}
|
||||
|
||||
int RepeatCont::jump(VmState* st) const & {
|
||||
VM_LOG(st) << "repeat " << count << " more times (slow)\n";
|
||||
if (count <= 0) {
|
||||
|
@ -401,6 +429,10 @@ Ref<RepeatCont> RepeatCont::deserialize(CellSlice& cs, int mode) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string RepeatCont::type() const {
|
||||
return "vmc_repeat";
|
||||
}
|
||||
|
||||
int VmState::repeat(Ref<Continuation> body, Ref<Continuation> after, long long count) {
|
||||
if (count <= 0) {
|
||||
body.clear();
|
||||
|
@ -444,6 +476,10 @@ Ref<AgainCont> AgainCont::deserialize(CellSlice& cs, int mode) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string AgainCont::type() const {
|
||||
return "vmc_again";
|
||||
}
|
||||
|
||||
int VmState::again(Ref<Continuation> body) {
|
||||
return jump(Ref<AgainCont>{true, std::move(body)});
|
||||
}
|
||||
|
@ -493,6 +529,10 @@ Ref<UntilCont> UntilCont::deserialize(CellSlice& cs, int mode) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string UntilCont::type() const {
|
||||
return "vmc_until";
|
||||
}
|
||||
|
||||
int VmState::until(Ref<Continuation> body, Ref<Continuation> after) {
|
||||
if (!body->has_c0()) {
|
||||
set_c0(Ref<UntilCont>{true, body, std::move(after)});
|
||||
|
@ -575,6 +615,10 @@ Ref<WhileCont> WhileCont::deserialize(CellSlice& cs, int mode) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string WhileCont::type() const {
|
||||
return chkcond ? "vmc_while_cond" : "vmc_while_body";
|
||||
}
|
||||
|
||||
int VmState::loop_while(Ref<Continuation> cond, Ref<Continuation> body, Ref<Continuation> after) {
|
||||
if (!cond->has_c0()) {
|
||||
set_c0(Ref<WhileCont>{true, cond, std::move(body), std::move(after), true});
|
||||
|
@ -610,4 +654,8 @@ Ref<OrdCont> OrdCont::deserialize(CellSlice& cs, int mode) {
|
|||
: Ref<OrdCont>{};
|
||||
}
|
||||
|
||||
std::string OrdCont::type() const {
|
||||
return "vmc_std";
|
||||
}
|
||||
|
||||
} // namespace vm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue