23#ifdef SHAMROCK_USE_CPPTRACE
24 #include <cpptrace/cpptrace.hpp>
25 #include <cpptrace/formatting.hpp>
31 static const std::vector<std::pair<std::string, std::string>> replace_rules = {
33 {
"hipsycl::sycl::vec<long, 3, hipsycl::sycl::detail::vec_storage<long, 3> >",
"i64_3"},
34 {
"hipsycl::sycl::vec<double, 3, hipsycl::sycl::detail::vec_storage<double, 3> >",
"f64_3"},
35 {
"hipsycl::sycl::",
"sycl::"},
38 {
"sycl::_V1::vec<long, 3>",
"i64_3"},
39 {
"sycl::_V1::vec<double, 3>",
"f64_3"},
40 {
"sycl::_V1::",
"sycl::"},
44#ifdef SHAMROCK_USE_CPPTRACE
45 static cpptrace::formatter
formatter = {};
54#ifdef SHAMROCK_USE_CPPTRACE
55 auto color_mode = enable_colors ? cpptrace::formatter::color_mode::always
56 : cpptrace::formatter::color_mode::none;
58 formatter = cpptrace::formatter{}
59 .transform([](cpptrace::stacktrace_frame frame) {
60 for (
const auto &[pattern, replacement] : replace_rules) {
65 .symbols(cpptrace::formatter::symbol_mode::pretty)
67 .break_before_filename()
74 ss <<
"------ Profiler stacktrace ------\n";
75 ss <<
" - Provide a basic stacktrace based on the locations of StackEntry objects\n";
76#ifndef SHAMROCK_USE_CPPTRACE
77 ss <<
" - To get the precise a more precise stacktrace, please reconfigure with :\n";
78 ss <<
" \"cmake . -DSHAMROCK_USE_CPPTRACE=on -DCMAKE_BUILD_TYPE=RelWithDebInfo\"\n";
82 ss <<
"------ End of profiler stacktrace ------\n";
84#ifdef SHAMROCK_USE_CPPTRACE
85 ss <<
"------ True stacktrace ------\n";
86 ss <<
" - Provide a true stacktrace based on the actual call stack (using cpptrace)\n";
87 ss <<
" - Please compile with -g to get line informations (cmake . "
88 "-DCMAKE_BUILD_TYPE=RelWithDebInfo)\n";
90 ss << formatter.format(cpptrace::generate_trace());
92 ss <<
"------ End of true stacktrace ------\n";
std::string fmt_callstack()
Get the formatted callstack.
void replace_all(std::string &inout, std::string_view what, std::string_view with)
replace all occurence of a search string with another
fmt::formatter< T > formatter
Formatter alias for fmt::formatter
namespace for the system handling
void init_backtrace_utilities(bool enable_colors)
Initialize the backtrace utilities.
std::string crash_report_backtrace()
Generate a backtrace for the crash report.
This file contains the definition for the stacktrace related functionality.
Utilities to generate a backtrace for the crash report.