0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-28 01:04:41 +08:00

Fixing problems after changing thread_id_t to uint64_t from uint32_t: There is still a big problem with target-thread ids of context-switch events on *nix systems (it has been stored in block_id_t which is uint32_t and now it requires Core API changes to support new thread_id_t). Also there is a problem with statistics displaying (for top-level blocks parent_index had value of thread-id, it requires a work around now).

This commit is contained in:
Victor Zarubkin 2017-06-05 21:24:01 +03:00
parent 35b4796a62
commit 65ac892e32
4 changed files with 29 additions and 16 deletions

View File

@ -263,7 +263,12 @@ namespace profiler {
}; // END of class BlocksTreeRoot.
typedef ::profiler::BlocksTree::blocks_t blocks_t;
#ifdef _WIN64
typedef ::std::unordered_map<::profiler::thread_id_t, ::profiler::BlocksTreeRoot, ::profiler::passthrough_hash> thread_blocks_tree_t;
#else
typedef ::std::unordered_map<::profiler::thread_id_t, ::profiler::BlocksTreeRoot> thread_blocks_tree_t;
#endif
//////////////////////////////////////////////////////////////////////////

View File

@ -1041,7 +1041,10 @@ void ProfileManager::beginContextSwitch(profiler::thread_id_t _thread_id, profil
if (ts != nullptr)
// Dirty hack: _target_thread_id will be written to the field "block_id_t m_id"
// and will be available calling method id().
ts->sync.openedList.emplace_back(_time, _time, _target_thread_id, _target_process);
#ifndef _WIN32
#pragma message "WARNING: Fix saving thread_id_t as block_id_t for Context-Switch events !!!!"
#endif
ts->sync.openedList.emplace_back(_time, _time, (profiler::block_id_t)_target_thread_id, _target_process);
}
//////////////////////////////////////////////////////////////////////////
@ -1284,7 +1287,7 @@ char ProfileManager::checkThreadExpired(ThreadStorage& _registeredThread)
// Check thread for Windows
DWORD exitCode = 0;
auto hThread = OpenThread(THREAD_QUERY_LIMITED_INFORMATION, FALSE, _registeredThread.id);
auto hThread = OpenThread(THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)_registeredThread.id);
if (hThread == nullptr || GetExitCodeThread(hThread, &exitCode) == FALSE || exitCode != STILL_ACTIVE)
{
// Thread has been expired

View File

@ -540,7 +540,11 @@ extern "C" {
}
}
#ifdef _WIN64
typedef ::std::unordered_map<::profiler::thread_id_t, StatsMap, ::profiler::passthrough_hash> PerThreadStats;
#else
typedef ::std::unordered_map<::profiler::thread_id_t, StatsMap> PerThreadStats;
#endif
PerThreadStats parent_statistics, frame_statistics;
IdMap identification_table;

View File

@ -100,42 +100,43 @@ inline qreal microseconds2units(qreal _value)
namespace profiler_gui {
template <const size_t SIZEOF_T>
struct no_hasher {
template <class T> inline size_t operator () (const T& _data) const {
return (size_t)_data;
}
template <class T, const size_t SIZEOF_T>
struct no_hasher : public ::std::hash<T> {
using ::std::hash<T>::operator ();
//inline size_t operator () (const T& _data) const {
// return ::std::hash<T>::operator () (_data);
//}
};
#ifdef _WIN64
template <> struct no_hasher<8> {
template <class T> inline size_t operator () (T _data) const {
template <class T> struct no_hasher<T, 8> {
inline size_t operator () (T _data) const {
return (size_t)_data;
}
};
#endif
template <> struct no_hasher<4> {
template <class T> inline size_t operator () (T _data) const {
template <class T> struct no_hasher<T, 4> {
inline size_t operator () (T _data) const {
return (size_t)_data;
}
};
template <> struct no_hasher<2> {
template <class T> inline size_t operator () (T _data) const {
template <class T> struct no_hasher<T, 2> {
inline size_t operator () (T _data) const {
return (size_t)_data;
}
};
template <> struct no_hasher<1> {
template <class T> inline size_t operator () (T _data) const {
template <class T> struct no_hasher<T, 1> {
inline size_t operator () (T _data) const {
return (size_t)_data;
}
};
template <class T>
struct do_no_hash {
typedef no_hasher<sizeof(T)> hasher_t;
typedef no_hasher<T, sizeof(T)> hasher_t;
};
//////////////////////////////////////////////////////////////////////////