2020-07-26 15:36:28 -04:00
|
|
|
//===-- SBHostOS.cpp ------------------------------------------------------===//
|
2013-08-23 13:46:38 -04:00
|
|
|
//
|
2019-08-20 16:51:52 -04:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-08-23 13:46:38 -04:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2020-01-17 15:45:01 -05:00
|
|
|
#include "lldb/API/SBHostOS.h"
|
2013-08-23 13:46:38 -04:00
|
|
|
#include "lldb/API/SBError.h"
|
2020-01-17 15:45:01 -05:00
|
|
|
#include "lldb/Host/Config.h"
|
2019-01-19 05:06:29 -05:00
|
|
|
#include "lldb/Host/FileSystem.h"
|
2013-08-23 13:46:38 -04:00
|
|
|
#include "lldb/Host/Host.h"
|
2014-11-25 16:00:58 -05:00
|
|
|
#include "lldb/Host/HostInfo.h"
|
2015-02-06 16:38:51 -05:00
|
|
|
#include "lldb/Host/HostNativeThread.h"
|
|
|
|
|
#include "lldb/Host/HostThread.h"
|
|
|
|
|
#include "lldb/Host/ThreadLauncher.h"
|
2017-04-16 12:04:10 -04:00
|
|
|
#include "lldb/Utility/FileSpec.h"
|
2022-01-27 17:06:42 -05:00
|
|
|
#include "lldb/Utility/Instrumentation.h"
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2018-07-28 07:09:23 -04:00
|
|
|
#include "Plugins/ExpressionParser/Clang/ClangHost.h"
|
2020-01-17 15:45:01 -05:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2018-07-28 07:09:23 -04:00
|
|
|
#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-07-23 16:50:09 -04:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2017-01-02 14:26:05 -05:00
|
|
|
#include "llvm/Support/Path.h"
|
2016-07-23 16:50:09 -04:00
|
|
|
|
2013-08-23 13:46:38 -04:00
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBFileSpec SBHostOS::GetProgramFileSpec() {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT();
|
2019-08-20 16:51:52 -04:00
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBFileSpec sb_filespec;
|
|
|
|
|
sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec());
|
2022-01-27 17:06:42 -05:00
|
|
|
return sb_filespec;
|
2017-01-02 14:26:05 -05:00
|
|
|
}
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBFileSpec SBHostOS::GetLLDBPythonPath() {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT();
|
2019-08-20 16:51:52 -04:00
|
|
|
|
2022-01-27 17:06:42 -05:00
|
|
|
return GetLLDBPath(ePathTypePythonDir);
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT_VA(path_type);
|
2019-08-20 16:51:52 -04:00
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
FileSpec fspec;
|
2018-07-28 07:09:23 -04:00
|
|
|
switch (path_type) {
|
|
|
|
|
case ePathTypeLLDBShlibDir:
|
|
|
|
|
fspec = HostInfo::GetShlibDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeSupportExecutableDir:
|
|
|
|
|
fspec = HostInfo::GetSupportExeDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeHeaderDir:
|
|
|
|
|
fspec = HostInfo::GetHeaderDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypePythonDir:
|
2020-01-17 15:45:01 -05:00
|
|
|
#if LLDB_ENABLE_PYTHON
|
2018-07-28 07:09:23 -04:00
|
|
|
fspec = ScriptInterpreterPython::GetPythonDir();
|
|
|
|
|
#endif
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeLLDBSystemPlugins:
|
|
|
|
|
fspec = HostInfo::GetSystemPluginDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeLLDBUserPlugins:
|
|
|
|
|
fspec = HostInfo::GetUserPluginDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeLLDBTempSystemDir:
|
|
|
|
|
fspec = HostInfo::GetProcessTempDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeGlobalLLDBTempSystemDir:
|
|
|
|
|
fspec = HostInfo::GetGlobalTempDir();
|
|
|
|
|
break;
|
|
|
|
|
case ePathTypeClangDir:
|
|
|
|
|
fspec = GetClangResourceDir();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SBFileSpec sb_fspec;
|
|
|
|
|
sb_fspec.SetFileSpec(fspec);
|
2022-01-27 17:06:42 -05:00
|
|
|
return sb_fspec;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
SBFileSpec SBHostOS::GetUserHomeDirectory() {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT();
|
2019-08-20 16:51:52 -04:00
|
|
|
|
2021-02-16 15:13:02 -05:00
|
|
|
FileSpec homedir;
|
|
|
|
|
FileSystem::Instance().GetHomeDirectory(homedir);
|
2019-01-19 05:06:29 -05:00
|
|
|
FileSystem::Instance().Resolve(homedir);
|
2017-01-02 14:26:05 -05:00
|
|
|
|
2021-02-16 15:13:02 -05:00
|
|
|
SBFileSpec sb_fspec;
|
2017-01-02 14:26:05 -05:00
|
|
|
sb_fspec.SetFileSpec(homedir);
|
2021-02-16 15:13:02 -05:00
|
|
|
|
2022-01-27 17:06:42 -05:00
|
|
|
return sb_fspec;
|
2014-11-25 16:00:58 -05:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
lldb::thread_t SBHostOS::ThreadCreate(const char *name,
|
|
|
|
|
lldb::thread_func_t thread_function,
|
|
|
|
|
void *thread_arg, SBError *error_ptr) {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT_VA(name, thread_function, thread_arg, error_ptr);
|
2023-12-18 15:30:12 -05:00
|
|
|
return LLDB_INVALID_HOST_THREAD;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2022-01-27 17:06:42 -05:00
|
|
|
void SBHostOS::ThreadCreated(const char *name) { LLDB_INSTRUMENT_VA(name); }
|
2013-08-23 13:46:38 -04:00
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT_VA(thread, error_ptr);
|
2023-12-18 15:30:12 -05:00
|
|
|
return false;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT_VA(thread, error_ptr);
|
2023-12-18 15:30:12 -05:00
|
|
|
return false;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 14:26:05 -05:00
|
|
|
bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result,
|
|
|
|
|
SBError *error_ptr) {
|
2022-01-27 17:06:42 -05:00
|
|
|
LLDB_INSTRUMENT_VA(thread, result, error_ptr);
|
2023-12-18 15:30:12 -05:00
|
|
|
return false;
|
2013-08-23 13:46:38 -04:00
|
|
|
}
|