Interfacing GDBStub with Dynarmic wip.

This commit is contained in:
Jarek Syrylak
2018-07-23 15:08:25 +01:00
parent bfb96d05f5
commit c2d6c6a3d4
4 changed files with 43 additions and 10 deletions

View File

@@ -136,6 +136,7 @@ void ARM_Dynarmic::Run() {
void ARM_Dynarmic::Step() {
cb->InterpreterFallback(jit->GetPC(), 1);
ClearInstructionCache();
}
ARM_Dynarmic::ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, size_t core_index)

View File

@@ -195,21 +195,49 @@ MICROPROFILE_DEFINE(ARM_Jit, "ARM JIT", "ARM JIT", MP_RGB(255, 64, 64));
void ARM_Unicorn::ExecuteInstructions(int num_instructions) {
MICROPROFILE_SCOPE(ARM_Jit);
//if (GDBStub::IsServerEnabled()) {
// GDBStub::BreakpointAddress bkpt;
// bkpt.address = GetPC();
// bkpt.type = GDBStub::BreakpointType::Execute;
// u8 opcode[4];
// Memory::ReadBlock(bkpt.address, opcode, 4);
// static const u8 btrap[] = {0xd4, 0x20, 0x7d, 0x00};
// if (memcmp(opcode, btrap, 4) == 0) {
// if(!last_bkpt_hit)
// {
// LOG_ERROR(Debug_GDBStub, "btrap detected at {:16x}!", bkpt.address);
// RecordBreak(bkpt);
// uc_emu_stop(uc);
// }
// }
//}
CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions));
CoreTiming::AddTicks(num_instructions);
if (GDBStub::IsServerEnabled()) {
//u64 pc = GetPC();
//GDBStub::BreakpointAddress bkpt = GDBStub::GetNextBreakpointFromAddress(pc, GDBStub::BreakpointType::Execute);
//if(bkpt.type != GDBStub::BreakpointType::None && bkpt.address == pc)
//{
// RecordBreak(bkpt);
//}
if (last_bkpt_hit) {
uc_reg_write(uc, UC_ARM64_REG_PC, &last_bkpt.address);
}
//else
//{
// GDBStub::BreakpointAddress bkpt;
// bkpt.address = GetPC();
// bkpt.type = GDBStub::BreakpointType::Execute;
// u8 opcode[4];
// Memory::ReadBlock(bkpt.address, opcode, 4);
// static const u8 btrap[] = {0xd4, 0x20, 0x7d, 0x00};
// if(memcmp(opcode, btrap, 4) == 0)
// {
// if(!last_bkpt_hit)
// {
// LOG_ERROR(Debug_GDBStub, "btrap detected at {:16x}!", bkpt.address);
// RecordBreak(bkpt);
// uc_emu_stop(uc);
// }
// }
//}
Kernel::Thread* thread = Kernel::GetCurrentThread();
SaveContext(thread->context);
if (last_bkpt_hit || (num_instructions == 1 && GDBStub::GetCpuHaltFlag())) {
if (last_bkpt_hit || (num_instructions == 1)) {
last_bkpt_hit = false;
GDBStub::Break();
GDBStub::SendTrap(thread, 5);

View File

@@ -31,6 +31,10 @@
#endif
#include "common/logging/log.h"
#undef LOG_DEBUG
#undef LOG_INFO
#define LOG_DEBUG LOG_ERROR
#define LOG_INFO LOG_ERROR
#include "common/string_util.h"
#include "common/swap.h"
#include "core/arm/arm_interface.h"
@@ -986,8 +990,8 @@ static bool CommitBreakpoint(BreakpointType type, PAddr addr, u64 len) {
breakpoint.addr = addr;
breakpoint.len = len;
Memory::ReadBlock(addr, breakpoint.old, 4);
static const u8 bkpt0[] = {0xd4, 0x20, 0x00, 0x00};
Memory::WriteBlock(addr, bkpt0, 4);
static const u8 btrap[] = {0xd4, 0x20, 0x7d, 0x00};
Memory::WriteBlock(addr, btrap, 4);
p.insert({addr, breakpoint});
LOG_DEBUG(Debug_GDBStub, "gdb: added {} breakpoint: {:016X} bytes at {:016X}",