mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
More involved callstack frame description on linux.
This commit is contained in:
parent
36d81412a0
commit
c8f51d7f11
@ -5,6 +5,8 @@
|
|||||||
#if defined _WIN32 || defined __CYGWIN__
|
#if defined _WIN32 || defined __CYGWIN__
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <dbghelp.h>
|
# include <dbghelp.h>
|
||||||
|
#elif defined _GNU_SOURCE
|
||||||
|
# include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace tracy
|
namespace tracy
|
||||||
@ -71,10 +73,23 @@ CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
|||||||
CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
||||||
{
|
{
|
||||||
CallstackEntry ret;
|
CallstackEntry ret;
|
||||||
|
ret.line = 0;
|
||||||
|
|
||||||
const char* symname;
|
const char* symname = nullptr;
|
||||||
|
const char* symloc = nullptr;
|
||||||
auto vptr = (void*)ptr;
|
auto vptr = (void*)ptr;
|
||||||
auto sym = backtrace_symbols( &vptr, 1 );
|
char** sym = nullptr;
|
||||||
|
|
||||||
|
Dl_info dlinfo;
|
||||||
|
if( dladdr( vptr, &dlinfo ) )
|
||||||
|
{
|
||||||
|
symloc = dlinfo.dli_fname;
|
||||||
|
symname = dlinfo.dli_sname;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !symname )
|
||||||
|
{
|
||||||
|
sym = backtrace_symbols( &vptr, 1 );
|
||||||
if( !sym )
|
if( !sym )
|
||||||
{
|
{
|
||||||
symname = "[unknown]";
|
symname = "[unknown]";
|
||||||
@ -83,20 +98,23 @@ CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
|||||||
{
|
{
|
||||||
symname = *sym;
|
symname = *sym;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if( !symloc )
|
||||||
|
{
|
||||||
|
symloc = "[unknown]";
|
||||||
|
}
|
||||||
|
|
||||||
const auto namelen = strlen( symname );
|
const auto namelen = strlen( symname );
|
||||||
auto name = (char*)tracy_malloc( namelen + 1 );
|
auto name = (char*)tracy_malloc( namelen + 1 );
|
||||||
memcpy( name, symname, namelen );
|
memcpy( name, symname, namelen );
|
||||||
name[namelen] = '\0';
|
name[namelen] = '\0';
|
||||||
|
|
||||||
ret.name = name;
|
ret.name = name;
|
||||||
|
|
||||||
auto unknown = (char*)tracy_malloc( 10 );
|
const auto loclen = strlen( symloc );
|
||||||
memcpy( unknown, "[unknown]", 9 );
|
auto loc = (char*)tracy_malloc( loclen + 1 );
|
||||||
unknown[9] = '\0';
|
memcpy( loc, symloc, loclen );
|
||||||
|
loc[loclen] = '\0';
|
||||||
ret.file = unknown;
|
ret.file = loc;
|
||||||
ret.line = 0;
|
|
||||||
|
|
||||||
if( sym ) free( sym );
|
if( sym ) free( sym );
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ CFLAGS := $(OPTFLAGS) -Wall -DTRACY_ENABLE -rdynamic
|
|||||||
CXXFLAGS := $(CFLAGS) -std=gnu++17
|
CXXFLAGS := $(CFLAGS) -std=gnu++17
|
||||||
DEFINES +=
|
DEFINES +=
|
||||||
INCLUDES :=
|
INCLUDES :=
|
||||||
LIBS := -lpthread
|
LIBS := -lpthread -ldl
|
||||||
IMAGE := tracy_test
|
IMAGE := tracy_test
|
||||||
|
|
||||||
SRC := \
|
SRC := \
|
||||||
|
Loading…
Reference in New Issue
Block a user