Presently, commands registration taks a static handler data pointer.
This patch adds support for commands that require a dynamic pointer,
such as those registered in a dynamic context (e.g. subcommands for a
user-created 'foo.cpu' command). The command_set_handler_data will
update a command (group) to use a new context pointer, while the
CMD_DATA macro allows command handlers to access the value.
Jim handlers should find this value in interp->cmdPrivData.
+void command_set_handler_data(struct command *c, void *p)
+{
+ if (NULL != c->handler || NULL != c->jim_handler)
+ c->jim_handler_data = p;
+ for (struct command *cc = c->children; NULL != cc; cc = cc->next)
+ command_set_handler_data(cc, p);
+}
+
void command_output_text(struct command_context *context, const char *data)
{
if (context && context->output_handler && data) {
void command_output_text(struct command_context *context, const char *data)
{
if (context && context->output_handler && data) {
void *output_handler_priv;
};
void *output_handler_priv;
};
/**
* When run_command is called, a new instance will be created on the
* stack, filled with the proper values, and passed by reference to the
/**
* When run_command is called, a new instance will be created on the
* stack, filled with the proper values, and passed by reference to the
*/
struct command_invocation {
struct command_context *ctx;
*/
struct command_invocation {
struct command_context *ctx;
+ struct command *current;
const char *name;
unsigned argc;
const char **argv;
const char *name;
unsigned argc;
const char **argv;
* rather than accessing the variable directly. It may be moved.
*/
#define CMD_NAME cmd->name
* rather than accessing the variable directly. It may be moved.
*/
#define CMD_NAME cmd->name
+/**
+ * Use this macro to access the current command being handled,
+ * rather than accessing the variable directly. It may be moved.
+ */
+#define CMD_CURRENT cmd->current
+/**
+ * Use this macro to access the invoked command handler's data pointer,
+ * rather than accessing the variable directly. It may be moved.
+ */
+#define CMD_DATA CMD_CURRENT->jim_handler_data
/// The type signature for commands' handler functions.
/// The type signature for commands' handler functions.
struct command *command_find_in_parent(struct command *parent,
const char *name);
struct command *command_find_in_parent(struct command *parent,
const char *name);
+/**
+ * Update the private command data field for a command and all descendents.
+ * This is used when creating a new heirarchy of commands that depends
+ * on obtaining a dynamically created context. The value will be available
+ * in command handlers by using the CMD_DATA macro.
+ * @param c The command (group) whose data pointer(s) will be updated.
+ * @param p The new data pointer to use for the command or its descendents.
+ */
+void command_set_handler_data(struct command *c, void *p);
+
void command_set_output_handler(struct command_context* context,
command_output_handler_t output_handler, void *priv);
void command_set_output_handler(struct command_context* context,
command_output_handler_t output_handler, void *priv);
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)