Merge branch 'master' of https://github.com/Hedges/yuzu
This commit is contained in:
@@ -143,8 +143,8 @@ static u32 command_length;
|
||||
static u32 latest_signal = 0;
|
||||
static bool memory_break = false;
|
||||
|
||||
static Kernel::Thread* current_thread_c = nullptr;
|
||||
static Kernel::Thread* current_thread_g = nullptr;
|
||||
static Kernel::Thread* current_thread = nullptr;
|
||||
static unsigned current_core = 0;
|
||||
|
||||
// Binding to a port within the reserved ports range (0-1023) requires root permissions,
|
||||
// so default to a port outside of that range.
|
||||
@@ -173,10 +173,11 @@ static std::map<u64, Breakpoint> breakpoints_read;
|
||||
static std::map<u64, Breakpoint> breakpoints_write;
|
||||
|
||||
static Kernel::Thread* FindThreadById(int id) {
|
||||
for (int core = 0; core < Core::NUM_CPU_CORES; core++) {
|
||||
for (unsigned core = 0; core < Core::NUM_CPU_CORES; core++) {
|
||||
auto threads = Core::System::GetInstance().Scheduler(core)->GetThreadList();
|
||||
for (auto thread : threads) {
|
||||
if (thread->GetThreadId() == id) {
|
||||
current_core = core;
|
||||
return thread.get();
|
||||
}
|
||||
}
|
||||
@@ -561,12 +562,6 @@ static void HandleQuery() {
|
||||
for (int core = 0; core < Core::NUM_CPU_CORES; core++) {
|
||||
auto threads = Core::System::GetInstance().Scheduler(core)->GetThreadList();
|
||||
for (auto thread : threads) {
|
||||
// buffer += fmt::format(R"*(<thread id="{:x}" core="{:d}" name="Thread 0x{:016x}
|
||||
// (LWP {:x})"></thread>)*",
|
||||
// thread->GetThreadId(),
|
||||
// core,
|
||||
// reinterpret_cast<u64>(thread.get()),
|
||||
// thread->GetThreadId());
|
||||
buffer +=
|
||||
fmt::format(R"*(<thread id="{:x}" core="{:d}" name="Thread {:x}"></thread>)*",
|
||||
thread->GetThreadId(), core, thread->GetThreadId());
|
||||
@@ -581,28 +576,20 @@ static void HandleQuery() {
|
||||
|
||||
/// Handle set thread command from gdb client.
|
||||
static void HandleSetThread() {
|
||||
if (memcmp(command_buffer, "Hc", 2) == 0 || memcmp(command_buffer, "Hg", 2) == 0) {
|
||||
int thread_id = -1;
|
||||
static Kernel::Thread* current_thread;
|
||||
if (command_buffer[2] != '-') {
|
||||
thread_id = static_cast<int>(HexToInt(command_buffer + 2, command_length - 2));
|
||||
}
|
||||
if (thread_id >= 1) {
|
||||
current_thread = FindThreadById(thread_id);
|
||||
}
|
||||
if (!current_thread) {
|
||||
thread_id = 1;
|
||||
current_thread = FindThreadById(thread_id);
|
||||
}
|
||||
if (current_thread) {
|
||||
if (command_buffer[1] == 'c') {
|
||||
current_thread_c = current_thread;
|
||||
} else {
|
||||
current_thread_g = current_thread;
|
||||
}
|
||||
SendReply("OK");
|
||||
return;
|
||||
}
|
||||
int thread_id = -1;
|
||||
if (command_buffer[2] != '-') {
|
||||
thread_id = static_cast<int>(HexToInt(command_buffer + 2, command_length - 2));
|
||||
}
|
||||
if (thread_id >= 1) {
|
||||
current_thread = FindThreadById(thread_id);
|
||||
}
|
||||
if (!current_thread) {
|
||||
thread_id = 1;
|
||||
current_thread = FindThreadById(thread_id);
|
||||
}
|
||||
if (current_thread) {
|
||||
SendReply("OK");
|
||||
return;
|
||||
}
|
||||
SendReply("E01");
|
||||
}
|
||||
@@ -650,8 +637,6 @@ static void SendSignal(Kernel::Thread* thread, u32 signal, bool full = true) {
|
||||
buffer += fmt::format(";thread:{:x};", thread->GetThreadId());
|
||||
}
|
||||
|
||||
// NGLOG_ERROR(Debug_GDBStub, "{}", buffer.c_str());
|
||||
|
||||
SendReply(buffer.c_str());
|
||||
}
|
||||
|
||||
@@ -667,7 +652,7 @@ static void ReadCommand() {
|
||||
} else if (c == 0x03) {
|
||||
NGLOG_INFO(Debug_GDBStub, "gdb: found break command");
|
||||
halt_loop = true;
|
||||
SendSignal(current_thread_c, SIGTRAP);
|
||||
SendSignal(current_thread, SIGTRAP);
|
||||
return;
|
||||
} else if (c != GDB_STUB_START) {
|
||||
NGLOG_DEBUG(Debug_GDBStub, "gdb: read invalid byte {:02X}", c);
|
||||
@@ -738,11 +723,11 @@ static void ReadRegister() {
|
||||
}
|
||||
|
||||
if (id <= SP_REGISTER) {
|
||||
LongToGdbHex(reply, RegRead(id, current_thread_g));
|
||||
LongToGdbHex(reply, RegRead(id, current_thread));
|
||||
} else if (id == PC_REGISTER) {
|
||||
LongToGdbHex(reply, RegRead(id, current_thread_g));
|
||||
LongToGdbHex(reply, RegRead(id, current_thread));
|
||||
} else if (id == CPSR_REGISTER) {
|
||||
IntToGdbHex(reply, (u32)RegRead(id, current_thread_g));
|
||||
IntToGdbHex(reply, (u32)RegRead(id, current_thread));
|
||||
} else {
|
||||
return SendReply("E01");
|
||||
}
|
||||
@@ -758,16 +743,16 @@ static void ReadRegisters() {
|
||||
u8* bufptr = buffer;
|
||||
|
||||
for (int reg = 0; reg <= SP_REGISTER; reg++) {
|
||||
LongToGdbHex(bufptr + reg * 16, RegRead(reg, current_thread_g));
|
||||
LongToGdbHex(bufptr + reg * 16, RegRead(reg, current_thread));
|
||||
}
|
||||
|
||||
bufptr += (32 * 16);
|
||||
|
||||
LongToGdbHex(bufptr, RegRead(PC_REGISTER, current_thread_g));
|
||||
LongToGdbHex(bufptr, RegRead(PC_REGISTER, current_thread));
|
||||
|
||||
bufptr += 16;
|
||||
|
||||
IntToGdbHex(bufptr, (u32)RegRead(CPSR_REGISTER, current_thread_g));
|
||||
IntToGdbHex(bufptr, (u32)RegRead(CPSR_REGISTER, current_thread));
|
||||
|
||||
bufptr += 8;
|
||||
|
||||
@@ -786,15 +771,17 @@ static void WriteRegister() {
|
||||
}
|
||||
|
||||
if (id <= SP_REGISTER) {
|
||||
RegWrite(id, GdbHexToLong(buffer_ptr), current_thread_g);
|
||||
RegWrite(id, GdbHexToLong(buffer_ptr), current_thread);
|
||||
} else if (id == PC_REGISTER) {
|
||||
RegWrite(id, GdbHexToLong(buffer_ptr), current_thread_g);
|
||||
RegWrite(id, GdbHexToLong(buffer_ptr), current_thread);
|
||||
} else if (id == CPSR_REGISTER) {
|
||||
RegWrite(id, GdbHexToInt(buffer_ptr), current_thread_g);
|
||||
RegWrite(id, GdbHexToInt(buffer_ptr), current_thread);
|
||||
} else {
|
||||
return SendReply("E01");
|
||||
}
|
||||
|
||||
Core::System::GetInstance().ArmInterface(current_core).LoadContext(current_thread->context);
|
||||
|
||||
SendReply("OK");
|
||||
}
|
||||
|
||||
@@ -807,16 +794,18 @@ static void WriteRegisters() {
|
||||
|
||||
for (int i = 0, reg = 0; reg <= CPSR_REGISTER; i++, reg++) {
|
||||
if (reg <= SP_REGISTER) {
|
||||
RegWrite(reg, GdbHexToLong(buffer_ptr + i * 16), current_thread_g);
|
||||
RegWrite(reg, GdbHexToLong(buffer_ptr + i * 16), current_thread);
|
||||
} else if (reg == PC_REGISTER) {
|
||||
RegWrite(PC_REGISTER, GdbHexToLong(buffer_ptr + i * 16), current_thread_g);
|
||||
RegWrite(PC_REGISTER, GdbHexToLong(buffer_ptr + i * 16), current_thread);
|
||||
} else if (reg == CPSR_REGISTER) {
|
||||
RegWrite(CPSR_REGISTER, GdbHexToInt(buffer_ptr + i * 16), current_thread_g);
|
||||
RegWrite(CPSR_REGISTER, GdbHexToInt(buffer_ptr + i * 16), current_thread);
|
||||
} else {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
||||
Core::System::GetInstance().ArmInterface(current_core).LoadContext(current_thread->context);
|
||||
|
||||
SendReply("OK");
|
||||
}
|
||||
|
||||
@@ -872,10 +861,6 @@ static void WriteMemory() {
|
||||
}
|
||||
|
||||
void Break(bool is_memory_break) {
|
||||
// if (!halt_loop) {
|
||||
// halt_loop = true;
|
||||
//}
|
||||
|
||||
send_trap = true;
|
||||
|
||||
memory_break = is_memory_break;
|
||||
@@ -883,6 +868,10 @@ void Break(bool is_memory_break) {
|
||||
|
||||
/// Tell the CPU that it should perform a single step.
|
||||
static void Step() {
|
||||
if (command_length > 1) {
|
||||
RegWrite(PC_REGISTER, GdbHexToLong(command_buffer + 1), current_thread);
|
||||
Core::System::GetInstance().ArmInterface(current_core).LoadContext(current_thread->context);
|
||||
}
|
||||
step_loop = true;
|
||||
halt_loop = true;
|
||||
send_trap = true;
|
||||
@@ -1038,7 +1027,7 @@ void HandlePacket() {
|
||||
HandleSetThread();
|
||||
break;
|
||||
case '?':
|
||||
SendSignal(current_thread_c, latest_signal);
|
||||
SendSignal(current_thread, latest_signal);
|
||||
break;
|
||||
case 'k':
|
||||
Shutdown();
|
||||
@@ -1225,11 +1214,8 @@ void SetCpuStepFlag(bool is_step) {
|
||||
|
||||
void SendTrap(Kernel::Thread* thread, int trap) {
|
||||
if (send_trap) {
|
||||
// NGLOG_ERROR(Debug_GDBStub, "SendTrap {} {} {} {}", thread->GetThreadId(),
|
||||
// current_thread_c->GetThreadId(), halt_loop, step_loop);
|
||||
if (!halt_loop || (current_thread_c == thread)) {
|
||||
// NGLOG_ERROR(Debug_GDBStub, "SendTrap Fired!");
|
||||
current_thread_c = thread;
|
||||
if (!halt_loop || (current_thread == thread)) {
|
||||
current_thread = thread;
|
||||
SendSignal(thread, trap);
|
||||
}
|
||||
halt_loop = true;
|
||||
|
||||
@@ -538,7 +538,7 @@ private:
|
||||
// vertex shader, and what's the value of the fourth element when inside a Tess Eval
|
||||
// shader.
|
||||
ASSERT(stage == Maxwell3D::Regs::ShaderStage::Vertex);
|
||||
return "vec4(0, 0, gl_InstanceID, gl_VertexID)";
|
||||
return "vec4(0, 0, uintBitsToFloat(gl_InstanceID), uintBitsToFloat(gl_VertexID))";
|
||||
default:
|
||||
const u32 index{static_cast<u32>(attribute) -
|
||||
static_cast<u32>(Attribute::Index::Attribute_0)};
|
||||
|
||||
Reference in New Issue
Block a user