2424# pragma warning( disable : 4091 )
2525# endif
2626# include < dbghelp.h>
27+ # pragma comment( lib, "dbghelp.lib" )
2728# ifdef _MSC_VER
2829# pragma warning( pop )
2930# endif
30- #elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
31+ #elif defined(TRACY_USE_LIBBACKTRACE)
32+
3133# include " ../libbacktrace/backtrace.hpp"
3234# include < algorithm>
3335# include < dlfcn.h>
3436# include < cxxabi.h>
3537# include < stdlib.h>
38+
39+ // Implementation files
40+ # include " ../libbacktrace/alloc.cpp"
41+ # include " ../libbacktrace/dwarf.cpp"
42+ # include " ../libbacktrace/fileline.cpp"
43+ # include " ../libbacktrace/mmapio.cpp"
44+ # include " ../libbacktrace/posix.cpp"
45+ # include " ../libbacktrace/sort.cpp"
46+ # include " ../libbacktrace/state.cpp"
47+ # if TRACY_HAS_CALLSTACK == 4
48+ # include " ../libbacktrace/macho.cpp"
49+ # else
50+ # include " ../libbacktrace/elf.cpp"
51+ # endif
52+ # include " ../common/TracyStackFrames.cpp"
53+
3654#elif TRACY_HAS_CALLSTACK == 5
3755# include < dlfcn.h>
3856# include < cxxabi.h>
@@ -53,7 +71,7 @@ extern "C"
5371};
5472#endif
5573
56- #if TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 5 || TRACY_HAS_CALLSTACK == 6
74+ #if defined(TRACY_USE_LIBBACKTRACE) || TRACY_HAS_CALLSTACK == 5
5775// If you want to use your own demangling functionality (e.g. for another language),
5876// define TRACY_DEMANGLE and provide your own implementation of the __tracy_demangle
5977// function. The input parameter is a function name. The demangle function must
@@ -91,7 +109,7 @@ extern "C" const char* ___tracy_demangle( const char* mangled )
91109#endif
92110#endif
93111
94- #if TRACY_HAS_CALLSTACK == 3
112+ #if defined(TRACY_USE_LIBBACKTRACE) && TRACY_HAS_CALLSTACK != 4 // dl_iterate_phdr is required for the current image cache. Need to move it to libbacktrace?
95113# define TRACY_USE_IMAGE_CACHE
96114# include < link.h>
97115#endif
@@ -758,7 +776,7 @@ CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
758776 return { cb_data, uint8_t ( cb_num ), moduleNameAndAddress.name };
759777}
760778
761- #elif TRACY_HAS_CALLSTACK == 2 || TRACY_HAS_CALLSTACK == 3 || TRACY_HAS_CALLSTACK == 4 || TRACY_HAS_CALLSTACK == 6
779+ #elif defined(TRACY_USE_LIBBACKTRACE)
762780
763781enum { MaxCbTrace = 64 };
764782
0 commit comments