1 //===-- PlatformAndroidRemoteGDBServer.h ------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_PlatformAndroidRemoteGDBServer_h_
11 #define liblldb_PlatformAndroidRemoteGDBServer_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <map>
16 #include <utility>
17 
18 // Other libraries and framework includes
19 // Project includes
20 #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
21 
22 #include "llvm/ADT/Optional.h"
23 
24 #include "AdbClient.h"
25 
26 namespace lldb_private {
27 namespace platform_android {
28 
29 class PlatformAndroidRemoteGDBServer : public platform_gdb_server::PlatformRemoteGDBServer
30 {
31 public:
32     PlatformAndroidRemoteGDBServer();
33 
34     ~PlatformAndroidRemoteGDBServer() override;
35 
36     Error
37     ConnectRemote (Args& args) override;
38 
39     Error
40     DisconnectRemote () override;
41 
42 protected:
43     std::string m_device_id;
44     std::map<lldb::pid_t, uint16_t> m_port_forwards;
45     llvm::Optional<AdbClient::UnixSocketNamespace> m_socket_namespace;
46 
47     bool
48     LaunchGDBServer (lldb::pid_t &pid, std::string &connect_url) override;
49 
50     bool
51     KillSpawnedProcess (lldb::pid_t pid) override;
52 
53     void
54     DeleteForwardPort (lldb::pid_t pid);
55 
56     Error
57     MakeConnectURL(const lldb::pid_t pid,
58                    const uint16_t remote_port,
59                    const char* remote_socket_name,
60                    std::string& connect_url);
61 
62 private:
63     DISALLOW_COPY_AND_ASSIGN (PlatformAndroidRemoteGDBServer);
64 };
65 
66 } // namespace platform_android
67 } // namespace lldb_private
68 
69 #endif // liblldb_PlatformAndroidRemoteGDBServer_h_
70