| 1 | //===-- NativeThreadFreeBSD.h --------------------------------- -*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef liblldb_NativeThreadFreeBSD_H_ |
| 10 | #define liblldb_NativeThreadFreeBSD_H_ |
| 11 | |
| 12 | #include "lldb/Host/common/NativeThreadProtocol.h" |
| 13 | |
| 14 | #include "Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h" |
| 15 | |
| 16 | #include <csignal> |
| 17 | #include <map> |
| 18 | #include <string> |
| 19 | |
| 20 | namespace lldb_private { |
| 21 | namespace process_freebsd { |
| 22 | |
| 23 | class NativeProcessFreeBSD; |
| 24 | |
| 25 | class NativeThreadFreeBSD : public NativeThreadProtocol { |
| 26 | friend class NativeProcessFreeBSD; |
| 27 | |
| 28 | public: |
| 29 | NativeThreadFreeBSD(NativeProcessFreeBSD &process, lldb::tid_t tid); |
| 30 | |
| 31 | // NativeThreadProtocol Interface |
| 32 | std::string GetName() override; |
| 33 | |
| 34 | lldb::StateType GetState() override; |
| 35 | |
| 36 | bool GetStopReason(ThreadStopInfo &stop_info, |
| 37 | std::string &description) override; |
| 38 | |
| 39 | NativeRegisterContextFreeBSD &GetRegisterContext() override; |
| 40 | |
| 41 | Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags, |
| 42 | bool hardware) override; |
| 43 | |
| 44 | Status RemoveWatchpoint(lldb::addr_t addr) override; |
| 45 | |
| 46 | Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override; |
| 47 | |
| 48 | Status RemoveHardwareBreakpoint(lldb::addr_t addr) override; |
| 49 | |
| 50 | NativeProcessFreeBSD &GetProcess(); |
| 51 | |
| 52 | llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> |
| 53 | GetSiginfo() const override; |
| 54 | |
| 55 | private: |
| 56 | // Interface for friend classes |
| 57 | |
| 58 | Status Resume(); |
| 59 | Status SingleStep(); |
| 60 | Status Suspend(); |
| 61 | |
| 62 | void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); |
| 63 | void SetStoppedByBreakpoint(); |
| 64 | void SetStoppedByTrace(); |
| 65 | void SetStoppedByExec(); |
| 66 | void SetStoppedByWatchpoint(uint32_t wp_index); |
| 67 | void SetStoppedByFork(lldb::pid_t child_pid, lldb::tid_t child_tid); |
| 68 | void SetStoppedByVFork(lldb::pid_t child_pid, lldb::tid_t child_tid); |
| 69 | void SetStoppedByVForkDone(); |
| 70 | void SetStoppedWithNoReason(); |
| 71 | void SetStopped(); |
| 72 | void SetRunning(); |
| 73 | void SetStepping(); |
| 74 | |
| 75 | llvm::Error CopyWatchpointsFrom(NativeThreadFreeBSD &source); |
| 76 | |
| 77 | // Member Variables |
| 78 | lldb::StateType m_state; |
| 79 | ThreadStopInfo m_stop_info; |
| 80 | std::unique_ptr<NativeRegisterContextFreeBSD> m_reg_context_up; |
| 81 | std::string m_stop_description; |
| 82 | using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>; |
| 83 | WatchpointIndexMap m_watchpoint_index_map; |
| 84 | WatchpointIndexMap m_hw_break_index_map; |
| 85 | }; |
| 86 | |
| 87 | typedef std::shared_ptr<NativeThreadFreeBSD> NativeThreadFreeBSDSP; |
| 88 | } // namespace process_freebsd |
| 89 | } // namespace lldb_private |
| 90 | |
| 91 | #endif // #ifndef liblldb_NativeThreadFreeBSD_H_ |
| 92 | |