Path: blob/main/contrib/llvm-project/lldb/source/API/SBHostOS.cpp
39587 views
//===-- SBHostOS.cpp ------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/API/SBHostOS.h"9#include "lldb/API/SBError.h"10#include "lldb/Host/Config.h"11#include "lldb/Host/FileSystem.h"12#include "lldb/Host/Host.h"13#include "lldb/Host/HostInfo.h"14#include "lldb/Host/HostNativeThread.h"15#include "lldb/Host/HostThread.h"16#include "lldb/Host/ThreadLauncher.h"17#include "lldb/Utility/FileSpec.h"18#include "lldb/Utility/Instrumentation.h"1920#include "Plugins/ExpressionParser/Clang/ClangHost.h"21#if LLDB_ENABLE_PYTHON22#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"23#endif2425#include "llvm/ADT/SmallString.h"26#include "llvm/Support/Path.h"2728using namespace lldb;29using namespace lldb_private;3031SBFileSpec SBHostOS::GetProgramFileSpec() {32LLDB_INSTRUMENT();3334SBFileSpec sb_filespec;35sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec());36return sb_filespec;37}3839SBFileSpec SBHostOS::GetLLDBPythonPath() {40LLDB_INSTRUMENT();4142return GetLLDBPath(ePathTypePythonDir);43}4445SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {46LLDB_INSTRUMENT_VA(path_type);4748FileSpec fspec;49switch (path_type) {50case ePathTypeLLDBShlibDir:51fspec = HostInfo::GetShlibDir();52break;53case ePathTypeSupportExecutableDir:54fspec = HostInfo::GetSupportExeDir();55break;56case ePathTypeHeaderDir:57fspec = HostInfo::GetHeaderDir();58break;59case ePathTypePythonDir:60#if LLDB_ENABLE_PYTHON61fspec = ScriptInterpreterPython::GetPythonDir();62#endif63break;64case ePathTypeLLDBSystemPlugins:65fspec = HostInfo::GetSystemPluginDir();66break;67case ePathTypeLLDBUserPlugins:68fspec = HostInfo::GetUserPluginDir();69break;70case ePathTypeLLDBTempSystemDir:71fspec = HostInfo::GetProcessTempDir();72break;73case ePathTypeGlobalLLDBTempSystemDir:74fspec = HostInfo::GetGlobalTempDir();75break;76case ePathTypeClangDir:77fspec = GetClangResourceDir();78break;79}8081SBFileSpec sb_fspec;82sb_fspec.SetFileSpec(fspec);83return sb_fspec;84}8586SBFileSpec SBHostOS::GetUserHomeDirectory() {87LLDB_INSTRUMENT();8889FileSpec homedir;90FileSystem::Instance().GetHomeDirectory(homedir);91FileSystem::Instance().Resolve(homedir);9293SBFileSpec sb_fspec;94sb_fspec.SetFileSpec(homedir);9596return sb_fspec;97}9899lldb::thread_t SBHostOS::ThreadCreate(const char *name,100lldb::thread_func_t thread_function,101void *thread_arg, SBError *error_ptr) {102LLDB_INSTRUMENT_VA(name, thread_function, thread_arg, error_ptr);103return LLDB_INVALID_HOST_THREAD;104}105106void SBHostOS::ThreadCreated(const char *name) { LLDB_INSTRUMENT_VA(name); }107108bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) {109LLDB_INSTRUMENT_VA(thread, error_ptr);110return false;111}112113bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) {114LLDB_INSTRUMENT_VA(thread, error_ptr);115return false;116}117118bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result,119SBError *error_ptr) {120LLDB_INSTRUMENT_VA(thread, result, error_ptr);121return false;122}123124125