| 758 | } |
| 759 | |
| 760 | String PlatformBase::GetStackTrace(int32 skipCount, int32 maxDepth, void* context) |
| 761 | { |
| 762 | StringBuilder result; |
| 763 | Array<StackFrame> stackFrames = Platform::GetStackFrames(skipCount, maxDepth, context); |
| 764 | for (const auto& frame : stackFrames) |
| 765 | { |
| 766 | StringAsUTF16<ARRAY_COUNT(StackFrame::FunctionName)> functionName(frame.FunctionName); |
| 767 | const StringView functionNameStr(functionName.Get()); |
| 768 | if (StringUtils::Length(frame.FileName) != 0) |
| 769 | { |
| 770 | StringAsUTF16<ARRAY_COUNT(StackFrame::FileName)> fileName(frame.FileName); |
| 771 | result.Append(TEXT(" at ")).Append(functionNameStr); |
| 772 | if (!functionNameStr.EndsWith(')')) |
| 773 | result.Append(TEXT("()")); |
| 774 | result.AppendFormat(TEXT("in {0}:line {1}\n"),fileName.Get(), frame.LineNumber); |
| 775 | } |
| 776 | else if (StringUtils::Length(frame.FunctionName) != 0) |
| 777 | { |
| 778 | result.Append(TEXT(" at ")).Append(functionNameStr); |
| 779 | if (!functionNameStr.EndsWith(')')) |
| 780 | result.Append(TEXT("()")); |
| 781 | result.Append('\n'); |
| 782 | } |
| 783 | else |
| 784 | { |
| 785 | result.AppendFormat(TEXT(" at 0x{0:x}\n"), (uint64)frame.ProgramCounter); |
| 786 | } |
| 787 | } |
| 788 | return result.ToString(); |
| 789 | } |
| 790 | |
| 791 | void PlatformBase::CollectCrashData(const String& crashDataFolder, void* context) |
| 792 | { |