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

Function SetVariableValue

src/hx/Debugger.cpp:1156–1223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1154}
1155
1156static Dynamic SetVariableValue(int threadNumber, int stackFrameNumber,
1157 String name, Dynamic value,
1158 bool unsafe, Dynamic markNonexistent,
1159 Dynamic markThreadNotStopped)
1160{
1161 if (threadNumber == g_debugThreadNumber) {
1162 return null();
1163 }
1164
1165 DebuggerContext *ctx;
1166
1167 gMutex.lock();
1168
1169 if (gMap.count(threadNumber) == 0) {
1170 gMutex.unlock();
1171 return null();
1172 }
1173 else {
1174 ctx = gMap[threadNumber];
1175 }
1176
1177 if ((ctx->mStatus == DBG_STATUS_RUNNING) && !unsafe) {
1178 gMutex.unlock();
1179 return markThreadNotStopped;
1180 }
1181
1182 // Don't need the lock any more, the thread is not running
1183 gMutex.unlock();
1184
1185 StackContext *stack = ctx->mStackContext;
1186 // Check to ensure that the stack frame is valid
1187 int size = stack->mStackFrames.size();
1188
1189 if ((stackFrameNumber < 0) || (stackFrameNumber >= size)) {
1190 return null();
1191 }
1192
1193 const char *nameToFind = name.c_str();
1194
1195 if (!strcmp(nameToFind, "this")) {
1196 return markNonexistent;
1197 }
1198
1199 StackVariable *sv = stack->mStackFrames[stackFrameNumber]->variables;
1200
1201 while (sv) {
1202 if (!strcmp(sv->mHaxeName, nameToFind)) {
1203 *sv = value;
1204 return (Dynamic) *sv;
1205 }
1206 sv = sv->mNext;
1207 }
1208
1209 #ifdef HXCPP_STACK_SCRIPTABLE
1210 StackFrame *scriptFrame = stack->mStackFrames[stackFrameNumber];
1211 if (scriptFrame)
1212 {
1213 if (__hxcpp_dbg_setScriptableValue(scriptFrame, name, value))

Callers 1

Calls 5

c_strMethod · 0.80
nullClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected