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

Method GetStackFrames

Source/Engine/Platform/Web/WebPlatform.cpp:429–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427}
428
429Array<PlatformBase::StackFrame> WebPlatform::GetStackFrames(int32 skipCount, int32 maxDepth, void* context)
430{
431 Array<StackFrame> result;
432#if CRASH_LOG_ENABLE
433 // Get callstack
434 char callstack[2000];
435 emscripten_get_callstack(EM_LOG_JS_STACK, callstack, sizeof(callstack));
436
437 // Parse callstack
438 int32 pos = 0;
439 while (callstack[pos])
440 {
441 StackFrame& frame = result.AddOne();
442 frame.ProgramCounter = 0;
443 frame.ModuleName[0] = 0;
444 frame.FileName[0] = 0;
445 frame.LineNumber = 0;
446
447 // Skip leading spaces
448 while (callstack[pos] == ' ')
449 pos++;
450
451 // Skip 'at '
452 pos += 3;
453
454 // Read function name
455 int32 dst = 0;
456 while (callstack[pos] && callstack[pos] != '\n' && dst < ARRAY_COUNT(frame.FileName) - 1)
457 frame.FunctionName[dst++] = callstack[pos++];
458 frame.FunctionName[dst] = 0;
459
460 // Skip '\n'
461 if (callstack[pos])
462 pos++;
463 }
464
465 // Adjust frames range
466 skipCount += 2; // Skip this function and utility JS frames
467 while (skipCount-- && result.HasItems())
468 result.RemoveAtKeepOrder(0);
469 if (result.Count() > maxDepth)
470 result.Resize(maxDepth);
471#endif
472 return result;
473}
474
475#if 1
476// Fix linker errors when using '-sAUTO_JS_LIBRARIES=0' due to unused WebGL functions (referenced by SDL3 port itself from emscripten: SDL_emscriptenopengles.c)

Callers

nothing calls this directly

Calls 5

AddOneMethod · 0.80
RemoveAtKeepOrderMethod · 0.80
HasItemsMethod · 0.45
CountMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected