#include "cpptrace/formatting.hpp" #include "cpptrace/forward.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include "symbols/symbols.hpp" #include "demangle/demangle.hpp" using namespace std::literals; using namespace cpptrace::detail; template<> struct fmt::formatter : ostream_formatter {}; auto formatter = cpptrace::formatter{}.addresses(cpptrace::formatter::address_mode::object); struct options { bool show_help = false; std::filesystem::path path; std::vector address_strings; bool from_stdin = false; bool keepalive = false; bool timing = false; }; void resolve(const options& opts, cpptrace::frame_ptr address) { cpptrace::object_frame obj_frame{0, address, opts.path}; auto start = std::chrono::high_resolution_clock::now(); std::vector trace = cpptrace::detail::resolve_frames({obj_frame}); auto end = std::chrono::high_resolution_clock::now(); auto duration = std::chrono::duration_cast(end - start); if(trace.size() != 1) { throw std::runtime_error("Something went wrong, trace vector size didn't match"); } trace[0].symbol = cpptrace::demangle(trace[0].symbol); formatter.print(trace[0]); std::cout<> word) { resolve(opts, std::stoi(word, nullptr, 16)); } } if(opts.keepalive) { fmt::println("Done"); while(true) { std::this_thread::sleep_for(std::chrono::seconds(60)); } } } CPPTRACE_CATCH(const std::exception& e) { fmt::println(stderr, "Caught exception {}: {}", cpptrace::demangle(typeid(e).name()), e.what()); cpptrace::from_current_exception().print(); }