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"
{
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
@ -143,6 +139,10 @@ size_t s_krnlCacheCnt;
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;
@ -383,19 +383,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
@ -428,13 +431,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;
@ -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 )
{
for( DWORD i=0; i<inlineNum; 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;
if( SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) == 0 )
if( _SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) == 0 )
{
filename = "[unknown]";
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.
\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}

View File

@ -278,6 +278,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();