forked from OSchip/llvm-project
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. llvm-svn: 295345
This commit is contained in:
parent
72ba210916
commit
7278496ccf
|
@ -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;
|
||||
|
|
|
@ -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> SingleStepWorkaround::Get(::pid_t tid) {
|
|||
// 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> SingleStepWorkaround::Get(::pid_t tid) {
|
|||
}
|
||||
|
||||
LLDB_LOG(log, "workaround for thread {0} prepared", tid);
|
||||
return SingleStepWorkaround(tid, original_set);
|
||||
return llvm::make_unique<SingleStepWorkaround>(tid, original_set);
|
||||
}
|
||||
|
||||
SingleStepWorkaround::~SingleStepWorkaround() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue