update tracy from 11.0 to 13.1 and fix build with tracy enabled
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF)
|
||||
option(NO_STATISTICS "Disable calculation of statistics" ON)
|
||||
option(NO_PARALLEL_STL "Disable parallel STL" OFF)
|
||||
|
||||
set(NO_STATISTICS ON)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake)
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unordered_map>
|
||||
#include <zstd.h>
|
||||
|
||||
#include "../../server/TracyWorker.hpp"
|
||||
#include "../../zstd/zstd.h"
|
||||
|
||||
#include "OfflineSymbolResolver.h"
|
||||
|
||||
@@ -15,7 +15,7 @@ bool ApplyPathSubstitutions( std::string& path, const PathSubstitutionList& path
|
||||
{
|
||||
for( const auto& substitution : pathSubstitutionlist )
|
||||
{
|
||||
if( std::regex_match(path, substitution.first) )
|
||||
if( std::regex_search(path, substitution.first) )
|
||||
{
|
||||
path = std::regex_replace( path, substitution.first, substitution.second );
|
||||
return true;
|
||||
@@ -45,13 +45,9 @@ bool PatchSymbolsWithRegex( tracy::Worker& worker, const PathSubstitutionList& p
|
||||
auto& callstackFrameMap = worker.GetCallstackFrameMap();
|
||||
for( auto it = callstackFrameMap.begin(); it != callstackFrameMap.end(); ++it )
|
||||
{
|
||||
tracy::CallstackFrameData* frameDataPtr = it->second;
|
||||
if( !frameDataPtr )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if( !it->second ) continue;
|
||||
|
||||
tracy::CallstackFrameData& frameData = *frameDataPtr;
|
||||
tracy::CallstackFrameData& frameData = *it->second;
|
||||
const char* imageName = worker.GetString( frameData.imageName );
|
||||
|
||||
const uint32_t imageNameIdx = frameData.imageName.Idx();
|
||||
@@ -168,4 +164,4 @@ void PatchSymbols( tracy::Worker& worker, const std::vector<std::string>& pathSu
|
||||
{
|
||||
std::cerr << "Failed to patch symbols" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,57 +44,102 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void escapeShellParam(std::string const& s, std::string& out)
|
||||
{
|
||||
out.reserve( s.size() + 2 );
|
||||
out.push_back( '"' );
|
||||
for( unsigned char c : s )
|
||||
{
|
||||
if( ' ' <= c and c <= '~' and c != '\\' and c != '"' )
|
||||
{
|
||||
out.push_back( c );
|
||||
}
|
||||
else
|
||||
{
|
||||
out.push_back( '\\' );
|
||||
switch( c )
|
||||
{
|
||||
case '"': out.push_back( '"' ); break;
|
||||
case '\\': out.push_back( '\\' ); break;
|
||||
case '\t': out.push_back( 't' ); break;
|
||||
case '\r': out.push_back( 'r' ); break;
|
||||
case '\n': out.push_back( 'n' ); break;
|
||||
default:
|
||||
char const* const hexdig = "0123456789ABCDEF";
|
||||
out.push_back( 'x' );
|
||||
out.push_back( hexdig[c >> 4] );
|
||||
out.push_back( hexdig[c & 0xF] );
|
||||
}
|
||||
}
|
||||
}
|
||||
out.push_back( '"' );
|
||||
}
|
||||
|
||||
bool ResolveSymbols( const std::string& imagePath, const FrameEntryList& inputEntryList,
|
||||
SymbolEntryList& resolvedEntries )
|
||||
{
|
||||
if (!m_addr2LinePath.length()) return false;
|
||||
if( !m_addr2LinePath.length() ) return false;
|
||||
|
||||
std:: string escapedPath;
|
||||
escapeShellParam( imagePath, escapedPath );
|
||||
|
||||
// generate a single addr2line cmd line for all addresses in one invocation
|
||||
std::stringstream ss;
|
||||
ss << m_addr2LinePath << " -C -f -e " << imagePath << " -a ";
|
||||
for ( const FrameEntry& entry : inputEntryList )
|
||||
size_t entryIdx = 0;
|
||||
while( entryIdx < inputEntryList.size() )
|
||||
{
|
||||
ss << " 0x" << std::hex << entry.symbolOffset;
|
||||
}
|
||||
const size_t startIdx = entryIdx;
|
||||
const size_t batchEndIdx = std::min( inputEntryList.size(), startIdx + (size_t)1024 );
|
||||
|
||||
std::string resultStr = ExecShellCommand( ss.str().c_str() );
|
||||
std::stringstream result(resultStr);
|
||||
//printf("executing: '%s' got '%s'\n", ss.str().c_str(), result.str().c_str());
|
||||
printf( "Resolving symbols [%zu-%zu]\n", startIdx, batchEndIdx );
|
||||
|
||||
// The output is 2 lines per entry with the following contents:
|
||||
// hex_address_of_symbol
|
||||
// symbol_name
|
||||
// file:line
|
||||
|
||||
for( size_t i = 0; i < inputEntryList.size(); ++i )
|
||||
{
|
||||
const FrameEntry& inputEntry = inputEntryList[i];
|
||||
|
||||
SymbolEntry newEntry;
|
||||
|
||||
std::string addr;
|
||||
std::getline( result, addr );
|
||||
std::getline( result, newEntry.name );
|
||||
if (newEntry.name == "??")
|
||||
// generate a single addr2line cmd line for all addresses in one invocation
|
||||
std::stringstream ss;
|
||||
ss << m_addr2LinePath << " -C -f -e " << escapedPath << " -a ";
|
||||
for( ; entryIdx < batchEndIdx; entryIdx++ )
|
||||
{
|
||||
newEntry.name = "[unknown] + " + std::to_string(inputEntry.symbolOffset);
|
||||
const FrameEntry& entry = inputEntryList[entryIdx];
|
||||
ss << " 0x" << std::hex << entry.symbolOffset;
|
||||
}
|
||||
|
||||
std::string fileLine;
|
||||
std::getline(result, fileLine);
|
||||
if ( fileLine != "??:?" )
|
||||
std::string resultStr = ExecShellCommand( ss.str().c_str() );
|
||||
std::stringstream result( resultStr );
|
||||
|
||||
//printf("executing: '%s' got '%s'\n", ss.str().c_str(), result.str().c_str());
|
||||
|
||||
// The output is 2 lines per entry with the following contents:
|
||||
// hex_address_of_symbol
|
||||
// symbol_name
|
||||
// file:line
|
||||
|
||||
for( size_t i = startIdx ;i < batchEndIdx; i++ )
|
||||
{
|
||||
size_t pos = fileLine.find_last_of(':');
|
||||
if ( pos != std::string::npos )
|
||||
const FrameEntry& inputEntry = inputEntryList[i];
|
||||
|
||||
SymbolEntry newEntry;
|
||||
|
||||
std::string addr;
|
||||
std::getline( result, addr );
|
||||
std::getline( result, newEntry.name );
|
||||
if( newEntry.name == "??" )
|
||||
{
|
||||
newEntry.file = fileLine.substr( 0, pos );
|
||||
std::string lineStr = fileLine.substr( pos + 1 );
|
||||
char* after = nullptr;
|
||||
newEntry.line = strtol( lineStr.c_str(), &after, 10 );
|
||||
newEntry.name = "[unknown] + " + std::to_string( inputEntry.symbolOffset );
|
||||
}
|
||||
}
|
||||
|
||||
resolvedEntries.push_back( std::move(newEntry) );
|
||||
std::string fileLine;
|
||||
std::getline( result, fileLine );
|
||||
if( fileLine != "??:?" )
|
||||
{
|
||||
size_t pos = fileLine.find_last_of( ':' );
|
||||
if( pos != std::string::npos )
|
||||
{
|
||||
newEntry.file = fileLine.substr( 0, pos );
|
||||
std::string lineStr = fileLine.substr( pos + 1 );
|
||||
char* after = nullptr;
|
||||
newEntry.line = strtol( lineStr.c_str(), &after, 10 );
|
||||
}
|
||||
}
|
||||
|
||||
resolvedEntries.push_back( std::move( newEntry ) );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <zstd.h>
|
||||
|
||||
#include "../../public/common/TracyVersion.hpp"
|
||||
#include "../../server/TracyFileRead.hpp"
|
||||
#include "../../server/TracyFileWrite.hpp"
|
||||
#include "../../server/TracyPrint.hpp"
|
||||
#include "../../server/TracyWorker.hpp"
|
||||
#include "../../zstd/zstd.h"
|
||||
#include "../../getopt/getopt.h"
|
||||
|
||||
#include "OfflineSymbolResolver.h"
|
||||
|
||||
Reference in New Issue
Block a user