|
|
@ -184,7 +184,7 @@ void gdbstub_thread_gdb() |
|
|
|
char resp[32 * 8 + 8 + 1] = {0}; |
|
|
|
char resp[32 * 8 + 8 + 1] = {0}; |
|
|
|
|
|
|
|
|
|
|
|
// Obtain CPU0 mutex
|
|
|
|
// Obtain CPU0 mutex
|
|
|
|
pthread_mutex_lock(cpu0_mutex); |
|
|
|
pthread_mutex_lock(&cpu0_mutex); |
|
|
|
|
|
|
|
|
|
|
|
// All general purpose registers in host byte order as chars
|
|
|
|
// All general purpose registers in host byte order as chars
|
|
|
|
for(size_t i = 0; i < 32; i++) |
|
|
|
for(size_t i = 0; i < 32; i++) |
|
|
@ -198,7 +198,7 @@ void gdbstub_thread_gdb() |
|
|
|
snprintf(resp + 32 * 8, 9, "%08x", pc); |
|
|
|
snprintf(resp + 32 * 8, 9, "%08x", pc); |
|
|
|
|
|
|
|
|
|
|
|
// Let go of CPU0 mutex
|
|
|
|
// Let go of CPU0 mutex
|
|
|
|
pthread_mutex_unlock(cpu0_mutex); |
|
|
|
pthread_mutex_unlock(&cpu0_mutex); |
|
|
|
|
|
|
|
|
|
|
|
// Final packet size, send packet
|
|
|
|
// Final packet size, send packet
|
|
|
|
size_t size = 32 * 8 + 8; |
|
|
|
size_t size = 32 * 8 + 8; |
|
|
@ -209,7 +209,7 @@ void gdbstub_thread_gdb() |
|
|
|
// G : write all registers -> read and set all registers
|
|
|
|
// G : write all registers -> read and set all registers
|
|
|
|
|
|
|
|
|
|
|
|
// Obtain CPU0 mutex
|
|
|
|
// Obtain CPU0 mutex
|
|
|
|
pthread_mutex_lock(cpu0_mutex); |
|
|
|
pthread_mutex_lock(&cpu0_mutex); |
|
|
|
|
|
|
|
|
|
|
|
// All general purpose registers in host byte order as chars
|
|
|
|
// All general purpose registers in host byte order as chars
|
|
|
|
for(size_t i = 1; i < 32; i++) |
|
|
|
for(size_t i = 1; i < 32; i++) |
|
|
@ -228,7 +228,7 @@ void gdbstub_thread_gdb() |
|
|
|
cpu0->pc = pc; |
|
|
|
cpu0->pc = pc; |
|
|
|
|
|
|
|
|
|
|
|
// Let go of CPU0 Mutex
|
|
|
|
// Let go of CPU0 Mutex
|
|
|
|
pthread_mutex_unlock(cpu0_mutex); |
|
|
|
pthread_mutex_unlock(&cpu0_mutex); |
|
|
|
|
|
|
|
|
|
|
|
gdbstub_send_packet("OK", 2); |
|
|
|
gdbstub_send_packet("OK", 2); |
|
|
|
} |
|
|
|
} |
|
|
@ -239,6 +239,9 @@ void gdbstub_thread_gdb() |
|
|
|
uint32_t length; |
|
|
|
uint32_t length; |
|
|
|
sscanf(packet + 1, "%x,%x", &address, &length); |
|
|
|
sscanf(packet + 1, "%x,%x", &address, &length); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Aquire memory mutex
|
|
|
|
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
|
|
|
|
|
|
|
|
char data[length * 2 + 1]; |
|
|
|
char data[length * 2 + 1]; |
|
|
|
for(size_t i = 0; i < length; i++) |
|
|
|
for(size_t i = 0; i < length; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -246,6 +249,9 @@ void gdbstub_thread_gdb() |
|
|
|
snprintf(data + i * 2, 3, "%02x", value); |
|
|
|
snprintf(data + i * 2, 3, "%02x", value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Let go of memory mutex
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&memory_mutex); |
|
|
|
|
|
|
|
|
|
|
|
gdbstub_send_packet(data, length * 2); |
|
|
|
gdbstub_send_packet(data, length * 2); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(packet[0] == 'M') |
|
|
|
else if(packet[0] == 'M') |
|
|
@ -260,6 +266,9 @@ void gdbstub_thread_gdb() |
|
|
|
data_start++; |
|
|
|
data_start++; |
|
|
|
data_start++; |
|
|
|
data_start++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Aquire memory mutex
|
|
|
|
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < length; i++) |
|
|
|
for(size_t i = 0; i < length; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint32_t value; |
|
|
|
uint32_t value; |
|
|
@ -267,6 +276,9 @@ void gdbstub_thread_gdb() |
|
|
|
memory[mmu_translate(address + i)] = value; |
|
|
|
memory[mmu_translate(address + i)] = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Let go of memory mutex
|
|
|
|
|
|
|
|
pthread_mutex_unlock(&memory_mutex); |
|
|
|
|
|
|
|
|
|
|
|
gdbstub_send_packet("OK", 2); |
|
|
|
gdbstub_send_packet("OK", 2); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(packet[0] == 's') |
|
|
|
else if(packet[0] == 's') |
|
|
|