mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-14 07:04:24 -04:00
kern: optimize hw-single-step management
This commit is contained in:
parent
05ea0c53d7
commit
9e7b56b33c
7 changed files with 102 additions and 125 deletions
|
@ -109,6 +109,15 @@ namespace ams::kern::arch::arm64 {
|
|||
break;
|
||||
}
|
||||
|
||||
/* If we should, clear the thread's state as single-step. */
|
||||
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
|
||||
if (AMS_UNLIKELY(GetCurrentThread().IsSingleStep())) {
|
||||
GetCurrentThread().ClearSingleStep();
|
||||
cpu::MonitorDebugSystemControlRegisterAccessor().SetSoftwareStep(false).Store();
|
||||
cpu::EnsureInstructionConsistency();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If we should process the user exception (and it's not a breakpoint), try to enter. */
|
||||
const bool is_software_break = (ec == EsrEc_Unknown || ec == EsrEc_IllegalExecution || ec == EsrEc_BkptInstruction || ec == EsrEc_BrkInstruction);
|
||||
const bool is_breakpoint = (ec == EsrEc_BreakPointEl0 || ec == EsrEc_SoftwareStepEl0 || ec == EsrEc_WatchPointEl0);
|
||||
|
@ -290,16 +299,40 @@ namespace ams::kern::arch::arm64 {
|
|||
return;
|
||||
}
|
||||
|
||||
/* Print that an exception occurred. */
|
||||
MESOSPHERE_RELEASE_LOG("Exception occurred. %016lx\n", GetCurrentProcess().GetProgramId());
|
||||
|
||||
#if defined(MESOSPHERE_ENABLE_HARDWARE_SINGLE_STEP)
|
||||
{
|
||||
/* Print the current thread's registers. */
|
||||
KDebug::PrintRegister();
|
||||
if (ec != EsrEc_SoftwareStepEl0) {
|
||||
/* If the exception wasn't single-step, print details. */
|
||||
MESOSPHERE_RELEASE_LOG("Exception occurred. %016lx\n", GetCurrentProcess().GetProgramId());
|
||||
|
||||
/* Print a backtrace. */
|
||||
KDebug::PrintBacktrace();
|
||||
{
|
||||
/* Print the current thread's registers. */
|
||||
KDebug::PrintRegister();
|
||||
|
||||
/* Print a backtrace. */
|
||||
KDebug::PrintBacktrace();
|
||||
}
|
||||
} else {
|
||||
/* If the exception was single-step and we have no debug object, we should just return. */
|
||||
if (AMS_UNLIKELY(!cur_process.IsAttachedToDebugger())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
/* Print that an exception occurred. */
|
||||
MESOSPHERE_RELEASE_LOG("Exception occurred. %016lx\n", GetCurrentProcess().GetProgramId());
|
||||
|
||||
{
|
||||
/* Print the current thread's registers. */
|
||||
KDebug::PrintRegister();
|
||||
|
||||
/* Print a backtrace. */
|
||||
KDebug::PrintBacktrace();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the SVC is handled, handle it. */
|
||||
if (!svc::ResultNotHandled::Includes(result)) {
|
||||
|
@ -559,6 +592,7 @@ namespace ams::kern::arch::arm64 {
|
|||
KDpcManager::HandleDpc();
|
||||
}
|
||||
}
|
||||
|
||||
/* Note that we're no longer in an exception handler. */
|
||||
GetCurrentThread().ClearInExceptionHandler();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue