This file is indexed.

/usr/include/crystalspace-2.0/ivaria/profile.h is in libcrystalspace-dev 2.0+dfsg-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
  Copyright (C) 2007 by Marten Svanfeldt

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __CS_IVARIA_PROFILE_H__
#define __CS_IVARIA_PROFILE_H__

/**\file
 * Interface and helper macros for performance profiler
 */

#include "csutil/array.h"
#include "csutil/scf_interface.h"
#include "csutil/sysfunc.h"
#include "csutil/threading/atomicops.h"

struct iObjectRegistry;

//#define CS_USE_PROFILER

namespace CS
{
namespace Debug
{
  class ProfileZone
  {
  public:
    // Methods
    ProfileZone ()
      : zoneName (0), parentZone (0), totalTime (0), enterCount (0)
    {}

    ~ProfileZone ()
    {
      delete[] zoneName;
    }

    // Data
    const char* zoneName;
    ProfileZone* parentZone;
    uint64 totalTime;
    uint32 enterCount;
  };


  class ProfileCounter
  {
  public:
    // Methods

    ProfileCounter ()
      : counterName (0), counterValue (0)
    {
    }

    ~ProfileCounter ()
    {
      delete[] counterName;
    }

    // Data
    const char* counterName;
    uint64 counterValue;
  };

  class ProfilerZoneScope
  {
  public:
    ProfilerZoneScope (ProfileZone* zone)
    {
      this->zone = zone;
      startTime = csGetMicroTicks ();
    }

    ~ProfilerZoneScope ()
    {
      int64 stopTime = csGetMicroTicks ();

      zone->enterCount++;
      zone->totalTime += (stopTime - startTime);
    }


  private:
    int64 startTime;
    ProfileZone* zone;
  };

  inline void ProfilerCounterAdd (ProfileCounter* counter)
  {
    counter->counterValue++;
  }
}
}


/**
 * Interface to profiler
 */
struct iProfiler : public virtual iBase
{
  SCF_INTERFACE (iProfiler, 3,0,1);
  
  /**\name Deprecated methods
   * \deprecated These methods are present solely for source code 
   *   compatibility; don't use.
   * @{
   */
  CS_DEPRECATED_METHOD_MSG("Old profiling discontinued; check docs for new API")
  static void RegisterProfilePoint (const char*, const char*, int, uint32*, 
    uint32*, uint32*, uint32*) {}
  CS_DEPRECATED_METHOD_MSG("Old profiling discontinued; check docs for new API")
  static void Dump () {}
  /** @} */
  
  /**
   * Get a pointer to a profiler zone.
   * Will register a new zone if it doesn't exist. The pointer is guaranteed to
   * be valid until the profiler object is destroyed.
   */
  virtual CS::Debug::ProfileZone* GetProfileZone (const char* zonename) = 0;

  /**
   * Get a pointer to a profiler counter.
   * Will register a new counter if it doesn't exist. The pointer is guaranteed to
   * be valid until the profiler object is destroyed.
   */
  virtual CS::Debug::ProfileCounter* GetProfileCounter (const char* countername) = 0;

  /**
   * Reset all zones and counters.
   */
  virtual void Reset () = 0;

  /**
   * Get all profiler zones.
   */
  virtual const csArray<CS::Debug::ProfileZone*>& GetProfileZones () = 0;
  
  /**
   * Get all profiler counters.
   */
  virtual const csArray<CS::Debug::ProfileCounter*>& GetProfileCounters () = 0;

  /**
   * Start logging profiling data to file.
   * \param filenamebase Path and basic portion of filename. This will be 
   *   postfixed with an unique id for every logging session.
   * \param objreg Object registry. If none is given, or the given object
   *  registry does not contain an iVFS instance, \a filenamebase is treated
   *  as a native path.
   */
  virtual void StartLogging (const char* filenamebase, 
    iObjectRegistry* objreg) = 0;

