diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 23748e7c6..d5c3f3510 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2211,7 +2211,8 @@ int gdb_init(void) add_service("gdb", CONNECTION_PIPE, 0, 1, gdb_new_connection, gdb_input, gdb_connection_closed, gdb_service); - LOG_DEBUG("gdb service for target %s using pipes", target->type->name); + LOG_DEBUG("gdb service for target %s using pipes", + target_get_name(target)); } else { @@ -2222,7 +2223,9 @@ int gdb_init(void) add_service("gdb", CONNECTION_TCP, gdb_port + target->target_number, 1, gdb_new_connection, gdb_input, gdb_connection_closed, gdb_service); - LOG_DEBUG("gdb service for target %s at port %i", target->type->name, gdb_port + target->target_number); + LOG_DEBUG("gdb service for target %s at port %i", + target_get_name(target), + gdb_port + target->target_number); target = target->next; } } diff --git a/src/target/arm11.c b/src/target/arm11.c index 0dc6bf476..155573270 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1847,7 +1847,7 @@ arm11_common_t * arm11_find_target(const char * arg) continue; /* if (t->type == arm11_target) */ - if (0 == strcmp(t->type->name, "arm11")) + if (0 == strcmp(target_get_name(t), "arm11")) return t->arch_info; } diff --git a/src/target/embeddedice.c b/src/target/embeddedice.c index 9d2be364d..d96debd05 100644 --- a/src/target/embeddedice.c +++ b/src/target/embeddedice.c @@ -184,7 +184,7 @@ reg_cache_t* embeddedice_build_reg_cache(target_t *target, arm7_9_common_t *arm7 * in some unusual bits. Let feroceon.c validate it * and do the appropriate setup itself. */ - if (strcmp(target->type->name, "feroceon") == 0) + if (strcmp(target_get_name(target), "feroceon") == 0) break; LOG_ERROR("unknown EmbeddedICE version (comms ctrl: 0x%8.8x)", buf_get_u32(reg_list[EICE_COMMS_CTRL].value, 0, 32)); } diff --git a/src/target/target.c b/src/target/target.c index 993b8c613..a54e0654b 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -484,6 +484,10 @@ int target_examine(void) } return retval; } +const char *target_get_name(struct target_s *target) +{ + return target->type->name; +} static int target_write_memory_imp(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { @@ -598,7 +602,7 @@ int target_init(struct command_context_s *cmd_ctx) if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK) { - LOG_ERROR("target '%s' init failed", target->type->name); + LOG_ERROR("target '%s' init failed", target_get_name(target)); return retval; } @@ -1451,7 +1455,7 @@ DumpTargets: command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %10d %14s %s", target->target_number, target->cmd_name, - target->type->name, + target_get_name(target), Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness )->name, target->tap->abs_chain_position, target->tap->dotted_name, @@ -3131,7 +3135,7 @@ void target_handle_event( target_t *target, enum target_event e ) LOG_DEBUG( "target: (%d) %s (%s) event: %d (%s) action: %s\n", target->target_number, target->cmd_name, - target->type->name, + target_get_name(target), e, Jim_Nvp_value2name_simple( nvp_target_event, e )->name, Jim_GetString( teap->body, NULL ) ); @@ -3220,7 +3224,7 @@ static int target_configure( Jim_GetOptInfo *goi, target_t *target ) return JIM_ERR; } } - Jim_SetResultString( goi->interp, target->type->name, -1 ); + Jim_SetResultString( goi->interp, target_get_name(target), -1 ); /* loop for more */ break; case TCFG_EVENT: diff --git a/src/target/target.h b/src/target/target.h index 3d9d8e9f9..91dd1b154 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -107,6 +107,10 @@ typedef struct working_area_s typedef struct target_type_s { + /** + * Name of the target. Do @b not access this field directly, use + * target_get_name() instead. + */ char *name; /** @@ -395,6 +399,13 @@ extern target_t* get_current_target(struct command_context_s *cmd_ctx); extern int get_num_by_target(target_t *query_target); extern target_t *get_target(const char *id); +/** + * Get the target name. + * + * This routine is a wrapper for the target->type->name field. + */ +extern const char *target_get_name(struct target_s *target); + /// @returns @c true if the target has been examined. extern bool target_was_examined(struct target_s *target); /// Sets the @c examined flag for the given target.