Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static const seconds kWakeupInterval(5);
GDBRemoteClientBase::ContinueDelegate::~ContinueDelegate() = default;

GDBRemoteClientBase::GDBRemoteClientBase(const char *comm_name)
: GDBRemoteCommunication(), Broadcaster(nullptr, comm_name),
: GDBRemoteCommunication(comm_name), Broadcaster(nullptr, comm_name),
m_async_count(0), m_is_running(false), m_should_stop(false) {}

StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
Expand Down
38 changes: 18 additions & 20 deletions lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;

// GDBRemoteCommunication constructor
GDBRemoteCommunication::GDBRemoteCommunication()
GDBRemoteCommunication::GDBRemoteCommunication(llvm::StringRef name)
: Communication(),
#ifdef LLDB_CONFIGURATION_DEBUG
m_packet_timeout(1000),
Expand All @@ -68,7 +68,7 @@ GDBRemoteCommunication::GDBRemoteCommunication()
#endif
m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512),
m_send_acks(true), m_is_platform(false),
m_compression_type(CompressionType::None), m_listen_url() {
m_compression_type(CompressionType::None), m_listen_url(), m_name(name) {
}

// Destructor
Expand Down Expand Up @@ -97,7 +97,7 @@ size_t GDBRemoteCommunication::SendAck() {
ConnectionStatus status = eConnectionStatusSuccess;
char ch = '+';
const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
LLDB_LOGF(log, "%p <%4" PRIu64 "> send packet: %c", static_cast<void *>(this),
LLDB_LOGF(log, "%s <%4" PRIu64 "> send packet: %c", m_name.c_str(),
(uint64_t)bytes_written, ch);
m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
return bytes_written;
Expand All @@ -108,7 +108,7 @@ size_t GDBRemoteCommunication::SendNack() {
ConnectionStatus status = eConnectionStatusSuccess;
char ch = '-';
const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
LLDB_LOGF(log, "%p <%4" PRIu64 "> send packet: %c", static_cast<void *>(this),
LLDB_LOGF(log, "%s <%4" PRIu64 "> send packet: %c", m_name.c_str(),
(uint64_t)bytes_written, ch);
m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
return bytes_written;
Expand Down Expand Up @@ -180,9 +180,9 @@ GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef packet,
if (binary_start_offset) {
StreamString strm;
// Print non binary data header
strm.Printf("%p <%4" PRIu64 "> send packet: %.*s",
static_cast<void *>(this), (uint64_t)bytes_written,
(int)binary_start_offset, packet_data);
strm.Printf("%s <%4" PRIu64 "> send packet: %.*s", m_name.c_str(),
(uint64_t)bytes_written, (int)binary_start_offset,
packet_data);
const uint8_t *p;
// Print binary data exactly as sent
for (p = (const uint8_t *)packet_data + binary_start_offset; *p != '#';
Expand All @@ -192,9 +192,8 @@ GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef packet,
strm.Printf("%*s", (int)3, p);
log->PutString(strm.GetString());
} else
LLDB_LOGF(log, "%p <%4" PRIu64 "> send packet: %.*s",
static_cast<void *>(this), (uint64_t)bytes_written,
(int)packet_length, packet_data);
LLDB_LOGF(log, "%s <%4" PRIu64 "> send packet: %.*s", m_name.c_str(),
(uint64_t)bytes_written, (int)packet_length, packet_data);
}

m_history.AddPacket(packet.str(), packet_length,
Expand Down Expand Up @@ -753,13 +752,12 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
StreamString strm;
// Packet header...
if (CompressionIsEnabled())
strm.Printf("%p <%4" PRIu64 ":%" PRIu64 "> read packet: %c",
static_cast<void *>(this), (uint64_t)original_packet_size,
strm.Printf("%s <%4" PRIu64 ":%" PRIu64 "> read packet: %c",
m_name.c_str(), (uint64_t)original_packet_size,
(uint64_t)total_length, m_bytes[0]);
else
strm.Printf("%p <%4" PRIu64 "> read packet: %c",
static_cast<void *>(this), (uint64_t)total_length,
m_bytes[0]);
strm.Printf("%s <%4" PRIu64 "> read packet: %c", m_name.c_str(),
(uint64_t)total_length, m_bytes[0]);
for (size_t i = content_start; i < content_end; ++i) {
// Remove binary escaped bytes when displaying the packet...
const char ch = m_bytes[i];
Expand All @@ -778,13 +776,13 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
log->PutString(strm.GetString());
} else {
if (CompressionIsEnabled())
LLDB_LOGF(log, "%p <%4" PRIu64 ":%" PRIu64 "> read packet: %.*s",
static_cast<void *>(this), (uint64_t)original_packet_size,
(uint64_t)total_length, (int)(total_length),
LLDB_LOGF(log, "%s <%4" PRIu64 ":%" PRIu64 "> read packet: %.*s",
m_name.c_str(), (uint64_t)original_packet_size,
(uint64_t)total_length, (int)(total_length),
m_bytes.c_str());
else
LLDB_LOGF(log, "%p <%4" PRIu64 "> read packet: %.*s",
static_cast<void *>(this), (uint64_t)total_length,
LLDB_LOGF(log, "%s <%4" PRIu64 "> read packet: %.*s",
m_name.c_str(), (uint64_t)total_length,
(int)(total_length), m_bytes.c_str());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ class GDBRemoteCommunication : public Communication {
bool m_timeout_modified;
};

GDBRemoteCommunication();
/// \param[in] name
/// The name of the communication channel.
GDBRemoteCommunication(llvm::StringRef name);

~GDBRemoteCommunication() override;

Expand Down Expand Up @@ -227,6 +229,8 @@ class GDBRemoteCommunication : public Communication {
HostThread m_listen_thread;
std::string m_listen_url;

std::string m_name;

#if defined(HAVE_LIBCOMPRESSION)
CompressionType m_decompression_scratch_type = CompressionType::None;
void *m_decompression_scratch = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
using namespace llvm;

GDBRemoteCommunicationServer::GDBRemoteCommunicationServer()
: GDBRemoteCommunication(), m_exit_now(false) {
GDBRemoteCommunicationServer::GDBRemoteCommunicationServer(llvm::StringRef name)
: GDBRemoteCommunication(name), m_exit_now(false) {
RegisterPacketHandler(
StringExtractorGDBRemote::eServerPacketType_QEnableErrorStrings,
[this](StringExtractorGDBRemote packet, Status &error, bool &interrupt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class GDBRemoteCommunicationServer : public GDBRemoteCommunication {
std::function<PacketResult(StringExtractorGDBRemote &packet,
Status &error, bool &interrupt, bool &quit)>;

GDBRemoteCommunicationServer();
/// \param[in] name
/// The name of the communication channel.
GDBRemoteCommunicationServer(llvm::StringRef name);

~GDBRemoteCommunicationServer() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ const static uint32_t g_default_packet_timeout_sec = 0; // not specified
#endif

// GDBRemoteCommunicationServerCommon constructor
GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon()
: GDBRemoteCommunicationServer(), m_process_launch_info(),
GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon(
llvm::StringRef name)
: GDBRemoteCommunicationServer(name), m_process_launch_info(),
m_process_launch_error(), m_proc_infos(), m_proc_infos_index(0) {
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_A,
&GDBRemoteCommunicationServerCommon::Handle_A);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class ProcessGDBRemote;

class GDBRemoteCommunicationServerCommon : public GDBRemoteCommunicationServer {
public:
GDBRemoteCommunicationServerCommon();
/// \param[in] name
/// The name of the communication channel.
GDBRemoteCommunicationServerCommon(llvm::StringRef name);

~GDBRemoteCommunicationServerCommon() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ enum GDBRemoteServerError {

// GDBRemoteCommunicationServerLLGS constructor
GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(
MainLoop &mainloop, NativeProcessProtocol::Manager &process_manager)
: GDBRemoteCommunicationServerCommon(), m_mainloop(mainloop),
MainLoop &mainloop, NativeProcessProtocol::Manager &process_manager,
llvm::StringRef name)
: GDBRemoteCommunicationServerCommon(name), m_mainloop(mainloop),
m_process_manager(process_manager), m_current_process(nullptr),
m_continue_process(nullptr), m_stdio_communication() {
RegisterPacketHandlers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ class GDBRemoteCommunicationServerLLGS
: public GDBRemoteCommunicationServerCommon,
public NativeProcessProtocol::NativeDelegate {
public:
// Constructors and Destructors
/// \param[in] mainloop
/// The main loop.
/// \param[in] process_manager
/// The process manager.
/// \param[in] name
/// The name of the communication channel.
GDBRemoteCommunicationServerLLGS(
MainLoop &mainloop, NativeProcessProtocol::Manager &process_manager);
MainLoop &mainloop, NativeProcessProtocol::Manager &process_manager,
llvm::StringRef name);

void SetLaunchInfo(const ProcessLaunchInfo &info);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ using namespace lldb_private;
// GDBRemoteCommunicationServerPlatform constructor
GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
const Socket::SocketProtocol socket_protocol, uint16_t gdbserver_port)
: GDBRemoteCommunicationServerCommon(), m_socket_protocol(socket_protocol),
m_gdbserver_port(gdbserver_port) {
: GDBRemoteCommunicationServerCommon("gdb-server-platform"),
m_socket_protocol(socket_protocol), m_gdbserver_port(gdbserver_port) {

RegisterMemberFunctionHandler(
StringExtractorGDBRemote::eServerPacketType_qC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ LLDBServerPluginMockGPU::LLDBServerPluginMockGPU(
LLDBServerPlugin::GDBServer &native_process)
: LLDBServerPlugin(native_process) {
m_process_manager_up.reset(new ProcessMockGPU::Manager(m_main_loop));
m_gdb_server.reset(
new GDBRemoteCommunicationServerLLGS(m_main_loop, *m_process_manager_up));
m_gdb_server.reset(new GDBRemoteCommunicationServerLLGS(
m_main_loop, *m_process_manager_up, "mock-gpu.server"));

Log *log = GetLog(GDBRLog::Plugin);
LLDB_LOGF(log, "LLDBServerPluginMockGPU::LLDBServerPluginMockGPU() faking launch...");
Expand Down
2 changes: 1 addition & 1 deletion lldb/tools/lldb-server/lldb-gdbserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ int main_gdbserver(int argc, char *argv[]) {
}

NativeProcessManager manager(mainloop);
GDBRemoteCommunicationServerLLGS gdb_server(mainloop, manager);
GDBRemoteCommunicationServerLLGS gdb_server(mainloop, manager, "gdb-server");

// Install the mock GPU plugin.
gdb_server.InstallPlugin(std::make_unique<LLDBServerPluginMockGPU>(gdb_server));
Expand Down