command: the Jim interpreter can now be provided rather than created
authorØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 1 Dec 2009 07:41:41 +0000 (08:41 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 1 Dec 2009 08:53:23 +0000 (09:53 +0100)
In embedded hosts, the Jim interpreter can come from the
existing context rather than be created by OpenOCD.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/helper/command.c
src/helper/command.h
src/openocd.c

index dcad6a198e39ff9de78f6a740263f66af2ece812..d65766842a5f23357d7108190c214d161f11e07e 100644 (file)
@@ -1272,7 +1272,7 @@ static const struct command_registration command_builtin_handlers[] = {
        COMMAND_REGISTRATION_DONE
 };
 
-struct command_context* command_init(const char *startup_tcl)
+struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp)
 {
        struct command_context* context = malloc(sizeof(struct command_context));
        const char *HostOs;
@@ -1284,14 +1284,18 @@ struct command_context* command_init(const char *startup_tcl)
        context->output_handler_priv = NULL;
 
 #if !BUILD_ECOSBOARD
-       Jim_InitEmbedded();
-       /* Create an interpreter */
-       context->interp = Jim_CreateInterp();
-       /* Add all the Jim core commands */
-       Jim_RegisterCoreCommands(context->interp);
+       /* Create a jim interpreter if we were not handed one */
+       if (interp == NULL)
+       {
+               Jim_InitEmbedded();
+               /* Create an interpreter */
+               interp = Jim_CreateInterp();
+               /* Add all the Jim core commands */
+               Jim_RegisterCoreCommands(interp);
+       }
 #endif
+       context->interp = interp;
 
-       Jim_Interp *interp = context->interp;
 #if defined(_MSC_VER)
        /* WinXX - is generic, the forward
         * looking problem is this:
index 611db8733eb806df4e185a9457dc2b268b1e3aa1..8d68c18387ca9703ad37644734da3830ae8e8c4e 100644 (file)
@@ -323,9 +323,11 @@ void command_set_output_handler(struct command_context* context,
 int command_context_mode(struct command_context *context, enum command_mode mode);
 
 /**
- * Creates a new command context using the startup TCL provided.
+ * Creates a new command context using the startup TCL provided and
+ * the existing Jim interpreter, if any. If interp == NULL, then command_init
+ * creates a command interpreter.
  */
-struct command_context* command_init(const char *startup_tcl);
+struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp);
 /**
  * Creates a copy of an existing command context.  This does not create
  * a deep copy of the command list, so modifications in one context will
index 22d45828ddc9f01cf5245c9504c2d27ebfdf2293..44e029251aa6c05eafd0a148c2631e3800989a3b 100644 (file)
@@ -188,14 +188,14 @@ static const struct command_registration openocd_command_handlers[] = {
 struct command_context *global_cmd_ctx;
 
 /* NB! this fn can be invoked outside this file for non PC hosted builds */
-struct command_context *setup_command_handler(void)
+struct command_context *setup_command_handler(Jim_Interp *interp)
 {
        log_init();
        LOG_DEBUG("log_init: complete");
 
        struct command_context *cmd_ctx;
 
-       global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl);
+       global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl, interp);
 
        register_commands(cmd_ctx, NULL, openocd_command_handlers);
        /* register subsystem commands */
@@ -242,7 +242,7 @@ int openocd_main(int argc, char *argv[])
        /* initialize commandline interface */
        struct command_context *cmd_ctx;
 
-       cmd_ctx = setup_command_handler();
+       cmd_ctx = setup_command_handler(NULL);
 
 #if BUILD_IOUTIL
        if (ioutil_init(cmd_ctx) != ERROR_OK)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)