diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/gdb_server.c | 11 | ||||
-rw-r--r-- | src/target/register.c | 21 | ||||
-rw-r--r-- | src/target/target.c | 13 |
3 files changed, 13 insertions, 32 deletions
diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index b5a35f58..851777a9 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -936,11 +936,7 @@ int gdb_set_registers_packet(connection_t *connection, target_t *target, char *p /* get register arch_type, and call set method */ arch_type = register_get_arch_type(reg_list[i]->arch_type); - if (arch_type == NULL) - { - LOG_ERROR("BUG: encountered unregistered arch type"); - exit(-1); - } + arch_type->set(reg_list[i], bin_buf); /* advance packet pointer */ @@ -1033,11 +1029,6 @@ int gdb_set_register_packet(connection_t *connection, target_t *target, char *pa /* get register arch_type, and call set method */ arch_type = register_get_arch_type(reg_list[reg_num]->arch_type); - if (arch_type == NULL) - { - LOG_ERROR("BUG: encountered unregistered arch type"); - exit(-1); - } arch_type->set(reg_list[reg_num], bin_buf); gdb_put_packet(connection, "OK", 2); diff --git a/src/target/register.c b/src/target/register.c index 2adf73e7..1a8f6ddd 100644 --- a/src/target/register.c +++ b/src/target/register.c @@ -35,7 +35,7 @@ reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_all) { int i; reg_cache_t *cache = first; - + while (cache) { for (i = 0; i < cache->num_regs; i++) @@ -43,26 +43,26 @@ reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_all) if (strcmp(cache->reg_list[i].name, name) == 0) return &(cache->reg_list[i]); } - + if (search_all) cache = cache->next; else break; } - + return NULL; } reg_cache_t** register_get_last_cache_p(reg_cache_t **first) { reg_cache_t **cache_p = first; - + if (*cache_p) while (*cache_p) cache_p = &((*cache_p)->next); else return first; - + return cache_p; } @@ -70,7 +70,7 @@ int register_reg_arch_type(int (*get)(reg_t *reg), int (*set)(reg_t *reg, u8 *bu { reg_arch_type_t** arch_type_p = ®_arch_types; int id = 0; - + if (*arch_type_p) { while (*arch_type_p) @@ -79,26 +79,27 @@ int register_reg_arch_type(int (*get)(reg_t *reg), int (*set)(reg_t *reg, u8 *bu arch_type_p = &((*arch_type_p)->next); } } - + (*arch_type_p) = malloc(sizeof(reg_arch_type_t)); (*arch_type_p)->id = id + 1; (*arch_type_p)->set = set; (*arch_type_p)->get = get; (*arch_type_p)->next = NULL; - + return id + 1; } reg_arch_type_t* register_get_arch_type(int id) { reg_arch_type_t *arch_type = reg_arch_types; - + while (arch_type) { if (arch_type->id == id) return arch_type; arch_type = arch_type->next; } - + LOG_ERROR("BUG: encountered unregistered arch type 0x%08x", id); + exit(-1); return NULL; } diff --git a/src/target/target.c b/src/target/target.c index 3426b23e..f530eb31 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1212,7 +1212,7 @@ int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* } if ((retval = target->type->checksum_memory(target, address, - size, &checksum)) == ERROR_TARGET_RESOURCE_NOT_AVAILABLE) + size, &checksum)) != ERROR_OK) { buffer = malloc(size); if (buffer == NULL) @@ -1625,11 +1625,6 @@ int handle_reg_command(struct command_context_s *cmd_ctx, char *cmd, char **args if (reg->valid == 0) { reg_arch_type_t *arch_type = register_get_arch_type(reg->arch_type); - if (arch_type == NULL) - { - LOG_ERROR("BUG: encountered unregistered arch type"); - return ERROR_OK; - } arch_type->get(reg); } value = buf_to_str(reg->value, reg->size, 16); @@ -1645,12 +1640,6 @@ int handle_reg_command(struct command_context_s *cmd_ctx, char *cmd, char **args str_to_buf(args[1], strlen(args[1]), buf, reg->size, 0); reg_arch_type_t *arch_type = register_get_arch_type(reg->arch_type); - if (arch_type == NULL) - { - LOG_ERROR("BUG: encountered unregistered arch type"); - return ERROR_OK; - } - arch_type->set(reg, buf); value = buf_to_str(reg->value, reg->size, 16); |