1 //===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/API/SBHostOS.h" 11 #include "lldb/API/SBError.h" 12 #include "lldb/Host/FileSpec.h" 13 #include "lldb/Core/Log.h" 14 #include "lldb/Host/Host.h" 15 16 using namespace lldb; 17 using namespace lldb_private; 18 19 20 21 SBFileSpec 22 SBHostOS::GetProgramFileSpec () 23 { 24 SBFileSpec sb_filespec; 25 sb_filespec.SetFileSpec (Host::GetProgramFileSpec ()); 26 return sb_filespec; 27 } 28 29 SBFileSpec 30 SBHostOS::GetLLDBPythonPath () 31 { 32 SBFileSpec sb_lldb_python_filespec; 33 FileSpec lldb_python_spec; 34 if (Host::GetLLDBPath (ePathTypePythonDir, lldb_python_spec)) 35 { 36 sb_lldb_python_filespec.SetFileSpec (lldb_python_spec); 37 } 38 return sb_lldb_python_filespec; 39 } 40 41 42 SBFileSpec 43 SBHostOS::GetLLDBPath (lldb::PathType path_type) 44 { 45 SBFileSpec sb_fspec; 46 FileSpec fspec; 47 if (Host::GetLLDBPath (path_type, fspec)) 48 sb_fspec.SetFileSpec (fspec); 49 return sb_fspec; 50 } 51 52 lldb::thread_t 53 SBHostOS::ThreadCreate 54 ( 55 const char *name, 56 lldb::thread_func_t thread_function, 57 void *thread_arg, 58 SBError *error_ptr 59 ) 60 { 61 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 62 63 if (log) 64 log->Printf ("SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, thread_arg=%p, error_ptr=%p)", 65 name, reinterpret_cast<void*>(reinterpret_cast<intptr_t>(thread_function)), 66 static_cast<void*>(thread_arg), 67 static_cast<void*>(error_ptr)); 68 69 // FIXME: You should log the return value? 70 71 return Host::ThreadCreate (name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL); 72 } 73 74 void 75 SBHostOS::ThreadCreated (const char *name) 76 { 77 Host::ThreadCreated (name); 78 } 79 80 bool 81 SBHostOS::ThreadCancel (lldb::thread_t thread, SBError *error_ptr) 82 { 83 return Host::ThreadCancel (thread, error_ptr ? error_ptr->get() : NULL); 84 } 85 86 bool 87 SBHostOS::ThreadDetach (lldb::thread_t thread, SBError *error_ptr) 88 { 89 return Host::ThreadDetach (thread, error_ptr ? error_ptr->get() : NULL); 90 } 91 92 bool 93 SBHostOS::ThreadJoin (lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr) 94 { 95 return Host::ThreadJoin (thread, result, error_ptr ? error_ptr->get() : NULL); 96 } 97 98 99