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