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 14class CallgrindImageProfileResult; 15 16 17struct 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 34struct CallgrindFunction { 35 int64 hits; 36 CallgrindCalledFunction* calledFunctions; 37 int32 outputIndex; 38 // index when generating the output file 39}; 40 41 42class CallgrindImageProfileResult : public ImageProfileResult, 43 public DoublyLinkedListLinkImpl<CallgrindImageProfileResult> { 44public: 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 60private: 61 CallgrindFunction* fFunctions; 62 int32 fOutputIndex; 63}; 64 65 66class CallgrindProfileResult : public ProfileResult { 67public: 68 CallgrindProfileResult(); 69 70 virtual void AddSamples( 71 ImageProfileResultContainer* container, 72 addr_t* samples, int32 sampleCount); 73 virtual void AddDroppedTicks(int32 dropped); 74 virtual void PrintResults( 75 ImageProfileResultContainer* container); 76 77 virtual status_t GetImageProfileResult(SharedImage* image, 78 image_id id, 79 ImageProfileResult*& _imageResult); 80 81private: 82 void _PrintFunction(FILE* out, 83 CallgrindImageProfileResult* image, 84 int32 functionIndex, bool called); 85private: 86 int64 fTotalTicks; 87 int64 fUnkownTicks; 88 int64 fDroppedTicks; 89 int32 fNextImageOutputIndex; 90 int32 fNextFunctionOutputIndex; 91}; 92 93 94#endif // CALLGRIND_PROFILE_RESULT_H 95