mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Add user data storage handler.
This commit is contained in:
parent
34cc7183d0
commit
27965e8690
@ -117,6 +117,7 @@
|
||||
<ClCompile Include="..\..\..\server\TracyPrint.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyStorage.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTexture.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyUserData.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyWorker.cpp" />
|
||||
<ClCompile Include="..\..\libs\gl3w\GL\gl3w.c" />
|
||||
@ -171,6 +172,7 @@
|
||||
<ClInclude Include="..\..\..\server\TracyStorage.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyStringDiscovery.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTexture.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyUserData.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyVarArray.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyVector.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyVersion.hpp" />
|
||||
|
@ -102,6 +102,9 @@
|
||||
<ClCompile Include="..\..\src\ResolvService.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyUserData.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||
@ -275,6 +278,9 @@
|
||||
<ClInclude Include="..\..\src\ResolvService.hpp">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\server\TracyUserData.hpp">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="DebugVis.natvis" />
|
||||
|
63
server/TracyUserData.cpp
Normal file
63
server/TracyUserData.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include <assert.h>
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "TracyStorage.hpp"
|
||||
#include "TracyUserData.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
constexpr auto FileDescription = "description";
|
||||
|
||||
UserData::UserData()
|
||||
{
|
||||
}
|
||||
|
||||
UserData::UserData( const char* program, uint64_t time )
|
||||
: m_program( program )
|
||||
, m_time( time )
|
||||
{
|
||||
const auto descpath = GetSavePath( m_program.c_str(), m_time, FileDescription, false );
|
||||
if( descpath )
|
||||
{
|
||||
FILE* f = fopen( descpath, "rb" );
|
||||
if( f )
|
||||
{
|
||||
fseek( f, 0, SEEK_END );
|
||||
const auto sz = ftell( f );
|
||||
fseek( f, 0, SEEK_SET );
|
||||
auto buf = std::make_unique<char[]>( sz );
|
||||
fread( buf.get(), 1, sz, f );
|
||||
fclose( f );
|
||||
m_description.assign( buf.get(), buf.get() + sz );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UserData::Init( const char* program, uint64_t time )
|
||||
{
|
||||
assert( !Valid() );
|
||||
m_program = program;
|
||||
m_time = time;
|
||||
}
|
||||
|
||||
bool UserData::SetDescription( const char* description )
|
||||
{
|
||||
assert( Valid() );
|
||||
|
||||
m_description = description;
|
||||
const auto sz = m_description.size();
|
||||
|
||||
const auto path = GetSavePath( m_program.c_str(), m_time, FileDescription, true );
|
||||
if( !path ) return false;
|
||||
|
||||
FILE* f = fopen( path, "wb" );
|
||||
if( !f ) return false;
|
||||
|
||||
fwrite( description, 1, sz, f );
|
||||
fclose( f );
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
31
server/TracyUserData.hpp
Normal file
31
server/TracyUserData.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef __TRACYUSERDATA_HPP__
|
||||
#define __TRACYUSERDATA_HPP__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
class UserData
|
||||
{
|
||||
public:
|
||||
UserData();
|
||||
UserData( const char* program, uint64_t time );
|
||||
|
||||
bool Valid() const { return !m_program.empty(); }
|
||||
void Init( const char* program, uint64_t time );
|
||||
|
||||
const std::string& GetDescription() const { return m_description; }
|
||||
bool SetDescription( const char* description );
|
||||
|
||||
private:
|
||||
std::string m_program;
|
||||
uint64_t m_time;
|
||||
|
||||
std::string m_description;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -109,6 +109,7 @@ View::View( const char* addr, ImFont* fixedWidth, ImFont* bigFont, SetTitleCallb
|
||||
, m_textEditorFont( fixedWidth )
|
||||
, m_bigFont( bigFont )
|
||||
, m_stcb( stcb )
|
||||
, m_userData()
|
||||
{
|
||||
assert( s_instance == nullptr );
|
||||
s_instance = this;
|
||||
@ -125,6 +126,7 @@ View::View( FileRead& f, ImFont* fixedWidth, ImFont* bigFont, SetTitleCallback s
|
||||
, m_textEditorFont( fixedWidth )
|
||||
, m_bigFont( bigFont )
|
||||
, m_stcb( stcb )
|
||||
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
||||
{
|
||||
assert( s_instance == nullptr );
|
||||
s_instance = this;
|
||||
@ -379,6 +381,7 @@ bool View::DrawImpl()
|
||||
return !wasCancelled;
|
||||
}
|
||||
|
||||
if( !m_userData.Valid() ) m_userData.Init( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() );
|
||||
if( m_saveThreadState.load( std::memory_order_relaxed ) == SaveThreadState::NeedsJoin )
|
||||
{
|
||||
m_saveThread.join();
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "TracyBuzzAnim.hpp"
|
||||
#include "TracyDecayValue.hpp"
|
||||
#include "TracyTexture.hpp"
|
||||
#include "TracyUserData.hpp"
|
||||
#include "TracyVector.hpp"
|
||||
#include "TracyWorker.hpp"
|
||||
#include "tracy_flat_hash_map.hpp"
|
||||
@ -343,6 +344,8 @@ private:
|
||||
void* m_frameTexture = nullptr;
|
||||
const void* m_frameTexturePtr = nullptr;
|
||||
|
||||
UserData m_userData;
|
||||
|
||||
struct FindZone {
|
||||
enum : uint64_t { Unselected = std::numeric_limits<uint64_t>::max() - 1 };
|
||||
enum class GroupBy : int { Thread, UserText, Callstack };
|
||||
|
Loading…
x
Reference in New Issue
Block a user