[Lldb-commits] [PATCH] Factor out common URL handling code in PlatformRemoteGDBServer
Pavel Labath
labath at google.com
Thu Feb 19 10:12:53 PST 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7751
Files:
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
Index: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
===================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -37,6 +37,18 @@
static bool g_initialized = false;
+static std::string MakeGdbServerUrl (const std::string &platform_hostname, uint16_t port)
+{
+ const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
+ const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
+ int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
+ lldb_private::StreamString result;
+ result.Printf("connect://%s:%u",
+ override_hostname ? override_hostname : platform_hostname.c_str(),
+ port + port_offset);
+ return result.GetString();
+}
+
void
PlatformRemoteGDBServer::Initialize ()
{
@@ -576,20 +588,11 @@
if (process_sp)
{
- char connect_url[256];
- const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
- const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
- int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
- const int connect_url_len = ::snprintf (connect_url,
- sizeof(connect_url),
- "connect://%s:%u",
- override_hostname ? override_hostname : m_platform_hostname.c_str(),
- port + port_offset);
- assert (connect_url_len < (int)sizeof(connect_url));
- error = process_sp->ConnectRemote (NULL, connect_url);
+ std::string connect_url = MakeGdbServerUrl(m_platform_hostname, port);
+ error = process_sp->ConnectRemote (nullptr, connect_url.c_str());
// Retry the connect remote one time...
if (error.Fail())
- error = process_sp->ConnectRemote (NULL, connect_url);
+ error = process_sp->ConnectRemote (nullptr, connect_url.c_str());
if (error.Success())
error = process_sp->Launch(launch_info);
else if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
@@ -680,17 +683,8 @@
if (process_sp)
{
- char connect_url[256];
- const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
- const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
- int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
- const int connect_url_len = ::snprintf (connect_url,
- sizeof(connect_url),
- "connect://%s:%u",
- override_hostname ? override_hostname : m_platform_hostname.c_str(),
- port + port_offset);
- assert (connect_url_len < (int)sizeof(connect_url));
- error = process_sp->ConnectRemote(nullptr, connect_url);
+ std::string connect_url = MakeGdbServerUrl(m_platform_hostname, port);
+ error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
if (error.Success())
{
auto listener = attach_info.GetHijackListener();
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7751.20313.patch
Type: text/x-patch
Size: 4186 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150219/551365b6/attachment.bin>
More information about the lldb-commits
mailing list