btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / debugger / model / Thread.h
blob2d74ac075315da2f4be5bb8e43eebb67ebb981e1
1 /*
2 * Copyright 2013-2016, Rene Gollent, rene@gollent.com.
3 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef THREAD_H
7 #define THREAD_H
9 #include <OS.h>
10 #include <String.h>
12 #include <Referenceable.h>
13 #include <util/DoublyLinkedList.h>
15 #include "ReturnValueInfo.h"
16 #include "types/Types.h"
19 class CpuState;
20 class StackTrace;
21 class Team;
24 // general thread state
25 enum {
26 THREAD_STATE_UNKNOWN,
27 THREAD_STATE_RUNNING,
28 THREAD_STATE_STOPPED
31 // reason why stopped
32 enum {
33 THREAD_STOPPED_UNKNOWN,
34 THREAD_STOPPED_DEBUGGED,
35 THREAD_STOPPED_DEBUGGER_CALL,
36 THREAD_STOPPED_BREAKPOINT,
37 THREAD_STOPPED_WATCHPOINT,
38 THREAD_STOPPED_SINGLE_STEP,
39 THREAD_STOPPED_EXCEPTION
43 class Thread : public BReferenceable,
44 public DoublyLinkedListLinkImpl< ::Thread> {
45 public:
46 Thread(Team* team, thread_id threadID);
47 ~Thread();
49 status_t Init();
51 Team* GetTeam() const { return fTeam; }
52 thread_id ID() const { return fID; }
54 bool IsMainThread() const;
56 const char* Name() const { return fName.String(); }
57 void SetName(const BString& name);
59 uint32 State() const { return fState; }
60 void SetState(uint32 state,
61 uint32 reason = THREAD_STOPPED_UNKNOWN,
62 const BString& info = BString());
64 uint32 StoppedReason() const
65 { return fStoppedReason; }
66 const BString& StoppedReasonInfo() const
67 { return fStoppedReasonInfo; }
69 CpuState* GetCpuState() const { return fCpuState; }
70 void SetCpuState(CpuState* state);
72 StackTrace* GetStackTrace() const { return fStackTrace; }
73 void SetStackTrace(StackTrace* trace);
75 bool StopRequestPending() const
76 { return fStopRequestPending; }
77 void SetStopRequestPending();
79 ReturnValueInfoList*
80 ReturnValueInfos() const
81 { return fReturnValueInfos; }
82 status_t AddReturnValueInfo(ReturnValueInfo* info);
83 void ClearReturnValueInfos();
85 private:
86 Team* fTeam;
87 thread_id fID;
88 BString fName;
89 uint32 fState;
90 ReturnValueInfoList*
91 fReturnValueInfos;
92 bool fStopRequestPending;
93 uint32 fStoppedReason;
94 BString fStoppedReasonInfo;
95 CpuState* fCpuState;
96 StackTrace* fStackTrace;
100 typedef DoublyLinkedList< ::Thread> ThreadList;
103 #endif // THREAD_H