Skip to content

Commit

Permalink
#1667 Move prettyPrintStack to stack_out
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Strzebonski committed Feb 9, 2022
1 parent 07f5d90 commit aeae094
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 152 deletions.
94 changes: 0 additions & 94 deletions src/vt/configs/error/pretty_print_stack.cc

This file was deleted.

57 changes: 0 additions & 57 deletions src/vt/configs/error/pretty_print_stack.h

This file was deleted.

42 changes: 41 additions & 1 deletion src/vt/configs/error/stack_out.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
#include <fmt/core.h>

#include "vt/configs/error/stack_out.h"
#include "vt/configs/debug/debug_colorize.h"
#include "vt/context/context.h"

#include <cstdlib>
#include <vector>
Expand Down Expand Up @@ -117,5 +119,43 @@ DumpStackType dumpStack(int skip) {
return std::make_tuple(trace_buf.str(),tuple);
}

}}} /* end namespace vt::debug::stack */
std::string prettyPrintStack(StackVectorType const& stack) {
auto green = ::vt::debug::green();
auto bred = ::vt::debug::bred();
auto reset = ::vt::debug::reset();
auto magenta = ::vt::debug::magenta();
auto yellow = ::vt::debug::yellow();
auto vt_pre = ::vt::debug::vtPre();
auto node = ::vt::theContext()->getNode();
auto node_str = ::vt::debug::proc(node);
auto prefix = vt_pre + node_str + " ";
auto seperator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset);
auto title_node = fmt::format("on Node {}", node);
auto title = fmt::format(" Dump Stack Backtrace {} ", title_node);

std::string out = "";

out += fmt::format("{}", seperator);
out += fmt::format("{}{}{:-^120}{}\n", prefix, yellow, title, reset);
out += fmt::format("{}", seperator);

int i = 0;
for (auto&& t : stack) {
auto ret_str = fmt::format(
"{}{}{:<3}{} {}{:<3} {:<13}{} {}{}{} + {}{}\n",
prefix,
bred, i, reset,
magenta, std::get<0>(t), std::get<1>(t), reset,
green, std::get<2>(t), reset,
std::get<3>(t), reset
);
out += ret_str;
i++;
}

//out += seperator + seperator + seperator;

return out;
}

}}} /* end namespace vt::debug::stack */
2 changes: 2 additions & 0 deletions src/vt/configs/error/stack_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ using DumpStackType = std::tuple<std::string, StackVectorType>;
*/
DumpStackType dumpStack(int skip = 0);

std::string prettyPrintStack(StackVectorType const& stack);

}}} /* end namespace vt::debug::stack */

#endif /*INCLUDED_VT_CONFIGS_ERROR_STACK_OUT_H*/

0 comments on commit aeae094

Please sign in to comment.