From: openocd-gerrit <ope...@us...> - 2023-11-11 18:44:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 42441fd96cf86ffca61f77afe24aae21fb00bb89 (commit) from a9080087d82688043ca216d50926228d09631297 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 42441fd96cf86ffca61f77afe24aae21fb00bb89 Author: Peter Collingbourne <pc...@go...> Date: Thu Oct 19 19:07:29 2023 -0700 target: Add a debug_reason command This allows programmatically determining the debug reason. Change-Id: I0c3e85cebb6dc28fc0fc212beca84a484ac654a5 Signed-off-by: Peter Collingbourne <pc...@go...> Reviewed-on: https://review.openocd.org/c/openocd/+/7952 Reviewed-by: Jan Matyas <jan...@co...> Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index a2965189f..45c2e4df5 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -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. diff --git a/src/target/target.c b/src/target/target.c index 61c243510..d368cb515 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; @@ -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, ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 12 ++++++++++++ src/target/target.c | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) hooks/post-receive -- Main OpenOCD repository |