mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 12:53:51 +00:00
Add module name cache.
This commit is contained in:
parent
6532f622cb
commit
0a02cf32be
@ -56,6 +56,17 @@ BOOL IMAGEAPI SymGetLineFromInlineContext(HANDLE hProcess, DWORD64 qwAddr, ULONG
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct ModuleCache
|
||||||
|
{
|
||||||
|
uint64_t start;
|
||||||
|
uint64_t end;
|
||||||
|
char* name;
|
||||||
|
uint32_t nameLen;
|
||||||
|
ModuleCache* next;
|
||||||
|
};
|
||||||
|
|
||||||
|
static ModuleCache* s_modCache = nullptr;
|
||||||
|
|
||||||
void InitCallstack()
|
void InitCallstack()
|
||||||
{
|
{
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
@ -100,6 +111,18 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
|
|||||||
static void GetModuleName( uint64_t addr, char* buf, ULONG& len )
|
static void GetModuleName( uint64_t addr, char* buf, ULONG& len )
|
||||||
{
|
{
|
||||||
#ifndef __CYGWIN__
|
#ifndef __CYGWIN__
|
||||||
|
auto ptr = s_modCache;
|
||||||
|
while( ptr )
|
||||||
|
{
|
||||||
|
if( addr >= ptr->start && addr < ptr->end )
|
||||||
|
{
|
||||||
|
memcpy( buf, ptr->name, ptr->nameLen+1 );
|
||||||
|
len = ptr->nameLen;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ptr = ptr->next;
|
||||||
|
}
|
||||||
|
|
||||||
HMODULE mod[1024];
|
HMODULE mod[1024];
|
||||||
DWORD needed;
|
DWORD needed;
|
||||||
HANDLE proc = GetCurrentProcess();
|
HANDLE proc = GetCurrentProcess();
|
||||||
@ -128,6 +151,16 @@ static void GetModuleName( uint64_t addr, char* buf, ULONG& len )
|
|||||||
buf[namelen+1] = ']';
|
buf[namelen+1] = ']';
|
||||||
buf[namelen+2] = '\0';
|
buf[namelen+2] = '\0';
|
||||||
len = namelen+2;
|
len = namelen+2;
|
||||||
|
|
||||||
|
auto cache = (ModuleCache*)tracy_malloc( sizeof( ModuleCache ) );
|
||||||
|
cache->start = base;
|
||||||
|
cache->end = base + info.SizeOfImage;
|
||||||
|
cache->name = (char*)tracy_malloc( namelen+3 );
|
||||||
|
memcpy( cache->name, buf, namelen+3 );
|
||||||
|
cache->nameLen = namelen+2;
|
||||||
|
cache->next = s_modCache;
|
||||||
|
s_modCache = cache;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user