vitasdk
Documentation of the vitasdk
debug.h
Go to the documentation of this file.
1 
6 // or SceDebugForKernel_stub
7 
8 #ifndef _PSP2KERN_KERNEL_DEBUG_H_
9 #define _PSP2KERN_KERNEL_DEBUG_H_
10 
12 #include <psp2kern/types.h>
13 #include <stdarg.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 
20 typedef struct SceKernelDebugInfo {
21  union {
22  struct {
26  };
27  struct { /* For backwards compatibility */
31  };
32  };
33  const char *func;
35  const char *file;
38 
40 
48 
49 typedef enum SceKernelDebugLevel {
54 
55 typedef enum SceKernelAssertLevel {
60 
61 
62 int ksceKernelDebugPutchar(int character);
63 
73 int ksceKernelPrintf(const char *fmt, ...);
74 
81 int ksceKernelPrintfLevel(SceUInt32 level, const char *fmt, ...);
82 
91 int ksceKernelPrintfLevelWithInfo(SceUInt32 level, SceUInt32 flags, const SceKernelDebugInfo *dbginfo, const char *fmt, ...);
92 
105 int ksceKernelPrintfWithInfo(SceUInt32 flags, const SceKernelDebugInfo *dbginfo, const char *fmt, ...);
106 
113 int ksceKernelVprintf(const char *fmt, va_list arg);
114 
122 int ksceKernelVprintfLevel(SceUInt32 level, const char *fmt, va_list arg);
123 
130 __attribute__((__noreturn__)) void ksceKernelPanic(const SceKernelDebugInfo *dbginfo, const void *lr);
131 
139 __attribute__((__noreturn__)) void ksceKernelPrintfPanic(const SceKernelDebugInfo *dbginfo, const void *lr, const char *fmt, ...);
140 
150 void ksceKernelAssert(SceBool condition, const SceKernelDebugInfo *dbginfo, const void *lr);
151 
162 void ksceKernelAssertLevel(SceUInt32 level, SceBool condition, const SceKernelDebugInfo *dbginfo, const void *lr);
163 
175 void ksceKernelPrintfAssertLevel(SceUInt32 level, SceBool condition, const SceKernelDebugInfo *dbginfo, const void *lr, const char *fmt, ...);
176 
177 
178 #ifndef __PSP2FILEHASH__
179 #define __PSP2FILEHASH__ (0)
180 #endif
181 
182 #ifndef __PSP2FILE__
183 #define __PSP2FILE__ __FILE__
184 #endif
185 
186 
187 #define SCE_KERNEL_PANIC() do { \
188  static const SceKernelDebugInfo __dbginfo = {.fileHash = __PSP2FILEHASH__, .lineHash = 0, .funcHash = 0, .func = __FUNCTION__, .line = __LINE__, .file = __PSP2FILE__}; \
189  ksceKernelPanic(&__dbginfo, __builtin_return_address(0)); \
190  } while(0)
191 
192 #define SCE_KERNEL_PRINTF_PANIC(__fmt__, ...) do { \
193  static const SceKernelDebugInfo __dbginfo = {.fileHash = __PSP2FILEHASH__, .lineHash = 0, .funcHash = 0, .func = __FUNCTION__, .line = __LINE__, .file = __PSP2FILE__}; \
194  ksceKernelPrintfPanic(&__dbginfo, __builtin_return_address(0), __fmt__, ##__VA_ARGS__); \
195  } while(0)
196 
197 #define SCE_KERNEL_ASSERT(__cond__) do { \
198  static const SceKernelDebugInfo __dbginfo = {.fileHash = __PSP2FILEHASH__, .lineHash = 0, .funcHash = 0, .func = __FUNCTION__, .line = __LINE__, .file = __PSP2FILE__}; \
199  ksceKernelAssert(__cond__, &__dbginfo, __builtin_return_address(0)); \
200  } while(0)
201 
202 #define SCE_KERNEL_ASSERT_LEVEL(__level__, __cond__) do { \
203  static const SceKernelDebugInfo __dbginfo = {.fileHash = __PSP2FILEHASH__, .lineHash = 0, .funcHash = 0, .func = __FUNCTION__, .line = __LINE__, .file = __PSP2FILE__}; \
204  ksceKernelAssertLevel(__level__, __cond__, &__dbginfo, __builtin_return_address(0)); \
205  } while(0)
206 
207 #define SCE_KERNEL_PRINTF_LEVEL(__level__, __fmt__, ...) do { \
208  static const SceKernelDebugInfo __dbginfo = {.fileHash = __PSP2FILEHASH__, .lineHash = 0, .funcHash = 0, .func = __FUNCTION__, .line = __LINE__, .file = __PSP2FILE__}; \
209  ksceKernelPrintfLevelWithInfo(__level__, 0xF, &__dbginfo, __fmt__, ##__VA_ARGS__); \
210  } while(0)
211 
212 
213 int ksceKernelRegisterKprintfHandler(int (* handler)(int unk, const char *format, va_list args), void *argp);
214 
215 int ksceKernelRegisterDebugPutcharHandler(int (* handler)(void *argp, char c), void *argp);
216 
218 
227 
234 
243 
244 // process
245 typedef struct SceKernelDebugEventLog1 { // size is 0x1C
249  int data_0x4C;
250  char titleid[0xC];
253 
254 // Related to network
255 typedef struct SceKernelDebugEventLog2 { // size is 0x4
256  int data_0x40;
259 
260 // Related to network
261 typedef struct SceKernelDebugEventLog3 { // size is 0x54
262  int data_0x40;
263  char ip1[0x10];
264  char ip2[0x10];
265  char ip3[0x10];
266  char ip4[0x10];
267  char ip5[0x10];
270 
271 typedef struct SceKernelDebugEventLog {
273  int data_0x04;
274  char titleid[0xC];
275  int flags;
278  int rsvd[4];
282  union {
286  };
289 
299 int ksceEventLogGetInfo(void *buf, SceSize buf_size, SceSize *read_blocks);
300 
309 int ksceKernelGetTtyInfo(char *buf, SceSize buf_size);
310 
311 
312 /* For backwards compatibility */
313 
314 #define ksceDebugPrintf ksceKernelPrintf
315 #define ksceDebugPrintf2 ksceKernelPrintfWithInfo
316 #define ksceDebugPrintKernelPanic ksceKernelPanic
317 #define ksceDebugPrintfKernelPanic ksceKernelVprintfPanic
318 #define ksceDebugPrintKernelAssertion ksceKernelAssert
319 #define ksceDebugPrintfKernelAssertion ksceKernelPrintfAssertLevel
320 #define ksceKernelGetMinimumAssertionLevel ksceKernelGetAssertLevel
321 #define ksceDebugPutchar ksceKernelDebugPutchar
322 #define ksceDebugSetHandlers ksceKernelRegisterKprintfHandler
323 #define ksceDebugRegisterPutcharHandler ksceKernelRegisterDebugPutcharHandler
324 #define ksceDebugGetPutcharHandler ksceKernelGetDebugPutcharHandler
325 #define ksceDebugDisableInfoDump ksceKernelEnableCrashDump
326 #define ksceKernelSetMinimumAssertionLevel ksceKernelSetAssertLevel
327 
328 
329 #ifdef __cplusplus
330 }
331 #endif
332 
333 #endif /* _PSP2KERN_KERNEL_DEBUG_H_ */
SceUInt32 funcHash
Definition: debug.h:25
int data_0x40
Definition: debug.h:246
int ksceKernelGetAssertLevel(void)
Get current minimum assertion level.
int ksceKernelEnableCrashDump(SceBool enable)
Set CrashDump enable.
SceKernelDebugEventLog3 type3
Definition: debug.h:285
SceUInt32 ksceKernelSetAssertLevel(SceUInt32 level)
Get current assert level.
char ip1[0x10]
Definition: debug.h:263
SceKernelAssertLevel
Definition: debug.h:55
SceSize item_size
Event data size.
Definition: debug.h:281
int data_0x40
0?
Definition: debug.h:262
SceUID ppid
Parent process id.
Definition: debug.h:276
SceUInt64 time
Time of the event occurred.
Definition: debug.h:279
VITASDK_BUILD_ASSERT_EQ(0x18, SceKernelDebugInfo)
char ip5[0x10]
Definition: debug.h:267
SceUID pid
Definition: debug.h:247
int data_0x40
0 or 0x80412118?
Definition: debug.h:256
const char * file
Definition: debug.h:35
int ksceKernelVprintf(const char *fmt, va_list arg)
Kernel Vprintf.
int rsvd[4]
Definition: debug.h:278
int ksceKernelRegisterKprintfHandler(int(*handler)(int unk, const char *format, va_list args), void *argp)
int ksceKernelGetTtyInfo(char *buf, SceSize buf_size)
Get tty log info.
SceUInt32 hex_value0_lo
Definition: debug.h:29
char ip4[0x10]
Definition: debug.h:266
char ip2[0x10]
Definition: debug.h:264
char ip3[0x10]
Definition: debug.h:265
int data_0x04
0xA, maybe titleid size
Definition: debug.h:273
int ksceKernelRegisterDebugPutcharHandler(int(*handler)(void *argp, char c), void *argp)
SceUInt32 line
Definition: debug.h:34
int ksceKernelDebugPutchar(int character)
SceUInt32 hex_value0_hi
Definition: debug.h:28
SceUInt32 lineHash
Definition: debug.h:24
int data_0x4C
0xA
Definition: debug.h:249
SceSize size
struct size(variable size)
Definition: debug.h:272
__attribute__((__noreturn__)) void ksceKernelPanic(const SceKernelDebugInfo *dbginfo
Kernel Panic.
int ksceKernelPrintfLevelWithInfo(SceUInt32 level, SceUInt32 flags, const SceKernelDebugInfo *dbginfo, const char *fmt,...)
Kernel Printf Level with Info.
SceUInt32 fileHash
Definition: debug.h:23
SceKernelDebugEventLog1 type1
Definition: debug.h:283
SceKernelDebugInfo SceKernelDebugMessageContext
Definition: debug.h:39
void ksceKernelPrintfAssertLevel(SceUInt32 level, SceBool condition, const SceKernelDebugInfo *dbginfo, const void *lr, const char *fmt,...)
Printf Assertion Level.
const char * func
Definition: debug.h:33
SceKernelDebugEventLog2 type2
Definition: debug.h:284
int budget_type
Definition: debug.h:248
const void const char void ksceKernelAssert(SceBool condition, const SceKernelDebugInfo *dbginfo, const void *lr)
Assertion.
int data_0x38
Definition: debug.h:280
SceKernelDebugInfoFlags
Definition: debug.h:41
char titleid[0xC]
Definition: debug.h:250
void * ksceKernelGetDebugPutcharHandler(void)
int flags
Event flags.
Definition: debug.h:3
SceKernelDebugLevel
Definition: debug.h:49
int flags
Event flags.
Definition: debug.h:275
int ksceKernelPrintf(const char *fmt,...)
Print log.
char titleid[0xC]
Title id of the process where the event occurred.
Definition: debug.h:274
const void * lr
Definition: debug.h:130
SceUID data_0x1C
Thread id?
Definition: debug.h:277
void ksceKernelAssertLevel(SceUInt32 level, SceBool condition, const SceKernelDebugInfo *dbginfo, const void *lr)
Printf Assertion Level.
SceUInt32 hex_value1
Definition: debug.h:30
int ksceEventLogGetInfo(void *buf, SceSize buf_size, SceSize *read_blocks)
Get event log info.
int ksceKernelVprintfLevel(SceUInt32 level, const char *fmt, va_list arg)
Kernel Vprintf Level.
int ksceKernelPrintfWithInfo(SceUInt32 flags, const SceKernelDebugInfo *dbginfo, const char *fmt,...)
Kernel Printf with Info.
int ksceKernelPrintfLevel(SceUInt32 level, const char *fmt,...)
Kernel Printf.
const void const char * fmt
Definition: debug.h:139
@ SCE_KERNEL_ASSERT_LEVEL_2
Definition: debug.h:58
@ SCE_KERNEL_ASSERT_LEVEL_1
Definition: debug.h:57
@ SCE_KERNEL_ASSERT_LEVEL_0
Definition: debug.h:56
@ SCE_KERNEL_DEBUG_INFO_FLAG_NONE
Definition: debug.h:42
@ SCE_KERNEL_DEBUG_INFO_FLAG_FUNC
Definition: debug.h:44
@ SCE_KERNEL_DEBUG_INFO_FLAG_FILE
Definition: debug.h:46
@ SCE_KERNEL_DEBUG_INFO_FLAG_LINE
Definition: debug.h:45
@ SCE_KERNEL_DEBUG_INFO_FLAG_CORE
Definition: debug.h:43
@ SCE_KERNEL_DEBUG_LEVEL_TRACE
Definition: debug.h:52
@ SCE_KERNEL_DEBUG_LEVEL_DEBUG
Definition: debug.h:51
@ SCE_KERNEL_DEBUG_LEVEL_ALWAYS
Definition: debug.h:50
Definition: debug.h:271
Definition: debug.h:245
Definition: debug.h:255
Definition: debug.h:261
Definition: debug.h:20
int SceBool
Definition: types.h:59
unsigned int SceSize
Definition: types.h:56
int SceUID
UIDs are used to describe many different kernel objects.
Definition: types.h:90
uint64_t SceUInt64
Definition: types.h:51
uint32_t SceUInt32
Definition: types.h:45