]> git.sur5r.net Git - openocd/commitdiff
Fixes SEGFAULT when setting registers from GDB.
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 7 Oct 2008 18:04:14 +0000 (18:04 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 7 Oct 2008 18:04:14 +0000 (18:04 +0000)
set $cpsr=1234

git-svn-id: svn://svn.berlios.de/openocd/trunk@1026 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/target/arm11.c
src/target/armv4_5.c
src/target/armv7m.c
src/target/mips32.c
src/target/register.c
src/target/register.h

index 758e99d402f3cddf35d773f8519adbb3b5522c6e..f2adce85608139ce842370756912b7ac704ebb6c 100644 (file)
@@ -1683,7 +1683,10 @@ void arm11_build_reg_cache(target_t *target)
     NEW(arm11_reg_state_t,     arm11_reg_states,       ARM11_REGCACHE_COUNT);
 
     if (arm11_regs_arch_type == -1)
-       arm11_regs_arch_type = register_reg_arch_type(arm11_get_reg, arm11_set_reg);
+       arm11_regs_arch_type = register_reg_arch_type(arm11_get_reg, arm11_set_reg);
+   
+       register_init_dummy(&arm11_gdb_dummy_fp_reg);
+       register_init_dummy(&arm11_gdb_dummy_fps_reg);
 
     arm11->reg_list    = reg_list;
 
index df9e3df7836ed587a845a2900dbafde7f7a45e1c..6848bf7617f4db3d6308c8455a97d1f207c09516 100644 (file)
@@ -277,6 +277,9 @@ reg_cache_t* armv4_5_build_reg_cache(target_t *target, armv4_5_common_t *armv4_5
        if (armv4_5_core_reg_arch_type == -1)
                armv4_5_core_reg_arch_type = register_reg_arch_type(armv4_5_get_core_reg, armv4_5_set_core_reg);
 
+       register_init_dummy(&armv4_5_gdb_dummy_fp_reg);
+       register_init_dummy(&armv4_5_gdb_dummy_fps_reg);
+
        for (i = 0; i < 37; i++)
        {
                arch_info[i] = armv4_5_core_reg_list_arch_info[i];
index 38f635ea46f05d9aeebe5b09cd8d2ee1f7c4f795..8456754de95f9ac71059ff5095c6bce3a3800a20 100644 (file)
@@ -198,21 +198,6 @@ int armv7m_set_core_reg(reg_t *reg, u8 *buf)
        return ERROR_OK;
 }
 
-int armv7m_get_dummy_core_reg(reg_t *reg)
-{
-       return ERROR_OK;
-}
-
-int armv7m_set_dummy_core_reg(reg_t *reg, u8 *buf)
-{
-       u32 value = buf_get_u32(buf, 0, 32);
-       buf_set_u32(reg->value, 0, 32, value);
-       reg->dirty = 1;
-       reg->valid = 1;
-
-       return ERROR_OK;
-}
-
 int armv7m_read_core_reg(struct target_s *target, int num)
 {
        u32 reg_value;
@@ -485,12 +470,11 @@ reg_cache_t *armv7m_build_reg_cache(target_t *target)
        if (armv7m_core_reg_arch_type == -1)
        {
                armv7m_core_reg_arch_type = register_reg_arch_type(armv7m_get_core_reg, armv7m_set_core_reg);
-               armv7m_dummy_core_reg_arch_type = register_reg_arch_type(armv7m_get_dummy_core_reg, armv7m_set_dummy_core_reg);
-
-               armv7m_gdb_dummy_fp_reg.arch_type=armv7m_dummy_core_reg_arch_type;
-               armv7m_gdb_dummy_fps_reg.arch_type=armv7m_dummy_core_reg_arch_type;
-               armv7m_gdb_dummy_cpsr_reg.arch_type=armv7m_dummy_core_reg_arch_type;
        }
+       
+       register_init_dummy(&armv7m_gdb_dummy_fps_reg);
+       register_init_dummy(&armv7m_gdb_dummy_cpsr_reg);
+       register_init_dummy(&armv7m_gdb_dummy_fp_reg);
                
        /* Build the process context cache */ 
        cache->name = "arm v7m registers";
index 96e509c3b895ad42b3a47bd18b6ece9ee17b804f..47b069e62877e8d847bfa4cf47bd43caedec7e98 100644 (file)
@@ -4,6 +4,9 @@
  *                                                                         *
  *   Copyright (C) 2008 by David T.L. Wong                                 *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -286,7 +289,10 @@ reg_cache_t *mips32_build_reg_cache(target_t *target)
        
        if (mips32_core_reg_arch_type == -1)
                mips32_core_reg_arch_type = register_reg_arch_type(mips32_get_core_reg, mips32_set_core_reg);
-               
+
+       register_init_dummy(&mips32_gdb_dummy_fsr_reg);
+       register_init_dummy(&mips32_gdb_dummy_fir_reg);
+
        /* Build the process context cache */ 
        cache->name = "mips32 registers";
        cache->next = NULL;
index 1a8f6ddd3a038ce49cfdd08ca13a85c46cc82065..cb80eff658f6bcc1923dd59dd1ac6e4f5cefc5a4 100644 (file)
@@ -2,6 +2,9 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -103,3 +106,27 @@ reg_arch_type_t* register_get_arch_type(int id)
        exit(-1);
        return NULL;
 }
+
+
+
+static int register_get_dummy_core_reg(reg_t *reg)
+{
+       return ERROR_OK;
+}
+
+static int register_set_dummy_core_reg(reg_t *reg, u8 *buf)
+{
+       reg->dirty = 1;
+       reg->valid = 1;
+
+       return ERROR_OK;
+}
+
+void register_init_dummy(reg_t *reg)
+{
+       static int dummy_arch_type = -1;
+       if (dummy_arch_type == -1 )
+               register_reg_arch_type(register_get_dummy_core_reg, register_set_dummy_core_reg);
+       
+       reg->arch_type = dummy_arch_type;
+}
index 456ab5901c443ea227dc95dfec6dedccc673a9b3..96bd3da94887a4d660071b6537e7a7ce4601a9e0 100644 (file)
@@ -2,6 +2,9 @@
  *   Copyright (C) 2005 by Dominic Rath                                    *
  *   Dominic.Rath@gmx.de                                                   *
  *                                                                         *
+ *   Copyright (C) 2007,2008 Øyvind Harboe                                 *
+ *   oyvind.harboe@zylin.com                                               *
+ *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
@@ -64,6 +67,7 @@ extern reg_t* register_get_by_name(reg_cache_t *first, char *name, int search_al
 extern reg_cache_t** register_get_last_cache_p(reg_cache_t **first);
 extern int register_reg_arch_type(int (*get)(reg_t *reg), int (*set)(reg_t *reg, u8 *buf));
 extern reg_arch_type_t* register_get_arch_type(int id);
+extern void register_init_dummy(reg_t *reg);
 
 #endif /* REGISTER_H */