2
0

Move exception.h to the roctracer

Only the roctracer API is using exceptions to return error codes to the
client application.

Change-Id: I92e5bd1a044dbde0c80dd9ef87e606550c3ff790


[ROCm/roctracer commit: 1e8e53da1d]
Este cometimento está contido em:
Laurent Morichetti
2022-05-23 19:51:34 -07:00
cometido por Laurent Morichetti
ascendente 1418bca17c
cometimento 23893311af
5 ficheiros modificados com 17 adições e 27 eliminações
@@ -18,8 +18,8 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
#ifndef SRC_UTIL_EXCEPTION_H_
#define SRC_UTIL_EXCEPTION_H_
#ifndef EXCEPTION_H_
#define EXCEPTION_H_
#include <sstream>
#include <stdexcept>
@@ -29,22 +29,22 @@
do { \
std::ostringstream oss; \
oss << __FUNCTION__ << "(), " << stream; \
throw roctracer::util::exception(error, oss.str()); \
throw roctracer::ApiError(error, oss.str()); \
} while (false)
namespace roctracer::util {
namespace roctracer {
template <class Status> class exception : public std::runtime_error {
class ApiError : public std::runtime_error {
public:
explicit exception(Status status, const std::string& what_arg)
explicit ApiError(roctracer_status_t status, const std::string& what_arg)
: std::runtime_error(what_arg), status_(status) {}
Status status() const noexcept { return status_; }
roctracer_status_t status() const noexcept { return status_; }
private:
const Status status_;
const roctracer_status_t status_;
};
} // namespace roctracer::util
} // namespace roctracer
#endif // SRC_UTIL_EXCEPTION_H_
#endif // EXCEPTION_H_
-2
Ver ficheiro
@@ -21,8 +21,6 @@
#ifndef MEMORY_POOL_H_
#define MEMORY_POOL_H_
#include "util/exception.h"
#include <cassert>
#include <condition_variable>
#include <cstdlib>
+2 -3
Ver ficheiro
@@ -40,7 +40,7 @@
#include "loader.h"
#include "memory_pool.h"
#include "tracker.h"
#include "util/exception.h"
#include "exception.h"
#include "util/logger.h"
#define PUBLIC_API __attribute__((visibility("default")))
@@ -181,8 +181,7 @@ struct ActivityJournalData {
static Journal<ActivityJournalData> act_journal;
roctracer_status_t GetExcStatus(const std::exception& e) {
const util::exception<roctracer_status_t>* roctracer_exc_ptr =
dynamic_cast<const util::exception<roctracer_status_t>*>(&e);
const ApiError* roctracer_exc_ptr = dynamic_cast<const ApiError*>(&e);
return (roctracer_exc_ptr) ? roctracer_exc_ptr->status() : ROCTRACER_STATUS_ERROR;
}
+1 -1
Ver ficheiro
@@ -28,7 +28,7 @@
#include <atomic>
#include "util/exception.h"
#include "exception.h"
#include "util/logger.h"
namespace roctracer {
+4 -11
Ver ficheiro
@@ -41,7 +41,6 @@
#include <roctracer_hsa.h>
#include <roctracer_hip.h>
#include "util/exception.h"
#include "util/xml.h"
#include "loader.h"
#include "trace_buffer.h"
@@ -847,16 +846,10 @@ void tool_load() {
uint32_t ctrl_len = 0;
uint32_t ctrl_rate = 0;
if (sscanf(ctrl_str, "%d:%d:%d", &ctrl_delay, &ctrl_len, &ctrl_rate) != 3) {
fprintf(stderr,
"ROCTracer: Invalid ROCP_CTRL_RATE var(%s), expected ctrl_delay:ctrl_len:ctrl_rate",
ctrl_str);
abort();
}
if (ctrl_len > ctrl_rate) {
fprintf(stderr, "ROCTracer: Control length value %u > rate value %u", ctrl_len, ctrl_rate);
abort();
}
if (sscanf(ctrl_str, "%d:%d:%d", &ctrl_delay, &ctrl_len, &ctrl_rate) != 3 ||
ctrl_len > ctrl_rate)
fatal("Invalid ROCP_CTRL_RATE variable (ctrl_delay:ctrl_len:ctrl_rate)");
control_dist_us = ctrl_rate - ctrl_len;
control_len_us = ctrl_len;
control_delay_us = ctrl_delay;