Add EnsureReadable() implementation for Windows.

This commit is contained in:
Bartosz Taudul 2024-07-08 18:42:17 +02:00
parent 6d1deb5640
commit c383e7ae25
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -271,8 +271,19 @@ static bool EnsureReadable( uintptr_t address )
MappingInfo* mapping = LookUpMapping(address); MappingInfo* mapping = LookUpMapping(address);
return mapping && EnsureReadable( *mapping ); return mapping && EnsureReadable( *mapping );
} }
#elif defined WIN32
#endif // defined __ANDROID__ static bool EnsureReadable( uintptr_t address )
{
MEMORY_BASIC_INFORMATION memInfo;
VirtualQuery( reinterpret_cast<void*>( address ), &memInfo, sizeof( memInfo ) );
return memInfo.Protect != PAGE_NOACCESS;
}
#else
static bool EnsureReadable( uintptr_t address )
{
return true;
}
#endif
#ifndef TRACY_DELAYED_INIT #ifndef TRACY_DELAYED_INIT
@ -3913,15 +3924,12 @@ void Profiler::HandleSymbolCodeQuery( uint64_t symbol, uint32_t size )
} }
else else
{ {
#ifdef __ANDROID__
// On Android it's common for code to be in mappings that are only executable
// but not readable.
if( !EnsureReadable( symbol ) ) if( !EnsureReadable( symbol ) )
{ {
AckSymbolCodeNotAvailable(); AckSymbolCodeNotAvailable();
return; return;
} }
#endif
SendLongString( symbol, (const char*)symbol, size, QueueType::SymbolCode ); SendLongString( symbol, (const char*)symbol, size, QueueType::SymbolCode );
} }
} }