MCPcopy Create free account
hub / github.com/Warzone2100/warzone2100 / _debugBacktrace

Function _debugBacktrace

lib/framework/debug.cpp:761–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761void _debugBacktrace(code_part part)
762{
763#if defined(WZ_OS_LINUX) && defined(__GLIBC__)
764 void *btv[20];
765 unsigned num = backtrace(btv, sizeof(btv) / sizeof(*btv));
766 char **btc = backtrace_symbols(btv, num);
767 unsigned i;
768 auto trim = [](const char *in, char *out) {
769 const char *begin = strchr(in, '_');
770 if (begin)
771 {
772 const char *end = strchr(begin, '+');
773 if (end)
774 {
775 memcpy(out, begin, end - begin);
776 out[end - begin] = '\0';
777 }
778 }
779 };
780 for (i = 1; i + 2 < num; ++i)
781 {
782 int status = -1;
783 char buf[1024];
784 const char *p = btc[i];
785 trim(p, buf);
786 char *readableName = abi::__cxa_demangle(buf, NULL, NULL, &status);
787 if (status == 0)
788 {
789 _debug(0, part, "BT", "%s", readableName);
790 }
791 else
792 {
793 _debug(0, part, "BT", "%s [status: %i]", btc[i], status);
794 }
795 }
796 free(btc);
797#else
798 // debugBacktrace not implemented.
799#endif
800}
801
802bool debugPartEnabled(code_part codePart)
803{

Callers

nothing calls this directly

Calls 1

_debugFunction · 0.85

Tested by

no test coverage detected