aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Schink <dev@zapb.de>2024-05-01 12:58:18 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2024-05-26 09:54:01 +0000
commitbe1aebd8183c5b6b3bbecfc065a84b7e10bd8f8e (patch)
tree397d9b9d74625d43fadc54dbc24a11b3b4b0c0ca
parentc831758ea4f0baf6e4d1b2ee69ae3c895922fee5 (diff)
downloadriscv-openocd-be1aebd8183c5b6b3bbecfc065a84b7e10bd8f8e.zip
riscv-openocd-be1aebd8183c5b6b3bbecfc065a84b7e10bd8f8e.tar.gz
riscv-openocd-be1aebd8183c5b6b3bbecfc065a84b7e10bd8f8e.tar.bz2
target/arm_tpiu_swo: Handle errors in pre/post-enable events
Currently, errors in pre/post-enable events are ignored and capturing is always started, even if necessary device configuration fails. This behaviour is confusing to users. Also, the TPIU must be disabled before re-configuration is possible. Start capturing and enable TPIU only if no errors in pre/post-enable events occurred. Change-Id: I422033e36ca006e38aa4504d491b7947def1237a Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: https://review.openocd.org/c/openocd/+/8254 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
-rw-r--r--src/target/arm_tpiu_swo.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c
index 128e147..340d332 100644
--- a/src/target/arm_tpiu_swo.c
+++ b/src/target/arm_tpiu_swo.c
@@ -161,7 +161,7 @@ static int arm_tpiu_swo_poll_trace(void *priv)
return ERROR_OK;
}
-static void arm_tpiu_swo_handle_event(struct arm_tpiu_swo_object *obj, enum arm_tpiu_swo_event event)
+static int arm_tpiu_swo_handle_event(struct arm_tpiu_swo_object *obj, enum arm_tpiu_swo_event event)
{
for (struct arm_tpiu_swo_event_action *ea = obj->event_action; ea; ea = ea->next) {
if (ea->event != event)
@@ -182,7 +182,7 @@ static void arm_tpiu_swo_handle_event(struct arm_tpiu_swo_object *obj, enum arm_
if (retval == JIM_RETURN)
retval = ea->interp->returnCode;
if (retval == JIM_OK || retval == ERROR_COMMAND_CLOSE_CONNECTION)
- return;
+ return ERROR_OK;
Jim_MakeErrorMessage(ea->interp);
LOG_USER("Error executing event %s on TPIU/SWO %s:\n%s",
@@ -191,8 +191,10 @@ static void arm_tpiu_swo_handle_event(struct arm_tpiu_swo_object *obj, enum arm_
Jim_GetString(Jim_GetResult(ea->interp), NULL));
/* clean both error code and stacktrace before return */
Jim_Eval(ea->interp, "error \"\" \"\"");
- return;
+ return ERROR_FAIL;
}
+
+ return ERROR_OK;
}
static void arm_tpiu_swo_close_output(struct arm_tpiu_swo_object *obj)
@@ -674,7 +676,9 @@ COMMAND_HANDLER(handle_arm_tpiu_swo_enable)
}
/* trigger the event before any attempt to R/W in the TPIU/SWO */
- arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_PRE_ENABLE);
+ retval = arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_PRE_ENABLE);
+ if (retval != ERROR_OK)
+ return retval;
retval = wrap_read_u32(target, obj->ap, obj->spot.base + TPIU_DEVID_OFFSET, &value);
if (retval != ERROR_OK) {
@@ -800,7 +804,9 @@ COMMAND_HANDLER(handle_arm_tpiu_swo_enable)
if (retval != ERROR_OK)
goto error_exit;
- arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_POST_ENABLE);
+ retval = arm_tpiu_swo_handle_event(obj, TPIU_SWO_EVENT_POST_ENABLE);
+ if (retval != ERROR_OK)
+ goto error_exit;
/* START_DEPRECATED_TPIU */
target_handle_event(target, TARGET_EVENT_TRACE_CONFIG);