Fix a bug in crashhandler where we could end up disassembling far too much.

This commit is contained in:
Henrik Rydgård 2020-07-19 17:22:33 +02:00
parent 44954cff3f
commit dae9df3829
4 changed files with 17 additions and 7 deletions

View file

@ -15,7 +15,8 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "x64Analyzer.h"
#include "Common/Log.h"
#include "Common/x64Analyzer.h"
bool X86AnalyzeMOV(const unsigned char *codePtr, LSInstructionInfo &info)
{
@ -183,8 +184,11 @@ bool X86AnalyzeMOV(const unsigned char *codePtr, LSInstructionInfo &info)
case MOVE_REG_TO_MEM: //move reg to memory
break;
case MOVE_MEM_TO_REG:
break;
default:
PanicAlert("Unhandled disasm case in write handler!\n\nPlease implement or avoid.");
ERROR_LOG(CPU, "Unhandled disasm case in write handler!\n\nPlease implement or avoid.");
return false;
}
}

View file

@ -53,6 +53,7 @@ enum {
MOVE_8BIT = 0xC6, //move 8-bit immediate
MOVE_16_32BIT = 0xC7, //move 16 or 32-bit immediate
MOVE_REG_TO_MEM = 0x89, //move reg to memory
MOVE_MEM_TO_REG = 0x8B, //move memory to reg
};
enum AccessType {

View file

@ -246,7 +246,12 @@ std::vector<std::string> DisassembleX86(const u8 *data, int size) {
int int3_count = 0;
while (ud_disassemble(&ud_obj) != 0) {
std::string str = ud_insn_asm(&ud_obj);
const char *buf = ud_insn_asm(&ud_obj);
if (!buf) {
lines.push_back("[bad]");
continue;
}
std::string str = buf;
if (str == "int3") {
int3_count++;
} else {

View file

@ -114,25 +114,25 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) {
// X86, X86-64. Variable instruction size so need to analyze the mov instruction in detail.
// To ignore the access, we need to disassemble the instruction and modify context->CTX_PC
LSInstructionInfo info;
LSInstructionInfo info{};
success = X86AnalyzeMOV(codePtr, info);
instructionSize = info.instructionSize;
#elif PPSSPP_ARCH(ARM64)
uint32_t word;
memcpy(&word, codePtr, 4);
// To ignore the access, we need to disassemble the instruction and modify context->CTX_PC
Arm64LSInstructionInfo info;
Arm64LSInstructionInfo info{};
success = Arm64AnalyzeLoadStore((uint64_t)codePtr, word, &info);
#elif PPSSPP_ARCH(ARM)
uint32_t word;
memcpy(&word, codePtr, 4);
// To ignore the access, we need to disassemble the instruction and modify context->CTX_PC
ArmLSInstructionInfo info;
ArmLSInstructionInfo info{};
success = ArmAnalyzeLoadStore((uint32_t)codePtr, word, &info);
#endif
std::string disassembly;
if (DisassembleNativeAt(codePtr, instructionSize, &disassembly)) {
if (success && DisassembleNativeAt(codePtr, instructionSize, &disassembly)) {
infoString += disassembly + "\n";
}