aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Collingbourne <pcc@google.com>2023-10-19 19:07:29 -0700
committerAntonio Borneo <borneo.antonio@gmail.com>2023-11-11 18:43:43 +0000
commit42441fd96cf86ffca61f77afe24aae21fb00bb89 (patch)
treeed4b25c4bfa233f42b166c058c819fb7b63a7e36 /src
parenta9080087d82688043ca216d50926228d09631297 (diff)
downloadriscv-openocd-42441fd96cf86ffca61f77afe24aae21fb00bb89.zip
riscv-openocd-42441fd96cf86ffca61f77afe24aae21fb00bb89.tar.gz
riscv-openocd-42441fd96cf86ffca61f77afe24aae21fb00bb89.tar.bz2
target: Add a debug_reason command
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
Diffstat (limited to 'src')
-rw-r--r--src/target/target.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/target/target.c b/src/target/target.c
index 61c2435..d368cb5 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -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;
@@ -6026,6 +6038,13 @@ static const struct command_registration target_instance_command_handlers[] = {
.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,
.handler = handle_target_examine,