diff --git a/projects/roctracer/src/roctx/roctx.cpp b/projects/roctracer/src/roctx/roctx.cpp index 1799b17910..b7faab91e3 100644 --- a/projects/roctracer/src/roctx/roctx.cpp +++ b/projects/roctracer/src/roctx/roctx.cpp @@ -28,6 +28,7 @@ THE SOFTWARE. #include "inc/ext/prof_protocol.h" #include "util/exception.h" #include "util/logger.h" +#include #define PUBLIC_API __attribute__((visibility("default"))) #define CONSTRUCTOR_API __attribute__((constructor)) @@ -61,6 +62,8 @@ THE SOFTWARE. (void)err; \ return X; +std::stack message_stack; + static inline uint32_t GetPid() { return syscall(__NR_getpid); } static inline uint32_t GetTid() { return syscall(__NR_gettid); } @@ -114,13 +117,30 @@ PUBLIC_API void roctxMarkA(const char* message) { PUBLIC_API int roctxRangePushA(const char* message) { API_METHOD_PREFIX - EXC_ABORT(ROCTX_STATUS_ERROR, "method is not implemented"); + //EXC_ABORT(ROCTX_STATUS_ERROR, "method is not implemented"); + roctx_api_data_t api_data{}; + api_data.args.roctxRangePushA.message = strdup(message); + activity_rtapi_callback_t api_callback_fun = NULL; + void* api_callback_arg = NULL; + roctx::cb_table.get(ROCTX_API_ID_roctxRangePushA, &api_callback_fun, &api_callback_arg); + if (api_callback_fun) api_callback_fun(ACTIVITY_DOMAIN_ROCTX, ROCTX_API_ID_roctxRangePushA, &api_data, api_callback_arg); + message_stack.push(strdup(message)); API_METHOD_SUFFIX } PUBLIC_API int roctxRangePop() { API_METHOD_PREFIX - EXC_ABORT(ROCTX_STATUS_ERROR, "method is not implemented"); + //EXC_ABORT(ROCTX_STATUS_ERROR, "method is not implemented"); + roctx_api_data_t api_data{}; + activity_rtapi_callback_t api_callback_fun = NULL; + void* api_callback_arg = NULL; + roctx::cb_table.get(ROCTX_API_ID_roctxRangePop, &api_callback_fun, &api_callback_arg); + if (api_callback_fun) api_callback_fun(ACTIVITY_DOMAIN_ROCTX, ROCTX_API_ID_roctxRangePop, &api_data, api_callback_arg); + if (message_stack.empty()) { + EXC_ABORT(ROCTX_STATUS_ERROR, "Pop from empty stack!"); + } else { + message_stack.pop(); + } API_METHOD_SUFFIX }