27 #define DB_RESOURCE 10 35 extern unsigned HCC_DB;
37 #define DBPARM(x) #x << "=" << x 41 static std::vector<std::string> g_DbStr = {
"api",
"cmd",
"wait",
"aql",
"queue",
"sig",
"lock",
"kernarg",
"copy",
"copy2",
"resource",
"init",
"misc",
"aql2",
"code",
"cmd2"};
46 #define COMPILE_HCC_DB 1 48 #define DBFLAG(db_flag) (HCC_DB & (1<<(db_flag))) 50 #define DBSTREAM std::cerr 53 #define DBOUT(db_flag, msg) \ 54 if (COMPILE_HCC_DB && (HCC_DB & (1<<(db_flag)))) { \ 55 std::stringstream sstream;\ 56 sstream << " hcc-" << g_DbStr[db_flag] << " tid:" << hcc_tlsShortTid._shortTid << " " << msg ; \ 57 DBSTREAM << sstream.str();\ 61 #define DBOUTL(db_flag, msg) \ 62 if (COMPILE_HCC_DB && (HCC_DB & (1<<(db_flag)))) { \ 63 std::stringstream sstream;\ 64 sstream << " hcc-" << g_DbStr[db_flag] << " tid:" << hcc_tlsShortTid._shortTid << " " << msg << "\n"; \ 65 DBSTREAM << sstream.str();\ 69 #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/')+1 : __FILE__) 77 extern thread_local
ShortTid hcc_tlsShortTid;
82 static std::string get_backtrace() {
83 constexpr
int buffer_size = 512;
88 unw_context_t context;
89 unw_getcontext(&context);
90 unw_init_local(&cursor, &context);
92 bt += std::string(
"Backtrace:\n");
94 while(unw_step(&cursor) > 0) {
97 unw_get_reg(&cursor, UNW_REG_IP, &pc);
102 char func[buffer_size];
103 char* demangled =
nullptr;
104 const char* print_func_name;
106 if (unw_get_proc_name(&cursor, func,
sizeof(func), &offp) == 0) {
109 demangled = abi::__cxa_demangle(func,
nullptr,
nullptr, &status);
111 print_func_name = demangled ? demangled : func;
114 print_func_name =
"<unknown function>";
117 char loc[buffer_size];
118 std::snprintf(loc, buffer_size,
"0x%016lx:\t%s + 0x%lx\n", pc, print_func_name, offp);
119 bt += std::string(loc);
127 static void print_backtrace() {
128 std::string bt = get_backtrace();
129 std::printf(
"\n%s\n", bt.c_str());
Definition: hc_rt_debug.h:72
Heterogeneous C++ (HC) namespace.
Definition: grid_launch.h:10