Core timing 2.0 (#4913)
* Core::Timing: Add multiple timer, one for each core * revert clang-format; work on tests for CoreTiming * Kernel:: Add support for multiple cores, asserts in HandleSyncRequest because Thread->status == WaitIPC * Add some TRACE_LOGs * fix tests * make some adjustments to qt-debugger, cheats and gdbstub(probably still broken) * Make ARM_Interface::id private, rework ARM_Interface ctor * ReRename TimingManager to Timing for smaler diff * addressed review comments
This commit is contained in:
parent
e3dbdcbdff
commit
55ec7031cc
32 changed files with 760 additions and 535 deletions
|
@ -160,10 +160,14 @@ BreakpointMap breakpoints_write;
|
|||
} // Anonymous namespace
|
||||
|
||||
static Kernel::Thread* FindThreadById(int id) {
|
||||
const auto& threads = Core::System::GetInstance().Kernel().GetThreadManager().GetThreadList();
|
||||
for (auto& thread : threads) {
|
||||
if (thread->GetThreadId() == static_cast<u32>(id)) {
|
||||
return thread.get();
|
||||
u32 num_cores = Core::GetNumCores();
|
||||
for (u32 i = 0; i < num_cores; ++i) {
|
||||
const auto& threads =
|
||||
Core::System::GetInstance().Kernel().GetThreadManager(i).GetThreadList();
|
||||
for (auto& thread : threads) {
|
||||
if (thread->GetThreadId() == static_cast<u32>(id)) {
|
||||
return thread.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -414,7 +418,10 @@ static void RemoveBreakpoint(BreakpointType type, VAddr addr) {
|
|||
Core::System::GetInstance().Memory().WriteBlock(
|
||||
*Core::System::GetInstance().Kernel().GetCurrentProcess(), bp->second.addr,
|
||||
bp->second.inst.data(), bp->second.inst.size());
|
||||
Core::CPU().ClearInstructionCache();
|
||||
u32 num_cores = Core::GetNumCores();
|
||||
for (u32 i = 0; i < num_cores; ++i) {
|
||||
Core::GetCore(i).ClearInstructionCache();
|
||||
}
|
||||
}
|
||||
p.erase(addr);
|
||||
}
|
||||
|
@ -540,10 +547,13 @@ static void HandleQuery() {
|
|||
SendReply(target_xml);
|
||||
} else if (strncmp(query, "fThreadInfo", strlen("fThreadInfo")) == 0) {
|
||||
std::string val = "m";
|
||||
const auto& threads =
|
||||
Core::System::GetInstance().Kernel().GetThreadManager().GetThreadList();
|
||||
for (const auto& thread : threads) {
|
||||
val += fmt::format("{:x},", thread->GetThreadId());
|
||||
u32 num_cores = Core::GetNumCores();
|
||||
for (u32 i = 0; i < num_cores; ++i) {
|
||||
const auto& threads =
|
||||
Core::System::GetInstance().Kernel().GetThreadManager(i).GetThreadList();
|
||||
for (const auto& thread : threads) {
|
||||
val += fmt::format("{:x},", thread->GetThreadId());
|
||||
}
|
||||
}
|
||||
val.pop_back();
|
||||
SendReply(val.c_str());
|
||||
|
@ -553,11 +563,14 @@ static void HandleQuery() {
|
|||
std::string buffer;
|
||||
buffer += "l<?xml version=\"1.0\"?>";
|
||||
buffer += "<threads>";
|
||||
const auto& threads =
|
||||
Core::System::GetInstance().Kernel().GetThreadManager().GetThreadList();
|
||||
for (const auto& thread : threads) {
|
||||
buffer += fmt::format(R"*(<thread id="{:x}" name="Thread {:x}"></thread>)*",
|
||||
thread->GetThreadId(), thread->GetThreadId());
|
||||
u32 num_cores = Core::GetNumCores();
|
||||
for (u32 i = 0; i < num_cores; ++i) {
|
||||
const auto& threads =
|
||||
Core::System::GetInstance().Kernel().GetThreadManager(i).GetThreadList();
|
||||
for (const auto& thread : threads) {
|
||||
buffer += fmt::format(R"*(<thread id="{:x}" name="Thread {:x}"></thread>)*",
|
||||
thread->GetThreadId(), thread->GetThreadId());
|
||||
}
|
||||
}
|
||||
buffer += "</threads>";
|
||||
SendReply(buffer.c_str());
|
||||
|
@ -619,9 +632,9 @@ static void SendSignal(Kernel::Thread* thread, u32 signal, bool full = true) {
|
|||
if (full) {
|
||||
|
||||
buffer = fmt::format("T{:02x}{:02x}:{:08x};{:02x}:{:08x};{:02x}:{:08x}", latest_signal,
|
||||
PC_REGISTER, htonl(Core::CPU().GetPC()), SP_REGISTER,
|
||||
htonl(Core::CPU().GetReg(SP_REGISTER)), LR_REGISTER,
|
||||
htonl(Core::CPU().GetReg(LR_REGISTER)));
|
||||
PC_REGISTER, htonl(Core::GetRunningCore().GetPC()), SP_REGISTER,
|
||||
htonl(Core::GetRunningCore().GetReg(SP_REGISTER)), LR_REGISTER,
|
||||
htonl(Core::GetRunningCore().GetReg(LR_REGISTER)));
|
||||
} else {
|
||||
buffer = fmt::format("T{:02x}", latest_signal);
|
||||
}
|
||||
|
@ -782,7 +795,7 @@ static void WriteRegister() {
|
|||
return SendReply("E01");
|
||||
}
|
||||
|
||||
Core::CPU().LoadContext(current_thread->context);
|
||||
Core::GetRunningCore().LoadContext(current_thread->context);
|
||||
|
||||
SendReply("OK");
|
||||
}
|
||||
|
@ -812,7 +825,7 @@ static void WriteRegisters() {
|
|||
}
|
||||
}
|
||||
|
||||
Core::CPU().LoadContext(current_thread->context);
|
||||
Core::GetRunningCore().LoadContext(current_thread->context);
|
||||
|
||||
SendReply("OK");
|
||||
}
|
||||
|
@ -869,7 +882,7 @@ static void WriteMemory() {
|
|||
GdbHexToMem(data.data(), len_pos + 1, len);
|
||||
Core::System::GetInstance().Memory().WriteBlock(
|
||||
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, data.data(), len);
|
||||
Core::CPU().ClearInstructionCache();
|
||||
Core::GetRunningCore().ClearInstructionCache();
|
||||
SendReply("OK");
|
||||
}
|
||||
|
||||
|
@ -883,12 +896,12 @@ void Break(bool is_memory_break) {
|
|||
static void Step() {
|
||||
if (command_length > 1) {
|
||||
RegWrite(PC_REGISTER, GdbHexToInt(command_buffer + 1), current_thread);
|
||||
Core::CPU().LoadContext(current_thread->context);
|
||||
Core::GetRunningCore().LoadContext(current_thread->context);
|
||||
}
|
||||
step_loop = true;
|
||||
halt_loop = true;
|
||||
send_trap = true;
|
||||
Core::CPU().ClearInstructionCache();
|
||||
Core::GetRunningCore().ClearInstructionCache();
|
||||
}
|
||||
|
||||
bool IsMemoryBreak() {
|
||||
|
@ -904,7 +917,7 @@ static void Continue() {
|
|||
memory_break = false;
|
||||
step_loop = false;
|
||||
halt_loop = false;
|
||||
Core::CPU().ClearInstructionCache();
|
||||
Core::GetRunningCore().ClearInstructionCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -930,7 +943,7 @@ static bool CommitBreakpoint(BreakpointType type, VAddr addr, u32 len) {
|
|||
Core::System::GetInstance().Memory().WriteBlock(
|
||||
*Core::System::GetInstance().Kernel().GetCurrentProcess(), addr, btrap.data(),
|
||||
btrap.size());
|
||||
Core::CPU().ClearInstructionCache();
|
||||
Core::GetRunningCore().ClearInstructionCache();
|
||||
}
|
||||
p.insert({addr, breakpoint});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue