vfs: check userland buffers before reading them.
[haiku.git] / src / bin / debug / profile / SummaryProfileResult.h
blob57fdd274c7c0ee8dad4c8fb88a3011c47ac80714
1 /*
2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef SUMMARY_PROFILE_RESULT_H
6 #define SUMMARY_PROFILE_RESULT_H
9 #include <util/OpenHashTable.h>
11 #include "ProfileResult.h"
14 class SummaryImage {
15 public:
16 SummaryImage(ImageProfileResult* result);
17 ~SummaryImage();
19 ImageProfileResult* Result() const { return fResult; }
20 SharedImage* GetImage() const { return fResult->GetImage(); }
22 SummaryImage*& HashNext() { return fHashNext; }
24 private:
25 ImageProfileResult* fResult;
26 SummaryImage* fHashNext;
30 struct SummaryImageHashDefinition {
31 typedef SharedImage* KeyType;
32 typedef SummaryImage ValueType;
34 size_t HashKey(SharedImage* key) const
36 return (addr_t)key / (2 * sizeof(void*));
39 size_t Hash(SummaryImage* value) const
41 return HashKey(value->GetImage());
44 bool Compare(SharedImage* key, SummaryImage* value) const
46 return value->GetImage() == key;
49 SummaryImage*& GetLink(SummaryImage* value) const
51 return value->HashNext();
56 class SummaryProfileResult : public ProfileResult,
57 private ImageProfileResultContainer {
58 public:
59 SummaryProfileResult(ProfileResult* result);
60 virtual ~SummaryProfileResult();
62 virtual status_t Init(ProfiledEntity* entity);
64 virtual void SetInterval(bigtime_t interval);
66 virtual void AddSamples(
67 ImageProfileResultContainer* container,
68 addr_t* samples, int32 sampleCount);
69 virtual void AddDroppedTicks(int32 dropped);
70 virtual void PrintResults(
71 ImageProfileResultContainer* container);
73 virtual status_t GetImageProfileResult(SharedImage* image,
74 image_id id,
75 ImageProfileResult*& _imageResult);
77 void PrintSummaryResults();
79 private:
80 typedef BOpenHashTable<SummaryImageHashDefinition> ImageTable;
82 private:
83 // ImageProfileResultContainer
84 virtual int32 CountImages() const;
85 virtual ImageProfileResult* VisitImages(Visitor& visitor) const;
86 virtual ImageProfileResult* FindImage(addr_t address,
87 addr_t& _loadDelta) const;
89 private:
90 ProfileResult* fResult;
91 ImageTable fImages;
92 image_id fNextImageID;
96 #endif // SUMMARY_PROFILE_RESULT_H