vfs: check userland buffers before reading them.
[haiku.git] / src / bin / debug / profile / Thread.h
blob95245d38b139775e0ffb84d993f07f8c038fd744
1 /*
2 * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef THREAD_H
6 #define THREAD_H
9 #include <String.h>
11 #include <util/DoublyLinkedList.h>
13 #include "ProfiledEntity.h"
14 #include "ProfileResult.h"
17 class Image;
18 class Team;
21 class ThreadImage : public DoublyLinkedListLinkImpl<ThreadImage> {
22 public:
23 ThreadImage(Image* image,
24 ImageProfileResult* result);
25 ~ThreadImage();
27 Image* GetImage() const { return fImage; }
28 ImageProfileResult* Result() const { return fResult; }
30 private:
31 Image* fImage;
32 ImageProfileResult* fResult;
36 class Thread : public ProfiledEntity, public DoublyLinkedListLinkImpl<Thread>,
37 private ImageProfileResultContainer {
38 public:
39 Thread(thread_id threadID, const char* name,
40 Team* team);
41 virtual ~Thread();
43 inline thread_id ID() const;
44 inline const char* Name() const;
45 inline addr_t* Samples() const;
46 inline Team* GetTeam() const;
48 virtual int32 EntityID() const;
49 virtual const char* EntityName() const;
50 virtual const char* EntityType() const;
52 inline ProfileResult* GetProfileResult() const;
53 void SetProfileResult(ProfileResult* result);
55 void UpdateInfo(const char* name);
57 void SetSampleArea(area_id area, addr_t* samples);
58 void SetInterval(bigtime_t interval);
60 void SetLazyImages(bool lazy);
62 status_t AddImage(Image* image);
63 void RemoveImage(Image* image);
65 void AddSamples(int32 count, int32 dropped,
66 int32 stackDepth, bool variableStackDepth,
67 int32 event);
68 void AddSamples(addr_t* samples, int32 sampleCount);
69 void PrintResults();
71 private:
72 typedef DoublyLinkedList<ThreadImage> ImageList;
74 private:
75 // ImageProfileResultContainer
76 virtual int32 CountImages() const;
77 virtual ImageProfileResult* VisitImages(Visitor& visitor) const;
78 virtual ImageProfileResult* FindImage(addr_t address,
79 addr_t& _loadDelta) const;
81 private:
82 void _SynchronizeImages(int32 event);
84 private:
85 thread_id fID;
86 BString fName;
87 ::Team* fTeam;
88 area_id fSampleArea;
89 addr_t* fSamples;
90 ProfileResult* fProfileResult;
91 ImageList fImages;
92 ImageList fNewImages;
93 ImageList fOldImages;
94 bool fLazyImages;
98 thread_id
99 Thread::ID() const
101 return fID;
105 const char*
106 Thread::Name() const
108 return fName.String();
112 addr_t*
113 Thread::Samples() const
115 return fSamples;
119 Team*
120 Thread::GetTeam() const
122 return fTeam;
126 ProfileResult*
127 Thread::GetProfileResult() const
129 return fProfileResult;
133 #endif // THREAD_H