-static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
-{
- /* the private data is stashed in the interp structure */
- struct command *c;
- int retval;
-
- /* DANGER!!!! be careful what we invoke here, since interp->cmdPrivData might
- * get overwritten by running other Jim commands! Treat it as an
- * emphemeral global variable that is used in lieu of an argument
- * to the fn and fish it out manually.
- */
- c = interp->cmdPrivData;
- if (c == NULL)
- {
- LOG_ERROR("BUG: interp->cmdPrivData == NULL");
- return JIM_ERR;
- }
- target_call_timer_callbacks_now();
- LOG_USER_N("%s", ""); /* Keep GDB connection alive*/
-
- script_debug(interp, c->name, argc, argv);
-
- unsigned nwords;
- const char **words = script_command_args_alloc(argc, argv, &nwords);
- if (NULL == words)
- return JIM_ERR;
-
- /* capture log output and return it */
- Jim_Obj *tclOutput = Jim_NewStringObj(interp, "", 0);
- /* a garbage collect can happen, so we need a reference count to this object */
- Jim_IncrRefCount(tclOutput);
-
- log_add_callback(tcl_output, tclOutput);
-
- struct command_context *cmd_ctx = current_command_context();
- retval = run_command(cmd_ctx, c, (const char **)words, nwords);
-
- log_remove_callback(tcl_output, tclOutput);
-
- /* We dump output into this local variable */
- Jim_SetResult(interp, tclOutput);
- Jim_DecrRefCount(interp, tclOutput);
-
- script_command_args_free(words, nwords);
-
- int *return_retval = Jim_GetAssocData(interp, "retval");
- if (return_retval != NULL)
- {
- *return_retval = retval;
- }
-
- return (retval == ERROR_OK)?JIM_OK:JIM_ERR;
-}
-
-/* nice short description of source file */
-#define __THIS__FILE__ "command.c"
-