@@ -290,6 +290,165 @@ typedef enum {
290290 IoPoolType_PcieA2 = 0 , ///< Physical address range 0x12000000-0x1FFFFFFF
291291} IoPoolType ;
292292
293+ /// DebugEvent types
294+ typedef enum {
295+ DebugEventType_CreateProcess = 0 ,
296+ DebugEventType_CreateThread = 1 ,
297+ DebugEventType_ExitProcess = 2 ,
298+ DebugEventType_ExitThread = 3 ,
299+ DebugEventType_Exception = 4 ,
300+ } DebugEventType ;
301+
302+ /// Process exit reasons
303+ typedef enum {
304+ ProcessExitReason_ExitProcess = 0 ,
305+ ProcessExitReason_TerminateProcess = 1 ,
306+ ProcessExitReason_Exception = 2 ,
307+ } ProcessExitReason ;
308+
309+ /// Thread exit reasons
310+ typedef enum {
311+ ThreadExitReason_ExitThread = 0 ,
312+ ThreadExitReason_TerminateThread = 1 ,
313+ ThreadExitReason_ExitProcess = 2 ,
314+ ThreadExitReason_TerminateProcess = 3 ,
315+ } ThreadExitReason ;
316+
317+ /// Debug exception types
318+ typedef enum {
319+ DebugException_UndefinedInstruction = 0 ,
320+ DebugException_InstructionAbort = 1 ,
321+ DebugException_DataAbort = 2 ,
322+ DebugException_AlignmentFault = 3 ,
323+ DebugException_DebuggerAttached = 4 ,
324+ DebugException_BreakPoint = 5 ,
325+ DebugException_UserBreak = 6 ,
326+ DebugException_DebuggerBreak = 7 ,
327+ DebugException_UndefinedSystemCall = 8 ,
328+ DebugException_MemorySystemError = 9 , ///< [2.0.0+]
329+ } DebugException ;
330+
331+ /// Break point types
332+ typedef enum {
333+ BreakPointType_HardwareInstruction = 0 ,
334+ BreakPointType_HardwareData = 1 ,
335+ } BreakPointType ;
336+
337+ /// DebugEvent flags
338+ typedef enum {
339+ DebugEventFlag_Stopped = BIT (0 ),
340+ } DebugEventFlag ;
341+
342+ /// Address space types for CreateProcessFlags
343+ typedef enum {
344+ CreateProcessFlagAddressSpace_32bit = 0 ,
345+ CreateProcessFlagAddressSpace_64bitDeprecated = 1 , ///< 36-bit width
346+ CreateProcessFlagAddressSpace_32bitWithoutAlias = 2 ,
347+ CreateProcessFlagAddressSpace_64bit = 3 , ///< [2.0.0+] 39-bit width
348+ } CreateProcessFlagAddressSpace ;
349+
350+ /// Memory regions
351+ typedef enum {
352+ MemoryRegion_Default = 0 , ///< [1.0.0-4.1.0]
353+ MemoryRegion_Secure = 1 , ///< [2.0.0-4.1.0]
354+ } MemoryRegion ;
355+
356+ /// Flags for svcCreateProcess and CreateProcess event
357+ typedef struct {
358+ u32 is_64bit : 1 ;
359+ u32 address_space : 3 ; ///< \ref CreateProcessFlagAddressSpace
360+ u32 enable_debug : 1 ; ///< [2.0.0+]
361+ u32 enable_aslr : 1 ;
362+ u32 is_application : 1 ;
363+ u32 pool_partition : 4 ; ///< [4.0.0-4.1.0] \ref MemoryRegion, [5.0.0+] \ref PhysicalMemorySystemInfo
364+ u32 optimize_memory_allocation : 1 ; ///< [7.0.0+] Only allowed in combination with is_application
365+ u32 disable_device_address_space_merge : 1 ; ///< [11.0.0+]
366+ u32 enable_alias_region_extra_size : 1 ; ///< [18.0.0+]
367+ u32 reserved : 18 ;
368+ } CreateProcessFlags ;
369+
370+ /// DebugEvent structure
371+ typedef struct {
372+ u32 type ; ///< \ref DebugEventType
373+ u32 flags ; ///< \ref DebugEventFlag
374+ u64 thread_id ;
375+
376+ union {
377+ /// DebugEventType_CreateProcess
378+ struct {
379+ u64 program_id ;
380+ u64 process_id ;
381+ char name [0xC ];
382+ u32 flags ; ///< \ref CreateProcessFlags
383+ void * user_exception_context_address ; ///< [5.0.0+]
384+ } create_process ;
385+
386+ /// DebugEventType_CreateThread
387+ struct {
388+ u64 thread_id ;
389+ void * tls_address ;
390+ void * entrypoint ; ///< [1.0.0-10.2.0]
391+ } create_thread ;
392+
393+ /// DebugEventType_ExitProcess
394+ struct {
395+ u32 reason ; ///< \ref ProcessExitReason
396+ } exit_process ;
397+
398+ /// DebugEventType_ExitThread
399+ struct {
400+ u32 reason ; ///< \ref ThreadExitReason
401+ } exit_thread ;
402+
403+ /// DebugEventType_Exception
404+ struct {
405+ u32 type ; ///< \ref DebugException
406+ void * address ;
407+ union {
408+ /// DebugException_UndefinedInstruction
409+ struct {
410+ u32 insn ;
411+ } undefined_instruction ;
412+
413+ /// DebugException_DataAbort
414+ struct {
415+ void * address ;
416+ } data_abort ;
417+
418+ /// DebugException_AlignmentFault
419+ struct {
420+ void * address ;
421+ } alignment_fault ;
422+
423+ /// DebugException_BreakPoint
424+ struct {
425+ u32 type ; ///< \ref BreakPointType
426+ void * address ;
427+ } break_point ;
428+
429+ /// DebugException_UserBreak
430+ struct {
431+ u32 break_reason ; ///< \ref BreakReason
432+ void * address ;
433+ size_t size ;
434+ } user_break ;
435+
436+ /// DebugException_DebuggerBreak
437+ struct {
438+ u64 active_thread_ids [4 ];
439+ } debugger_break ;
440+
441+ /// DebugException_UndefinedSystemCall
442+ struct {
443+ u32 id ;
444+ } undefined_system_call ;
445+
446+ u64 raw ;
447+ } specific ;
448+ } exception ;
449+ } info ;
450+ } DebugEvent ;
451+
293452///@name Memory management
294453///@{
295454
@@ -1265,7 +1424,7 @@ Result svcTerminateDebugProcess(Handle debug);
12651424 * @note Syscall number 0x63.
12661425 * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
12671426 */
1268- Result svcGetDebugEvent (void * event_out , Handle debug );
1427+ Result svcGetDebugEvent (DebugEvent * event_out , Handle debug );
12691428
12701429/**
12711430 * @brief Continues a debugging session.
0 commit comments