1af245d11STodd Fiala //===-- NativeThreadLinux.h ----------------------------------- -*- C++ -*-===//
2af245d11STodd Fiala //
3af245d11STodd Fiala //                     The LLVM Compiler Infrastructure
4af245d11STodd Fiala //
5af245d11STodd Fiala // This file is distributed under the University of Illinois Open Source
6af245d11STodd Fiala // License. See LICENSE.TXT for details.
7af245d11STodd Fiala //
8af245d11STodd Fiala //===----------------------------------------------------------------------===//
9af245d11STodd Fiala 
10af245d11STodd Fiala #ifndef liblldb_NativeThreadLinux_H_
11af245d11STodd Fiala #define liblldb_NativeThreadLinux_H_
12af245d11STodd Fiala 
13af245d11STodd Fiala #include "lldb/lldb-private-forward.h"
142fe1d0abSChaoren Lin #include "lldb/Host/common/NativeThreadProtocol.h"
15af245d11STodd Fiala 
1618fe6404SChaoren Lin #include <map>
1718fe6404SChaoren Lin 
18af245d11STodd Fiala namespace lldb_private
19af245d11STodd Fiala {
20af245d11STodd Fiala     class NativeProcessLinux;
21af245d11STodd Fiala 
22af245d11STodd Fiala     class NativeThreadLinux : public NativeThreadProtocol
23af245d11STodd Fiala     {
24af245d11STodd Fiala         friend class NativeProcessLinux;
25af245d11STodd Fiala 
26af245d11STodd Fiala     public:
27af245d11STodd Fiala         NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid);
28af245d11STodd Fiala 
29af245d11STodd Fiala         // ---------------------------------------------------------------------
30af245d11STodd Fiala         // NativeThreadProtocol Interface
31af245d11STodd Fiala         // ---------------------------------------------------------------------
327206c6d1STodd Fiala         std::string
33af245d11STodd Fiala         GetName() override;
34af245d11STodd Fiala 
35af245d11STodd Fiala         lldb::StateType
36af245d11STodd Fiala         GetState () override;
37af245d11STodd Fiala 
38af245d11STodd Fiala         bool
3928e57429SChaoren Lin         GetStopReason (ThreadStopInfo &stop_info, std::string& description) override;
40af245d11STodd Fiala 
41af245d11STodd Fiala         NativeRegisterContextSP
42af245d11STodd Fiala         GetRegisterContext () override;
43af245d11STodd Fiala 
44af245d11STodd Fiala         Error
45af245d11STodd Fiala         SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override;
46af245d11STodd Fiala 
47af245d11STodd Fiala         Error
48af245d11STodd Fiala         RemoveWatchpoint (lldb::addr_t addr) override;
49af245d11STodd Fiala 
50af245d11STodd Fiala     private:
51af245d11STodd Fiala         // ---------------------------------------------------------------------
52af245d11STodd Fiala         // Interface for friend classes
53af245d11STodd Fiala         // ---------------------------------------------------------------------
54af245d11STodd Fiala         void
55af245d11STodd Fiala         SetLaunching ();
56af245d11STodd Fiala 
57af245d11STodd Fiala         void
58af245d11STodd Fiala         SetRunning ();
59af245d11STodd Fiala 
60af245d11STodd Fiala         void
61af245d11STodd Fiala         SetStepping ();
62af245d11STodd Fiala 
63af245d11STodd Fiala         void
64af245d11STodd Fiala         SetStoppedBySignal (uint32_t signo);
65af245d11STodd Fiala 
66511e5cdcSTodd Fiala         /// Return true if the thread is stopped.
67511e5cdcSTodd Fiala         /// If stopped by a signal, indicate the signo in the signo argument.
68511e5cdcSTodd Fiala         /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
69511e5cdcSTodd Fiala         bool
70511e5cdcSTodd Fiala         IsStopped (int *signo);
71511e5cdcSTodd Fiala 
72af245d11STodd Fiala         void
73a9882ceeSTodd Fiala         SetStoppedByExec ();
74a9882ceeSTodd Fiala 
75a9882ceeSTodd Fiala         void
76af245d11STodd Fiala         SetStoppedByBreakpoint ();
77af245d11STodd Fiala 
7818fe6404SChaoren Lin         void
79*c16f5dcaSChaoren Lin         SetStoppedByWatchpoint (uint32_t wp_index);
8018fe6404SChaoren Lin 
81af245d11STodd Fiala         bool
82af245d11STodd Fiala         IsStoppedAtBreakpoint ();
83af245d11STodd Fiala 
8418fe6404SChaoren Lin         bool
8518fe6404SChaoren Lin         IsStoppedAtWatchpoint ();
8618fe6404SChaoren Lin 
87af245d11STodd Fiala         void
8828e57429SChaoren Lin         SetStoppedByTrace ();
8928e57429SChaoren Lin 
9028e57429SChaoren Lin         void
9128e57429SChaoren Lin         SetCrashedWithException (const siginfo_t& info);
92af245d11STodd Fiala 
93af245d11STodd Fiala         void
94af245d11STodd Fiala         SetSuspended ();
95af245d11STodd Fiala 
96af245d11STodd Fiala         void
97af245d11STodd Fiala         SetExited ();
98af245d11STodd Fiala 
99af245d11STodd Fiala         // ---------------------------------------------------------------------
100af245d11STodd Fiala         // Private interface
101af245d11STodd Fiala         // ---------------------------------------------------------------------
102af245d11STodd Fiala         void
103af245d11STodd Fiala         MaybeLogStateChange (lldb::StateType new_state);
104af245d11STodd Fiala 
105af245d11STodd Fiala         // ---------------------------------------------------------------------
106af245d11STodd Fiala         // Member Variables
107af245d11STodd Fiala         // ---------------------------------------------------------------------
108af245d11STodd Fiala         lldb::StateType m_state;
109af245d11STodd Fiala         ThreadStopInfo m_stop_info;
110af245d11STodd Fiala         NativeRegisterContextSP m_reg_context_sp;
11128e57429SChaoren Lin         std::string m_stop_description;
11218fe6404SChaoren Lin         using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
11318fe6404SChaoren Lin         WatchpointIndexMap m_watchpoint_index_map;
114af245d11STodd Fiala     };
115af245d11STodd Fiala }
116af245d11STodd Fiala 
117af245d11STodd Fiala #endif // #ifndef liblldb_NativeThreadLinux_H_
118