| 1091 | } |
| 1092 | |
| 1093 | static Dynamic GetVariableValue(int threadNumber, int stackFrameNumber, |
| 1094 | String name, bool unsafe, |
| 1095 | Dynamic markNonexistent, |
| 1096 | Dynamic markThreadNotStopped) |
| 1097 | { |
| 1098 | if (threadNumber == g_debugThreadNumber) { |
| 1099 | return markNonexistent; |
| 1100 | } |
| 1101 | |
| 1102 | DebuggerContext *ctx; |
| 1103 | |
| 1104 | gMutex.lock(); |
| 1105 | |
| 1106 | if (gMap.count(threadNumber) == 0) { |
| 1107 | gMutex.unlock(); |
| 1108 | return markNonexistent; |
| 1109 | } |
| 1110 | else { |
| 1111 | ctx = gMap[threadNumber]; |
| 1112 | } |
| 1113 | |
| 1114 | if ((ctx->mStatus == DBG_STATUS_RUNNING) && !unsafe) { |
| 1115 | gMutex.unlock(); |
| 1116 | return markThreadNotStopped; |
| 1117 | } |
| 1118 | |
| 1119 | // Don't need the lock any more, the thread is not running |
| 1120 | gMutex.unlock(); |
| 1121 | |
| 1122 | StackContext *stack = ctx->mStackContext; |
| 1123 | |
| 1124 | // Check to ensure that the stack frame is valid |
| 1125 | int size = stack->mStackFrames.size(); |
| 1126 | |
| 1127 | if ((stackFrameNumber < 0) || (stackFrameNumber >= size)) { |
| 1128 | return markNonexistent; |
| 1129 | } |
| 1130 | |
| 1131 | const char *nameToFind = name.c_str(); |
| 1132 | |
| 1133 | StackVariable *sv = stack->mStackFrames[stackFrameNumber]->variables; |
| 1134 | |
| 1135 | while (sv) { |
| 1136 | if (!strcmp(sv->mHaxeName, nameToFind)) { |
| 1137 | return (Dynamic) *sv; |
| 1138 | } |
| 1139 | sv = sv->mNext; |
| 1140 | } |
| 1141 | |
| 1142 | #ifdef HXCPP_STACK_SCRIPTABLE |
| 1143 | StackFrame *scriptFrame = stack->mStackFrames[stackFrameNumber]; |
| 1144 | if (scriptFrame) |
| 1145 | { |
| 1146 | Dynamic result; |
| 1147 | if (__hxcpp_dbg_getScriptableValue(scriptFrame, name, result)) |
| 1148 | return result; |
| 1149 | } |
| 1150 | #endif |
no test coverage detected