summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleksiy Vyalov <ovyalov@google.com>2015-04-07 17:23:15 +0000
committerOleksiy Vyalov <ovyalov@google.com>2015-04-07 17:23:15 +0000
commit1c1d76b3796ca399fd234defde9fee6a0668c312 (patch)
treea534a7458ef723034140393efdf982ad8d2c40e1
parent7acdbfc84b18c13c11dc0fd2d527dbf5d5153bb5 (diff)
downloadbcm5719-llvm-1c1d76b3796ca399fd234defde9fee6a0668c312.tar.gz
bcm5719-llvm-1c1d76b3796ca399fd234defde9fee6a0668c312.zip
Delete port forwarding if ConnectRemote fails.
http://reviews.llvm.org/D8826 llvm-svn: 234332
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp41
-rw-r--r--lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h3
2 files changed, 29 insertions, 15 deletions
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
index ede6b8f953e..2cb487ad181 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -80,13 +80,7 @@ PlatformAndroidRemoteGDBServer::LaunchGDBserverAndGetPort (lldb::pid_t &pid)
bool
PlatformAndroidRemoteGDBServer::KillSpawnedProcess (lldb::pid_t pid)
{
- auto it = m_port_forwards.find (pid);
- if (it != m_port_forwards.end ())
- {
- DeleteForwardPortWithAdb (it->second.first, it->second.second);
- m_port_forwards.erase (it);
- }
-
+ DeleteForwardPort (pid);
return m_gdb_client.KillSpawnedProcess (pid);
}
@@ -109,18 +103,35 @@ PlatformAndroidRemoteGDBServer::ConnectRemote (Args& args)
m_port_forwards[g_remote_platform_pid] = std::make_pair (port, device_id);
- return PlatformRemoteGDBServer::ConnectRemote (args);
+ error = PlatformRemoteGDBServer::ConnectRemote (args);
+ if (error.Fail ())
+ DeleteForwardPort (g_remote_platform_pid);
+
+ return error;
}
Error
PlatformAndroidRemoteGDBServer::DisconnectRemote ()
{
- auto it = m_port_forwards.find (g_remote_platform_pid);
- if (it != m_port_forwards.end ())
- {
- DeleteForwardPortWithAdb (it->second.first, it->second.second);
- m_port_forwards.erase (it);
- }
-
+ DeleteForwardPort (g_remote_platform_pid);
return PlatformRemoteGDBServer::DisconnectRemote ();
}
+
+void
+PlatformAndroidRemoteGDBServer::DeleteForwardPort (lldb::pid_t pid)
+{
+ Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
+
+ auto it = m_port_forwards.find (pid);
+ if (it == m_port_forwards.end ())
+ return;
+
+ const auto& forward_val = it->second;
+ const auto error = DeleteForwardPortWithAdb (forward_val.first, forward_val.second);
+ if (error.Fail ()) {
+ if (log)
+ log->Printf ("Failed to delete port forwarding (pid=%" PRIu64 ", port=%d, device=%s): %s",
+ pid, forward_val.first, forward_val.second.c_str (), error.AsCString ());
+ }
+ m_port_forwards.erase (it);
+}
diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
index 0cac44cbf79..1959bb86a7b 100644
--- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
@@ -45,6 +45,9 @@ protected:
bool
KillSpawnedProcess (lldb::pid_t pid) override;
+ void
+ DeleteForwardPort (lldb::pid_t pid);
+
private:
DISALLOW_COPY_AND_ASSIGN (PlatformAndroidRemoteGDBServer);
OpenPOWER on IntegriCloud