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 #include "lldb/Host/HostInfo.h"
16 
17 using namespace lldb;
18 using namespace lldb_private;
19 
20 
21 
22 SBFileSpec
23 SBHostOS::GetProgramFileSpec ()
24 {
25     SBFileSpec sb_filespec;
26     sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec());
27     return sb_filespec;
28 }
29 
30 SBFileSpec
31 SBHostOS::GetLLDBPythonPath ()
32 {
33     SBFileSpec sb_lldb_python_filespec;
34     FileSpec lldb_python_spec;
35     if (HostInfo::GetLLDBPath(ePathTypePythonDir, lldb_python_spec))
36     {
37         sb_lldb_python_filespec.SetFileSpec (lldb_python_spec);
38     }
39     return sb_lldb_python_filespec;
40 }
41 
42 
43 SBFileSpec
44 SBHostOS::GetLLDBPath (lldb::PathType path_type)
45 {
46     SBFileSpec sb_fspec;
47     FileSpec fspec;
48     if (HostInfo::GetLLDBPath(path_type, fspec))
49         sb_fspec.SetFileSpec (fspec);
50     return sb_fspec;
51 }
52 
53 lldb::thread_t
54 SBHostOS::ThreadCreate
55 (
56     const char *name,
57     lldb::thread_func_t thread_function,
58     void *thread_arg,
59     SBError *error_ptr
60 )
61 {
62     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
63 
64     if (log)
65         log->Printf ("SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, thread_arg=%p, error_ptr=%p)",
66                      name, reinterpret_cast<void*>(reinterpret_cast<intptr_t>(thread_function)),
67                      static_cast<void*>(thread_arg),
68                      static_cast<void*>(error_ptr));
69 
70     // FIXME: You should log the return value?
71 
72     return Host::ThreadCreate (name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL);
73 }
74 
75 void
76 SBHostOS::ThreadCreated (const char *name)
77 {
78     Host::ThreadCreated (name);
79 }
80 
81 bool
82 SBHostOS::ThreadCancel (lldb::thread_t thread, SBError *error_ptr)
83 {
84     return Host::ThreadCancel (thread, error_ptr ? error_ptr->get() : NULL);
85 }
86 
87 bool
88 SBHostOS::ThreadDetach (lldb::thread_t thread, SBError *error_ptr)
89 {
90     return Host::ThreadDetach (thread, error_ptr ? error_ptr->get() : NULL);
91 }
92 
93 bool
94 SBHostOS::ThreadJoin (lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr)
95 {
96     return Host::ThreadJoin (thread, result, error_ptr ? error_ptr->get() : NULL);
97 }
98 
99 
100