Commit 3aef2f08 authored by oharboe's avatar oharboe
Browse files

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
parent 2babd879
......@@ -1685,6 +1685,9 @@ void arm11_build_reg_cache(target_t *target)
if (arm11_regs_arch_type == -1)
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;
/* Build the process context cache */
......
......@@ -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];
......
......@@ -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,13 +470,12 @@ 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";
cache->next = NULL;
......
......@@ -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 *
......@@ -287,6 +290,9 @@ 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;
......
......@@ -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;
}
......@@ -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 */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment