MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / dapiStackDepth

Function dapiStackDepth

src/builtin/module_builtin_debugger.cpp:843–879  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841 }
842
843 int32_t dapiStackDepth ( Context & context ) {
844 #if DAS_ENABLE_STACK_WALK
845 char * sp = context.stack.ap();
846 int32_t depth = 0;
847 while ( sp < context.stack.top() ) {
848 Prologue * pp = (Prologue *) sp;
849 Block * block = nullptr;
850 FuncInfo * info = nullptr;
851 // char * SP = sp;
852 if ( pp->info ) {
853 intptr_t iblock = intptr_t(pp->block);
854 if ( iblock & 1 ) {
855 block = (Block *) (iblock & ~1);
856 info = block->info;
857 // SP = context.stack.bottom() + block->stackOffset;
858 } else {
859 info = pp->info;
860 }
861 }
862 auto incr = info ? info->stackSize : pp->stackSize;
863 if ( incr >= context.stack.size() || incr<sizeof(Prologue) ) {
864 // corrupted stack
865 break;
866 }
867 sp += incr;
868 if ( sp > context.stack.top() ) {
869 // corrupted stack
870 break;
871 }
872 depth ++;
873 }
874 return depth;
875 #else
876 context.throw_error("stack walking disabled");
877 return 0;
878 #endif
879 }
880
881 void dapiStackWalk ( StackWalkerPtr walker, Context & context, const LineInfo & at ) {
882 #if DAS_ENABLE_STACK_WALK

Callers

nothing calls this directly

Calls 4

apMethod · 0.80
topMethod · 0.80
throw_errorMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected