1 //===-- PlatformRemoteGDBServer.cpp -----------------------------*- 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 #include "lldb/lldb-python.h"
11 
12 #include "PlatformRemoteGDBServer.h"
13 #include "lldb/Host/Config.h"
14 
15 // C Includes
16 #ifndef LLDB_DISABLE_POSIX
17 #include <sys/sysctl.h>
18 #endif
19 
20 // C++ Includes
21 // Other libraries and framework includes
22 // Project includes
23 #include "lldb/Breakpoint/BreakpointLocation.h"
24 #include "lldb/Core/ConnectionFileDescriptor.h"
25 #include "lldb/Core/Debugger.h"
26 #include "lldb/Core/Error.h"
27 #include "lldb/Core/Log.h"
28 #include "lldb/Core/Module.h"
29 #include "lldb/Core/ModuleList.h"
30 #include "lldb/Core/PluginManager.h"
31 #include "lldb/Core/StreamString.h"
32 #include "lldb/Host/FileSpec.h"
33 #include "lldb/Host/Host.h"
34 #include "lldb/Target/Process.h"
35 #include "lldb/Target/Target.h"
36 
37 using namespace lldb;
38 using namespace lldb_private;
39 
40 static bool g_initialized = false;
41 
42 void
43 PlatformRemoteGDBServer::Initialize ()
44 {
45     if (g_initialized == false)
46     {
47         g_initialized = true;
48         PluginManager::RegisterPlugin (PlatformRemoteGDBServer::GetPluginNameStatic(),
49                                        PlatformRemoteGDBServer::GetDescriptionStatic(),
50                                        PlatformRemoteGDBServer::CreateInstance);
51     }
52 }
53 
54 void
55 PlatformRemoteGDBServer::Terminate ()
56 {
57     if (g_initialized)
58     {
59         g_initialized = false;
60         PluginManager::UnregisterPlugin (PlatformRemoteGDBServer::CreateInstance);
61     }
62 }
63 
64 Platform*
65 PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
66 {
67     bool create = force;
68     if (!create)
69     {
70         create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified();
71     }
72     if (create)
73         return new PlatformRemoteGDBServer ();
74     return NULL;
75 }
76 
77 
78 lldb_private::ConstString
79 PlatformRemoteGDBServer::GetPluginNameStatic()
80 {
81     static ConstString g_name("remote-gdb-server");
82     return g_name;
83 }
84 
85 const char *
86 PlatformRemoteGDBServer::GetDescriptionStatic()
87 {
88     return "A platform that uses the GDB remote protocol as the communication transport.";
89 }
90 
91 const char *
92 PlatformRemoteGDBServer::GetDescription ()
93 {
94     if (m_platform_description.empty())
95     {
96         if (IsConnected())
97         {
98             // Send the get description packet
99         }
100     }
101 
102     if (!m_platform_description.empty())
103         return m_platform_description.c_str();
104     return GetDescriptionStatic();
105 }
106 
107 Error
108 PlatformRemoteGDBServer::ResolveExecutable (const FileSpec &exe_file,
109                                             const ArchSpec &exe_arch,
110                                             lldb::ModuleSP &exe_module_sp,
111                                             const FileSpecList *module_search_paths_ptr)
112 {
113     Error error;
114     //error.SetErrorString ("PlatformRemoteGDBServer::ResolveExecutable() is unimplemented");
115     if (m_gdb_client.GetFileExists(exe_file))
116         return error;
117     // TODO: get the remote end to somehow resolve this file
118     error.SetErrorString("file not found on remote end");
119     return error;
120 }
121 
122 Error
123 PlatformRemoteGDBServer::GetFileWithUUID (const FileSpec &platform_file,
124                                           const UUID *uuid_ptr,
125                                           FileSpec &local_file)
126 {
127     // Default to the local case
128     local_file = platform_file;
129     return Error();
130 }
131 
132 //------------------------------------------------------------------
133 /// Default Constructor
134 //------------------------------------------------------------------
135 PlatformRemoteGDBServer::PlatformRemoteGDBServer () :
136     Platform(false), // This is a remote platform
137     m_gdb_client(true)
138 {
139 }
140 
141 //------------------------------------------------------------------
142 /// Destructor.
143 ///
144 /// The destructor is virtual since this class is designed to be
145 /// inherited from by the plug-in instance.
146 //------------------------------------------------------------------
147 PlatformRemoteGDBServer::~PlatformRemoteGDBServer()
148 {
149 }
150 
151 bool
152 PlatformRemoteGDBServer::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
153 {
154     return false;
155 }
156 
157 size_t
158 PlatformRemoteGDBServer::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
159 {
160     // This isn't needed if the z/Z packets are supported in the GDB remote
161     // server. But we might need a packet to detect this.
162     return 0;
163 }
164 
165 bool
166 PlatformRemoteGDBServer::GetRemoteOSVersion ()
167 {
168     uint32_t major, minor, update;
169     if (m_gdb_client.GetOSVersion (major, minor, update))
170     {
171         m_major_os_version = major;
172         m_minor_os_version = minor;
173         m_update_os_version = update;
174         return true;
175     }
176     return false;
177 }
178 
179 bool
180 PlatformRemoteGDBServer::GetRemoteOSBuildString (std::string &s)
181 {
182     return m_gdb_client.GetOSBuildString (s);
183 }
184 
185 bool
186 PlatformRemoteGDBServer::GetRemoteOSKernelDescription (std::string &s)
187 {
188     return m_gdb_client.GetOSKernelDescription (s);
189 }
190 
191 // Remote Platform subclasses need to override this function
192 ArchSpec
193 PlatformRemoteGDBServer::GetRemoteSystemArchitecture ()
194 {
195     return m_gdb_client.GetSystemArchitecture();
196 }
197 
198 lldb_private::ConstString
199 PlatformRemoteGDBServer::GetRemoteWorkingDirectory()
200 {
201     if (IsConnected())
202     {
203         Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
204         std::string cwd;
205         if (m_gdb_client.GetWorkingDir(cwd))
206         {
207             ConstString working_dir(cwd.c_str());
208             if (log)
209                 log->Printf("PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'", working_dir.GetCString());
210             return working_dir;
211         }
212         else
213         {
214             return ConstString();
215         }
216     }
217     else
218     {
219         return Platform::GetRemoteWorkingDirectory();
220     }
221 }
222 
223 bool
224 PlatformRemoteGDBServer::SetRemoteWorkingDirectory(const lldb_private::ConstString &path)
225 {
226     if (IsConnected())
227     {
228         // Clear the working directory it case it doesn't get set correctly. This will
229         // for use to re-read it
230         Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
231         if (log)
232             log->Printf("PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')", path.GetCString());
233         return m_gdb_client.SetWorkingDir(path.GetCString()) == 0;
234     }
235     else
236         return Platform::SetRemoteWorkingDirectory(path);
237 }
238 
239 bool
240 PlatformRemoteGDBServer::IsConnected () const
241 {
242     return m_gdb_client.IsConnected();
243 }
244 
245 Error
246 PlatformRemoteGDBServer::ConnectRemote (Args& args)
247 {
248     Error error;
249     if (IsConnected())
250     {
251         error.SetErrorStringWithFormat ("the platform is already connected to '%s', execute 'platform disconnect' to close the current connection",
252                                         GetHostname());
253     }
254     else
255     {
256         if (args.GetArgumentCount() == 1)
257         {
258             const char *url = args.GetArgumentAtIndex(0);
259             m_gdb_client.SetConnection (new ConnectionFileDescriptor());
260             const ConnectionStatus status = m_gdb_client.Connect(url, &error);
261             if (status == eConnectionStatusSuccess)
262             {
263                 if (m_gdb_client.HandshakeWithServer(&error))
264                 {
265                     m_gdb_client.GetHostInfo();
266                     // If a working directory was set prior to connecting, send it down now
267                     if (m_working_dir)
268                         m_gdb_client.SetWorkingDir(m_working_dir.GetCString());
269                 }
270                 else
271                 {
272                     m_gdb_client.Disconnect();
273                     if (error.Success())
274                         error.SetErrorString("handshake failed");
275                 }
276             }
277         }
278         else
279         {
280             error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
281         }
282     }
283 
284     return error;
285 }
286 
287 Error
288 PlatformRemoteGDBServer::DisconnectRemote ()
289 {
290     Error error;
291     m_gdb_client.Disconnect(&error);
292     return error;
293 }
294 
295 const char *
296 PlatformRemoteGDBServer::GetHostname ()
297 {
298     m_gdb_client.GetHostname (m_name);
299     if (m_name.empty())
300         return NULL;
301     return m_name.c_str();
302 }
303 
304 const char *
305 PlatformRemoteGDBServer::GetUserName (uint32_t uid)
306 {
307     // Try and get a cache user name first
308     const char *cached_user_name = Platform::GetUserName(uid);
309     if (cached_user_name)
310         return cached_user_name;
311     std::string name;
312     if (m_gdb_client.GetUserName(uid, name))
313         return SetCachedUserName(uid, name.c_str(), name.size());
314 
315     SetUserNameNotFound(uid); // Negative cache so we don't keep sending packets
316     return NULL;
317 }
318 
319 const char *
320 PlatformRemoteGDBServer::GetGroupName (uint32_t gid)
321 {
322     const char *cached_group_name = Platform::GetGroupName(gid);
323     if (cached_group_name)
324         return cached_group_name;
325     std::string name;
326     if (m_gdb_client.GetGroupName(gid, name))
327         return SetCachedGroupName(gid, name.c_str(), name.size());
328 
329     SetGroupNameNotFound(gid); // Negative cache so we don't keep sending packets
330     return NULL;
331 }
332 
333 uint32_t
334 PlatformRemoteGDBServer::FindProcesses (const ProcessInstanceInfoMatch &match_info,
335                                         ProcessInstanceInfoList &process_infos)
336 {
337     return m_gdb_client.FindProcesses (match_info, process_infos);
338 }
339 
340 bool
341 PlatformRemoteGDBServer::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
342 {
343     return m_gdb_client.GetProcessInfo (pid, process_info);
344 }
345 
346 
347 Error
348 PlatformRemoteGDBServer::LaunchProcess (ProcessLaunchInfo &launch_info)
349 {
350     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
351     Error error;
352     lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
353 
354     if (log)
355         log->Printf ("PlatformRemoteGDBServer::%s() called", __FUNCTION__);
356 
357     m_gdb_client.SetSTDIN ("/dev/null");
358     m_gdb_client.SetSTDOUT ("/dev/null");
359     m_gdb_client.SetSTDERR ("/dev/null");
360     m_gdb_client.SetDisableASLR (launch_info.GetFlags().Test (eLaunchFlagDisableASLR));
361     m_gdb_client.SetDetachOnError (launch_info.GetFlags().Test (eLaunchFlagDetachOnError));
362 
363     const char *working_dir = launch_info.GetWorkingDirectory();
364     if (working_dir && working_dir[0])
365     {
366         m_gdb_client.SetWorkingDir (working_dir);
367     }
368 
369     // Send the environment and the program + arguments after we connect
370     const char **envp = launch_info.GetEnvironmentEntries().GetConstArgumentVector();
371 
372     if (envp)
373     {
374         const char *env_entry;
375         for (int i=0; (env_entry = envp[i]); ++i)
376         {
377             if (m_gdb_client.SendEnvironmentPacket(env_entry) != 0)
378                 break;
379         }
380     }
381 
382     ArchSpec arch_spec = launch_info.GetArchitecture();
383     const char *arch_triple = arch_spec.GetTriple().str().c_str();
384 
385     m_gdb_client.SendLaunchArchPacket(arch_triple);
386     if (log)
387         log->Printf ("PlatformRemoteGDBServer::%s() set launch architecture triple to '%s'", __FUNCTION__, arch_triple ? arch_triple : "<NULL>");
388 
389     const uint32_t old_packet_timeout = m_gdb_client.SetPacketTimeout (5);
390     int arg_packet_err = m_gdb_client.SendArgumentsPacket (launch_info);
391     m_gdb_client.SetPacketTimeout (old_packet_timeout);
392     if (arg_packet_err == 0)
393     {
394         std::string error_str;
395         if (m_gdb_client.GetLaunchSuccess (error_str))
396         {
397             pid = m_gdb_client.GetCurrentProcessID ();
398             if (pid != LLDB_INVALID_PROCESS_ID)
399             {
400                 launch_info.SetProcessID (pid);
401                 if (log)
402                     log->Printf ("PlatformRemoteGDBServer::%s() pid %" PRIu64 " launched successfully", __FUNCTION__, pid);
403             }
404             else
405             {
406                 if (log)
407                     log->Printf ("PlatformRemoteGDBServer::%s() launch succeeded but we didn't get a valid process id back!", __FUNCTION__);
408                 // FIXME isn't this an error condition? Do we need to set an error here?  Check with Greg.
409             }
410         }
411         else
412         {
413             error.SetErrorString (error_str.c_str());
414             if (log)
415                 log->Printf ("PlatformRemoteGDBServer::%s() launch failed: %s", __FUNCTION__, error.AsCString ());
416         }
417     }
418     else
419     {
420         error.SetErrorStringWithFormat("'A' packet returned an error: %i", arg_packet_err);
421     }
422     return error;
423 }
424 
425 lldb::ProcessSP
426 PlatformRemoteGDBServer::DebugProcess (lldb_private::ProcessLaunchInfo &launch_info,
427                                        lldb_private::Debugger &debugger,
428                                        lldb_private::Target *target,       // Can be NULL, if NULL create a new target, else use existing one
429                                        lldb_private::Listener &listener,
430                                        lldb_private::Error &error)
431 {
432     lldb::ProcessSP process_sp;
433     if (IsRemote())
434     {
435         if (IsConnected())
436         {
437             lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
438             ArchSpec remote_arch = GetRemoteSystemArchitecture();
439             llvm::Triple &remote_triple = remote_arch.GetTriple();
440             uint16_t port = 0;
441             if (remote_triple.getVendor() == llvm::Triple::Apple && remote_triple.getOS() == llvm::Triple::IOS)
442             {
443                 // When remote debugging to iOS, we use a USB mux that always talks
444                 // to localhost, so we will need the remote debugserver to accept connections
445                 // only from localhost, no matter what our current hostname is
446                 port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, "127.0.0.1");
447             }
448             else
449             {
450                 // All other hosts should use their actual hostname
451                 port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, NULL);
452             }
453 
454             if (port == 0)
455             {
456                 error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ());
457             }
458             else
459             {
460                 if (target == NULL)
461                 {
462                     TargetSP new_target_sp;
463 
464                     error = debugger.GetTargetList().CreateTarget (debugger,
465                                                                    NULL,
466                                                                    NULL,
467                                                                    false,
468                                                                    NULL,
469                                                                    new_target_sp);
470                     target = new_target_sp.get();
471                 }
472                 else
473                     error.Clear();
474 
475                 if (target && error.Success())
476                 {
477                     debugger.GetTargetList().SetSelectedTarget(target);
478 
479                     // The darwin always currently uses the GDB remote debugger plug-in
480                     // so even when debugging locally we are debugging remotely!
481                     process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
482 
483                     if (process_sp)
484                     {
485                         char connect_url[256];
486                         const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
487                         const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
488                         int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
489                         const int connect_url_len = ::snprintf (connect_url,
490                                                                 sizeof(connect_url),
491                                                                 "connect://%s:%u",
492                                                                 override_hostname ? override_hostname : GetHostname (),
493                                                                 port + port_offset);
494                         assert (connect_url_len < (int)sizeof(connect_url));
495                         error = process_sp->ConnectRemote (NULL, connect_url);
496                         if (error.Success())
497                             error = process_sp->Launch(launch_info);
498                         else if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
499                             m_gdb_client.KillSpawnedProcess(debugserver_pid);
500                     }
501                 }
502             }
503         }
504         else
505         {
506             error.SetErrorString("not connected to remote gdb server");
507         }
508     }
509     return process_sp;
510 
511 }
512 
513 lldb::ProcessSP
514 PlatformRemoteGDBServer::Attach (lldb_private::ProcessAttachInfo &attach_info,
515                                  Debugger &debugger,
516                                  Target *target,       // Can be NULL, if NULL create a new target, else use existing one
517                                  Listener &listener,
518                                  Error &error)
519 {
520     lldb::ProcessSP process_sp;
521     if (IsRemote())
522     {
523         if (IsConnected())
524         {
525             lldb::pid_t debugserver_pid = LLDB_INVALID_PROCESS_ID;
526             ArchSpec remote_arch = GetRemoteSystemArchitecture();
527             llvm::Triple &remote_triple = remote_arch.GetTriple();
528             uint16_t port = 0;
529             if (remote_triple.getVendor() == llvm::Triple::Apple && remote_triple.getOS() == llvm::Triple::IOS)
530             {
531                 // When remote debugging to iOS, we use a USB mux that always talks
532                 // to localhost, so we will need the remote debugserver to accept connections
533                 // only from localhost, no matter what our current hostname is
534                 port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, "127.0.0.1");
535             }
536             else
537             {
538                 // All other hosts should use their actual hostname
539                 port = m_gdb_client.LaunchGDBserverAndGetPort(debugserver_pid, NULL);
540             }
541 
542             if (port == 0)
543             {
544                 error.SetErrorStringWithFormat ("unable to launch a GDB server on '%s'", GetHostname ());
545             }
546             else
547             {
548                 if (target == NULL)
549                 {
550                     TargetSP new_target_sp;
551 
552                     error = debugger.GetTargetList().CreateTarget (debugger,
553                                                                    NULL,
554                                                                    NULL,
555                                                                    false,
556                                                                    NULL,
557                                                                    new_target_sp);
558                     target = new_target_sp.get();
559                 }
560                 else
561                     error.Clear();
562 
563                 if (target && error.Success())
564                 {
565                     debugger.GetTargetList().SetSelectedTarget(target);
566 
567                     // The darwin always currently uses the GDB remote debugger plug-in
568                     // so even when debugging locally we are debugging remotely!
569                     process_sp = target->CreateProcess (listener, "gdb-remote", NULL);
570 
571                     if (process_sp)
572                     {
573                         char connect_url[256];
574                         const char *override_hostname = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_HOSTNAME");
575                         const char *port_offset_c_str = getenv("LLDB_PLATFORM_REMOTE_GDB_SERVER_PORT_OFFSET");
576                         int port_offset = port_offset_c_str ? ::atoi(port_offset_c_str) : 0;
577                         const int connect_url_len = ::snprintf (connect_url,
578                                                                 sizeof(connect_url),
579                                                                 "connect://%s:%u",
580                                                                 override_hostname ? override_hostname : GetHostname (),
581                                                                 port + port_offset);
582                         assert (connect_url_len < (int)sizeof(connect_url));
583                         error = process_sp->ConnectRemote (NULL, connect_url);
584                         if (error.Success())
585                             error = process_sp->Attach(attach_info);
586                         else if (debugserver_pid != LLDB_INVALID_PROCESS_ID)
587                         {
588                             m_gdb_client.KillSpawnedProcess(debugserver_pid);
589                         }
590                     }
591                 }
592             }
593         }
594         else
595         {
596             error.SetErrorString("not connected to remote gdb server");
597         }
598     }
599     return process_sp;
600 }
601 
602 Error
603 PlatformRemoteGDBServer::MakeDirectory (const char *path, uint32_t mode)
604 {
605     Error error = m_gdb_client.MakeDirectory(path,mode);
606     Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
607     if (log)
608         log->Printf ("PlatformRemoteGDBServer::MakeDirectory(path='%s', mode=%o) error = %u (%s)", path, mode, error.GetError(), error.AsCString());
609     return error;
610 }
611 
612 
613 Error
614 PlatformRemoteGDBServer::GetFilePermissions (const char *path, uint32_t &file_permissions)
615 {
616     Error error = m_gdb_client.GetFilePermissions(path, file_permissions);
617     Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
618     if (log)
619         log->Printf ("PlatformRemoteGDBServer::GetFilePermissions(path='%s', file_permissions=%o) error = %u (%s)", path, file_permissions, error.GetError(), error.AsCString());
620     return error;
621 }
622 
623 Error
624 PlatformRemoteGDBServer::SetFilePermissions (const char *path, uint32_t file_permissions)
625 {
626     Error error = m_gdb_client.SetFilePermissions(path, file_permissions);
627     Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
628     if (log)
629         log->Printf ("PlatformRemoteGDBServer::SetFilePermissions(path='%s', file_permissions=%o) error = %u (%s)", path, file_permissions, error.GetError(), error.AsCString());
630     return error;
631 }
632 
633 
634 lldb::user_id_t
635 PlatformRemoteGDBServer::OpenFile (const lldb_private::FileSpec& file_spec,
636                                    uint32_t flags,
637                                    uint32_t mode,
638                                    Error &error)
639 {
640     return m_gdb_client.OpenFile (file_spec, flags, mode, error);
641 }
642 
643 bool
644 PlatformRemoteGDBServer::CloseFile (lldb::user_id_t fd, Error &error)
645 {
646     return m_gdb_client.CloseFile (fd, error);
647 }
648 
649 lldb::user_id_t
650 PlatformRemoteGDBServer::GetFileSize (const lldb_private::FileSpec& file_spec)
651 {
652     return m_gdb_client.GetFileSize(file_spec);
653 }
654 
655 uint64_t
656 PlatformRemoteGDBServer::ReadFile (lldb::user_id_t fd,
657                                    uint64_t offset,
658                                    void *dst,
659                                    uint64_t dst_len,
660                                    Error &error)
661 {
662     return m_gdb_client.ReadFile (fd, offset, dst, dst_len, error);
663 }
664 
665 uint64_t
666 PlatformRemoteGDBServer::WriteFile (lldb::user_id_t fd,
667                                     uint64_t offset,
668                                     const void* src,
669                                     uint64_t src_len,
670                                     Error &error)
671 {
672     return m_gdb_client.WriteFile (fd, offset, src, src_len, error);
673 }
674 
675 lldb_private::Error
676 PlatformRemoteGDBServer::PutFile (const lldb_private::FileSpec& source,
677          const lldb_private::FileSpec& destination,
678          uint32_t uid,
679          uint32_t gid)
680 {
681     return Platform::PutFile(source,destination,uid,gid);
682 }
683 
684 Error
685 PlatformRemoteGDBServer::CreateSymlink (const char *src,    // The name of the link is in src
686                                         const char *dst)    // The symlink points to dst
687 {
688     Error error = m_gdb_client.CreateSymlink (src, dst);
689     Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
690     if (log)
691         log->Printf ("PlatformRemoteGDBServer::CreateSymlink(src='%s', dst='%s') error = %u (%s)", src, dst, error.GetError(), error.AsCString());
692     return error;
693 }
694 
695 Error
696 PlatformRemoteGDBServer::Unlink (const char *path)
697 {
698     Error error = m_gdb_client.Unlink (path);
699     Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM);
700     if (log)
701         log->Printf ("PlatformRemoteGDBServer::Unlink(path='%s') error = %u (%s)", path, error.GetError(), error.AsCString());
702     return error;
703 }
704 
705 bool
706 PlatformRemoteGDBServer::GetFileExists (const lldb_private::FileSpec& file_spec)
707 {
708     return m_gdb_client.GetFileExists (file_spec);
709 }
710 
711 lldb_private::Error
712 PlatformRemoteGDBServer::RunShellCommand (const char *command,           // Shouldn't be NULL
713                                           const char *working_dir,       // Pass NULL to use the current working directory
714                                           int *status_ptr,               // Pass NULL if you don't want the process exit status
715                                           int *signo_ptr,                // Pass NULL if you don't want the signal that caused the process to exit
716                                           std::string *command_output,   // Pass NULL if you don't want the command output
717                                           uint32_t timeout_sec)          // Timeout in seconds to wait for shell program to finish
718 {
719     return m_gdb_client.RunShellCommand (command, working_dir, status_ptr, signo_ptr, command_output, timeout_sec);
720 }
721 
722 void
723 PlatformRemoteGDBServer::CalculateTrapHandlerSymbolNames ()
724 {
725     m_trap_handlers.push_back (ConstString ("_sigtramp"));
726 }
727