1 //===-- SBHostOS.cpp ------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBHostOS.h"
10 #include "lldb/API/SBError.h"
11 #include "lldb/Host/Config.h"
12 #include "lldb/Host/FileSystem.h"
13 #include "lldb/Host/Host.h"
14 #include "lldb/Host/HostInfo.h"
15 #include "lldb/Host/HostNativeThread.h"
16 #include "lldb/Host/HostThread.h"
17 #include "lldb/Host/ThreadLauncher.h"
18 #include "lldb/Utility/FileSpec.h"
19 #include "lldb/Utility/Instrumentation.h"
21 #include "Plugins/ExpressionParser/Clang/ClangHost.h"
22 #if LLDB_ENABLE_PYTHON
23 #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
26 #include "llvm/ADT/SmallString.h"
27 #include "llvm/Support/Path.h"
30 using namespace lldb_private
;
32 SBFileSpec
SBHostOS::GetProgramFileSpec() {
35 SBFileSpec sb_filespec
;
36 sb_filespec
.SetFileSpec(HostInfo::GetProgramFileSpec());
40 SBFileSpec
SBHostOS::GetLLDBPythonPath() {
43 return GetLLDBPath(ePathTypePythonDir
);
46 SBFileSpec
SBHostOS::GetLLDBPath(lldb::PathType path_type
) {
47 LLDB_INSTRUMENT_VA(path_type
);
51 case ePathTypeLLDBShlibDir
:
52 fspec
= HostInfo::GetShlibDir();
54 case ePathTypeSupportExecutableDir
:
55 fspec
= HostInfo::GetSupportExeDir();
57 case ePathTypeHeaderDir
:
58 fspec
= HostInfo::GetHeaderDir();
60 case ePathTypePythonDir
:
61 #if LLDB_ENABLE_PYTHON
62 fspec
= ScriptInterpreterPython::GetPythonDir();
65 case ePathTypeLLDBSystemPlugins
:
66 fspec
= HostInfo::GetSystemPluginDir();
68 case ePathTypeLLDBUserPlugins
:
69 fspec
= HostInfo::GetUserPluginDir();
71 case ePathTypeLLDBTempSystemDir
:
72 fspec
= HostInfo::GetProcessTempDir();
74 case ePathTypeGlobalLLDBTempSystemDir
:
75 fspec
= HostInfo::GetGlobalTempDir();
77 case ePathTypeClangDir
:
78 fspec
= GetClangResourceDir();
83 sb_fspec
.SetFileSpec(fspec
);
87 SBFileSpec
SBHostOS::GetUserHomeDirectory() {
91 FileSystem::Instance().GetHomeDirectory(homedir
);
92 FileSystem::Instance().Resolve(homedir
);
95 sb_fspec
.SetFileSpec(homedir
);
100 lldb::thread_t
SBHostOS::ThreadCreate(const char *name
,
101 lldb::thread_func_t thread_function
,
102 void *thread_arg
, SBError
*error_ptr
) {
103 LLDB_INSTRUMENT_VA(name
, thread_function
, thread_arg
, error_ptr
);
104 return LLDB_INVALID_HOST_THREAD
;
107 void SBHostOS::ThreadCreated(const char *name
) { LLDB_INSTRUMENT_VA(name
); }
109 bool SBHostOS::ThreadCancel(lldb::thread_t thread
, SBError
*error_ptr
) {
110 LLDB_INSTRUMENT_VA(thread
, error_ptr
);
114 bool SBHostOS::ThreadDetach(lldb::thread_t thread
, SBError
*error_ptr
) {
115 LLDB_INSTRUMENT_VA(thread
, error_ptr
);
119 bool SBHostOS::ThreadJoin(lldb::thread_t thread
, lldb::thread_result_t
*result
,
120 SBError
*error_ptr
) {
121 LLDB_INSTRUMENT_VA(thread
, result
, error_ptr
);