The Gaudi Framework  master (37c0b60a)
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 
93 
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
IgHookTrace::parent
IgHookTrace * parent(void)
Definition: IgHook_IgHookTrace.cpp:216
IgHookTrace::CounterValue::CounterValue
CounterValue(Counter *counter, CounterValue *next=0, unsigned long long value=0)
Definition: IgHook_IgHookTrace.cpp:143
IgHookTraceAlloc::allocate
void * allocate(size_t bytes)
Definition: IgHook_IgHookTrace.cpp:111
IgHookTraceAlloc
Definition: IgHook_IgHookTrace.h:26
IgHookTrace::CounterValue::counter
Counter * counter(void)
Definition: IgHook_IgHookTrace.cpp:147
IgHookTrace::CounterValue::max
unsigned long long max(unsigned long long value)
Definition: IgHook_IgHookTrace.cpp:175
IgHookTrace
Definition: IgHook_IgHookTrace.h:37
IgHookTraceAlloc::m_pool
void * m_pool
Definition: IgHook_IgHookTrace.h:33
IgHookTrace::m_next
IgHookTrace * m_next
Definition: IgHook_IgHookTrace.h:102
IgHookTrace::CounterValue::count
unsigned long long count(void)
Definition: IgHook_IgHookTrace.cpp:153
IgHookTrace::m_counters
CounterValue * m_counters
Definition: IgHook_IgHookTrace.h:105
IgHookTrace::m_parent
IgHookTrace * m_parent
Definition: IgHook_IgHookTrace.h:101
IgHookTrace::child
IgHookTrace * child(void *address)
IgHookTrace::CounterValue::next
CounterValue * next(void)
Definition: IgHook_IgHookTrace.cpp:149
IgHookTrace::m_children
IgHookTrace * m_children
Definition: IgHook_IgHookTrace.h:103
IgHookTrace::CounterValue::value
unsigned long long value(void)
Definition: IgHook_IgHookTrace.cpp:151
IgHookTrace::counter
CounterValue * counter(Counter *id)
IgHookTrace::CounterValue::sub
unsigned long long sub(unsigned long long value)
Definition: IgHook_IgHookTrace.cpp:170
IgHookTrace::CounterValue::tick
unsigned long long tick(void)
Definition: IgHook_IgHookTrace.cpp:155
IgHookTrace::counters
CounterValue * counters(void)
IgHookTrace::stacktrace
static int stacktrace(void **addresses, int nmax)
IgHookTrace::symbol
static bool symbol(void *address, const char *&sym, const char *&lib, int &offset, int &liboffset)
Definition: IgHook_IgHookTrace.cpp:222
IgHookTraceAlloc::m_left
size_t m_left
Definition: IgHook_IgHookTrace.h:34
IgHookTrace::CounterValue::m_count
unsigned long long m_count
Definition: IgHook_IgHookTrace.h:72
IgHookTrace::CounterValue::m_counter
Counter * m_counter
Definition: IgHook_IgHookTrace.h:69
IgHookTrace::next
IgHookTrace * next(void)
Definition: IgHook_IgHookTrace.cpp:218
IgHookTrace::address
void * address(void)
Definition: IgHook_IgHookTrace.cpp:220
IgHookTrace::tosymbol
static void * tosymbol(void *address)
Definition: IgHook_IgHookTrace.cpp:247
IgHookTrace::CounterValue
Value for a counter chained from a trace.
Definition: IgHook_IgHookTrace.h:45
IgHookTraceAlloc::IgHookTraceAlloc
IgHookTraceAlloc(void)
Definition: IgHook_IgHookTrace.cpp:109
IgHookTrace::CounterValue::untick
unsigned long long untick(void)
Definition: IgHook_IgHookTrace.cpp:160
IgHookTrace::children
IgHookTrace * children(void)
IgHookTrace::CounterValue::m_value
unsigned long long m_value
Definition: IgHook_IgHookTrace.h:71
cpluginsvc.n
n
Definition: cpluginsvc.py:234
IgHookTrace::m_address
void * m_address
Definition: IgHook_IgHookTrace.h:104
IgHookTrace::merge
void merge(IgHookTrace *other)
IgHookTrace::Counter::m_name
const char * m_name
Definition: IgHook_IgHookTrace.h:41
IgHookTrace::m_alloc
IgHookTraceAlloc * m_alloc
Definition: IgHook_IgHookTrace.h:100
IgHookTrace::Counter
Nearly dummy object type to identify a counter.
Definition: IgHook_IgHookTrace.h:40
IgHookTrace::IgHookTrace
IgHookTrace(IgHookTrace *parent=0, void *address=0)
Definition: IgHook_IgHookTrace.cpp:206
IgHookTrace::CounterValue::add
unsigned long long add(unsigned long long value)
Definition: IgHook_IgHookTrace.cpp:165
IgHookTrace::CounterValue::m_next
CounterValue * m_next
Definition: IgHook_IgHookTrace.h:70