Index: source/Plugins/Process/Linux/NativeProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.cpp +++ source/Plugins/Process/Linux/NativeProcessLinux.cpp @@ -3676,16 +3676,25 @@ return true; } -static size_t WriteMemoryCallback (EmulateInstruction *instruction, - void *baton, - const EmulateInstruction::Context &context, - lldb::addr_t addr, - const void *dst, - size_t length) +static size_t +WriteMemoryCallback (EmulateInstruction *instruction, + void *baton, + const EmulateInstruction::Context &context, + lldb::addr_t addr, + const void *dst, + size_t length) { return length; } +static lldb::addr_t +ReadCspr (NativeRegisterContext* regsiter_context) +{ + const RegisterInfo* cpsr_info = regsiter_context->GetRegisterInfo( + eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS); + return regsiter_context->ReadRegisterAsUnsigned(cpsr_info, LLDB_INVALID_ADDRESS); +} + Error NativeProcessLinux::SingleStep(lldb::tid_t tid, uint32_t signo) { @@ -3696,7 +3705,7 @@ EmulateInstruction::FindPlugin(m_arch, eInstructionTypePCModifying, nullptr)); if (emulator_ap == nullptr) - return Error("Instrunction emulator not found!"); + return Error("Instruction emulator not found!"); EmulatorBaton baton(this, register_context_sp.get()); emulator_ap->SetBaton(&baton); @@ -3708,20 +3717,23 @@ if (!emulator_ap->ReadInstruction()) return Error("Read instruction failed!"); - if (!emulator_ap->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC)) - return Error("Evaluate instrcution failed!"); - - lldb::addr_t next_pc = baton.m_pc.GetAsUInt32(); - lldb::addr_t next_cpsr = 0; - if (baton.m_cpsr.GetType() != RegisterValue::eTypeInvalid) + lldb::addr_t next_pc; + lldb::addr_t next_cpsr; + if (emulator_ap->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC)) { - next_cpsr = baton.m_cpsr.GetAsUInt32(); + next_pc = baton.m_pc.GetAsUInt32(); + if (baton.m_cpsr.GetType() != RegisterValue::eTypeInvalid) + next_cpsr = baton.m_cpsr.GetAsUInt32(); + else + next_cpsr = ReadCspr (register_context_sp.get()); } else { - const RegisterInfo* cpsr_info = register_context_sp->GetRegisterInfo( - eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FLAGS); - next_cpsr = register_context_sp->ReadRegisterAsUnsigned(cpsr_info, LLDB_INVALID_ADDRESS); + // Emulate instruction failed. Advance PC with the size of the current + // opcode because the emulation of all PC modifying instruction should + // be successful. + next_pc = register_context_sp->GetPC() + emulator_ap->GetOpcode().GetByteSize(); + next_cpsr = ReadCspr (register_context_sp.get()); } if (next_cpsr & 0x20)