| 15 | #include "symbol_manager.hpp" |
| 16 | |
| 17 | void af_get_last_error(char **str, dim_t *len) { |
| 18 | // Set error message from unified backend |
| 19 | std::string &global_error_string = get_global_error_string(); |
| 20 | dim_t slen = |
| 21 | std::min(MAX_ERR_SIZE, static_cast<int>(global_error_string.size())); |
| 22 | |
| 23 | // If this is true, the error is coming from the unified backend. |
| 24 | if (slen != 0) { |
| 25 | if (len && slen == 0) { |
| 26 | *len = 0; |
| 27 | *str = NULL; |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | void *in = nullptr; |
| 32 | af_alloc_host(&in, sizeof(char) * (slen + 1)); |
| 33 | memcpy(str, &in, sizeof(void *)); |
| 34 | global_error_string.copy(*str, slen); |
| 35 | |
| 36 | (*str)[slen] = '\0'; |
| 37 | global_error_string = std::string(""); |
| 38 | |
| 39 | if (len) { *len = slen; } |
| 40 | } else { |
| 41 | // If false, the error is coming from active backend. |
| 42 | typedef void (*af_func)(char **, dim_t *); |
| 43 | void *vfn = LOAD_SYMBOL(); |
| 44 | af_func func = nullptr; |
| 45 | memcpy(&func, &vfn, sizeof(void *)); |
| 46 | func(str, len); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | af_err af_set_enable_stacktrace(int is_enabled) { |
| 51 | CALL(af_set_enable_stacktrace, is_enabled); |
nothing calls this directly
no test coverage detected