- gdb server was incorrectly sending null terminator on qXfer:features:read: packet
[openocd.git] / src / target / armv7m.c
index 6a8119a02ddb4fdd8c9b10b1aa6fc51a113658cc..e2134420a8333a1cf865e9276eb16baef91648d9 100644 (file)
@@ -85,6 +85,13 @@ reg_t armv7m_gdb_dummy_fp_reg =
        "GDB dummy floating-point register", armv7m_gdb_dummy_fp_value, 0, 1, 96, NULL, 0, NULL, 0
 };
 
+u8 armv7m_gdb_dummy_fps_value[] = {0, 0, 0, 0};
+
+reg_t armv7m_gdb_dummy_fps_reg =
+{
+       "GDB dummy floating-point status register", armv7m_gdb_dummy_fps_value, 0, 1, 32, NULL, 0, NULL, 0
+};
+
 armv7m_core_reg_t armv7m_core_reg_list_arch_info[] = 
 {
        /*  CORE_GP are accesible using the core debug registers */
@@ -111,10 +118,10 @@ armv7m_core_reg_t armv7m_core_reg_list_arch_info[] =
 
        /*  CORE_SP are accesible using MSR and MRS instructions */
 #if 0
-//     {0x00, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* APSR */
-//     {0x01, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* IAPSR */
-//     {0x05, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* IPSR */
-//     {0x06, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* EPSR */
+       {0x00, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* APSR */
+       {0x01, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* IAPSR */
+       {0x05, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* IPSR */
+       {0x06, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* EPSR */
 #endif
 
        {0x10, ARMV7M_REGISTER_CORE_SP, ARMV7M_MODE_ANY, NULL, NULL}, /* PRIMASK */
@@ -169,7 +176,7 @@ int armv7m_use_context(target_t *target, enum armv7m_runcontext new_ctx)
        } 
        /* Mark registers in new context as dirty to force reload when run */
        
-       for (i = 0; i < armv7m->core_cache->num_regs-1; i++) /* EXCLUDE CONTROL TODOLATER : CHECK THIS */
+       for (i = 0; i < armv7m->core_cache->num_regs; i++)
        {
                armv7m->core_cache->reg_list[i].dirty = 1;
        }
@@ -203,11 +210,11 @@ int armv7m_restore_context(target_t *target)
        return ERROR_OK;                
 }
 
-
 /* Core state functions */
-char enamebuf[32];
 char *armv7m_exception_string(int number)
 {
+       static char enamebuf[32];
+       
        if ((number < 0) | (number > 511))
                return "Invalid exception";
        if (number < 16)
@@ -321,24 +328,23 @@ int armv7m_get_gdb_reg_list(target_t *target, reg_t **reg_list[], int *reg_list_
        armv7m_common_t *armv7m = target->arch_info;
        int i;
        
-       if (target->state != TARGET_HALTED)
-       {
-               return ERROR_TARGET_NOT_HALTED;
-       }
-       
        *reg_list_size = 26;
        *reg_list = malloc(sizeof(reg_t*) * (*reg_list_size));
        
-       /* TODOLATER correct list of registers, names ? */
-       for (i = 0; i < *reg_list_size; i++)
+       for (i = 0; i < 16; i++)
        {
-               if (i < ARMV7NUMCOREREGS)
-                       (*reg_list)[i] = &armv7m->process_context->reg_list[i];
-                       /* (*reg_list)[i] = &armv7m->core_cache->reg_list[i]; */
-               else
-                       (*reg_list)[i] = &armv7m_gdb_dummy_fp_reg;
+               (*reg_list)[i] = &armv7m->process_context->reg_list[i];
        }
-       /* ARMV7M is always in thumb mode, try to make GDB understand this if it does not support this arch */
+       
+       for (i = 16; i < 24; i++)
+       {
+               (*reg_list)[i] = &armv7m_gdb_dummy_fp_reg;
+       }
+       
+       (*reg_list)[24] = &armv7m_gdb_dummy_fps_reg;
+       
+       /* ARMV7M is always in thumb mode, try to make GDB understand this
+        * if it does not support this arch */
        armv7m->process_context->reg_list[15].value[0] |= 1;    
        (*reg_list)[25] = &armv7m->process_context->reg_list[ARMV7M_xPSR];      
        return ERROR_OK;
@@ -349,15 +355,9 @@ int armv7m_run_algorithm(struct target_s *target, int num_mem_params, mem_param_
        /* get pointers to arch-specific information */
        armv7m_common_t *armv7m = target->arch_info;
        armv7m_algorithm_t *armv7m_algorithm_info = arch_info;
-       enum armv7m_state core_state = armv7m->core_state;
-       enum armv7m_mode core_mode = armv7m->core_mode;
        int retval = ERROR_OK;
        u32 pc;
-       int exit_breakpoint_size = 0;
        int i;
-               
-       armv7m->core_state = core_state;
-       armv7m->core_mode = core_mode;
 
        if (armv7m_algorithm_info->common_magic != ARMV7M_COMMON_MAGIC)
        {
@@ -402,8 +402,7 @@ int armv7m_run_algorithm(struct target_s *target, int num_mem_params, mem_param_
        }
        
        /* ARMV7M always runs in Thumb state */
-       exit_breakpoint_size = 2;
-       if ((retval = breakpoint_add(target, exit_point, exit_breakpoint_size, BKPT_SOFT)) != ERROR_OK)
+       if ((retval = breakpoint_add(target, exit_point, 2, BKPT_SOFT)) != ERROR_OK)
        {
                ERROR("can't add breakpoint to finish algorithm execution");
                return ERROR_TARGET_FAILURE;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)