Update svcGetDebugThreadContext, add svcSetDebugThreadContext, implement threadDumpContext

This commit is contained in:
TuxSH 2018-09-16 03:10:05 +02:00 committed by fincs
parent 5498d3e0c7
commit 3ecd841ec2
3 changed files with 29 additions and 2 deletions

View File

@ -861,12 +861,30 @@ Result svcContinueDebugEvent(Handle debug, u32 flags, u64* tid_list, u32 num_tid
Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID); Result svcLegacyContinueDebugEvent(Handle debug, u32 flags, u64 threadID);
/** /**
* @brief Gets the context of a thread in a debugging session. * @brief Gets the context (dump the registers) of a thread in a debugging session.
* @return Result code. * @return Result code.
* @param[out] ctx Output thread context (register dump).
* @param[in] debug Debug handle.
* @param[in] threadId ID of the thread to dump the context of.
* @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
* @note Syscall number 0x67. * @note Syscall number 0x67.
* @warning Official kernel will not dump any CPU GPR if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException).
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available. * @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/ */
Result svcGetDebugThreadContext(u8* out, Handle debug, u64 threadID, u32 flags); Result svcGetDebugThreadContext(ThreadContext* ctx, Handle debug, u64 threadID, u32 flags);
/**
* @brief Gets the context (dump the registers) of a thread in a debugging session.
* @return Result code.
* @param[in] debug Debug handle.
* @param[in] threadId ID of the thread to set the context of.
* @param[in] ctx Input thread context (register dump).
* @param[in] flags Register groups to select, combination of @ref RegisterGroup flags.
* @note Syscall number 0x68.
* @warning Official kernel will return an error if the thread is currently executing a system call (except @ref svcBreak and @ref svcReturnFromException).
* @warning This is a privileged syscall. Use \ref envIsSyscallHinted to check if it is available.
*/
Result svcSetDebugThreadContext(Handle debug, u64 threadID, const ThreadContext* ctx, u32 flags);
///@} ///@}

View File

@ -482,6 +482,11 @@ SVC_BEGIN svcGetDebugThreadContext
ret ret
SVC_END SVC_END
SVC_BEGIN svcSetDebugThreadContext
svc 0x68
ret
SVC_END
SVC_BEGIN svcQueryDebugProcessMemory SVC_BEGIN svcQueryDebugProcessMemory
str x1, [sp, #-16]! str x1, [sp, #-16]!
svc 0x69 svc 0x69

View File

@ -134,3 +134,7 @@ Result threadPause(Thread* t) {
Result threadResume(Thread* t) { Result threadResume(Thread* t) {
return svcSetThreadActivity(t->handle, 0); return svcSetThreadActivity(t->handle, 0);
} }
Result threadDumpContext(ThreadContext* ctx, Thread* t) {
return svcGetThreadContext3(ctx, t->handle);
}