2009-06-16 04:25:36 +04:00
|
|
|
/*
|
2016-05-29 20:52:47 +03:00
|
|
|
* Copyright 2013-2016, Rene Gollent, rene@gollent.com.
|
2009-06-16 04:25:36 +04:00
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef THREAD_H
|
|
|
|
#define THREAD_H
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
#include <Referenceable.h>
|
2009-06-16 04:25:36 +04:00
|
|
|
#include <util/DoublyLinkedList.h>
|
|
|
|
|
2013-03-28 07:21:42 +04:00
|
|
|
#include "ReturnValueInfo.h"
|
2013-01-01 07:52:34 +04:00
|
|
|
#include "types/Types.h"
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
class CpuState;
|
|
|
|
class StackTrace;
|
2009-06-18 04:35:12 +04:00
|
|
|
class Team;
|
|
|
|
|
|
|
|
|
2009-10-15 08:40:33 +04:00
|
|
|
// general thread state
|
2009-06-18 04:35:12 +04:00
|
|
|
enum {
|
|
|
|
THREAD_STATE_UNKNOWN,
|
|
|
|
THREAD_STATE_RUNNING,
|
|
|
|
THREAD_STATE_STOPPED
|
|
|
|
};
|
|
|
|
|
2009-10-15 08:40:33 +04:00
|
|
|
// reason why stopped
|
|
|
|
enum {
|
|
|
|
THREAD_STOPPED_UNKNOWN,
|
|
|
|
THREAD_STOPPED_DEBUGGED,
|
|
|
|
THREAD_STOPPED_DEBUGGER_CALL,
|
|
|
|
THREAD_STOPPED_BREAKPOINT,
|
|
|
|
THREAD_STOPPED_WATCHPOINT,
|
|
|
|
THREAD_STOPPED_SINGLE_STEP,
|
|
|
|
THREAD_STOPPED_EXCEPTION
|
|
|
|
};
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
|
2016-05-29 20:52:47 +03:00
|
|
|
class Thread : public BReferenceable,
|
|
|
|
public DoublyLinkedListLinkImpl< ::Thread> {
|
2009-06-16 04:25:36 +04:00
|
|
|
public:
|
2009-06-18 04:35:12 +04:00
|
|
|
Thread(Team* team, thread_id threadID);
|
2009-06-16 04:25:36 +04:00
|
|
|
~Thread();
|
|
|
|
|
|
|
|
status_t Init();
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
Team* GetTeam() const { return fTeam; }
|
|
|
|
thread_id ID() const { return fID; }
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-07-03 18:23:19 +04:00
|
|
|
bool IsMainThread() const;
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
const char* Name() const { return fName.String(); }
|
|
|
|
void SetName(const BString& name);
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
uint32 State() const { return fState; }
|
2009-10-15 08:40:33 +04:00
|
|
|
void SetState(uint32 state,
|
|
|
|
uint32 reason = THREAD_STOPPED_UNKNOWN,
|
|
|
|
const BString& info = BString());
|
|
|
|
|
|
|
|
uint32 StoppedReason() const
|
|
|
|
{ return fStoppedReason; }
|
|
|
|
const BString& StoppedReasonInfo() const
|
|
|
|
{ return fStoppedReasonInfo; }
|
2009-06-16 04:25:36 +04:00
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
CpuState* GetCpuState() const { return fCpuState; }
|
|
|
|
void SetCpuState(CpuState* state);
|
|
|
|
|
|
|
|
StackTrace* GetStackTrace() const { return fStackTrace; }
|
|
|
|
void SetStackTrace(StackTrace* trace);
|
|
|
|
|
2013-07-04 07:28:33 +04:00
|
|
|
bool StopRequestPending() const
|
|
|
|
{ return fStopRequestPending; }
|
|
|
|
void SetStopRequestPending();
|
|
|
|
|
2013-03-28 07:21:42 +04:00
|
|
|
ReturnValueInfoList*
|
|
|
|
ReturnValueInfos() const
|
|
|
|
{ return fReturnValueInfos; }
|
|
|
|
status_t AddReturnValueInfo(ReturnValueInfo* info);
|
|
|
|
void ClearReturnValueInfos();
|
2012-12-30 07:43:34 +04:00
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
private:
|
2009-06-18 04:35:12 +04:00
|
|
|
Team* fTeam;
|
2009-06-16 04:25:36 +04:00
|
|
|
thread_id fID;
|
|
|
|
BString fName;
|
2009-06-18 04:35:12 +04:00
|
|
|
uint32 fState;
|
2013-03-28 07:21:42 +04:00
|
|
|
ReturnValueInfoList*
|
|
|
|
fReturnValueInfos;
|
2013-07-04 07:28:33 +04:00
|
|
|
bool fStopRequestPending;
|
2009-10-15 08:40:33 +04:00
|
|
|
uint32 fStoppedReason;
|
|
|
|
BString fStoppedReasonInfo;
|
2009-06-18 23:57:46 +04:00
|
|
|
CpuState* fCpuState;
|
|
|
|
StackTrace* fStackTrace;
|
2009-06-16 04:25:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-05-29 20:52:47 +03:00
|
|
|
typedef DoublyLinkedList< ::Thread> ThreadList;
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
#endif // THREAD_H
|