aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYvan Roux <yvan.roux@foss.st.com>2022-06-15 16:07:22 +0200
committerYvan Roux <yvan.roux@foss.st.com>2022-06-15 16:07:22 +0200
commitb9b66a3a5740dfa0cf929a9c9abcdbaabe989358 (patch)
tree4c2bc14bc2505fcd4d2a5c0f9fbed5cb01da1842 /gdb
parent0d12d61b9a646f317d9793492971c9a28f83b754 (diff)
downloadgdb-b9b66a3a5740dfa0cf929a9c9abcdbaabe989358.zip
gdb-b9b66a3a5740dfa0cf929a9c9abcdbaabe989358.tar.gz
gdb-b9b66a3a5740dfa0cf929a9c9abcdbaabe989358.tar.bz2
gdb/arm: Make sp alias for one of the other stack pointers
For Cortex-M targets, SP register is never detached from msp or psp, it always has the same value as one of them. Let GDB treat ARM_SP_REGNUM as an alias similar to what is done in hardware. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Signed-off-by: Yvan Roux <yvan.roux@foss.st.com>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/arm-tdep.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 38ce85e..0c90748 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -385,9 +385,6 @@ static CORE_ADDR
arm_cache_get_sp_register (struct arm_prologue_cache *cache,
arm_gdbarch_tdep *tdep, int regnum)
{
- if (regnum == ARM_SP_REGNUM)
- return cache->sp;
-
if (tdep->have_sec_ext)
{
if (regnum == tdep->m_profile_msp_s_regnum)
@@ -402,6 +399,8 @@ arm_cache_get_sp_register (struct arm_prologue_cache *cache,
return arm_cache_get_sp_register (cache, tdep, cache->active_msp_regnum);
if (regnum == tdep->m_profile_psp_regnum)
return arm_cache_get_sp_register (cache, tdep, cache->active_psp_regnum);
+ if (regnum == ARM_SP_REGNUM)
+ return arm_cache_get_sp_register (cache, tdep, cache->active_sp_regnum);
}
else if (tdep->is_m)
{
@@ -409,7 +408,11 @@ arm_cache_get_sp_register (struct arm_prologue_cache *cache,
return cache->msp_s;
if (regnum == tdep->m_profile_psp_regnum)
return cache->psp_s;
+ if (regnum == ARM_SP_REGNUM)
+ return arm_cache_get_sp_register (cache, tdep, cache->active_sp_regnum);
}
+ else if (regnum == ARM_SP_REGNUM)
+ return cache->sp;
gdb_assert_not_reached ("Invalid SP selection");
}
@@ -430,12 +433,6 @@ static void
arm_cache_set_active_sp_value (struct arm_prologue_cache *cache,
arm_gdbarch_tdep *tdep, CORE_ADDR val)
{
- if (cache->active_sp_regnum == ARM_SP_REGNUM)
- {
- cache->sp = val;
- return;
- }
-
if (tdep->have_sec_ext)
{
if (cache->active_sp_regnum == tdep->m_profile_msp_s_regnum)
@@ -458,6 +455,11 @@ arm_cache_set_active_sp_value (struct arm_prologue_cache *cache,
return;
}
+ else if (cache->active_sp_regnum == ARM_SP_REGNUM)
+ {
+ cache->sp = val;
+ return;
+ }
gdb_assert_not_reached ("Invalid SP selection");
}