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 TEAM_H
|
|
|
|
#define TEAM_H
|
|
|
|
|
|
|
|
#include <Locker.h>
|
|
|
|
|
|
|
|
#include "Image.h"
|
2009-06-18 21:57:37 +04:00
|
|
|
#include "ImageInfo.h"
|
2009-06-16 04:25:36 +04:00
|
|
|
#include "Thread.h"
|
2009-06-18 21:57:37 +04:00
|
|
|
#include "ThreadInfo.h"
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
// team event types
|
|
|
|
enum {
|
|
|
|
TEAM_EVENT_THREAD_ADDED,
|
|
|
|
TEAM_EVENT_THREAD_REMOVED,
|
|
|
|
TEAM_EVENT_IMAGE_ADDED,
|
2009-06-19 01:45:14 +04:00
|
|
|
TEAM_EVENT_IMAGE_REMOVED,
|
|
|
|
|
|
|
|
TEAM_EVENT_THREAD_STATE_CHANGED,
|
|
|
|
TEAM_EVENT_THREAD_CPU_STATE_CHANGED,
|
2009-06-27 20:49:55 +04:00
|
|
|
TEAM_EVENT_THREAD_STACK_TRACE_CHANGED,
|
|
|
|
|
|
|
|
TEAM_EVENT_IMAGE_DEBUG_INFO_CHANGED
|
2009-06-18 04:35:12 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-28 01:09:21 +04:00
|
|
|
class TeamDebugInfo;
|
|
|
|
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
class Team : public BLocker {
|
2009-06-17 01:47:49 +04:00
|
|
|
public:
|
2009-06-18 04:35:12 +04:00
|
|
|
class Event;
|
|
|
|
class ThreadEvent;
|
|
|
|
class ImageEvent;
|
2009-06-17 01:47:49 +04:00
|
|
|
class Listener;
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
public:
|
2009-06-28 01:09:21 +04:00
|
|
|
Team(team_id teamID, TeamDebugInfo* debugInfo);
|
2009-06-16 04:25:36 +04:00
|
|
|
~Team();
|
|
|
|
|
|
|
|
status_t Init();
|
|
|
|
|
2009-06-28 01:09:21 +04:00
|
|
|
team_id ID() const { return fID; }
|
|
|
|
TeamDebugInfo* DebugInfo() const { return fDebugInfo; }
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
const char* Name() const { return fName.String(); }
|
|
|
|
void SetName(const BString& name);
|
|
|
|
|
|
|
|
void AddThread(Thread* thread);
|
2009-06-18 21:57:37 +04:00
|
|
|
status_t AddThread(const ThreadInfo& threadInfo,
|
2009-06-17 17:35:27 +04:00
|
|
|
Thread** _thread = NULL);
|
2009-06-16 04:25:36 +04:00
|
|
|
void RemoveThread(Thread* thread);
|
|
|
|
bool RemoveThread(thread_id threadID);
|
|
|
|
Thread* ThreadByID(thread_id threadID) const;
|
2009-06-17 01:47:49 +04:00
|
|
|
const ThreadList& Threads() const;
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
void AddImage(Image* image);
|
2009-06-18 21:57:37 +04:00
|
|
|
status_t AddImage(const ImageInfo& imageInfo,
|
2009-06-16 04:25:36 +04:00
|
|
|
Image** _image = NULL);
|
|
|
|
void RemoveImage(Image* image);
|
|
|
|
bool RemoveImage(image_id imageID);
|
|
|
|
Image* ImageByID(image_id imageID) const;
|
2009-06-20 21:20:49 +04:00
|
|
|
Image* ImageByAddress(target_addr_t address) const;
|
2009-06-17 01:47:49 +04:00
|
|
|
const ImageList& Images() const;
|
|
|
|
|
|
|
|
void AddListener(Listener* listener);
|
|
|
|
void RemoveListener(Listener* listener);
|
|
|
|
|
2009-06-19 01:45:14 +04:00
|
|
|
// service methods for Thread
|
|
|
|
void NotifyThreadStateChanged(Thread* thread);
|
|
|
|
void NotifyThreadCpuStateChanged(Thread* thread);
|
|
|
|
void NotifyThreadStackTraceChanged(Thread* thread);
|
|
|
|
|
2009-06-27 20:49:55 +04:00
|
|
|
// service methods for Image
|
|
|
|
void NotifyImageDebugInfoChanged(Image* image);
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
private:
|
|
|
|
typedef DoublyLinkedList<Listener> ListenerList;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void _NotifyThreadAdded(Thread* thread);
|
|
|
|
void _NotifyThreadRemoved(Thread* thread);
|
|
|
|
void _NotifyImageAdded(Image* image);
|
|
|
|
void _NotifyImageRemoved(Image* image);
|
2009-06-16 04:25:36 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
team_id fID;
|
2009-06-28 01:09:21 +04:00
|
|
|
TeamDebugInfo* fDebugInfo;
|
2009-06-16 04:25:36 +04:00
|
|
|
BString fName;
|
|
|
|
ThreadList fThreads;
|
|
|
|
ImageList fImages;
|
2009-06-17 01:47:49 +04:00
|
|
|
ListenerList fListeners;
|
2009-06-16 04:25:36 +04:00
|
|
|
};
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
class Team::Event {
|
|
|
|
public:
|
|
|
|
Event(uint32 type, Team* team);
|
|
|
|
|
|
|
|
uint32 EventType() const { return fEventType; }
|
|
|
|
Team* GetTeam() const { return fTeam; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32 fEventType;
|
|
|
|
Team* fTeam;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Team::ThreadEvent : public Event {
|
|
|
|
public:
|
|
|
|
ThreadEvent(uint32 type, Thread* thread);
|
|
|
|
|
|
|
|
Thread* GetThread() const { return fThread; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Thread* fThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class Team::ImageEvent : public Event {
|
|
|
|
public:
|
|
|
|
ImageEvent(uint32 type, Image* image);
|
|
|
|
|
|
|
|
Image* GetImage() const { return fImage; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Image* fImage;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-17 01:47:49 +04:00
|
|
|
class Team::Listener : public DoublyLinkedListLinkImpl<Team::Listener> {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
virtual void ThreadAdded(const Team::ThreadEvent& event);
|
|
|
|
virtual void ThreadRemoved(const Team::ThreadEvent& event);
|
2009-06-17 01:47:49 +04:00
|
|
|
|
2009-06-18 04:35:12 +04:00
|
|
|
virtual void ImageAdded(const Team::ImageEvent& event);
|
|
|
|
virtual void ImageRemoved(const Team::ImageEvent& event);
|
2009-06-19 01:45:14 +04:00
|
|
|
|
|
|
|
virtual void ThreadStateChanged(
|
|
|
|
const Team::ThreadEvent& event);
|
|
|
|
virtual void ThreadCpuStateChanged(
|
|
|
|
const Team::ThreadEvent& event);
|
|
|
|
virtual void ThreadStackTraceChanged(
|
|
|
|
const Team::ThreadEvent& event);
|
2009-06-27 20:49:55 +04:00
|
|
|
|
|
|
|
virtual void ImageDebugInfoChanged(
|
|
|
|
const Team::ImageEvent& event);
|
2009-06-17 01:47:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-16 04:25:36 +04:00
|
|
|
#endif // TEAM_H
|