Symbol address decoding for old androids.

This commit is contained in:
Bartosz Taudul 2020-02-26 23:24:18 +01:00
parent 7c506d5426
commit 4ddafdeeaf

View File

@ -573,6 +573,51 @@ const char* DecodeCallstackPtrFast( uint64_t ptr )
return ret; return ret;
} }
SymbolData DecodeSymbolAddress( uint64_t ptr )
{
SymbolData sym;
char* demangled = nullptr;
const char* symname = nullptr;
const char* symloc = nullptr;
auto vptr = (void*)ptr;
Dl_info dlinfo;
if( dladdr( vptr, &dlinfo ) )
{
symloc = dlinfo.dli_fname;
symname = dlinfo.dli_sname;
if( symname && symname[0] == '_' )
{
size_t len = 0;
int status;
demangled = abi::__cxa_demangle( symname, nullptr, &len, &status );
if( status == 0 )
{
symname = demangled;
}
}
}
if( !symname )
{
symname = "[unknown]";
}
if( !symloc )
{
symloc = "[unknown]";
}
sym.name = CopyString( symname );
sym.file = CopyString( symloc );
sym.line = 0;
if( demangled ) free( demangled );
return sym;
}
CallstackEntryData DecodeCallstackPtr( uint64_t ptr ) CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
{ {
static CallstackEntry cb; static CallstackEntry cb;