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