LLDB  mainline
PlatformDarwin.h
Go to the documentation of this file.
1 //===-- PlatformDarwin.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWIN_H
10 #define LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWIN_H
11 
13 #include "lldb/Host/FileSystem.h"
15 #include "lldb/Utility/FileSpec.h"
17 #include "lldb/Utility/XcodeSDK.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/Support/FileSystem.h"
20 
21 #include <string>
22 #include <tuple>
23 
24 class PlatformDarwin : public PlatformPOSIX {
25 public:
26  PlatformDarwin(bool is_host);
27 
28  ~PlatformDarwin() override;
29 
31  const lldb_private::FileSpec &destination,
32  uint32_t uid = UINT32_MAX,
33  uint32_t gid = UINT32_MAX) override;
34 
35  // lldb_private::Platform functions
38  const lldb_private::ModuleSpec &sym_spec,
39  lldb_private::FileSpec &sym_file) override;
40 
41  lldb_private::FileSpecList LocateExecutableScriptingResources(
43  lldb_private::Stream *feedback_stream) override;
44 
46  GetSharedModule(const lldb_private::ModuleSpec &module_spec,
47  lldb_private::Process *process, lldb::ModuleSP &module_sp,
48  const lldb_private::FileSpecList *module_search_paths_ptr,
49  lldb::ModuleSP *old_module_sp_ptr,
50  bool *did_create_ptr) override;
51 
53  lldb_private::Target &target,
54  lldb_private::BreakpointSite *bp_site) override;
55 
56  lldb::BreakpointSP
58 
60  lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
61 
64 
67 
69  lldb_private::ProcessLaunchInfo &launch_info) override;
70 
71  void CalculateTrapHandlerSymbolNames() override;
72 
73  llvm::VersionTuple
74  GetOSVersion(lldb_private::Process *process = nullptr) override;
75 
76  bool SupportsModules() override { return true; }
77 
80 
81  lldb_private::FileSpec LocateExecutable(const char *basename) override;
82 
84  LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
85 
86  static std::tuple<llvm::VersionTuple, llvm::StringRef>
87  ParseVersionBuildDir(llvm::StringRef str);
88 
89  llvm::Expected<lldb_private::StructuredData::DictionarySP>
91 
94 
95  /// Return the toolchain directory the current LLDB instance is located in.
97 
98  /// Return the command line tools directory the current LLDB instance is
99  /// located in.
101 
102 protected:
104  uint64_t version; // unsigned long
105  uint64_t message; // char *
106  uint64_t signature_string; // char *
107  uint64_t backtrace; // char *
108  uint64_t message2; // char *
109  uint64_t thread; // uint64_t
110  uint64_t dialog_mode; // unsigned int
111  uint64_t abort_cause; // unsigned int
112  };
113 
114  /// Extract the `__crash_info` annotations from each of of the target's
115  /// modules.
116  ///
117  /// If the platform have a crashed processes with a `__crash_info` section,
118  /// extract the section to gather the messages annotations and the abort
119  /// cause.
120  ///
121  /// \param[in] process
122  /// The crashed process.
123  ///
124  /// \return
125  /// A structured data array containing at each entry in each entry, the
126  /// module spec, its UUID, the crash messages and the abort cause.
127  /// \b nullptr if process has no crash information annotations.
130 
132 
134 
136  const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
137  const lldb_private::FileSpecList *module_search_paths_ptr,
138  lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr);
139 
143  };
144 
146  DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type,
147  llvm::StringRef path);
148 
151  const lldb_private::FileSpec &sdks_spec);
152 
155 
157  lldb_private::Target *target, std::vector<std::string> &options,
159 
161  const lldb_private::ModuleSpec &module_spec,
162  lldb_private::Process *process, lldb::ModuleSP &module_sp,
163  const lldb_private::FileSpecList *module_search_paths_ptr,
164  lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr);
165 
166  static std::string FindComponentInPath(llvm::StringRef path,
167  llvm::StringRef component);
168  static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
169 
171  llvm::StringMap<std::string> m_sdk_path;
172  std::mutex m_sdk_path_mutex;
173 
174 private:
176 };
177 
178 #endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWIN_H
lldb_private::StructuredData::ArraySP ExtractCrashInfoAnnotations(lldb_private::Process &process)
Extract the __crash_info annotations from each of of the target&#39;s modules.
Class that manages the actual breakpoint that will be inserted into the running program.
PlatformDarwin(bool is_host)
Default Constructor.
Type
Different types of Xcode SDKs.
Definition: XcodeSDK.h:29
llvm::StringMap< std::string > m_sdk_path
static lldb_private::FileSpec GetCurrentCommandLineToolsDirectory()
Return the command line tools directory the current LLDB instance is located in.
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
lldb::BreakpointSP SetThreadCreationBreakpoint(lldb_private::Target &target) override
std::shared_ptr< Array > ArraySP
static lldb_private::FileSpec GetXcodeDeveloperDirectory()
lldb_private::XcodeSDK::Type sdk_type
lldb_private::FileSpecList LocateExecutableScriptingResources(lldb_private::Target *target, lldb_private::Module &module, lldb_private::Stream *feedback_stream) override
std::string m_developer_directory
lldb_private::Status FindBundleBinaryInExecSearchPaths(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr)
bool ARMGetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch)
A file utility class.
Definition: FileSpec.h:56
An architecture specification class.
Definition: ArchSpec.h:33
static lldb_private::FileSpec GetCurrentToolchainDirectory()
Return the toolchain directory the current LLDB instance is located in.
void AddClangModuleCompilationOptionsForSDKType(lldb_private::Target *target, std::vector< std::string > &options, lldb_private::XcodeSDK::Type sdk_type)
std::mutex m_sdk_path_mutex
lldb_private::Status GetSharedModule(const lldb_private::ModuleSpec &module_spec, lldb_private::Process *process, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr) override
bool SupportsModules() override
size_t GetSoftwareBreakpointTrapOpcode(lldb_private::Target &target, lldb_private::BreakpointSite *bp_site) override
static std::string FindComponentInPath(llvm::StringRef path, llvm::StringRef component)
lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override
static lldb_private::FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path)
#define UINT32_MAX
Definition: lldb-defines.h:31
void ReadLibdispatchOffsetsAddress(lldb_private::Process *process)
static lldb_private::FileSpec GetXcodeContentsDirectory()
void ReadLibdispatchOffsets(lldb_private::Process *process)
lldb_private::Status LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
llvm::Expected< lldb_private::StructuredData::DictionarySP > FetchExtendedCrashInformation(lldb_private::Process &process) override
Gather all of crash informations into a structured data dictionary.
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:75
lldb_private::FileSpec found_path
bool ModuleIsExcludedForUnconstrainedSearches(lldb_private::Target &target, const lldb::ModuleSP &module_sp) override
DISALLOW_COPY_AND_ASSIGN(PlatformDarwin)
lldb_private::Status PutFile(const lldb_private::FileSpec &source, const lldb_private::FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
A plug-in interface definition class for debugging a process.
Definition: Process.h:362
lldb_private::Status ResolveSymbolFile(lldb_private::Target &target, const lldb_private::ModuleSpec &sym_spec, lldb_private::FileSpec &sym_file) override
Find a symbol file given a symbol file module specification.
llvm::VersionTuple GetOSVersion(lldb_private::Process *process=nullptr) override
Get the OS version from a connected platform.
bool x86GetSupportedArchitectureAtIndex(uint32_t idx, lldb_private::ArchSpec &arch)
~PlatformDarwin() override
Destructor.
A uniqued constant string class.
Definition: ConstString.h:40
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
int32_t GetResumeCountForLaunchInfo(lldb_private::ProcessLaunchInfo &launch_info) override
virtual lldb_private::Status GetSharedModuleWithLocalCache(const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, const lldb_private::FileSpecList *module_search_paths_ptr, lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr)
static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path)
static lldb_private::FileSpec FindSDKInXcodeForModules(lldb_private::XcodeSDK::Type sdk_type, const lldb_private::FileSpec &sdks_spec)
static lldb_private::FileSpec GetSDKDirectoryForModules(lldb_private::XcodeSDK::Type sdk_type)
static std::tuple< llvm::VersionTuple, llvm::StringRef > ParseVersionBuildDir(llvm::StringRef str)
lldb_private::FileSpec LocateExecutable(const char *basename) override
Find a support executable that may not live within in the standard locations related to LLDB...
An error handling class.
Definition: Status.h:44