Improve ETM tracemode update command.
authorZachary T Welch <zw@superlucidity.net>
Thu, 22 Oct 2009 15:11:55 +0000 (08:11 -0700)
committerZachary T Welch <zw@superlucidity.net>
Fri, 6 Nov 2009 02:03:20 +0000 (18:03 -0800)
src/target/etm.c

index 0f5a96f6103dff6bca63a242645aa65c1e701669..8229bb07d0b154943149655201d3c70764c38703 100644 (file)
@@ -1155,112 +1155,108 @@ static int etmv1_analyze_trace(etm_context_t *ctx, struct command_context_s *cmd
        return ERROR_OK;
 }
 
-static int handle_etm_tracemode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+static int handle_etm_tracemode_command_update(
+               struct command_context_s *cmd_ctx,
+               char **args, etmv1_tracemode_t *mode)
 {
-       target_t *target;
-       armv4_5_common_t *armv4_5;
-       arm7_9_common_t *arm7_9;
        etmv1_tracemode_t tracemode;
 
-       target = get_current_target(cmd_ctx);
-
-       if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK)
+       /* what parts of data access are traced? */
+       if (strcmp(args[0], "none") == 0)
+               tracemode = ETMV1_TRACE_NONE;
+       else if (strcmp(args[0], "data") == 0)
+               tracemode = ETMV1_TRACE_DATA;
+       else if (strcmp(args[0], "address") == 0)
+               tracemode = ETMV1_TRACE_ADDR;
+       else if (strcmp(args[0], "all") == 0)
+               tracemode = ETMV1_TRACE_DATA | ETMV1_TRACE_ADDR;
+       else
        {
-               command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target");
+               command_print(cmd_ctx, "invalid option '%s'", args[0]);
                return ERROR_OK;
        }
 
-       if (!arm7_9->etm_ctx)
-       {
-               command_print(cmd_ctx, "current target doesn't have an ETM configured");
+       uint8_t context_id;
+       COMMAND_PARSE_NUMBER(u8, args[1], context_id);
+       switch (context_id)
+       {
+       case 0:
+               tracemode |= ETMV1_CONTEXTID_NONE;
+               break;
+       case 8:
+               tracemode |= ETMV1_CONTEXTID_8;
+               break;
+       case 16:
+               tracemode |= ETMV1_CONTEXTID_16;
+               break;
+       case 32:
+               tracemode |= ETMV1_CONTEXTID_32;
+               break;
+       default:
+               command_print(cmd_ctx, "invalid option '%s'", args[1]);
                return ERROR_OK;
        }
 
-       tracemode = arm7_9->etm_ctx->tracemode;
+       if (strcmp(args[2], "enable") == 0)
+               tracemode |= ETMV1_CYCLE_ACCURATE;
+       else if (strcmp(args[2], "disable") == 0)
+               tracemode |= 0;
+       else
+       {
+               command_print(cmd_ctx, "invalid option '%s'", args[2]);
+               return ERROR_OK;
+       }
 
-       if (argc == 4)
+       if (strcmp(args[3], "enable") == 0)
+               tracemode |= ETMV1_BRANCH_OUTPUT;
+       else if (strcmp(args[3], "disable") == 0)
+               tracemode |= 0;
+       else
        {
-               /* what parts of data access are traced? */
-               if (strcmp(args[0], "none") == 0)
-               {
-                       tracemode = ETMV1_TRACE_NONE;
-               }
-               else if (strcmp(args[0], "data") == 0)
-               {
-                       tracemode = ETMV1_TRACE_DATA;
-               }
-               else if (strcmp(args[0], "address") == 0)
-               {
-                       tracemode = ETMV1_TRACE_ADDR;
-               }
-               else if (strcmp(args[0], "all") == 0)
-               {
-                       tracemode = ETMV1_TRACE_DATA | ETMV1_TRACE_ADDR;
-               }
-               else
-               {
-                       command_print(cmd_ctx, "invalid option '%s'", args[0]);
-                       return ERROR_OK;
-               }
+               command_print(cmd_ctx, "invalid option '%s'", args[3]);
+               return ERROR_OK;
+       }
 
-               uint8_t context_id;
-               COMMAND_PARSE_NUMBER(u8, args[1], context_id);
-               switch (context_id)
-               {
-                       case 0:
-                               tracemode |= ETMV1_CONTEXTID_NONE;
-                               break;
-                       case 8:
-                               tracemode |= ETMV1_CONTEXTID_8;
-                               break;
-                       case 16:
-                               tracemode |= ETMV1_CONTEXTID_16;
-                               break;
-                       case 32:
-                               tracemode |= ETMV1_CONTEXTID_32;
-                               break;
-                       default:
-                               command_print(cmd_ctx, "invalid option '%s'", args[1]);
-                               return ERROR_OK;
-               }
+       /* IGNORED:
+        *  - CPRT tracing (coprocessor register transfers)
+        *  - debug request (causes debug entry on trigger)
+        *  - stall on FIFOFULL (preventing tracedata lossage)
+        */
+       *mode = tracemode;
 
-               if (strcmp(args[2], "enable") == 0)
-               {
-                       tracemode |= ETMV1_CYCLE_ACCURATE;
-               }
-               else if (strcmp(args[2], "disable") == 0)
-               {
-                       tracemode |= 0;
-               }
-               else
-               {
-                       command_print(cmd_ctx, "invalid option '%s'", args[2]);
-                       return ERROR_OK;
-               }
+       return ERROR_OK;
+}
 
-               if (strcmp(args[3], "enable") == 0)
-               {
-                       tracemode |= ETMV1_BRANCH_OUTPUT;
-               }
-               else if (strcmp(args[3], "disable") == 0)
-               {
-                       tracemode |= 0;
-               }
-               else
-               {
-                       command_print(cmd_ctx, "invalid option '%s'", args[2]);
-                       return ERROR_OK;
-               }
+static int handle_etm_tracemode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+{
+       target_t *target = get_current_target(cmd_ctx);
 
-               /* IGNORED:
-                *  - CPRT tracing (coprocessor register transfers)
-                *  - debug request (causes debug entry on trigger)
-                *  - stall on FIFOFULL (preventing tracedata lossage)
-                */
+       armv4_5_common_t *armv4_5;
+       arm7_9_common_t *arm7_9;
+       if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK)
+       {
+               command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target");
+               return ERROR_OK;
        }
-       else if (argc != 0)
+
+       if (!arm7_9->etm_ctx)
+       {
+               command_print(cmd_ctx, "current target doesn't have an ETM configured");
+               return ERROR_OK;
+       }
+
+       etmv1_tracemode_t tracemode = arm7_9->etm_ctx->tracemode;
+       switch (argc)
        {
-               command_print(cmd_ctx, "usage: configure trace mode <none | data | address | all> <context id bits> <cycle accurate> <branch output>");
+       case 0:
+               break;
+       case 4:
+               handle_etm_tracemode_command_update(cmd_ctx, args, &tracemode);
+               break;
+       default:
+               command_print(cmd_ctx, "usage: configure trace mode "
+                               "<none | data | address | all> "
+                               "<context id bits> <cycle accurate> <branch output>");
                return 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)