Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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" |
Greg Clayton | 53239f0 | 2011-02-08 05:05:52 +0000 | [diff] [blame] | 12 | #include "lldb/Host/FileSpec.h" |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 13 | #include "lldb/Core/Log.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 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 | |
Jim Ingham | e2231ac | 2012-12-21 22:22:26 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 41 | lldb::thread_t |
| 42 | SBHostOS::ThreadCreate |
| 43 | ( |
| 44 | const char *name, |
Deepak Panickal | 99fbc07 | 2014-03-03 15:39:47 +0000 | [diff] [blame] | 45 | lldb::thread_func_t thread_function, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | void *thread_arg, |
| 47 | SBError *error_ptr |
| 48 | ) |
| 49 | { |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 50 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 51 | |
| 52 | if (log) |
Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 53 | log->Printf ("SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, thread_arg=%p, error_ptr=%p)", |
| 54 | name, reinterpret_cast<void*>(thread_function), |
| 55 | static_cast<void*>(thread_arg), |
| 56 | static_cast<void*>(error_ptr)); |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 57 | |
Caroline Tice | c1338e8 | 2011-06-14 16:36:12 +0000 | [diff] [blame] | 58 | // FIXME: You should log the return value? |
Caroline Tice | ceb6b13 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 59 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 60 | return Host::ThreadCreate (name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL); |
| 61 | } |
| 62 | |
| 63 | void |
| 64 | SBHostOS::ThreadCreated (const char *name) |
| 65 | { |
| 66 | Host::ThreadCreated (name); |
| 67 | } |
| 68 | |
| 69 | bool |
| 70 | SBHostOS::ThreadCancel (lldb::thread_t thread, SBError *error_ptr) |
| 71 | { |
| 72 | return Host::ThreadCancel (thread, error_ptr ? error_ptr->get() : NULL); |
| 73 | } |
| 74 | |
| 75 | bool |
| 76 | SBHostOS::ThreadDetach (lldb::thread_t thread, SBError *error_ptr) |
| 77 | { |
| 78 | return Host::ThreadDetach (thread, error_ptr ? error_ptr->get() : NULL); |
| 79 | } |
| 80 | |
| 81 | bool |
Deepak Panickal | 99fbc07 | 2014-03-03 15:39:47 +0000 | [diff] [blame] | 82 | SBHostOS::ThreadJoin (lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 83 | { |
| 84 | return Host::ThreadJoin (thread, result, error_ptr ? error_ptr->get() : NULL); |
| 85 | } |
| 86 | |
| 87 | |