From ccd0626bf8d76d448197f1166abdc03dafa6b7bf Mon Sep 17 00:00:00 2001 From: Sergey Yagovtsev Date: Mon, 5 Jun 2017 12:57:03 +0300 Subject: [PATCH] backward compatibility with old size of thread_id_t. For #41 --- easy_profiler_core/include/easy/profiler.h | 2 +- easy_profiler_core/reader.cpp | 6 +++++- easy_profiler_core/version.info | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/easy_profiler_core/include/easy/profiler.h b/easy_profiler_core/include/easy/profiler.h index c0bdc20..4fca4ea 100644 --- a/easy_profiler_core/include/easy/profiler.h +++ b/easy_profiler_core/include/easy/profiler.h @@ -445,7 +445,7 @@ namespace profiler { const uint16_t DEFAULT_PORT = EASY_DEFAULT_PORT; typedef uint64_t timestamp_t; - typedef size_t thread_id_t; + typedef uint64_t thread_id_t; typedef uint32_t block_id_t; enum BlockType : uint8_t diff --git a/easy_profiler_core/reader.cpp b/easy_profiler_core/reader.cpp index b56ed6c..5c3516b 100644 --- a/easy_profiler_core/reader.cpp +++ b/easy_profiler_core/reader.cpp @@ -87,6 +87,7 @@ extern const uint32_t EASY_CURRENT_VERSION; # define EASY_VERSION_INT(v_major, v_minor, v_patch) ((static_cast(v_major) << 24) | (static_cast(v_minor) << 16) | static_cast(v_patch)) const uint32_t MIN_COMPATIBLE_VERSION = EASY_VERSION_INT(0, 1, 0); ///< minimal compatible version (.prof file format was not changed seriously since this version) const uint32_t EASY_V_100 = EASY_VERSION_INT(1, 0, 0); ///< in v1.0.0 some additional data were added into .prof file +const uint32_t EASY_V_130 = EASY_VERSION_INT(1, 3, 0); ///< in v1.3.0 changed sizeof(thread_id_t) uint32_t -> uint64_t # undef EASY_VERSION_INT const uint64_t TIME_FACTOR = 1000000000ULL; @@ -557,7 +558,10 @@ extern "C" { EASY_BLOCK("Read thread data", ::profiler::colors::DarkGreen); ::profiler::thread_id_t thread_id = 0; - inFile.read((char*)&thread_id, sizeof(decltype(thread_id))); + long thread_id_t_size = sizeof(decltype(thread_id)); + if (version < EASY_V_130) + thread_id_t_size = sizeof(uint32_t); + inFile.read((char*)&thread_id, thread_id_t_size); auto& root = threaded_trees[thread_id]; diff --git a/easy_profiler_core/version.info b/easy_profiler_core/version.info index 26aaba0..f0bb29e 100644 --- a/easy_profiler_core/version.info +++ b/easy_profiler_core/version.info @@ -1 +1 @@ -1.2.0 +1.3.0