This is an automated email from Gerrit.

"Tomas Vanek <[email protected]>" just uploaded a new patch set to Gerrit, which 
you can find at https://review.openocd.org/c/openocd/+/9274

-- gerrit

commit b93e27d7cf9d788d555d3853aea468b458e307fe
Author: Tomas Vanek <[email protected]>
Date:   Sat Nov 29 21:13:27 2025 +0100

    target: add couple of target examined checks
    
    Add check to target_step() to be like target_resume() and target_halt().
    Add checks to handle_target_get_reg() and handle_target_set_reg()
    to behave similarly as reg command.
    
    Change-Id: I7bfbba9e8e89461897ecd7f20a6628a015a57625
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/target.c b/src/target/target.c
index bb02d94be5..d55c43d355 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -1424,6 +1424,11 @@ int target_step(struct target *target,
 {
        int retval;
 
+       if (!target_was_examined(target)) {
+               LOG_TARGET_ERROR(target, "not examined");
+               return ERROR_TARGET_NOT_EXAMINED;
+       }
+
        target_call_event_callbacks(target, TARGET_EVENT_STEP_START);
 
        retval = target->type->step(target, current, address, 
handle_breakpoints);
@@ -4725,6 +4730,11 @@ COMMAND_HANDLER(handle_target_get_reg)
        if (CMD_ARGC < 1 || CMD_ARGC > 2)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
+       if (target->state != TARGET_HALTED) {
+               command_print(CMD, "Error: [%s] not halted", 
target_name(target));
+               return ERROR_TARGET_NOT_HALTED;
+       }
+
        bool force = false;
        Jim_Obj *next_argv = CMD_JIMTCL_ARGV[0];
 
@@ -4783,6 +4793,11 @@ COMMAND_HANDLER(handle_set_reg_command)
        if (CMD_ARGC != 1)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
+       if (target->state != TARGET_HALTED) {
+               command_print(CMD, "Error: [%s] not halted", 
target_name(target));
+               return ERROR_TARGET_NOT_HALTED;
+       }
+
        int tmp;
 #if JIM_VERSION >= 80
        Jim_Obj **dict = Jim_DictPairs(CMD_CTX->interp, CMD_JIMTCL_ARGV[0], 
&tmp);

-- 

Reply via email to