Debugger: Fix disassembler to handle newer udis86 API.

In newer versions of udis86, the ud_t.mnemonic field is deprecated,
and one must now call ud_insn_mnemonic() to retrieve that information.
This was causing Debugger to not correctly identify subroutine calls
and jump instructions, which broke the stepping code in various fun
ways.
This commit is contained in:
Rene Gollent
2014-11-12 21:50:53 -05:00
parent 242c022af8
commit dc257d1603
@@ -153,9 +153,10 @@ DisassemblerX86::GetNextInstructionInfo(InstructionInfo& _info,
instruction_type type = INSTRUCTION_TYPE_OTHER; instruction_type type = INSTRUCTION_TYPE_OTHER;
target_addr_t targetAddress = 0; target_addr_t targetAddress = 0;
if (fUdisData->mnemonic == UD_Icall) ud_mnemonic_code mnemonic = ud_insn_mnemonic(fUdisData);
if (mnemonic == UD_Icall)
type = INSTRUCTION_TYPE_SUBROUTINE_CALL; type = INSTRUCTION_TYPE_SUBROUTINE_CALL;
else if (fUdisData->mnemonic == UD_Ijmp) else if (mnemonic == UD_Ijmp)
type = INSTRUCTION_TYPE_JUMP; type = INSTRUCTION_TYPE_JUMP;
if (state != NULL) if (state != NULL)
targetAddress = GetInstructionTargetAddress(state); targetAddress = GetInstructionTargetAddress(state);
@@ -175,7 +176,8 @@ DisassemblerX86::GetNextInstructionInfo(InstructionInfo& _info,
target_addr_t target_addr_t
DisassemblerX86::GetInstructionTargetAddress(CpuState* state) const DisassemblerX86::GetInstructionTargetAddress(CpuState* state) const
{ {
if (fUdisData->mnemonic != UD_Icall && fUdisData->mnemonic != UD_Ijmp) ud_mnemonic_code mnemonic = ud_insn_mnemonic(fUdisData);
if (mnemonic != UD_Icall && mnemonic != UD_Ijmp)
return 0; return 0;
CpuStateX86* x86State = dynamic_cast<CpuStateX86*>(state); CpuStateX86* x86State = dynamic_cast<CpuStateX86*>(state);