1 //===-- PlatformRemoteGDBServer.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_PlatformRemoteGDBServer_h_
11 #define liblldb_PlatformRemoteGDBServer_h_
12 
13 // C Includes
14 // C++ Includes
15 #include <string>
16 
17 // Other libraries and framework includes
18 // Project includes
19 #include "lldb/Target/Platform.h"
20 #include "../../Process/gdb-remote/GDBRemoteCommunicationClient.h"
21 
22 class PlatformRemoteGDBServer : public lldb_private::Platform
23 {
24 public:
25 
26     static void
27     Initialize ();
28 
29     static void
30     Terminate ();
31 
32     static lldb_private::Platform*
33     CreateInstance ();
34 
35     static const char *
36     GetShortPluginNameStatic();
37 
38     static const char *
39     GetDescriptionStatic();
40 
41 
42     PlatformRemoteGDBServer ();
43 
44     virtual
45     ~PlatformRemoteGDBServer();
46 
47     //------------------------------------------------------------
48     // lldb_private::PluginInterface functions
49     //------------------------------------------------------------
50     virtual const char *
51     GetPluginName()
52     {
53         return "PlatformRemoteGDBServer";
54     }
55 
56     virtual const char *
57     GetShortPluginName()
58     {
59         return GetShortPluginNameStatic();
60     }
61 
62     virtual uint32_t
63     GetPluginVersion()
64     {
65         return 1;
66     }
67 
68 
69     //------------------------------------------------------------
70     // lldb_private::Platform functions
71     //------------------------------------------------------------
72     virtual lldb_private::Error
73     ResolveExecutable (const lldb_private::FileSpec &exe_file,
74                        const lldb_private::ArchSpec &arch,
75                        lldb::ModuleSP &module_sp);
76 
77     virtual const char *
78     GetDescription ();
79 
80     virtual lldb_private::Error
81     GetFile (const lldb_private::FileSpec &platform_file,
82              const lldb_private::UUID *uuid_ptr,
83              lldb_private::FileSpec &local_file);
84 
85     virtual bool
86     GetProcessInfo (lldb::pid_t pid,
87                     lldb_private::ProcessInstanceInfo &proc_info);
88 
89     virtual uint32_t
90     FindProcesses (const lldb_private::ProcessInstanceInfoMatch &match_info,
91                    lldb_private::ProcessInstanceInfoList &process_infos);
92 
93     virtual lldb_private::Error
94     LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info);
95 
96     virtual lldb::ProcessSP
97     Attach (lldb_private::ProcessAttachInfo &attach_info,
98             lldb_private::Debugger &debugger,
99             lldb_private::Target *target,       // Can be NULL, if NULL create a new target, else use existing one
100             lldb_private::Listener &listener,
101             lldb_private::Error &error);
102 
103     virtual bool
104     GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch);
105 
106     virtual size_t
107     GetSoftwareBreakpointTrapOpcode (lldb_private::Target &target,
108                                      lldb_private::BreakpointSite *bp_site);
109 
110     virtual bool
111     GetRemoteOSVersion ();
112 
113     virtual bool
114     GetRemoteOSBuildString (std::string &s);
115 
116     virtual bool
117     GetRemoteOSKernelDescription (std::string &s);
118 
119     // Remote Platform subclasses need to override this function
120     virtual lldb_private::ArchSpec
121     GetRemoteSystemArchitecture ();
122 
123     // Remote subclasses should override this and return a valid instance
124     // name if connected.
125     virtual const char *
126     GetHostname ();
127 
128     virtual const char *
129     GetUserName (uint32_t uid);
130 
131     virtual const char *
132     GetGroupName (uint32_t gid);
133 
134     virtual bool
135     IsConnected () const;
136 
137     virtual lldb_private::Error
138     ConnectRemote (lldb_private::Args& args);
139 
140     virtual lldb_private::Error
141     DisconnectRemote ();
142 
143 protected:
144     GDBRemoteCommunicationClient m_gdb_client;
145     std::string m_platform_description; // After we connect we can get a more complete description of what we are connected to
146 
147 private:
148     DISALLOW_COPY_AND_ASSIGN (PlatformRemoteGDBServer);
149 
150 };
151 
152 #endif  // liblldb_PlatformRemoteGDBServer_h_
153