diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/API/SBHostOS.cpp | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/API/SBHostOS.cpp')
-rw-r--r-- | source/API/SBHostOS.cpp | 97 |
1 files changed, 69 insertions, 28 deletions
diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp index ac6ab40bda41..c3c92e68140d 100644 --- a/source/API/SBHostOS.cpp +++ b/source/API/SBHostOS.cpp @@ -1,16 +1,12 @@ //===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// -#ifndef LLDB_DISABLE_PYTHON -#include "Plugins/ScriptInterpreter/Python/lldb-python.h" -#endif - +#include "SBReproducerPrivate.h" #include "lldb/API/SBError.h" #include "lldb/API/SBHostOS.h" #include "lldb/Host/FileSystem.h" @@ -20,7 +16,6 @@ #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Log.h" #include "Plugins/ExpressionParser/Clang/ClangHost.h" #ifndef LLDB_DISABLE_PYTHON @@ -34,16 +29,25 @@ using namespace lldb; using namespace lldb_private; SBFileSpec SBHostOS::GetProgramFileSpec() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, + GetProgramFileSpec); + SBFileSpec sb_filespec; sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec()); - return sb_filespec; + return LLDB_RECORD_RESULT(sb_filespec); } SBFileSpec SBHostOS::GetLLDBPythonPath() { - return GetLLDBPath(ePathTypePythonDir); + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, + GetLLDBPythonPath); + + return LLDB_RECORD_RESULT(GetLLDBPath(ePathTypePythonDir)); } SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { + LLDB_RECORD_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath, + (lldb::PathType), path_type); + FileSpec fspec; switch (path_type) { case ePathTypeLLDBShlibDir: @@ -79,10 +83,13 @@ SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) { SBFileSpec sb_fspec; sb_fspec.SetFileSpec(fspec); - return sb_fspec; + return LLDB_RECORD_RESULT(sb_fspec); } SBFileSpec SBHostOS::GetUserHomeDirectory() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS, + GetUserHomeDirectory); + SBFileSpec sb_fspec; llvm::SmallString<64> home_dir_path; @@ -91,32 +98,38 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() { FileSystem::Instance().Resolve(homedir); sb_fspec.SetFileSpec(homedir); - return sb_fspec; + return LLDB_RECORD_RESULT(sb_fspec); } lldb::thread_t SBHostOS::ThreadCreate(const char *name, lldb::thread_func_t thread_function, void *thread_arg, SBError *error_ptr) { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - - if (log) - log->Printf( - "SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, " - "thread_arg=%p, error_ptr=%p)", - name, - reinterpret_cast<void *>(reinterpret_cast<intptr_t>(thread_function)), - static_cast<void *>(thread_arg), static_cast<void *>(error_ptr)); - - // FIXME: You should log the return value? + LLDB_RECORD_DUMMY(lldb::thread_t, SBHostOS, ThreadCreate, + (lldb::thread_func_t, void *, SBError *), name, + thread_function, thread_arg, error_ptr); + llvm::Expected<HostThread> thread = + ThreadLauncher::LaunchThread(name, thread_function, thread_arg); + if (!thread) { + if (error_ptr) + error_ptr->SetError(Status(thread.takeError())); + else + llvm::consumeError(thread.takeError()); + return LLDB_INVALID_HOST_THREAD; + } - HostThread thread(ThreadLauncher::LaunchThread( - name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL)); - return thread.Release(); + return thread->Release(); } -void SBHostOS::ThreadCreated(const char *name) {} +void SBHostOS::ThreadCreated(const char *name) { + LLDB_RECORD_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *), + name); +} bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { + LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadCancel, + (lldb::thread_t, lldb::SBError *), thread, + error_ptr); + Status error; HostThread host_thread(thread); error = host_thread.Cancel(); @@ -127,6 +140,10 @@ bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) { } bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { + LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadDetach, + (lldb::thread_t, lldb::SBError *), thread, + error_ptr); + Status error; #if defined(_WIN32) if (error_ptr) @@ -143,6 +160,11 @@ bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) { bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, SBError *error_ptr) { + LLDB_RECORD_DUMMY( + bool, SBHostOS, ThreadJoin, + (lldb::thread_t, lldb::thread_result_t *, lldb::SBError *), thread, + result, error_ptr); + Status error; HostThread host_thread(thread); error = host_thread.Join(result); @@ -151,3 +173,22 @@ bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result, host_thread.Release(); return error.Success(); } + +namespace lldb_private { +namespace repro { + +template <> +void RegisterMethods<SBHostOS>(Registry &R) { + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetProgramFileSpec, + ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPythonPath, + ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath, + (lldb::PathType)); + LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, + GetUserHomeDirectory, ()); + LLDB_REGISTER_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *)); +} + +} +} |