blob: bf6b00a78cfdaab86a04050b95c675725eae260c [file] [log] [blame]
Todd Fialaaf245d12014-06-30 21:05:18 +00001//===-- 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 Lin2fe1d0a2015-02-03 01:51:38 +000014#include "lldb/Host/common/NativeThreadProtocol.h"
Todd Fialaaf245d12014-06-30 21:05:18 +000015
Chaoren Lin18fe6402015-02-03 01:51:47 +000016#include <map>
Pavel Labath0e1d7292015-08-20 09:06:12 +000017#include <memory>
Richard Smith7572caf2015-03-22 23:18:46 +000018#include <string>
Chaoren Lin18fe6402015-02-03 01:51:47 +000019
Tamas Berghammerdb264a62015-03-31 09:52:22 +000020namespace lldb_private {
21namespace process_linux {
22
Todd Fialaaf245d12014-06-30 21:05:18 +000023 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 Fiala7206c6d2014-09-12 22:51:49 +000035 std::string
Todd Fialaaf245d12014-06-30 21:05:18 +000036 GetName() override;
37
38 lldb::StateType
39 GetState () override;
40
41 bool
Chaoren Lin28e57422015-02-03 01:51:25 +000042 GetStopReason (ThreadStopInfo &stop_info, std::string& description) override;
Todd Fialaaf245d12014-06-30 21:05:18 +000043
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 Fialaaf245d12014-06-30 21:05:18 +000053 private:
54 // ---------------------------------------------------------------------
55 // Interface for friend classes
56 // ---------------------------------------------------------------------
57 void
Todd Fialaaf245d12014-06-30 21:05:18 +000058 SetRunning ();
59
60 void
61 SetStepping ();
62
63 void
Pavel Labathc4e25c92015-05-29 10:13:03 +000064 SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
Todd Fialaaf245d12014-06-30 21:05:18 +000065
Todd Fiala511e5cd2014-09-11 23:29:14 +000066 /// 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 Fialaaf245d12014-06-30 21:05:18 +000072 void
Todd Fialaa9882ce2014-08-28 15:46:54 +000073 SetStoppedByExec ();
74
75 void
Todd Fialaaf245d12014-06-30 21:05:18 +000076 SetStoppedByBreakpoint ();
77
Chaoren Lin18fe6402015-02-03 01:51:47 +000078 void
Chaoren Linc16f5dc2015-03-19 23:28:10 +000079 SetStoppedByWatchpoint (uint32_t wp_index);
Chaoren Lin18fe6402015-02-03 01:51:47 +000080
Todd Fialaaf245d12014-06-30 21:05:18 +000081 bool
82 IsStoppedAtBreakpoint ();
83
Chaoren Lin18fe6402015-02-03 01:51:47 +000084 bool
85 IsStoppedAtWatchpoint ();
86
Todd Fialaaf245d12014-06-30 21:05:18 +000087 void
Chaoren Lin28e57422015-02-03 01:51:25 +000088 SetStoppedByTrace ();
89
90 void
Pavel Labath05569f62015-07-23 09:09:29 +000091 SetStoppedWithNoReason ();
Todd Fialaaf245d12014-06-30 21:05:18 +000092
93 void
94 SetExited ();
95
Pavel Labath8c8ff7a2015-05-11 10:03:10 +000096 Error
97 RequestStop ();
98
Todd Fialaaf245d12014-06-30 21:05:18 +000099 // ---------------------------------------------------------------------
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 Lin28e57422015-02-03 01:51:25 +0000111 std::string m_stop_description;
Chaoren Lin18fe6402015-02-03 01:51:47 +0000112 using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
113 WatchpointIndexMap m_watchpoint_index_map;
Todd Fialaaf245d12014-06-30 21:05:18 +0000114 };
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000115
Pavel Labath0e1d7292015-08-20 09:06:12 +0000116 typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP;
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000117} // namespace process_linux
118} // namespace lldb_private
Todd Fialaaf245d12014-06-30 21:05:18 +0000119
120#endif // #ifndef liblldb_NativeThreadLinux_H_