Improve static singleton memory safety (#316)

* Update GitHub links

* Update samples/api_buffered_tracing/client.cpp

- check if initialized before forcing initialization

* Add lib/common/static_object.*

- template class for creating a static allocation in the binary which has all the properties of a heap allocated singleton but does not trigger leak sanitizers

* Update include/rocprofiler-sdk/internal_threading.h

- document return values

* Update lib/rocprofiler-sdk/internal_threading.cpp

- return codes from rocprofiler_create_callback_thread and rocprofiler_assign_callback_thread
- use common::static_object for thread-pool object

* Update lib/rocprofiler-sdk/agent.cpp

- use common::static_object to store array of strings and their hashes

* Update lib/rocprofiler-sdk/hsa/code_object.cpp

- use common::static_object to store array of strings and their hashes to ensure strings exist until termination

* Update lib/rocprofiler-sdk/registration.cpp

- use common::static_object to store status and client libraries
- update return values for rocprofiler_set_api_table

* Update lib/rocprofiler-sdk/hsa/hsa.cpp

- check registration::get_fini_status() in hsa_api_impl::functor<Idx>(args...)

* Update lib/rocprofiler-sdk/context/context.cpp

- using common::static_object for correlation id map
This commit is contained in:
Jonathan R. Madsen
2023-12-19 13:47:21 -06:00
committed by GitHub
parent 5761b5fb60
commit 6b374b8e68
14 changed files with 367 additions and 63 deletions
@@ -98,6 +98,8 @@ typedef struct
* @param [in] cb_thread_id User-provided pointer to a @ref rocprofiler_callback_thread_t
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Successful thread creation
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Thread creation is no longer available
* post-initialization
* @retval ::ROCPROFILER_STATUS_ERROR Failed to create thread
*/
rocprofiler_status_t ROCPROFILER_API
@@ -114,6 +116,8 @@ rocprofiler_create_callback_thread(rocprofiler_callback_thread_t* cb_thread_id)
* @return ::rocprofiler_status_t
* @retval ::ROCPROFILER_STATUS_SUCCESS Successful assignment of the delivery thread for the given
* buffer
* @retval ::ROCPROFILER_STATUS_ERROR_CONFIGURATION_LOCKED Thread assignment is no longer available
* post-initialization
* @retval ::ROCPROFILER_STATUS_ERROR_THREAD_NOT_FOUND Thread identifier did not match any of the
* threads created by rocprofiler
* @retval ::ROCPROFILER_STATUS_ERROR_BUFFER_NOT_FOUND Buffer identifier did not match any of the