From 00d741d6d0a04bcc19dd4711bdb11e3fe08539ab Mon Sep 17 00:00:00 2001 From: Xusheng Date: Wed, 31 Jan 2024 12:31:44 +0800 Subject: [PATCH] Only use the LLIL/MLIL/HLIL if they are available. Fix crash when stepping fast. Fix https://github.com/Vector35/debugger/issues/537 --- core/debuggercontroller.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/core/debuggercontroller.cpp b/core/debuggercontroller.cpp index 07d1491..3ce4e0f 100644 --- a/core/debuggercontroller.cpp +++ b/core/debuggercontroller.cpp @@ -370,7 +370,10 @@ DebugStopReason DebuggerController::StepIntoIL(BNFunctionGraphType il) for (FunctionRef& func : functions) { - LowLevelILFunctionRef llil = func->GetLowLevelIL(); + LowLevelILFunctionRef llil = func->GetLowLevelILIfAvailable(); + if (!llil) + return SingleStep; + size_t start = llil->GetInstructionStart(m_liveView->GetDefaultArchitecture(), newRemoteRip); if (start < llil->GetInstructionCount()) { @@ -397,7 +400,10 @@ DebugStopReason DebuggerController::StepIntoIL(BNFunctionGraphType il) for (FunctionRef& func : functions) { - MediumLevelILFunctionRef mlil = func->GetMediumLevelIL(); + MediumLevelILFunctionRef mlil = func->GetMediumLevelILIfAvailable(); + if (!mlil) + return SingleStep; + size_t start = mlil->GetInstructionStart(m_liveView->GetDefaultArchitecture(), newRemoteRip); if (start < mlil->GetInstructionCount()) { @@ -425,7 +431,10 @@ DebugStopReason DebuggerController::StepIntoIL(BNFunctionGraphType il) for (FunctionRef& func : functions) { - HighLevelILFunctionRef hlil = func->GetHighLevelIL(); + HighLevelILFunctionRef hlil = func->GetHighLevelILIfAvailable(); + if (!hlil) + return SingleStep; + for (size_t i = 0; i < hlil->GetInstructionCount(); i++) { if (hlil->GetInstruction(i).address == newRemoteRip) @@ -491,7 +500,10 @@ DebugStopReason DebuggerController::StepOverIL(BNFunctionGraphType il) for (FunctionRef& func : functions) { - LowLevelILFunctionRef llil = func->GetLowLevelIL(); + LowLevelILFunctionRef llil = func->GetLowLevelILIfAvailable(); + if (!llil) + return SingleStep; + size_t start = llil->GetInstructionStart(m_liveView->GetDefaultArchitecture(), newRemoteRip); if (start < llil->GetInstructionCount()) { @@ -517,7 +529,10 @@ DebugStopReason DebuggerController::StepOverIL(BNFunctionGraphType il) for (FunctionRef& func : functions) { - MediumLevelILFunctionRef mlil = func->GetMediumLevelIL(); + MediumLevelILFunctionRef mlil = func->GetMediumLevelILIfAvailable(); + if (!mlil) + return SingleStep; + size_t start = mlil->GetInstructionStart(m_liveView->GetDefaultArchitecture(), newRemoteRip); if (start < mlil->GetInstructionCount()) { @@ -545,7 +560,10 @@ DebugStopReason DebuggerController::StepOverIL(BNFunctionGraphType il) for (FunctionRef& func : functions) { - HighLevelILFunctionRef hlil = func->GetHighLevelIL(); + HighLevelILFunctionRef hlil = func->GetHighLevelILIfAvailable(); + if (!hlil) + return SingleStep; + for (size_t i = 0; i < hlil->GetInstructionCount(); i++) { if (hlil->GetInstruction(i).address == newRemoteRip)