mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
msbuild: enable USE_GDBSTUB
this does nothing about it actually being usable
This commit is contained in:
@ -5,17 +5,21 @@
|
||||
// Originally written by Sven Peter <sven@fail0verflow.com> for anergistic.
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <iphlpapi.h>
|
||||
#include <ws2tcpip.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
@ -108,7 +112,7 @@ static u8 gdb_read_byte()
|
||||
{
|
||||
u8 c = '+';
|
||||
|
||||
const ssize_t res = recv(sock, &c, 1, MSG_WAITALL);
|
||||
const ssize_t res = recv(sock, (char*)&c, 1, MSG_WAITALL);
|
||||
if (res != 1)
|
||||
{
|
||||
ERROR_LOG_FMT(GDB_STUB, "recv failed : {}", res);
|
||||
@ -319,7 +323,7 @@ static void gdb_reply(const char* reply)
|
||||
|
||||
memset(cmd_bfr, 0, sizeof cmd_bfr);
|
||||
|
||||
cmd_len = strlen(reply);
|
||||
cmd_len = (u32)strlen(reply);
|
||||
if (cmd_len + 4 > sizeof cmd_bfr)
|
||||
ERROR_LOG_FMT(GDB_STUB, "cmd_bfr overflow in gdb_reply");
|
||||
|
||||
@ -335,7 +339,7 @@ static void gdb_reply(const char* reply)
|
||||
|
||||
DEBUG_LOG_FMT(GDB_STUB, "gdb: reply (len: {}): {}", cmd_len, CommandBufferAsString());
|
||||
|
||||
u8* ptr = cmd_bfr;
|
||||
const char* ptr = (const char*)cmd_bfr;
|
||||
u32 left = cmd_len + 4;
|
||||
while (left > 0)
|
||||
{
|
||||
@ -427,41 +431,46 @@ static void gdb_read_register()
|
||||
id |= hex2char(cmd_bfr[2]);
|
||||
}
|
||||
|
||||
switch (id)
|
||||
if (id < 32)
|
||||
{
|
||||
case 0 ... 31:
|
||||
wbe32hex(reply, GPR(id));
|
||||
break;
|
||||
case 32 ... 63:
|
||||
}
|
||||
else if (id >= 32 && id < 64)
|
||||
{
|
||||
wbe64hex(reply, rPS(id - 32).PS0AsU64());
|
||||
break;
|
||||
case 64:
|
||||
wbe32hex(reply, PC);
|
||||
break;
|
||||
case 65:
|
||||
wbe32hex(reply, MSR.Hex);
|
||||
break;
|
||||
case 66:
|
||||
wbe32hex(reply, PowerPC::ppcState.cr.Get());
|
||||
break;
|
||||
case 67:
|
||||
wbe32hex(reply, LR);
|
||||
break;
|
||||
case 68:
|
||||
wbe32hex(reply, CTR);
|
||||
break;
|
||||
case 69:
|
||||
wbe32hex(reply, PowerPC::ppcState.spr[SPR_XER]);
|
||||
break;
|
||||
case 70:
|
||||
wbe32hex(reply, 0x0BADC0DE);
|
||||
break;
|
||||
case 71:
|
||||
wbe32hex(reply, FPSCR.Hex);
|
||||
break;
|
||||
default:
|
||||
return gdb_reply("E01");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 64:
|
||||
wbe32hex(reply, PC);
|
||||
break;
|
||||
case 65:
|
||||
wbe32hex(reply, MSR.Hex);
|
||||
break;
|
||||
case 66:
|
||||
wbe32hex(reply, PowerPC::ppcState.cr.Get());
|
||||
break;
|
||||
case 67:
|
||||
wbe32hex(reply, LR);
|
||||
break;
|
||||
case 68:
|
||||
wbe32hex(reply, CTR);
|
||||
break;
|
||||
case 69:
|
||||
wbe32hex(reply, PowerPC::ppcState.spr[SPR_XER]);
|
||||
break;
|
||||
case 70:
|
||||
wbe32hex(reply, 0x0BADC0DE);
|
||||
break;
|
||||
case 71:
|
||||
wbe32hex(reply, FPSCR.Hex);
|
||||
break;
|
||||
default:
|
||||
return gdb_reply("E01");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gdb_reply((char*)reply);
|
||||
@ -512,41 +521,46 @@ static void gdb_write_register()
|
||||
id |= hex2char(cmd_bfr[2]);
|
||||
}
|
||||
|
||||
switch (id)
|
||||
if (id < 32)
|
||||
{
|
||||
case 0 ... 31:
|
||||
GPR(id) = re32hex(bufptr);
|
||||
break;
|
||||
case 32 ... 63:
|
||||
}
|
||||
else if (id >= 32 && id < 64)
|
||||
{
|
||||
rPS(id - 32).SetPS0(re64hex(bufptr));
|
||||
break;
|
||||
case 64:
|
||||
PC = re32hex(bufptr);
|
||||
break;
|
||||
case 65:
|
||||
MSR.Hex = re32hex(bufptr);
|
||||
break;
|
||||
case 66:
|
||||
PowerPC::ppcState.cr.Set(re32hex(bufptr));
|
||||
break;
|
||||
case 67:
|
||||
LR = re32hex(bufptr);
|
||||
break;
|
||||
case 68:
|
||||
CTR = re32hex(bufptr);
|
||||
break;
|
||||
case 69:
|
||||
PowerPC::ppcState.spr[SPR_XER] = re32hex(bufptr);
|
||||
break;
|
||||
case 70:
|
||||
// do nothing, we dont have MQ
|
||||
break;
|
||||
case 71:
|
||||
FPSCR.Hex = re32hex(bufptr);
|
||||
break;
|
||||
default:
|
||||
return gdb_reply("E01");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case 64:
|
||||
PC = re32hex(bufptr);
|
||||
break;
|
||||
case 65:
|
||||
MSR.Hex = re32hex(bufptr);
|
||||
break;
|
||||
case 66:
|
||||
PowerPC::ppcState.cr.Set(re32hex(bufptr));
|
||||
break;
|
||||
case 67:
|
||||
LR = re32hex(bufptr);
|
||||
break;
|
||||
case 68:
|
||||
CTR = re32hex(bufptr);
|
||||
break;
|
||||
case 69:
|
||||
PowerPC::ppcState.spr[SPR_XER] = re32hex(bufptr);
|
||||
break;
|
||||
case 70:
|
||||
// do nothing, we dont have MQ
|
||||
break;
|
||||
case 71:
|
||||
FPSCR.Hex = re32hex(bufptr);
|
||||
break;
|
||||
default:
|
||||
return gdb_reply("E01");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
gdb_reply("OK");
|
||||
@ -833,7 +847,7 @@ static void gdb_init_generic(int domain, const sockaddr* server_addr, socklen_t
|
||||
ERROR_LOG_FMT(GDB_STUB, "Failed to create gdb socket");
|
||||
|
||||
int on = 1;
|
||||
if (setsockopt(tmpsock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof on) < 0)
|
||||
if (setsockopt(tmpsock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof on) < 0)
|
||||
ERROR_LOG_FMT(GDB_STUB, "Failed to setsockopt");
|
||||
|
||||
if (bind(tmpsock, server_addr, server_addrlen) < 0)
|
||||
@ -849,7 +863,11 @@ static void gdb_init_generic(int domain, const sockaddr* server_addr, socklen_t
|
||||
ERROR_LOG_FMT(GDB_STUB, "Failed to accept gdb client");
|
||||
INFO_LOG_FMT(GDB_STUB, "Client connected.");
|
||||
|
||||
#ifdef _WIN32
|
||||
closesocket(tmpsock);
|
||||
#else
|
||||
close(tmpsock);
|
||||
#endif
|
||||
tmpsock = -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user