1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-17 17:36:44 +00:00

kern: since 10.0.0, KDebug::GetThreadContext always returns X0-X7

This commit is contained in:
Michael Scire 2021-07-13 13:00:16 -07:00
parent 3bedf56512
commit bd6155bcb4

View file

@ -74,26 +74,32 @@ namespace ams::kern::arch::arm64 {
/* Get the exception context. */ /* Get the exception context. */
const KExceptionContext *e_ctx = GetExceptionContext(thread); const KExceptionContext *e_ctx = GetExceptionContext(thread);
/* Get whether we're 64-bit. */
const bool is_64_bit = this->Is64Bit();
/* If general registers are requested, get them. */ /* If general registers are requested, get them. */
if ((context_flags & ams::svc::ThreadContextFlag_General) != 0) { if ((context_flags & ams::svc::ThreadContextFlag_General) != 0) {
/* We can always get X0-X7/R0-R7. */
auto register_count = 8;
if (!thread->IsCallingSvc() || thread->GetSvcId() == svc::SvcId_ReturnFromException) { if (!thread->IsCallingSvc() || thread->GetSvcId() == svc::SvcId_ReturnFromException) {
if (this->Is64Bit()) { if (is_64_bit) {
/* Get X0-X28. */ /* We're not in an SVC, so we can get X0-X29. */
for (auto i = 0; i <= 28; ++i) { register_count = 29;
out->r[i] = e_ctx->x[i];
}
} else { } else {
/* Get R0-R12. */ /* We're 32-bit, so we should get R0-R12. */
for (auto i = 0; i <= 12; ++i) { register_count = 13;
out->r[i] = static_cast<u32>(e_ctx->x[i]);
}
} }
} }
/* Get the registers. */
for (auto i = 0; i < register_count; ++i) {
out->r[i] = is_64_bit ? e_ctx->x[i] : static_cast<u32>(e_ctx->x[i]);
}
} }
/* If control flags are requested, get them. */ /* If control flags are requested, get them. */
if ((context_flags & ams::svc::ThreadContextFlag_Control) != 0) { if ((context_flags & ams::svc::ThreadContextFlag_Control) != 0) {
if (this->Is64Bit()) { if (is_64_bit) {
out->fp = e_ctx->x[29]; out->fp = e_ctx->x[29];
out->lr = e_ctx->x[30]; out->lr = e_ctx->x[30];
out->sp = e_ctx->sp; out->sp = e_ctx->sp;