Commit b0af13ea by Paolo Carlini Committed by Paolo Carlini

profiler_list_to_slist.h: Fix formatting, other minor stylistic changes.

2010-06-22  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/profile/impl/profiler_list_to_slist.h: Fix formatting,
	other minor stylistic changes.
	* include/profile/impl/profiler_container_size.h: Likewise.
	* include/profile/impl/profiler_vector_size.h: Likewise.
	* include/profile/impl/profiler_hash_func.h: Likewise.
	* include/profile/impl/profiler_trace.h: Likewise.
	* include/profile/impl/profiler_list_to_vector.h: Likewise.
	* include/profile/impl/profiler_vector_to_list.h: Likewise.
	* include/profile/impl/profiler_state.h: Likewise.
	* include/profile/impl/profiler_map_to_unordered_map.h: Likewise.
	* include/profile/impl/profiler_hashtable_size.h: Likewise.
	* include/profile/impl/profiler_node.h: Likewise.

From-SVN: r161236
parent b2e894b5
2010-06-22 Paolo Carlini <paolo.carlini@oracle.com>
* include/profile/impl/profiler_list_to_slist.h: Fix formatting,
other minor stylistic changes.
* include/profile/impl/profiler_container_size.h: Likewise.
* include/profile/impl/profiler_vector_size.h: Likewise.
* include/profile/impl/profiler_hash_func.h: Likewise.
* include/profile/impl/profiler_trace.h: Likewise.
* include/profile/impl/profiler_list_to_vector.h: Likewise.
* include/profile/impl/profiler_vector_to_list.h: Likewise.
* include/profile/impl/profiler_state.h: Likewise.
* include/profile/impl/profiler_map_to_unordered_map.h: Likewise.
* include/profile/impl/profiler_hashtable_size.h: Likewise.
* include/profile/impl/profiler_node.h: Likewise.
2010-06-22 Matthias Klose <doko@ubuntu.com>
* python/libstdcxx/v6/printers.py: Don't use string exceptions.
......
......@@ -52,134 +52,137 @@
namespace __gnu_profile
{
/** @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(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() {}
void __merge(const __hashfunc_info& __o);
void __destruct(size_t __chain, size_t __accesses, size_t __hops);
void __write(FILE* __f) const;
float __magnitude() const { return static_cast<float>(_M_hops); }
const char* __advice() const { return strdup("change hash function"); }
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
};
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)
{
_M_longest_chain = std::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)
{
_M_longest_chain = std::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 {
public:
__hashfunc_stack_info(const __hashfunc_info& __o) : __hashfunc_info(__o) {}
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__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);
};
inline __trace_hash_func::__trace_hash_func()
/** @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(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) { }
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack),
_M_longest_chain(0), _M_accesses(0), _M_hops(0){ }
virtual ~__hashfunc_info() {}
void
__merge(const __hashfunc_info& __o)
{
_M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
}
void
__destruct(size_t __chain, size_t __accesses, size_t __hops)
{
_M_longest_chain = std::max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
void
__write(FILE* __f) const
{ fprintf(__f, "%Zu %Zu %Zu\n", _M_hops, _M_accesses, _M_longest_chain); }
float
__magnitude() const
{ return static_cast<float>(_M_hops); }
const char*
__advice() const
{ return strdup("change hash function"); }
private:
size_t _M_longest_chain;
size_t _M_accesses;
size_t _M_hops;
};
/** @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) { }
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{
__id = "hash-distr";
}
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 __trace_hash_func::__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__is_on()) return;
// First find the item from the live objects and update the informations.
__hashfunc_info* __objs = __get_object_info(__obj);
if (!__objs)
return;
__objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
}
inline void __trace_hash_func_init()
{
_GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func();
}
inline void __trace_hash_func_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_hash_func)) {
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f);
{ __id = "hash-distr"; }
~__trace_hash_func() {}
// Insert a new node at construct with object, callstack and initial size.
void
__insert(__object_t __obj, __stack_t __stack)
{ __add_object(__obj, __hashfunc_info(__stack)); }
// Call at destruction/clean to set container final size.
void
__destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__is_on())
return;
// First find the item from the live objects and update the informations.
__hashfunc_info* __objs = __get_object_info(__obj);
if (!__objs)
return;
__objs->__destruct(__chain, __accesses, __hops);
__retire_object(__obj);
}
};
inline void
__trace_hash_func_init()
{ _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); }
inline void
__trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_hash_func))
{
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__write(__f);
}
}
}
inline void __trace_hash_func_construct(const void* __obj)
{
if (!__profcxx_init()) return;
inline void
__trace_hash_func_construct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__insert(__obj, __get_stack());
}
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__insert(__obj, __get_stack());
}
inline void __trace_hash_func_destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__profcxx_init()) return;
inline void
__trace_hash_func_destruct(const void* __obj, size_t __chain,
size_t __accesses, size_t __hops)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses,
__hops);
}
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj, __chain, __accesses,
__hops);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -54,54 +54,60 @@
namespace __gnu_profile
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_hashtable_size : public __trace_container_size
{
public:
__trace_hashtable_size() : __trace_container_size()
/** @brief Hashtable size instrumentation trace producer. */
class __trace_hashtable_size
: public __trace_container_size
{
__id = "hashtable-size";
}
};
inline void __trace_hashtable_size_init()
{
_GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size();
}
inline void __trace_hashtable_size_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_hashtable_size)) {
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__write(__f);
public:
__trace_hashtable_size()
: __trace_container_size()
{ __id = "hashtable-size"; }
};
inline void
__trace_hashtable_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_hashtable_size) = new __trace_hashtable_size(); }
inline void
__trace_hashtable_size_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_hashtable_size))
{
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->
__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__write(__f);
}
}
}
inline void __trace_hashtable_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
inline void
__trace_hashtable_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__insert(__obj, __get_stack(),
__num);
}
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__insert(__obj, __get_stack(),
__num);
}
inline void __trace_hashtable_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
inline void
__trace_hashtable_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__destruct(__obj, __num, __inum);
}
_GLIBCXX_PROFILE_DATA(_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;
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__resize(__obj, __from, __to);
}
_GLIBCXX_PROFILE_DATA(_S_hashtable_size)->__resize(__obj, __from, __to);
}
} // namespace __gnu_profile
......
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -52,131 +52,173 @@
namespace __gnu_profile
{
class __list2slist_info: public __object_info_base
{
public:
__list2slist_info() : _M_rewind(false), _M_operations(0) {}
__list2slist_info(__stack_t __stack)
: _M_rewind(false), _M_operations(0),__object_info_base(__stack) {}
virtual ~__list2slist_info() {}
__list2slist_info(const __list2slist_info& __o) : __object_info_base(__o)
{ _M_rewind = __o._M_rewind; _M_operations = __o._M_operations; }
// XXX: the magnitude should be multiplied with a constant factor F,
// where F is 1 when the malloc size class of list nodes is different
// from the malloc size class of slist nodes. When they fall into the same
// class, the only slist benefit is from having to set fewer links, so
// the factor F should be much smaller, closer to 0 than to 1.
// This could be implemented by passing the size classes in the config file.
// For now, we always assume F to be 1.
float __magnitude() const
{ if (!_M_rewind) return _M_operations; else return 0; }
void __merge(const __list2slist_info& __o) {};
void __write(FILE* __f) const;
const char* __advice() const
{ return strdup("change std::list to std::forward_list"); }
void __opr_rewind() { _M_rewind = true; _M_valid = false;}
void __record_operation() { _M_operations++; }
bool __has_rewind() { return _M_rewind; }
private:
bool _M_rewind;
size_t _M_operations;
};
class __list2slist_stack_info: public __list2slist_info {
public:
__list2slist_stack_info(const __list2slist_info& __o)
: __list2slist_info(__o) {}
};
class __trace_list_to_slist
: public __trace_base<__list2slist_info, __list2slist_stack_info>
{
public:
~__trace_list_to_slist() {}
__trace_list_to_slist()
: __trace_base<__list2slist_info, __list2slist_stack_info>()
{ __id = "list-to-slist"; }
void __opr_rewind(const void* __obj);
void __record_operation(const void* __obj);
void __insert(const __object_t __obj, __stack_t __stack)
{ __add_object(__obj, __list2slist_info(__stack)); }
void __destruct(const void* __obj);
};
inline void __list2slist_info::__write(FILE* __f) const
{
fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid");
}
inline void __trace_list_to_slist::__destruct(const void* __obj)
{
if (!__is_on())
return;
__list2slist_info* __res = __get_object_info(__obj);
if (!__res)
return;
__retire_object(__obj);
}
inline void __trace_list_to_slist_init()
{
_GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist();
}
inline void __trace_list_to_slist_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_list_to_slist)) {
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__write(__f);
class __list2slist_info
: public __object_info_base
{
public:
__list2slist_info()
: _M_rewind(false), _M_operations(0) { }
__list2slist_info(__stack_t __stack)
: __object_info_base(__stack), _M_rewind(false), _M_operations(0) { }
virtual ~__list2slist_info() { }
__list2slist_info(const __list2slist_info& __o)
: __object_info_base(__o), _M_rewind(__o._M_rewind),
_M_operations(__o._M_operations) { }
// XXX: the magnitude should be multiplied with a constant factor F,
// where F is 1 when the malloc size class of list nodes is different
// from the malloc size class of slist nodes. When they fall into the same
// class, the only slist benefit is from having to set fewer links, so
// the factor F should be much smaller, closer to 0 than to 1.
// This could be implemented by passing the size classes in the config
// file. For now, we always assume F to be 1.
float
__magnitude() const
{
if (!_M_rewind)
return _M_operations;
else
return 0;
}
void
__merge(const __list2slist_info&) { };
void
__write(FILE* __f) const
{ fprintf(__f, "%s\n", _M_rewind ? "invalid" : "valid"); }
const char*
__advice() const
{ return strdup("change std::list to std::forward_list"); }
void
__opr_rewind()
{
_M_rewind = true;
_M_valid = false;
}
void
__record_operation()
{ _M_operations++; }
bool
__has_rewind()
{ return _M_rewind; }
private:
bool _M_rewind;
size_t _M_operations;
};
class __list2slist_stack_info
: public __list2slist_info
{
public:
__list2slist_stack_info(const __list2slist_info& __o)
: __list2slist_info(__o) { }
};
class __trace_list_to_slist
: public __trace_base<__list2slist_info, __list2slist_stack_info>
{
public:
~__trace_list_to_slist() { }
__trace_list_to_slist()
: __trace_base<__list2slist_info, __list2slist_stack_info>()
{ __id = "list-to-slist"; }
void
__opr_rewind(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_rewind();
}
void
__record_operation(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__record_operation();
}
void
__insert(const __object_t __obj, __stack_t __stack)
{ __add_object(__obj, __list2slist_info(__stack)); }
void
__destruct(const void* __obj)
{
if (!__is_on())
return;
__list2slist_info* __res = __get_object_info(__obj);
if (!__res)
return;
__retire_object(__obj);
}
};
inline void
__trace_list_to_slist_init()
{ _GLIBCXX_PROFILE_DATA(_S_list_to_slist) = new __trace_list_to_slist(); }
inline void
__trace_list_to_slist_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_list_to_slist))
{
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->
__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__write(__f);
}
}
}
inline void __trace_list_to_slist::__opr_rewind(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__opr_rewind();
}
inline void __trace_list_to_slist::__record_operation(const void* __obj)
{
__list2slist_info* __res = __get_object_info(__obj);
if (__res)
__res->__record_operation();
}
inline void
__trace_list_to_slist_rewind(const void* __obj)
{
if (!__profcxx_init())
return;
inline void __trace_list_to_slist_rewind(const void* __obj)
{
if (!__profcxx_init()) return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj);
}
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__opr_rewind(__obj);
}
inline void __trace_list_to_slist_operation(const void* __obj)
{
if (!__profcxx_init()) return;
inline void
__trace_list_to_slist_operation(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj);
}
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__record_operation(__obj);
}
inline void __trace_list_to_slist_construct(const void* __obj)
{
if (!__profcxx_init()) return;
inline void
__trace_list_to_slist_construct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack());
}
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__insert(__obj, __get_stack());
}
inline void __trace_list_to_slist_destruct(const void* __obj)
{
if (!__profcxx_init()) return;
inline void
__trace_list_to_slist_destruct(const void* __obj)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj);
}
_GLIBCXX_PROFILE_DATA(_S_list_to_slist)->__destruct(__obj);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_LIST_TO_SLIST_H */
......@@ -53,120 +53,125 @@
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 _GLIBCXX_HAVE_EXECINFO_H
size_t __max_depth = __stack_max_depth();
if (__max_depth == 0)
return 0;
__stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth);
__stack_t __stack = new __stack_npt(__depth);
memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t));
return __stack;
size_t __max_depth = __stack_max_depth();
if (__max_depth == 0)
return 0;
__stack_npt __buffer(__max_depth);
int __depth = backtrace(&__buffer[0], __max_depth);
__stack_t __stack = new __stack_npt(__depth);
memcpy(&(*__stack)[0], &__buffer[0], __depth * sizeof(__object_t));
return __stack;
#else
return 0;
#endif
}
inline __size(const __stack_t& __stack)
{
if (!__stack) {
return 0;
} else {
return __stack->size();
}
}
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) {
fprintf(__f, "%p ", *__it);
#endif
}
}
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
public:
size_t operator()(const __stack_t __s) const
inline size_t
__size(__stack_t __stack)
{
if (!__s) {
if (!__stack)
return 0;
}
else
return __stack->size();
}
uintptr_t __index = 0;
// XXX
inline void
__write(FILE* __f, __stack_t __stack)
{
if (!__stack)
return;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it) {
__index += reinterpret_cast<uintptr_t>(*__it);
}
return __index;
for (__it = __stack->begin(); __it != __stack->end(); ++__it)
fprintf(__f, "%p ", *__it);
}
bool operator() (const __stack_t __stack1, const __stack_t __stack2) const
/** @brief Hash function for summary trace using call stack as index. */
class __stack_hash
{
if (!__stack1 && !__stack2) return true;
if (!__stack1 || !__stack2) return false;
if (__stack1->size() != __stack2->size()) return false;
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0;
}
};
public:
size_t
operator()(__stack_t __s) const
{
if (!__s)
return 0;
uintptr_t __index = 0;
__stack_npt::const_iterator __it;
for (__it = __s->begin(); __it != __s->end(); ++__it)
__index += reinterpret_cast<uintptr_t>(*__it);
return __index;
}
/** @brief Base class for a line in the object table. */
class __object_info_base
{
public:
__object_info_base() {}
__object_info_base(__stack_t __stack);
__object_info_base(const __object_info_base& o);
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;
protected:
__stack_t _M_stack;
bool _M_valid;
};
inline __object_info_base::__object_info_base(__stack_t __stack)
{
_M_stack = __stack;
_M_valid = true;
}
bool operator() (__stack_t __stack1, __stack_t __stack2) const
{
if (!__stack1 && !__stack2)
return true;
if (!__stack1 || !__stack2)
return false;
if (__stack1->size() != __stack2->size())
return false;
size_t __byte_size = __stack1->size() * sizeof(__stack_npt::value_type);
return memcmp(&(*__stack1)[0], &(*__stack2)[0], __byte_size) == 0;
}
};
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
{
public:
__stack_info_base() {}
__stack_info_base(const __object_info& __info) = 0;
virtual ~__stack_info_base() {}
void __merge(const __object_info& __info) = 0;
virtual float __magnitude() const = 0;
virtual const char* __get_id() const = 0;
};
/** @brief Base class for a line in the object table. */
class __object_info_base
{
public:
__object_info_base() { }
__object_info_base(__stack_t __stack)
: _M_stack(__stack), _M_valid(true) { }
__object_info_base(const __object_info_base& __o)
: _M_stack(__o._M_stack), _M_valid(__o._M_valid) { }
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;
protected:
__stack_t _M_stack;
bool _M_valid;
};
/** @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(const __object_info& __info) = 0;
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 /* _GLIBCXX_PROFILE_PROFILER_NODE_H */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -39,32 +39,35 @@
namespace __gnu_profile
{
enum __state_type { __ON, __OFF, __INVALID };
enum __state_type { __ON, __OFF, __INVALID };
_GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID);
_GLIBCXX_PROFILE_DEFINE_DATA(__state_type, __state, __INVALID);
inline bool
__turn(__state_type __s)
{ return (_GLIBCXX_PROFILE_DATA(__state)
== __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
__INVALID, __s)); }
inline bool __turn(__state_type __s)
{
return (_GLIBCXX_PROFILE_DATA(__state)
== __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
__INVALID, __s));
}
inline bool __turn_on()
{ return __turn(__ON); }
inline bool
__turn_on()
{ return __turn(__ON); }
inline bool __turn_off()
{ return __turn(__OFF); }
inline bool
__turn_off()
{ return __turn(__OFF); }
inline bool __is_on()
{ return _GLIBCXX_PROFILE_DATA(__state) == __ON; }
inline bool
__is_on()
{ return _GLIBCXX_PROFILE_DATA(__state) == __ON; }
inline bool __is_off()
{ return _GLIBCXX_PROFILE_DATA(__state) == __OFF; }
inline bool
__is_off()
{ return _GLIBCXX_PROFILE_DATA(__state) == __OFF; }
inline bool __is_invalid()
{ return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; }
inline bool
__is_invalid()
{ return _GLIBCXX_PROFILE_DATA(__state) == __INVALID; }
} // end namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_STATE_H */
// -*- C++ -*-
//
// Copyright (C) 2009 Free Software Foundation, Inc.
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -54,50 +54,57 @@
namespace __gnu_profile
{
/** @brief Hashtable size instrumentation trace producer. */
class __trace_vector_size : public __trace_container_size
{
public:
__trace_vector_size() : __trace_container_size() { __id = "vector-size"; }
};
inline void __trace_vector_size_init()
{
_GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size();
}
inline void __trace_vector_size_report(FILE* __f,
__warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_vector_size)) {
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__write(__f);
/** @brief Hashtable size instrumentation trace producer. */
class __trace_vector_size
: public __trace_container_size
{
public:
__trace_vector_size()
: __trace_container_size()
{ __id = "vector-size"; }
};
inline void
__trace_vector_size_init()
{ _GLIBCXX_PROFILE_DATA(_S_vector_size) = new __trace_vector_size(); }
inline void
__trace_vector_size_report(FILE* __f, __warning_vector_t& __warnings)
{
if (_GLIBCXX_PROFILE_DATA(_S_vector_size))
{
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__collect_warnings(__warnings);
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__write(__f);
}
}
}
inline void __trace_vector_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init()) return;
inline void
__trace_vector_size_construct(const void* __obj, size_t __num)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__insert(__obj, __get_stack(), __num);
}
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__insert(__obj, __get_stack(),
__num);
}
inline void __trace_vector_size_destruct(const void* __obj, size_t __num,
size_t __inum)
{
if (!__profcxx_init()) return;
inline void
__trace_vector_size_destruct(const void* __obj, size_t __num, size_t __inum)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__destruct(__obj, __num, __inum);
}
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__destruct(__obj, __num, __inum);
}
inline void __trace_vector_size_resize(const void* __obj, size_t __from,
size_t __to)
{
if (!__profcxx_init()) return;
inline void
__trace_vector_size_resize(const void* __obj, size_t __from, size_t __to)
{
if (!__profcxx_init())
return;
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__resize(__obj, __from, __to);
}
_GLIBCXX_PROFILE_DATA(_S_vector_size)->__resize(__obj, __from, __to);
}
} // namespace __gnu_profile
......
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