Skip to content

Commit

Permalink
target: Add a debug_reason command
Browse files Browse the repository at this point in the history
This allows programmatically determining the debug reason.

Change-Id: I0c3e85cebb6dc28fc0fc212beca84a484ac654a5
Signed-off-by: Peter Collingbourne <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7952
Reviewed-by: Jan Matyas <[email protected]>
Reviewed-by: Tomas Vanek <[email protected]>
Reviewed-by: Antonio Borneo <[email protected]>
Tested-by: jenkins
  • Loading branch information
pcc authored and borneoa committed Nov 11, 2023
1 parent a908008 commit 42441fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions src/target/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 42441fd

Please sign in to comment.