2023-08-19 12:49:23 +00:00
|
|
|
/************************************************************/ /**
|
2023-08-09 11:06:32 +00:00
|
|
|
*
|
|
|
|
* @file: debug.h
|
|
|
|
* @author: Martin Fouilleul
|
|
|
|
* @date: 13/08/2023
|
|
|
|
*
|
|
|
|
*****************************************************************/
|
|
|
|
#ifndef __DEBUG_H_
|
|
|
|
#define __DEBUG_H_
|
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
#include "platform/platform_debug.h"
|
|
|
|
#include "util/macros.h"
|
2023-08-09 11:06:32 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Logging
|
|
|
|
//----------------------------------------------------------------
|
2023-08-14 08:26:11 +00:00
|
|
|
#define oc_log_generic(level, msg, ...) oc_log_ext(level, __FUNCTION__, __FILE__, __LINE__, msg, ##__VA_ARGS__)
|
2023-08-09 11:06:32 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#define oc_log_error(msg, ...) oc_log_generic(OC_LOG_LEVEL_ERROR, msg, ##__VA_ARGS__)
|
2023-08-09 11:06:32 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#ifndef OC_LOG_COMPILE_WARNING
|
2023-08-19 12:49:23 +00:00
|
|
|
#define OC_LOG_COMPILE_WARNING 1
|
2023-08-09 11:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#ifndef OC_LOG_COMPILE_INFO
|
2023-08-19 12:49:23 +00:00
|
|
|
#define OC_LOG_COMPILE_INFO 1
|
2023-08-09 11:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#if OC_LOG_COMPILE_WARNING || OC_LOG_COMPILE_INFO
|
2023-08-19 12:49:23 +00:00
|
|
|
#define oc_log_warning(msg, ...) oc_log_generic(OC_LOG_LEVEL_WARNING, msg, ##__VA_ARGS__)
|
2023-08-09 11:06:32 +00:00
|
|
|
|
2023-08-19 12:49:23 +00:00
|
|
|
#if OC_LOG_COMPILE_INFO
|
|
|
|
#define oc_log_info(msg, ...) oc_log_generic(OC_LOG_LEVEL_INFO, msg, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define oc_log_info(msg, ...)
|
|
|
|
#endif
|
2023-08-09 11:06:32 +00:00
|
|
|
#else
|
2023-08-19 12:49:23 +00:00
|
|
|
#define oc_log_warning(msg, ...)
|
|
|
|
#define oc_log_info(msg, ...)
|
2023-08-09 11:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
// Abort/Assert
|
|
|
|
//----------------------------------------------------------------
|
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#define OC_ABORT(fmt, ...) oc_abort_ext(__FILE__, __FUNCTION__, __LINE__, fmt, ##__VA_ARGS__)
|
2023-08-09 11:06:32 +00:00
|
|
|
|
2023-08-14 08:26:11 +00:00
|
|
|
#ifdef OC_NO_ASSERT
|
2023-08-19 12:49:23 +00:00
|
|
|
#define OC_ASSERT(x, ...)
|
|
|
|
#define OC_DEBUG_ASSERT(x, ...)
|
2023-08-14 08:26:11 +00:00
|
|
|
#else
|
2023-08-19 12:49:23 +00:00
|
|
|
#define _OC_ASSERT_(test, fmt, ...) ((test) || (oc_assert_fail(__FILE__, __FUNCTION__, __LINE__, #test, fmt, ##__VA_ARGS__), 0))
|
|
|
|
#define OC_ASSERT(test, ...) _OC_ASSERT_(test, OC_VA_NOPT("", ##__VA_ARGS__) OC_ARG1(__VA_ARGS__) OC_VA_COMMA_TAIL(__VA_ARGS__))
|
|
|
|
|
|
|
|
#ifdef OC_DEBUG
|
|
|
|
#define OC_DEBUG_ASSERT(x, ...) OC_ASSERT(x, ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define OC_DEBUG_ASSERT(x, ...)
|
|
|
|
#endif
|
2023-08-09 11:06:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif //__DEBUG_H_
|