blob: 4170fd9556b39dbba3d96f5ca3f973bd2abc2957 [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>
Richard Smith7572caf2015-03-22 23:18:46 +000017#include <string>
Chaoren Lin18fe6402015-02-03 01:51:47 +000018
Tamas Berghammerdb264a62015-03-31 09:52:22 +000019namespace lldb_private {
20namespace process_linux {
21
Todd Fialaaf245d12014-06-30 21:05:18 +000022 class NativeProcessLinux;
23
24 class NativeThreadLinux : public NativeThreadProtocol
25 {
26 friend class NativeProcessLinux;
27
28 public:
29 NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid);
30
31 // ---------------------------------------------------------------------
32 // NativeThreadProtocol Interface
33 // ---------------------------------------------------------------------
Todd Fiala7206c6d2014-09-12 22:51:49 +000034 std::string
Todd Fialaaf245d12014-06-30 21:05:18 +000035 GetName() override;
36
37 lldb::StateType
38 GetState () override;
39
40 bool
Chaoren Lin28e57422015-02-03 01:51:25 +000041 GetStopReason (ThreadStopInfo &stop_info, std::string& description) override;
Todd Fialaaf245d12014-06-30 21:05:18 +000042
43 NativeRegisterContextSP
44 GetRegisterContext () override;
45
46 Error
47 SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override;
48
49 Error
50 RemoveWatchpoint (lldb::addr_t addr) override;
51
Todd Fialaaf245d12014-06-30 21:05:18 +000052 private:
53 // ---------------------------------------------------------------------
54 // Interface for friend classes
55 // ---------------------------------------------------------------------
56 void
57 SetLaunching ();
58
59 void
60 SetRunning ();
61
62 void
63 SetStepping ();
64
65 void
66 SetStoppedBySignal (uint32_t signo);
67
Todd Fiala511e5cd2014-09-11 23:29:14 +000068 /// Return true if the thread is stopped.
69 /// If stopped by a signal, indicate the signo in the signo argument.
70 /// Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
71 bool
72 IsStopped (int *signo);
73
Todd Fialaaf245d12014-06-30 21:05:18 +000074 void
Todd Fialaa9882ce2014-08-28 15:46:54 +000075 SetStoppedByExec ();
76
77 void
Todd Fialaaf245d12014-06-30 21:05:18 +000078 SetStoppedByBreakpoint ();
79
Chaoren Lin18fe6402015-02-03 01:51:47 +000080 void
Chaoren Linc16f5dc2015-03-19 23:28:10 +000081 SetStoppedByWatchpoint (uint32_t wp_index);
Chaoren Lin18fe6402015-02-03 01:51:47 +000082
Todd Fialaaf245d12014-06-30 21:05:18 +000083 bool
84 IsStoppedAtBreakpoint ();
85
Chaoren Lin18fe6402015-02-03 01:51:47 +000086 bool
87 IsStoppedAtWatchpoint ();
88
Todd Fialaaf245d12014-06-30 21:05:18 +000089 void
Chaoren Lin28e57422015-02-03 01:51:25 +000090 SetStoppedByTrace ();
91
92 void
93 SetCrashedWithException (const siginfo_t& info);
Todd Fialaaf245d12014-06-30 21:05:18 +000094
95 void
96 SetSuspended ();
97
98 void
99 SetExited ();
100
101 // ---------------------------------------------------------------------
102 // Private interface
103 // ---------------------------------------------------------------------
104 void
105 MaybeLogStateChange (lldb::StateType new_state);
106
107 // ---------------------------------------------------------------------
108 // Member Variables
109 // ---------------------------------------------------------------------
110 lldb::StateType m_state;
111 ThreadStopInfo m_stop_info;
112 NativeRegisterContextSP m_reg_context_sp;
Chaoren Lin28e57422015-02-03 01:51:25 +0000113 std::string m_stop_description;
Chaoren Lin18fe6402015-02-03 01:51:47 +0000114 using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
115 WatchpointIndexMap m_watchpoint_index_map;
Todd Fialaaf245d12014-06-30 21:05:18 +0000116 };
Tamas Berghammerdb264a62015-03-31 09:52:22 +0000117
118} // namespace process_linux
119} // namespace lldb_private
Todd Fialaaf245d12014-06-30 21:05:18 +0000120
121#endif // #ifndef liblldb_NativeThreadLinux_H_