1254721Semaste//===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef liblldb_GDBRemoteCommunicationServer_h_
11254721Semaste#define liblldb_GDBRemoteCommunicationServer_h_
12254721Semaste
13254721Semaste// C Includes
14254721Semaste// C++ Includes
15254721Semaste// Other libraries and framework includes
16254721Semaste// Project includes
17254721Semaste#include "lldb/Target/Process.h"
18254721Semaste
19254721Semaste#include "GDBRemoteCommunication.h"
20254721Semaste
21254721Semasteclass ProcessGDBRemote;
22254721Semasteclass StringExtractorGDBRemote;
23254721Semaste
24254721Semasteclass GDBRemoteCommunicationServer : public GDBRemoteCommunication
25254721Semaste{
26254721Semastepublic:
27254721Semaste    enum
28254721Semaste    {
29254721Semaste        eBroadcastBitRunPacketSent = kLoUserBroadcastBit
30254721Semaste    };
31254721Semaste    //------------------------------------------------------------------
32254721Semaste    // Constructors and Destructors
33254721Semaste    //------------------------------------------------------------------
34254721Semaste    GDBRemoteCommunicationServer(bool is_platform);
35254721Semaste
36254721Semaste    virtual
37254721Semaste    ~GDBRemoteCommunicationServer();
38254721Semaste
39254721Semaste    bool
40254721Semaste    GetPacketAndSendResponse (uint32_t timeout_usec,
41254721Semaste                              lldb_private::Error &error,
42254721Semaste                              bool &interrupt,
43254721Semaste                              bool &quit);
44254721Semaste
45254721Semaste    virtual bool
46254721Semaste    GetThreadSuffixSupported ()
47254721Semaste    {
48254721Semaste        return true;
49254721Semaste    }
50254721Semaste
51254721Semaste    // After connecting, do a little handshake with the client to make sure
52254721Semaste    // we are at least communicating
53254721Semaste    bool
54254721Semaste    HandshakeWithClient (lldb_private::Error *error_ptr);
55254721Semaste
56254721Semaste    // Set both ports to zero to let the platform automatically bind to
57254721Semaste    // a port chosen by the OS.
58254721Semaste    void
59254721Semaste    SetPortRange (uint16_t lo_port_num, uint16_t hi_port_num)
60254721Semaste    {
61254721Semaste        m_lo_port_num = lo_port_num;
62254721Semaste        m_hi_port_num = hi_port_num;
63254721Semaste    }
64254721Semaste
65254721Semasteprotected:
66254721Semaste    //typedef std::map<uint16_t, lldb::pid_t> PortToPIDMap;
67254721Semaste
68254721Semaste    lldb::thread_t m_async_thread;
69254721Semaste    lldb_private::ProcessLaunchInfo m_process_launch_info;
70254721Semaste    lldb_private::Error m_process_launch_error;
71254721Semaste    lldb_private::ProcessInstanceInfoList m_proc_infos;
72254721Semaste    uint32_t m_proc_infos_index;
73254721Semaste    uint16_t m_lo_port_num;
74254721Semaste    uint16_t m_hi_port_num;
75254721Semaste    //PortToPIDMap m_port_to_pid_map;
76254721Semaste
77254721Semaste    size_t
78254721Semaste    SendUnimplementedResponse (const char *packet);
79254721Semaste
80254721Semaste    size_t
81254721Semaste    SendErrorResponse (uint8_t error);
82254721Semaste
83254721Semaste    size_t
84254721Semaste    SendOKResponse ();
85254721Semaste
86254721Semaste    bool
87254721Semaste    Handle_A (StringExtractorGDBRemote &packet);
88254721Semaste
89254721Semaste    bool
90254721Semaste    Handle_qLaunchSuccess (StringExtractorGDBRemote &packet);
91254721Semaste
92254721Semaste    bool
93254721Semaste    Handle_qHostInfo (StringExtractorGDBRemote &packet);
94254721Semaste
95254721Semaste    bool
96254721Semaste    Handle_qLaunchGDBServer (StringExtractorGDBRemote &packet);
97254721Semaste
98254721Semaste    bool
99254721Semaste    Handle_qProcessInfoPID (StringExtractorGDBRemote &packet);
100254721Semaste
101254721Semaste    bool
102254721Semaste    Handle_qfProcessInfo (StringExtractorGDBRemote &packet);
103254721Semaste
104254721Semaste    bool
105254721Semaste    Handle_qsProcessInfo (StringExtractorGDBRemote &packet);
106254721Semaste
107254721Semaste    bool
108254721Semaste    Handle_qC (StringExtractorGDBRemote &packet);
109254721Semaste
110254721Semaste    bool
111254721Semaste    Handle_qUserName (StringExtractorGDBRemote &packet);
112254721Semaste
113254721Semaste    bool
114254721Semaste    Handle_qGroupName (StringExtractorGDBRemote &packet);
115254721Semaste
116254721Semaste    bool
117254721Semaste    Handle_qSpeedTest (StringExtractorGDBRemote &packet);
118254721Semaste
119254721Semaste    bool
120254721Semaste    Handle_QEnvironment  (StringExtractorGDBRemote &packet);
121254721Semaste
122254721Semaste    bool
123254721Semaste    Handle_QSetDisableASLR (StringExtractorGDBRemote &packet);
124254721Semaste
125254721Semaste    bool
126254721Semaste    Handle_QSetWorkingDir (StringExtractorGDBRemote &packet);
127254721Semaste
128254721Semaste    bool
129254721Semaste    Handle_QStartNoAckMode (StringExtractorGDBRemote &packet);
130254721Semaste
131254721Semaste    bool
132254721Semaste    Handle_QSetSTDIN (StringExtractorGDBRemote &packet);
133254721Semaste
134254721Semaste    bool
135254721Semaste    Handle_QSetSTDOUT (StringExtractorGDBRemote &packet);
136254721Semaste
137254721Semaste    bool
138254721Semaste    Handle_QSetSTDERR (StringExtractorGDBRemote &packet);
139254721Semaste
140254721Semasteprivate:
141254721Semaste    //------------------------------------------------------------------
142254721Semaste    // For GDBRemoteCommunicationServer only
143254721Semaste    //------------------------------------------------------------------
144254721Semaste    DISALLOW_COPY_AND_ASSIGN (GDBRemoteCommunicationServer);
145254721Semaste};
146254721Semaste
147254721Semaste#endif  // liblldb_GDBRemoteCommunicationServer_h_
148