mirror of
https://github.com/switchbrew/libnx.git
synced 2025-08-05 07:59:24 +02:00
svcBreak: fix prototype, add and use BreakReason enum
This commit is contained in:
parent
e0c1dfe2ce
commit
4c6abe1e41
@ -108,6 +108,20 @@ typedef struct {
|
||||
u64 X[8]; ///< Values of X0 through X7.
|
||||
} PACKED SecmonArgs;
|
||||
|
||||
/// Break reasons
|
||||
typedef enum {
|
||||
BreakReason_Panic = 0,
|
||||
BreakReason_Assert = 1,
|
||||
BreakReason_User = 2,
|
||||
BreakReason_PreLoadDll = 3,
|
||||
BreakReason_PostLoadDll = 4,
|
||||
BreakReason_PreUnloadDll = 5,
|
||||
BreakReason_PostUnloadDll = 6,
|
||||
BreakReason_CppException = 7,
|
||||
|
||||
BreakReason_NotificationOnlyFlag = 0x80000000,
|
||||
} BreakReason;
|
||||
|
||||
/// Code memory mapping operations
|
||||
typedef enum {
|
||||
CodeMapOperation_MapOwner=0, ///< Map owner.
|
||||
@ -603,14 +617,14 @@ Result svcGetThreadId(u64 *threadID, Handle handle);
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Breaks execution. Panic.
|
||||
* @param[in] breakReason Break reason.
|
||||
* @param[in] inval1 First break parameter.
|
||||
* @param[in] inval2 Second break parameter.
|
||||
* @brief Breaks execution.
|
||||
* @param[in] breakReason Break reason (see \ref BreakReason).
|
||||
* @param[in] address Address of the buffer to pass to the debugger.
|
||||
* @param[in] size Size of the buffer to pass to the debugger.
|
||||
* @return Result code.
|
||||
* @note Syscall number 0x26.
|
||||
*/
|
||||
Result svcBreak(u32 breakReason, u64 inval1, u64 inval2);
|
||||
Result svcBreak(u32 breakReason, uintptr_t address, uintptr_t size);
|
||||
|
||||
///@}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static bool _leventWait(u32* counter, bool clear, u64 timeout_ns) {
|
||||
if (R_VALUE(res) == KERNELRESULT(TimedOut))
|
||||
return false; // whoops, timed out
|
||||
if (R_VALUE(res) != KERNELRESULT(InvalidState))
|
||||
svcBreak(0, 0, 0); // should not happen
|
||||
svcBreak(BreakReason_Assert, 0, 0); // should not happen
|
||||
}
|
||||
|
||||
if (clear) {
|
||||
@ -104,7 +104,7 @@ static bool _leventWait(u32* counter, bool clear, u64 timeout_ns) {
|
||||
}
|
||||
else {
|
||||
// Invalid state - should not happen
|
||||
svcBreak(0, 0, 0);
|
||||
svcBreak(BreakReason_Assert, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ static void _leventSignal(u32* counter, bool autoclear) {
|
||||
}
|
||||
|
||||
if (R_FAILED(res))
|
||||
svcBreak(0, 0, 0); // should not happen
|
||||
svcBreak(BreakReason_Assert, 0, 0); // should not happen
|
||||
}
|
||||
|
||||
static void _leventClear(u32* counter) {
|
||||
|
@ -57,7 +57,7 @@ void mutexLock(Mutex* m) {
|
||||
// Ask the kernel to arbitrate the lock for us.
|
||||
if (UNLIKELY(R_FAILED(svcArbitrateLock(value & ~HANDLE_WAIT_MASK, m, cur_handle)))) {
|
||||
// This should be impossible under normal circumstances.
|
||||
svcBreak(0, 0, 0);
|
||||
svcBreak(BreakReason_Assert, 0, 0);
|
||||
}
|
||||
|
||||
// Reload the value, and check if we got the lock.
|
||||
@ -126,7 +126,7 @@ void mutexUnlock(Mutex* m) {
|
||||
// Ask the kernel to arbitrate unlock for us.
|
||||
if (UNLIKELY(R_FAILED(svcArbitrateUnlock(m)))) {
|
||||
// This should be impossible under normal circumstances.
|
||||
svcBreak(0, 0, 0);
|
||||
svcBreak(BreakReason_Assert, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ static void _fatalCmd(Result err, FatalPolicy type, FatalCpuContext *ctx, u32 cm
|
||||
if (type == FatalPolicy_ErrorScreen && !kernelAbove300()) type = FatalPolicy_ErrorReportAndErrorScreen;
|
||||
|
||||
if (detectDebugger()) {
|
||||
svcBreak(0x80000000, err, 0);
|
||||
svcBreak(BreakReason_Panic | BreakReason_NotificationOnlyFlag, (uintptr_t)&err, sizeof(err));
|
||||
}
|
||||
|
||||
Handle session;
|
||||
|
Loading…
Reference in New Issue
Block a user