Merge pull request #9431 from shuffle2/msvc-gdbstub

msbuild: enable USE_GDBSTUB
This commit is contained in:
LC 2021-01-10 01:56:46 -05:00 committed by GitHub
commit 59fa613020
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 97 additions and 70 deletions

View File

@ -242,6 +242,7 @@
<ClCompile Include="PowerPC\CachedInterpreter\CachedInterpreter.cpp" />
<ClCompile Include="PowerPC\CachedInterpreter\InterpreterBlockCache.cpp" />
<ClCompile Include="PowerPC\ConditionRegister.cpp" />
<ClCompile Include="PowerPC\GDBStub.cpp" />
<ClCompile Include="PowerPC\Interpreter\Interpreter.cpp" />
<ClCompile Include="PowerPC\Interpreter\Interpreter_Branch.cpp" />
<ClCompile Include="PowerPC\Interpreter\Interpreter_FloatingPoint.cpp" />
@ -600,6 +601,7 @@
<ClInclude Include="PowerPC\CachedInterpreter\CachedInterpreter.h" />
<ClInclude Include="PowerPC\CachedInterpreter\InterpreterBlockCache.h" />
<ClInclude Include="PowerPC\ConditionRegister.h" />
<ClInclude Include="PowerPC\GDBStub.h" />
<ClInclude Include="PowerPC\Interpreter\ExceptionUtils.h" />
<ClInclude Include="PowerPC\Interpreter\Interpreter.h" />
<ClInclude Include="PowerPC\Interpreter\Interpreter_FPUtils.h" />

View File

@ -326,6 +326,9 @@
<ClCompile Include="PowerPC\BreakPoints.cpp">
<Filter>PowerPC</Filter>
</ClCompile>
<ClCompile Include="PowerPC\GDBStub.cpp">
<Filter>PowerPC</Filter>
</ClCompile>
<ClCompile Include="PowerPC\CachedInterpreter\CachedInterpreter.cpp">
<Filter>PowerPC\Cached Interpreter</Filter>
</ClCompile>
@ -1390,6 +1393,9 @@
<ClInclude Include="PowerPC\CPUCoreBase.h">
<Filter>PowerPC</Filter>
</ClInclude>
<ClInclude Include="PowerPC\GDBStub.h">
<Filter>PowerPC</Filter>
</ClInclude>
<ClInclude Include="PowerPC\Gekko.h">
<Filter>PowerPC</Filter>
</ClInclude>

View File

@ -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,14 +431,18 @@ static void gdb_read_register()
id |= hex2char(cmd_bfr[2]);
}
if (id < 32)
{
wbe32hex(reply, GPR(id));
}
else if (id >= 32 && id < 64)
{
wbe64hex(reply, rPS(id - 32).PS0AsU64());
}
else
{
switch (id)
{
case 0 ... 31:
wbe32hex(reply, GPR(id));
break;
case 32 ... 63:
wbe64hex(reply, rPS(id - 32).PS0AsU64());
break;
case 64:
wbe32hex(reply, PC);
break;
@ -463,6 +471,7 @@ static void gdb_read_register()
return gdb_reply("E01");
break;
}
}
gdb_reply((char*)reply);
}
@ -512,14 +521,18 @@ static void gdb_write_register()
id |= hex2char(cmd_bfr[2]);
}
if (id < 32)
{
GPR(id) = re32hex(bufptr);
}
else if (id >= 32 && id < 64)
{
rPS(id - 32).SetPS0(re64hex(bufptr));
}
else
{
switch (id)
{
case 0 ... 31:
GPR(id) = re32hex(bufptr);
break;
case 32 ... 63:
rPS(id - 32).SetPS0(re64hex(bufptr));
break;
case 64:
PC = re32hex(bufptr);
break;
@ -548,6 +561,7 @@ static void gdb_write_register()
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;
}

View File

@ -8,7 +8,7 @@
#include "Common/CommonTypes.h"
#if defined(_WIN32) || !defined(MSG_WAITALL)
#ifndef MSG_WAITALL
#define MSG_WAITALL (8)
#endif

View File

@ -69,6 +69,7 @@
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_ARCH_64=1;_M_X86=1;_M_X86_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='ARM64'">_ARCH_64=1;_M_ARM_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">HAVE_FFMPEG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>USE_GDBSTUB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!--
Make sure we include a clean version of windows.h.
-->