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
19#include "lldb/Utility/Status.h"
22#include "lldb/lldb-forward.h"
23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/StringMap.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/ADT/Triple.h"
27#include "llvm/Support/Error.h"
28#include "llvm/Support/VersionTuple.h"
29
30#include <mutex>
31#include <optional>
32#include <string>
33#include <vector>
34
35namespace lldb_private {
36class BreakpointSite;
37class Debugger;
38class Module;
39class ModuleSpec;
40class Process;
41class ProcessLaunchInfo;
42class Stream;
43class Target;
44
46public:
48
49 ~PlatformDarwin() override;
50
51 static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
52
53 static void DebuggerInitialize(lldb_private::Debugger &debugger);
54
55 static void Initialize();
56
57 static void Terminate();
58
59 static llvm::StringRef GetPluginNameStatic() { return "darwin"; }
60
61 static llvm::StringRef GetDescriptionStatic();
62
63 Status PutFile(const FileSpec &source, const FileSpec &destination,
64 uint32_t uid = UINT32_MAX, uint32_t gid = UINT32_MAX) override;
65
66 // Platform functions
67 Status ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec,
68 FileSpec &sym_file) override;
69
70 FileSpecList
72 Stream *feedback_stream) override;
73
74 Status GetSharedModule(const ModuleSpec &module_spec, Process *process,
75 lldb::ModuleSP &module_sp,
76 const FileSpecList *module_search_paths_ptr,
78 bool *did_create_ptr) override;
79
81 BreakpointSite *bp_site) override;
82
83 lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target) override;
84
86 Target &target, const lldb::ModuleSP &module_sp) override;
87
88 void
89 ARMGetSupportedArchitectures(std::vector<ArchSpec> &archs,
90 std::optional<llvm::Triple::OSType> os = {});
91
92 void x86GetSupportedArchitectures(std::vector<ArchSpec> &archs);
93
94 uint32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
95
96 lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
97 Debugger &debugger, Target &target,
98 Status &error) override;
99
100 void CalculateTrapHandlerSymbolNames() override;
101
102 llvm::VersionTuple GetOSVersion(Process *process = nullptr) override;
103
104 bool SupportsModules() override { return true; }
105
107
108 FileSpec LocateExecutable(const char *basename) override;
109
110 Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
111
112 Args GetExtraStartupCommands() override;
113
114 static std::tuple<llvm::VersionTuple, llvm::StringRef>
115 ParseVersionBuildDir(llvm::StringRef str);
116
117 llvm::Expected<StructuredData::DictionarySP>
118 FetchExtendedCrashInformation(Process &process) override;
119
120 /// Return the toolchain directory the current LLDB instance is located in.
122
123 /// Return the command line tools directory the current LLDB instance is
124 /// located in.
126
127protected:
128 static const char *GetCompatibleArch(ArchSpec::Core core, size_t idx);
129
131 uint64_t version; // unsigned long
132 uint64_t message; // char *
133 uint64_t signature_string; // char *
134 uint64_t backtrace; // char *
135 uint64_t message2; // char *
136 uint64_t thread; // uint64_t
137 uint64_t dialog_mode; // unsigned int
138 uint64_t abort_cause; // unsigned int
139 };
140
141 /// Extract the `__crash_info` annotations from each of of the target's
142 /// modules.
143 ///
144 /// If the platform have a crashed processes with a `__crash_info` section,
145 /// extract the section to gather the messages annotations and the abort
146 /// cause.
147 ///
148 /// \param[in] process
149 /// The crashed process.
150 ///
151 /// \return
152 /// A structured data array containing at each entry in each entry, the
153 /// module spec, its UUID, the crash messages and the abort cause.
154 /// \b nullptr if process has no crash information annotations.
156
157 /// Extract the `Application Specific Information` messages from a crash
158 /// report.
160
162
164
165 virtual bool CheckLocalSharedCache() const { return IsHost(); }
166
170 };
171
173 DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type,
174 llvm::StringRef path);
175
177 const FileSpec &sdks_spec);
178
180
181 void
183 std::vector<std::string> &options,
184 XcodeSDK::Type sdk_type);
185
187 const ModuleSpec &module_spec, Process *process,
188 lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,
189 llvm::SmallVectorImpl<lldb::ModuleSP> *old_modules, bool *did_create_ptr);
190
191 static std::string FindComponentInPath(llvm::StringRef path,
192 llvm::StringRef component);
193
194 // The OSType where lldb is running.
195 static llvm::Triple::OSType GetHostOSType();
196
198 llvm::StringMap<std::string> m_sdk_path;
200
201private:
203 const PlatformDarwin &operator=(const PlatformDarwin &) = delete;
204};
205
206} // namespace lldb_private
207
208#endif // LLDB_SOURCE_PLUGINS_PLATFORM_MACOSX_PLATFORMDARWIN_H
static llvm::raw_ostream & error(Stream &strm)
PlatformPOSIX(bool is_host)
Default Constructor.
An architecture specification class.
Definition: ArchSpec.h:32
A command line argument class.
Definition: Args.h:33
Class that manages the actual breakpoint that will be inserted into the running program.
A uniqued constant string class.
Definition: ConstString.h:39
A class to manage flag bits.
Definition: Debugger.h:77
A file utility class.
Definition: FileSpec.h:56
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
void ReadLibdispatchOffsets(Process *process)
StructuredData::ArraySP ExtractCrashInfoAnnotations(Process &process)
Extract the __crash_info annotations from each of of the target's modules.
static FileSpec GetCurrentCommandLineToolsDirectory()
Return the command line tools directory the current LLDB instance is located in.
llvm::Expected< StructuredData::DictionarySP > FetchExtendedCrashInformation(Process &process) override
Gather all of crash informations into a structured data dictionary.
~PlatformDarwin() override
Destructor.
FileSpecList LocateExecutableScriptingResources(Target *target, Module &module, Stream *feedback_stream) override
static FileSpec GetSDKDirectoryForModules(XcodeSDK::Type sdk_type)
Status ResolveSymbolFile(Target &target, const ModuleSpec &sym_spec, FileSpec &sym_file) override
Find a symbol file given a symbol file module specification.
void CalculateTrapHandlerSymbolNames() override
Ask the Platform subclass to fill in the list of trap handler names.
static FileSpec GetCurrentToolchainDirectory()
Return the toolchain directory the current LLDB instance is located in.
static std::tuple< llvm::VersionTuple, llvm::StringRef > ParseVersionBuildDir(llvm::StringRef str)
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch)
llvm::VersionTuple GetOSVersion(Process *process=nullptr) override
Get the OS version from a connected platform.
void ReadLibdispatchOffsetsAddress(Process *process)
static FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path)
static std::string FindComponentInPath(llvm::StringRef path, llvm::StringRef component)
static FileSpec FindSDKInXcodeForModules(XcodeSDK::Type sdk_type, const FileSpec &sdks_spec)
ConstString GetFullNameForDylib(ConstString basename) override
static void DebuggerInitialize(lldb_private::Debugger &debugger)
static llvm::StringRef GetPluginNameStatic()
static llvm::Triple::OSType GetHostOSType()
virtual bool CheckLocalSharedCache() const
StructuredData::DictionarySP ExtractAppSpecificInfo(Process &process)
Extract the Application Specific Information messages from a crash report.
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, Target &target, Status &error) override
Subclasses do not need to implement this function as it uses the Platform::LaunchProcess() followed b...
lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target) override
static llvm::StringRef GetDescriptionStatic()
llvm::StringMap< std::string > m_sdk_path
Status LaunchProcess(ProcessLaunchInfo &launch_info) override
Launch a new process on a platform, not necessarily for debugging, it could be just for running the p...
const PlatformDarwin & operator=(const PlatformDarwin &)=delete
Status GetSharedModule(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr) override
static const char * GetCompatibleArch(ArchSpec::Core core, size_t idx)
uint32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override
Status FindBundleBinaryInExecSearchPaths(const ModuleSpec &module_spec, Process *process, lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, llvm::SmallVectorImpl< lldb::ModuleSP > *old_modules, bool *did_create_ptr)
size_t GetSoftwareBreakpointTrapOpcode(Target &target, BreakpointSite *bp_site) override
void AddClangModuleCompilationOptionsForSDKType(Target *target, std::vector< std::string > &options, XcodeSDK::Type sdk_type)
Args GetExtraStartupCommands() override
Status PutFile(const FileSpec &source, const FileSpec &destination, uint32_t uid=UINT32_MAX, uint32_t gid=UINT32_MAX) override
FileSpec LocateExecutable(const char *basename) override
Find a support executable that may not live within in the standard locations related to LLDB.
void x86GetSupportedArchitectures(std::vector< ArchSpec > &archs)
bool ModuleIsExcludedForUnconstrainedSearches(Target &target, const lldb::ModuleSP &module_sp) override
void ARMGetSupportedArchitectures(std::vector< ArchSpec > &archs, std::optional< llvm::Triple::OSType > os={})
The architecture selection rules for arm processors These cpu subtypes have distinct names (e....
PlatformDarwin(const PlatformDarwin &)=delete
bool IsHost() const
Definition: Platform.h:421
A plug-in interface definition class for debugging a process.
Definition: Process.h:342
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Array > ArraySP
Type
Different types of Xcode SDKs.
Definition: XcodeSDK.h:29
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.