blob: 2519b5b1da0771f244bc45a837d8f46bf84326f4 [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>
17
Todd Fialaaf245d12014-06-30 21:05:18 +000018namespace lldb_private
19{
20 class NativeProcessLinux;
21
22 class NativeThreadLinux : public NativeThreadProtocol
23 {
24 friend class NativeProcessLinux;
25
26 public:
27 NativeThreadLinux (NativeProcessLinux *process, lldb::tid_t tid);
28
29 // ---------------------------------------------------------------------
30 // NativeThreadProtocol Interface
31 // ---------------------------------------------------------------------
Todd Fiala7206c6d2014-09-12 22:51:49 +000032 std::string
Todd Fialaaf245d12014-06-30 21:05:18 +000033 GetName() override;
34
35 lldb::StateType
36 GetState () override;
37
38 bool
Chaoren Lin28e57422015-02-03 01:51:25 +000039 GetStopReason (ThreadStopInfo &stop_info, std::string& description) override;
Todd Fialaaf245d12014-06-30 21:05:18 +000040
41 NativeRegisterContextSP
42 GetRegisterContext () override;
43
44 Error
45 SetWatchpoint (lldb::addr_t addr, size_t size, uint32_t watch_flags, bool hardware) override;
46
47 Error
48 RemoveWatchpoint (lldb::addr_t addr) override;
49
Todd Fialaaf245d12014-06-30 21:05:18 +000050 private:
51 // ---------------------------------------------------------------------
52 // Interface for friend classes
53 // ---------------------------------------------------------------------
54 void
55 SetLaunching ();
56
57 void
58 SetRunning ();
59
60 void
61 SetStepping ();
62
63 void
64 SetStoppedBySignal (uint32_t signo);
65
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
79 SetStoppedByWatchpoint ();
80
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
91 SetCrashedWithException (const siginfo_t& info);
Todd Fialaaf245d12014-06-30 21:05:18 +000092
93 void
94 SetSuspended ();
95
96 void
97 SetExited ();
98
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 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 };
115}
116
117#endif // #ifndef liblldb_NativeThreadLinux_H_