@@ -22,6 +22,7 @@ LOG_CHANNEL(GDBServer);
2222namespace GDBServer {
2323
2424namespace {
25+
2526class ClientSocket final : public BufferedStreamSocket
2627{
2728public:
@@ -43,13 +44,15 @@ class ClientSocket final : public BufferedStreamSocket
4344
4445 bool m_seen_resume = false ;
4546};
47+
4648} // namespace
4749
4850static u8 ComputeChecksum (std::string_view str);
4951
5052static bool Cmd$_questionMark(ClientSocket* client, std::string_view data);
5153static bool Cmd$g(ClientSocket* client, std::string_view data);
5254static bool Cmd$G(ClientSocket* client, std::string_view data);
55+ static bool Cmd$H(ClientSocket* client, std::string_view data);
5356static bool Cmd$m(ClientSocket* client, std::string_view data);
5457static bool Cmd$M(ClientSocket* client, std::string_view data);
5558static bool Cmd$s(ClientSocket* client, std::string_view data);
@@ -69,10 +72,10 @@ static bool ProcessPacket(ClientSocket* socket, std::string_view data);
6972using 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.
207219bool 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
549560void GDBServer::ClientSocket::OnSystemResumed ()
0 commit comments