Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 1 | //===-- GDBRemoteCommunicationServerPlatform.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_GDBRemoteCommunicationServerPlatform_h_ |
| 11 | #define liblldb_GDBRemoteCommunicationServerPlatform_h_ |
| 12 | |
| 13 | #include "GDBRemoteCommunicationServerCommon.h" |
| 14 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame^] | 15 | namespace lldb_private { |
| 16 | namespace process_gdb_remote { |
| 17 | |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 18 | class GDBRemoteCommunicationServerPlatform : |
| 19 | public GDBRemoteCommunicationServerCommon |
| 20 | { |
| 21 | public: |
| 22 | typedef std::map<uint16_t, lldb::pid_t> PortMap; |
| 23 | |
| 24 | GDBRemoteCommunicationServerPlatform(); |
| 25 | |
| 26 | virtual |
| 27 | ~GDBRemoteCommunicationServerPlatform(); |
| 28 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame^] | 29 | Error |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 30 | LaunchProcess () override; |
| 31 | |
| 32 | // Set both ports to zero to let the platform automatically bind to |
| 33 | // a port chosen by the OS. |
| 34 | void |
| 35 | SetPortMap (PortMap &&port_map); |
| 36 | |
| 37 | //---------------------------------------------------------------------- |
| 38 | // If we are using a port map where we can only use certain ports, |
| 39 | // get the next available port. |
| 40 | // |
| 41 | // If we are using a port map and we are out of ports, return UINT16_MAX |
| 42 | // |
| 43 | // If we aren't using a port map, return 0 to indicate we should bind to |
| 44 | // port 0 and then figure out which port we used. |
| 45 | //---------------------------------------------------------------------- |
| 46 | uint16_t |
| 47 | GetNextAvailablePort (); |
| 48 | |
| 49 | bool |
| 50 | AssociatePortWithProcess (uint16_t port, lldb::pid_t pid); |
| 51 | |
| 52 | bool |
| 53 | FreePort (uint16_t port); |
| 54 | |
| 55 | bool |
| 56 | FreePortForProcess (lldb::pid_t pid); |
| 57 | |
| 58 | void |
| 59 | SetPortOffset (uint16_t port_offset); |
| 60 | |
| 61 | protected: |
| 62 | lldb::PlatformSP m_platform_sp; |
| 63 | |
| 64 | PortMap m_port_map; |
| 65 | uint16_t m_port_offset; |
| 66 | |
| 67 | PacketResult |
| 68 | Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet); |
| 69 | |
| 70 | PacketResult |
| 71 | Handle_qProcessInfo (StringExtractorGDBRemote &packet); |
| 72 | |
| 73 | PacketResult |
| 74 | Handle_qGetWorkingDir (StringExtractorGDBRemote &packet); |
| 75 | |
| 76 | PacketResult |
| 77 | Handle_QSetWorkingDir (StringExtractorGDBRemote &packet); |
| 78 | |
| 79 | PacketResult |
| 80 | Handle_qC (StringExtractorGDBRemote &packet); |
| 81 | |
| 82 | private: |
| 83 | bool |
| 84 | DebugserverProcessReaped (lldb::pid_t pid); |
| 85 | |
| 86 | static bool |
| 87 | ReapDebugserverProcess (void *callback_baton, |
| 88 | lldb::pid_t pid, |
| 89 | bool exited, |
| 90 | int signal, |
| 91 | int status); |
| 92 | |
| 93 | //------------------------------------------------------------------ |
| 94 | // For GDBRemoteCommunicationServerPlatform only |
| 95 | //------------------------------------------------------------------ |
| 96 | DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServerPlatform); |
| 97 | }; |
| 98 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame^] | 99 | } // namespace process_gdb_remote |
| 100 | } // namespace lldb_private |
| 101 | |
Tamas Berghammer | e13c273 | 2015-02-11 10:29:30 +0000 | [diff] [blame] | 102 | #endif // liblldb_GDBRemoteCommunicationServerPlatform_h_ |