The Gaudi Framework  v33r1 (b1225454)
IgHook_IgHookTrace.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef IG_HOOK_IG_HOOK_TRACE_H
12 #define IG_HOOK_IG_HOOK_TRACE_H
13 
14 //<<<<<< INCLUDES >>>>>>
15 
16 #include <cstddef>
17 #include <new>
18 
19 //<<<<<< PUBLIC DEFINES >>>>>>
20 //<<<<<< PUBLIC CONSTANTS >>>>>>
21 //<<<<<< PUBLIC TYPES >>>>>>
22 //<<<<<< PUBLIC VARIABLES >>>>>>
23 //<<<<<< PUBLIC FUNCTIONS >>>>>>
24 //<<<<<< CLASS DECLARATIONS >>>>>>
25 
27 public:
28  IgHookTraceAlloc( void );
29 
30  void* allocate( size_t bytes );
31 
32 private:
33  void* m_pool;
34  size_t m_left;
35 };
36 
37 class IgHookTrace {
38 public:
40  struct Counter {
41  const char* m_name;
42  };
43 
45  class CounterValue {
46  public:
47  void* operator new( size_t n, IgHookTraceAlloc* alloc = 0 );
48 
49  CounterValue( Counter* counter, CounterValue* next = 0, unsigned long long value = 0 );
50  // implicit copy constructor
51  // implicit assignment operator
52  // implicit destructor
53 
54  Counter* counter( void );
55  CounterValue* next( void );
56  unsigned long long count( void );
57 
58  unsigned long long value( void );
59  unsigned long long tick( void );
60  unsigned long long untick( void );
61  unsigned long long add( unsigned long long value );
62  unsigned long long add( CounterValue& x );
63  unsigned long long sub( unsigned long long value );
64  unsigned long long sub( CounterValue& x );
65  unsigned long long max( unsigned long long value );
66  unsigned long long max( CounterValue& x );
67 
68  private:
71  unsigned long long m_value;
72  unsigned long long m_count;
73  };
74 
75  // General utilities
76  static int stacktrace( void** addresses, int nmax );
77  static void* tosymbol( void* address );
78  static bool symbol( void* address, const char*& sym, const char*& lib, int& offset, int& liboffset );
79 
80  void* operator new( size_t n, IgHookTraceAlloc* alloc = 0 );
81 
82  // Class methods
83  IgHookTrace( IgHookTrace* parent = 0, void* address = 0 );
84 
85  IgHookTrace* parent( void );
86  IgHookTrace* next( void );
87 
88  void* address( void );
89  bool symbol( const char*& sym, const char*& lib, int& offset, int& liboffset );
90 
91  IgHookTrace* children( void );
92  IgHookTrace* child( void* address );
93 
94  CounterValue* counters( void );
96 
97  void merge( IgHookTrace* other );
98 
99 private:
104  void* m_address;
106 };
107 
108 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>>
109 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>>
110 
111 #endif // IG_HOOK_IG_HOOK_TRACE_H
static void * tosymbol(void *address)
IgHookTrace * parent(void)
unsigned long long untick(void)
CounterValue * counter(Counter *id)
IgHookTrace * m_children
unsigned long long add(unsigned long long value)
IgHookTrace * m_parent
IgHookTrace * child(void *address)
IgHookTrace * children(void)
unsigned long long tick(void)
void * address(void)
Value for a counter chained from a trace.
CounterValue * counters(void)
static int stacktrace(void **addresses, int nmax)
static bool symbol(void *address, const char *&sym, const char *&lib, int &offset, int &liboffset)
unsigned long long max(unsigned long long value)
unsigned long long value(void)
unsigned long long m_value
unsigned long long sub(unsigned long long value)
Nearly dummy object type to identify a counter.
IgHookTrace * m_next
CounterValue(Counter *counter, CounterValue *next=0, unsigned long long value=0)
unsigned long long m_count
CounterValue * m_counters
void merge(IgHookTrace *other)
IgHookTraceAlloc * m_alloc
unsigned long long count(void)
IgHookTrace(IgHookTrace *parent=0, void *address=0)
IgHookTrace * next(void)
void * allocate(size_t bytes)