Fixes SEGFAULT when setting registers from GDB.

set $cpsr=1234 

git-svn-id: svn://svn.berlios.de/openocd/trunk@1026 b42882b7-edfa-0310-969c-e2dbd0fdcd60
__archive__
oharboe 2008-10-07 18:04:14 +00:00
parent 2babd87916
commit 3aef2f0858
6 changed files with 49 additions and 22 deletions

View File

@ -1683,7 +1683,10 @@ void arm11_build_reg_cache(target_t *target)
NEW(arm11_reg_state_t, arm11_reg_states, ARM11_REGCACHE_COUNT); NEW(arm11_reg_state_t, arm11_reg_states, ARM11_REGCACHE_COUNT);
if (arm11_regs_arch_type == -1) 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; arm11->reg_list = reg_list;

View 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) 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); 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++) for (i = 0; i < 37; i++)
{ {
arch_info[i] = armv4_5_core_reg_list_arch_info[i]; arch_info[i] = armv4_5_core_reg_list_arch_info[i];

View File

@ -198,21 +198,6 @@ int armv7m_set_core_reg(reg_t *reg, u8 *buf)
return ERROR_OK; 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) int armv7m_read_core_reg(struct target_s *target, int num)
{ {
u32 reg_value; u32 reg_value;
@ -485,12 +470,11 @@ reg_cache_t *armv7m_build_reg_cache(target_t *target)
if (armv7m_core_reg_arch_type == -1) 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_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 */ /* Build the process context cache */
cache->name = "arm v7m registers"; cache->name = "arm v7m registers";

View File

@ -4,6 +4,9 @@
* * * *
* Copyright (C) 2008 by David T.L. Wong * * 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 * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * 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) if (mips32_core_reg_arch_type == -1)
mips32_core_reg_arch_type = register_reg_arch_type(mips32_get_core_reg, mips32_set_core_reg); 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 */ /* Build the process context cache */
cache->name = "mips32 registers"; cache->name = "mips32 registers";
cache->next = NULL; cache->next = NULL;

View File

@ -2,6 +2,9 @@
* Copyright (C) 2005 by Dominic Rath * * Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de * * 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 * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * 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); exit(-1);
return NULL; 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;
}

View File

@ -2,6 +2,9 @@
* Copyright (C) 2005 by Dominic Rath * * Copyright (C) 2005 by Dominic Rath *
* Dominic.Rath@gmx.de * * 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 * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * 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 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 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 reg_arch_type_t* register_get_arch_type(int id);
extern void register_init_dummy(reg_t *reg);
#endif /* REGISTER_H */ #endif /* REGISTER_H */