MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetStackFrames

Method GetStackFrames

Source/Engine/Platform/Apple/ApplePlatform.cpp:612–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610}
611
612Array<ApplePlatform::StackFrame> ApplePlatform::GetStackFrames(int32 skipCount, int32 maxDepth, void* context)
613{
614 Array<StackFrame> result;
615#if CRASH_LOG_ENABLE
616 void* callstack[120];
617 skipCount = Math::Min<int32>(skipCount, ARRAY_COUNT(callstack));
618 int32 maxCount = Math::Min<int32>(ARRAY_COUNT(callstack), skipCount + maxDepth);
619 int32 count = backtrace(callstack, maxCount);
620 int32 useCount = count - skipCount;
621 if (useCount > 0)
622 {
623 char** names = backtrace_symbols(callstack + skipCount, useCount);
624 result.Resize(useCount);
625 Array<StringAnsi> parts;
626 int32 len;
627#define COPY_STR(str, dst) \
628 len = Math::Min<int32>(str.Length(), ARRAY_COUNT(frame.dst) - 1); \
629 Platform::MemoryCopy(frame.dst, str.Get(), len); \
630 frame.dst[len] = 0
631 for (int32 i = 0; i < useCount; i++)
632 {
633 const StringAnsi name(names[i]);
634 StackFrame& frame = result[i];
635 frame.ProgramCounter = callstack[skipCount + i];
636 frame.ModuleName[0] = 0;
637 frame.FileName[0] = 0;
638 frame.LineNumber = 0;
639
640 // Decode name
641 parts.Clear();
642 name.Split(' ', parts);
643 if (parts.Count() == 6)
644 {
645 COPY_STR(parts[1], ModuleName);
646 const StringAnsiView toDemangle(parts[3]);
647 int status = 0;
648 char* demangled = __cxxabiv1::__cxa_demangle(*toDemangle, 0, 0, &status);
649 const StringAnsiView toCopy = demangled && status == 0 ? StringAnsiView(demangled) : StringAnsiView(toDemangle);
650 COPY_STR(toCopy, FunctionName);
651 if (demangled)
652 free(demangled);
653 }
654 else
655 {
656 COPY_STR(name, FunctionName);
657 }
658 }
659 free(names);
660#undef COPY_STR
661 }
662#endif
663 return result;
664}
665
666#endif

Callers

nothing calls this directly

Calls 5

StringAnsiViewClass · 0.50
ResizeMethod · 0.45
ClearMethod · 0.45
SplitMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected