From 8f8a28db607b8c768137c2986179e725a7da505b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 17 Jun 2021 00:52:50 +0200 Subject: [PATCH 1/3] Allow manual setting of DPI scale. --- profiler/src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/profiler/src/main.cpp b/profiler/src/main.cpp index 04353ec7..adcaa081 100644 --- a/profiler/src/main.cpp +++ b/profiler/src/main.cpp @@ -297,6 +297,13 @@ int main( int argc, char** argv ) # endif #endif + const auto envDpiScale = getenv( "TRACY_DPI_SCALE" ); + if( envDpiScale ) + { + const auto cnv = atof( envDpiScale ); + if( cnv != 0 ) dpiScale = cnv; + } + // Setup ImGui binding IMGUI_CHECKVERSION(); ImGui::CreateContext(); From c41a5b0df0862ec582998b8dcdee94e92c2cb07b Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 17 Jun 2021 01:03:05 +0200 Subject: [PATCH 2/3] Update manual. --- manual/tracy.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manual/tracy.tex b/manual/tracy.tex index d2eaaf95..e764f398 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -739,6 +739,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. \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} \label{namingthreads} From fde62b4e6e66bf0c2e31d257531f85a49a428fd4 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Thu, 17 Jun 2021 01:34:45 +0200 Subject: [PATCH 3/3] Dynamically load some dbghelp functions. --- client/TracyCallstack.cpp | 75 +++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 28bbe763..14e332e3 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -78,21 +78,17 @@ CallstackEntry cb_data[MaxCbTrace]; extern "C" { 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 -extern "C" { -// Actual required API_VERSION_NUMBER is unknown because it is undocumented. These functions are not present in at least v11. -DWORD IMAGEAPI SymAddrIncludeInlineTrace(HANDLE hProcess, DWORD64 Address); -BOOL IMAGEAPI SymQueryInlineTrace(HANDLE hProcess, DWORD64 StartAddress, DWORD StartContext, DWORD64 StartRetAddress, - 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 + t_RtlWalkFrameChain RtlWalkFrameChain = 0; + t_SymAddrIncludeInlineTrace _SymAddrIncludeInlineTrace = 0; + t_SymQueryInlineTrace _SymQueryInlineTrace = 0; + t_SymFromInlineContext _SymFromInlineContext = 0; + t_SymGetLineFromInlineContext _SymGetLineFromInlineContext = 0; +} #ifndef __CYGWIN__ struct ModuleCache @@ -108,6 +104,10 @@ static FastVector* s_modCache; void InitCallstack() { 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 DBGHELP_INIT; @@ -292,19 +292,22 @@ CallstackSymbolData DecodeCodeAddress( uint64_t ptr ) #ifdef TRACY_DBGHELP_LOCK DBGHELP_LOCK; #endif -#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES - 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 ) +#if !defined TRACY_NO_CALLSTACK_INLINES + if( _SymAddrIncludeInlineTrace ) { - 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; - sym.line = line.LineNumber; - done = true; + if( _SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) != 0 ) + { + sym.file = line.FileName; + sym.line = line.LineNumber; + done = true; + } } } #endif @@ -335,13 +338,17 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) #ifdef TRACY_DBGHELP_LOCK DBGHELP_LOCK; #endif -#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES - DWORD inlineNum = SymAddrIncludeInlineTrace( proc, ptr ); - if( inlineNum > MaxCbTrace - 1 ) inlineNum = MaxCbTrace - 1; - DWORD ctx = 0; - DWORD idx; +#if !defined TRACY_NO_CALLSTACK_INLINES 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 ) { write = inlineNum; @@ -393,15 +400,15 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) } } -#if !defined __CYGWIN__ && !defined TRACY_NO_CALLSTACK_INLINES +#if !defined TRACY_NO_CALLSTACK_INLINES if( doInline ) { for( DWORD i=0; i