vitasdk
Documentation of the vitasdk
libdbg.h
Go to the documentation of this file.
1 
6 #ifndef _PSP2_LIBDBG_H_
7 #define _PSP2_LIBDBG_H_
8 
9 #include <psp2/types.h>
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif /* __cplusplus */
14 
18 typedef enum SceDbgLogLevel {
19  SCE_DBG_LOG_LEVEL_TRACE = 0, /* An extremely verbose logging level, mostly useful for internal developers. */
20  SCE_DBG_LOG_LEVEL_DEBUG, /* A diagnostic logging level. */
21  SCE_DBG_LOG_LEVEL_INFO, /* An informational logging level. */
22  SCE_DBG_LOG_LEVEL_WARNING, /* A logging level that gives warnings of situations detrimental to proper execution. */
23  SCE_DBG_LOG_LEVEL_ERROR, /* A logging level that will report erroneous conditions in execution. */
24  SCE_DBG_NUM_LOG_LEVELS /* The number of logging levels available. */
26 
32 #ifndef SCE_DBG_COMPONENT
33 #define SCE_DBG_COMPONENT NULL
34 #endif /* SCE_DBG_COMPONENT */
35 
41 #ifndef SCE_DBG_BREAK_ON_ASSERT
42 #define SCE_DBG_BREAK_ON_ASSERT 1
43 #endif /* SCE_DBG_BREAK_ON_ASSERT */
44 
51 #ifndef SCE_DBG_BREAK_ACTION
52 #define SCE_DBG_BREAK_ACTION asm volatile ("bkpt 0x0")
53 #endif /* SCE_DBG_BREAK_ACTION */
54 
55 #ifndef NDEBUG
61 #define SCE_DBG_ASSERT(expression) \
62 do { \
63  if (!(expression)) { \
64  sceDbgAssertionHandler(__FILE__, __LINE__, 0, SCE_DBG_COMPONENT, "Assertion ("#expression") failed.\n"); \
65  if (SCE_DBG_BREAK_ON_ASSERT) \
66  SCE_DBG_BREAK_ACTION; \
67  } \
68 } while (0)
75 #define SCE_DBG_ASSERT_MSG(expression, msg, ...) \
76 do { \
77  if (!(expression)) { \
78  sceDbgAssertionHandler(__FILE__, __LINE__, 0, SCE_DBG_COMPONENT, msg, ##__VA_ARGS__); \
79  if (SCE_DBG_BREAK_ON_ASSERT) \
80  SCE_DBG_BREAK_ACTION; \
81  } \
82 } while (0)
89 #define SCE_DBG_LOG(logLevel, msg, ...) \
90 sceDbgLoggingHandler(__FILE__, __LINE__, logLevel, SCE_DBG_COMPONENT, msg, ##__VA_ARGS__)
91 
95 #define SCE_DBG_LOG_TRACE(msg, ...) SCE_DBG_LOG(SCE_DBG_LOG_LEVEL_TRACE, msg, ##__VA_ARGS__)
96 #define SCE_DBG_LOG_INFO(msg, ...) SCE_DBG_LOG(SCE_DBG_LOG_LEVEL_INFO, msg, ##__VA_ARGS__)
97 #define SCE_DBG_LOG_DEBUG(msg, ...) SCE_DBG_LOG(SCE_DBG_LOG_LEVEL_DEBUG, msg, ##__VA_ARGS__)
98 #define SCE_DBG_LOG_WARNING(msg, ...) SCE_DBG_LOG(SCE_DBG_LOG_LEVEL_WARNING, msg, ##__VA_ARGS__)
99 #define SCE_DBG_LOG_ERROR(msg, ...) SCE_DBG_LOG(SCE_DBG_LOG_LEVEL_ERROR, msg, ##__VA_ARGS__)
100 #else // Disable macros if NDEBUG is defined.
101 #define SCE_DBG_ASSERT(expression)
102 #define SCE_DBG_ASSERT_MSG(expression, msg, ...)
103 #define SCE_DBG_LOG(msg, ...)
104 
105 #define SCE_DBG_LOG_TRACE(msg, ...)
106 #define SCE_DBG_LOG_INFO(msg, ...)
107 #define SCE_DBG_LOG_DEBUG(msg, ...)
108 #define SCE_DBG_LOG_WARNING(msg, ...)
109 #define SCE_DBG_LOG_ERROR(msg, ...)
110 #endif /* NDEBUG */
111 
126 int sceDbgAssertionHandler(const char* file, int line, int unk, const char* component, const char* msg, ...);
142 int sceDbgLoggingHandler(const char* file, int line, SceDbgLogLevel logLevel, const char* component, const char* msg, ...);
143 
163 
164 #ifdef __cplusplus
165 }
166 #endif /* __cplusplus */
167 
168 #endif /* _PSP2_LIBDBG_H_ */
int sceDbgLoggingHandler(const char *file, int line, SceDbgLogLevel logLevel, const char *component, const char *msg,...)
Handler for logging in this library.
int sceDbgAssertionHandler(const char *file, int line, int unk, const char *component, const char *msg,...)
Handler for assertion logging in this library.
void sceDbgSetBreakOnWarningState(SceBool breakOnWarning)
Set whether or not to enter a breakpoint upon logging a warning.
void sceDbgSetMinimumLogLevel(SceDbgLogLevel level)
Set the minimum logging level.
void sceDbgSetBreakOnErrorState(SceBool breakOnError)
Set whether or not to enter a breakpoint upon logging an error.
SceDbgLogLevel
Logging level for sceDbgLoggingHandler.
Definition: libdbg.h:18
@ SCE_DBG_LOG_LEVEL_DEBUG
Definition: libdbg.h:20
@ SCE_DBG_LOG_LEVEL_TRACE
Definition: libdbg.h:19
@ SCE_DBG_NUM_LOG_LEVELS
Definition: libdbg.h:24
@ SCE_DBG_LOG_LEVEL_WARNING
Definition: libdbg.h:22
@ SCE_DBG_LOG_LEVEL_ERROR
Definition: libdbg.h:23
@ SCE_DBG_LOG_LEVEL_INFO
Definition: libdbg.h:21
int SceBool
Definition: types.h:59