Commit 6b223191 by Benjamin Kosnik Committed by Benjamin Kosnik

profiler_container_size.h: Fix include guard, formatting fixes.

2009-12-09  Benjamin Kosnik  <bkoz@redhat.com>

	* include/profile/impl/profiler_container_size.h: Fix include
	guard, formatting fixes.
	* include/profile/impl/profiler_vector_size.h: Same.
	* include/profile/impl/profiler_hash_func.h: Same.
	* include/profile/impl/profiler_trace.h: Same.
	* include/profile/impl/profiler_vector_to_list.h: Same.
	* include/profile/impl/profiler.h: Same.
	* include/profile/impl/profiler_state.h: Same.
	* include/profile/impl/profiler_map_to_unordered_map.h: Same.
	* include/profile/impl/profiler_hashtable_size.h: Same.
	* include/profile/impl/profiler_node.h: Same.

From-SVN: r155123
parent 14aa6352
2009-12-09 Benjamin Kosnik <bkoz@redhat.com>
* include/profile/impl/profiler_container_size.h: Fix include
guard, formatting fixes.
* include/profile/impl/profiler_vector_size.h: Same.
* include/profile/impl/profiler_hash_func.h: Same.
* include/profile/impl/profiler_trace.h: Same.
* include/profile/impl/profiler_vector_to_list.h: Same.
* include/profile/impl/profiler.h: Same.
* include/profile/impl/profiler_state.h: Same.
* include/profile/impl/profiler_map_to_unordered_map.h: Same.
* include/profile/impl/profiler_hashtable_size.h: Same.
* include/profile/impl/profiler_node.h: Same.
2009-12-09 Roman Odaisky <to.roma.from.bugcc@qwertty.com>
PR libstdc++/42273
......
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_H__
#define PROFCXX_PROFILER_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_H
#define _GLIBCXX_PROFILE_PROFILER_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstddef>
......@@ -311,4 +311,4 @@ namespace __gnu_profile
#include "profile/impl/profiler_vector_size.h"
#include "profile/impl/profiler_vector_to_list.h"
#endif // PROFCXX_PROFILER_H__
#endif // _GLIBCXX_PROFILE_PROFILER_H
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_CONTAINER_SIZE_H__
#define PROFCXX_PROFILER_CONTAINER_SIZE_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
......@@ -53,43 +53,46 @@
namespace __gnu_profile
{
/** @brief A container size instrumentation line in the object table. */
class __container_size_info: public __object_info_base
{
/** @brief A container size instrumentation line in the object table. */
class __container_size_info: public __object_info_base
{
public:
__container_size_info();
__container_size_info(const __container_size_info& __o);
__container_size_info(__stack_t __stack, size_t __num);
virtual ~__container_size_info() {}
virtual ~__container_size_info() { }
void __write(FILE* f) const;
float __magnitude() const { return static_cast<float>(_M_cost); }
const char* __advice() const;
void __merge(const __container_size_info& __o);
// Call if a container is destructed or cleaned.
void __destruct(size_t __num, size_t __inum);
// Estimate the cost of resize/rehash.
float __resize_cost(size_t __from, size_t __to) { return __from; }
// Call if container is resized.
void __resize(size_t __from, size_t __to);
private:
size_t _M_init;
size_t _M_max; // range of # buckets
size_t _M_max; // Range of # buckets.
size_t _M_min;
size_t _M_total;
size_t _M_item_min; // range of # items
size_t _M_item_min; // Range of # items.
size_t _M_item_max;
size_t _M_item_total;
size_t _M_count;
size_t _M_resize;
size_t _M_cost;
};
};
inline const char* __container_size_info::__advice() const
{
inline const char*
__container_size_info::__advice() const
{
const size_t __max_chars_size_t_printed = 20;
const char* __message_pattern =
"change initial container size from %d to %d";
......@@ -106,46 +109,39 @@ inline const char* __container_size_info::__advice() const
_M_item_max);
return __message;
}
}
inline void __container_size_info::__destruct(size_t __num, size_t __inum)
{
inline void
__container_size_info::__destruct(size_t __num, size_t __inum)
{
_M_max = __max(_M_max, __num);
_M_item_max = __max(_M_item_max, __inum);
if (_M_min == 0) {
if (_M_min == 0)
{
_M_min = __num;
_M_item_min = __inum;
} else {
}
else
{
_M_min = __min(_M_min, __num);
_M_item_min = __min(_M_item_min, __inum);
}
_M_total += __num;
_M_item_total += __inum;
_M_count += 1;
}
}
inline void __container_size_info::__resize(size_t __from, size_t __to)
{
inline void
__container_size_info::__resize(size_t __from, size_t __to)
{
_M_cost += this->__resize_cost(__from, __to);
_M_resize += 1;
_M_max = __max(_M_max, __to);
}
inline __container_size_info::__container_size_info(__stack_t __stack,
size_t __num)
: __object_info_base(__stack), _M_init(0), _M_max(0), _M_item_max(0),
_M_min(0), _M_item_min(0), _M_total(0), _M_item_total(0), _M_cost(0),
_M_count(0), _M_resize(0)
{
_M_init = _M_max = __num;
_M_item_min = _M_item_max = _M_item_total = _M_total = 0;
_M_min = 0;
_M_count = 0;
_M_resize = 0;
}
}
inline void __container_size_info::__merge(const __container_size_info& __o)
{
inline void
__container_size_info::__merge(const __container_size_info& __o)
{
_M_init = __max(_M_init, __o._M_init);
_M_max = __max(_M_max, __o._M_max);
_M_item_max = __max(_M_item_max, __o._M_item_max);
......@@ -156,18 +152,29 @@ inline void __container_size_info::__merge(const __container_size_info& __o)
_M_count += __o._M_count;
_M_cost += __o._M_cost;
_M_resize += __o._M_resize;
}
}
inline __container_size_info::__container_size_info()
inline __container_size_info::__container_size_info()
: _M_init(0), _M_max(0), _M_item_max(0), _M_min(0), _M_item_min(0),
_M_total(0), _M_item_total(0), _M_cost(0), _M_count(0), _M_resize(0)
{
}
{ }
inline __container_size_info::__container_size_info(
const __container_size_info& __o)
inline __container_size_info::__container_size_info(__stack_t __stack,
size_t __num)
: __object_info_base(__stack), _M_init(0), _M_max(0), _M_item_max(0),
_M_min(0), _M_item_min(0), _M_total(0), _M_item_total(0), _M_cost(0),
_M_count(0), _M_resize(0)
{
_M_init = _M_max = __num;
_M_item_min = _M_item_max = _M_item_total = _M_total = 0;
_M_min = 0;
_M_count = 0;
_M_resize = 0;
}
inline __container_size_info::__container_size_info(const __container_size_info& __o)
: __object_info_base(__o)
{
{
_M_init = __o._M_init;
_M_max = __o._M_max;
_M_item_max = __o._M_item_max;
......@@ -178,50 +185,54 @@ inline __container_size_info::__container_size_info(
_M_cost = __o._M_cost;
_M_count = __o._M_count;
_M_resize = __o._M_resize;
}
}
/** @brief A container size instrumentation line in the stack table. */
class __container_size_stack_info: public __container_size_info
{
/** @brief A container size instrumentation line in the stack table. */
class __container_size_stack_info: public __container_size_info
{
public:
__container_size_stack_info(const __container_size_info& __o)
: __container_size_info(__o) {}
};
: __container_size_info(__o) { }
};
/** @brief Container size instrumentation trace producer. */
class __trace_container_size
/** @brief Container size instrumentation trace producer. */
class __trace_container_size
: public __trace_base<__container_size_info, __container_size_stack_info>
{
{
public:
~__trace_container_size() {}
__trace_container_size()
: __trace_base<__container_size_info, __container_size_stack_info>() {};
: __trace_base<__container_size_info, __container_size_stack_info>() { };
~__trace_container_size() { }
// Insert a new node at construct with object, callstack and initial size.
void __insert(const __object_t __obj, __stack_t __stack, size_t __num);
// Call at destruction/clean to set container final size.
void __destruct(const void* __obj, size_t __num, size_t __inum);
void __construct(const void* __obj, size_t __inum);
// Call at resize to set resize/cost information.
void __resize(const void* __obj, int __from, int __to);
};
};
inline void __trace_container_size::__insert(const __object_t __obj,
inline void
__trace_container_size::__insert(const __object_t __obj,
__stack_t __stack, size_t __num)
{
__add_object(__obj, __container_size_info(__stack, __num));
}
{ __add_object(__obj, __container_size_info(__stack, __num)); }
inline void __container_size_info::__write(FILE* __f) const
{
inline void
__container_size_info::__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu %Zu\n",
_M_init, _M_count, _M_cost, _M_resize, _M_min, _M_max, _M_total,
_M_item_min, _M_item_max, _M_item_total);
}
}
inline void __trace_container_size::__destruct(const void* __obj,
size_t __num, size_t __inum)
{
inline void
__trace_container_size::__destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__is_on()) return;
__object_t __obj_handle = static_cast<__object_t>(__obj);
......@@ -232,11 +243,11 @@ inline void __trace_container_size::__destruct(const void* __obj,
__object_info->__destruct(__num, __inum);
__retire_object(__obj_handle);
}
}
inline void __trace_container_size::__resize(const void* __obj, int __from,
int __to)
{
inline void
__trace_container_size::__resize(const void* __obj, int __from, int __to)
{
if (!__is_on()) return;
__container_size_info* __object_info = __get_object_info(__obj);
......@@ -244,7 +255,6 @@ inline void __trace_container_size::__resize(const void* __obj, int __from,
return;
__object_info->__resize(__from, __to);
}
}
} // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_CONTAINER_SIZE_H__ */
#endif /* _GLIBCXX_PROFILE_PROFILER_CONTAINER_SIZE_H */
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_HASH_FUNC_H__
#define PROFCXX_PROFILER_HASH_FUNC_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
#define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
......@@ -52,18 +52,19 @@
namespace __gnu_profile
{
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info: public __object_info_base
{
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info: public __object_info_base
{
public:
__hashfunc_info()
:_M_longest_chain(0), _M_accesses(0), _M_hops(0) {}
__hashfunc_info() :_M_longest_chain(0), _M_accesses(0), _M_hops(0) { }
__hashfunc_info(const __hashfunc_info& o);
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){}
virtual ~__hashfunc_info() {}
: __object_info_base(__stack), _M_longest_chain(0),
_M_accesses(0), _M_hops(0) { }
virtual ~__hashfunc_info() { }
void __merge(const __hashfunc_info& __o);
void __destruct(size_t __chain, size_t __accesses, size_t __hops);
......@@ -71,76 +72,77 @@ class __hashfunc_info: public __object_info_base
float __magnitude() const { return static_cast<float>(_M_hops); }
const char* __advice() const { return "change hash function"; }
private:
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
};
};
inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
inline __hashfunc_info::__hashfunc_info(const __hashfunc_info& __o)
: __object_info_base(__o)
{
{
_M_longest_chain = __o._M_longest_chain;
_M_accesses = __o._M_accesses;
_M_hops = __o._M_hops;
}
}
inline void __hashfunc_info::__merge(const __hashfunc_info& __o)
{
inline void
__hashfunc_info::__merge(const __hashfunc_info& __o)
{
_M_longest_chain = __max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
}
}
inline void __hashfunc_info::__destruct(size_t __chain, size_t __accesses,
size_t __hops)
{
inline void
__hashfunc_info::__destruct(size_t __chain, size_t __accesses, size_t __hops)
{
_M_longest_chain = __max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
}
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info: public __hashfunc_info {
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info: public __hashfunc_info
{
public:
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) {}
};
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) { }
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
{
public:
__trace_hash_func();
~__trace_hash_func() {}
~__trace_hash_func() { }
// Insert a new node at construct with object, callstack and initial size.
void __insert(__object_t __obj, __stack_t __stack);
// Call at destruction/clean to set container final size.
void __destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops);
};
void __destruct(const void* __obj, size_t __chain, size_t __accesses,
size_t __hops);
};
inline __trace_hash_func::__trace_hash_func()
inline __trace_hash_func::__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{
__id = "hash-distr";
}
{ __id = "hash-distr"; }
inline void __trace_hash_func::__insert(__object_t __obj, __stack_t __stack)
{
__add_object(__obj, __hashfunc_info(__stack));
}
inline void
__trace_hash_func::__insert(__object_t __obj, __stack_t __stack)
{ __add_object(__obj, __hashfunc_info(__stack)); }
inline void __hashfunc_info::__write(FILE* __f) const
{
fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain);
}
inline void
__hashfunc_info::__write(FILE* __f) const
{ fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); }
inline void __trace_hash_func::__destruct(const void* __obj, size_t __chain,
inline void
__trace_hash_func::__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__is_on()) return;
{
if (!__is_on())
return;
// First find the item from the live objects and update the informations.
__hashfunc_info* __objs = __get_object_info(__obj);
......@@ -149,44 +151,44 @@ inline void __trace_hash_func::__destruct(const void* __obj, size_t __chain,
__objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
}
}
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hash_func_init()
{
__tables<0>::_S_hash_func = new __trace_hash_func();
}
// Initialization and report.
inline void
__trace_hash_func_init()
{ __tables<0>::_S_hash_func = new __trace_hash_func(); }
inline void __trace_hash_func_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_hash_func) {
inline void
__trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
{
if (__tables<0>::_S_hash_func)
{
__tables<0>::_S_hash_func->__collect_warnings(__warnings);
__tables<0>::_S_hash_func->__write(__f);
}
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_hash_func_construct(const void* __obj)
{
if (!__profcxx_init()) return;
// Implementations of instrumentation hooks.
inline void
__trace_hash_func_construct(const void* __obj)
{
if (!__profcxx_init())
return;
__tables<0>::_S_hash_func->__insert(__obj, __get_stack());
}
}
inline void __trace_hash_func_destruct(const void* __obj, size_t __chain,
inline void
__trace_hash_func_destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__profcxx_init()) return;
{
if (!__profcxx_init())
return;
__tables<0>::_S_hash_func->__destruct(__obj, __chain, __accesses, __hops);
}
}
} // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_HASH_FUNC_H__ */
#endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_HASHTABLE_SIZE_H__
#define PROFCXX_PROFILER_HASHTABLE_SIZE_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
......@@ -54,62 +54,58 @@
namespace __gnu_profile
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_hashtable_size : public __trace_container_size
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_hashtable_size : public __trace_container_size
{
public:
__trace_hashtable_size() : __trace_container_size()
{
__id = "hashtable-size";
}
};
{ __id = "hashtable-size"; }
};
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
inline void
__trace_hashtable_size_init()
{ __tables<0>::_S_hashtable_size = new __trace_hashtable_size(); }
inline void __trace_hashtable_size_init()
{
__tables<0>::_S_hashtable_size = new __trace_hashtable_size();
}
inline void __trace_hashtable_size_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_hashtable_size) {
inline void
__trace_hashtable_size_report(FILE* __f, __warning_vector_t& __warnings)
{
if (__tables<0>::_S_hashtable_size)
{
__tables<0>::_S_hashtable_size->__collect_warnings(__warnings);
__tables<0>::_S_hashtable_size->__write(__f);
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
}
inline void __trace_hashtable_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
// Implementations of instrumentation hooks.
inline void
__trace_hashtable_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init())
return;
__tables<0>::_S_hashtable_size->__insert(__obj, __get_stack(), __num);
}
}
inline void __trace_hashtable_size_destruct(const void* __obj, size_t __num,
inline void
__trace_hashtable_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
{
if (!__profcxx_init())
return;
__tables<0>::_S_hashtable_size->__destruct(__obj, __num, __inum);
}
}
inline void __trace_hashtable_size_resize(const void* __obj, size_t __from,
size_t __to)
{
if (!__profcxx_init()) return;
inline void
__trace_hashtable_size_resize(const void* __obj, size_t __from, size_t __to)
{
if (!__profcxx_init())
return;
__tables<0>::_S_hashtable_size->__resize(__obj, __from, __to);
}
}
} // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_HASHTABLE_SIZE_H__ */
#endif /* _GLIBCXX_PROFILE_PROFILER_HASHTABLE_SIZE_H */
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_NODE_H__
#define PROFCXX_PROFILER_NODE_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_NODE_H
#define _GLIBCXX_PROFILE_PROFILER_NODE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
......@@ -53,15 +53,15 @@
namespace __gnu_profile
{
typedef const void* __object_t;
typedef void* __instruction_address_t;
typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t;
typedef const void* __object_t;
typedef void* __instruction_address_t;
typedef std::_GLIBCXX_STD_PR::vector<__instruction_address_t> __stack_npt;
typedef __stack_npt* __stack_t;
size_t __stack_max_depth();
size_t __stack_max_depth();
inline __stack_t __get_stack()
{
inline __stack_t __get_stack()
{
#if defined HAVE_EXECINFO_H
size_t __max_depth = __stack_max_depth();
if (__max_depth == 0)
......@@ -74,42 +74,39 @@ inline __stack_t __get_stack()
#else
return NULL;
#endif
}
}
inline __size(const __stack_t& __stack)
{
if (!__stack) {
inline __size(const __stack_t& __stack)
{
if (!__stack)
return 0;
} else {
else
return __stack->size();
}
}
inline void __write(FILE* __f, const __stack_t __stack)
{
if (!__stack) {
inline void __write(FILE* __f, const __stack_t __stack)
{
if (!__stack)
return;
}
__stack_npt::const_iterator __it;
for (__it = __stack->begin(); __it != __stack->end(); ++__it) {
for (__it = __stack->begin(); __it != __stack->end(); ++__it)
fprintf(__f, "%p ", *__it);
}
}
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
public:
size_t operator()(const __stack_t __s) const
{
if (!__s) {
if (!__s)
return 0;
}
uintptr_t __index = 0;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it) {
for (__it = __s->begin(); __it != __s->end(); ++__it)
{
__index += reinterpret_cast<uintptr_t>(*__it);
}
return __index;
......@@ -124,16 +121,16 @@ class __stack_hash
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0;
}
};
};
/** @brief Base class for a line in the object table. */
class __object_info_base
{
/** @brief Base class for a line in the object table. */
class __object_info_base
{
public:
__object_info_base() {}
__object_info_base() { }
__object_info_base(__stack_t __stack);
__object_info_base(const __object_info_base& o);
virtual ~__object_info_base() {}
virtual ~__object_info_base() { }
bool __is_valid() const { return _M_valid; }
__stack_t __stack() const { return _M_stack; }
virtual void __write(FILE* f) const = 0;
......@@ -141,32 +138,31 @@ class __object_info_base
protected:
__stack_t _M_stack;
bool _M_valid;
};
};
inline __object_info_base::__object_info_base(__stack_t __stack)
{
inline __object_info_base::__object_info_base(__stack_t __stack)
{
_M_stack = __stack;
_M_valid = true;
}
}
inline __object_info_base::__object_info_base(const __object_info_base& __o)
{
inline __object_info_base::__object_info_base(const __object_info_base& __o)
{
_M_stack = __o._M_stack;
_M_valid = __o._M_valid;
}
}
/** @brief Base class for a line in the stack table. */
template<typename __object_info>
class __stack_info_base
{
/** @brief Base class for a line in the stack table. */
template<typename __object_info>
class __stack_info_base
{
public:
__stack_info_base() {}
__stack_info_base() { }
__stack_info_base(const __object_info& __info) = 0;
virtual ~__stack_info_base() {}
virtual ~__stack_info_base() { }
void __merge(const __object_info& __info) = 0;
virtual float __magnitude() const = 0;
virtual const char* __get_id() const = 0;
};
};
} // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_NODE_H__ */
#endif /* _GLIBCXX_PROFILE_PROFILER_NODE_H */
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_STATE_H__
#define PROFCXX_PROFILER_STATE_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_STATE_H
#define _GLIBCXX_PROFILE_PROFILER_STATE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdio>
......@@ -45,63 +45,64 @@
namespace __gnu_profile
{
/** @brief Profiling mode on/off state. */
template<int _Unused=0>
class __state
{
private:
enum __state_type { __ON, __OFF, __INVALID };
/** @brief Profiling mode on/off state. */
template <int _Unused=0>
class __state
{
public:
__state_type _M_state;
public:
static __state<_Unused>* _S_diag_state;
__state() : _M_state(__INVALID) {}
~__state() {}
__state() : _M_state(__INVALID) { }
~__state() { }
bool __is_on() { return _M_state == __ON; }
bool __is_off() { return _M_state == __OFF; }
bool __is_invalid() { return _M_state == __INVALID; }
void __turn_on() { _M_state = __ON; }
void __turn_off() { _M_state = __OFF; }
};
private:
enum __state_type { __ON, __OFF, __INVALID };
__state_type _M_state;
};
template<int _Unused>
__state<_Unused>* __state<_Unused>::_S_diag_state = NULL;
template <int _Unused>
__state<_Unused>* __state<_Unused>::_S_diag_state = NULL;
inline bool __is_on()
{
inline bool
__is_on()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_on();
}
}
inline bool __is_off()
{
inline bool
__is_off()
{
return __state<0>::_S_diag_state && __state<0>::_S_diag_state->__is_off();
}
}
inline bool __is_invalid()
{
return (!__state<0>::_S_diag_state
|| __state<0>::_S_diag_state->__is_invalid());
}
inline bool
__is_invalid()
{
return (!__state<0>::_S_diag_state || __state<0>::_S_diag_state->__is_invalid());
}
inline void __turn_on()
{
if (!__state<0>::_S_diag_state) {
inline void
__turn_on()
{
if (!__state<0>::_S_diag_state)
__state<0>::_S_diag_state = new __state<0>();
}
__state<0>::_S_diag_state->__turn_on();
}
}
inline void __turn_off()
{
if (!__state<0>::_S_diag_state) {
inline void
__turn_off()
{
if (!__state<0>::_S_diag_state)
__state<0>::_S_diag_state = new __state<0>();
}
__state<0>::_S_diag_state->__turn_off();
}
}
} // end namespace __gnu_profile
#endif /* PROFCXX_PROFILER_STATE_H__ */
#endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */
......@@ -34,8 +34,8 @@
// Written by Lixia Liu and Silvius Rus.
#ifndef PROFCXX_PROFILER_VECTOR_SIZE_H__
#define PROFCXX_PROFILER_VECTOR_SIZE_H__ 1
#ifndef _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H
#define _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H 1
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdlib>
......@@ -54,59 +54,49 @@
namespace __gnu_profile
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_vector_size : public __trace_container_size
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_vector_size : public __trace_container_size
{
public:
__trace_vector_size() : __trace_container_size() { __id = "vector-size"; }
};
//////////////////////////////////////////////////////////////////////////////
// Initialization and report.
//////////////////////////////////////////////////////////////////////////////
inline void __trace_vector_size_init()
{
__tables<0>::_S_vector_size = new __trace_vector_size();
}
inline void __trace_vector_size_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (__tables<0>::_S_vector_size) {
};
// Initialization and report.
inline void
__trace_vector_size_init()
{ __tables<0>::_S_vector_size = new __trace_vector_size(); }
inline void
__trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings)
{
if (__tables<0>::_S_vector_size)
{
__tables<0>::_S_vector_size->__collect_warnings(__warnings);
__tables<0>::_S_vector_size->__write(__f);
}
}
//////////////////////////////////////////////////////////////////////////////
// Implementations of instrumentation hooks.
//////////////////////////////////////////////////////////////////////////////
}
inline void __trace_vector_size_construct(const void* __obj, size_t __num)
{
// Implementations of instrumentation hooks.
inline void
__trace_vector_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__insert(__obj, __get_stack(), __num);
}
}
inline void __trace_vector_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
inline void
__trace_vector_size_destruct(const void* __obj, size_t __num, size_t __inum)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__destruct(__obj, __num, __inum);
}
}
inline void __trace_vector_size_resize(const void* __obj, size_t __from,
size_t __to)
{
inline void
__trace_vector_size_resize(const void* __obj, size_t __from, size_t __to)
{
if (!__profcxx_init()) return;
__tables<0>::_S_vector_size->__resize(__obj, __from, __to);
}
}
} // namespace __gnu_profile
#endif /* PROFCXX_PROFILER_VECTOR_SIZE_H__ */
#endif /* _GLIBCXX_PROFILE_PROFILER_VECTOR_SIZE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment