Skip to content

Commit

Permalink
Debug dump improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed Oct 4, 2023
1 parent cd6bf08 commit 152c16a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions dev/TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
it make things harder to recognize without its namespace in front.
Really, don't put things in a namespace if you don't effectively want to make it part of the name.

- Debug dump improvements:
- automatically zip these files, can be 5x smaller.
- Turn C++ crashes into Lobster errors so they can be saved with a lot of context.
- For cycle objects, instead save object ids so a viewer can still find the original objects?

- auto binding generated C++ headers from a Lobster decl

- allow let inside if/guard as syntactic sugar
Expand Down
3 changes: 2 additions & 1 deletion dev/src/lobster/vmdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ struct ToFlexBufferContext {
string cycle_hit;
flexbuffers::Builder::Value cycle_hit_value;

ToFlexBufferContext(VM &vm) : vm(vm) {}
ToFlexBufferContext(VM &vm, size_t initial_size, flexbuffers::BuilderFlag flags)
: vm(vm), builder(initial_size, flags) {}
};

struct Value {
Expand Down
2 changes: 1 addition & 1 deletion dev/src/lobsterreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ nfr("flexbuffers_value_to_binary", "val,max_nesting,cycle_detection", "AI?B?", "
"turns any reference value into a flexbuffer. max_nesting defaults to 100. "
"cycle_detection is by default off (expensive)",
[](StackPtr &, VM &vm, Value &val, Value &maxnest, Value &cycle_detect) {
ToFlexBufferContext fbc(vm);
ToFlexBufferContext fbc(vm, 1024, flexbuffers::BUILDER_FLAG_SHARE_KEYS);
auto mn = maxnest.ival();
if (mn > 0) fbc.max_depth = mn;
fbc.cycle_detect = cycle_detect.True();
Expand Down
2 changes: 1 addition & 1 deletion dev/src/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void VM::DumpStackTraceMemory(const string &err) {
// We're going to be dumping as much as possible of the memory of the program along with
// the stack trace. To this end we're using the FlexBuffers dumper which already can deal with
// cycles etc, so it will output max 1 copy of each data structure.
ToFlexBufferContext fbc(*this);
ToFlexBufferContext fbc(*this, 1024 * 1024, flexbuffers::BUILDER_FLAG_SHARE_KEYS_AND_STRINGS);
fbc.cycle_detect = true;
fbc.max_depth = 64;
fbc.ignore_unsupported_types = true;
Expand Down

0 comments on commit 152c16a

Please sign in to comment.