target: Add a debug_reason command 52/7952/4
authorPeter Collingbourne <pcc@google.com>
Fri, 20 Oct 2023 02:07:29 +0000 (19:07 -0700)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 11 Nov 2023 18:43:43 +0000 (18:43 +0000)
This allows programmatically determining the debug reason.

Change-Id: I0c3e85cebb6dc28fc0fc212beca84a484ac654a5
Signed-off-by: Peter Collingbourne <pcc@google.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/7952
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
doc/openocd.texi
src/target/target.c

index a2965189fbb3aca12eaf5e9bf469eadfd92e0444..45c2e4df5d2d40ef87a5a90d06cba9541ea7854e 100644 (file)
@@ -5296,6 +5296,18 @@ Displays the current target state:
 (Also, @pxref{eventpolling,,Event Polling}.)
 @end deffn
 
+@deffn {Command} {$target_name debug_reason}
+Displays the current debug reason:
+@code{debug-request},
+@code{breakpoint},
+@code{watchpoint},
+@code{watchpoint-and-breakpoint},
+@code{single-step},
+@code{target-not-halted},
+@code{program-exit},
+@code{exception-catch} or @code{undefined}.
+@end deffn
+
 @deffn {Command} {$target_name eventlist}
 Displays a table listing all event handlers
 currently associated with this target.
index 61c243510a24f46bcc189ca64cdf9c243f2b95dc..d368cb5156f4befdf9a895d8a9dc1122da1d694c 100644 (file)
@@ -5874,6 +5874,18 @@ COMMAND_HANDLER(handle_target_current_state)
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(handle_target_debug_reason)
+{
+       if (CMD_ARGC != 0)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       struct target *target = get_current_target(CMD_CTX);
+
+       command_print(CMD, "%s", debug_reason_name(target));
+
+       return ERROR_OK;
+}
+
 static int jim_target_invoke_event(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 {
        struct jim_getopt_info goi;
@@ -6025,6 +6037,13 @@ static const struct command_registration target_instance_command_handlers[] = {
                .help = "displays the current state of this target",
                .usage = "",
        },
+       {
+               .name = "debug_reason",
+               .mode = COMMAND_EXEC,
+               .handler = handle_target_debug_reason,
+               .help = "displays the debug reason of this target",
+               .usage = "",
+       },
        {
                .name = "arp_examine",
                .mode = COMMAND_EXEC,

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)