Author: labath Date: Thu Feb 16 12:12:04 2017 New Revision: 295345 URL: http://llvm.org/viewvc/llvm-project?rev=295345&view=rev Log: NPL: Fix single step workaround
While refactoring the code in r293046 I made a very basic error - relying on destructor side-effects of a copyable object. Fix that and make the object non-copyable. This fixes the tests on the platforms that need this workaround, but unfortunately we don't have a way to make a more platform-agnostic test right now. Modified: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h Modified: lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h?rev=295345&r1=295344&r2=295345&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/NativeThreadLinux.h Thu Feb 16 12:12:04 2017 @@ -102,7 +102,7 @@ private: std::string m_stop_description; using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>; WatchpointIndexMap m_watchpoint_index_map; - llvm::Optional<SingleStepWorkaround> m_step_workaround; + std::unique_ptr<SingleStepWorkaround> m_step_workaround; }; typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP; Modified: lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp?rev=295345&r1=295344&r2=295345&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.cpp Thu Feb 16 12:12:04 2017 @@ -139,13 +139,13 @@ bool WorkaroundNeeded() { } // end anonymous namespace -llvm::Optional<SingleStepWorkaround> SingleStepWorkaround::Get(::pid_t tid) { +std::unique_ptr<SingleStepWorkaround> SingleStepWorkaround::Get(::pid_t tid) { Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD); static bool workaround_needed = WorkaroundNeeded(); if (!workaround_needed) { LLDB_LOG(log, "workaround for thread {0} not needed", tid); - return llvm::None; + return nullptr; } cpu_set_t original_set; @@ -153,7 +153,7 @@ llvm::Optional<SingleStepWorkaround> Sin // This should really not fail. But, just in case... LLDB_LOG(log, "Unable to get cpu affinity for thread {0}: {1}", tid, Error(errno, eErrorTypePOSIX)); - return llvm::None; + return nullptr; } cpu_set_t set; @@ -168,7 +168,7 @@ llvm::Optional<SingleStepWorkaround> Sin } LLDB_LOG(log, "workaround for thread {0} prepared", tid); - return SingleStepWorkaround(tid, original_set); + return llvm::make_unique<SingleStepWorkaround>(tid, original_set); } SingleStepWorkaround::~SingleStepWorkaround() { Modified: lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h?rev=295345&r1=295344&r2=295345&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/SingleStepCheck.h Thu Feb 16 12:12:04 2017 @@ -10,8 +10,8 @@ #ifndef liblldb_SingleStepCheck_H_ #define liblldb_SingleStepCheck_H_ -#include "sched.h" -#include "llvm/ADT/Optional.h" +#include <memory> +#include <sched.h> #include <sys/types.h> namespace lldb_private { @@ -32,18 +32,21 @@ class SingleStepWorkaround { ::pid_t m_tid; cpu_set_t m_original_set; + SingleStepWorkaround(const SingleStepWorkaround &) = delete; + void operator=(const SingleStepWorkaround &) = delete; + public: SingleStepWorkaround(::pid_t tid, cpu_set_t original_set) : m_tid(tid), m_original_set(original_set) {} ~SingleStepWorkaround(); - static llvm::Optional<SingleStepWorkaround> Get(::pid_t tid); + static std::unique_ptr<SingleStepWorkaround> Get(::pid_t tid); }; #else class SingleStepWorkaround { public: - static llvm::Optional<SingleStepWorkaround> Get(::pid_t tid) { - return llvm::None; + static std::unique_ptr<SingleStepWorkaround> Get(::pid_t tid) { + return nullptr; } }; #endif _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits