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

View File

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

View File

@ -5,17 +5,21 @@
// Originally written by Sven Peter <sven@fail0verflow.com> for anergistic. // Originally written by Sven Peter <sven@fail0verflow.com> for anergistic.
#include <signal.h> #include <signal.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#ifdef _WIN32 #ifdef _WIN32
#include <WinSock2.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
typedef SSIZE_T ssize_t;
#define SHUT_RDWR SD_BOTH
#else #else
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include <unistd.h>
#endif #endif
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
@ -108,7 +112,7 @@ static u8 gdb_read_byte()
{ {
u8 c = '+'; 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) if (res != 1)
{ {
ERROR_LOG_FMT(GDB_STUB, "recv failed : {}", res); 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); memset(cmd_bfr, 0, sizeof cmd_bfr);
cmd_len = strlen(reply); cmd_len = (u32)strlen(reply);
if (cmd_len + 4 > sizeof cmd_bfr) if (cmd_len + 4 > sizeof cmd_bfr)
ERROR_LOG_FMT(GDB_STUB, "cmd_bfr overflow in gdb_reply"); 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()); 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; u32 left = cmd_len + 4;
while (left > 0) while (left > 0)
{ {
@ -427,41 +431,46 @@ static void gdb_read_register()
id |= hex2char(cmd_bfr[2]); id |= hex2char(cmd_bfr[2]);
} }
switch (id) if (id < 32)
{ {
case 0 ... 31:
wbe32hex(reply, GPR(id)); wbe32hex(reply, GPR(id));
break; }
case 32 ... 63: else if (id >= 32 && id < 64)
{
wbe64hex(reply, rPS(id - 32).PS0AsU64()); wbe64hex(reply, rPS(id - 32).PS0AsU64());
break; }
case 64: else
wbe32hex(reply, PC); {
break; switch (id)
case 65: {
wbe32hex(reply, MSR.Hex); case 64:
break; wbe32hex(reply, PC);
case 66: break;
wbe32hex(reply, PowerPC::ppcState.cr.Get()); case 65:
break; wbe32hex(reply, MSR.Hex);
case 67: break;
wbe32hex(reply, LR); case 66:
break; wbe32hex(reply, PowerPC::ppcState.cr.Get());
case 68: break;
wbe32hex(reply, CTR); case 67:
break; wbe32hex(reply, LR);
case 69: break;
wbe32hex(reply, PowerPC::ppcState.spr[SPR_XER]); case 68:
break; wbe32hex(reply, CTR);
case 70: break;
wbe32hex(reply, 0x0BADC0DE); case 69:
break; wbe32hex(reply, PowerPC::ppcState.spr[SPR_XER]);
case 71: break;
wbe32hex(reply, FPSCR.Hex); case 70:
break; wbe32hex(reply, 0x0BADC0DE);
default: break;
return gdb_reply("E01"); case 71:
break; wbe32hex(reply, FPSCR.Hex);
break;
default:
return gdb_reply("E01");
break;
}
} }
gdb_reply((char*)reply); gdb_reply((char*)reply);
@ -512,41 +521,46 @@ static void gdb_write_register()
id |= hex2char(cmd_bfr[2]); id |= hex2char(cmd_bfr[2]);
} }
switch (id) if (id < 32)
{ {
case 0 ... 31:
GPR(id) = re32hex(bufptr); GPR(id) = re32hex(bufptr);
break; }
case 32 ... 63: else if (id >= 32 && id < 64)
{
rPS(id - 32).SetPS0(re64hex(bufptr)); rPS(id - 32).SetPS0(re64hex(bufptr));
break; }
case 64: else
PC = re32hex(bufptr); {
break; switch (id)
case 65: {
MSR.Hex = re32hex(bufptr); case 64:
break; PC = re32hex(bufptr);
case 66: break;
PowerPC::ppcState.cr.Set(re32hex(bufptr)); case 65:
break; MSR.Hex = re32hex(bufptr);
case 67: break;
LR = re32hex(bufptr); case 66:
break; PowerPC::ppcState.cr.Set(re32hex(bufptr));
case 68: break;
CTR = re32hex(bufptr); case 67:
break; LR = re32hex(bufptr);
case 69: break;
PowerPC::ppcState.spr[SPR_XER] = re32hex(bufptr); case 68:
break; CTR = re32hex(bufptr);
case 70: break;
// do nothing, we dont have MQ case 69:
break; PowerPC::ppcState.spr[SPR_XER] = re32hex(bufptr);
case 71: break;
FPSCR.Hex = re32hex(bufptr); case 70:
break; // do nothing, we dont have MQ
default: break;
return gdb_reply("E01"); case 71:
break; FPSCR.Hex = re32hex(bufptr);
break;
default:
return gdb_reply("E01");
break;
}
} }
gdb_reply("OK"); 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"); ERROR_LOG_FMT(GDB_STUB, "Failed to create gdb socket");
int on = 1; 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"); ERROR_LOG_FMT(GDB_STUB, "Failed to setsockopt");
if (bind(tmpsock, server_addr, server_addrlen) < 0) 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"); ERROR_LOG_FMT(GDB_STUB, "Failed to accept gdb client");
INFO_LOG_FMT(GDB_STUB, "Client connected."); INFO_LOG_FMT(GDB_STUB, "Client connected.");
#ifdef _WIN32
closesocket(tmpsock);
#else
close(tmpsock); close(tmpsock);
#endif
tmpsock = -1; tmpsock = -1;
} }

View File

@ -8,7 +8,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#if defined(_WIN32) || !defined(MSG_WAITALL) #ifndef MSG_WAITALL
#define MSG_WAITALL (8) #define MSG_WAITALL (8)
#endif #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)'=='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)'=='ARM64'">_ARCH_64=1;_M_ARM_64=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">HAVE_FFMPEG;%(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. Make sure we include a clean version of windows.h.
--> -->