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

Function invokeInDebugAgent2

src/builtin/module_builtin_debugger.cpp:1143–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1141 // invoke_debug_agent_function("category","function",....)
1142
1143 vec4f invokeInDebugAgent2 ( Context & context, SimNode_CallBase * call, vec4f * args ) {
1144 if ( call->nArguments>=MAX_DEBUG_AGENT_ARGS-3 ) context.throw_error_at(call->debugInfo, "too many arguments");
1145 const char * category = cast<char *>::to(args[0]);
1146 const char * function_name = cast<char *>::to(args[1]);
1147 if ( !function_name ) context.throw_error_at(call->debugInfo, "need to specify function name");
1148 g_DebugAgentMutex.lock();
1149 Context * invCtx = nullptr;
1150 DebugAgentAdapter * adapter = nullptr;
1151 if ( !category || category[0] == '\0' ) {
1152 if ( *daScriptEnvironment::g_threadLocalDebugAgent && (*daScriptEnvironment::g_threadLocalDebugAgent)->debugAgent ) {
1153 invCtx = (*daScriptEnvironment::g_threadLocalDebugAgent)->debugAgentContext.get();
1154 adapter = (DebugAgentAdapter *)(*daScriptEnvironment::g_threadLocalDebugAgent)->debugAgent.get();
1155 } else {
1156 g_DebugAgentMutex.unlock();
1157 context.throw_error_at(call->debugInfo, "no thread-local debug agent available");
1158 }
1159 } else {
1160 auto it = g_DebugAgents.find(category);
1161 if ( it == g_DebugAgents.end() ) {
1162 g_DebugAgentMutex.unlock();
1163 context.throw_error_at(call->debugInfo, "can't get debug agent '%s'", category);
1164 }
1165 invCtx = it->second.debugAgentContext.get();
1166 adapter = (DebugAgentAdapter *) it->second.debugAgent.get();
1167 }
1168 if ( !invCtx || !adapter ) {
1169 g_DebugAgentMutex.unlock();
1170 context.throw_error_at(call->debugInfo, "debug agent '%s' is a CPP-only agent", category);
1171 }
1172 Func func;
1173 func.PTR = invCtx->findFunction(function_name);
1174 if ( !func.PTR ) {
1175 g_DebugAgentMutex.unlock();
1176 context.throw_error_at(call->debugInfo, "function '%s' not found in debug agent '%s'", function_name, category);
1177 }
1178 vec4f args2[MAX_DEBUG_AGENT_ARGS];
1179 args2[0] = cast<Context *>::from(invCtx);
1180 args2[1] = cast<Func>::from(func);
1181 args2[2] = cast<void *>::from(adapter->classPtr);
1182 for ( int32_t ai=2, ais=call->nArguments; ai!=ais; ++ai ) {
1183 args2[ai + 1] = args[ai];
1184 }
1185 auto result = pinvoke_impl2_core(context, call, args2, call->nArguments - 1);
1186 g_DebugAgentMutex.unlock();
1187 return result;
1188 }
1189
1190 vec4f get_global_variable ( Context & context, SimNode_CallBase * node, vec4f * args ) {
1191 auto ctx = cast<Context *>::to(args[0]);

Callers

nothing calls this directly

Calls 7

toFunction · 0.85
pinvoke_impl2_coreFunction · 0.85
throw_error_atMethod · 0.80
getMethod · 0.45
findMethod · 0.45
endMethod · 0.45
findFunctionMethod · 0.45

Tested by

no test coverage detected