• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

kcachegrind

  • sources
  • kde-4.14
  • kdesdk
  • kcachegrind
  • libcore
fixcost.cpp
Go to the documentation of this file.
1 /* This file is part of KCachegrind.
2  Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
3 
4  KCachegrind is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation, version 2.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 
19 #include "fixcost.h"
20 #include "utils.h"
21 #include "addr.h"
22 
23 // FixCost
24 
25 FixCost::FixCost(TracePart* part, FixPool* pool,
26  TraceFunctionSource* functionSource,
27  PositionSpec& pos,
28  TracePartFunction* partFunction,
29  FixString& s)
30 {
31  int maxCount = part->eventTypeMapping()->count();
32 
33  _part = part;
34  _functionSource = functionSource;
35  _pos = pos;
36 
37  _cost = (SubCost*) pool->reserve(sizeof(SubCost) * maxCount);
38  s.stripSpaces();
39  int i = 0;
40  while(i<maxCount) {
41  if (!s.stripUInt64(_cost[i])) break;
42  i++;
43  }
44  _count = i;
45 
46  if (!pool->allocateReserved(sizeof(SubCost) * _count))
47  _count = 0;
48 
49  _nextCostOfPartFunction = partFunction ?
50  partFunction->setFirstFixCost(this) : 0;
51 }
52 
53 void* FixCost::operator new(size_t size, FixPool* pool)
54 {
55  return pool->allocate(size);
56 }
57 
58 void FixCost::addTo(ProfileCostArray* c)
59 {
60  EventTypeMapping* sm = _part->eventTypeMapping();
61 
62  int i, realIndex;
63 
64  c->reserve(sm->maxRealIndex(_count)+1);
65  for(i=0; i<_count; i++) {
66  realIndex = sm->realIndex(i);
67  c->addCost(realIndex, _cost[i]);
68  }
69 }
70 
71 
72 
73 // FixCallCost
74 
75 FixCallCost::FixCallCost(TracePart* part, FixPool* pool,
76  TraceFunctionSource* functionSource,
77  unsigned int line, Addr addr,
78  TracePartCall* partCall,
79  SubCost callCount, FixString& s)
80 {
81  if (0) qDebug("Got FixCallCost (addr 0x%s, line %d): calls %s",
82  qPrintable(addr.toString()), line,
83  qPrintable(callCount.pretty()));
84 
85  int maxCount = part->eventTypeMapping()->count();
86 
87  _part = part;
88  _functionSource = functionSource;
89  _line = line;
90  _addr = addr;
91 
92  _cost = (SubCost*) pool->reserve(sizeof(SubCost) * (maxCount+1));
93  s.stripSpaces();
94  int i = 0;
95  while(i<maxCount) {
96  if (!s.stripUInt64(_cost[i])) break;
97  i++;
98  }
99  _count = i;
100 
101  if (!pool->allocateReserved(sizeof(SubCost) * (_count+1) ))
102  _count = 0;
103  else
104  _cost[_count] = callCount;
105 
106  _nextCostOfPartCall = partCall ? partCall->setFirstFixCallCost(this) : 0;
107 }
108 
109 void* FixCallCost::operator new(size_t size, FixPool* pool)
110 {
111  return pool->allocate(size);
112 }
113 
114 void FixCallCost::addTo(TraceCallCost* c)
115 {
116  EventTypeMapping* sm = _part->eventTypeMapping();
117 
118  int i, realIndex;
119 
120  for(i=0; i<_count; i++) {
121  realIndex = sm->realIndex(i);
122  c->addCost(realIndex, _cost[i]);
123  }
124  c->addCallCount(_cost[_count]);
125 
126  if (0) qDebug("Adding from (addr 0x%s, ln %d): calls %s",
127  qPrintable(_addr.toString()), _line,
128  qPrintable(_cost[_count].pretty()));
129 }
130 
131 void FixCallCost::setMax(ProfileCostArray* c)
132 {
133  EventTypeMapping* sm = _part->eventTypeMapping();
134 
135  int i, realIndex;
136 
137  for(i=0; i<_count; i++) {
138  realIndex = sm->realIndex(i);
139  c->maxCost(realIndex, _cost[i]);
140  }
141 }
142 
143 
144 // FixJump
145 
146 FixJump::FixJump(TracePart* part, FixPool* pool,
147  unsigned int line, Addr addr,
148  TracePartFunction* partFunction,
149  TraceFunctionSource* source,
150  unsigned int targetLine, Addr targetAddr,
151  TraceFunction* targetFunction,
152  TraceFunctionSource* targetSource,
153  bool isCondJump,
154  SubCost executed, SubCost followed)
155 {
156  _part = part;
157  _source = source;
158  _line = line;
159  _addr = addr;
160 
161  _targetFunction = targetFunction;
162  _targetSource = targetSource;
163  _targetLine = targetLine;
164  _targetAddr = targetAddr;
165 
166  _isCondJump = isCondJump;
167 
168  int size = (isCondJump ? 2 : 1) * sizeof(SubCost);
169  _cost = (SubCost*) pool->allocate(size);
170  _cost[0] = executed;
171  if (isCondJump) _cost[1] = followed;
172 
173  _nextJumpOfPartFunction = partFunction ?
174  partFunction->setFirstFixJump(this) : 0;
175 }
176 
177 void* FixJump::operator new(size_t size, FixPool* pool)
178 {
179  return pool->allocate(size);
180 }
181 
182 void FixJump::addTo(TraceJumpCost* jc)
183 {
184  jc->addExecutedCount(_cost[0]);
185  if (_isCondJump)
186  jc->addFollowedCount(_cost[1]);
187 }
ProfileCostArray::reserve
void reserve(int)
Definition: costitem.cpp:160
FixString::stripSpaces
void stripSpaces()
Strip leading spaces.
Definition: utils.cpp:155
TracePartCall::setFirstFixCallCost
FixCallCost * setFirstFixCallCost(FixCallCost *fc)
Definition: tracedata.h:530
FixJump::FixJump
FixJump(TracePart *, FixPool *, unsigned int line, Addr addr, TracePartFunction *, TraceFunctionSource *, unsigned int targetLine, Addr targetAddr, TraceFunction *, TraceFunctionSource *, bool isCondJump, SubCost, SubCost)
Definition: fixcost.cpp:146
FixCallCost::FixCallCost
FixCallCost(TracePart *, FixPool *, TraceFunctionSource *, unsigned int line, Addr addr, TracePartCall *, SubCost, FixString &)
Definition: fixcost.cpp:75
FixJump::isCondJump
bool isCondJump() const
Definition: fixcost.h:161
PositionSpec
Definition: fixcost.h:32
TracePartFunction::setFirstFixCost
FixCost * setFirstFixCost(FixCost *fc)
Definition: tracedata.h:569
TraceFunction
A traced function.
Definition: tracedata.h:1122
TraceCallCost::addCallCount
void addCallCount(SubCost c)
Definition: tracedata.cpp:132
FixCost::FixCost
FixCost(TracePart *, FixPool *, TraceFunctionSource *, PositionSpec &, TracePartFunction *, FixString &)
Definition: fixcost.cpp:25
FixJump::line
unsigned int line() const
Definition: fixcost.h:154
EventTypeMapping
A index list into a EventTypeSet.
Definition: eventtype.h:170
Addr
Addresses are 64bit values like costs to be able to always load profile data produced on 64bit archit...
Definition: addr.h:31
FixJump::source
TraceFunctionSource * source() const
Definition: fixcost.h:156
FixCallCost::functionSource
TraceFunctionSource * functionSource() const
Definition: fixcost.h:116
utils.h
ProfileCostArray::maxCost
void maxCost(EventTypeMapping *, FixString &)
Definition: costitem.cpp:358
Addr::toString
QString toString() const
Definition: addr.cpp:50
FixPool
FixPool.
Definition: pool.h:34
ProfileCostArray
An array of basic cost metrics for a trace item.
Definition: costitem.h:144
EventTypeMapping::realIndex
int realIndex(int i)
Definition: eventtype.h:191
FixPool::allocateReserved
bool allocateReserved(unsigned int size)
Before calling this, you have to reserve at least bytes with reserveSpace().
Definition: pool.cpp:80
FixCallCost::part
TracePart * part() const
Definition: fixcost.h:112
FixPool::reserve
void * reserve(unsigned int size)
Reserve space.
Definition: pool.cpp:71
TraceFunctionSource
A container helper class for TraceFunction for source lines where a function is implemented in...
Definition: tracedata.h:1029
FixCallCost::setMax
void setMax(ProfileCostArray *)
Definition: fixcost.cpp:131
FixCallCost::addTo
void addTo(TraceCallCost *)
Definition: fixcost.cpp:114
EventTypeMapping::maxRealIndex
int maxRealIndex(int count)
Get maximal real index for the first mapping indexes.
Definition: eventtype.cpp:582
FixString
A simple, constant string class.
Definition: utils.h:38
FixCost::addTo
void addTo(ProfileCostArray *)
Definition: fixcost.cpp:58
fixcost.h
FixCost::part
TracePart * part() const
Definition: fixcost.h:67
TracePartFunction
Cost of a function, from a single trace file.
Definition: tracedata.h:543
TracePart::eventTypeMapping
EventTypeMapping * eventTypeMapping()
Definition: tracedata.h:686
FixCallCost::line
unsigned int line() const
Definition: fixcost.h:113
TracePartCall
Cost of a call at a function to another function, from a single trace file.
Definition: tracedata.h:516
TraceJumpCost::addFollowedCount
void addFollowedCount(SubCost c)
Definition: tracedata.h:216
TracePart
A Trace Part: All data read from a trace file, containing all costs that happened in a specified time...
Definition: tracedata.h:655
FixCallCost::addr
Addr addr() const
Definition: fixcost.h:114
FixJump::addTo
void addTo(TraceJumpCost *)
Definition: fixcost.cpp:182
SubCost
Cost event counter, simple wrapper around a 64bit entity.
Definition: subcost.h:32
FixJump::part
TracePart * part() const
Definition: fixcost.h:153
FixJump::targetLine
unsigned int targetLine() const
Definition: fixcost.h:158
TraceCallCost
Cost item with additional call count metric.
Definition: tracedata.h:228
FixPool::allocate
void * allocate(unsigned int size)
Take bytes from the pool.
Definition: pool.cpp:57
ProfileCostArray::addCost
void addCost(EventTypeMapping *, const char *)
Definition: costitem.cpp:252
FixString::stripUInt64
bool stripUInt64(uint64 &, bool stripSpaces=true)
Definition: utils.cpp:210
SubCost::pretty
QString pretty(char sep= ' ') const
Convert SubCost value into a QString, spaced every 3 digits.
Definition: subcost.cpp:46
FixJump::targetSource
TraceFunctionSource * targetSource() const
Definition: fixcost.h:160
FixCallCost::callCount
SubCost callCount() const
Definition: fixcost.h:115
FixJump::targetAddr
Addr targetAddr() const
Definition: fixcost.h:159
TraceJumpCost::addExecutedCount
void addExecutedCount(SubCost c)
Definition: tracedata.h:217
FixJump::targetFunction
TraceFunction * targetFunction() const
Definition: fixcost.h:157
TraceJumpCost
Cost of a (conditional) jump.
Definition: tracedata.h:201
FixJump::addr
Addr addr() const
Definition: fixcost.h:155
TracePartFunction::setFirstFixJump
FixJump * setFirstFixJump(FixJump *fj)
Definition: tracedata.h:572
addr.h
EventTypeMapping::count
int count()
Get number of used indexes.
Definition: eventtype.h:184
FixCost::functionSource
TraceFunctionSource * functionSource() const
Definition: fixcost.h:76
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:39:50 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kcachegrind

Skip menu "kcachegrind"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal