Skip to content

Commit 541af8d

Browse files
committed
GDBServer: Stub out thread commands
1 parent 7bae23d commit 541af8d

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

src/core/cpu_core.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,17 +2363,20 @@ ALWAYS_INLINE_RELEASE bool CPU::CheckBreakpointList(BreakpointType type, Virtual
23632363
{
23642364
System::PauseSystem(true);
23652365

2366+
TinyString msg;
23662367
if (bp.auto_clear)
23672368
{
2368-
Host::ReportDebuggerMessage(fmt::format("Stopped execution at 0x{:08X}.", pc));
2369+
msg.format("Stopped execution at 0x{:08X}.", pc);
2370+
Host::ReportDebuggerMessage(msg);
23692371
bplist.erase(bplist.begin() + i);
23702372
count--;
23712373
UpdateDebugDispatcherFlag();
23722374
}
23732375
else
23742376
{
2375-
Host::ReportDebuggerMessage(fmt::format("Hit {} breakpoint {} at 0x{:08X}, Hit Count {}.",
2376-
GetBreakpointTypeName(type), bp.number, address, bp.hit_count));
2377+
msg.format("Hit {} breakpoint {} at 0x{:08X}, Hit Count {}.", GetBreakpointTypeName(type), bp.number, address,
2378+
bp.hit_count);
2379+
Host::ReportDebuggerMessage(msg);
23772380
i++;
23782381
}
23792382

src/core/gdb_server.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ LOG_CHANNEL(GDBServer);
2222
namespace GDBServer {
2323

2424
namespace {
25+
2526
class ClientSocket final : public BufferedStreamSocket
2627
{
2728
public:
@@ -43,13 +44,15 @@ class ClientSocket final : public BufferedStreamSocket
4344

4445
bool m_seen_resume = false;
4546
};
47+
4648
} // namespace
4749

4850
static u8 ComputeChecksum(std::string_view str);
4951

5052
static bool Cmd$_questionMark(ClientSocket* client, std::string_view data);
5153
static bool Cmd$g(ClientSocket* client, std::string_view data);
5254
static bool Cmd$G(ClientSocket* client, std::string_view data);
55+
static bool Cmd$H(ClientSocket* client, std::string_view data);
5356
static bool Cmd$m(ClientSocket* client, std::string_view data);
5457
static bool Cmd$M(ClientSocket* client, std::string_view data);
5558
static bool Cmd$s(ClientSocket* client, std::string_view data);
@@ -69,10 +72,10 @@ static bool ProcessPacket(ClientSocket* socket, std::string_view data);
6972
using LargeReplyPacket = SmallStackString<768>;
7073

7174
/// Number of registers in GDB remote protocol for MIPS III.
72-
constexpr int NUM_GDB_REGISTERS = 73;
75+
static constexpr int NUM_GDB_REGISTERS = 73;
7376

7477
/// List of GDB remote protocol registers for MIPS III (excluding FP).
75-
static const std::array<u32*, 38> REGISTERS{
78+
static constexpr std::array<u32*, 38> REGISTERS{
7679
&CPU::g_state.regs.r[0],
7780
&CPU::g_state.regs.r[1],
7881
&CPU::g_state.regs.r[2],
@@ -119,6 +122,7 @@ static constexpr std::pair<std::string_view, bool (*)(ClientSocket*, std::string
119122
{"?", Cmd$_questionMark},
120123
{"g", Cmd$g},
121124
{"G", Cmd$G},
125+
{"H", Cmd$H},
122126
{"m", Cmd$m},
123127
{"M", Cmd$M},
124128
{"s", Cmd$s},
@@ -203,6 +207,14 @@ bool GDBServer::Cmd$G(ClientSocket* client, std::string_view data)
203207
return true;
204208
}
205209

210+
/// Thread operations, ignored.
211+
bool GDBServer::Cmd$H(ClientSocket* client, std::string_view data)
212+
{
213+
WARNING_LOG("Ignoring thread command '{}'", data);
214+
client->SendReplyWithAck("OK");
215+
return true;
216+
}
217+
206218
/// Get memory.
207219
bool GDBServer::Cmd$m(ClientSocket* client, std::string_view data)
208220
{
@@ -499,8 +511,7 @@ void GDBServer::ClientSocket::OnRead()
499511
}
500512
else if (GDBServer::IsPacketComplete(current_packet))
501513
{
502-
// TODO: Make this not copy.
503-
DEV_LOG("{} > {}", GetRemoteAddress().ToString(), current_packet);
514+
DEBUG_LOG("{} > {}", GetRemoteAddress().ToString(), current_packet);
504515
if (!ProcessPacket(this, current_packet))
505516
SendPacket("-");
506517

@@ -530,7 +541,7 @@ void GDBServer::ClientSocket::SendPacket(std::string_view sv)
530541
if (sv.empty())
531542
return;
532543

533-
WARNING_LOG("Write: {}", sv);
544+
DEBUG_LOG("Send reply: {}", sv);
534545
if (size_t written = Write(sv.data(), sv.length()); written != sv.length())
535546
ERROR_LOG("Only wrote {} of {} bytes.", written, sv.length());
536547
}
@@ -543,7 +554,7 @@ void GDBServer::ClientSocket::OnSystemPaused()
543554
m_seen_resume = false;
544555

545556
// Generate a stop reply packet, insert '?' command to generate it.
546-
GDBServer::ProcessPacket(this, "$?#3f");
557+
SendReplyWithAck("S00");
547558
}
548559

549560
void GDBServer::ClientSocket::OnSystemResumed()

src/duckstation-qt/qthost.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,7 @@ bool Host::CopyTextToClipboard(std::string_view text)
21402140

21412141
void Host::ReportDebuggerMessage(std::string_view message)
21422142
{
2143+
INFO_LOG("Debugger message: {}", message);
21432144
emit g_emu_thread->debuggerMessageReported(QString::fromUtf8(message));
21442145
}
21452146

0 commit comments

Comments
 (0)