1 /* 2 * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef CALLGRIND_PROFILE_RESULT_H 6 #define CALLGRIND_PROFILE_RESULT_H 7 8 9 #include <stdio.h> 10 11 #include "ProfileResult.h" 12 13 14 class CallgrindImageProfileResult; 15 16 17 struct CallgrindCalledFunction { 18 CallgrindCalledFunction* next; 19 CallgrindImageProfileResult* image; 20 int32 function; 21 int64 hits; 22 23 CallgrindCalledFunction(CallgrindImageProfileResult* image, int32 function) 24 : 25 next(NULL), 26 image(image), 27 function(function), 28 hits(0) 29 { 30 } 31 }; 32 33 34 struct CallgrindFunction { 35 int64 hits; 36 CallgrindCalledFunction* calledFunctions; 37 int32 outputIndex; 38 // index when generating the output file 39 }; 40 41 42 class CallgrindImageProfileResult : public ImageProfileResult, 43 public DoublyLinkedListLinkImpl<CallgrindImageProfileResult> { 44 public: 45 CallgrindImageProfileResult(SharedImage* image, 46 image_id id); 47 virtual ~CallgrindImageProfileResult(); 48 49 status_t Init(); 50 51 inline void AddSymbolHit(int32 symbolIndex, 52 CallgrindImageProfileResult* calledImage, 53 int32 calledSymbol); 54 55 inline CallgrindFunction* Functions() const; 56 57 inline int32 OutputIndex() const; 58 inline void SetOutputIndex(int32 index); 59 60 private: 61 CallgrindFunction* fFunctions; 62 int32 fOutputIndex; 63 }; 64 65 66 class CallgrindProfileResult : public ProfileResult { 67 public: 68 CallgrindProfileResult(); 69 70 virtual void AddSamples( 71 ImageProfileResultContainer* container, 72 addr_t* samples, int32 sampleCount); 73 virtual void AddExpectedTicks(int32 expected); 74 virtual void AddDroppedTicks(int32 dropped); 75 virtual void PrintResults( 76 ImageProfileResultContainer* container); 77 78 virtual status_t GetImageProfileResult(SharedImage* image, 79 image_id id, 80 ImageProfileResult*& _imageResult); 81 82 private: 83 void _PrintFunction(FILE* out, 84 CallgrindImageProfileResult* image, 85 int32 functionIndex, bool called); 86 private: 87 int64 fTotalTicks; 88 int64 fUnkownTicks; 89 int64 fExpectedTicks; 90 int64 fDroppedTicks; 91 int32 fNextImageOutputIndex; 92 int32 fNextFunctionOutputIndex; 93 }; 94 95 96 #endif // CALLGRIND_PROFILE_RESULT_H 97