mirror of
https://github.com/wolfpld/tracy.git
synced 2026-07-01 19:48:56 +00:00
Compare commits
1 Commits
master
...
slomp/quer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75499a4944 |
@@ -10,6 +10,9 @@
|
||||
#include "../common/TracyAlloc.hpp"
|
||||
#include "../common/TracySystem.hpp"
|
||||
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
|
||||
@@ -1952,6 +1955,33 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
|
||||
#endif
|
||||
|
||||
TRACY_API const char* QuerySymbolName(void* ptr)
|
||||
{
|
||||
#ifndef TRACY_HAS_CALLSTACK
|
||||
return "[unavailable]";
|
||||
#else
|
||||
uint64_t address = uint64_t(ptr);
|
||||
|
||||
static std::unordered_map<uint64_t, std::string> s_cache;
|
||||
static std::shared_mutex s_mutex;
|
||||
|
||||
{
|
||||
std::shared_lock lock(s_mutex);
|
||||
auto it = s_cache.find(address);
|
||||
if (it != s_cache.end()) return it->second.c_str();
|
||||
}
|
||||
|
||||
std::unique_lock lock(s_mutex);
|
||||
auto [it, inserted] = s_cache.try_emplace(address);
|
||||
if (inserted)
|
||||
{
|
||||
const char* symbol = DecodeCallstackPtrFast(address);
|
||||
it->second = symbol;
|
||||
}
|
||||
return it->second.c_str();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace tracy
|
||||
{
|
||||
static constexpr bool has_callstack() { return false; }
|
||||
static tracy_force_inline void* Callstack( int32_t /*depth*/ ) { return nullptr; }
|
||||
TRACY_API const char* QuerySymbolName(void* address);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -87,6 +88,7 @@ void InitCallstack();
|
||||
void InitCallstackCritical();
|
||||
void EndCallstack();
|
||||
const char* GetKernelModulePath( uint64_t addr );
|
||||
TRACY_API const char* QuerySymbolName(void* address);
|
||||
|
||||
#ifdef __linux__
|
||||
void InitExternalImageCache( pid_t pid );
|
||||
|
||||
Reference in New Issue
Block a user