Skip to content

Commit c54046b

Browse files
authored
Merge pull request #320 from adanalis/2025.rocprof_sdk
rocprof_sdk: Propagate error when obtaining function pointers
2 parents 894f65e + 9e70fff commit c54046b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/components/rocp_sdk/sdk_class.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ get_profiling_mode(void)
175175
}
176176

177177
/* ** */
178-
static char *
178+
static const char *
179179
obtain_function_pointers()
180180
{
181181
static bool first_time = true;
@@ -197,7 +197,7 @@ obtain_function_pointers()
197197
const char *rocm_root = std::getenv("PAPI_ROCP_SDK_ROOT");
198198
if( nullptr == rocm_root || strlen(rocm_root) > PATH_MAX ){
199199
set_error_string("Did not find path for librocprofiler-sdk.so. Set either PAPI_ROCP_SDK_ROOT, or ROCP_SDK_LIB.");
200-
return NULL;
200+
return get_error_string().c_str();
201201
}
202202
path2 = std::string(rocm_root) + "/lib/librocprofiler-sdk.so";
203203

@@ -207,7 +207,7 @@ obtain_function_pointers()
207207
dllHandle = dlopen(path2.c_str(), RTLD_NOW | RTLD_GLOBAL);
208208
if (dllHandle == NULL) {
209209
set_error_string(std::string("Could not dlopen() librocprofiler-sdk.so. Set either PAPI_ROCP_SDK_ROOT, or ROCP_SDK_LIB. Error: ")+dlerror());
210-
return NULL;
210+
return dlerror();
211211
}
212212
}
213213

@@ -1010,7 +1010,6 @@ void tool_fini(void* tool_data) {
10101010

10111011
/* ** */
10121012
int setup() {
1013-
char *error_msg = NULL;
10141013
int status = 0;
10151014

10161015
// Set sampling as the default mode and allow the users to change this
@@ -1020,7 +1019,7 @@ int setup() {
10201019
rpsdk_profiling_mode = RPSDK_MODE_DISPATCH;
10211020
}
10221021

1023-
error_msg = obtain_function_pointers();
1022+
const char *error_msg = obtain_function_pointers();
10241023
if( NULL != error_msg ){
10251024
set_error_string("Could not obtain all functions from librocprofiler-sdk.so. Possible library version mismatch.");
10261025
SUBDBG("dlsym(): %s\n", error_msg);
@@ -1293,7 +1292,7 @@ rocprofiler_configure(uint32_t version,
12931292
uint32_t priority,
12941293
rocprofiler_client_id_t* id)
12951294
{
1296-
char *error_msg = papi_rocpsdk::obtain_function_pointers();
1295+
const char *error_msg = papi_rocpsdk::obtain_function_pointers();
12971296

12981297
if( NULL != error_msg ){
12991298
papi_rocpsdk::set_error_string("Could not obtain all functions from librocprofiler-sdk.so. Possible library version mismatch.");

0 commit comments

Comments
 (0)