xref: /openbsd-src/gnu/llvm/lldb/source/Plugins/Process/OpenBSD/NativeThreadOpenBSD.h (revision 1a8dbaac879b9f3335ad7fb25429ce63ac1d6bac)
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   Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
43                        bool hardware) override;
44 
45   Status RemoveWatchpoint(lldb::addr_t addr) override;
46 
47   Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
48 
49   Status RemoveHardwareBreakpoint(lldb::addr_t addr) override;
50 
51 private:
52   // ---------------------------------------------------------------------
53   // Interface for friend classes
54   // ---------------------------------------------------------------------
55 
56   void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
57   void SetStoppedByBreakpoint();
58   void SetStoppedByTrace();
59   void SetStoppedByExec();
60   void SetStoppedByWatchpoint(uint32_t wp_index);
61   void SetStopped();
62   void SetRunning();
63   void SetStepping();
64 
65   // ---------------------------------------------------------------------
66   // Member Variables
67   // ---------------------------------------------------------------------
68   lldb::StateType m_state;
69   ThreadStopInfo m_stop_info;
70   std::unique_ptr<NativeRegisterContext> m_reg_context_up;
71   std::string m_stop_description;
72   using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
73   WatchpointIndexMap m_watchpoint_index_map;
74   WatchpointIndexMap m_hw_break_index_map;
75 };
76 
77 typedef std::shared_ptr<NativeThreadOpenBSD> NativeThreadOpenBSDSP;
78 } // namespace process_openbsd
79 } // namespace lldb_private
80 
81 #endif // #ifndef liblldb_NativeThreadOpenBSD_H_
82