MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / GetThreadInfo

Function GetThreadInfo

src/hx/Debugger.cpp:965–1017  ·  view source on GitHub ↗

Gets a ThreadInfo for a thread

Source from the content-addressed store, hash-verified

963
964// Gets a ThreadInfo for a thread
965static Dynamic GetThreadInfo(int threadNumber, bool unsafe)
966{
967 if (threadNumber == g_debugThreadNumber)
968 return null();
969
970 DebuggerContext *stack = 0;
971
972 gMutex.lock();
973
974 if (gMap.count(threadNumber) == 0)
975 {
976 gMutex.unlock();
977 return null();
978 }
979 else
980 stack = gMap[threadNumber];
981
982 if ((stack->mStatus == DBG_STATUS_RUNNING) && !unsafe)
983 {
984 gMutex.unlock();
985 return null();
986 }
987
988 // It's safe to release the mutex here, because the stack to be
989 // converted is either for a thread that is not running (and thus
990 // the stack cannot be altered while the conversion is in progress),
991 // or unsafe mode has been invoked
992 gMutex.unlock();
993
994
995 Dynamic ret = g_newThreadInfoFunction
996 (stack->mThreadNumber, stack->mStatus, stack->mBreakpoint,
997 stack->mCriticalError);
998
999 int size = stack->mStackContext->getDepth();
1000 for (int i = 0; i < size; i++)
1001 {
1002 StackFrame *frame = stack->mStackContext->getStackFrame(i);
1003 #ifdef HXCPP_STACK_LINE
1004 Dynamic info = g_newStackFrameFunction
1005 (String(frame->position->fileName), String(frame->lineNumber),
1006 String(frame->position->className), String(frame->position->functionName));
1007 #else
1008 Dynamic info = g_newStackFrameFunction
1009 (String(frame->position->fileName), String(frame->position->firstLineNumber),
1010 String(frame->position->className), String(frame->position->functionName));
1011 #endif
1012
1013 g_addStackFrameToThreadInfoFunction(ret, info);
1014 }
1015
1016 return ret;
1017}
1018
1019// Gets a ThreadInfo for each Thread
1020static ::Array<Dynamic> GetThreadInfos()

Callers 2

GetThreadInfosFunction · 0.85

Calls 4

getDepthMethod · 0.80
getStackFrameMethod · 0.80
nullClass · 0.50
StringClass · 0.50

Tested by

no test coverage detected