mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Symbol address decoding (win32 implementation).
This commit is contained in:
parent
03ff08a934
commit
ef05570540
@ -231,6 +231,39 @@ static void GetModuleName( uint64_t addr, char* buf, ULONG& len )
|
||||
len = 9;
|
||||
}
|
||||
|
||||
SymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||
{
|
||||
SymbolData sym;
|
||||
const auto proc = GetCurrentProcess();
|
||||
|
||||
char buf[sizeof( SYMBOL_INFO ) + MaxNameSize];
|
||||
auto si = (SYMBOL_INFO*)buf;
|
||||
si->SizeOfStruct = sizeof( SYMBOL_INFO );
|
||||
si->MaxNameLen = MaxNameSize;
|
||||
const auto symValid = SymFromAddr( proc, ptr, nullptr, si ) != 0;
|
||||
|
||||
IMAGEHLP_LINE64 line;
|
||||
DWORD displacement = 0;
|
||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
|
||||
const char* filename;
|
||||
if (SymGetLineFromAddr64(proc, ptr, &displacement, &line) == 0)
|
||||
{
|
||||
filename = "[unknown]";
|
||||
sym.line = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
filename = line.FileName;
|
||||
sym.line = line.LineNumber;
|
||||
}
|
||||
|
||||
sym.name = symValid ? CopyString( si->Name, si->NameLen ) : CopyString( "[unknown]", 9 );
|
||||
sym.file = CopyString( filename );
|
||||
|
||||
return sym;
|
||||
}
|
||||
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
{
|
||||
int write;
|
||||
|
@ -22,11 +22,15 @@
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
struct CallstackEntry
|
||||
struct SymbolData
|
||||
{
|
||||
const char* name;
|
||||
const char* file;
|
||||
uint32_t line;
|
||||
};
|
||||
|
||||
struct CallstackEntry : public SymbolData
|
||||
{
|
||||
uint64_t symAddr;
|
||||
};
|
||||
|
||||
@ -37,6 +41,7 @@ struct CallstackEntryData
|
||||
const char* imageName;
|
||||
};
|
||||
|
||||
SymbolData DecodeSymbolAddress( uint64_t ptr );
|
||||
const char* DecodeCallstackPtrFast( uint64_t ptr );
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr );
|
||||
void InitCallstack();
|
||||
|
Loading…
Reference in New Issue
Block a user