  /**
   * Stop logging.
   */
  virtual void StopLogging () = 0;
};

/**
 * Interface to profile factory.
 */
struct iProfilerFactory : public virtual iBase
{
  SCF_INTERFACE (iProfilerFactory, 1,0,0);

  /**
   * Get a profiler object to use.
   */
  virtual iProfiler* GetProfiler () = 0;
};

#ifdef CS_USE_PROFILER
#define CS_DECLARE_PROFILER \
static iProfiler* CS_DEBUG_Profiler_staticProfilerPtr = 0; \
static inline iProfiler* CS_DEBUG_Profiler_GetProfiler () \
{ \
  if (!CS_DEBUG_Profiler_staticProfilerPtr)  \
  { \
    csRef<iProfilerFactory> fact = \
      scfCreateInstance<iProfilerFactory> ("crystalspace.utilities.profiler"); \
    CS_DEBUG_Profiler_staticProfilerPtr = fact->GetProfiler (); \
  } \
  CS_ASSERT (CS_DEBUG_Profiler_staticProfilerPtr); \
  return CS_DEBUG_Profiler_staticProfilerPtr; \
}
#define CS_DECLARE_PROFILER_ZONE(name) \
static CS::Debug::ProfileZone* CS_DEBUG_Profiler_staticProfileZone ## name = 0; \
static inline CS::Debug::ProfileZone* CS_DEBUG_Profiler_GetProfileZone ## name () \
{\
  if (!CS_DEBUG_Profiler_staticProfileZone ## name) \
  {\
    CS_DEBUG_Profiler_staticProfileZone ## name = CS_DEBUG_Profiler_GetProfiler ()->GetProfileZone (#name); \
  }\
  return CS_DEBUG_Profiler_staticProfileZone ## name; \
}
#define CS_DECLARE_PROFILER_COUNTER(name) \
static CS::Debug::ProfileCounter* CS_DEBUG_Profiler_staticProfileCounter ## name = 0; \
static inline CS::Debug::ProfileCounter* CS_DEBUG_Profiler_GetProfileCounter ## name () \
{\
  if (!CS_DEBUG_Profiler_staticProfileCounter ## name) \
  {\
    CS_DEBUG_Profiler_staticProfileCounter ## name = CS_DEBUG_Profiler_GetProfiler ()->GetProfileZone (#name); \
  }\
  return CS_DEBUG_Profiler_staticProfileCounter ## name; \
}
#define CS_PROFILER_GET_PROFILER \
  CS_DEBUG_Profiler_GetProfiler ()
#define CS_PROFILER_ZONE(name) \
CS::Debug::ProfilerZoneScope CS_DEBUG_Profiler_zone ## name ## __LINE__ \
  (CS_DEBUG_Profiler_GetProfileZone ## name());
#define CS_PROFILER_COUNTER(name) \
CS::Debug::ProfilerCounterAdd (CS_DEBUG_Profiler_GetProfileCounter ## name());
#define CS_PROFILER_START_LOGGING(filebase, objectreg) \
  CS_DEBUG_Profiler_GetProfiler ()->StartLogging (filebase, objectreg);
#define CS_PROFILER_STOP_LOGGING() \
  CS_DEBUG_Profiler_GetProfiler ()->StopLogging ();
#define CS_PROFILER_RESET() \
  CS_DEBUG_Profiler_GetProfiler ()->Reset ();
#else

#define CS_DECLARE_PROFILER 
#define CS_DECLARE_PROFILER_ZONE(name)
#define CS_DECLARE_PROFILER_COUNTER(name)
#define CS_PROFILER_GET_PROFILER (0)
#define CS_PROFILER_ZONE(name)
#define CS_PROFILER_COUNTER(name)
#define CS_PROFILER_START_LOGGING(filebase, objectreg)
#define CS_PROFILER_STOP_LOGGING()
#define CS_PROFILER_RESET()
#endif


#endif