hopefully fixes Windows CI
This commit is contained in:
24
external/gdbstub/gdbstub.h
vendored
24
external/gdbstub/gdbstub.h
vendored
@@ -27,7 +27,7 @@
|
|||||||
#ifndef GDBSTUB_H
|
#ifndef GDBSTUB_H
|
||||||
#define GDBSTUB_H
|
#define GDBSTUB_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
typedef void (*gdbstub_connected_t)(void * user_data);
|
typedef void (*gdbstub_connected_t)(void * user_data);
|
||||||
@@ -37,9 +37,9 @@ typedef void (*gdbstub_stop_t)(void * user_data);
|
|||||||
typedef void (*gdbstub_step_t)(void * user_data);
|
typedef void (*gdbstub_step_t)(void * user_data);
|
||||||
typedef void (*gdbstub_set_breakpoint_t)(void * user_data, uint32_t address);
|
typedef void (*gdbstub_set_breakpoint_t)(void * user_data, uint32_t address);
|
||||||
typedef void (*gdbstub_clear_breakpoint_t)(void * user_data, uint32_t address);
|
typedef void (*gdbstub_clear_breakpoint_t)(void * user_data, uint32_t address);
|
||||||
typedef ssize_t (*gdbstub_get_memory_t)(void * user_data, char * buffer, size_t buffer_length, uint32_t address, size_t length);
|
typedef size_t (*gdbstub_get_memory_t)(void * user_data, char * buffer, size_t buffer_length, uint32_t address, size_t length);
|
||||||
typedef ssize_t (*gdbstub_get_register_value_t)(void * user_data, char * buffer, size_t buffer_length, int reg);
|
typedef size_t (*gdbstub_get_register_value_t)(void * user_data, char * buffer, size_t buffer_length, int reg);
|
||||||
typedef ssize_t (*gdbstub_get_general_registers_t)(void * user_data, char * buffer, size_t buffer_length);
|
typedef size_t (*gdbstub_get_general_registers_t)(void * user_data, char * buffer, size_t buffer_length);
|
||||||
|
|
||||||
typedef struct gdbstub_config gdbstub_config_t;
|
typedef struct gdbstub_config gdbstub_config_t;
|
||||||
|
|
||||||
@@ -90,12 +90,12 @@ void gdbstub_breakpoint_hit(gdbstub_t * gdb);
|
|||||||
|
|
||||||
#ifdef GDBSTUB_IMPLEMENTATION
|
#ifdef GDBSTUB_IMPLEMENTATION
|
||||||
|
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
@@ -127,15 +127,15 @@ struct gdbstub
|
|||||||
int client;
|
int client;
|
||||||
|
|
||||||
char buffer[GDBSTUB_BUFFER_LENGTH];
|
char buffer[GDBSTUB_BUFFER_LENGTH];
|
||||||
ssize_t buffer_length;
|
size_t buffer_length;
|
||||||
|
|
||||||
gdbstate_t state;
|
gdbstate_t state;
|
||||||
char packet[GDBSTUB_BUFFER_LENGTH];
|
char packet[GDBSTUB_BUFFER_LENGTH];
|
||||||
ssize_t packet_length;
|
size_t packet_length;
|
||||||
uint8_t packet_checksum;
|
uint8_t packet_checksum;
|
||||||
|
|
||||||
char checksum[2];
|
char checksum[2];
|
||||||
ssize_t checksum_length;
|
size_t checksum_length;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ void _gdbstub_recv(gdbstub_t * gdb)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ssize_t i = 0; i < gdb->buffer_length; ++i) {
|
for (size_t i = 0; i < gdb->buffer_length; ++i) {
|
||||||
char c = gdb->buffer[i];
|
char c = gdb->buffer[i];
|
||||||
|
|
||||||
switch (gdb->state)
|
switch (gdb->state)
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ file(REMOVE
|
|||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_compile_definitions(gadolinium PUBLIC NOMINMAX _CRT_SECURE_NO_WARNINGS)
|
target_compile_definitions(gadolinium PUBLIC NOMINMAX _CRT_SECURE_NO_WARNINGS)
|
||||||
target_compile_options(gadolinium PUBLIC /EHa)
|
target_compile_options(gadolinium PUBLIC /EHa)
|
||||||
|
target_link_libraries(gadolinium PUBLIC ws2_32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${CMAKE_BUILD_TYPE} MATCHES Release)
|
if(${CMAKE_BUILD_TYPE} MATCHES Release)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ void Core::Run(Window& window, float volumeL, float volumeR) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(debugger.enabled && romLoaded && !pause)
|
if(debugger.enabled)
|
||||||
debugger.tick();
|
debugger.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <backend/core/Dynarec.hpp>
|
#include <backend/core/Dynarec.hpp>
|
||||||
#include <backend/core/registers/Registers.hpp>
|
#include <backend/core/registers/Registers.hpp>
|
||||||
#include <Debugger.hpp>
|
#include <Debugger.hpp>
|
||||||
|
#include <SDL_timer.h>
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ struct Core {
|
|||||||
core.debugger.breakpointHit();
|
core.debugger.breakpointHit();
|
||||||
}
|
}
|
||||||
while (core.debugger.broken) {
|
while (core.debugger.broken) {
|
||||||
usleep(1000);
|
SDL_Delay(1);
|
||||||
core.debugger.tick();
|
core.debugger.tick();
|
||||||
}
|
}
|
||||||
switch(core.cpuType) {
|
switch(core.cpuType) {
|
||||||
|
|||||||
@@ -110,17 +110,17 @@ const char* memory_map =
|
|||||||
"<memory type=\"rom\" start=\"0xffffffffbfc00000\" length=\"0x7c0\"/>" // PIF ROM
|
"<memory type=\"rom\" start=\"0xffffffffbfc00000\" length=\"0x7c0\"/>" // PIF ROM
|
||||||
"</memory-map>";
|
"</memory-map>";
|
||||||
|
|
||||||
void n64_debug_start(void* user_data) {
|
void debugStart(void* user_data) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
debugger->broken = false;
|
debugger->broken = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void n64_debug_stop(void* user_data) {
|
void debugStop(void* user_data) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
debugger->broken = true;
|
debugger->broken = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void n64_debug_step(void* user_data) {
|
void debugStep(void* user_data) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
bool old_broken = debugger->broken;
|
bool old_broken = debugger->broken;
|
||||||
debugger->broken = false;
|
debugger->broken = false;
|
||||||
@@ -129,7 +129,7 @@ void n64_debug_step(void* user_data) {
|
|||||||
debugger->steps += 2;
|
debugger->steps += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void n64_debug_set_breakpoint(void* user_data, u32 address) {
|
void debugSetBreakpoint(void* user_data, u32 address) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
auto* breakpoint = (Breakpoint*)malloc(sizeof(Breakpoint));
|
auto* breakpoint = (Breakpoint*)malloc(sizeof(Breakpoint));
|
||||||
breakpoint->address = address;
|
breakpoint->address = address;
|
||||||
@@ -149,7 +149,7 @@ void n64_debug_set_breakpoint(void* user_data, u32 address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void n64_debug_clear_breakpoint(void* user_data, u32 address) {
|
void debugClearBreakpoint(void* user_data, u32 address) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
if (debugger->breakpoints == nullptr) {
|
if (debugger->breakpoints == nullptr) {
|
||||||
return; // No breakpoints set at all
|
return; // No breakpoints set at all
|
||||||
@@ -171,7 +171,7 @@ void n64_debug_clear_breakpoint(void* user_data, u32 address) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t n64_debug_get_memory(void* user_data, char* buffer, size_t length, u32 address, size_t bytes) {
|
size_t debugGetMemory(void* user_data, char* buffer, size_t length, u32 address, size_t bytes) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
printf("Checking memory at address 0x%08X\n", address);
|
printf("Checking memory at address 0x%08X\n", address);
|
||||||
int printed = 0;
|
int printed = 0;
|
||||||
@@ -188,7 +188,7 @@ ssize_t n64_debug_get_memory(void* user_data, char* buffer, size_t length, u32 a
|
|||||||
return printed + 1;
|
return printed + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t n64_debug_get_register_value(void* user_data, char * buffer, size_t buffer_length, int reg) {
|
size_t debugGetRegisterValue(void* user_data, char * buffer, size_t buffer_length, int reg) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
switch (reg) {
|
switch (reg) {
|
||||||
case 0 ... 31:
|
case 0 ... 31:
|
||||||
@@ -204,7 +204,7 @@ ssize_t n64_debug_get_register_value(void* user_data, char * buffer, size_t buff
|
|||||||
case 36:
|
case 36:
|
||||||
return snprintf(buffer, buffer_length, "%08x", debugger->core.CpuGetRegs().cop0.cause.raw);
|
return snprintf(buffer, buffer_length, "%08x", debugger->core.CpuGetRegs().cop0.cause.raw);
|
||||||
case 37:
|
case 37:
|
||||||
printf("Sending PC: 0x%016lX\n", debugger->core.CpuGetRegs().pc);
|
//printf("Sending PC: 0x%016lX\n", debugger->core.CpuGetRegs().pc);
|
||||||
return snprintf(buffer, buffer_length, "%016lx", debugger->core.CpuGetRegs().pc);
|
return snprintf(buffer, buffer_length, "%016lx", debugger->core.CpuGetRegs().pc);
|
||||||
case 38 ... 71: // TODO FPU stuff
|
case 38 ... 71: // TODO FPU stuff
|
||||||
return snprintf(buffer, buffer_length, "%08x", 0);
|
return snprintf(buffer, buffer_length, "%08x", 0);
|
||||||
@@ -213,10 +213,10 @@ ssize_t n64_debug_get_register_value(void* user_data, char * buffer, size_t buff
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t n64_debug_get_general_registers(void* user_data, char * buffer, size_t buffer_length) {
|
size_t debugGetGeneralRegisters(void* user_data, char * buffer, size_t buffer_length) {
|
||||||
auto* debugger = (Debugger*)user_data;
|
auto* debugger = (Debugger*)user_data;
|
||||||
printf("The buffer length is %ld!\n", buffer_length);
|
printf("The buffer length is %ld!\n", buffer_length);
|
||||||
ssize_t printed = 0;
|
size_t printed = 0;
|
||||||
for (int i = 0; i < 32; i++) {
|
for (int i = 0; i < 32; i++) {
|
||||||
int ofs = i * 16; // 64 bit regs take up 16 ascii chars to print in hex
|
int ofs = i * 16; // 64 bit regs take up 16 ascii chars to print in hex
|
||||||
if (ofs + 16 > buffer_length) {
|
if (ofs + 16 > buffer_length) {
|
||||||
@@ -233,14 +233,14 @@ Debugger::Debugger(n64::Core& core) : core(core) {
|
|||||||
memset(&config, 0, sizeof(gdbstub_config_t));
|
memset(&config, 0, sizeof(gdbstub_config_t));
|
||||||
config.port = 1337;
|
config.port = 1337;
|
||||||
config.user_data = this;
|
config.user_data = this;
|
||||||
config.start = (gdbstub_start_t) n64_debug_start;
|
config.start = (gdbstub_start_t) debugStart;
|
||||||
config.stop = (gdbstub_stop_t) n64_debug_stop;
|
config.stop = (gdbstub_stop_t) debugStop;
|
||||||
config.step = (gdbstub_step_t) n64_debug_step;
|
config.step = (gdbstub_step_t) debugStep;
|
||||||
config.set_breakpoint = (gdbstub_set_breakpoint_t) n64_debug_set_breakpoint;
|
config.set_breakpoint = (gdbstub_set_breakpoint_t) debugSetBreakpoint;
|
||||||
config.clear_breakpoint = (gdbstub_clear_breakpoint_t) n64_debug_clear_breakpoint;
|
config.clear_breakpoint = (gdbstub_clear_breakpoint_t) debugClearBreakpoint;
|
||||||
config.get_memory = (gdbstub_get_memory_t) n64_debug_get_memory;
|
config.get_memory = (gdbstub_get_memory_t) debugGetMemory;
|
||||||
config.get_register_value = (gdbstub_get_register_value_t) n64_debug_get_register_value;
|
config.get_register_value = (gdbstub_get_register_value_t) debugGetRegisterValue;
|
||||||
config.get_general_registers = (gdbstub_get_general_registers_t) n64_debug_get_general_registers;
|
config.get_general_registers = (gdbstub_get_general_registers_t) debugGetGeneralRegisters;
|
||||||
|
|
||||||
config.target_config = target_xml;
|
config.target_config = target_xml;
|
||||||
config.target_config_length = strlen(target_xml);
|
config.target_config_length = strlen(target_xml);
|
||||||
|
|||||||
Reference in New Issue
Block a user