1 //===-- Platform.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Platform_h_
11 #define liblldb_Platform_h_
19 // Other libraries and framework includes
21 #include "lldb/lldb-public.h"
22 #include "lldb/Core/ArchSpec.h"
23 #include "lldb/Core/ConstString.h"
24 #include "lldb/Core/PluginInterface.h"
25 #include "lldb/Interpreter/Options.h"
26 #include "lldb/Host/Mutex.h"
28 namespace lldb_private {
30 //----------------------------------------------------------------------
31 /// @class Platform Platform.h "lldb/Target/Platform.h"
32 /// @brief A plug-in interface definition class for debug platform that
33 /// includes many platform abilities such as:
34 /// @li getting platform information such as supported architectures,
35 /// supported binary file formats and more
36 /// @li launching new processes
37 /// @li attaching to existing processes
38 /// @li download/upload files
39 /// @li execute shell commands
40 /// @li listing and getting info for existing processes
41 /// @li attaching and possibly debugging the platform's kernel
42 //----------------------------------------------------------------------
44 public PluginInterface
48 //------------------------------------------------------------------
49 /// Get the native host platform plug-in.
51 /// There should only be one of these for each host that LLDB runs
52 /// upon that should be statically compiled in and registered using
53 /// preprocessor macros or other similar build mechanisms in a
54 /// PlatformSubclass::Initialize() function.
56 /// This platform will be used as the default platform when launching
57 /// or attaching to processes unless another platform is specified.
58 //------------------------------------------------------------------
59 static lldb::PlatformSP
60 GetDefaultPlatform ();
62 static lldb::PlatformSP
63 GetPlatformForArchitecture (const ArchSpec &arch,
64 ArchSpec *platform_arch_ptr);
67 GetHostPlatformName ();
70 SetDefaultPlatform (const lldb::PlatformSP &platform_sp);
72 static lldb::PlatformSP
73 Create (const char *platform_name, Error &error);
75 static lldb::PlatformSP
76 Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &error);
79 GetNumConnectedRemotePlatforms ();
81 static lldb::PlatformSP
82 GetConnectedRemotePlatformAtIndex (uint32_t idx);
84 //------------------------------------------------------------------
85 /// Default Constructor
86 //------------------------------------------------------------------
87 Platform (bool is_host_platform);
89 //------------------------------------------------------------------
92 /// The destructor is virtual since this class is designed to be
93 /// inherited from by the plug-in instance.
94 //------------------------------------------------------------------
98 //------------------------------------------------------------------
99 /// Find a platform plugin for a given process.
101 /// Scans the installed Platform plug-ins and tries to find
102 /// an instance that can be used for \a process
104 /// @param[in] process
105 /// The process for which to try and locate a platform
106 /// plug-in instance.
108 /// @param[in] plugin_name
109 /// An optional name of a specific platform plug-in that
110 /// should be used. If NULL, pick the best plug-in.
111 //------------------------------------------------------------------
113 FindPlugin (Process *process, const ConstString &plugin_name);
115 //------------------------------------------------------------------
116 /// Set the target's executable based off of the existing
117 /// architecture information in \a target given a path to an
118 /// executable \a exe_file.
120 /// Each platform knows the architectures that it supports and can
121 /// select the correct architecture slice within \a exe_file by
122 /// inspecting the architecture in \a target. If the target had an
123 /// architecture specified, then in can try and obey that request
124 /// and optionally fail if the architecture doesn't match up.
125 /// If no architecture is specified, the platform should select the
126 /// default architecture from \a exe_file. Any application bundles
127 /// or executable wrappers can also be inspected for the actual
128 /// application binary within the bundle that should be used.
131 /// Returns \b true if this Platform plug-in was able to find
132 /// a suitable executable, \b false otherwise.
133 //------------------------------------------------------------------
135 ResolveExecutable (const FileSpec &exe_file,
136 const ArchSpec &arch,
137 lldb::ModuleSP &module_sp,
138 const FileSpecList *module_search_paths_ptr);
141 //------------------------------------------------------------------
142 /// Find a symbol file given a symbol file module specification.
144 /// Each platform might have tricks to find symbol files for an
145 /// executable given information in a symbol file ModuleSpec. Some
146 /// platforms might also support symbol files that are bundles and
147 /// know how to extract the right symbol file given a bundle.
149 /// @param[in] target
150 /// The target in which we are trying to resolve the symbol file.
151 /// The target has a list of modules that we might be able to
152 /// use in order to help find the right symbol file. If the
153 /// "m_file" or "m_platform_file" entries in the \a sym_spec
154 /// are filled in, then we might be able to locate a module in
155 /// the target, extract its UUID and locate a symbol file.
156 /// If just the "m_uuid" is specified, then we might be able
157 /// to find the module in the target that matches that UUID
158 /// and pair the symbol file along with it. If just "m_symbol_file"
159 /// is specified, we can use a variety of tricks to locate the
160 /// symbols in an SDK, PDK, or other development kit location.
162 /// @param[in] sym_spec
163 /// A module spec that describes some information about the
164 /// symbol file we are trying to resolve. The ModuleSpec might
165 /// contain the following:
166 /// m_file - A full or partial path to an executable from the
167 /// target (might be empty).
168 /// m_platform_file - Another executable hint that contains
169 /// the path to the file as known on the
170 /// local/remote platform.
171 /// m_symbol_file - A full or partial path to a symbol file
172 /// or symbol bundle that should be used when
173 /// trying to resolve the symbol file.
174 /// m_arch - The architecture we are looking for when resolving
176 /// m_uuid - The UUID of the executable and symbol file. This
177 /// can often be used to match up an exectuable with
178 /// a symbol file, or resolve an symbol file in a
179 /// symbol file bundle.
181 /// @param[out] sym_file
182 /// The resolved symbol file spec if the returned error
183 /// indicates succes.
186 /// Returns an error that describes success or failure.
187 //------------------------------------------------------------------
189 ResolveSymbolFile (Target &target,
190 const ModuleSpec &sym_spec,
193 //------------------------------------------------------------------
194 /// Resolves the FileSpec to a (possibly) remote path. Remote
195 /// platforms must override this to resolve to a path on the remote
197 //------------------------------------------------------------------
199 ResolveRemotePath (const FileSpec &platform_path,
200 FileSpec &resolved_platform_path);
203 GetOSVersion (uint32_t &major,
208 SetOSVersion (uint32_t major,
213 GetOSBuildString (std::string &s);
216 GetOSKernelDescription (std::string &s);
218 // Returns the the name of the platform
226 GetDescription () = 0;
228 //------------------------------------------------------------------
229 /// Report the current status for this platform.
231 /// The returned string usually involves returning the OS version
232 /// (if available), and any SDK directory that might be being used
233 /// for local file caching, and if connected a quick blurb about
234 /// what this platform is connected to.
235 //------------------------------------------------------------------
237 GetStatus (Stream &strm);
239 //------------------------------------------------------------------
240 // Subclasses must be able to fetch the current OS version
242 // Remote classes must be connected for this to succeed. Local
243 // subclasses don't need to override this function as it will just
244 // call the Host::GetOSVersion().
245 //------------------------------------------------------------------
247 GetRemoteOSVersion ()
253 GetRemoteOSBuildString (std::string &s)
260 GetRemoteOSKernelDescription (std::string &s)
266 // Remote Platform subclasses need to override this function
268 GetRemoteSystemArchitecture ()
270 return ArchSpec(); // Return an invalid architecture
274 GetRemoteWorkingDirectory()
276 return m_working_dir;
280 SetRemoteWorkingDirectory(const ConstString &path);
283 GetUserName (uint32_t uid);
286 GetGroupName (uint32_t gid);
288 //------------------------------------------------------------------
289 /// Locate a file for a platform.
291 /// The default implementation of this function will return the same
292 /// file patch in \a local_file as was in \a platform_file.
294 /// @param[in] platform_file
295 /// The platform file path to locate and cache locally.
297 /// @param[in] uuid_ptr
298 /// If we know the exact UUID of the file we are looking for, it
299 /// can be specified. If it is not specified, we might now know
300 /// the exact file. The UUID is usually some sort of MD5 checksum
301 /// for the file and is sometimes known by dynamic linkers/loaders.
302 /// If the UUID is known, it is best to supply it to platform
303 /// file queries to ensure we are finding the correct file, not
304 /// just a file at the correct path.
306 /// @param[out] local_file
307 /// A locally cached version of the platform file. For platforms
308 /// that describe the current host computer, this will just be
309 /// the same file. For remote platforms, this file might come from
310 /// and SDK directory, or might need to be sync'ed over to the
311 /// current machine for efficient debugging access.
315 //------------------------------------------------------------------
317 GetFileWithUUID (const FileSpec &platform_file,
318 const UUID *uuid_ptr,
319 FileSpec &local_file);
321 //----------------------------------------------------------------------
322 // Locate the scripting resource given a module specification.
324 // Locating the file should happen only on the local computer or using
325 // the current computers global settings.
326 //----------------------------------------------------------------------
328 LocateExecutableScriptingResources (Target *target,
332 GetSharedModule (const ModuleSpec &module_spec,
333 lldb::ModuleSP &module_sp,
334 const FileSpecList *module_search_paths_ptr,
335 lldb::ModuleSP *old_module_sp_ptr,
336 bool *did_create_ptr);
339 ConnectRemote (Args& args);
344 //------------------------------------------------------------------
345 /// Get the platform's supported architectures in the order in which
346 /// they should be searched.
349 /// A zero based architecture index
352 /// A copy of the archgitecture at index if the return value is
356 /// \b true if \a arch was filled in and is valid, \b false
358 //------------------------------------------------------------------
360 GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) = 0;
363 GetSoftwareBreakpointTrapOpcode (Target &target,
364 BreakpointSite *bp_site) = 0;
366 //------------------------------------------------------------------
367 /// Launch a new process on a platform, not necessarily for
368 /// debugging, it could be just for running the process.
369 //------------------------------------------------------------------
371 LaunchProcess (ProcessLaunchInfo &launch_info);
373 //------------------------------------------------------------------
374 /// Lets a platform answer if it is compatible with a given
375 /// architecture and the target triple contained within.
376 //------------------------------------------------------------------
378 IsCompatibleArchitecture (const ArchSpec &arch,
379 bool exact_arch_match,
380 ArchSpec *compatible_arch_ptr);
382 //------------------------------------------------------------------
383 /// Not all platforms will support debugging a process by spawning
384 /// somehow halted for a debugger (specified using the
385 /// "eLaunchFlagDebug" launch flag) and then attaching. If your
386 /// platform doesn't support this, override this function and return
388 //------------------------------------------------------------------
395 //------------------------------------------------------------------
396 /// Subclasses do not need to implement this function as it uses
397 /// the Platform::LaunchProcess() followed by Platform::Attach ().
398 /// Remote platforms will want to subclass this function in order
399 /// to be able to intercept STDIO and possibly launch a separate
400 /// process that will debug the debuggee.
401 //------------------------------------------------------------------
402 virtual lldb::ProcessSP
403 DebugProcess (ProcessLaunchInfo &launch_info,
405 Target *target, // Can be NULL, if NULL create a new target, else use existing one
409 //------------------------------------------------------------------
410 /// Attach to an existing process using a process ID.
412 /// Each platform subclass needs to implement this function and
413 /// attempt to attach to the process with the process ID of \a pid.
414 /// The platform subclass should return an appropriate ProcessSP
415 /// subclass that is attached to the process, or an empty shared
416 /// pointer with an appriopriate error.
419 /// The process ID that we should attempt to attach to.
422 /// An appropriate ProcessSP containing a valid shared pointer
423 /// to the default Process subclass for the platform that is
424 /// attached to the process, or an empty shared pointer with an
425 /// appriopriate error fill into the \a error object.
426 //------------------------------------------------------------------
427 virtual lldb::ProcessSP
428 Attach (ProcessAttachInfo &attach_info,
430 Target *target, // Can be NULL, if NULL create a new target, else use existing one
434 //------------------------------------------------------------------
435 /// Attach to an existing process by process name.
437 /// This function is not meant to be overridden by Process
438 /// subclasses. It will first call
439 /// Process::WillAttach (const char *) and if that returns \b
440 /// true, Process::DoAttach (const char *) will be called to
441 /// actually do the attach. If DoAttach returns \b true, then
442 /// Process::DidAttach() will be called.
444 /// @param[in] process_name
445 /// A process name to match against the current process list.
448 /// Returns \a pid if attaching was successful, or
449 /// LLDB_INVALID_PROCESS_ID if attaching fails.
450 //------------------------------------------------------------------
451 // virtual lldb::ProcessSP
452 // Attach (const char *process_name,
453 // bool wait_for_launch,
454 // Error &error) = 0;
456 //------------------------------------------------------------------
457 // The base class Platform will take care of the host platform.
458 // Subclasses will need to fill in the remote case.
459 //------------------------------------------------------------------
461 FindProcesses (const ProcessInstanceInfoMatch &match_info,
462 ProcessInstanceInfoList &proc_infos);
465 GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &proc_info);
467 //------------------------------------------------------------------
468 // Set a breakpoint on all functions that can end up creating a thread
469 // for this platform. This is needed when running expressions and
470 // also for process control.
471 //------------------------------------------------------------------
472 virtual lldb::BreakpointSP
473 SetThreadCreationBreakpoint (Target &target);
475 //------------------------------------------------------------------
476 // Given a target, find the local SDK directory if one exists on the
478 //------------------------------------------------------------------
479 virtual lldb_private::ConstString
480 GetSDKDirectory (lldb_private::Target &target)
482 return lldb_private::ConstString();
486 GetRemoteURL () const
494 return m_is_host; // Is this the default host platform?
506 // Remote subclasses should override this function
511 GetSystemArchitecture();
514 SetSystemArchitecture (const ArchSpec &arch)
516 m_system_arch = arch;
518 m_os_version_set_while_connected = m_system_arch.IsValid();
521 // Used for column widths
523 GetMaxUserIDNameLength() const
525 return m_max_uid_name_len;
527 // Used for column widths
529 GetMaxGroupIDNameLength() const
531 return m_max_gid_name_len;
535 GetSDKRootDirectory () const
537 return m_sdk_sysroot;
541 SetSDKRootDirectory (const ConstString &dir)
553 SetSDKBuild (const ConstString &sdk_build)
555 m_sdk_build = sdk_build;
559 GetWorkingDirectory ();
562 SetWorkingDirectory (const ConstString &path);
564 // There may be modules that we don't want to find by default for operations like "setting breakpoint by name".
565 // The platform will return "true" from this call if the passed in module happens to be one of these.
568 ModuleIsExcludedForNonModuleSpecificSearches (Target &target, const lldb::ModuleSP &module_sp)
574 MakeDirectory (const char *path, uint32_t permissions);
577 GetFilePermissions (const char *path, uint32_t &file_permissions);
580 SetFilePermissions (const char *path, uint32_t file_permissions);
582 virtual lldb::user_id_t
583 OpenFile (const FileSpec& file_spec,
592 CloseFile (lldb::user_id_t fd,
598 virtual lldb::user_id_t
599 GetFileSize (const FileSpec& file_spec)
605 ReadFile (lldb::user_id_t fd,
611 error.SetErrorStringWithFormat ("Platform::ReadFile() is not supported in the %s platform", GetName().GetCString());
616 WriteFile (lldb::user_id_t fd,
622 error.SetErrorStringWithFormat ("Platform::ReadFile() is not supported in the %s platform", GetName().GetCString());
627 GetFile (const FileSpec& source,
628 const FileSpec& destination);
631 PutFile (const FileSpec& source,
632 const FileSpec& destination,
633 uint32_t uid = UINT32_MAX,
634 uint32_t gid = UINT32_MAX);
637 CreateSymlink (const char *src, // The name of the link is in src
638 const char *dst);// The symlink points to dst
640 //----------------------------------------------------------------------
641 /// Install a file or directory to the remote system.
643 /// Install is similar to Platform::PutFile(), but it differs in that if
644 /// an application/framework/shared library is installed on a remote
645 /// platform and the remote platform requires something to be done to
646 /// register the application/framework/shared library, then this extra
647 /// registration can be done.
650 /// The source file/directory to install on the remote system.
653 /// The destination file/directory where \a src will be installed.
654 /// If \a dst has no filename specified, then its filename will
655 /// be set from \a src. It \a dst has no directory specified, it
656 /// will use the platform working directory. If \a dst has a
657 /// directory specified, but the directory path is relative, the
658 /// platform working directory will be prepended to the relative
662 /// An error object that describes anything that went wrong.
663 //----------------------------------------------------------------------
665 Install (const FileSpec& src, const FileSpec& dst);
668 GetEnvironment (StringList &environment);
671 GetFileExists (const lldb_private::FileSpec& file_spec);
674 Unlink (const char *path);
679 return m_supports_rsync;
683 SetSupportsRSync(bool flag)
685 m_supports_rsync = flag;
691 return m_rsync_opts.c_str();
695 SetRSyncOpts (const char* opts)
697 m_rsync_opts.assign(opts);
703 return m_rsync_prefix.c_str();
707 SetRSyncPrefix (const char* prefix)
709 m_rsync_prefix.assign(prefix);
715 return m_supports_ssh;
719 SetSupportsSSH(bool flag)
721 m_supports_ssh = flag;
727 return m_ssh_opts.c_str();
731 SetSSHOpts (const char* opts)
733 m_ssh_opts.assign(opts);
737 GetIgnoresRemoteHostname ()
739 return m_ignores_remote_hostname;
743 SetIgnoresRemoteHostname(bool flag)
745 m_ignores_remote_hostname = flag;
748 virtual lldb_private::OptionGroupOptions *
749 GetConnectionOptions (CommandInterpreter& interpreter)
754 virtual lldb_private::Error
755 RunShellCommand (const char *command, // Shouldn't be NULL
756 const char *working_dir, // Pass NULL to use the current working directory
757 int *status_ptr, // Pass NULL if you don't want the process exit status
758 int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit
759 std::string *command_output, // Pass NULL if you don't want the command output
760 uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish
763 SetLocalCacheDirectory (const char* local);
766 GetLocalCacheDirectory ();
769 GetPlatformSpecificConnectionInformation()
775 CalculateMD5 (const FileSpec& file_spec,
780 GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
785 //------------------------------------------------------------------
786 /// Locate a queue name given a thread's qaddr
788 /// On a system using libdispatch ("Grand Central Dispatch") style
789 /// queues, a thread may be associated with a GCD queue or not,
790 /// and a queue may be associated with multiple threads.
791 /// The process/thread must provide a way to find the "dispatch_qaddr"
792 /// for each thread, and from that dispatch_qaddr this Platform method
793 /// will locate the queue name and provide that.
795 /// @param[in] process
796 /// A process is required for reading memory.
798 /// @param[in] dispatch_qaddr
799 /// The dispatch_qaddr for this thread.
802 /// The name of the queue, if there is one. An empty string
803 /// means that this thread is not associated with a dispatch
805 //------------------------------------------------------------------
807 GetQueueNameForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
812 //------------------------------------------------------------------
813 /// Locate a queue ID given a thread's qaddr
815 /// On a system using libdispatch ("Grand Central Dispatch") style
816 /// queues, a thread may be associated with a GCD queue or not,
817 /// and a queue may be associated with multiple threads.
818 /// The process/thread must provide a way to find the "dispatch_qaddr"
819 /// for each thread, and from that dispatch_qaddr this Platform method
820 /// will locate the queue ID and provide that.
822 /// @param[in] process
823 /// A process is required for reading memory.
825 /// @param[in] dispatch_qaddr
826 /// The dispatch_qaddr for this thread.
829 /// The queue_id for this thread, if this thread is associated
830 /// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned.
831 //------------------------------------------------------------------
832 virtual lldb::queue_id_t
833 GetQueueIDForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr)
835 return LLDB_INVALID_QUEUE_ID;
838 //------------------------------------------------------------------
839 /// Provide a list of trap handler function names for this platform
841 /// The unwinder needs to treat trap handlers specially -- the stack
842 /// frame may not be aligned correctly for a trap handler (the kernel
843 /// often won't perturb the stack pointer, or won't re-align it properly,
844 /// in the process of calling the handler) and the frame above the handler
845 /// needs to be treated by the unwinder's "frame 0" rules instead of its
846 /// "middle of the stack frame" rules.
848 /// In a user process debugging scenario, the list of trap handlers is
849 /// typically just "_sigtramp".
851 /// The Platform base class provides the m_trap_handlers ivar but it does
852 /// not populate it. Subclasses should add the names of the asynchronous
853 /// signal handler routines as needed. For most Unix platforms, add _sigtramp.
856 /// A list of symbol names. The list may be empty.
857 //------------------------------------------------------------------
858 virtual const std::vector<ConstString> &
859 GetTrapHandlerSymbolNames ();
863 // Set to true when we are able to actually set the OS version while
864 // being connected. For remote platforms, we might set the version ahead
865 // of time before we actually connect and this version might change when
866 // we actually connect to a remote platform. For the host platform this
867 // will be set to the once we call Host::GetOSVersion().
868 bool m_os_version_set_while_connected;
869 bool m_system_arch_set_while_connected;
870 ConstString m_sdk_sysroot; // the root location of where the SDK files are all located
871 ConstString m_sdk_build;
872 ConstString m_working_dir; // The working directory which is used when installing modules that have no install path set
873 std::string m_remote_url;
875 uint32_t m_major_os_version;
876 uint32_t m_minor_os_version;
877 uint32_t m_update_os_version;
878 ArchSpec m_system_arch; // The architecture of the kernel or the remote platform
879 typedef std::map<uint32_t, ConstString> IDToNameMap;
880 Mutex m_uid_map_mutex;
881 Mutex m_gid_map_mutex;
882 IDToNameMap m_uid_map;
883 IDToNameMap m_gid_map;
884 size_t m_max_uid_name_len;
885 size_t m_max_gid_name_len;
886 bool m_supports_rsync;
887 std::string m_rsync_opts;
888 std::string m_rsync_prefix;
890 std::string m_ssh_opts;
891 bool m_ignores_remote_hostname;
892 std::string m_local_cache_directory;
893 std::vector<ConstString> m_trap_handlers;
894 bool m_calculated_trap_handlers;
896 //------------------------------------------------------------------
897 /// Ask the Platform subclass to fill in the list of trap handler names
899 /// For most Unix user process environments, this will be a single
900 /// function name, _sigtramp. More specialized environments may have
901 /// additional handler names. The unwinder code needs to know when a
902 /// trap handler is on the stack because the unwind rules for the frame
903 /// that caused the trap are different.
905 /// The base class Platform ivar m_trap_handlers should be updated by
906 /// the Platform subclass when this method is called. If there are no
907 /// predefined trap handlers, this method may be a no-op.
908 //------------------------------------------------------------------
910 CalculateTrapHandlerSymbolNames () = 0;
913 GetCachedUserName (uint32_t uid)
915 Mutex::Locker locker (m_uid_map_mutex);
916 IDToNameMap::iterator pos = m_uid_map.find (uid);
917 if (pos != m_uid_map.end())
919 // return the empty string if our string is NULL
920 // so we can tell when things were in the negative
921 // cached (didn't find a valid user name, don't keep
923 return pos->second.AsCString("");
929 SetCachedUserName (uint32_t uid, const char *name, size_t name_len)
931 Mutex::Locker locker (m_uid_map_mutex);
932 ConstString const_name (name);
933 m_uid_map[uid] = const_name;
934 if (m_max_uid_name_len < name_len)
935 m_max_uid_name_len = name_len;
936 // Const strings lives forever in our const string pool, so we can return the const char *
937 return const_name.GetCString();
941 SetUserNameNotFound (uint32_t uid)
943 Mutex::Locker locker (m_uid_map_mutex);
944 m_uid_map[uid] = ConstString();
949 ClearCachedUserNames ()
951 Mutex::Locker locker (m_uid_map_mutex);
956 GetCachedGroupName (uint32_t gid)
958 Mutex::Locker locker (m_gid_map_mutex);
959 IDToNameMap::iterator pos = m_gid_map.find (gid);
960 if (pos != m_gid_map.end())
962 // return the empty string if our string is NULL
963 // so we can tell when things were in the negative
964 // cached (didn't find a valid group name, don't keep
966 return pos->second.AsCString("");
972 SetCachedGroupName (uint32_t gid, const char *name, size_t name_len)
974 Mutex::Locker locker (m_gid_map_mutex);
975 ConstString const_name (name);
976 m_gid_map[gid] = const_name;
977 if (m_max_gid_name_len < name_len)
978 m_max_gid_name_len = name_len;
979 // Const strings lives forever in our const string pool, so we can return the const char *
980 return const_name.GetCString();
984 SetGroupNameNotFound (uint32_t gid)
986 Mutex::Locker locker (m_gid_map_mutex);
987 m_gid_map[gid] = ConstString();
991 ClearCachedGroupNames ()
993 Mutex::Locker locker (m_gid_map_mutex);
998 DISALLOW_COPY_AND_ASSIGN (Platform);
1006 m_mutex (Mutex::eMutexTypeRecursive),
1008 m_selected_platform_sp()
1017 Append (const lldb::PlatformSP &platform_sp, bool set_selected)
1019 Mutex::Locker locker (m_mutex);
1020 m_platforms.push_back (platform_sp);
1022 m_selected_platform_sp = m_platforms.back();
1028 Mutex::Locker locker (m_mutex);
1029 return m_platforms.size();
1033 GetAtIndex (uint32_t idx)
1035 lldb::PlatformSP platform_sp;
1037 Mutex::Locker locker (m_mutex);
1038 if (idx < m_platforms.size())
1039 platform_sp = m_platforms[idx];
1044 //------------------------------------------------------------------
1045 /// Select the active platform.
1047 /// In order to debug remotely, other platform's can be remotely
1048 /// connected to and set as the selected platform for any subsequent
1049 /// debugging. This allows connection to remote targets and allows
1050 /// the ability to discover process info, launch and attach to remote
1052 //------------------------------------------------------------------
1054 GetSelectedPlatform ()
1056 Mutex::Locker locker (m_mutex);
1057 if (!m_selected_platform_sp && !m_platforms.empty())
1058 m_selected_platform_sp = m_platforms.front();
1060 return m_selected_platform_sp;
1064 SetSelectedPlatform (const lldb::PlatformSP &platform_sp)
1068 Mutex::Locker locker (m_mutex);
1069 const size_t num_platforms = m_platforms.size();
1070 for (size_t idx=0; idx<num_platforms; ++idx)
1072 if (m_platforms[idx].get() == platform_sp.get())
1074 m_selected_platform_sp = m_platforms[idx];
1078 m_platforms.push_back (platform_sp);
1079 m_selected_platform_sp = m_platforms.back();
1084 typedef std::vector<lldb::PlatformSP> collection;
1085 mutable Mutex m_mutex;
1086 collection m_platforms;
1087 lldb::PlatformSP m_selected_platform_sp;
1090 DISALLOW_COPY_AND_ASSIGN (PlatformList);
1093 class OptionGroupPlatformRSync : public lldb_private::OptionGroup
1096 OptionGroupPlatformRSync ();
1099 ~OptionGroupPlatformRSync ();
1101 virtual lldb_private::Error
1102 SetOptionValue (CommandInterpreter &interpreter,
1103 uint32_t option_idx,
1104 const char *option_value);
1107 OptionParsingStarting (CommandInterpreter &interpreter);
1109 const lldb_private::OptionDefinition*
1113 GetNumDefinitions ();
1115 // Options table: Required for subclasses of Options.
1117 static lldb_private::OptionDefinition g_option_table[];
1119 // Instance variables to hold the values for command options.
1122 std::string m_rsync_opts;
1123 std::string m_rsync_prefix;
1124 bool m_ignores_remote_hostname;
1126 DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
1129 class OptionGroupPlatformSSH : public lldb_private::OptionGroup
1132 OptionGroupPlatformSSH ();
1135 ~OptionGroupPlatformSSH ();
1137 virtual lldb_private::Error
1138 SetOptionValue (CommandInterpreter &interpreter,
1139 uint32_t option_idx,
1140 const char *option_value);
1143 OptionParsingStarting (CommandInterpreter &interpreter);
1146 GetNumDefinitions ();
1148 const lldb_private::OptionDefinition*
1151 // Options table: Required for subclasses of Options.
1153 static lldb_private::OptionDefinition g_option_table[];
1155 // Instance variables to hold the values for command options.
1158 std::string m_ssh_opts;
1162 DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
1165 class OptionGroupPlatformCaching : public lldb_private::OptionGroup
1168 OptionGroupPlatformCaching ();
1171 ~OptionGroupPlatformCaching ();
1173 virtual lldb_private::Error
1174 SetOptionValue (CommandInterpreter &interpreter,
1175 uint32_t option_idx,
1176 const char *option_value);
1179 OptionParsingStarting (CommandInterpreter &interpreter);
1182 GetNumDefinitions ();
1184 const lldb_private::OptionDefinition*
1187 // Options table: Required for subclasses of Options.
1189 static lldb_private::OptionDefinition g_option_table[];
1191 // Instance variables to hold the values for command options.
1193 std::string m_cache_dir;
1195 DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
1198 } // namespace lldb_private
1200 #endif // liblldb_Platform_h_