1 //===-- NativeThreadOpenBSD.h ---------------------------------- -*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_NativeThreadOpenBSD_H_
11 #define liblldb_NativeThreadOpenBSD_H_
12 
13 #include "lldb/Host/common/NativeThreadProtocol.h"
14 
15 #include <csignal>
16 #include <map>
17 #include <string>
18 
19 namespace lldb_private {
20 namespace process_openbsd {
21 
22 class NativeProcessOpenBSD;
23 
24 class NativeThreadOpenBSD : public NativeThreadProtocol {
25   friend class NativeProcessOpenBSD;
26 
27 public:
28   NativeThreadOpenBSD(NativeProcessOpenBSD &process, lldb::tid_t tid);
29 
30   // ---------------------------------------------------------------------
31   // NativeThreadProtocol Interface
32   // ---------------------------------------------------------------------
33   std::string GetName() override;
34 
35   lldb::StateType GetState() override;
36 
37   bool GetStopReason(ThreadStopInfo &stop_info,
38                      std::string &description) override;
39 
40   NativeRegisterContext& GetRegisterContext() override;
41 
42   // OpenBSD does not expose hardware debug registers to userland
43   // so these functions will just return a Status error.
44   Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
45   Status RemoveHardwareBreakpoint(lldb::addr_t addr) override;
46 
47   // Similarly, until software watchpoints are implemented in lldb,
48   // these functions will just return a Status error.
49   Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
50                        bool hardware) override;
51   Status RemoveWatchpoint(lldb::addr_t addr) override;
52 
53 private:
54   // ---------------------------------------------------------------------
55   // Interface for friend classes
56   // ---------------------------------------------------------------------
57 
58   void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
59   void SetStoppedByBreakpoint();
60   void SetStoppedByTrace();
61   void SetStoppedByExec();
62   void SetStopped();
63   void SetRunning();
64   void SetStepping();
65 
66   // ---------------------------------------------------------------------
67   // Member Variables
68   // ---------------------------------------------------------------------
69   lldb::StateType m_state;
70   ThreadStopInfo m_stop_info;
71   std::unique_ptr<NativeRegisterContext> m_reg_context_up;
72   std::string m_stop_description;
73 };
74 
75 typedef std::shared_ptr<NativeThreadOpenBSD> NativeThreadOpenBSDSP;
76 } // namespace process_openbsd
77 } // namespace lldb_private
78 
79 #endif // #ifndef liblldb_NativeThreadOpenBSD_H_
80