Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 1 | //===-- NativeThreadLinux.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_NativeThreadLinux_H_ |
| 11 | #define liblldb_NativeThreadLinux_H_ |
| 12 | |
| 13 | #include "lldb/lldb-private-forward.h" |
Chaoren Lin | 2fe1d0a | 2015-02-03 01:51:38 +0000 | [diff] [blame] | 14 | #include "lldb/Host/common/NativeThreadProtocol.h" |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 15 | |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 16 | #include <map> |
Pavel Labath | 0e1d729 | 2015-08-20 09:06:12 +0000 | [diff] [blame] | 17 | #include <memory> |
Richard Smith | 7572caf | 2015-03-22 23:18:46 +0000 | [diff] [blame] | 18 | #include <string> |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 19 | |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 20 | namespace lldb_private { |
| 21 | namespace process_linux { |
| 22 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 23 | class NativeProcessLinux; |
| 24 | |
| 25 | class NativeThreadLinux : public NativeThreadProtocol |
| 26 | { |
| 27 | friend class NativeProcessLinux; |
| 28 | |
| 29 | public: |
| 30 | NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid); |
| 31 | |
| 32 | // --------------------------------------------------------------------- |
| 33 | // NativeThreadProtocol Interface |
| 34 | // --------------------------------------------------------------------- |
Todd Fiala | 7206c6d | 2014-09-12 22:51:49 +0000 | [diff] [blame] | 35 | std::string |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 36 | GetName() override; |
| 37 | |
| 38 | lldb::StateType |
| 39 | GetState () override; |
| 40 | |
| 41 | bool |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 42 | GetStopReason (ThreadStopInfo &stop_info, std::string& description) override; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 43 | |
| 44 | NativeRegisterContextSP |
| 45 | GetRegisterContext () override; |
| 46 | |
| 47 | Error |
| 48 | SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override; |
| 49 | |
| 50 | Error |
| 51 | RemoveWatchpoint (lldb::addr_t addr) override; |
| 52 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 53 | private: |
| 54 | // --------------------------------------------------------------------- |
| 55 | // Interface for friend classes |
| 56 | // --------------------------------------------------------------------- |
| 57 | void |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 58 | SetRunning (); |
| 59 | |
| 60 | void |
| 61 | SetStepping (); |
| 62 | |
| 63 | void |
Pavel Labath | c4e25c9 | 2015-05-29 10:13:03 +0000 | [diff] [blame] | 64 | SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 65 | |
Todd Fiala | 511e5cd | 2014-09-11 23:29:14 +0000 | [diff] [blame] | 66 | /// Return true if the thread is stopped. |
| 67 | /// If stopped by a signal, indicate the signo in the signo argument. |
| 68 | /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER. |
| 69 | bool |
| 70 | IsStopped (int *signo); |
| 71 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 72 | void |
Todd Fiala | a9882ce | 2014-08-28 15:46:54 +0000 | [diff] [blame] | 73 | SetStoppedByExec (); |
| 74 | |
| 75 | void |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 76 | SetStoppedByBreakpoint (); |
| 77 | |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 78 | void |
Chaoren Lin | c16f5dc | 2015-03-19 23:28:10 +0000 | [diff] [blame] | 79 | SetStoppedByWatchpoint (uint32_t wp_index); |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 80 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 81 | bool |
| 82 | IsStoppedAtBreakpoint (); |
| 83 | |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 84 | bool |
| 85 | IsStoppedAtWatchpoint (); |
| 86 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 87 | void |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 88 | SetStoppedByTrace (); |
| 89 | |
| 90 | void |
Pavel Labath | 05569f6 | 2015-07-23 09:09:29 +0000 | [diff] [blame] | 91 | SetStoppedWithNoReason (); |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 92 | |
| 93 | void |
| 94 | SetExited (); |
| 95 | |
Pavel Labath | 8c8ff7a | 2015-05-11 10:03:10 +0000 | [diff] [blame] | 96 | Error |
| 97 | RequestStop (); |
| 98 | |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 99 | // --------------------------------------------------------------------- |
| 100 | // Private interface |
| 101 | // --------------------------------------------------------------------- |
| 102 | void |
| 103 | MaybeLogStateChange (lldb::StateType new_state); |
| 104 | |
| 105 | // --------------------------------------------------------------------- |
| 106 | // Member Variables |
| 107 | // --------------------------------------------------------------------- |
| 108 | lldb::StateType m_state; |
| 109 | ThreadStopInfo m_stop_info; |
| 110 | NativeRegisterContextSP m_reg_context_sp; |
Chaoren Lin | 28e5742 | 2015-02-03 01:51:25 +0000 | [diff] [blame] | 111 | std::string m_stop_description; |
Chaoren Lin | 18fe640 | 2015-02-03 01:51:47 +0000 | [diff] [blame] | 112 | using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>; |
| 113 | WatchpointIndexMap m_watchpoint_index_map; |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 114 | }; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 115 | |
Pavel Labath | 0e1d729 | 2015-08-20 09:06:12 +0000 | [diff] [blame] | 116 | typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP; |
Tamas Berghammer | db264a6 | 2015-03-31 09:52:22 +0000 | [diff] [blame] | 117 | } // namespace process_linux |
| 118 | } // namespace lldb_private |
Todd Fiala | af245d1 | 2014-06-30 21:05:18 +0000 | [diff] [blame] | 119 | |
| 120 | #endif // #ifndef liblldb_NativeThreadLinux_H_ |