From 2653b8030722c85393974cd6c0ebcdbd1ae27c72 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Wed, 25 Nov 2009 16:38:08 -0800 Subject: target: create and use target_name() Several of the sites now using target_type_name() really ought to be using an instance-specific name. Create a function called target_name(), accessing the instance's own (command) name. Use it in several places that really should be displaying instance-specific names. Also in several places which were already doing so, but which had no wrapper to call. Signed-off-by: David Brownell --- src/target/breakpoints.c | 4 ++-- src/target/etm.c | 3 ++- src/target/target.c | 35 +++++++++++++++++++---------------- src/target/target.h | 6 ++++++ 4 files changed, 29 insertions(+), 19 deletions(-) (limited to 'src/target') diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index df797e37..16ab7e0c 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -157,7 +157,7 @@ void breakpoint_clear_target(struct target *target) struct breakpoint *breakpoint; LOG_DEBUG("Delete all breakpoints for target: %s", - target_type_name(target)); + target_name(target)); while ((breakpoint = target->breakpoints) != NULL) { breakpoint_free(target, breakpoint); @@ -294,7 +294,7 @@ void watchpoint_clear_target(struct target *target) struct watchpoint *watchpoint; LOG_DEBUG("Delete all watchpoints for target: %s", - target_type_name(target)); + target_name(target)); while ((watchpoint = target->watchpoints) != NULL) { watchpoint_free(target, watchpoint); diff --git a/src/target/etm.c b/src/target/etm.c index 2ea7345d..520e22f6 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1374,7 +1374,8 @@ COMMAND_HANDLER(handle_etm_config_command) arm = target_to_arm(target); if (!is_arm(arm)) { command_print(CMD_CTX, "target '%s' is '%s'; not an ARM", - target->cmd_name, target_type_name(target)); + target_name(target), + target_type_name(target)); return ERROR_FAIL; } diff --git a/src/target/target.c b/src/target/target.c index f46fc67b..3de9f2c6 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -556,7 +556,7 @@ static int target_soft_reset_halt_imp(struct target *target) } if (!target->type->soft_reset_halt_imp) { LOG_ERROR("Target %s does not support soft_reset_halt", - target->cmd_name); + target_name(target)); return ERROR_FAIL; } return target->type->soft_reset_halt_imp(target); @@ -766,7 +766,7 @@ int target_init(struct command_context *cmd_ctx) if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK) { - LOG_ERROR("target '%s' init failed", target_type_name(target)); + LOG_ERROR("target '%s' init failed", target_name(target)); return retval; } @@ -1697,7 +1697,7 @@ DumpTargets: command_print(CMD_CTX, "%2d%c %-18s %-10s %-6s %-18s %s", target->target_number, marker, - target->cmd_name, + target_name(target), target_type_name(target), Jim_Nvp_value2name_simple(nvp_target_endian, target->endianness)->name, @@ -3510,7 +3510,7 @@ void target_handle_event(struct target *target, enum target_event e) if (teap->event == e) { LOG_DEBUG("target: (%d) %s (%s) event: %d (%s) action: %s", target->target_number, - target->cmd_name, + target_name(target), target_type_name(target), e, Jim_Nvp_value2name_simple(nvp_target_event, e)->name, @@ -4139,7 +4139,7 @@ static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv) || !target->type->deassert_reset) { Jim_SetResult_sprintf(interp, "No target-specific reset for %s", - target->cmd_name); + target_name(target)); return JIM_ERR; } /* determine if we should halt or not. */ @@ -4183,10 +4183,9 @@ static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv) e = target_wait_state(target, n->value, a); if (e != ERROR_OK) { Jim_SetResult_sprintf(goi.interp, - "target: %s wait %s fails (%d) %s", - target->cmd_name, - n->name, - e, target_strerror_safe(e)); + "target: %s wait %s fails (%d) %s", + target_name(target), n->name, + e, target_strerror_safe(e)); return JIM_ERR; } else { return JIM_OK; @@ -4198,9 +4197,10 @@ static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { struct target_event_action *teap; teap = target->event_action; - command_print(cmd_ctx, "Event actions for target (%d) %s\n", - target->target_number, - target->cmd_name); + command_print(cmd_ctx, + "Event actions for target (%d) %s\n", + target->target_number, + target_name(target)); command_print(cmd_ctx, "%-25s | Body", "Event"); command_print(cmd_ctx, "------------------------- | ----------------------------------------"); while (teap) { @@ -4450,7 +4450,9 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters"); return JIM_ERR; } - Jim_SetResultString(goi.interp, get_current_target(cmd_ctx)->cmd_name, -1); + Jim_SetResultString(goi.interp, + target_name(get_current_target(cmd_ctx)), + -1); return JIM_OK; case TG_CMD_TYPES: if (goi.argc != 0) { @@ -4473,8 +4475,9 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv) target = all_targets; while (target) { Jim_ListAppendElement(goi.interp, - Jim_GetResult(goi.interp), - Jim_NewStringObj(goi.interp, target->cmd_name, -1)); + Jim_GetResult(goi.interp), + Jim_NewStringObj(goi.interp, + target_name(target), -1)); target = target->next; } return JIM_OK; @@ -4505,7 +4508,7 @@ static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv) "Target: number %d does not exist", (int)(w)); return JIM_ERR; } - Jim_SetResultString(goi.interp, target->cmd_name, -1); + Jim_SetResultString(goi.interp, target_name(target), -1); return JIM_OK; case TG_CMD_COUNT: if (goi.argc != 0) { diff --git a/src/target/target.h b/src/target/target.h index 61bc68ae..15003c65 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -159,6 +159,12 @@ struct target long long halt_issued_time; /* Note time when halt was issued */ }; +/** Returns the instance-specific name of the specified target. */ +static inline const char *target_name(struct target *target) +{ + return target->cmd_name; +} + enum target_event { /* LD historical names -- cgit v1.2.3