1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Merge branch 'master' into hw

This commit is contained in:
Bartosz Taudul 2021-06-17 01:37:10 +02:00
commit 7086f2db65
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
3 changed files with 52 additions and 34 deletions

View File

@ -103,21 +103,17 @@ CallstackEntry cb_data[MaxCbTrace];
extern "C" extern "C"
{ {
typedef unsigned long (__stdcall *t_RtlWalkFrameChain)( void**, unsigned long, unsigned long ); typedef unsigned long (__stdcall *t_RtlWalkFrameChain)( void**, unsigned long, unsigned long );
t_RtlWalkFrameChain RtlWalkFrameChain = 0; typedef DWORD (__stdcall *t_SymAddrIncludeInlineTrace)( HANDLE hProcess, DWORD64 Address );
} typedef BOOL (__stdcall *t_SymQueryInlineTrace)( HANDLE hProcess, DWORD64 StartAddress, DWORD StartContext, DWORD64 StartRetAddress, DWORD64 CurAddress, LPDWORD CurContext, LPDWORD CurFrameIndex );
typedef BOOL (__stdcall *t_SymFromInlineContext)( HANDLE hProcess, DWORD64 Address, ULONG InlineContext, PDWORD64 Displacement, PSYMBOL_INFO Symbol );
typedef BOOL (__stdcall *t_SymGetLineFromInlineContext)( HANDLE hProcess, DWORD64 qwAddr, ULONG InlineContext, DWORD64 qwModuleBaseAddress, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64 );
#if defined __MINGW32__ && API_VERSION_NUMBER < 12 t_RtlWalkFrameChain RtlWalkFrameChain = 0;
extern "C" { t_SymAddrIncludeInlineTrace _SymAddrIncludeInlineTrace = 0;
// Actual required API_VERSION_NUMBER is unknown because it is undocumented. These functions are not present in at least v11. t_SymQueryInlineTrace _SymQueryInlineTrace = 0;
DWORD IMAGEAPI SymAddrIncludeInlineTrace(HANDLE hProcess, DWORD64 Address); t_SymFromInlineContext _SymFromInlineContext = 0;
BOOL IMAGEAPI SymQueryInlineTrace(HANDLE hProcess, DWORD64 StartAddress, DWORD StartContext, DWORD64 StartRetAddress, t_SymGetLineFromInlineContext _SymGetLineFromInlineContext = 0;
DWORD64 CurAddress, LPDWORD CurContext, LPDWORD CurFrameIndex); }
BOOL IMAGEAPI SymFromInlineContext(HANDLE hProcess, DWORD64 Address, ULONG InlineContext, PDWORD64 Displacement,
PSYMBOL_INFO Symbol);
BOOL IMAGEAPI SymGetLineFromInlineContext(HANDLE hProcess, DWORD64 qwAddr, ULONG InlineContext,
DWORD64 qwModuleBaseAddress, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64);
};
#endif
#ifndef __CYGWIN__ #ifndef __CYGWIN__
struct ModuleCache struct ModuleCache
@ -143,6 +139,10 @@ size_t s_krnlCacheCnt;
void InitCallstack() void InitCallstack()
{ {
RtlWalkFrameChain = (t_RtlWalkFrameChain)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlWalkFrameChain" ); RtlWalkFrameChain = (t_RtlWalkFrameChain)GetProcAddress( GetModuleHandleA( "ntdll.dll" ), "RtlWalkFrameChain" );
_SymAddrIncludeInlineTrace = (t_SymAddrIncludeInlineTrace)GetProcAddress( GetModuleHandleA( "dbghelp.dll" ), "SymAddrIncludeInlineTrace" );
_SymQueryInlineTrace = (t_SymQueryInlineTrace)GetProcAddress( GetModuleHandleA( "dbghelp.dll" ), "SymQueryInlineTrace" );
_SymFromInlineContext = (t_SymFromInlineContext)GetProcAddress( GetModuleHandleA( "dbghelp.dll" ), "SymFromInlineContext" );
_SymGetLineFromInlineContext = (t_SymGetLineFromInlineContext)GetProcAddress( GetModuleHandleA( "dbghelp.dll" ), "SymGetLineFromInlineContext" );
#ifdef TRACY_DBGHELP_LOCK #ifdef TRACY_DBGHELP_LOCK
DBGHELP_INIT; DBGHELP_INIT;
@ -383,19 +383,22 @@ CallstackSymbolData DecodeCodeAddress( uint64_t ptr )
#ifdef TRACY_DBGHELP_LOCK #ifdef TRACY_DBGHELP_LOCK
DBGHELP_LOCK; DBGHELP_LOCK;
#endif #endif
#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES #if !defined TRACY_NO_CALLSTACK_INLINES
DWORD inlineNum = SymAddrIncludeInlineTrace( proc, ptr ); if( _SymAddrIncludeInlineTrace )
DWORD ctx = 0;
DWORD idx;
BOOL doInline = FALSE;
if( inlineNum != 0 ) doInline = SymQueryInlineTrace( proc, ptr, 0, ptr, ptr, &ctx, &idx );
if( doInline )
{ {
if( SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) != 0 ) DWORD inlineNum = _SymAddrIncludeInlineTrace( proc, ptr );
DWORD ctx = 0;
DWORD idx;
BOOL doInline = FALSE;
if( inlineNum != 0 ) doInline = _SymQueryInlineTrace( proc, ptr, 0, ptr, ptr, &ctx, &idx );
if( doInline )
{ {
sym.file = line.FileName; if( _SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) != 0 )
sym.line = line.LineNumber; {
done = true; sym.file = line.FileName;
sym.line = line.LineNumber;
done = true;
}
} }
} }
#endif #endif
@ -428,13 +431,17 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
#ifdef TRACY_DBGHELP_LOCK #ifdef TRACY_DBGHELP_LOCK
DBGHELP_LOCK; DBGHELP_LOCK;
#endif #endif
#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES #if !defined TRACY_NO_CALLSTACK_INLINES
DWORD inlineNum = SymAddrIncludeInlineTrace( proc, ptr );
if( inlineNum > MaxCbTrace - 1 ) inlineNum = MaxCbTrace - 1;
DWORD ctx = 0;
DWORD idx;
BOOL doInline = FALSE; BOOL doInline = FALSE;
if( inlineNum != 0 ) doInline = SymQueryInlineTrace( proc, ptr, 0, ptr, ptr, &ctx, &idx ); DWORD ctx = 0;
DWORD inlineNum;
if( _SymAddrIncludeInlineTrace )
{
inlineNum = _SymAddrIncludeInlineTrace( proc, ptr );
if( inlineNum > MaxCbTrace - 1 ) inlineNum = MaxCbTrace - 1;
DWORD idx;
if( inlineNum != 0 ) doInline = _SymQueryInlineTrace( proc, ptr, 0, ptr, ptr, &ctx, &idx );
}
if( doInline ) if( doInline )
{ {
write = inlineNum; write = inlineNum;
@ -486,15 +493,15 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
} }
} }
#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES #if !defined TRACY_NO_CALLSTACK_INLINES
if( doInline ) if( doInline )
{ {
for( DWORD i=0; i<inlineNum; i++ ) for( DWORD i=0; i<inlineNum; i++ )
{ {
auto& cb = cb_data[i]; auto& cb = cb_data[i];
const auto symInlineValid = SymFromInlineContext( proc, ptr, ctx, nullptr, si ) != 0; const auto symInlineValid = _SymFromInlineContext( proc, ptr, ctx, nullptr, si ) != 0;
const char* filename; const char* filename;
if( SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) == 0 ) if( _SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) == 0 )
{ {
filename = "[unknown]"; filename = "[unknown]";
cb.line = 0; cb.line = 0;

View File

@ -742,6 +742,10 @@ The following defines may be of interest:
\item \texttt{TRACY\_NO\_ROOT\_WINDOW} -- the main profiler view won't occupy whole window if this macro is defined. Additional setup is required for this to work. If you are embedding the server into your application you probably want to enable this option. \item \texttt{TRACY\_NO\_ROOT\_WINDOW} -- the main profiler view won't occupy whole window if this macro is defined. Additional setup is required for this to work. If you are embedding the server into your application you probably want to enable this option.
\end{itemize} \end{itemize}
\subsubsection{DPI scaling}
The graphic server application will adapt to the system DPI scaling. If for some reason this doesn't work in your case, you may try setting the \texttt{TRACY\_DPI\_SCALE} environment variable to a scale fraction, where a value of 1 indicates no scaling.
\subsection{Naming threads} \subsection{Naming threads}
\label{namingthreads} \label{namingthreads}

View File

@ -278,6 +278,13 @@ int main( int argc, char** argv )
# endif # endif
#endif #endif
const auto envDpiScale = getenv( "TRACY_DPI_SCALE" );
if( envDpiScale )
{
const auto cnv = atof( envDpiScale );
if( cnv != 0 ) dpiScale = cnv;
}
// Setup ImGui binding // Setup ImGui binding
IMGUI_CHECKVERSION(); IMGUI_CHECKVERSION();
ImGui::CreateContext(); ImGui::CreateContext();