]> git.sur5r.net Git - openocd/commitdiff
Centralize error handling for buggy register handling
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 6 Oct 2008 12:09:27 +0000 (12:09 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 6 Oct 2008 12:09:27 +0000 (12:09 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1019 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/server/gdb_server.c
src/target/register.c
src/target/target.c

index b5a35f58ac875fd19e08fdeeed6013217041cddb..851777a9c4f3a0b937cb43906a8080b34b0c2c62 100644 (file)
@@ -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);
index 2adf73e7590e601f0c6d47cbf62c94f3a05be20c..1a8f6ddd3a038ce49cfdd08ca13a85c46cc82065 100644 (file)
@@ -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 = &reg_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;
 }
index 3426b23e4761086d5fae8f170afe25cfae2adb57..f530eb31334877a4c333db8b67bdcc2d79946232 100644 (file)
@@ -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);