diff --git a/furdb/src/command.cpp b/furdb/src/command.cpp index 56b5c60..88f997e 100644 --- a/furdb/src/command.cpp +++ b/furdb/src/command.cpp @@ -172,8 +172,9 @@ void info_command::execute(context& ctx, const command_info& info) { if (info.args.empty()) { std::cout << "Possible arguments:\n"; std::cout << "- variables\n"; + std::cout << "- stack\n"; } else if (info.args[0] == "variables") { - if (ctx.executor->frames().empty()) { + if (ctx.executor->done()) { std::cerr << "Not running\n"; return; } @@ -185,6 +186,18 @@ void info_command::execute(context& ctx, const command_info& info) { print_thing(frame.variables[i]); std::cout << '\n'; } + } else if (info.args[0] == "stack") { + if (ctx.executor->done()) { + std::cerr << "Not running\n"; + return; + } + std::cout << "Stack from top to bottom:\n"; + const auto& frame = ctx.executor->top_frame(); + for (std::size_t begin = frame.stackBase, i = ctx.executor->stack().size(); i > begin;) { + std::cout << "- "; + print_thing(ctx.executor->stack()[--i]); + std::cout << '\n'; + } } else { std::cerr << "Unexpected argument \"" << info.args[0] << "\"\n"; }