Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--import-chrome/src/import-chrome.cpp11
-rw-r--r--server/TracyWorker.cpp18
-rw-r--r--server/TracyWorker.hpp2
3 files changed, 25 insertions, 6 deletions
diff --git a/import-chrome/src/import-chrome.cpp b/import-chrome/src/import-chrome.cpp
index a5186e4d..a03888d9 100644
--- a/import-chrome/src/import-chrome.cpp
+++ b/import-chrome/src/import-chrome.cpp
@@ -6,6 +6,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
+#include <unordered_map>
#include "json.hpp"
@@ -56,6 +57,7 @@ int main( int argc, char** argv )
std::vector<tracy::Worker::ImportEventTimeline> timeline;
std::vector<tracy::Worker::ImportEventMessages> messages;
std::vector<tracy::Worker::ImportEventPlots> plots;
+ std::unordered_map<uint64_t, std::string> threadNames;
if( j.is_object() && j.contains( "traceEvents" ) )
{
@@ -156,6 +158,13 @@ int main( int argc, char** argv )
}
}
}
+ else if (type == "M")
+ {
+ if (v.contains("name") && v["name"] == "thread_name" && v.contains("args") && v["args"].is_object() && v["args"].contains("name"))
+ {
+ threadNames[v["tid"].get<uint64_t>()] = v["args"]["name"].get<std::string>();
+ }
+ }
}
std::stable_sort( timeline.begin(), timeline.end(), [] ( const auto& l, const auto& r ) { return l.timestamp < r.timestamp; } );
@@ -189,7 +198,7 @@ int main( int argc, char** argv )
while( *program ) program++;
program--;
while( program > input && ( *program != '/' || *program != '\\' ) ) program--;
- tracy::Worker worker( program, timeline, messages, plots );
+ tracy::Worker worker( program, timeline, messages, plots, threadNames );
auto w = std::unique_ptr<tracy::FileWrite>( tracy::FileWrite::Open( output, clev ) );
if( !w )
diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp
index 6fb4ffcc..a519274f 100644
--- a/server/TracyWorker.cpp
+++ b/server/TracyWorker.cpp
@@ -275,7 +275,7 @@ Worker::Worker( const char* addr, uint16_t port )
m_threadNet = std::thread( [this] { SetThreadName( "Tracy Network" ); Network(); } );
}
-Worker::Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots )
+Worker::Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames )
: m_hasData( true )
, m_delay( 0 )
, m_resolution( 0 )
@@ -428,9 +428,19 @@ Worker::Worker( const std::string& program, const std::vector<ImportEventTimelin
for( auto& t : m_threadMap )
{
- char buf[64];
- sprintf( buf, "%" PRIu64, t.first );
- AddThreadString( t.first, buf, strlen( buf ) );
+ auto name = threadNames.find(t.first);
+ if (name != threadNames.end())
+ {
+ char buf[128];
+ int len = snprintf(buf, sizeof(buf), "(%" PRIu64 ") %s", t.first, name->second.c_str());
+ AddThreadString(t.first, buf, len);
+ }
+ else
+ {
+ char buf[64];
+ sprintf( buf, "%" PRIu64, t.first );
+ AddThreadString( t.first, buf, strlen( buf ) );
+ }
}
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {
diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp
index 2fe6ba00..b2f9a3d1 100644
--- a/server/TracyWorker.hpp
+++ b/server/TracyWorker.hpp
@@ -394,7 +394,7 @@ public:
};
Worker( const char* addr, uint16_t port );
- Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots );
+ Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames );
Worker( FileRead& f, EventType::Type eventMask = EventType::All, bool bgTasks = true );
~Worker();