diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:13:54 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:13:54 +0000 |
commit | 8b4000f13b303cc154136abc74c55670673e2a96 (patch) | |
tree | cde70521176ae2fac67cb037f0a876972b9cc5f0 /include | |
parent | 52fd8de56a8a12201c1e6188e1f34d28c3d3398d (diff) |
Notes
Diffstat (limited to 'include')
-rw-r--r-- | include/lldb/API/SBAddress.h | 4 | ||||
-rw-r--r-- | include/lldb/API/SBInstruction.h | 2 | ||||
-rw-r--r-- | include/lldb/API/SBInstructionList.h | 9 | ||||
-rw-r--r-- | include/lldb/Core/Disassembler.h | 2 | ||||
-rw-r--r-- | include/lldb/Expression/Expression.h | 10 | ||||
-rw-r--r-- | include/lldb/Host/MainLoop.h | 7 | ||||
-rw-r--r-- | include/lldb/Host/common/UDPSocket.h | 4 | ||||
-rw-r--r-- | include/lldb/Target/ThreadPlanCallFunction.h | 2 | ||||
-rw-r--r-- | include/lldb/Target/ThreadPlanCallUserExpression.h | 3 | ||||
-rw-r--r-- | include/lldb/Utility/TaskPool.h | 108 |
10 files changed, 44 insertions, 107 deletions
diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h index ddbe5a7427860..9e697beffdd1d 100644 --- a/include/lldb/API/SBAddress.h +++ b/include/lldb/API/SBAddress.h @@ -103,6 +103,8 @@ protected: const lldb_private::Address *operator->() const; + friend bool operator==(const SBAddress &lhs, const SBAddress &rhs); + lldb_private::Address *get(); lldb_private::Address &ref(); @@ -117,6 +119,8 @@ private: std::unique_ptr<lldb_private::Address> m_opaque_ap; }; +bool operator==(const SBAddress &lhs, const SBAddress &rhs); + } // namespace lldb #endif // LLDB_SBAddress_h_ diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h index 0fc12eb61cbaf..23daf1c566377 100644 --- a/include/lldb/API/SBInstruction.h +++ b/include/lldb/API/SBInstruction.h @@ -53,6 +53,8 @@ public: bool HasDelaySlot(); + bool CanSetBreakpoint(); + void Print(FILE *out); bool GetDescription(lldb::SBStream &description); diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h index 29baef5790ebf..0323a3c80c05d 100644 --- a/include/lldb/API/SBInstructionList.h +++ b/include/lldb/API/SBInstructionList.h @@ -32,6 +32,15 @@ public: lldb::SBInstruction GetInstructionAtIndex(uint32_t idx); + // ---------------------------------------------------------------------- + // Returns the number of instructions between the start and end address. + // If canSetBreakpoint is true then the count will be the number of + // instructions on which a breakpoint can be set. + // ---------------------------------------------------------------------- + size_t GetInstructionsCount(const SBAddress &start, + const SBAddress &end, + bool canSetBreakpoint = false); + void Clear(); void AppendInstruction(lldb::SBInstruction inst); diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index 929b668c092b6..addc83ad5e9d1 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -173,6 +173,8 @@ public: virtual bool HasDelaySlot(); + bool CanSetBreakpoint (); + virtual size_t Decode(const Disassembler &disassembler, const DataExtractor &data, lldb::offset_t data_offset) = 0; diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h index f48a7992227d1..860444e9c2c2e 100644 --- a/include/lldb/Expression/Expression.h +++ b/include/lldb/Expression/Expression.h @@ -99,6 +99,16 @@ public: //------------------------------------------------------------------ lldb::addr_t StartAddress() { return m_jit_start_addr; } + //------------------------------------------------------------------ + /// Called to notify the expression that it is about to be executed. + //------------------------------------------------------------------ + virtual void WillStartExecuting() {} + + //------------------------------------------------------------------ + /// Called to notify the expression that its execution has finished. + //------------------------------------------------------------------ + virtual void DidFinishExecuting() {} + virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; } protected: diff --git a/include/lldb/Host/MainLoop.h b/include/lldb/Host/MainLoop.h index 79370bf8461ff..f5d906e98a7b2 100644 --- a/include/lldb/Host/MainLoop.h +++ b/include/lldb/Host/MainLoop.h @@ -42,6 +42,7 @@ private: public: typedef std::unique_ptr<SignalHandle> SignalHandleUP; + MainLoop(); ~MainLoop() override; ReadHandleUP RegisterReadObject(const lldb::IOObjectSP &object_sp, @@ -71,6 +72,9 @@ protected: void UnregisterSignal(int signo); private: + void ProcessReadObject(IOObject::WaitableHandle handle); + void ProcessSignal(int signo); + class SignalHandle { public: ~SignalHandle() { m_mainloop.UnregisterSignal(m_signo); } @@ -97,6 +101,9 @@ private: llvm::DenseMap<IOObject::WaitableHandle, Callback> m_read_fds; llvm::DenseMap<int, SignalInfo> m_signals; +#if HAVE_SYS_EVENT_H + int m_kqueue; +#endif bool m_terminate_request : 1; }; diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h index 38524fa8f62bd..977ce151e4ffc 100644 --- a/include/lldb/Host/common/UDPSocket.h +++ b/include/lldb/Host/common/UDPSocket.h @@ -21,15 +21,13 @@ public: Socket *&socket); private: - UDPSocket(NativeSocket socket, const UDPSocket &listen_socket); + UDPSocket(NativeSocket socket); size_t Send(const void *buf, const size_t num_bytes) override; Error Connect(llvm::StringRef name) override; Error Listen(llvm::StringRef name, int backlog) override; Error Accept(Socket *&socket) override; - Error CreateSocket(); - SocketAddress m_sockaddr; }; } diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index 3d43491af9af3..1c75b0a3645c0 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -117,7 +117,7 @@ protected: lldb::addr_t &start_load_addr, lldb::addr_t &function_load_addr); - void DoTakedown(bool success); + virtual void DoTakedown(bool success); void SetBreakpoints(); diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h index f1425b2f97e12..5fe80927ca21a 100644 --- a/include/lldb/Target/ThreadPlanCallUserExpression.h +++ b/include/lldb/Target/ThreadPlanCallUserExpression.h @@ -35,6 +35,8 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) override; + void DidPush() override; + void WillPop() override; lldb::StopInfoSP GetRealStopInfo() override; @@ -48,6 +50,7 @@ public: } protected: + void DoTakedown(bool success) override; private: lldb::UserExpressionSP m_user_expression_sp; // This is currently just used to ensure the diff --git a/include/lldb/Utility/TaskPool.h b/include/lldb/Utility/TaskPool.h index fb936bbb739a3..87b8824f9226a 100644 --- a/include/lldb/Utility/TaskPool.h +++ b/include/lldb/Utility/TaskPool.h @@ -53,50 +53,6 @@ private: static void AddTaskImpl(std::function<void()> &&task_fn); }; -// Wrapper class around the global TaskPool implementation to make it possible -// to create a set of -// tasks and then wait for the tasks to be completed by the -// WaitForNextCompletedTask call. This -// class should be used when WaitForNextCompletedTask is needed because this -// class add no other -// extra functionality to the TaskPool class and it have a very minor -// performance overhead. -template <typename T> // The return type of the tasks what will be added to this - // task runner - class TaskRunner { -public: - // Add a task to the task runner what will also add the task to the global - // TaskPool. The - // function doesn't return the std::future for the task because it will be - // supplied by the - // WaitForNextCompletedTask after the task is completed. - template <typename F, typename... Args> void AddTask(F &&f, Args &&... args); - - // Wait for the next task in this task runner to finish and then return the - // std::future what - // belongs to the finished task. If there is no task in this task runner - // (neither pending nor - // comleted) then this function will return an invalid future. Usually this - // function should be - // called in a loop processing the results of the tasks until it returns an - // invalid std::future - // what means that all task in this task runner is completed. - std::future<T> WaitForNextCompletedTask(); - - // Convenience method to wait for all task in this TaskRunner to finish. Do - // NOT use this class - // just because of this method. Use TaskPool instead and wait for each - // std::future returned by - // AddTask in a loop. - void WaitForAllTasks(); - -private: - std::list<std::future<T>> m_ready; - std::list<std::future<T>> m_pending; - std::mutex m_mutex; - std::condition_variable m_cv; -}; - template <typename F, typename... Args> std::future<typename std::result_of<F(Args...)>::type> TaskPool::AddTask(F &&f, Args &&... args) { @@ -126,64 +82,10 @@ template <> struct TaskPool::RunTaskImpl<> { static void Run() {} }; -template <typename T> -template <typename F, typename... Args> -void TaskRunner<T>::AddTask(F &&f, Args &&... args) { - std::unique_lock<std::mutex> lock(m_mutex); - auto it = m_pending.emplace(m_pending.end()); - *it = std::move(TaskPool::AddTask( - [this, it](F f, Args... args) { - T &&r = f(std::forward<Args>(args)...); - - std::unique_lock<std::mutex> lock(this->m_mutex); - this->m_ready.splice(this->m_ready.end(), this->m_pending, it); - lock.unlock(); - - this->m_cv.notify_one(); - return r; - }, - std::forward<F>(f), std::forward<Args>(args)...)); -} - -template <> -template <typename F, typename... Args> -void TaskRunner<void>::AddTask(F &&f, Args &&... args) { - std::unique_lock<std::mutex> lock(m_mutex); - auto it = m_pending.emplace(m_pending.end()); - *it = std::move(TaskPool::AddTask( - [this, it](F f, Args... args) { - f(std::forward<Args>(args)...); - - std::unique_lock<std::mutex> lock(this->m_mutex); - this->m_ready.emplace_back(std::move(*it)); - this->m_pending.erase(it); - lock.unlock(); - - this->m_cv.notify_one(); - }, - std::forward<F>(f), std::forward<Args>(args)...)); -} - -template <typename T> std::future<T> TaskRunner<T>::WaitForNextCompletedTask() { - std::unique_lock<std::mutex> lock(m_mutex); - if (m_ready.empty() && m_pending.empty()) - return std::future<T>(); // No more tasks - - if (m_ready.empty()) - m_cv.wait(lock, [this]() { return !this->m_ready.empty(); }); - - std::future<T> res = std::move(m_ready.front()); - m_ready.pop_front(); - - lock.unlock(); - res.wait(); - - return std::move(res); -} - -template <typename T> void TaskRunner<T>::WaitForAllTasks() { - while (WaitForNextCompletedTask().valid()) - ; -} +// Run 'func' on every value from begin .. end-1. Each worker will grab +// 'batch_size' numbers at a time to work on, so for very fast functions, batch +// should be large enough to avoid too much cache line contention. +void TaskMapOverInt(size_t begin, size_t end, + std::function<void(size_t)> const &func); #endif // #ifndef utility_TaskPool_h_ |